pantheon-opencode 1.6.2-beta.5 → 1.6.2-beta.7
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 +35 -0
- package/README.md +40 -38
- package/README.pt-BR.md +9 -0
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +4 -5
- package/scripts/decision-router.mjs +240 -1
- package/scripts/install/decision-router-config.mjs +4 -23
- package/src/agents/zeus.md +35 -65
- package/src/pantheon/jev-decision-tool.ts +336 -0
- package/src/pantheon/jev-decisions.ts +625 -0
- package/src/pantheon/local-decision-budget.ts +4 -1
- package/src/pantheon/local-decision-egress-gate.ts +16 -136
- package/src/pantheon/local-decision-prompt.ts +3 -9
- package/src/pantheon/local-decision-provider-matrix.ts +14 -62
- package/src/pantheon/local-decision-turn.ts +15 -252
- package/src/pantheon/local-decision-usage-evidence.internal.ts +80 -119
- package/src/pantheon/v2-decision-points/p8-guardrail.ts +3 -2
- package/src/pantheon/v2-decision-points.ts +1 -1
- package/src/pantheon/v2-native-decisions.ts +365 -0
- package/src/pantheon/v2-tools.ts +3 -0
- package/src/plugin-v2.ts +59 -15
- package/src/plugins/tui/dist/tui-v2.js +3 -3
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/pantheon/local-decision-provider-protocol.ts +0 -335
- package/src/pantheon/local-decision-provider.internal.ts +0 -260
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,41 @@ 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.2-beta.7] - 2026-11-02
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **install** — Added `decision-router setup-model <provider>/<model> --monthly-usd N --per-decision-usd N`: one command performs selection, enablement, egress consent, user/provider/model caps, and budget-period confirmation, then prints the verification checklist (`--no-consent` configures everything except consent).
|
|
18
|
+
- **install** — Added `decision-router doctor`: read-only diagnosis of the whole native decision route (config, consent, selection, budget admission, unresolved holds, best-effort host-catalog probe) printing the exact command to run for each failing gate.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **agents** — Modernized the Zeus system prompt: pruned stale release-history sections, kept the operational guards, and granted `pantheon_jev_decide` in the agent permission frontmatter so new installs get the advisory tool without manual config edits.
|
|
23
|
+
- **docs** — Documented ready-to-copy decision-provider examples (TypeSafe direct, OpenRouter-hosted Jev) with the catalog caveat that the flat `opencode models` list can omit decision-typed models.
|
|
24
|
+
- **agents** — Zeus routing policy now prefers one typed `pantheon_jev_decide` call for genuinely ambiguous routing and skill stacking, with `pantheon_local_decision` as the offline fallback.
|
|
25
|
+
- **docs** — Documented the skill-discovery loop (find, review, install, decide) and mapped the candidate MCP-gating expansions as deliberately unwired.
|
|
26
|
+
|
|
27
|
+
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
28
|
+
move this section to a versioned entry and reset the template below. -->
|
|
29
|
+
## [v1.6.2-beta.6] - 2026-11-01
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **routing** — Added the Zeus-only `pantheon_jev_decide` advisory tool: 1–4 typed questions (choice, score, predicate) answered by the Jev decision model through the host's native Decisions API; it registers only on hosts exposing that API and never dispatches agents, runs skills, or changes permissions.
|
|
34
|
+
- **routing** — Added native route selection from the user-level decision-router config (OpenCode Console `jev-1.13` and custom `typesafe-ai` decision models) with a frozen provider→host mapping; direct OpenAI is refused and never substituted.
|
|
35
|
+
- **routing** — Added host-reported settlement: the budget reservation reconciles from the host-reported DecisionResult cost (a reported zero releases the hold), and a failed or unreconciled call stays fail-closed.
|
|
36
|
+
- **routing** — Added catalog presets to `pantheon_jev_decide`: `mode: "skills"` stacks the locally prefiltered skill shortlist (whole-catalog fallback) and `mode: "delegation"` picks a specialist, both single typed calls with `none` always offered.
|
|
37
|
+
- **routing** — Extended the `skills` preset to decide over installed host skills (`ctx.skill.list()`) in addition to the Pantheon catalog: any Agent-Skills-format skill installed in the host becomes stackable without a Pantheon change. Installs stay manual and reviewed; Pantheon never installs or updates skills.
|
|
38
|
+
- **docs** — Documented the native gate chain, routes, and verification boundary in one reference (`docs/reference/native-decisions.md`) and indexed the decision-layer references in the docs nav; added a real-host canary assertion for the new tool's registration.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **security** — Removed the direct-fetch decision-provider path entirely (runner, payload protocol, fetch-path usage verifier, per-turn provider cache): Pantheon owns no transport, and the only egress is the host's native layer behind the enabled/consent/budget/permission chain. The per-turn prompt hook stays local-only.
|
|
43
|
+
- **security** — The budget ledger now treats a host-reported zero cost as a real zero (releasing the hold) while still freezing user/provider/model buckets when actual cost exceeds the reservation.
|
|
44
|
+
- **docs** — Consolidated the decision-status narrative to one source of truth per surface, corrected stale env-var rows (no decision credential is read on any production path), and removed an orphan planning note (the tracked deepwork note stays: it is the checkout fixture the resources server resolves against).
|
|
45
|
+
|
|
46
|
+
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
47
|
+
move this section to a versioned entry and reset the template below. -->
|
|
13
48
|
## [v1.6.2-beta.5] - 2026-11-01
|
|
14
49
|
|
|
15
50
|
## 🆕 What's New
|
package/README.md
CHANGED
|
@@ -97,14 +97,16 @@ see [Quick Start](docs/QUICKSTART.md).
|
|
|
97
97
|
and documenting work.
|
|
98
98
|
- **5 local MCP servers** for project memory, persistence, resources, confined
|
|
99
99
|
script execution, and vision.
|
|
100
|
-
- **A selective, advisory decision router** with structured local results and
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
decision
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
- **A selective, advisory decision router** with structured local results and
|
|
101
|
+
deterministic per-turn skill/specialist recommendations when enabled.
|
|
102
|
+
Pantheon-owned direct-provider egress is inactive; native egress exists only
|
|
103
|
+
via the explicit, Zeus-only `pantheon_jev_decide` advisory tool, which calls
|
|
104
|
+
the host's native Decisions API (TypeSafe Jev via OpenCode Console or a
|
|
105
|
+
configured decision model) behind the user's consent and budget gates — it
|
|
106
|
+
never dispatches agents, runs skills, or changes permissions. This does not
|
|
107
|
+
change separately documented quota and Vision integrations. See the
|
|
108
|
+
[router reference](docs/reference/local-decision-router.md) and the
|
|
109
|
+
[Native Decisions (Jev)](docs/reference/native-decisions.md).
|
|
108
110
|
- **An optional TUI** with a dispatch sidebar block and a full-width
|
|
109
111
|
`/dispatch` panel. The V2 TUI also provides a quota overview in the
|
|
110
112
|
sidebar/footer and a `/quota` details panel. Quota display is enabled by
|
|
@@ -242,26 +244,29 @@ fan-in or job recovery without an exposed mechanism.
|
|
|
242
244
|
The delegation model, caller/target matrix, and approval gates are documented
|
|
243
245
|
in [Architecture](docs/ARCHITECTURE.md) and
|
|
244
246
|
[Permissions, Gates & Delegation](docs/PERMISSIONS-QUALITY-DELEGATION.md).
|
|
245
|
-
The [local decision router](docs/reference/local-decision-router.md)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
247
|
+
The [local decision router](docs/reference/local-decision-router.md) provides a
|
|
248
|
+
default-off standalone local API (`PANTHEON_LOCAL_DECISION_ROUTER=1`), the
|
|
249
|
+
separate manual `pantheon_local_decision` advisory tool, and deterministic
|
|
250
|
+
per-turn local recommendations when the user-level `enabled` preference is on.
|
|
251
|
+
The prompt hook may add an advisory marker and narrow an existing `prompt.skills`
|
|
252
|
+
array only when identifiable skill IDs overlap the local selection; this never
|
|
253
|
+
dispatches child sessions or changes permissions or approvals. Per-turn selection
|
|
254
|
+
uses no provider egress: the formerly documented direct-provider route remains
|
|
255
|
+
historical/inactive, and legacy consent, caps, period, provider selection, or
|
|
256
|
+
credentials cannot activate it. Native child-session dispatch remains separate.
|
|
257
|
+
|
|
258
|
+
The one native egress surface is the Zeus-only `pantheon_jev_decide` tool,
|
|
259
|
+
available on hosts that expose the V2.2.5 native Decisions API; its full gate
|
|
260
|
+
chain, routes, and settlement rules are documented once in
|
|
261
|
+
[V2 native Decisions](docs/reference/native-decisions.md).
|
|
258
262
|
|
|
259
263
|
The installer may retain a legacy target-specific preference; it does not control
|
|
260
|
-
runtime routing. `npx pantheon-opencode decision-router ...` manages
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
credentials. The published CLI imports
|
|
264
|
+
runtime routing. `npx pantheon-opencode decision-router ...` manages stored
|
|
265
|
+
user-level preferences and budget state: `enabled` gates the local per-turn
|
|
266
|
+
recommendation only; provider-selection and budget/consent state do not activate
|
|
267
|
+
egress. The separate SQLite ledger has no default caps. Installation does not
|
|
268
|
+
contact a model provider or inspect credentials. The published CLI imports
|
|
269
|
+
committed ESM bundles:
|
|
265
270
|
`npm run build:decision-router` regenerates them and `npm run check:decision-router`
|
|
266
271
|
(the `prepack`/`prepublishOnly` drift gate) fails when any is stale. The
|
|
267
272
|
`pantheon-opencode/local-decision-router` subpath itself is TypeScript source, so
|
|
@@ -287,17 +292,14 @@ extra copy is made. Installer file-ownership tracking is partial and asymmetric
|
|
|
287
292
|
are not separately indexed — so this preview compares the decision-layer
|
|
288
293
|
artifacts it owns, not "everything the installer touched".
|
|
289
294
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
absence on an unexercised path; `permission.evaluate.egress` is likewise
|
|
299
|
-
unreachable in the probed host (a tool declaring it is never advertised to the
|
|
300
|
-
provider). Measured surface coverage is
|
|
295
|
+
The old OpenAI/TypeSafe per-turn provider adapters and endpoint descriptions are
|
|
296
|
+
retained as historical, inert code; no legacy consent, cap, period, provider, or
|
|
297
|
+
permission setting wires them into the production prompt hook. The captured-hook
|
|
298
|
+
boundary test supplies an isolated synthetic consent/provider config and fake
|
|
299
|
+
test-only credential, verifies a local recommendation marker, and verifies zero
|
|
300
|
+
native Decisions or global `fetch` calls. This is an offline regression check of
|
|
301
|
+
that hook, not a claim about unexercised network paths or a live-provider test.
|
|
302
|
+
Measured surface coverage is
|
|
301
303
|
reported honestly rather than implied: P7 runs behind `PANTHEON_V2_P7_LOOP` with
|
|
302
304
|
an **advisory** execution cap (never described as enforcement), P2 is
|
|
303
305
|
**advisory-only** (an empirical no-op on the default path), P9 was measured on
|
|
@@ -432,7 +434,7 @@ recorded in the [router reference](docs/reference/local-decision-router.md).
|
|
|
432
434
|
| [Compatibility](docs/COMPATIBILITY.md) | [OpenCode V2](docs/opencode-v2.md) |
|
|
433
435
|
| [Agents & Skills](docs/agents/README.md) | [Platforms](docs/PLATFORMS.md) |
|
|
434
436
|
| [Release Process](docs/RELEASING.md) | [Branch Protection](docs/BRANCH-PROTECTION.md) |
|
|
435
|
-
| [Model Routing](docs/reference/model-routing.md) | [Local Decision Router](docs/reference/local-decision-router.md) · [Offline Evaluation Protocol](docs/reference/offline-evaluation.md) · [Env Vars](docs/reference/env-vars.md) · [Code Mode](docs/reference/code-mode.md) |
|
|
437
|
+
| [Model Routing](docs/reference/model-routing.md) | [Local Decision Router](docs/reference/local-decision-router.md) · [V2 Native Decisions](docs/reference/native-decisions.md) · [Offline Evaluation Protocol](docs/reference/offline-evaluation.md) · [Env Vars](docs/reference/env-vars.md) · [Code Mode](docs/reference/code-mode.md) |
|
|
436
438
|
| [Contributing](CONTRIBUTING.md) | [Roadmap](ROADMAP.md) · [Changelog](CHANGELOG.md) |
|
|
437
439
|
|
|
438
440
|
Memory writes through `pantheon-memory` are serialized, and failed writes are
|
package/README.pt-BR.md
CHANGED
|
@@ -75,6 +75,15 @@ apenas — `init` → reiniciar → `/dispatch` → primeiro resultado — veja
|
|
|
75
75
|
documentar.
|
|
76
76
|
- **5 servidores MCP locais** para memória de projeto, persistência, recursos,
|
|
77
77
|
execução confinada de scripts e visão.
|
|
78
|
+
- **Um roteador de decisão seletivo e consultivo**, com resultados locais
|
|
79
|
+
estruturados e recomendações por turno quando habilitado. O egress direto
|
|
80
|
+
pertencente ao Pantheon é inativo; o egress nativo existe apenas na tool
|
|
81
|
+
explícita `pantheon_jev_decide` (só para o Zeus), que chama a API nativa de
|
|
82
|
+
Decisions do host (Jev/TypeSafe via OpenCode Console ou modelo configurado)
|
|
83
|
+
atrás do consentimento e dos limites de orçamento do usuário — ela nunca
|
|
84
|
+
despacha agentes, executa skills ou altera permissões. Veja a
|
|
85
|
+
[referência do roteador](docs/reference/local-decision-router.md) e o
|
|
86
|
+
[Decisions nativas (Jev)](docs/reference/native-decisions.md).
|
|
78
87
|
- **Uma TUI opcional**, com bloco de dispatch na sidebar e painel `/dispatch`
|
|
79
88
|
em largura total. A TUI V2 também inclui um resumo de quota na sidebar/rodapé
|
|
80
89
|
e o painel `/quota`, com abas Usage, Limits, Plugin e Settings. Usage mostra
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-opencode",
|
|
3
|
-
"version": "1.6.2-beta.
|
|
3
|
+
"version": "1.6.2-beta.7",
|
|
4
4
|
"description": "Multi-agent orchestration for OpenCode — 14 specialized agents, TDD, Themis review gates.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"@biomejs/biome": "2.5.14",
|
|
121
121
|
"@commitlint/cli": "21.2.3",
|
|
122
122
|
"@commitlint/config-conventional": "21.2.3",
|
|
123
|
+
"@opencode/plugin": "2.2.5",
|
|
123
124
|
"ajv": "8.20.0",
|
|
124
125
|
"esbuild": "0.28.2",
|
|
125
126
|
"husky": "^9.1.7",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon",
|
|
3
3
|
"publisher": "ils15",
|
|
4
|
-
"version": "1.6.2-beta.
|
|
4
|
+
"version": "1.6.2-beta.7",
|
|
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.
|
|
7
|
+
version = "1.6.2-beta.7"
|
|
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
|
|
@@ -11,10 +11,6 @@ import { performance } from "node:perf_hooks";
|
|
|
11
11
|
import { DatabaseSync } from "node:sqlite";
|
|
12
12
|
|
|
13
13
|
// src/pantheon/local-decision-usage-evidence.internal.ts
|
|
14
|
-
var MODEL_IDS = Object.freeze({
|
|
15
|
-
"openai-decisions": "gpt-6-luna",
|
|
16
|
-
"typesafe-jev": "jev-1.14.0"
|
|
17
|
-
});
|
|
18
14
|
var evidenceDetails = /* @__PURE__ */ new WeakMap();
|
|
19
15
|
function getVerifiedUsageEvidenceDetails(value) {
|
|
20
16
|
if (typeof value !== "object" && typeof value !== "function" || value === null) return null;
|
|
@@ -287,7 +283,10 @@ function openLocalDecisionBudgetLedger(options = {}) {
|
|
|
287
283
|
return { status: "unknown" };
|
|
288
284
|
}
|
|
289
285
|
const verified = getVerifiedUsageEvidenceDetails(evidence);
|
|
290
|
-
if (!verified || !Number.isSafeInteger(verified.actualCostMicros) ||
|
|
286
|
+
if (!verified || !Number.isSafeInteger(verified.actualCostMicros) || // Zero is a legitimate host-reported cost on the native route (the free
|
|
287
|
+
// Console variant and hosts that do not price Decisions); reconciling at
|
|
288
|
+
// zero releases the hold instead of burning the period's budget.
|
|
289
|
+
verified.actualCostMicros < 0 || !isAllowedProvider(verified.provider) || !isAllowedModel(verified.model) || !isValidPeriod(verified.period)) {
|
|
291
290
|
return { status: "unknown" };
|
|
292
291
|
}
|
|
293
292
|
return inImmediateTransaction(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process'
|
|
2
3
|
import { existsSync } from 'node:fs'
|
|
3
4
|
import { pathToFileURL } from 'node:url'
|
|
4
5
|
// Prebuilt bundles: Node refuses to strip TypeScript types under node_modules,
|
|
@@ -41,7 +42,7 @@ import { readState } from './install/state.mjs'
|
|
|
41
42
|
const BUDGET_PROVIDERS = DECISION_PROVIDER_BUDGET_MAPPING
|
|
42
43
|
|
|
43
44
|
const USAGE =
|
|
44
|
-
'Usage: decision-router help|status|setup|preview|select|enable|disable|consent|caps|period|holds'
|
|
45
|
+
'Usage: decision-router help|status|setup|preview|select|enable|disable|consent|caps|period|holds|setup-model|doctor'
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Malformed command line (wrong flags, unknown provider, invalid value).
|
|
@@ -71,6 +72,13 @@ export function decisionRouterHelp() {
|
|
|
71
72
|
' caps user|provider <p>|model <p> <m> --monthly-usd N --per-decision-usd N',
|
|
72
73
|
' period confirm --current none|YYYY-MM --next YYYY-MM',
|
|
73
74
|
'',
|
|
75
|
+
'Guided (each does the whole chain in one command):',
|
|
76
|
+
' setup-model <provider>/<model> --monthly-usd N --per-decision-usd N [--no-consent]',
|
|
77
|
+
' select + enable + consent + caps + period in one write,',
|
|
78
|
+
' then print the verification summary',
|
|
79
|
+
' doctor read-only diagnosis of the native decision route with',
|
|
80
|
+
' the exact command to run for each failing gate',
|
|
81
|
+
'',
|
|
74
82
|
'setup options:',
|
|
75
83
|
' --apply write the previewed artifacts (otherwise nothing is written)',
|
|
76
84
|
' --json machine-readable plan',
|
|
@@ -296,9 +304,240 @@ export async function runDecisionRouterCommand(
|
|
|
296
304
|
return
|
|
297
305
|
}
|
|
298
306
|
|
|
307
|
+
if (command === 'setup-model') {
|
|
308
|
+
const [target, ...flagArgs] = rest
|
|
309
|
+
const selection = parseSelectionTarget(target)
|
|
310
|
+
if (selection.mode !== 'explicit') {
|
|
311
|
+
throw new DecisionRouterUsageError(
|
|
312
|
+
'setup-model requires an explicit provider/model pair, not local or auto',
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
const noConsent = flagArgs.includes('--no-consent')
|
|
316
|
+
const capArgs = flagArgs.filter((arg) => arg !== '--no-consent')
|
|
317
|
+
// Exactly the two caps flags with values; parseCaps validates them and
|
|
318
|
+
// leaves `rest` empty because setup-model has no positional caps targets.
|
|
319
|
+
if (capArgs.length !== 4) throw new DecisionRouterUsageError(USAGE)
|
|
320
|
+
const caps = parseCaps(capArgs)
|
|
321
|
+
if (caps.rest.length > 0) throw new DecisionRouterUsageError(USAGE)
|
|
322
|
+
const { provider, model } = selection
|
|
323
|
+
const candidate = { provider, model }
|
|
324
|
+
|
|
325
|
+
// One update names selection, enablement, candidates and (unless refused)
|
|
326
|
+
// consent together: selecting a different target revokes consent unless
|
|
327
|
+
// the same update names it, so this single write is the consent act.
|
|
328
|
+
saveConfig(env, {
|
|
329
|
+
enabled: true,
|
|
330
|
+
selection,
|
|
331
|
+
enabled_candidates: [candidate],
|
|
332
|
+
...(noConsent ? {} : { egress_consent: true }),
|
|
333
|
+
})
|
|
334
|
+
stdout(`Selected and enabled ${provider}/${model}.`)
|
|
335
|
+
stdout(
|
|
336
|
+
noConsent ? 'Egress consent NOT recorded (--no-consent).' : 'Egress consent recorded: yes.',
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
const ledger = openLedger(env)
|
|
340
|
+
try {
|
|
341
|
+
ledger.configureUserCaps({
|
|
342
|
+
monthlyCapMicros: caps.monthly,
|
|
343
|
+
perDecisionCapMicros: caps.perDecision,
|
|
344
|
+
})
|
|
345
|
+
ledger.configureProviderCaps(DECISION_PROVIDER_BUDGET_MAPPING[provider], {
|
|
346
|
+
monthlyCapMicros: caps.monthly,
|
|
347
|
+
perDecisionCapMicros: caps.perDecision,
|
|
348
|
+
})
|
|
349
|
+
ledger.configureModelCaps(DECISION_PROVIDER_BUDGET_MAPPING[provider], model, {
|
|
350
|
+
monthlyCapMicros: caps.monthly,
|
|
351
|
+
perDecisionCapMicros: caps.perDecision,
|
|
352
|
+
})
|
|
353
|
+
stdout(
|
|
354
|
+
`Caps set (user/provider/model): $${(caps.monthly / 1_000_000).toFixed(2)}/month, $${(caps.perDecision / 1_000_000).toFixed(2)}/decision.`,
|
|
355
|
+
)
|
|
356
|
+
const wallPeriod = utcPeriodOf(Date.now())
|
|
357
|
+
const active = ledger.getActiveBudgetPeriod()
|
|
358
|
+
if (active === wallPeriod) {
|
|
359
|
+
stdout(`Budget period already active: ${wallPeriod}.`)
|
|
360
|
+
} else {
|
|
361
|
+
const result = ledger.confirmBudgetPeriod(active, wallPeriod)
|
|
362
|
+
if (result.status === 'confirmed') {
|
|
363
|
+
stdout(`Budget period confirmed: ${result.activePeriod}. Automatic rollover is disabled.`)
|
|
364
|
+
} else {
|
|
365
|
+
stdout(
|
|
366
|
+
`Budget period NOT confirmed (${result.reason}); run: decision-router period confirm --current ${active ?? 'none'} --next ${wallPeriod}`,
|
|
367
|
+
)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} finally {
|
|
371
|
+
ledger.close()
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
stdout('')
|
|
375
|
+
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").')
|
|
381
|
+
stdout('Read-only verification: decision-router status / doctor / holds.')
|
|
382
|
+
return
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (command === 'doctor' && rest.length === 0) {
|
|
386
|
+
// Read-only diagnosis. The host-catalog probe runs `opencode models` with a
|
|
387
|
+
// timeout; a missing/unavailable binary is a warning, not a failure.
|
|
388
|
+
const config = readUserDecisionRouterConfig({ env })
|
|
389
|
+
const dbPath = resolveLocalDecisionBudgetDbPath(env)
|
|
390
|
+
const inspection = inspectDecisionBudget(dbPath)
|
|
391
|
+
const wallPeriod = utcPeriodOf(Date.now())
|
|
392
|
+
const egress = describeEgress(config, inspection, wallPeriod)
|
|
393
|
+
const rows = []
|
|
394
|
+
const fail = (name, detail, fix) => rows.push({ name, state: 'FAIL', detail, fix })
|
|
395
|
+
const warn = (name, detail, fix) => rows.push({ name, state: 'WARN', detail, fix })
|
|
396
|
+
const pass = (name, detail) => rows.push({ name, state: 'PASS', detail })
|
|
397
|
+
|
|
398
|
+
if (!existsSync(resolveUserDecisionRouterConfigPath(env))) {
|
|
399
|
+
fail(
|
|
400
|
+
'config',
|
|
401
|
+
'no user-level config yet',
|
|
402
|
+
'decision-router setup-model <provider>/<model> --monthly-usd N --per-decision-usd N',
|
|
403
|
+
)
|
|
404
|
+
} else if (!config.enabled) {
|
|
405
|
+
fail('config', 'turn selection is disabled', 'decision-router enable')
|
|
406
|
+
} else {
|
|
407
|
+
pass('config', 'enabled')
|
|
408
|
+
}
|
|
409
|
+
if (config.enabled && !config.egress_consent) {
|
|
410
|
+
fail(
|
|
411
|
+
'consent',
|
|
412
|
+
'egress consent missing',
|
|
413
|
+
'decision-router consent yes (or rerun setup-model without --no-consent)',
|
|
414
|
+
)
|
|
415
|
+
} else if (config.enabled) {
|
|
416
|
+
pass('consent', 'recorded')
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const selection = config.selection
|
|
420
|
+
if (config.enabled && selection.mode === 'local') {
|
|
421
|
+
fail('selection', 'selection is local', 'decision-router select <provider>/<model>')
|
|
422
|
+
} else if (config.enabled && selection.mode === 'auto') {
|
|
423
|
+
if (egress.mode === 'opt-in')
|
|
424
|
+
pass('selection', `auto resolved ${egress.provider}/${egress.candidate.model}`)
|
|
425
|
+
else
|
|
426
|
+
fail(
|
|
427
|
+
'selection',
|
|
428
|
+
`auto did not resolve (${egress.reason})`,
|
|
429
|
+
'enable exactly one cap-valid candidate, or select explicitly',
|
|
430
|
+
)
|
|
431
|
+
} else if (config.enabled && selection.mode === 'explicit') {
|
|
432
|
+
const enabled = config.enabled_candidates.some(
|
|
433
|
+
(candidate) =>
|
|
434
|
+
candidate.provider === selection.provider && candidate.model === selection.model,
|
|
435
|
+
)
|
|
436
|
+
if (!enabled) {
|
|
437
|
+
fail(
|
|
438
|
+
'selection',
|
|
439
|
+
`${selection.provider}/${selection.model} selected but not enabled`,
|
|
440
|
+
`decision-router enable ${selection.provider} ${selection.model}`,
|
|
441
|
+
)
|
|
442
|
+
} else {
|
|
443
|
+
pass('selection', `${selection.provider}/${selection.model}`)
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (config.enabled && egress.mode !== 'opt-in' && config.egress_consent) {
|
|
448
|
+
fail(
|
|
449
|
+
'budget',
|
|
450
|
+
`no cap- and period-eligible candidate (${egress.reason})`,
|
|
451
|
+
'decision-router caps user|provider|model ... and decision-router period confirm',
|
|
452
|
+
)
|
|
453
|
+
} else if (config.enabled && egress.mode === 'opt-in') {
|
|
454
|
+
pass('budget', `admission open for ${egress.provider}/${egress.candidate.model}`)
|
|
455
|
+
}
|
|
456
|
+
if (inspection.ledger.present && inspection.ledger.readable && inspection.ledger.holds > 0) {
|
|
457
|
+
warn(
|
|
458
|
+
'holds',
|
|
459
|
+
`${inspection.ledger.holds} unresolved hold(s) hold budget until reconciled`,
|
|
460
|
+
'decision-router holds',
|
|
461
|
+
)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const target =
|
|
465
|
+
config.enabled && selection.mode === 'explicit'
|
|
466
|
+
? selection
|
|
467
|
+
: egress.mode === 'opt-in'
|
|
468
|
+
? { provider: egress.provider, model: egress.candidate.model }
|
|
469
|
+
: null
|
|
470
|
+
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 {
|
|
479
|
+
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',
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
} else {
|
|
486
|
+
warn(
|
|
487
|
+
'host-catalog',
|
|
488
|
+
`could not probe: ${probe.reason}`,
|
|
489
|
+
'run `opencode models` manually; slow plugin activation is the usual cause',
|
|
490
|
+
)
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
for (const row of rows) {
|
|
495
|
+
const mark = row.state === 'PASS' ? '✔' : row.state === 'WARN' ? '▲' : '✖'
|
|
496
|
+
stdout(`${mark} ${row.name}: ${row.detail}`)
|
|
497
|
+
if (row.fix) stdout(` fix → ${row.fix}`)
|
|
498
|
+
}
|
|
499
|
+
stdout('Read-only: doctor never creates, migrates or writes anything.')
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
|
|
299
503
|
throw new DecisionRouterUsageError(USAGE)
|
|
300
504
|
}
|
|
301
505
|
|
|
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
|
+
|
|
302
541
|
/** Cap- and period-eligible candidates, read-only, from the separated surfaces. */
|
|
303
542
|
function capEligibleCandidates(config, inspection, wallPeriod) {
|
|
304
543
|
if (inspection.caps === null) return []
|
|
@@ -80,7 +80,6 @@ const LEGACY_USER_CONFIG_KEYS = [
|
|
|
80
80
|
* new install-time option appears.
|
|
81
81
|
*/
|
|
82
82
|
const ACCEPTED_INSTALL_STATE_PROVIDERS = new Set([...DECISION_ROUTER_PROVIDERS, 'typesafe-jev'])
|
|
83
|
-
const externalProviderSet = new Set(['openai-decisions', 'jev', 'typesafe-jev'])
|
|
84
83
|
|
|
85
84
|
/** Canonicalize the legacy `jev` spelling once, at every user-config boundary. */
|
|
86
85
|
export function normalizeDecisionProviderId(provider) {
|
|
@@ -125,29 +124,11 @@ export function createDecisionRouterConfig(provider, egressConsent = false) {
|
|
|
125
124
|
|
|
126
125
|
/**
|
|
127
126
|
* Resolve a preference without probing the environment or credentials.
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @returns {'local'|'openai-decisions'|'jev'|'typesafe-jev'}
|
|
127
|
+
* (The legacy `resolveDecisionRouterProvider` auto resolver was removed with
|
|
128
|
+
* the direct-fetch provider path; runtime selection uses
|
|
129
|
+
* `resolveUserDecisionRouterCandidate` / `explainUserDecisionRouterAutoSelection`
|
|
130
|
+
* and the native route resolver.)
|
|
133
131
|
*/
|
|
134
|
-
export function resolveDecisionRouterProvider(
|
|
135
|
-
config,
|
|
136
|
-
{ authorizedProviders = [], budgetConfigured = false } = {},
|
|
137
|
-
) {
|
|
138
|
-
const preference = migrateDecisionRouterConfig(config)
|
|
139
|
-
if (!preference.egress_consent || budgetConfigured !== true) return 'local'
|
|
140
|
-
if (preference.provider === 'local') return 'local'
|
|
141
|
-
|
|
142
|
-
if (preference.provider === 'auto') {
|
|
143
|
-
const candidates = [
|
|
144
|
-
...new Set(authorizedProviders.filter((provider) => externalProviderSet.has(provider))),
|
|
145
|
-
]
|
|
146
|
-
return candidates.length === 1 ? candidates[0] : 'local'
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return externalProviderSet.has(preference.provider) ? preference.provider : 'local'
|
|
150
|
-
}
|
|
151
132
|
|
|
152
133
|
/**
|
|
153
134
|
* Resolve Pantheon's private non-secret user configuration path.
|