pantheon-opencode 1.6.2-beta.9 → 1.6.3-beta.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +34 -60
  3. package/README.pt-BR.md +10 -12
  4. package/bin/pantheon-init.mjs +23 -33
  5. package/package.json +3 -3
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/decision-router-budget.mjs +4 -1
  9. package/scripts/decision-router-v2-egress.mjs +11 -2
  10. package/scripts/decision-router.mjs +64 -56
  11. package/scripts/install/decision-router-config.mjs +110 -1
  12. package/scripts/install/npx-cache-sweep.mjs +103 -0
  13. package/scripts/install/opencode.mjs +7 -7
  14. package/scripts/install/plugin.mjs +4 -3
  15. package/scripts/install/strings.mjs +4 -0
  16. package/scripts/release-gates.mjs +6 -82
  17. package/scripts/secret-scan.mjs +1 -1
  18. package/scripts/sync-tui.mjs +3 -3
  19. package/src/agents/zeus.md +4 -2
  20. package/src/pantheon/jev-decision-tool.ts +455 -117
  21. package/src/pantheon/jev-decisions.ts +72 -25
  22. package/src/pantheon/jev-escalation.ts +639 -0
  23. package/src/pantheon/jev-quality-score.ts +432 -0
  24. package/src/pantheon/jev-risk-gate.ts +479 -0
  25. package/src/pantheon/local-decision-budget.ts +11 -1
  26. package/src/pantheon/local-decision-prompt.ts +12 -18
  27. package/src/pantheon/local-decision-provider-matrix.ts +3 -0
  28. package/src/pantheon/v2-decision-telemetry.ts +14 -4
  29. package/src/pantheon/v2-native-decisions.ts +1 -1
  30. package/src/plugin-v2.ts +204 -24
  31. package/src/plugins/tui/dist/server-v2.d.ts +19 -11
  32. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  33. package/src/plugins/tui/dist/server-v2.js +19 -789
  34. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  35. package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
  36. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  37. package/src/plugins/tui/dist/tui-v2.js +257 -5370
  38. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  39. package/src/plugins/tui/dist/tui.js +1 -1
  40. package/src/plugins/tui/package-lock.json +2 -2
  41. package/src/plugins/tui/package.json +1 -1
  42. package/src/plugins/tui/src/index-v2.tsx +213 -86
  43. package/src/plugins/tui/src/server-v2.ts +18 -982
  44. package/src/plugins/tui/tsconfig.typecheck.json +1 -6
  45. package/src/plugins/tui/tsdown.config.ts +1 -11
  46. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
  47. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
  48. package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
  49. package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
  50. package/src/plugins/tui/dist/quota-adapters.js +0 -1142
  51. package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
  52. package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
  53. package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
  54. package/src/plugins/tui/dist/quota-cli.js +0 -184
  55. package/src/plugins/tui/dist/quota-cli.js.map +0 -1
  56. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +0 -684
  57. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
  58. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
  59. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
  60. package/src/plugins/tui/dist/usage-history-worker.js +0 -25
  61. package/src/plugins/tui/dist/usage-history-worker.js.map +0 -1
  62. package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
  63. package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
  64. package/src/plugins/tui/src/quota-adapters.ts +0 -1598
  65. package/src/plugins/tui/src/quota-cli.ts +0 -237
  66. package/src/plugins/tui/src/quota-rpc.ts +0 -373
  67. package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
  68. package/src/plugins/tui/src/quota-v2.tsx +0 -1238
  69. package/src/plugins/tui/src/usage-history-contract.ts +0 -217
  70. package/src/plugins/tui/src/usage-history-validation.ts +0 -104
  71. package/src/plugins/tui/src/usage-history-view.tsx +0 -236
  72. package/src/plugins/tui/src/usage-history-worker.ts +0 -25
  73. package/src/plugins/tui/src/usage-view-model.ts +0 -272
package/CHANGELOG.md CHANGED
@@ -10,6 +10,119 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
  <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
11
11
  move this section to a versioned entry and reset the template below. -->
12
12
 
13
+ ## [v1.6.3-beta.1] - 2026-11-04
14
+
15
+ ### Added
16
+
17
+ - **routing** — The decision-provider matrix expands to the host-embedded decision modules confirmed in the 2.2.5 binary: `openrouter-jev` (OpenRouter-hosted `typesafe/jev-1.13`), `vercel-gateway-jev` (Vercel AI Gateway `typesafe-ai/jev`), and `cloudflare-workers-jev` (Workers AI `clef`; needs a custom entry with your accountId). Route resolution stays config-only; `doctor` gains route-aware rows per provider.
18
+ - **routing** — Specialist caller allowlist: `PANTHEON_JEV_SPECIALIST_CALLERS` (CSV, default empty = Zeus only) lets named agents call `pantheon_jev_decide` with explicit typed questions; preset modes stay orchestrator-owned. The permission assertion and the success output carry the real caller; caps and the `decision.egress` kill-switch are enforced per call regardless of caller.
19
+ - **routing** — `DECISION_CALL_FAILED` surfaces the provider reason class, integer status and retry window (rate limits now self-explain); `QUESTIONS_INVALID` carries a per-cause `detail` token (ten causes, one each); the tool description states the required-fields contract on its surface.
20
+
21
+ ### Fixed
22
+
23
+ - **routing** — The TypeSafe provisioner writes a **complete** custom provider entry: the `@ai-sdk/openai-compatible` adapter, the `api.typesafe.ai/v1` baseURL, and an `apiKey` env reference (`{env:TYPESAFE_API_KEY}` — the key itself never lands in the config file). Field evidence: a models-only entry is inert because models.dev has no typesafe-ai entry, so `/connect` and `opencode auth login` cannot supply it and the decisions call 404s. `doctor` now warns when the entry lacks the apiKey; the activation path is `export TYPESAFE_API_KEY=...` + restart.
24
+
25
+ ## [v1.6.2] - 2026-11-03
26
+
27
+ ### Added
28
+
29
+ - **routing** — The Jev uplift: the native `pantheon_jev_decide` route works end to end (Console free variant field-verified), and TypeSafe direct is one `decision-router setup-model` command away.
30
+ - **routing** — `decision-router doctor` is route-aware: Console routes pass host-native without a catalog probe; the TypeSafe route is checked against the provider entry.
31
+ - **hooks** — J1 risk-score advisory gate (shadow): one Jev risk-score + intent observation per exfil-capable tool call when `PANTHEON_J1_RISK_SCORE` is on; never blocks; zero user content.
32
+ - **hooks** — J3 turn-complexity escalation (shadow): cheap-vs-main per delegate dispatch with local rails, behind `PANTHEON_J3_ESCALATION`; the override is proven, never applied in shadow.
33
+ - **routing** — J4 `mode: "review"` quality scoring: one round-trip quality + needs-review predicate for delegated results, on demand; the result never leaves the machine.
34
+ - **routing** — The offline J2 skill-selection scorecard harness ships in `bench/results/` (29 scenarios, replies faked, honest negatives).
35
+ - **install** — `init` sweeps stale `pantheon-opencode` copies from the npm cache's `_npx/` after a successful install (failures retry on the next init).
36
+
37
+ ### Deprecated
38
+
39
+ - **install** — `--opencode-version v1` keeps its deprecation warning on this line; Pantheon 2.0 refuses it outright.
40
+
41
+ ### Removed
42
+
43
+ - **tui** — The native `/quota` panel, the sidebar quota block, usage history, go-key diagnostics, and the `pantheon.quota` RPC; see the community replacement below.
44
+ - **tui** — `/quota-go-check` and the undocumented `PANTHEON_TRUSTED_BL_EXECUTABLE` env var.
45
+ - **docs** — The quota replacement is documented in `docs/tui-v2-quota-providers.md`: `@slkiser/opencode-quota`.
46
+
47
+ ### Fixed
48
+
49
+ - **routing** — Three field-measured causes of a dead `pantheon_jev_decide` are fixed: the detached `model.list()` call, the wrapped `{ data: [...] }` shape, and the catalog-presence gate.
50
+ - **routing** — Decision models are not chat models: route resolution reads config only; the visible `pantheon-decision-router:v1` prompt marker is suppressed.
51
+ - **agents** — Zeus's decision-routing instructions no longer reference the removed `/quota-go-check` command.
52
+
53
+ ## [v1.6.2-beta.17] - 2026-11-03
54
+
55
+ ### Added
56
+
57
+ - **routing** — J2 skill-selection scorecard harness: an offline, rerunnable, dated scorecard (29 synthetic scenarios including adversarial injection and refusal shapes, every Jev reply faked — zero network) measuring the P2 prefilter and the skills preset against expected picks, with honest negatives recorded in `bench/results/`. Activation gate: two consecutive scorecards, separately reviewed.
58
+ - **hooks** — J3 turn-complexity escalation policy (shadow): when `PANTHEON_J3_ESCALATION` is on, delegate dispatches get one Jev complexity classification resolved cheap-vs-main through a pure policy with independent local rails (risk-word states never downgrade, user-pinned models always win, oversize context never downgrades, uncertainty resolves to main). Structurally shadow-only — the wiring cannot reach the override mechanism (contract-test enforced); the mechanism itself is proven by direct tests for the separately reviewed activation. Default off.
59
+ - **routing** — J4 output quality scoring: a new `mode: "review"` on `pantheon_jev_decide` scores a delegated result against caller-named criteria (one round-trip: quality score + needs-human-review predicate). The request carries no result content — only delegate id, result kind, shape metrics, and bounded criteria. Advisory flag only; nothing blocks. On demand (Zeus-only, same consent/caps/permission chain).
60
+
61
+ ## [v1.6.2-beta.16] - 2026-11-03
62
+
63
+ ### Added
64
+
65
+ - **hooks** — J1 risk-score advisory gate (shadow): when `PANTHEON_J1_RISK_SCORE` is on, exfil-capable tool calls get one Jev risk-score + intent-predicate observation through the same gate chain as `pantheon_jev_decide` (consent, budget caps, `decision.egress` permission). Shadow only — the verdict is always observed, never enforced; nothing blocks or delays (2s abandon, fail-open on every failure mode). The request carries zero user content: tool name token, scope class, input hash only. Default off.
66
+
67
+ ## [v1.6.2-beta.15] - 2026-11-03
68
+
69
+ ### Added
70
+
71
+ - **routing** — `decision-router setup-model typesafe-jev/...` now provisions the TypeSafe host provider entry itself (the same additive `providers.typesafe-ai` merge the installer's `--decision-model` path performs), so the TypeSafe direct route is one command plus your own sign-in.
72
+ - **routing** — `doctor` checks are route-aware: the Console routes pass as host-native without any catalog probe (decision models are not chat models and never appear in `opencode models`), and the TypeSafe route is verified against the provider entry with a provisioning fix hint.
73
+
74
+ ## [v1.6.2-beta.14] - 2026-11-03
75
+
76
+ ### Fixed
77
+
78
+ - **routing** — The native Jev route no longer consults the host chat catalog. Decision models are not chat models: on a measured 2.2.5 host the catalog carries 561 entries and zero jev models, while the decisions API answers the exact same model ref directly (`jev-1.13-free` -> real answer at $0.00; the paid `jev-1.13` without a Zen workspace -> the host's own 404). The catalog-presence gate was a wrong assumption that sandbox mocks reinforced; route resolution is now config + budget admission, with consent, caps and the host permission assertion unchanged as the safety gates. `ROUTE_UNRESOLVED` and its inner verdicts are gone from the surface. Field-verified end to end: Zeus -> `pantheon_jev_decide` (mode skills) -> real Jev answer, usage reconciled.
79
+ - **routing** — The `decision-router setup-model` checklist no longer tells users to verify the model in the host catalog (it is not there by design).
80
+
81
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
82
+ move this section to a versioned entry and reset the template below. --&gt;
83
+ ## [v1.6.2-beta.13] - 2026-11-03
84
+
85
+ ### Added
86
+
87
+ - **install** — `init` now sweeps stale `pantheon-opencode` copies out of the npm cache's `_npx/` after a successful install (only the package subtree; unrelated packages and the just-installed copy survive). Field evidence: a 1.6.1 npx copy beside the registered 1.6.2-beta.12 made a bare `npx pantheon-opencode doctor` report the registered plugin as outdated, and old copies accumulate forever because npm never prunes them. Removal failures are swallowed and retried by the next init.
88
+ - **routing** — `ROUTE_UNRESOLVED` refusals now carry the inner verdict in `detail` (`MODEL_NOT_IN_CATALOG`, `AMBIGUOUS_MODEL`, `MODEL_NOT_DECISION`): the class alone does not tell whether the configured decision model is absent from the host catalog or present but not decision-typed, and those have different fixes. Field-measured on 2.2.5: a host catalog without the Console Jev model (no OpenCode Console credential) reports `MODEL_NOT_IN_CATALOG`.
89
+
90
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
91
+ move this section to a versioned entry and reset the template below. --&gt;
92
+ ## [v1.6.2-beta.12] - 2026-11-03
93
+
94
+ ### Added
95
+
96
+ - **routing** — `ROUTE_UNRESOLVED` refusals now carry the inner verdict in `detail` (`MODEL_NOT_IN_CATALOG`, `AMBIGUOUS_MODEL`, `MODEL_NOT_DECISION`): the class alone does not tell whether the configured decision model is absent from the host catalog or present but not decision-typed, and those have different fixes. Field-measured on 2.2.5: a host catalog without the Console Jev model (no OpenCode Console credential) reports `MODEL_NOT_IN_CATALOG`.
97
+
98
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
99
+ move this section to a versioned entry and reset the template below. --&gt;
100
+ ## [v1.6.2-beta.11] - 2026-11-03
101
+
102
+ ### Fixed
103
+
104
+ - **routing** — `pantheon_jev_decide` now accepts the host's wrapped catalog shape. The 2.2.5 host returns `{ data: [...] }` from `model.list()`, not a bare array; requiring an array turned every real session into `CATALOG_UNAVAILABLE` (field evidence: the sanitized `detail: TypeError` under beta.10 once the receiver binding landed). Same tolerance as the vision surface, which already unwrapped the page object.
105
+
106
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
107
+ move this section to a versioned entry and reset the template below. --&gt;
108
+ ## [v1.6.2-beta.10] - 2026-11-03
109
+
110
+ ### Added
111
+
112
+ - **routing** — Jev refusals carry the sanitized error CLASS in a `detail` field (`TypeError`, `RangeError`, …): enough to tell a detached-call failure from a host-side data failure, while the message (which can carry paths or provider detail) never reaches the chat.
113
+
114
+ ### Changed
115
+
116
+ - **tui** — The native quota surface is removed: the `/quota` panel, the sidebar quota block, usage history, the go-key diagnostics, and the `pantheon.quota` RPC no longer ship. The recommended community plugin [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) covers provider quota and usage (OpenCode 2.0.26+; an `npx` installer path exists for 1.x hosts) — see [Quota & usage](docs/tui-v2-quota-providers.md). `pantheon_cost` and the sidebar `Context` block are unaffected.
117
+ - **routing** — The visible `&lt;!-- pantheon-decision-router:v1 … --&gt;` marker is no longer appended to the prompt: the host chat rendered the HTML comment to the user. The router keeps running (shadow observation, telemetry, budget, presets); measured evidence showed every prompt mutation was a no-op (F-24, F-08/F-09), so no behavioral routing is lost.
118
+ - **agents** — Zeus's decision-routing instructions no longer reference the removed `/quota-go-check` command.
119
+
120
+ ### Fixed
121
+
122
+ - **routing** — The native Jev runtime now invokes host methods with their owning domain as receiver. `model.list()` was called detached from the host object and threw on real sessions, surfacing only as `CATALOG_UNAVAILABLE`; the canary always exercised the bound call and never caught it. `decisions()` and `skill.list()` are bound the same way, with a contract test that fails on any detached call.
123
+
124
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
125
+ move this section to a versioned entry and reset the template below. --&gt;
13
126
  ## [v1.6.2-beta.9] - 2026-11-02
14
127
 
15
128
  ### Added
package/README.md CHANGED
@@ -104,68 +104,22 @@ see [Quick Start](docs/QUICKSTART.md).
104
104
  the host's native Decisions API (TypeSafe Jev via OpenCode Console or a
105
105
  configured decision model) behind the user's consent and budget gates — it
106
106
  never dispatches agents, runs skills, or changes permissions. This does not
107
- change separately documented quota and Vision integrations. See the
107
+ change the separately documented Vision integration. See the
108
108
  [router reference](docs/reference/local-decision-router.md) and the
109
109
  [Native Decisions (Jev)](docs/reference/native-decisions.md).
110
110
  - **An optional TUI** with a dispatch sidebar block and a full-width
111
- `/dispatch` panel. The V2 TUI also provides a quota overview in the
112
- sidebar/footer and a `/quota` details panel. Quota display is enabled by
113
- default; the sidebar keeps Todo and places quota immediately after Dispatch
114
- (header/version → Session → Context → Git → Todo → Dispatch → quota).
115
- Status stays in the native sidebar footer. Use `E` to disable quota or `M`
116
- to switch between remaining and used. The `/quota` panel has **Usage, Limits,
117
- Plugin, and Settings** tabs. Usage charts cover 7, 15, 30 days, or Total and
118
- plot recorded daily token usage and model totals rather than filling gaps with
119
- invented data. The panel identifies the active chat model; a partial-data
120
- warning appears only when the quota snapshot is actually partial.
121
- Session-reported spend is shown separately. The active context estimate uses
122
- the active model's input price times pre-cache context tokens, applies no cache
123
- discount, and is explicitly not billable.
124
- Quota windows show text amounts and status, not provider progress gauges. They
125
- show a local countdown and the provider-reported reset date/time in UTC when
126
- valid timing is available; missing timing is not inferred. After expiry the UI
127
- shows “aguardando atualização” until refreshed data arrives.
128
- When a quota status request fails, the UI preserves the last valid
129
- snapshot, marks it stale, and shows the failure cause as `Erro: <causa>`
130
- in the sidebar and `/quota` panel (plus a `Último erro` line) instead
131
- of a blind "Status indisponível"; the cause is logged as
132
- `[pantheon-tui quota]`.
133
- Usage severity uses warning color from 60% consumed and error color above 85%.
134
- Session costs, provider balances and selected-key usage retain their distinct
135
- labels and reported periods. Long values and states continue onto additional
136
- lines within the sidebar's fixed 34-column content budget.
137
- The installer selects the `plugins` component by default; in interactive setup
138
- you can change the component selection. A component-scoped install includes
139
- the TUI only when `plugins` is selected.
140
- The V2 quota RPC shows providers when OpenCode lists an active supported
141
- connection and Pantheon can locally resolve a nonblank credential. OpenCode
142
- Go also supports `OPENCODE_API_KEY` and effective `opencode-go`/`opencode`
143
- provider settings. This is not proof that the provider accepted the
144
- credential; failed requests and unsupported adapters can remain visible as
145
- unavailable. OpenCode Go checks a selected Console OAuth login first when
146
- available, then uses the first available API key if no Console login exists
147
- or its request fails; a Console 404 or a successful response without an
148
- access object reports no Go subscription and does not fall back.
149
- The API-key route follows OpenCode Quota's supported Go usage endpoint. See
150
- the
151
- [quota provider coverage table](docs/tui-v2-quota-providers.md) for limits and
152
- troubleshooting.
153
-
154
-
155
- Quota status requests are separate from the decision subsystem and continue to use
156
- their documented provider APIs. Removing decision-provider transport does not
157
- disable these quota requests.
158
- `/quota-go-check` is a separate manual, confirmation-gated diagnostic: one
159
- GET to `https://opencode.ai/zen/go/v1/usage` with the configured Go API key
160
- (not OAuth), at most one attempt per plugin runtime. It never refreshes quota,
161
- follows redirects or retries. Only HTTP 401 bodies are inspected, up to 4096
162
- bytes, for an own top-level JSON `error` property; its value is never inspected.
163
- Results contain only a safe category, optional HTTP status, coarse content type,
164
- and (for 401) whether that structure is present, absent, or unavailable.
165
- No error code, type, message, body, request ID, or byte count is displayed;
166
- a 401 rejection's cause remains unknown. `success` means
167
- HTTP success only—not a stable quota contract or parsed quota correctness.
168
- Require Themis security review before using this diagnostic.
111
+ `/dispatch` panel. The V2 sidebar keeps the Pantheon version, the active
112
+ preset/source, git state, and a `Context` block (tokens, a percent gauge,
113
+ `$<spent> spent`, and a muted `cache <n>% · <n.n> tok/s` line); the native
114
+ prompt footer keeps its own line, and Pantheon only appends
115
+ `▸<preset> · ✦<n> ativos` while delegations are running. The installer
116
+ selects the `plugins` component by default; in interactive setup you can
117
+ change the component selection. A component-scoped install includes the TUI
118
+ only when `plugins` is selected. The TUI ships no quota panel: for provider
119
+ quota and usage inside OpenCode, install the recommended community plugin
120
+ [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) — see
121
+ [Quota & usage](docs/tui-v2-quota-providers.md). `pantheon_cost` and
122
+ `pantheon_model` keep working unchanged.
169
123
 
170
124
  Vision requests to OpenCode Zen require a valid active session and are rejected
171
125
  before image fetching or model-catalog lookup when the session is missing or
@@ -258,7 +212,27 @@ credentials cannot activate it. Native child-session dispatch remains separate.
258
212
  The one native egress surface is the Zeus-only `pantheon_jev_decide` tool,
259
213
  available on hosts that expose the V2.2.5 native Decisions API; its full gate
260
214
  chain, routes, and settlement rules are documented once in
261
- [V2 native Decisions](docs/reference/native-decisions.md).
215
+ [V2 native Decisions](docs/reference/native-decisions.md). An opt-in second
216
+ consumer of that chain, the J1 risk-score shadow gate, fires one bounded
217
+ native decision per write/execute tool call behind `PANTHEON_J1_RISK_SCORE`
218
+ (off by default, zero overhead when off): the request carries no user content
219
+ (tool name token, scope class, input sha256 only), every failure mode skips
220
+ silently with a reason token, and the shadow record is the whole effect — it
221
+ never blocks, asks, or narrows a permission. A third opt-in consumer, the J3
222
+ turn-complexity escalation, runs in shadow behind `PANTHEON_J3_ESCALATION`
223
+ (off by default): it classifies each delegate dispatch with one bounded score
224
+ question (Brief sha256, length and a risk-word flag only — the Brief text
225
+ never leaves the machine), local rails (risk words, user-pinned models, large
226
+ context) and every unsure answer always favor the main model, and the recorded
227
+ verdict never changes the dispatched model — the per-agent override mechanism
228
+ is proved by test and reserved for a separately reviewed activation with its
229
+ own measured baseline. A fourth consumer needs no flag at all: the tool's
230
+ `mode: "review"` (J4 output-quality scoring) runs only when Zeus explicitly
231
+ asks, after a delegation completes — one typed round-trip returns an advisory
232
+ quality score against named criteria plus a needs-review flag. The result
233
+ content never leaves the machine (shape metrics and criteria only, hostile
234
+ criteria rejected outright), and the verdict is advisory telemetry plus a
235
+ flag: it never blocks, retries, or alters the delegated result.
262
236
 
263
237
  The installer may retain a legacy target-specific preference; it does not control
264
238
  runtime routing. `npx pantheon-opencode decision-router ...` manages stored
package/README.pt-BR.md CHANGED
@@ -85,18 +85,16 @@ apenas — `init` → reiniciar → `/dispatch` → primeiro resultado — veja
85
85
  [referência do roteador](docs/reference/local-decision-router.md) e o
86
86
  [Decisions nativas (Jev)](docs/reference/native-decisions.md).
87
87
  - **Uma TUI opcional**, com bloco de dispatch na sidebar e painel `/dispatch`
88
- em largura total. A TUI V2 também inclui um resumo de quota na sidebar/rodapé
89
- e o painel `/quota`, com abas Usage, Limits, Plugin e Settings. Usage mostra
90
- gráficos de tokens registrados e totais por modelo em períodos de 7, 15, 30
91
- dias ou Total, sem inventar dados para preencher lacunas. O painel identifica
92
- o modelo ativo da conversa; o aviso de dados parciais só aparece quando a
93
- resposta de quota é realmente parcial. O gasto reportado da sessão fica
94
- separado da estimativa de contexto pré-cache, calculada com o preço de entrada
95
- do modelo ativo, sem desconto de cache e sem representar uma cobrança. As
96
- quotas aparecem como valores e status em texto, sem medidores de progresso;
97
- quando há horário válido, mostram contagem regressiva local e o reset informado
98
- pelo provedor em UTC. Horários ausentes não são inferidos. Use `E` para
99
- desativar a quota e `M` para alternar entre restante e usado.
88
+ em largura total. A sidebar V2 mantém a versão do Pantheon, o preset/fonte
89
+ ativos, o estado do git e um bloco `Context` (tokens, medidor de percentual,
90
+ `$<gasto> gastos` e uma linha mutada `cache <n>% · <n.n> tok/s`); o rodapé
91
+ nativo do prompt segue intacto, e o Pantheon só acrescenta
92
+ `▸<preset> · ✦<n> ativos` enquanto há delegações rodando. A TUI não traz mais
93
+ painel de quota: para ver quota e uso de provedores dentro do OpenCode,
94
+ instale o plugin comunitário recomendado
95
+ [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) — veja
96
+ [Quota & uso](docs/tui-v2-quota-providers.md). As tools `pantheon_cost` e
97
+ `pantheon_model` seguem funcionando sem alterações.
100
98
 
101
99
  A memória MCP fica disponível para busca explícita: o coordenador consulta o
102
100
  histórico uma vez quando ele pode mudar a tarefa e repassa apenas resultados
@@ -26,6 +26,7 @@ import { fileURLToPath } from 'node:url'
26
26
  import { configure as configureUi, endGaugeLine, tag } from '../scripts/install/cli-ui.mjs'
27
27
  import { resolveComponentSelection } from '../scripts/install/component-selection.mjs'
28
28
  import { resolveGlobalConfigDirectory } from '../scripts/install/config-paths.mjs'
29
+ import { provisionTypesafeHostProvider } from '../scripts/install/decision-router-config.mjs'
29
30
  import { resolveInstallExitCode } from '../scripts/install/exit-codes.mjs'
30
31
  import { createInterruptHandler } from '../scripts/install/interrupt.mjs'
31
32
  import { parseOpenCodeVersion } from '../scripts/install/opencode-version.mjs'
@@ -68,40 +69,13 @@ function readVersion() {
68
69
  /**
69
70
  * Merge (never overwrite) the TypeSafe decision-model entry into the user's
70
71
  * OpenCode config, so choosing the TypeSafe route in the wizard needs only the
71
- * user's own sign-in afterwards. The merge is additive: existing provider
72
- * entries and an existing jev-1.14.0 model are preserved. Returns true, or a
73
- * short failure reason for the installer to print.
72
+ * user's own sign-in afterwards. Delegates to the shared installer module —
73
+ * the same provisioner `decision-router setup-model typesafe-jev/...` uses.
74
+ * Returns true, or a short failure reason for the installer to print.
74
75
  */
75
76
  function provisionTypesafeProvider() {
76
- const xdg = process.env.XDG_CONFIG_HOME
77
- const home = process.env.HOME
78
- const base = xdg && xdg.startsWith('/') ? xdg : `${home ?? '~'}/.config`
79
- const candidates = [`${base}/opencode/opencode.json`]
80
- if (home) candidates.push(`${home}/.config/opencode/opencode.json`)
81
- const configPath = candidates.find((candidate) => fs.existsSync(candidate))
82
- if (configPath === undefined) return 'opencode.json not found'
83
- let data
84
- try {
85
- data = JSON.parse(fs.readFileSync(configPath, 'utf8'))
86
- } catch {
87
- return 'opencode.json is not plain JSON (comments?)'
88
- }
89
- data.providers ??= {}
90
- data.providers['typesafe-ai'] ??= {}
91
- data.providers['typesafe-ai'].models ??= {}
92
- if (data.providers['typesafe-ai'].models['jev-1.14.0'] === undefined) {
93
- data.providers['typesafe-ai'].models['jev-1.14.0'] = {
94
- name: 'Jev (TypeSafe direct)',
95
- modelID: 'jev-latest',
96
- type: 'decision',
97
- }
98
- }
99
- try {
100
- fs.writeFileSync(configPath, `${JSON.stringify(data, null, 2)}\n`)
101
- return true
102
- } catch (error) {
103
- return String(error instanceof Error ? error.message : error)
104
- }
77
+ const result = provisionTypesafeHostProvider({ env: process.env })
78
+ return result.ok ? true : result.reason
105
79
  }
106
80
 
107
81
  /** Value of a repeatable installer flag from the raw argv, or undefined. */
@@ -1062,7 +1036,7 @@ async function main() {
1062
1036
  const provisioned = provisionTypesafeProvider()
1063
1037
  console.log(
1064
1038
  provisioned === true
1065
- ? ' TypeSafe provider entry merged into opencode.json (models.typesafe-ai, type "decision"). Sign in with `opencode auth login` (TypeSafe) or /connect.'
1039
+ ? ' TypeSafe provider entry merged into opencode.json (adapter + baseURL + apiKey via {env:TYPESAFE_API_KEY}, type "decision"). Activate: export TYPESAFE_API_KEY=<your TypeSafe key> and restart OpenCode. /connect does not carry custom providers.'
1066
1040
  : ` TypeSafe provider entry NOT merged (${provisioned}); merge it manually — see docs/reference/native-decisions.md.`,
1067
1041
  )
1068
1042
  }
@@ -1077,6 +1051,22 @@ async function main() {
1077
1051
  }
1078
1052
  }
1079
1053
 
1054
+ // Old-version residue: every `npx pantheon-opencode` invocation materializes
1055
+ // a full copy under the npm cache's _npx/ and nothing in npm removes old
1056
+ // ones. The registration points at THIS run's copy, so every other copy is
1057
+ // unreferenced residue — sweep it (only the pantheon-opencode subtree;
1058
+ // failures are swallowed and retried by the next init).
1059
+ try {
1060
+ const { sweepStalePantheonNpxCaches } = await import('../scripts/install/npx-cache-sweep.mjs')
1061
+ const sweep = await sweepStalePantheonNpxCaches({ keep: ROOT })
1062
+ if (sweep.removed.length > 0) {
1063
+ console.log('')
1064
+ console.log(` ${S.sweptNpxCaches(sweep.removed.length)}`)
1065
+ }
1066
+ } catch {
1067
+ // Diagnostics-only: a failed sweep never fails the install.
1068
+ }
1069
+
1080
1070
  console.log('')
1081
1071
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
1082
1072
  console.log(` ${S.installedTitle(version)}`)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.2-beta.9",
4
- "description": "Multi-agent orchestration for OpenCode — 14 specialized agents, TDD, Themis review gates.",
3
+ "version": "1.6.3-beta.1",
4
+ "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
7
7
  "src/plugins/tui"
@@ -32,7 +32,7 @@
32
32
  "start": "OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true opencode",
33
33
  "prepack": "npm run check:decision-router",
34
34
  "prepublishOnly": "node scripts/validate-routing.mjs && npm run check:decision-router",
35
- "postpublish": "node -e \"console.log('✅ Published pantheon-opencode v' + require('./package.json').version + ' to npm')\"",
35
+ "postpublish": "node -e \"console.log('\u2705 Published pantheon-opencode v' + require('./package.json').version + ' to npm')\"",
36
36
  "version:status": "node scripts/versioning.mjs status",
37
37
  "version:apply": "node scripts/versioning.mjs apply",
38
38
  "version:check": "node scripts/version-check.mjs",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.2-beta.9",
4
+ "version": "1.6.3-beta.1",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 20 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
4
4
 
5
5
  [project]
6
6
  name = "pantheon"
7
- version = "1.6.2-beta.9"
7
+ version = "1.6.3-beta.1"
8
8
  description = "Multi-agent orchestration framework"
9
9
  requires-python = ">=3.11"
10
10
  # Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
@@ -26,7 +26,10 @@ var LOCAL_DECISION_BUDGET_PROVIDERS = Object.freeze([
26
26
  "openai-decisions",
27
27
  "typesafe-jev",
28
28
  "opencode-console",
29
- "jev-free"
29
+ "jev-free",
30
+ "openrouter",
31
+ "vercel-ai-gateway",
32
+ "cloudflare-workers-ai"
30
33
  ]);
31
34
  var ALLOWED_PROVIDERS = new Set(LOCAL_DECISION_BUDGET_PROVIDERS);
32
35
  var MODEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
@@ -14,13 +14,22 @@ var DECISION_ROUTER_MODELS = Object.freeze({
14
14
  "openai-decisions": Object.freeze(["gpt-6-luna"]),
15
15
  "typesafe-jev": Object.freeze(["jev-1.14.0"]),
16
16
  "opencode-console-jev": Object.freeze(["jev-1.13"]),
17
- "opencode-console-jev-free": Object.freeze(["jev-1.13-free"])
17
+ "opencode-console-jev-free": Object.freeze(["jev-1.13-free"]),
18
+ // Host-embedded decision modules confirmed in the 2.2.5 binary; the model
19
+ // ids are the provider-side decision models (see
20
+ // docs/reference/native-decisions.md for credential acquisition).
21
+ "openrouter-jev": Object.freeze(["typesafe/jev-1.13"]),
22
+ "vercel-gateway-jev": Object.freeze(["typesafe-ai/jev"]),
23
+ "cloudflare-workers-jev": Object.freeze(["clef"])
18
24
  });
19
25
  var DECISION_PROVIDER_BUDGET_MAPPING = Object.freeze({
20
26
  "openai-decisions": "openai-decisions",
21
27
  "typesafe-jev": "typesafe-jev",
22
28
  "opencode-console-jev": "opencode-console",
23
- "opencode-console-jev-free": "jev-free"
29
+ "opencode-console-jev-free": "jev-free",
30
+ "openrouter-jev": "openrouter",
31
+ "vercel-gateway-jev": "vercel-ai-gateway",
32
+ "cloudflare-workers-jev": "cloudflare-workers-ai"
24
33
  });
25
34
  var REMOTELY_ELIGIBLE_DECISION_PROVIDERS = Object.freeze([
26
35
  "openai-decisions",
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { spawnSync } from 'node:child_process'
3
2
  import { existsSync } from 'node:fs'
4
3
  import { pathToFileURL } from 'node:url'
5
4
  // Prebuilt bundles: Node refuses to strip TypeScript types under node_modules,
@@ -32,6 +31,8 @@ import {
32
31
  DECISION_PROVIDER_BUDGET_MAPPING,
33
32
  DECISION_ROUTER_MODELS,
34
33
  diffDecisionRouterSurfaces,
34
+ inspectTypesafeHostProvider,
35
+ provisionTypesafeHostProvider,
35
36
  readUserDecisionRouterConfig,
36
37
  resolveUserDecisionRouterConfigPath,
37
38
  updateUserDecisionRouterConfig,
@@ -336,6 +337,23 @@ export async function runDecisionRouterCommand(
336
337
  noConsent ? 'Egress consent NOT recorded (--no-consent).' : 'Egress consent recorded: yes.',
337
338
  )
338
339
 
340
+ // The TypeSafe route needs a host-side provider entry the decisions API
341
+ // can resolve; the Console routes are host-native and need none. The
342
+ // merge is additive and idempotent; a failure is a printed warning (the
343
+ // decision config stays valid — the call fails at the host until the
344
+ // entry exists).
345
+ if (provider === 'typesafe-jev') {
346
+ const provision = provisionTypesafeHostProvider({ env })
347
+ if (provision.ok) {
348
+ stdout(
349
+ `TypeSafe provider entry merged into ${provision.path} (adapter + baseURL + apiKey via {env:TYPESAFE_API_KEY}, type "decision"). ` +
350
+ 'Activate: export TYPESAFE_API_KEY=<your TypeSafe key> and restart OpenCode. /connect does not carry custom providers.',
351
+ )
352
+ } else {
353
+ stdout(`⚠ TypeSafe provider entry NOT merged: ${provision.reason}`)
354
+ }
355
+ }
356
+
339
357
  const ledger = openLedger(env)
340
358
  try {
341
359
  ledger.configureUserCaps({
@@ -373,11 +391,11 @@ export async function runDecisionRouterCommand(
373
391
 
374
392
  stdout('')
375
393
  stdout('Native route checklist:')
376
- stdout(
377
- ' 1. Host catalog: the model must exist as type "decision" (stock: opencode/jev-1.13; custom providers need type: "decision" in opencode.json). Verify: decision-router doctor',
378
- )
379
- stdout(' 2. Restart OpenCode so the plugin registers pantheon_jev_decide.')
380
- stdout(' 3. Ask the Zeus agent to call pantheon_jev_decide (mode: "delegation" or "skills").')
394
+ // Decision models are not chat models: they never appear in the host
395
+ // model catalog (field evidence 2.2.5: 561 entries, 0 jev, while the
396
+ // decisions API answers the same ref directly). No catalog step here.
397
+ stdout(' 1. Restart OpenCode so the plugin registers pantheon_jev_decide.')
398
+ stdout(' 2. Ask the Zeus agent to call pantheon_jev_decide (mode: "delegation" or "skills").')
381
399
  stdout('Read-only verification: decision-router status / doctor / holds.')
382
400
  return
383
401
  }
@@ -468,25 +486,50 @@ export async function runDecisionRouterCommand(
468
486
  ? { provider: egress.provider, model: egress.candidate.model }
469
487
  : null
470
488
  if (target !== null) {
471
- const probe = probeHostCatalog(env)
472
- const hostProvider = target.provider === 'typesafe-jev' ? 'typesafe-ai' : 'opencode'
473
- if (probe.ok) {
474
- const exact = probe.models.has(`${hostProvider}/${target.model}`)
475
- const loose = probe.models.has(target.model)
476
- if (exact || loose) {
477
- pass('host-catalog', `${hostProvider}/${target.model} listed by \`opencode models\``)
478
- } else {
489
+ // Route-aware checks, not a catalog probe: decision models are not chat
490
+ // models and never appear in `opencode models` (field evidence 2.2.5:
491
+ // 561 entries, 0 jev, while the decisions API answers the same ref).
492
+ if (target.provider === 'openrouter-jev' || target.provider === 'vercel-gateway-jev') {
493
+ const envName =
494
+ target.provider === 'openrouter-jev' ? 'OPENROUTER_API_KEY' : 'AI_GATEWAY_API_KEY'
495
+ pass(
496
+ 'native-route',
497
+ `host-native ${target.provider === 'openrouter-jev' ? 'openrouter' : 'vercel-ai-gateway'} route; credential ${envName} via /connect or the environment`,
498
+ )
499
+ } else if (target.provider === 'cloudflare-workers-jev') {
500
+ warn(
501
+ 'native-route',
502
+ 'host module exists but the provider needs a custom entry with your Cloudflare accountId (models.dev does not carry it)',
503
+ 'add providers["cloudflare-workers-ai"] with accountId + CLOUDFLARE_API_TOKEN (scoped Workers AI token); model clef',
504
+ )
505
+ } else if (target.provider === 'typesafe-jev') {
506
+ const hostProvider = inspectTypesafeHostProvider({ env })
507
+ if (!hostProvider.present) {
508
+ fail(
509
+ 'native-route',
510
+ `opencode.json has no providers.typesafe-ai entry (${hostProvider.path})`,
511
+ 'decision-router setup-model typesafe-jev/jev-1.14.0 merges the full provider entry (adapter, baseURL, apiKey ref)',
512
+ )
513
+ } else if (!hostProvider.hasCredential) {
479
514
  warn(
480
- 'host-catalog',
481
- `${hostProvider}/${target.model} not in the flat models list`,
482
- 'the flat list can omit decision-typed models; if a call refuses with ROUTE_UNRESOLVED, add a custom provider entry with type: "decision" (see docs/reference/native-decisions.md) or pick a listed decision model',
515
+ 'native-route',
516
+ 'provider entry has no apiKey',
517
+ 'set the TypeSafe key: export TYPESAFE_API_KEY=... and re-run setup-model (writes {env:TYPESAFE_API_KEY}), or add options.apiKey to the entry',
518
+ )
519
+ } else {
520
+ pass(
521
+ 'native-route',
522
+ `typesafe-ai provider entry present (${hostProvider.path}); credential ${
523
+ hostProvider.viaEnvRef
524
+ ? `via env reference (${hostProvider.apiKeyRef}) — resolved by the host at call time`
525
+ : 'inline in the entry'
526
+ }`,
483
527
  )
484
528
  }
485
529
  } else {
486
- warn(
487
- 'host-catalog',
488
- `could not probe: ${probe.reason}`,
489
- 'run `opencode models` manually; slow plugin activation is the usual cause',
530
+ pass(
531
+ 'native-route',
532
+ 'host-native opencode route; decision models are not listed in the chat catalog by design',
490
533
  )
491
534
  }
492
535
  }
@@ -503,41 +546,6 @@ export async function runDecisionRouterCommand(
503
546
  throw new DecisionRouterUsageError(USAGE)
504
547
  }
505
548
 
506
- /** Spawn-sync timeout floor so a wedged host cannot stall the doctor. */
507
- const HOST_PROBE_TIMEOUT_MS = 30_000
508
-
509
- /**
510
- * Best-effort host catalog probe for the doctor. Returns the set of
511
- * `provider/model` (and bare model ids, for exact-id matching) the host
512
- * reports, or the reason the probe failed. Never writes anything.
513
- */
514
- function probeHostCatalog(env) {
515
- let result
516
- try {
517
- result = spawnSync('opencode', ['models'], {
518
- encoding: 'utf8',
519
- timeout: HOST_PROBE_TIMEOUT_MS,
520
- env,
521
- })
522
- } catch (error) {
523
- return { ok: false, reason: String(error?.message ?? error) }
524
- }
525
- if (result.error) return { ok: false, reason: String(result.error.message ?? result.error) }
526
- if (result.status !== 0) {
527
- const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim()
528
- return { ok: false, reason: output.slice(0, 120) || `exit ${result.status}` }
529
- }
530
- const models = new Set()
531
- for (const line of `${result.stdout ?? ''}`.split(/\r?\n/)) {
532
- const id = line.trim()
533
- if (!id) continue
534
- models.add(id)
535
- const slash = id.indexOf('/')
536
- if (slash > 0) models.add(id.slice(slash + 1))
537
- }
538
- return { ok: true, models }
539
- }
540
-
541
549
  /** Cap- and period-eligible candidates, read-only, from the separated surfaces. */
542
550
  function capEligibleCandidates(config, inspection, wallPeriod) {
543
551
  if (inspection.caps === null) return []