Coach: the Claude provider, and an AI runtime you only carry if you ask
The Agent SDK adapter, its dependency, and the packaging that keeps both out of the image an owner gets when they never wanted the Coach. api/Dockerfile builds two targets. The default one runs `npm ci --omit=optional` and ships no AI runtime at all (~158 MB); `--target coach` drops that flag and adds @anthropic-ai/claude-agent-sdk (~455 MB). The SDK's runtime ships as a per-platform package, so on this Alpine base the lockfile resolves the musl build — the kind of thing that only fails on somebody else's machine, which is why the new api-image CI job builds *and runs* both targets rather than merely building them. Both targets now create the unprivileged `coach` user. That is not a Claude detail: canDropPrivileges() fails closed, so without it every job is refused — including the fixture provider that exists so the loop can be walked before an account is connected. The shipped image could not run one. The adapter imports the SDK lazily, so an absent runtime stays an ordinary reportable state rather than a boot crash: check() says so, isConnected() goes false, and /api/config carries no coach key. Four SDK options are what make this safe next to ./data — tools: [] (no Read, no Bash, no Grep), settingSources: [], skills: [], strictMcpConfig. They are one frozen exported object, asserted by value, so re-enabling one is a red build rather than a quiet capability grant. Verified against the SDK's own type definitions rather than from memory. Two things the fork's draft had wrong: SDKResultError carries no `errors` field, so `message.errors?.join()` was dead code and the failure reason now comes from `subtype` and `stop_reason`; and the client-app version string was hardcoded at 1.2.3 two releases after it stopped being true, so it is read from package.json. The credential connect/disconnect routes land here as promised in 2/6 — they serve a credential, and until this PR there was no provider that had one. authMode and the per-profile pair still wait for the side that consumes them. api 72/72 on macOS and on Linux as uid 65534 with the SDK absent; both image targets built and run; library in sync at 1324. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2c76da270b
commit
49be4e0626
12 files changed
+1933
-16
No files matched your search
+50
-2
@@ -4,8 +4,8 @@ An optional AI that **designs** a training plan and **revises it from what you a
|
||||
running on your own server under your own provider account, off until an admin turns it on.
|
||||
|
||||
> This document grows with the feature. What is described here is what has landed: the server
|
||||
> plumbing, the consent and payload boundary, the credential model, and the validator and apply
|
||||
> path. The provider adapters and the UI arrive in the PRs that follow.
|
||||
> plumbing, the consent and payload boundary, the credential model, the validator and apply
|
||||
> path, and the Claude provider with its opt-in packaging. The UI arrives in the PRs that follow.
|
||||
|
||||
---
|
||||
|
||||
@@ -130,6 +130,54 @@ by sealing `./data` with a blanket `0700`. The directory is a host bind mount an
|
||||
runs as root, so sealing it lands on the host as root-owned and unreadable, and anything else
|
||||
the owner runs against their own data directory gets `EACCES`.
|
||||
|
||||
## You only carry the AI runtime if you ask for it
|
||||
|
||||
`api/Dockerfile` builds two targets from one file:
|
||||
|
||||
- **`default`** — what every instance has always had. `npm ci --omit=optional` skips the Agent
|
||||
SDK and its platform runtime entirely, so an owner who never wanted the Coach ships none of it.
|
||||
Around 158 MB.
|
||||
- **`coach`** — the same image plus `@anthropic-ai/claude-agent-sdk`. Around 455 MB.
|
||||
|
||||
```
|
||||
docker build --target coach ./api # or:
|
||||
API_TARGET=coach docker compose up --build api
|
||||
```
|
||||
|
||||
The SDK sits in `optionalDependencies`, and its runtime ships as a per-platform package — this
|
||||
base is Alpine, so the lockfile resolves `linux-x64-musl` / `linux-arm64-musl`. That resolution
|
||||
is the sort of thing that only fails on somebody else's machine, so CI builds **and runs** both
|
||||
targets: the default one has to boot and serve `/api/config` with the SDK genuinely unimportable,
|
||||
and the coach one has to report a runnable SDK through the same `check()` the admin card renders.
|
||||
|
||||
An absent runtime is an ordinary state, not a crash: the adapter imports the SDK lazily, `check()`
|
||||
says it is missing, `isConnected()` goes false, and `/api/config` carries no `coach` key at all.
|
||||
|
||||
Both targets create the unprivileged `coach` user. That is not a Claude-specific detail — the
|
||||
privilege drop fails closed, so without that user *every* job is refused, including the fixture
|
||||
provider that exists precisely so the loop can be walked before an account is connected.
|
||||
|
||||
## What the model is allowed to do
|
||||
|
||||
The Claude provider runs through the Agent SDK rather than a hand-rolled CLI call, because the
|
||||
SDK exposes the switches that matter and brings its own matching runtime. Four of them are the
|
||||
reason it can be trusted next to your `./data`:
|
||||
|
||||
| Option | Effect |
|
||||
| --- | --- |
|
||||
| `tools: []` | Disables **all** built-in tools — no Read, no Bash, no Grep. The model has no filesystem tool at all, however it is prompted. |
|
||||
| `settingSources: []` | No user/project/local settings file is loaded, so nothing on the host can widen the line above afterwards. |
|
||||
| `skills: []` | Same, for skills. |
|
||||
| `strictMcpConfig` | No MCP server can arrive from ambient configuration. |
|
||||
|
||||
They are exported as one frozen object and asserted by value in `adapters.test.js`, so
|
||||
re-enabling one is a red build rather than a quiet capability grant.
|
||||
|
||||
The credential reaches the model process as an environment variable and by no other route. The
|
||||
job environment is built from nothing rather than filtered, and the SDK's `env` option *replaces*
|
||||
the child environment rather than extending it — so `RP_ID`, `ADMIN_UIDS` and the VAPID keys
|
||||
cannot reach it by inheritance even by accident.
|
||||
|
||||
## Off is really off
|
||||
|
||||
`COACH_DISABLED=1` forces the Coach off everywhere regardless of what is stored — the fleet
|
||||
|
||||
Reference in new issue
Block a user