mercury-agent 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/docs/autopilot/config.yaml +5 -1
- package/docs/configuration.md +54 -2
- package/docs/container-lifecycle.md +18 -3
- package/docs/extensions.md +73 -0
- package/docs/goals/football-reporter-profile/decisions.md +104 -1
- package/docs/goals/football-reporter-profile/harness-2026-09-01.json +303 -0
- package/docs/goals/football-reporter-profile/harness-2026-09-01.md +75 -0
- package/docs/goals/football-reporter-profile/roadmap.md +12 -9
- package/docs/goals/rehearsal-bench/README.md +253 -0
- package/docs/goals/rehearsal-bench/decisions.md +398 -0
- package/docs/goals/rehearsal-bench/goal.md +198 -0
- package/docs/goals/rehearsal-bench/roadmap.md +173 -0
- package/docs/goals/release-gate/README.md +58 -0
- package/docs/goals/release-gate/decisions.md +112 -0
- package/docs/goals/release-gate/goal.md +146 -0
- package/docs/goals/release-gate/roadmap.md +115 -0
- package/docs/goals/whatsapp-bot-hardening/open-threads.md +21 -10
- package/docs/live-testing.md +368 -0
- package/docs/pending-verification.md +822 -0
- package/docs/profile-guide.md +38 -2
- package/docs/skills-guide.md +31 -0
- package/docs/web-search.md +3 -1
- package/examples/extensions/archive/README.md +146 -0
- package/examples/extensions/archive/backends/drive.ts +486 -0
- package/examples/extensions/archive/backends/local.ts +180 -0
- package/examples/extensions/archive/backends/types.ts +82 -0
- package/examples/extensions/archive/capability.ts +252 -0
- package/examples/extensions/archive/gc.ts +225 -0
- package/examples/extensions/archive/index.ts +324 -0
- package/examples/extensions/archive/inflight.ts +65 -0
- package/examples/extensions/archive/manifest.ts +310 -0
- package/examples/extensions/archive/queue.ts +435 -0
- package/examples/extensions/archive/skill/SKILL.md +59 -0
- package/examples/extensions/feed-watch/watch.ts +63 -3
- package/examples/extensions/longview/hook.ts +12 -6
- package/examples/extensions/longview/index.ts +47 -11
- package/examples/extensions/longview/render/images.ts +214 -0
- package/examples/extensions/longview/render/telegraph-nodes.ts +61 -1
- package/examples/extensions/longview/summarize.ts +46 -7
- package/examples/extensions/longview/targets/telegraph.ts +55 -2
- package/examples/extensions/morning/README.md +126 -0
- package/examples/extensions/morning/index.ts +174 -0
- package/examples/extensions/morning/lib/hosts.ts +75 -0
- package/examples/extensions/morning/lib/issue-token.ts +298 -0
- package/examples/extensions/morning/lib/morning.ts +515 -0
- package/examples/extensions/morning/lib/token.ts +282 -0
- package/examples/extensions/morning/skill/SKILL.md +144 -0
- package/examples/extensions/morning/skill/references/document-types.md +97 -0
- package/examples/extensions/morning/skill/references/errors.md +255 -0
- package/examples/extensions/napkin/distill-input.ts +127 -0
- package/examples/extensions/napkin/distill-safety.ts +495 -0
- package/examples/extensions/napkin/index.ts +54 -73
- package/examples/extensions/napkin/pi-spawn.ts +8 -28
- package/examples/extensions/tradestation/index.ts +9 -4
- package/examples/extensions/web-search/brave.ts +324 -0
- package/examples/extensions/web-search/index.ts +53 -1
- package/examples/extensions/web-search/skill/SKILL.md +50 -12
- package/examples/extensions/yahoo-mail/index.ts +42 -10
- package/examples/extensions/yahoo-mail/lib/ymail.ts +592 -0
- package/examples/extensions/yahoo-mail/{cli/package.json → package.json} +1 -4
- package/examples/extensions/yahoo-mail/skill/SKILL.md +36 -21
- package/examples/profiles/football-reporter/AGENTS.md +8 -3
- package/examples/profiles/football-reporter/README.md +118 -1
- package/examples/profiles/football-reporter/config.yaml +28 -13
- package/examples/profiles/football-reporter/standard.json +137 -0
- package/examples/profiles/football-reporter/tasks/daily-article.md +74 -47
- package/package.json +10 -3
- package/resources/templates/mercury.example.yaml +4 -0
- package/src/adapters/discord-native.ts +7 -0
- package/src/adapters/setup.ts +33 -0
- package/src/adapters/whatsapp-identity.ts +77 -0
- package/src/adapters/whatsapp-ingress.ts +325 -0
- package/src/adapters/whatsapp.ts +119 -182
- package/src/agent/container-entry.ts +2 -0
- package/src/agent/container-env.ts +10 -0
- package/src/agent/container-error.ts +13 -1
- package/src/agent/container-runner.ts +742 -146
- package/src/audit/ledger-queries.ts +345 -0
- package/src/bridges/discord.ts +4 -1
- package/src/bridges/slack.ts +1 -1
- package/src/bridges/teams.ts +1 -1
- package/src/bridges/telegram.ts +1 -1
- package/src/bridges/whatsapp.ts +3 -5
- package/src/cli/mercury.ts +585 -9
- package/src/cli/mrctl-http.ts +18 -0
- package/src/cli/mrctl.ts +11 -4
- package/src/config-file.ts +8 -0
- package/src/config.ts +98 -2
- package/src/core/debounce.ts +10 -5
- package/src/core/exec.ts +75 -0
- package/src/core/handler.ts +30 -13
- package/src/core/model-leg.ts +41 -0
- package/src/core/process-tree.ts +24 -18
- package/src/core/reply-context.ts +5 -0
- package/src/core/routes/capability.ts +4 -1
- package/src/core/routes/chat.ts +13 -1
- package/src/core/routes/control.ts +2 -2
- package/src/core/routes/dashboard.ts +2 -2
- package/src/core/runtime.ts +221 -46
- package/src/core/storage-cleanup.ts +59 -0
- package/src/core/trigger.ts +10 -4
- package/src/extensions/catalog.ts +18 -0
- package/src/extensions/hooks.ts +8 -2
- package/src/extensions/image-builder.ts +33 -51
- package/src/extensions/types.ts +46 -1
- package/src/logger.ts +27 -2
- package/src/main.ts +40 -5
- package/src/ops/preflight.ts +227 -0
- package/src/ops/shadow-root.ts +234 -0
- package/src/ops/shadow-snapshot.ts +1076 -0
- package/src/profile/space-profile.ts +48 -5
- package/src/server.ts +80 -25
- package/src/storage/backup.ts +403 -0
- package/src/storage/db.ts +30 -3
- package/src/storage/integrity.ts +94 -0
- package/src/text/markdown.ts +72 -1
- package/src/text/reporter-lint.ts +1607 -0
- package/src/text/write-claim.ts +68 -0
- package/src/types.ts +32 -2
- package/examples/extensions/yahoo-mail/cli/bun.lock +0 -66
- package/examples/extensions/yahoo-mail/cli/ymail.mjs +0 -353
package/README.md
CHANGED
|
@@ -167,6 +167,7 @@ Install extensions from the dashboard (**Features** page), the CLI, or during se
|
|
|
167
167
|
```bash
|
|
168
168
|
# From the CLI
|
|
169
169
|
mercury add web-browser # Web browsing & search (uses Brave Search, no API key needed)
|
|
170
|
+
mercury add web-search # Brave Search API + site search skill (key stays on the host)
|
|
170
171
|
mercury add napkin # Obsidian-style knowledge vault
|
|
171
172
|
|
|
172
173
|
# Or pick a profile that bundles what you need
|
|
@@ -267,6 +268,12 @@ mercury conversations
|
|
|
267
268
|
mercury conversations --unlinked
|
|
268
269
|
mercury link <conversation-id> <space-id>
|
|
269
270
|
|
|
271
|
+
# backups (state.db snapshots — also taken automatically by the running service)
|
|
272
|
+
mercury backup create # verified VACUUM INTO snapshot in <dataDir>/backups/
|
|
273
|
+
mercury backup list
|
|
274
|
+
mercury backup verify [snapshot] # quick_check a snapshot (default: newest)
|
|
275
|
+
mercury restore <snapshot> # verify + restore to a fresh path (never overwrites)
|
|
276
|
+
|
|
270
277
|
# extensions
|
|
271
278
|
mercury add ./path/to/extension
|
|
272
279
|
mercury add npm:<package>
|
|
@@ -430,10 +437,11 @@ Supported OAuth providers: Anthropic, GitHub Copilot, Google Gemini CLI, Antigra
|
|
|
430
437
|
> true` in `mercury.yaml`) to accept the trade knowingly — it is then logged at
|
|
431
438
|
> `warn` on every spawn. **Upgrading an existing Docker Desktop install requires
|
|
432
439
|
> this**, or every message gets a generic container failure. Linux hosts are
|
|
433
|
-
> unaffected; `MERCURY_CONTAINER_RUNTIME=runsc` (
|
|
434
|
-
>
|
|
440
|
+
> unaffected; `MERCURY_CONTAINER_RUNTIME=runsc` (or `agent.container_runtime:
|
|
441
|
+
> runsc` in `mercury.yaml`; gVisor) avoids the relaxation entirely, and the
|
|
442
|
+
> flag is ignored when `container_bwrap_docker_compat` is set.
|
|
435
443
|
|
|
436
|
-
> **Linux Docker Engine:** Mercury uses [bubblewrap](https://github.com/containers/bubblewrap) for in-container sandboxing. On Linux Docker Engine (not Docker Desktop), bwrap cannot mount `/proc` without extra privileges. Either set `container_bwrap_docker_compat: true` in `mercury.yaml` (adds `--privileged` to `docker run`), or install [gVisor](https://gvisor.dev/docs/user_guide/install/) and set `MERCURY_CONTAINER_RUNTIME=runsc` to skip bwrap entirely.
|
|
444
|
+
> **Linux Docker Engine:** Mercury uses [bubblewrap](https://github.com/containers/bubblewrap) for in-container sandboxing. On Linux Docker Engine (not Docker Desktop), bwrap cannot mount `/proc` without extra privileges. Either set `container_bwrap_docker_compat: true` in `mercury.yaml` (adds `--privileged` to `docker run`), or install [gVisor](https://gvisor.dev/docs/user_guide/install/) and set `MERCURY_CONTAINER_RUNTIME=runsc` (or `agent.container_runtime: runsc` in `mercury.yaml`) to skip bwrap entirely.
|
|
437
445
|
|
|
438
446
|
**KB Distillation:**
|
|
439
447
|
|
|
@@ -31,7 +31,11 @@ scope:
|
|
|
31
31
|
# Both are design decisions, not mechanical fixes, and neither is verifiable
|
|
32
32
|
# by the check suite. See docs/bugs/ for the filed reports.
|
|
33
33
|
- docker-desktop-sandbox-relaxation-silent # fix = a product call: warn, or refuse and break Docker Desktop users
|
|
34
|
-
|
|
34
|
+
# container-egress-unrestricted moved to docs/ideas/ on 2026-09-01 -- the
|
|
35
|
+
# two-container split it proposed was ruled out by investigation. Its one
|
|
36
|
+
# remaining code-shaped piece is env-passthrough-defaults-to-all, below.
|
|
37
|
+
- env-passthrough-defaults-to-all # breaking default change: needs the owner'''s go-ahead and a week of startup-log evidence first
|
|
38
|
+
- linux-default-sandbox-path-broken-on-modern-docker # product call on the relaxation shape; unverifiable by the check suite (container spawn flags)
|
|
35
39
|
# attachment-ingest-type-gating — unblocked 2026-08-27 (warn-only decision
|
|
36
40
|
# recorded in the spec). Eligible once it is listed under ROADMAP Now/Next.
|
|
37
41
|
|
package/docs/configuration.md
CHANGED
|
@@ -85,6 +85,58 @@ Per-space: `mrctl config set ambient.enabled false` disables capture entirely (t
|
|
|
85
85
|
|
|
86
86
|
You may also set a top-level **`model_chain`** array as an alias for `model.chain`.
|
|
87
87
|
|
|
88
|
+
## State database backups
|
|
89
|
+
|
|
90
|
+
`state.db` is snapshotted by the storage sweep via `VACUUM INTO
|
|
91
|
+
<dataDir>/backups/state-<timestamp>.db`. Every snapshot is verified
|
|
92
|
+
(`PRAGMA quick_check`) before it counts; a crash mid-snapshot leaves only a
|
|
93
|
+
`.partial` file that is never mistaken for a backup and is swept later.
|
|
94
|
+
|
|
95
|
+
- **`MERCURY_BACKUP_INTERVAL_HOURS`** (default `12`) — a new snapshot is taken
|
|
96
|
+
once the newest one is at least this old.
|
|
97
|
+
- **`MERCURY_BACKUP_RETENTION_COUNT`** (default `7`) — snapshots kept; older
|
|
98
|
+
ones are pruned by the same sweep.
|
|
99
|
+
|
|
100
|
+
`mercury backup create | list | verify` manages snapshots by hand;
|
|
101
|
+
`mercury restore <snapshot>` verifies a snapshot and writes it to a **fresh
|
|
102
|
+
path only** (default `<dataDir>/state.restored-<timestamp>.db`) — it never
|
|
103
|
+
overwrites the live database, and prints the manual swap-in steps.
|
|
104
|
+
|
|
105
|
+
`mercury doctor` **fails** when no snapshot at most 24 h old exists (a missing
|
|
106
|
+
backups directory included), and warns when the data dir sits on a
|
|
107
|
+
9p/virtiofs/CIFS filesystem (a `.mercury/` under `/mnt/c` in WSL2, or a VM
|
|
108
|
+
shared folder) — SQLite WAL locking is unreliable there.
|
|
109
|
+
|
|
110
|
+
The database itself refuses to open when `quick_check` fails — loudly, with a
|
|
111
|
+
typed error, never auto-repaired. The fix is `mercury restore`.
|
|
112
|
+
|
|
113
|
+
## Shadow mode (`MERCURY_SHADOW`)
|
|
114
|
+
|
|
115
|
+
**`MERCURY_SHADOW`** (default off; accepts only `1` or `true`,
|
|
116
|
+
case-insensitively — every other spelling, `yes` and `on` included, means
|
|
117
|
+
live) turns a process into a *rehearsal shadow*: it constructs no platform
|
|
118
|
+
adapter, makes no console billing call, delivers no task output, marks every
|
|
119
|
+
log line and the dashboard, and reports `shadow: true` on `/health`.
|
|
120
|
+
|
|
121
|
+
**A shadow refuses to start unless its data dir is inside
|
|
122
|
+
`<home>/mercury-shadow/`.** The flag keeps a shadow away from people; this
|
|
123
|
+
keeps it away from live *state*. Without it, `MERCURY_SHADOW=1` started in
|
|
124
|
+
the live project directory would construct no adapter and touch no session
|
|
125
|
+
while running a **second scheduler against the live database** — every due
|
|
126
|
+
task fires twice and SQLite gets a second writer.
|
|
127
|
+
|
|
128
|
+
The check runs in `loadConfig()`, so every entry point inherits it, and it
|
|
129
|
+
denies on absence at each input: no home directory (a systemd unit with no
|
|
130
|
+
`HOME`), a relative data dir, a `..` segment, the shadow root itself, a path
|
|
131
|
+
outside the root, or an existing directory whose `realpath` escapes the root.
|
|
132
|
+
It compares path *segments*, never string prefixes, so `mercury-shadowy` is
|
|
133
|
+
not inside `mercury-shadow`. A live process (`MERCURY_SHADOW` unset) is never
|
|
134
|
+
checked and runs exactly the code it ran before.
|
|
135
|
+
|
|
136
|
+
Snapshot directories are built by `mercury shadow snapshot`, which generates
|
|
137
|
+
the shadow's `.env` and `mercury.yaml` — nothing here needs to be set by
|
|
138
|
+
hand. See [live-testing.md](live-testing.md) §2 and §7.
|
|
139
|
+
|
|
88
140
|
## Container env passthrough (`agent.env_passthrough`)
|
|
89
141
|
|
|
90
142
|
Controls which host `MERCURY_*` variables reach agent containers:
|
|
@@ -94,7 +146,7 @@ agent:
|
|
|
94
146
|
env_passthrough: all # all (default) | claimed
|
|
95
147
|
```
|
|
96
148
|
|
|
97
|
-
- **`all`** — every `MERCURY_*` var except a fixed blocklist is passed into the container with the prefix stripped (`
|
|
149
|
+
- **`all`** — every `MERCURY_*` var except a fixed blocklist is passed into the container with the prefix stripped (`MERCURY_BILLING_API_KEY` → `BILLING_API_KEY`). Convenient, but blunt: a secret added to `.env` for one purpose reaches **every space's container**, regardless of who triggered the turn or whether that space has anything to do with it. Vars an extension declares `hostOnly` are excluded even here — `MERCURY_BRAVE_API_KEY` stays on the host once `web-search` is installed, which brokers Brave queries through `mrctl capability web-search`.
|
|
98
150
|
- **`claimed`** — only variables an extension declared via `mercury.env()` are passed, and only when the triggering caller holds that extension's permission. Undeclared variables stay on the host.
|
|
99
151
|
|
|
100
152
|
**Model-provider credentials are exempt** and pass in both modes (`MERCURY_ANTHROPIC_API_KEY`, `MERCURY_ANTHROPIC_OAUTH_TOKEN`, `MERCURY_GEMINI_API_KEY`, `MERCURY_GROQ_API_KEY`, and the rest of the provider list). pi reads them inside the container, and no extension declares them — without the exemption, `claimed` would leave the agent unable to reach any model. They remain subject to the blocklist.
|
|
@@ -104,7 +156,7 @@ Env: `MERCURY_CONTAINER_ENV_PASSTHROUGH`.
|
|
|
104
156
|
`claimed` is opt-in because it breaks setups that rely on blind passthrough for anything other than provider keys — API keys consumed by skills (search, TTS, scrapers) and any credential you added by hand. To migrate, declare those in an extension (see [extensions.md](extensions.md)) before switching. At startup with `all`, Mercury logs the vars it is passing that are neither declared nor provider credentials — names only, so a genuine outlier stands out:
|
|
105
157
|
|
|
106
158
|
```
|
|
107
|
-
Container env passthrough: all — these vars reach every space's container and are scoped to nothing. […] vars=
|
|
159
|
+
Container env passthrough: all — these vars reach every space's container and are scoped to nothing. […] vars=MERCURY_SCRAPER_API_KEY, MERCURY_BILLING_API_KEY
|
|
108
160
|
```
|
|
109
161
|
|
|
110
162
|
For secrets that only host-side hooks and jobs need, prefer `mercury.env({ from: "…", hostOnly: true })`, which keeps them out of containers in either mode. For credentials the agent should never hold at all, use a host-side capability handler (`mercury.capability()`), which runs the privileged call on the host and returns only the result.
|
|
@@ -191,14 +191,29 @@ The pi agent runs inside `bwrap`, which creates a minimal mount namespace with o
|
|
|
191
191
|
|
|
192
192
|
| Env Var | Purpose |
|
|
193
193
|
|---------|---------|
|
|
194
|
-
| `MERCURY_CONTAINER_BWRAP_DOCKER_COMPAT=1` | **Host only.**
|
|
195
|
-
| `MERCURY_CONTAINER_ALLOW_UNCONFINED=true` | **Host only.** Accepts the *auto-detected* Docker Desktop relaxation (
|
|
194
|
+
| `MERCURY_CONTAINER_BWRAP_DOCKER_COMPAT=1` | **Host only.** Runs the agent container `--privileged` — Docker's widest grant (every capability, no seccomp, no AppArmor, all devices) — so `bwrap` can nest inside it. Keeps bubblewrap on, but the outer isolation layer is gone. Prefer `MERCURY_CONTAINER_RUNTIME=runsc`. |
|
|
195
|
+
| `MERCURY_CONTAINER_ALLOW_UNCONFINED=true` | **Host only.** Accepts the *auto-detected* Docker Desktop relaxation (`seccomp=unconfined`, `apparmor=unconfined`, `--cap-add SYS_ADMIN` — narrower than `--privileged`). Defaults to `false`, so on Docker Desktop containers refuse to start until it is set — the relaxation is never applied without the operator seeing it. Logged at `warn` on every spawn once enabled. Ignored under `runsc` and when `BWRAP_DOCKER_COMPAT` is set. |
|
|
196
196
|
| `MERCURY_DISABLE_BUBBLEWRAP=1` | Disable bubblewrap; run pi directly (last resort / debugging) |
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
**On a stock Linux host the default shape cannot run bwrap.** Docker's default seccomp profile blocks the user-namespace clone and Ubuntu's `docker-default` AppArmor profile independently blocks bwrap's mount step, so every turn fails with `bwrap: No permissions to create new namespace` (or `Creating new namespace failed: Operation not permitted`). On a stock modern host the kernel sysctls that message points at (`unprivileged_userns_clone`, `max_user_namespaces`) are not the blocker — both gates are Docker's; check them only if they are off their defaults. Mercury probes for this once at boot (`docker run --entrypoint bwrap …` with the real bwrap shape) and, if blocked, logs one `error` line naming the fix and refuses every spawn with the same diagnosis instead of a per-turn bwrap error. Escapes, narrowest first: `MERCURY_CONTAINER_RUNTIME=runsc` (gVisor — strongest sandbox, no relaxation needed), then `MERCURY_CONTAINER_BWRAP_DOCKER_COMPAT=1` (`--privileged`), then `MERCURY_DISABLE_BUBBLEWRAP=1` (no inner sandbox at all).
|
|
199
199
|
|
|
200
200
|
Custom images must install `bubblewrap` for sandboxing to work.
|
|
201
201
|
|
|
202
|
+
**runsc (gVisor) mode requires `--host-uds=open` on the runtime registration.** In runsc mode the agent container reaches the host API over a bind-mounted unix socket — the socket is mrctl's *only* transport there (`API_URL` is a deliberate dummy). gVisor refuses `connect()` to host unix sockets unless the daemon registers runsc with the flag:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"runtimes": {
|
|
207
|
+
"runsc": {
|
|
208
|
+
"path": "/usr/bin/runsc",
|
|
209
|
+
"runtimeArgs": ["--host-uds=open"]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Without it, Mercury starts clean and containers run, but **every mrctl verb fails** (config, tasks, mutes, stop, capabilities — the whole host API surface) with a bare connect error inside the conversation. Mercury probes for this once at boot (a runsc container connect-tests the socket with the real spawn's mount shape) and, if blocked, logs one `error` line naming this fix. Applying it is zero-downtime: `runtimes` is a SIGHUP-reloadable daemon.json key, so edit the file and `kill -SIGHUP $(pidof dockerd)` — no daemon restart, no container kills.
|
|
216
|
+
|
|
202
217
|
## Agent Image Preset
|
|
203
218
|
|
|
204
219
|
Mercury publishes an image preset to GitHub Container Registry:
|
package/docs/extensions.md
CHANGED
|
@@ -160,6 +160,7 @@ mercury.on("workspace_init", async (event, ctx) => {
|
|
|
160
160
|
| `workspace_init` | Space workspace created/ensured | No |
|
|
161
161
|
| `before_container` | About to spawn container | Yes |
|
|
162
162
|
| `after_container` | Container finished | Yes |
|
|
163
|
+
| `delivery` | Reply stored, attachments final | No |
|
|
163
164
|
|
|
164
165
|
Both `workspace_init` and `before_container` events include:
|
|
165
166
|
- `workspace` — absolute host path (for file operations on the host)
|
|
@@ -198,6 +199,34 @@ mercury.on("after_container", async (event, ctx) => {
|
|
|
198
199
|
});
|
|
199
200
|
```
|
|
200
201
|
|
|
202
|
+
#### `delivery` — what the user actually received
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
mercury.on("delivery", async (event, ctx) => {
|
|
206
|
+
// event.files — exactly what the adapter will attach
|
|
207
|
+
// event.withheld — what the media gate stripped
|
|
208
|
+
// event.userMessageId / event.assistantMessageId — both rows exist
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Use this, not `after_container`, whenever a hook needs to know **what was
|
|
213
|
+
delivered**. `after_container` fires *before* the media send gate and can still
|
|
214
|
+
rewrite the reply, so its file list is a proposal: a handler reading it cannot
|
|
215
|
+
tell whether the recipient was actually shown those files. `delivery` fires
|
|
216
|
+
after the gate and after the assistant row is written.
|
|
217
|
+
|
|
218
|
+
It is non-mutating — by the time it runs, the reply has been decided — and it
|
|
219
|
+
does not fire on paths where nothing reaches the user: a suppressed reply, or a
|
|
220
|
+
scheduler no-op. Handler errors are logged and isolated, so a failing handler
|
|
221
|
+
costs a log line and never the reply.
|
|
222
|
+
|
|
223
|
+
`event.withheld` exists so a handler can tell "withheld" from "never produced".
|
|
224
|
+
Never treat a withheld file as delivered: the gate replaces the file array
|
|
225
|
+
rather than annotating it, so this is the only place that distinction survives.
|
|
226
|
+
|
|
227
|
+
The `archive` extension is the worked example
|
|
228
|
+
([`examples/extensions/archive/`](../examples/extensions/archive/)).
|
|
229
|
+
|
|
201
230
|
### `mercury.job(name, def)`
|
|
202
231
|
|
|
203
232
|
Register a background job that runs on the host.
|
|
@@ -440,6 +469,50 @@ The skill is installed into the management space's own workspace on
|
|
|
440
469
|
dir mounted into *every* container, which would advertise the capability to
|
|
441
470
|
spaces that cannot use it.
|
|
442
471
|
|
|
472
|
+
## Morning / Green Invoice invoicing (`morning`)
|
|
473
|
+
|
|
474
|
+
`examples/extensions/morning/` issues tax documents through the
|
|
475
|
+
[Morning](https://morning.co) API. Second `mercury.capability()` adopter after
|
|
476
|
+
yahoo-mail, and the case that justifies rung 4: these credentials create legally
|
|
477
|
+
binding documents against a real business, so they never enter a container.
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
mercury add ./examples/extensions/morning
|
|
481
|
+
MERCURY_MORNING_CLIENT_ID=... # hostOnly
|
|
482
|
+
MERCURY_MORNING_CLIENT_SECRET=... # hostOnly
|
|
483
|
+
mrctl config set morning.environment sandbox # or production; sandbox is the default
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
The agent calls it with `mrctl capability morning <action> '<json>'`:
|
|
487
|
+
|
|
488
|
+
| Action | Body | Returns |
|
|
489
|
+
|--------|------|---------|
|
|
490
|
+
| `client-search` | `{name?, email?, page?, pageSize?}` | paginated clients |
|
|
491
|
+
| `client-create` | `{name, taxId?, emails?, …}` | the new client |
|
|
492
|
+
| `document-types` | `{lang?}` | `[{id, name}]`, localised |
|
|
493
|
+
| `document-preview` | the document body | `{file, issueToken}` — base64 PDF, nothing created |
|
|
494
|
+
| `document-create` | the same body **plus `issueToken`** | `{id, number, url}` |
|
|
495
|
+
| `document-search` | `{fromDate?, toDate?, type?, …}` | paginated documents |
|
|
496
|
+
| `document-links` | `{id}` | `{origin, he, en}` |
|
|
497
|
+
|
|
498
|
+
Two properties are enforced in the broker rather than requested in the skill:
|
|
499
|
+
|
|
500
|
+
- **Preview before issue.** `document-create` refuses without a single-use
|
|
501
|
+
`issueToken` minted by `document-preview` of the *identical* payload. The
|
|
502
|
+
token is bound to the payload hash, the environment, the space and the caller,
|
|
503
|
+
so a changed amount, a sandbox-previewed document presented against
|
|
504
|
+
production, another person's preview, or a retry after a successful create are
|
|
505
|
+
each refused. A prompt instruction is not a control when the model may be the
|
|
506
|
+
thing under attack.
|
|
507
|
+
- **`sensitive: true`.** In a group-linked space the runtime then requires
|
|
508
|
+
`security.sensitive_connections_allowed` plus per-caller confirmation. Set that
|
|
509
|
+
key or the space refuses every turn — the symptom otherwise reads as a broken
|
|
510
|
+
extension.
|
|
511
|
+
|
|
512
|
+
Slice 1 is invoices. Expenses are deferred: `POST /expenses` requires an
|
|
513
|
+
`accountingClassification` whose lookup endpoint is absent from the published
|
|
514
|
+
spec, and an uploaded file becomes a draft with no API to approve it.
|
|
515
|
+
|
|
443
516
|
## Examples
|
|
444
517
|
|
|
445
518
|
See [`examples/extensions/`](../examples/extensions/) for complete, working extensions ranging from minimal (charts — CLI + skill) to full-featured (napkin — hooks, jobs, config, widgets, KB distillation).
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
implementing: `## Current State (as of …)` is not matched by the injector, so
|
|
476
476
|
every note napkin had written for this space was reaching the model as a
|
|
477
477
|
summary line with no facts —
|
|
478
|
-
`docs/debug/major/2026-08-31-episode-current-state-heading-suffix-drops-body.md`.
|
|
478
|
+
`docs/debug/major/08-2026/2026-08-31-episode-current-state-heading-suffix-drops-body.md`.
|
|
479
479
|
- **Used by:** reporter-notebook (M2.3, re-cut), football-reporter-fixture-harness (provenance source = `episodes/`), napkin (distill addendum)
|
|
480
480
|
|
|
481
481
|
## D-020: Live tuning is adopted into the repo, not reverted — and scans carry a fixed club emoji (decided 2026-08-31)
|
|
@@ -513,3 +513,106 @@
|
|
|
513
513
|
- **Revisit if:** live edits become frequent — then the right tool is a
|
|
514
514
|
profile PR flow from the box (edit → `dump` → commit), not a rule.
|
|
515
515
|
- **Used by:** football-reporter profile (`AGENTS.md`), football-reporter-fixture-harness (M3.1 lint spec)
|
|
516
|
+
|
|
517
|
+
## D-021: The daily article is an article, not a page of bins (decided 2026-09-01)
|
|
518
|
+
- **Category:** article contract / design (extends [D-005](#d-005-keep-telegraph-make-the-summary-fuller-and-redesign-the-article-itself-decided-2026-08-20), [D-010](#d-010-the-chat-summary-is-author-supplied-by-the-same-run-not-a-second-model-call); refines [D-013](#d-013-tone-is-editorial-and-scan-length-is-per-item-decided-2026-08-20))
|
|
519
|
+
- **Decided:** The owner opened the 2026-09-01 page on a phone (RTL fine) and
|
|
520
|
+
ruled the design wrong: *"it still looks too much like an itinerary and not
|
|
521
|
+
an article."* Eight prototype pages were published and compared on the phone
|
|
522
|
+
the same evening; prototype **C5** is the target shape. Five rulings:
|
|
523
|
+
1. **Images are in**, but only when the image is good and relevant, and it
|
|
524
|
+
must not take over the page. C2 (one wide banner) beat C1 (none); C4/C5
|
|
525
|
+
(a press photo) beat both.
|
|
526
|
+
2. **Side-by-side is dropped** — a platform limit, not a preference.
|
|
527
|
+
Telegraph strips every attribute except `src` and unwraps a `div`, so an
|
|
528
|
+
image beside text is impossible; footprint is controlled by aspect ratio
|
|
529
|
+
only (a 4.5:1 banner is ~85 px tall on a phone, a portrait ~430 px).
|
|
530
|
+
3. **Press photos are allowed**, hotlinked from the cited source and credited
|
|
531
|
+
in the caption. `telegra.ph/upload` answers 400, so hotlinking is the only
|
|
532
|
+
path anyway.
|
|
533
|
+
4. **The long source list goes.** Short bracketed links inline —
|
|
534
|
+
`([וואלה](url))` — plus **one** italic footer line naming every outlet
|
|
535
|
+
read. The footer line stays.
|
|
536
|
+
5. **Stay on Telegraph.** A richer target (real CSS, images beside text,
|
|
537
|
+
cards) is possible through `longview`'s `targets/` seam but needs a host
|
|
538
|
+
and is a separate project.
|
|
539
|
+
|
|
540
|
+
And four image rules, learned by publishing a wrong one (C4's hero showed
|
|
541
|
+
Anthony Gordon under a caption, written from assumption, naming Álvarez):
|
|
542
|
+
the image URL is the cited article's `og:image`; the caption is the source's
|
|
543
|
+
own caption, translated, never re-described — it lives in the article HTML,
|
|
544
|
+
not the RSS; no caption at the source means no image; the photo sits in the
|
|
545
|
+
section whose story it depicts, not automatically at the top (C5 is C4 with
|
|
546
|
+
only that changed). Wikimedia Commons is not a substitute: wide and relevant
|
|
547
|
+
are mutually exclusive there.
|
|
548
|
+
|
|
549
|
+
Two consequences the owner confirmed on 2026-09-01 when the story was
|
|
550
|
+
planned: the per-article "first three blocks get similar length" measure no
|
|
551
|
+
longer applies — the lead story leads, and the coverage balance in
|
|
552
|
+
`AGENTS.md` § תפקיד is a rule about coverage over time; and the
|
|
553
|
+
`DD.MM.YYYY · N מקורות` dateline goes, replaced by Telegraph's own
|
|
554
|
+
author-and-date block under the headline (`author_name`, empty on every page
|
|
555
|
+
published so far, is free article furniture).
|
|
556
|
+
- **Alternatives considered:**
|
|
557
|
+
- *Typography only, words unchanged (prototype A).* Better, and most of it
|
|
558
|
+
needs no code — `>>`, `---` and numbered lists are already in the
|
|
559
|
+
renderer. Not enough on its own: the bins are the tell, not the type.
|
|
560
|
+
- *Keep the eight blocks and drop only the empty ones.* Rejected: the same
|
|
561
|
+
headings in the same order every day is what reads as generated, whether
|
|
562
|
+
or not a bin is empty.
|
|
563
|
+
- *Images beside text via `h3`/`h4` level or `div` wrappers.* Measured
|
|
564
|
+
impossible (rule 2). Heading level is not a lever either: `h3` is 28 px,
|
|
565
|
+
`h4` 24 px, both sans-bold.
|
|
566
|
+
- *Commons images.* Every wide result is a stadium panorama, every usable
|
|
567
|
+
player photo a portrait, nothing of *yesterday's* match.
|
|
568
|
+
- **Reasoning:** the contract shipped by M1.2 is followed correctly — every
|
|
569
|
+
element renders — and the page still reads as a log because the contract
|
|
570
|
+
itself is a list of bins. The fix is the contract, and since M3.1 the
|
|
571
|
+
contract is countable, so the lint, its data file and its fixtures move in
|
|
572
|
+
the same change or the check goes green for the wrong reason.
|
|
573
|
+
- **Revisit if:** the model gets captions wrong in practice (then `longview`
|
|
574
|
+
fetches `og:image` and the caption host-side instead of the run emitting
|
|
575
|
+
them), or a private target with real CSS gets a host (then ruling 5).
|
|
576
|
+
- **Used by:** daily-article-design-follow-up (M1.3), football-reporter
|
|
577
|
+
profile (`tasks/daily-article.md`, `AGENTS.md` § שתיקה, `config.yaml`
|
|
578
|
+
`longview.byline`), football-reporter-fixture-harness (M3.1 lint
|
|
579
|
+
`article-structure` / `article-image`)
|
|
580
|
+
|
|
581
|
+
## D-022: M2.2 is closed as accepted by construction, with two revisit triggers (decided 2026-09-01)
|
|
582
|
+
- **Category:** scope / sequencing (closes [D-015](#d-015-m22-is-deferred-until-after-m31-not-dropped-decided-2026-08-21); keeps [D-006](#d-006-scheduled-research-runs-post-from-the-primary-model-leg-or-not-at-all) as the standing rule)
|
|
583
|
+
- **Decided:** `scheduled-task-model-leg-policy` (M2.2) is **closed**, not
|
|
584
|
+
built. The property it was written for — a scheduled research run posts from
|
|
585
|
+
the primary leg or not at all — has held by construction since the
|
|
586
|
+
2026-08-20 pin: every space carries a `model.active` row, the runtime turns
|
|
587
|
+
it into a one-element chain, a leg failure is a task error that retries and
|
|
588
|
+
reports to the admin and posts nothing, and the M3.2 ledger records the
|
|
589
|
+
model of every run. The backlog doc moves to `docs/ideas/` with its design
|
|
590
|
+
intact, re-labelled as what the same column is really worth: **per-task
|
|
591
|
+
model choice** (the article on one leg, verify runs on another — the Opus
|
|
592
|
+
A/B that was never started), with the safety property as a side effect.
|
|
593
|
+
- **Revisit triggers (either reopens it, as a prerequisite, not an option):**
|
|
594
|
+
1. anyone clears a `model.active` pin, or a `/model reset` verb is built —
|
|
595
|
+
the fix the `model-switch-disables-fallback` bug asks for. That verb must
|
|
596
|
+
not ship before a scheduled-run guard exists; the bug doc now says so.
|
|
597
|
+
2. the ledger records a scheduled run on a non-primary leg.
|
|
598
|
+
- **Alternatives considered:**
|
|
599
|
+
- *Build it as designed* (nullable `tasks.model_policy`, `primary_only`, a
|
|
600
|
+
`skipped` status, one truncation site). Sound, about a session of work,
|
|
601
|
+
and it buys nothing while the pin policy stands. Rejected for now, not on
|
|
602
|
+
merit.
|
|
603
|
+
- *Keep it deferred a third time.* Rejected: D-015's own revisit condition
|
|
604
|
+
(M3.1 in hand) has been met and the doc's open question — is this worth
|
|
605
|
+
its cost while every space is pinned — had gone unanswered since
|
|
606
|
+
2026-08-20. A story that cannot be scheduled or dropped is noise on the
|
|
607
|
+
roadmap.
|
|
608
|
+
- *Re-cut it as per-task model choice now.* Not rejected — parked as the
|
|
609
|
+
idea, to be planned on its own merits if the article A/B is wanted.
|
|
610
|
+
- **Reasoning:** the pin was a deliberate choice ("Opus-only, no fallback,
|
|
611
|
+
all legs switchable", 2026-08-20), not an accident to be guarded against.
|
|
612
|
+
The cost argument for re-opening died with the digest-replay fix
|
|
613
|
+
(M2 checkpoint, 2026-08-31). What remained was a guarantee against a future
|
|
614
|
+
the owner has not asked for, and that future has a clear trigger. 300-plus
|
|
615
|
+
scheduled runs since the pin, zero on a non-primary leg.
|
|
616
|
+
- **Used by:** football-reporter-profile roadmap (M2.2 row),
|
|
617
|
+
`docs/bugs/model-switch-disables-fallback.md` (the reset-verb constraint),
|
|
618
|
+
`docs/ideas/scheduled-task-model-leg-policy.md`
|