pi-crew 0.11.33 → 0.11.37

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/CHANGELOG.md CHANGED
@@ -6,6 +6,34 @@
6
6
 
7
7
  - **fix(gate): RT24-F1 root-gate config/autonomy read over-block** — `rootGateBlockReason` counted the `args` subcommand carrier as a config patch key, so worker-origin `config {args:"show"}` READS were rejected as "writes user-scope config" (live-caught in the v0.11.24 real-test battery; docblock promised reads open). `args` added to the carrier-key sets for `config` and `autonomy`; unknown junk keys stay write-classified (fail-closed). Pinned: reads with carrier keys open, writes hidden behind the same key still gated (`unset`/patch keys), user config byte-untouched. Live-verified end-to-end (fresh `pi -p`, worker env): read allowed + dumps config; `unset` write gate-blocked verbatim "root-session required".
8
8
 
9
+ ## [0.11.36] — Wave 9: exit-revoke wiring + bwrap OS boundary (Linux opt-in) + google provider route
10
+
11
+ ### Security
12
+ - **Exit-revoke (v0.11.36)**: the `runChildPi` wrapper now revokes the task's inference-broker token in a `finally` — normal exit, crash, abort-before-spawn, even thrown errors. No live token outlives its run; retries re-register a fresh token (register-replace semantics make the ordering safe). Anonymous (agentId-less) spawns keep per-spawn unique keys that die at broker stop. Pinned by an aborted-before-spawn wiring test: registration happens BEFORE the B5 abort check, so the orphan would be observable in `inferenceBrokerStats()` without the revoke.
13
+ - **OS boundary — `PI_CREW_SANDBOX=bwrap` (Linux opt-in)**: headless child-pi workers run inside a bubblewrap namespace. The worker sees ONLY the project cwd (rw), the scoped inference agent dir, explicitly handed-in temp/scratch paths (ro), the inter-pi broker socket (rw — connect needs write), toolchain mounts (node bin dir, pi bundle dir + node_modules ancestors, --extension/--skill resources up to their package root — ALL read-only), and the OS runtime (/usr,/etc ro + tmpfs /tmp,/run + HOME=/tmp). `~/.pi` (auth.json!), `~/.ssh` and every other host path are simply NOT MOUNTED — a forgotten path fails closed as ENOENT inside, never silently reaching the host. Fail-closed on EVERY misconfiguration: unsupported value, non-Linux, missing bwrap binary, net=off+broker (a new netns has no loopback route — broker-token workers would be keyless AND netless). TUI surface panes and the rpc transport are SKIPPED while the sandbox is on — a sandboxed request can never land in an unsandboxed pane. `PI_CREW_SANDBOX_NET=off` additionally unshares the network stack entirely (full egress isolation); the default `share` profile honestly leaves egress open (host-file boundary only).
14
+ - **google provider route**: the broker now routes `/google/*` to the native google-generative-ai upstream (default `https://generativelanguage.googleapis.com/v1beta`, per-provider override `PI_CREW_INFERENCE_UPSTREAM_GOOGLE`), substituting the real credential into `x-goog-api-key` (never Bearer/x-api-key on that wire). Credential precedence: GOOGLE_API_KEY > GEMINI_API_KEY > auth.json:google. Usage counting understands `usageMetadata` (promptTokenCount → input; candidatesTokenCount + thoughtsTokenCount → output, cumulative per stream). Built-in google models (gemini-*) ride the override-only scoped models.json with zero metadata mirroring.
15
+
16
+ ### Fixes
17
+ - Lazy budget 533 → 534 (sandbox.ts is a static import — the spawn path is sync).
18
+
19
+ ### Tests
20
+ - Sandbox battery 9 (NEW): config fail-closed ×3, availability fail-closed, argv pure ×3 (mount ORDER: tmpfs /tmp precedes binds under /tmp; toolchain ro), REAL bwrap smoke ×2 (host ~/.pi invisible while the file demonstrably exists outside + cwd writable; net=off → even loopback unreachable).
21
+ - Broker battery 18 → 21: google substitution/routing/usage/precedence + revoke helper semantics. Revoke WIRING test (NEW): no orphan token after an aborted runChildPi.
22
+ - 4/4 mutation checks: wrapper-revoke removed → wiring red; bwrap-missing fail-open → red; net=off+broker guard dropped → red; google usage names dropped → red.
23
+ - LIVE production-path e2e: a REAL `pi` completing inside bwrap through runChildPi + broker (upstream saw the substituted key; worker env credential-less; stats empty after the run).
24
+
25
+ ## [0.11.34] — Broker credentials completion: auth.json parents + OpenAI upstream (multi-provider routing)
26
+
27
+ ### Security / Features
28
+ - **auth.json credential fallback (v0.11.34)**: parents without provider env keys — interactive users who logged in via `/login` — can now use the inference broker. Resolution per provider: env credential FIRST (CI behavior identical to v0.11.33), then the parent's own auth.json file credential (`{"<provider>": {"type": "api_key", "key": ...}}`, shape verified against the live SDK store; read once at broker start; parse failures logged WITHOUT the key and ignored). The worker's scoped agent dir still contains NO auth.json — the worker never sees any stored credential.
29
+ - **OpenAI upstream + multi-provider routing**: the broker now routes by PROVIDER PATH PREFIX — the scoped models.json gives each resolvable provider a prefixed baseUrl (`…/anthropic`, `…/openai`) and the broker forwards the remaining path verbatim to that provider's upstream with the right substituted auth (anthropic → x-api-key; openai → Authorization: Bearer). Built-in model metadata is preserved on both providers (override-only), so `--model openai/<id>` and fallback chains across providers work unmodified. Unknown prefixes get a generic 404 and never touch an upstream.
30
+ - Per-worker usage counting now also understands OpenAI chat-completions usage fields (prompt_tokens/completion_tokens) alongside Anthropic's (input_tokens/output_tokens, incl. message_delta cumulative semantics), so budgets work per worker across providers (usage sums across requests).
31
+ - FAIL-CLOSED error now lists every consulted source (env names + auth.json path) when nothing resolves.
32
+
33
+ ### Tests
34
+ - Battery 15 → 18: auth.json fallback + env-beats-auth.json precedence; multi-provider routing (Bearer vs x-api-key substitution, prefix stripping, unknown-prefix 404, both-provider scoped models.json, cross-provider usage accumulation); LIVE e2e ×2 — REAL `pi -p` through BOTH the anthropic route and the openai route (openai-completions wire), upstreams seeing the real keys, worker env credential-less.
35
+ - 3/3 new mutation checks: auth.json ignored → h1 red; routing collapsed to first-route → b3/i1/g2 red (incl. LIVE); openai usage names dropped → i1 red. Restored green 18/18.
36
+
9
37
  ## [0.11.31] — Inference Broker PoC: workers no longer hold ANY real provider key
10
38
 
11
39
  ### Security