pantheon-opencode 1.6.2-beta.6 → 1.6.2-beta.8
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 +40 -0
- package/bin/pantheon-init.mjs +114 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router.mjs +240 -1
- package/scripts/install/interactive.mjs +61 -36
- package/scripts/install/opencode.mjs +9 -1
- package/scripts/install/strings.mjs +12 -0
- package/src/agents/aphrodite.md +5 -0
- package/src/agents/hermes.md +7 -9
- package/src/agents/talos.md +5 -0
- package/src/agents/zeus.md +40 -65
- package/src/pantheon/v2-hook-engine.ts +307 -0
- package/src/pantheon/v2-shell-hooks.ts +66 -2
- package/src/plugin-v2.ts +11 -3
- 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/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,49 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **install** — The wizard's decision-model question now configures the real route (consent + caps + period in one write): Console Jev, the free variant, or TypeSafe direct.
|
|
13
|
+
- **install** — Choosing TypeSafe direct merges the `providers.typesafe-ai` entry additively into the user's opencode.json; only the sign-in remains.
|
|
14
|
+
- **install** — Legacy metadata spellings degrade to skip with a hint; direct OpenAI has no native Decisions route.
|
|
15
|
+
- **install** — The capability notice prints only under `--verbose`.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **performance** — The in-process secret scan is gated to exfil-capable tools (shell, file writes, web); read-only tools skip it, unknown names stay scanned (fail-closed).
|
|
20
|
+
- **agents** — Zeus must never ask the user to type terminal commands: terminal work dispatches to a bash-capable specialist.
|
|
21
|
+
|
|
10
22
|
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
11
23
|
move this section to a versioned entry and reset the template below. -->
|
|
12
24
|
|
|
25
|
+
## [v1.6.2-beta.8] - 2026-11-02
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **install** — Added `init --decision-model <provider>/<model> --decision-monthly-usd N --decision-per-decision-usd N` to activate the Jev decision route during installation (the same chain as `decision-router setup-model`; `--decision-no-consent` refuses consent), and the post-install next steps now include the optional decision-model path in English and Portuguese.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **performance** — The per-tool-call secret scan and the per-dispatch delegation audit now run in-process (`v2-hook-engine.ts`): same patterns, masked trail, exit-code contract, fail-closed classifier, and `delegations.log` artifacts — without the former one `bash` child per tool call and two more per delegation (each also spawning `python3`). Post-write formatting spawns only when the tool call touched a formattable file.
|
|
34
|
+
- **agents** — Specialist prompts carry two-tier verification (small bounded fix → change plus one targeted proof; material change → full discipline), replacing the unconditional TDD mandate in Hermes; Aphrodite and Talos gained the same tier note.
|
|
35
|
+
- **docs** — New Performance and tuning reference (measured hook costs, prompt budget, decision latency, context-growth knob) and an INSTALLATION section for the Jev decision-model flow.
|
|
36
|
+
|
|
37
|
+
## [v1.6.2-beta.7] - 2026-11-02
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
|
|
41
|
+
- **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).
|
|
42
|
+
- **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.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **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.
|
|
47
|
+
- **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.
|
|
48
|
+
- **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.
|
|
49
|
+
- **docs** — Documented the skill-discovery loop (find, review, install, decide) and mapped the candidate MCP-gating expansions as deliberately unwired.
|
|
50
|
+
|
|
51
|
+
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
52
|
+
move this section to a versioned entry and reset the template below. -->
|
|
13
53
|
## [v1.6.2-beta.6] - 2026-11-01
|
|
14
54
|
|
|
15
55
|
### Added
|
package/bin/pantheon-init.mjs
CHANGED
|
@@ -60,6 +60,61 @@ function readVersion() {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Merge the TypeSafe decision-model provider entry into the user's
|
|
65
|
+
* `opencode.json` (never replaces existing keys; a non-JSON file is reported,
|
|
66
|
+
* never overwritten). Returns true, or a short failure reason.
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* Merge (never overwrite) the TypeSafe decision-model entry into the user's
|
|
70
|
+
* 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.
|
|
74
|
+
*/
|
|
75
|
+
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
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Value of a repeatable installer flag from the raw argv, or undefined. */
|
|
108
|
+
function readArgValue(name) {
|
|
109
|
+
const prefix = `${name}=`
|
|
110
|
+
for (let i = 1; i < process.argv.length; i++) {
|
|
111
|
+
const arg = process.argv[i]
|
|
112
|
+
if (arg === name) return process.argv[i + 1]
|
|
113
|
+
if (arg.startsWith(prefix)) return arg.slice(prefix.length)
|
|
114
|
+
}
|
|
115
|
+
return undefined
|
|
116
|
+
}
|
|
117
|
+
|
|
63
118
|
function printUsage() {
|
|
64
119
|
console.log('Pantheon OpenCode — Multi-agent orchestration platform')
|
|
65
120
|
console.log('')
|
|
@@ -78,6 +133,9 @@ function printUsage() {
|
|
|
78
133
|
console.log(' npx pantheon-opencode init --headless # Force non-interactive mode')
|
|
79
134
|
console.log(' npx pantheon-opencode init -y # Skip confirmations, use defaults')
|
|
80
135
|
console.log(' npx pantheon-opencode init --components agents,skills,instructions')
|
|
136
|
+
console.log(
|
|
137
|
+
' npx pantheon-opencode init --decision-model opencode-console-jev/jev-1.13 --decision-monthly-usd 5 --decision-per-decision-usd 0.10',
|
|
138
|
+
)
|
|
81
139
|
console.log(' npx pantheon-opencode init --opencode-version v1|v2|auto')
|
|
82
140
|
console.log(' npx pantheon-opencode init --preset <name> # Install and activate model preset')
|
|
83
141
|
console.log(
|
|
@@ -433,6 +491,9 @@ async function main() {
|
|
|
433
491
|
'--merge-dev-config',
|
|
434
492
|
'--apply-plan',
|
|
435
493
|
'--save-plan',
|
|
494
|
+
'--decision-model',
|
|
495
|
+
'--decision-monthly-usd',
|
|
496
|
+
'--decision-per-decision-usd',
|
|
436
497
|
])
|
|
437
498
|
for (let i = 1; i < args.length; i++) {
|
|
438
499
|
const arg = args[i]
|
|
@@ -958,6 +1019,56 @@ async function main() {
|
|
|
958
1019
|
}
|
|
959
1020
|
}
|
|
960
1021
|
|
|
1022
|
+
// Optional Jev decision-model activation, requested at install time with
|
|
1023
|
+
// explicit caps (the setup-model chain: selection + enable + consent +
|
|
1024
|
+
// user/provider/model caps + period confirmation). Dry-run prints intent
|
|
1025
|
+
// only. Failures never fail the install itself.
|
|
1026
|
+
// Explicit flags win; otherwise honor the wizard's Jev activation choice.
|
|
1027
|
+
const wizardActivation = result.decisionModelActivation ?? null
|
|
1028
|
+
const decisionTarget = readArgValue('--decision-model') ?? wizardActivation?.target ?? null
|
|
1029
|
+
if (decisionTarget) {
|
|
1030
|
+
const monthly = readArgValue('--decision-monthly-usd') ?? wizardActivation?.monthly ?? '5'
|
|
1031
|
+
const perDecision =
|
|
1032
|
+
readArgValue('--decision-per-decision-usd') ?? wizardActivation?.perDecision ?? '0.10'
|
|
1033
|
+
const noConsent = process.argv.includes('--decision-no-consent')
|
|
1034
|
+
console.log('')
|
|
1035
|
+
if (isDryRun) {
|
|
1036
|
+
console.log(` ${S.jevDryRun(decisionTarget)}`)
|
|
1037
|
+
} else {
|
|
1038
|
+
try {
|
|
1039
|
+
const { runDecisionRouterCommand } = await import('../scripts/decision-router.mjs')
|
|
1040
|
+
await runDecisionRouterCommand(
|
|
1041
|
+
[
|
|
1042
|
+
'setup-model',
|
|
1043
|
+
decisionTarget,
|
|
1044
|
+
'--monthly-usd',
|
|
1045
|
+
monthly,
|
|
1046
|
+
'--per-decision-usd',
|
|
1047
|
+
perDecision,
|
|
1048
|
+
...(noConsent ? ['--no-consent'] : []),
|
|
1049
|
+
],
|
|
1050
|
+
{ stdout: (line) => console.log(` ${line}`) },
|
|
1051
|
+
)
|
|
1052
|
+
console.log(` ${S.jevConfigured(decisionTarget)}`)
|
|
1053
|
+
if (decisionTarget.startsWith('typesafe-jev')) {
|
|
1054
|
+
const provisioned = provisionTypesafeProvider()
|
|
1055
|
+
console.log(
|
|
1056
|
+
provisioned === true
|
|
1057
|
+
? ' TypeSafe provider entry merged into opencode.json (models.typesafe-ai, type "decision"). Sign in with `opencode auth login` (TypeSafe) or /connect.'
|
|
1058
|
+
: ` TypeSafe provider entry NOT merged (${provisioned}); merge it manually — see docs/reference/native-decisions.md.`,
|
|
1059
|
+
)
|
|
1060
|
+
}
|
|
1061
|
+
} catch (error) {
|
|
1062
|
+
console.error(
|
|
1063
|
+
` ${S.jevConfigureFailed(error instanceof Error ? error.message : String(error))}`,
|
|
1064
|
+
)
|
|
1065
|
+
console.error(
|
|
1066
|
+
` Fix later with: npx pantheon-opencode decision-router setup-model ${decisionTarget} --monthly-usd ${monthly} --per-decision-usd ${perDecision}`,
|
|
1067
|
+
)
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
961
1072
|
console.log('')
|
|
962
1073
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
|
|
963
1074
|
console.log(` ${S.installedTitle(version)}`)
|
|
@@ -968,6 +1079,9 @@ async function main() {
|
|
|
968
1079
|
console.log(` ${S.nextLaunch}`)
|
|
969
1080
|
console.log(` ${S.nextAgents}`)
|
|
970
1081
|
console.log(` ${S.nextProject}`)
|
|
1082
|
+
if (!decisionTarget) {
|
|
1083
|
+
console.log(` ${S.nextJev}`)
|
|
1084
|
+
}
|
|
971
1085
|
console.log('')
|
|
972
1086
|
|
|
973
1087
|
return
|
package/package.json
CHANGED
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.8",
|
|
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.8"
|
|
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
|
|
@@ -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 []
|
|
@@ -126,61 +126,86 @@ export async function runInteractiveInstall({
|
|
|
126
126
|
})
|
|
127
127
|
if (cancelPrompt(prompts, target, 'target')) return { canceled: true, cancelPoint: 'target' }
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
// The old four-option metadata prompt (Local/OpenAI/Jev/Auto) recorded an
|
|
130
|
+
// installer preference that controlled nothing at runtime and confused
|
|
131
|
+
// everyone. The interactive question is now the honest one: configure the
|
|
132
|
+
// Jev decision model now (one write, explicit caps) or skip — the CLI
|
|
133
|
+
// (`decision-router setup-model`) remains the later path either way. The
|
|
134
|
+
// legacy installer-state record stays at its default (Local): metadata the
|
|
135
|
+
// runtime never reads, while real consent lives in the user-level config
|
|
136
|
+
// that setup-model writes.
|
|
137
|
+
const jevActivation = await prompts.select({
|
|
131
138
|
message:
|
|
132
|
-
'
|
|
139
|
+
'Configure the Jev decision model now? (advisory tool for Zeus; one write: selection, consent, caps, period — USD caps are required)',
|
|
133
140
|
options: [
|
|
134
141
|
{
|
|
135
|
-
label: '
|
|
136
|
-
value:
|
|
137
|
-
hint: '
|
|
142
|
+
label: 'Skip (default)',
|
|
143
|
+
value: 'skip',
|
|
144
|
+
hint: 'Configure later: decision-router setup-model',
|
|
138
145
|
},
|
|
139
146
|
{
|
|
140
|
-
label: '
|
|
141
|
-
value:
|
|
142
|
-
hint: '
|
|
147
|
+
label: 'OpenCode Console Jev (stock)',
|
|
148
|
+
value: 'opencode-console-jev/jev-1.13',
|
|
149
|
+
hint: 'Billed to your Console; uses host-owned auth',
|
|
143
150
|
},
|
|
144
151
|
{
|
|
145
|
-
label: 'Jev',
|
|
146
|
-
value:
|
|
147
|
-
hint: '
|
|
152
|
+
label: 'Console Jev free variant',
|
|
153
|
+
value: 'opencode-console-jev-free/jev-1.13-free',
|
|
154
|
+
hint: 'No paid budget consumed; host-owned auth',
|
|
148
155
|
},
|
|
149
156
|
{
|
|
150
|
-
label: '
|
|
151
|
-
value:
|
|
152
|
-
hint: 'Installer
|
|
157
|
+
label: 'TypeSafe Jev (direct)',
|
|
158
|
+
value: 'typesafe-jev/jev-1.14.0',
|
|
159
|
+
hint: 'Installer merges the provider entry; you sign in with your TypeSafe key (/connect)',
|
|
153
160
|
},
|
|
154
161
|
],
|
|
155
|
-
initialValue:
|
|
162
|
+
initialValue: 'skip',
|
|
156
163
|
})
|
|
157
|
-
if (cancelPrompt(prompts,
|
|
164
|
+
if (cancelPrompt(prompts, jevActivation, 'decisionRouter')) {
|
|
158
165
|
return { canceled: true, cancelPoint: 'decisionRouter' }
|
|
159
166
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
167
|
+
// Only known targets activate; anything else (a stale stub, a renamed
|
|
168
|
+
// option) degrades to skip instead of configuring a wrong route.
|
|
169
|
+
const KNOWN_JEV_TARGETS = new Set([
|
|
170
|
+
'opencode-console-jev/jev-1.13',
|
|
171
|
+
'opencode-console-jev-free/jev-1.13-free',
|
|
172
|
+
'typesafe-jev/jev-1.14.0',
|
|
173
|
+
])
|
|
174
|
+
const activationChoice =
|
|
175
|
+
typeof jevActivation === 'string' && KNOWN_JEV_TARGETS.has(jevActivation)
|
|
176
|
+
? jevActivation
|
|
177
|
+
: 'skip'
|
|
178
|
+
let decisionModelActivation = null
|
|
179
|
+
if (activationChoice !== 'skip') {
|
|
180
|
+
// Caps prompts degrade to the recommended defaults when the prompt
|
|
181
|
+
// implementation has no text input (stubbed tests, restricted TTYs).
|
|
182
|
+
const askText = async (message, fallback) => {
|
|
183
|
+
if (typeof prompts.text !== 'function') return fallback
|
|
184
|
+
const answer = await prompts.text({ message, defaultValue: fallback, placeholder: fallback })
|
|
185
|
+
if (cancelPrompt(prompts, answer, 'decisionRouter')) {
|
|
186
|
+
return { canceled: true }
|
|
187
|
+
}
|
|
188
|
+
return String(answer || fallback)
|
|
189
|
+
}
|
|
190
|
+
const monthly = await askText('Monthly USD cap for decision calls (e.g. 5)', '5')
|
|
191
|
+
if (monthly && typeof monthly === 'object') {
|
|
192
|
+
return { canceled: true, cancelPoint: 'decisionRouter' }
|
|
193
|
+
}
|
|
194
|
+
const perDecision = await askText('Per-decision USD cap (e.g. 0.10)', '0.10')
|
|
195
|
+
if (perDecision && typeof perDecision === 'object') {
|
|
196
|
+
return { canceled: true, cancelPoint: 'decisionRouter' }
|
|
197
|
+
}
|
|
198
|
+
decisionModelActivation = {
|
|
199
|
+
target: activationChoice,
|
|
200
|
+
monthly: String(monthly || '5'),
|
|
201
|
+
perDecision: String(perDecision || '0.10'),
|
|
177
202
|
}
|
|
178
|
-
egressConsent = consent === true
|
|
179
203
|
}
|
|
180
204
|
|
|
181
205
|
return {
|
|
182
206
|
components: selectedComponents,
|
|
183
207
|
target,
|
|
184
|
-
decisionRouterConfig: createDecisionRouterConfig(
|
|
208
|
+
decisionRouterConfig: createDecisionRouterConfig(DECISION_ROUTER_PROVIDERS[0], false),
|
|
209
|
+
decisionModelActivation,
|
|
185
210
|
}
|
|
186
211
|
}
|
|
@@ -1644,6 +1644,8 @@ async function installPass(
|
|
|
1644
1644
|
let decisionRouterConfig = migrateDecisionRouterConfig(
|
|
1645
1645
|
opts.decisionRouterConfig ?? readState(target)?.decision_router,
|
|
1646
1646
|
)
|
|
1647
|
+
/** Wizard-confirmed Jev activation (target + caps), surfaced on the result. */
|
|
1648
|
+
let decisionModelActivation = null
|
|
1647
1649
|
const stats = summary.opencode
|
|
1648
1650
|
// Per-call baseline. `stats` is the module-level cumulative summary, so the
|
|
1649
1651
|
// consistency guard must compare against THIS call's delta, not the total.
|
|
@@ -1772,7 +1774,10 @@ async function installPass(
|
|
|
1772
1774
|
// this notice cannot drift from what the plugin reports; the notice says
|
|
1773
1775
|
// so, because the live list is a superset that grows at runtime. Advisory:
|
|
1774
1776
|
// a V2 install is a supported configuration, not a failure.
|
|
1775
|
-
|
|
1777
|
+
// Default-quiet: the eleven-fact block is install *detail*, not an action
|
|
1778
|
+
// the user must take, so it prints only under --verbose (the recorded
|
|
1779
|
+
// run-state keeps it either way).
|
|
1780
|
+
if (opts.verbose === true) notice(formatV2CapabilityNotice())
|
|
1776
1781
|
}
|
|
1777
1782
|
|
|
1778
1783
|
// Interactive mode handling
|
|
@@ -1834,6 +1839,7 @@ async function installPass(
|
|
|
1834
1839
|
target = selectedTarget
|
|
1835
1840
|
decisionRouterConfig = migrateDecisionRouterConfig(result.decisionRouterConfig)
|
|
1836
1841
|
opts.decisionRouterConfig = decisionRouterConfig
|
|
1842
|
+
decisionModelActivation = result.decisionModelActivation ?? null
|
|
1837
1843
|
if (!dryRun && _lastRun) _lastRun.target = target
|
|
1838
1844
|
}
|
|
1839
1845
|
|
|
@@ -3426,12 +3432,14 @@ async function installPass(
|
|
|
3426
3432
|
versionAssumed,
|
|
3427
3433
|
configAdvisories,
|
|
3428
3434
|
v2Capabilities: version === 'v2' ? v2Capabilities() : null,
|
|
3435
|
+
decisionModelActivation,
|
|
3429
3436
|
pluginOptions: v2PluginOptions,
|
|
3430
3437
|
}
|
|
3431
3438
|
: {
|
|
3432
3439
|
...stats,
|
|
3433
3440
|
applied: true,
|
|
3434
3441
|
reason: 'applied',
|
|
3442
|
+
decisionModelActivation,
|
|
3435
3443
|
target,
|
|
3436
3444
|
runtimeEffects,
|
|
3437
3445
|
openCodeVersion: version,
|