pantheon-opencode 1.6.2-beta.7 → 1.6.2-beta.9
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 +41 -0
- package/bin/pantheon-init.mjs +122 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -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 +6 -1
- package/src/agents/apollo.md +1 -0
- package/src/agents/athena.md +1 -0
- package/src/agents/demeter.md +1 -1
- package/src/agents/gaia.md +1 -0
- package/src/agents/hephaestus.md +1 -1
- package/src/agents/hermes.md +8 -10
- package/src/agents/iris.md +1 -1
- package/src/agents/mnemosyne.md +1 -0
- package/src/agents/nyx.md +1 -1
- package/src/agents/prometheus.md +1 -1
- package/src/agents/talos.md +6 -1
- package/src/agents/themis.md +1 -1
- package/src/agents/zeus.md +6 -0
- 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
|
@@ -10,6 +10,47 @@ 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.9] - 2026-11-02
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **install** — `init --decision-model typesafe-jev/jev-1.14.0` merges the TypeSafe provider entry additively into the user's `opencode.json`; only the sign-in remains.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **agents** — Every agent frontmatter declares terminal permissions under `shell:` — the action a measured 2.2.5 host actually evaluates (canary-recorded evidence: a `shell` deny is enforced while `bash` falls through unruled).
|
|
22
|
+
- **agents** — Deny intents keep a `bash:` twin; the former `bash:`-only keys never matched, which made specialists' terminal grants inconsistent.
|
|
23
|
+
- **agents** — Zeus must never ask the user to type terminal commands: terminal work dispatches to a bash-capable specialist.
|
|
24
|
+
- **install** — `--opencode-version v1` is refused with a deprecation message front-running the 2.0 removal of the legacy plugin line.
|
|
25
|
+
- **docs** — New [Skill provenance search](docs/reference/skill-search-design.md) investigation (three tiers, Jev as typed ranker; deliberately unwired).
|
|
26
|
+
- **docs** — Measured MCP numbers in [Performance](docs/reference/performance.md) (fastmcp startup, FTS5 memory, vision deps).
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- **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.
|
|
31
|
+
- **install** — Choosing TypeSafe direct merges the `providers.typesafe-ai` entry additively into the user's opencode.json; only the sign-in remains.
|
|
32
|
+
- **install** — Legacy metadata spellings degrade to skip with a hint; direct OpenAI has no native Decisions route.
|
|
33
|
+
- **install** — The capability notice prints only under `--verbose`.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- **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).
|
|
38
|
+
- **agents** — Zeus must never ask the user to type terminal commands: terminal work dispatches to a bash-capable specialist.
|
|
39
|
+
|
|
40
|
+
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
41
|
+
move this section to a versioned entry and reset the template below. -->
|
|
42
|
+
## [v1.6.2-beta.8] - 2026-11-02
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- **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.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- **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.
|
|
51
|
+
- **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.
|
|
52
|
+
- **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.
|
|
53
|
+
|
|
13
54
|
## [v1.6.2-beta.7] - 2026-11-02
|
|
14
55
|
|
|
15
56
|
### 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]
|
|
@@ -509,6 +570,14 @@ async function main() {
|
|
|
509
570
|
console.error(`❌ Invalid --version "${versionOpt}" — expected v1, v2 or auto`)
|
|
510
571
|
process.exit(1)
|
|
511
572
|
}
|
|
573
|
+
// The 2.0 deprecation front-run: the legacy plugin line is end-of-life.
|
|
574
|
+
// Loud warning now (the v1 code path still exists for legacy installs);
|
|
575
|
+
// the 2.0 removal turns this into a hard refusal.
|
|
576
|
+
if (versionOpt === 'v1') {
|
|
577
|
+
console.error(
|
|
578
|
+
'⚠️ --opencode-version v1 is DEPRECATED and will be removed in Pantheon 2.0 — the legacy plugin line is end-of-life. OpenCode 2.x hosts are the supported generation; remove the flag (auto detects the host).',
|
|
579
|
+
)
|
|
580
|
+
}
|
|
512
581
|
|
|
513
582
|
// Resolve the user's explicit selection separately from the defaults.
|
|
514
583
|
// Runtime and prompt templates are opt-in in both TTY and headless mode.
|
|
@@ -958,6 +1027,56 @@ async function main() {
|
|
|
958
1027
|
}
|
|
959
1028
|
}
|
|
960
1029
|
|
|
1030
|
+
// Optional Jev decision-model activation, requested at install time with
|
|
1031
|
+
// explicit caps (the setup-model chain: selection + enable + consent +
|
|
1032
|
+
// user/provider/model caps + period confirmation). Dry-run prints intent
|
|
1033
|
+
// only. Failures never fail the install itself.
|
|
1034
|
+
// Explicit flags win; otherwise honor the wizard's Jev activation choice.
|
|
1035
|
+
const wizardActivation = result.decisionModelActivation ?? null
|
|
1036
|
+
const decisionTarget = readArgValue('--decision-model') ?? wizardActivation?.target ?? null
|
|
1037
|
+
if (decisionTarget) {
|
|
1038
|
+
const monthly = readArgValue('--decision-monthly-usd') ?? wizardActivation?.monthly ?? '5'
|
|
1039
|
+
const perDecision =
|
|
1040
|
+
readArgValue('--decision-per-decision-usd') ?? wizardActivation?.perDecision ?? '0.10'
|
|
1041
|
+
const noConsent = process.argv.includes('--decision-no-consent')
|
|
1042
|
+
console.log('')
|
|
1043
|
+
if (isDryRun) {
|
|
1044
|
+
console.log(` ${S.jevDryRun(decisionTarget)}`)
|
|
1045
|
+
} else {
|
|
1046
|
+
try {
|
|
1047
|
+
const { runDecisionRouterCommand } = await import('../scripts/decision-router.mjs')
|
|
1048
|
+
await runDecisionRouterCommand(
|
|
1049
|
+
[
|
|
1050
|
+
'setup-model',
|
|
1051
|
+
decisionTarget,
|
|
1052
|
+
'--monthly-usd',
|
|
1053
|
+
monthly,
|
|
1054
|
+
'--per-decision-usd',
|
|
1055
|
+
perDecision,
|
|
1056
|
+
...(noConsent ? ['--no-consent'] : []),
|
|
1057
|
+
],
|
|
1058
|
+
{ stdout: (line) => console.log(` ${line}`) },
|
|
1059
|
+
)
|
|
1060
|
+
console.log(` ${S.jevConfigured(decisionTarget)}`)
|
|
1061
|
+
if (decisionTarget.startsWith('typesafe-jev')) {
|
|
1062
|
+
const provisioned = provisionTypesafeProvider()
|
|
1063
|
+
console.log(
|
|
1064
|
+
provisioned === true
|
|
1065
|
+
? ' TypeSafe provider entry merged into opencode.json (models.typesafe-ai, type "decision"). Sign in with `opencode auth login` (TypeSafe) or /connect.'
|
|
1066
|
+
: ` TypeSafe provider entry NOT merged (${provisioned}); merge it manually — see docs/reference/native-decisions.md.`,
|
|
1067
|
+
)
|
|
1068
|
+
}
|
|
1069
|
+
} catch (error) {
|
|
1070
|
+
console.error(
|
|
1071
|
+
` ${S.jevConfigureFailed(error instanceof Error ? error.message : String(error))}`,
|
|
1072
|
+
)
|
|
1073
|
+
console.error(
|
|
1074
|
+
` Fix later with: npx pantheon-opencode decision-router setup-model ${decisionTarget} --monthly-usd ${monthly} --per-decision-usd ${perDecision}`,
|
|
1075
|
+
)
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
961
1080
|
console.log('')
|
|
962
1081
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
|
|
963
1082
|
console.log(` ${S.installedTitle(version)}`)
|
|
@@ -968,6 +1087,9 @@ async function main() {
|
|
|
968
1087
|
console.log(` ${S.nextLaunch}`)
|
|
969
1088
|
console.log(` ${S.nextAgents}`)
|
|
970
1089
|
console.log(` ${S.nextProject}`)
|
|
1090
|
+
if (!decisionTarget) {
|
|
1091
|
+
console.log(` ${S.nextJev}`)
|
|
1092
|
+
}
|
|
971
1093
|
console.log('')
|
|
972
1094
|
|
|
973
1095
|
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.9",
|
|
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.9"
|
|
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
|
|
@@ -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,
|
|
@@ -56,6 +56,12 @@ const TABLE = {
|
|
|
56
56
|
nextLaunch: '2. Launch OpenCode',
|
|
57
57
|
nextAgents: '3. Invoke agents with @agent-name in chat',
|
|
58
58
|
nextProject: '4. For project-local install:\n npx pantheon-opencode init --project',
|
|
59
|
+
nextJev:
|
|
60
|
+
'5. Jev decision model (optional, off by default):\n npx pantheon-opencode decision-router setup-model opencode-console-jev/jev-1.13 --monthly-usd 5 --per-decision-usd 0.10\n npx pantheon-opencode decision-router doctor',
|
|
61
|
+
jevConfigured: (target) =>
|
|
62
|
+
`Jev decision model configured: ${target} (consent + caps + period; verify with decision-router doctor)`,
|
|
63
|
+
jevConfigureFailed: (msg) => `Decision-model configuration failed: ${msg}`,
|
|
64
|
+
jevDryRun: (target) => `[DRY-RUN] decision model would be configured: ${target}`,
|
|
59
65
|
// install steps
|
|
60
66
|
globalLayout:
|
|
61
67
|
'Global config directory detected — using flat layout (agents/, skills/, commands/)',
|
|
@@ -148,6 +154,12 @@ const TABLE = {
|
|
|
148
154
|
nextLaunch: '2. Abra o OpenCode',
|
|
149
155
|
nextAgents: '3. Invoc agentes com @nome-do-agente no chat',
|
|
150
156
|
nextProject: '4. Para instalar no projeto:\n npx pantheon-opencode init --project',
|
|
157
|
+
nextJev:
|
|
158
|
+
'5. Modelo de decisão Jev (opcional, desligado por padrão):\n npx pantheon-opencode decision-router setup-model opencode-console-jev/jev-1.13 --monthly-usd 5 --per-decision-usd 0.10\n npx pantheon-opencode decision-router doctor',
|
|
159
|
+
jevConfigured: (target) =>
|
|
160
|
+
`Modelo de decisão Jev configurado: ${target} (consentimento + limites + período; verifique com decision-router doctor)`,
|
|
161
|
+
jevConfigureFailed: (msg) => `Falha ao configurar o modelo de decisão: ${msg}`,
|
|
162
|
+
jevDryRun: (target) => `[DRY-RUN] o modelo de decisão seria configurado: ${target}`,
|
|
151
163
|
// install steps
|
|
152
164
|
globalLayout:
|
|
153
165
|
'Diretório de config global detectado — layout plano (agents/, skills/, commands/)',
|
package/src/agents/aphrodite.md
CHANGED
|
@@ -8,7 +8,7 @@ permission:
|
|
|
8
8
|
grep: allow
|
|
9
9
|
edit: allow
|
|
10
10
|
vision_describe: allow
|
|
11
|
-
|
|
11
|
+
shell: allow
|
|
12
12
|
webfetch: allow
|
|
13
13
|
glob: allow
|
|
14
14
|
question: allow
|
|
@@ -30,6 +30,11 @@ mcp_tools:
|
|
|
30
30
|
pantheon-vision: [vision_describe, vision_ocr, vision_analyze]
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
+
## Verification Tiers
|
|
34
|
+
|
|
35
|
+
Small bounded fix → change + one targeted proof, no ceremony. Material change → full test discipline. Match the tier to the change.
|
|
36
|
+
|
|
37
|
+
|
|
33
38
|
## When NOT to Use Aphrodite
|
|
34
39
|
- For backend API implementation — that's @hermes
|
|
35
40
|
- For database schema changes — that's @demeter
|
package/src/agents/apollo.md
CHANGED
package/src/agents/athena.md
CHANGED
package/src/agents/demeter.md
CHANGED
package/src/agents/gaia.md
CHANGED
package/src/agents/hephaestus.md
CHANGED
package/src/agents/hermes.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hermes
|
|
3
|
-
description: Backend specialist — FastAPI, Python, async,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
description: Backend specialist — FastAPI, Python, async, modern Python stdlib,
|
|
4
|
+
obsolete lib detection. Root Hermes may call Apollo for discovery; child
|
|
5
|
+
sessions do not delegate. Sends material work to Themis via Zeus.
|
|
6
6
|
mode: all
|
|
7
7
|
reasoning_effort: medium
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ skills:
|
|
|
21
21
|
- tdd-with-agents
|
|
22
22
|
- worktrees
|
|
23
23
|
permission:
|
|
24
|
-
|
|
24
|
+
shell: allow
|
|
25
25
|
read: allow
|
|
26
26
|
grep: allow
|
|
27
27
|
edit: allow
|
|
@@ -246,13 +246,11 @@ When completing a task, provide:
|
|
|
246
246
|
|
|
247
247
|
**Philosophy**: Clean code, clear error messages, proper async patterns, thorough testing.
|
|
248
248
|
|
|
249
|
-
##
|
|
249
|
+
## Verification Tiers (match the change, not a ritual)
|
|
250
250
|
|
|
251
|
-
-
|
|
252
|
-
-
|
|
253
|
-
-
|
|
254
|
-
- Do NOT auto-continue when tests fail unexpectedly — stop and diagnose
|
|
255
|
-
- Partial results NOT allowed — must complete or fail
|
|
251
|
+
- **Small bounded fix** (typo, config, copy, single-function tweak): make the change, run the one targeted test or command that proves it, report. No RED→GREEN→REFACTOR ceremony, no extra discovery passes.
|
|
252
|
+
- **Material change** (new endpoint, schema, service, auth, public behavior): full TDD cycle via `skill: tdd-with-agents`, then the Themis handoff.
|
|
253
|
+
- Auto-continue through the chosen tier for authorized work; stop for required Themis review; stop and diagnose when tests fail unexpectedly; no partial results.
|
|
256
254
|
|
|
257
255
|
## Skills
|
|
258
256
|
Implementação: `tdd-with-agents`, `incremental-implementation`, `code-review-checklist`, `git-workflow-and-versioning`
|
package/src/agents/iris.md
CHANGED
package/src/agents/mnemosyne.md
CHANGED
package/src/agents/nyx.md
CHANGED
package/src/agents/prometheus.md
CHANGED
package/src/agents/talos.md
CHANGED
|
@@ -6,7 +6,7 @@ reasoning_effort: low
|
|
|
6
6
|
permission:
|
|
7
7
|
read: allow
|
|
8
8
|
edit: allow
|
|
9
|
-
|
|
9
|
+
shell: allow
|
|
10
10
|
task:
|
|
11
11
|
"*": deny
|
|
12
12
|
temperature: 0.3
|
|
@@ -22,6 +22,11 @@ mcp_tools:
|
|
|
22
22
|
pantheon-code-mode: [execute_code_script]
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
## Verification Tiers
|
|
26
|
+
|
|
27
|
+
Small bounded fix → change + one targeted proof, no ceremony. Material change → full test discipline. Match the tier to the change.
|
|
28
|
+
|
|
29
|
+
|
|
25
30
|
## Core Capabilities
|
|
26
31
|
|
|
27
32
|
### 1. Rapid Repairs
|
package/src/agents/themis.md
CHANGED
package/src/agents/zeus.md
CHANGED
|
@@ -6,6 +6,7 @@ permission:
|
|
|
6
6
|
read: allow
|
|
7
7
|
edit: deny
|
|
8
8
|
hashline_edit: deny
|
|
9
|
+
shell: deny
|
|
9
10
|
bash: deny
|
|
10
11
|
vision_describe: allow
|
|
11
12
|
pantheon_jev_decide: allow
|
|
@@ -98,6 +99,11 @@ Zeus nunca toca no código. Use o menor fluxo que preserve segurança: encaminhe
|
|
|
98
99
|
2. Pergunte ao usuário qual agente usar
|
|
99
100
|
3. NUNCA tente fazer você mesmo
|
|
100
101
|
|
|
102
|
+
**NUNCA peça ao usuário para digitar comandos de terminal.** Terminal é
|
|
103
|
+
trabalho de especialista com `bash` liberado (@prometheus, @hermes, @talos):
|
|
104
|
+
despache o Brief e receba o resultado. O usuário digita decisões e respostas,
|
|
105
|
+
não comandos — pedir comandos é falha de roteamento sua, não limite do host.
|
|
106
|
+
|
|
101
107
|
**Gates proporcionais** (via ferramenta root `question`, se visível):
|
|
102
108
|
- Tarefa delimitada, reversível, de baixa incerteza e não sensível/sem mudança material em API visível ao usuário: não force planejamento nem aprovação de plano; se delegar, encaminhe uma vez ao especialista correto, que inspeciona o contexto necessário, altera, verifica o comportamento e resume.
|
|
103
109
|
- Para um entregável delimitado, delegue uma vez ao especialista final; ele pode reunir os fatos necessários. Use Apollo à parte apenas se a pesquisa for o entregável ou bloquear a escolha do especialista. Planejamento e council ficam sob demanda; nunca dispare council para correção pequena.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process replacements for the three bash hooks the V2 tool guards used to
|
|
3
|
+
* spawn per tool call (`scan-secrets.sh`, `on-subagent-delegation-start.sh`,
|
|
4
|
+
* `on-subagent-delegation-stop.sh`).
|
|
5
|
+
*
|
|
6
|
+
* Why: the shell path cost one `bash` spawn per tool call plus two more per
|
|
7
|
+
* delegation (each of those also spawning `python3` to derive JSON fields), on
|
|
8
|
+
* the hot path of every tool execution. The logic is pure string processing —
|
|
9
|
+
* pattern matching and log-line formatting — so it runs in this process with
|
|
10
|
+
* identical observable behavior: same exit-code contract (0 allow / 1 advisory
|
|
11
|
+
* / 2 block), same masked `[SECRET SCAN]` trail, same `delegations.log`
|
|
12
|
+
* JSON lines, same LOG_DIR resolution order.
|
|
13
|
+
*
|
|
14
|
+
* What deliberately does NOT move here: `format-multi-language.sh` still
|
|
15
|
+
* spawns when it can actually format (it shells out to formatters itself);
|
|
16
|
+
* the in-process gate only skips the spawn for tool calls the script would
|
|
17
|
+
* no-op anyway. `HOOK_TIMEOUT_MS` does not apply — these functions are
|
|
18
|
+
* synchronous and bounded by the payload size, not by a child process.
|
|
19
|
+
*
|
|
20
|
+
* Fail-closed parity: an in-process scanner has no "missing script" failure,
|
|
21
|
+
* but an unexpected internal error still refuses to produce a trustworthy
|
|
22
|
+
* verdict — it returns exit-code 1 WITHOUT the `[SECRET SCAN]` marker, which
|
|
23
|
+
* the existing classifier (plugin-v2 `evaluateSecretScanResult`) reads as
|
|
24
|
+
* fail-closed, exactly as a broken child path always did.
|
|
25
|
+
*
|
|
26
|
+
* @module pantheon/v2-hook-engine
|
|
27
|
+
*/
|
|
28
|
+
import { appendFileSync, mkdirSync } from 'node:fs'
|
|
29
|
+
import { join } from 'node:path'
|
|
30
|
+
import type { HookPayload, HookResult } from '../plugins/hook-runner.ts'
|
|
31
|
+
|
|
32
|
+
/** Mirrors the scanner trail marker the classifier keys the advisory on. */
|
|
33
|
+
export const SECRET_SCAN_MARKER = '[SECRET SCAN]'
|
|
34
|
+
|
|
35
|
+
// Provider-specific markers are assembled at runtime so this scanner is not
|
|
36
|
+
// self-matched by the repository secret scan (the shell script's own trick).
|
|
37
|
+
const BIFROST_TOKEN_PREFIX = `${'sk'}${'-bf-'}`
|
|
38
|
+
const BIFROST_HEADER_NAME = `${'x'}${'-bf-'}${'vk'}`
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* High-confidence token formats. MIRRORS `HIGH_CONFIDENCE_PATTERNS` in
|
|
42
|
+
* scripts/hooks/scan-secrets.sh and `SECRET_MASK_RE` in src/plugin-v2.ts
|
|
43
|
+
* (V2 log masking); the drift is asserted by tests.
|
|
44
|
+
*/
|
|
45
|
+
const HIGH_CONFIDENCE_RES: readonly RegExp[] = Object.freeze([
|
|
46
|
+
/AKIA[0-9A-Z]{16}/i,
|
|
47
|
+
/gh[pousr]_[A-Za-z0-9_]{36,}/i,
|
|
48
|
+
/glpat-[A-Za-z0-9_-]{20}/i,
|
|
49
|
+
/sk-[a-zA-Z0-9]{20,}/i,
|
|
50
|
+
/sk_live_[a-zA-Z0-9]{20,}/i,
|
|
51
|
+
/sk_test_[a-zA-Z0-9]{20,}/i,
|
|
52
|
+
/xox[baprs]-[0-9]{10,13}-[0-9]{10,13}-[a-zA-Z0-9]{24}/i,
|
|
53
|
+
/bearer\s+[a-zA-Z0-9_.-]{20,}/i,
|
|
54
|
+
/eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]/,
|
|
55
|
+
])
|
|
56
|
+
const BIFROST_TOKEN_RE = new RegExp(`${BIFROST_TOKEN_PREFIX}[A-Za-z0-9_-]{8,}`, 'i')
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* KEY/header names without a recognizable token value — advisory only, never
|
|
60
|
+
* blocks (the script's LOW_CONFIDENCE_PATTERNS, including the Bifrost header).
|
|
61
|
+
*/
|
|
62
|
+
const LOW_CONFIDENCE_RES: readonly RegExp[] = Object.freeze([
|
|
63
|
+
/[a-zA-Z0-9_-]*api[_-]?key[a-zA-Z0-9_-]*\s*[:=]\s*["']?[a-zA-Z0-9_-]{16,}["']?/,
|
|
64
|
+
/[a-zA-Z0-9_-]*password[a-zA-Z0-9_-]*\s*[:=]\s*["'][^"']{8,}["']/,
|
|
65
|
+
/[a-zA-Z0-9_-]*secret[a-zA-Z0-9_-]*\s*[:=]\s*["'][^"']{8,}["']/,
|
|
66
|
+
])
|
|
67
|
+
const BIFROST_HEADER_RE = new RegExp(BIFROST_HEADER_NAME, 'i')
|
|
68
|
+
|
|
69
|
+
/** First 4 + last 4 chars (len > 8), else '****' — mirrors `mask_secret`. */
|
|
70
|
+
export function maskSecretMatch(match: string): string {
|
|
71
|
+
return match.length <= 8 ? '****' : `${match.slice(0, 4)}****${match.slice(-4)}`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function firstMatch(input: string, pattern: RegExp): string | null {
|
|
75
|
+
const found = input.match(pattern)
|
|
76
|
+
return found === null ? null : found[0]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Known read-only tools: their INPUT cannot carry a secret out of the user's
|
|
81
|
+
* machine (paths, patterns, ids), so scanning them was pure latency. The gate
|
|
82
|
+
* is a DENYLIST — any tool this list has never heard of keeps getting scanned
|
|
83
|
+
* (fail-closed for unknown names).
|
|
84
|
+
*/
|
|
85
|
+
const READ_ONLY_TOOLS = new Set([
|
|
86
|
+
'read',
|
|
87
|
+
'grep',
|
|
88
|
+
'glob',
|
|
89
|
+
'list',
|
|
90
|
+
'question',
|
|
91
|
+
'session_list',
|
|
92
|
+
'session_read',
|
|
93
|
+
'worktree_list',
|
|
94
|
+
'subagent_list',
|
|
95
|
+
])
|
|
96
|
+
|
|
97
|
+
export function secretScanApplies(tool: unknown): boolean {
|
|
98
|
+
if (typeof tool !== 'string') return true
|
|
99
|
+
const normalized = tool.trim().toLowerCase()
|
|
100
|
+
if (normalized === '') return true
|
|
101
|
+
return !READ_ONLY_TOOLS.has(normalized)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The serialized tool input the shell scanner received as `$1`/stdin. */
|
|
105
|
+
function scannerInput(payload: HookPayload): string {
|
|
106
|
+
if (typeof payload === 'string') return payload
|
|
107
|
+
if (payload === null || payload === undefined) return ''
|
|
108
|
+
const record = payload as Record<string, unknown>
|
|
109
|
+
const input = record.tool_input ?? record.input ?? payload
|
|
110
|
+
if (typeof input === 'string') return input
|
|
111
|
+
try {
|
|
112
|
+
return JSON.stringify(input)
|
|
113
|
+
} catch {
|
|
114
|
+
return ''
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Run the secret scan in-process and return the same {@link HookResult} shape
|
|
120
|
+
* the shell runner produced. Exit 0 → allow; 1 → advisory (marker present);
|
|
121
|
+
* 2 → block. An internal error returns exit 1 WITHOUT the marker, which the
|
|
122
|
+
* classifier maps to fail-closed.
|
|
123
|
+
*/
|
|
124
|
+
export function runSecretScanInProcess(payload: HookPayload): HookResult {
|
|
125
|
+
try {
|
|
126
|
+
const input = scannerInput(payload)
|
|
127
|
+
if (input === '') return { code: 0, stdout: '', stderr: '', signal: null, timedOut: false }
|
|
128
|
+
|
|
129
|
+
const stderr: string[] = []
|
|
130
|
+
let high: string | null = null
|
|
131
|
+
for (const pattern of [...HIGH_CONFIDENCE_RES, BIFROST_TOKEN_RE]) {
|
|
132
|
+
const match = firstMatch(input, pattern)
|
|
133
|
+
if (match !== null) {
|
|
134
|
+
stderr.push(
|
|
135
|
+
`${SECRET_SCAN_MARKER} High-confidence secret detected: ${maskSecretMatch(match)} (pattern: ${pattern.source})`,
|
|
136
|
+
)
|
|
137
|
+
high ??= match
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
let low = false
|
|
141
|
+
for (const pattern of [...LOW_CONFIDENCE_RES, BIFROST_HEADER_RE]) {
|
|
142
|
+
const match = firstMatch(input, pattern)
|
|
143
|
+
if (match !== null) {
|
|
144
|
+
stderr.push(
|
|
145
|
+
`${SECRET_SCAN_MARKER} Potential secret detected (low confidence): ${maskSecretMatch(match)} (pattern: ${pattern.source})`,
|
|
146
|
+
)
|
|
147
|
+
low = true
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (high !== null) {
|
|
152
|
+
stderr.push(
|
|
153
|
+
`${SECRET_SCAN_MARKER} High-confidence hardcoded secret detected. Tool call will be BLOCKED.`,
|
|
154
|
+
)
|
|
155
|
+
return {
|
|
156
|
+
code: 2,
|
|
157
|
+
stdout: '',
|
|
158
|
+
stderr: `${stderr.join('\n')}\n`,
|
|
159
|
+
signal: null,
|
|
160
|
+
timedOut: false,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (low) {
|
|
164
|
+
stderr.push(
|
|
165
|
+
`${SECRET_SCAN_MARKER} Possible secret detected. Remove it and use environment variables or a vault.`,
|
|
166
|
+
)
|
|
167
|
+
return {
|
|
168
|
+
code: 1,
|
|
169
|
+
stdout: '',
|
|
170
|
+
stderr: `${stderr.join('\n')}\n`,
|
|
171
|
+
signal: null,
|
|
172
|
+
timedOut: false,
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { code: 0, stdout: '', stderr: '', signal: null, timedOut: false }
|
|
176
|
+
} catch {
|
|
177
|
+
// Fail-closed: a verdict we cannot trust denies. Exit 1 with no marker.
|
|
178
|
+
return {
|
|
179
|
+
code: 1,
|
|
180
|
+
stdout: '',
|
|
181
|
+
stderr: 'in-process secret scan failed',
|
|
182
|
+
signal: null,
|
|
183
|
+
timedOut: false,
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ─── Delegation audit log ───────────────────────────────────────────────
|
|
189
|
+
|
|
190
|
+
/** Same resolution order as the shell scripts' LOG_DIR block. */
|
|
191
|
+
export function resolveDelegationLogDir(
|
|
192
|
+
env: Record<string, string | undefined> = process.env,
|
|
193
|
+
): string {
|
|
194
|
+
if (env.LOG_DIR) return env.LOG_DIR
|
|
195
|
+
if (env.XDG_STATE_HOME) return join(env.XDG_STATE_HOME, 'pantheon', 'hooks')
|
|
196
|
+
if (env.PANTHEON_HOME) return join(env.PANTHEON_HOME, 'logs', 'agent-sessions')
|
|
197
|
+
if (env.PANTHEON_PROJECT) return join(env.PANTHEON_PROJECT, 'logs', 'agent-sessions')
|
|
198
|
+
return join('logs', 'agent-sessions')
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function delegationTimestamp(now: number): string {
|
|
202
|
+
return `${new Date(now).toISOString().slice(0, 19)}Z`
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Append one JSON audit line; best-effort, never throws. */
|
|
206
|
+
export function appendDelegationAuditLine(line: Record<string, unknown>): boolean {
|
|
207
|
+
try {
|
|
208
|
+
const dir = resolveDelegationLogDir()
|
|
209
|
+
mkdirSync(dir, { recursive: true })
|
|
210
|
+
appendFileSync(join(dir, 'delegations.log'), `${JSON.stringify(line)}\n`, 'utf8')
|
|
211
|
+
return true
|
|
212
|
+
} catch {
|
|
213
|
+
return false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Build the `SubagentStart` audit line (same fields as the shell script). */
|
|
218
|
+
export function delegationStartLine(fields: {
|
|
219
|
+
agent: string
|
|
220
|
+
task: string
|
|
221
|
+
sessionID: string
|
|
222
|
+
delegationID: string
|
|
223
|
+
now: number
|
|
224
|
+
}): Record<string, unknown> {
|
|
225
|
+
return {
|
|
226
|
+
event: 'SubagentStart',
|
|
227
|
+
timestamp: delegationTimestamp(fields.now),
|
|
228
|
+
agent: fields.agent,
|
|
229
|
+
task: fields.task === '' ? fields.agent : fields.task,
|
|
230
|
+
session_id: fields.sessionID,
|
|
231
|
+
delegation_id: fields.delegationID,
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Build the `SubagentStop` audit line (same fields, duration as a number). */
|
|
236
|
+
export function delegationStopLine(fields: {
|
|
237
|
+
agent: string
|
|
238
|
+
status: string
|
|
239
|
+
reason: string
|
|
240
|
+
task: string
|
|
241
|
+
sessionID: string
|
|
242
|
+
result: unknown
|
|
243
|
+
delegationID: string
|
|
244
|
+
taskID: string
|
|
245
|
+
durationMs: number | null
|
|
246
|
+
now: number
|
|
247
|
+
}): Record<string, unknown> {
|
|
248
|
+
return {
|
|
249
|
+
event: 'SubagentStop',
|
|
250
|
+
timestamp: delegationTimestamp(fields.now),
|
|
251
|
+
agent: fields.agent,
|
|
252
|
+
status: fields.status,
|
|
253
|
+
reason: fields.reason,
|
|
254
|
+
task: fields.task === '' ? fields.agent : fields.task,
|
|
255
|
+
session_id: fields.sessionID,
|
|
256
|
+
result: fields.result ?? null,
|
|
257
|
+
delegation_id: fields.delegationID,
|
|
258
|
+
...(fields.taskID === '' ? {} : { task_id: fields.taskID }),
|
|
259
|
+
...(fields.durationMs === null ? {} : { duration_ms: fields.durationMs }),
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// ─── Formatter applicability gate ───────────────────────────────────────
|
|
264
|
+
|
|
265
|
+
/** Extensions `format-multi-language.sh` actually formats; others no-op. */
|
|
266
|
+
const FORMATTABLE_EXTENSIONS = new Set([
|
|
267
|
+
'.py',
|
|
268
|
+
'.ts',
|
|
269
|
+
'.tsx',
|
|
270
|
+
'.js',
|
|
271
|
+
'.jsx',
|
|
272
|
+
'.mjs',
|
|
273
|
+
'.cjs',
|
|
274
|
+
'.json',
|
|
275
|
+
'.md',
|
|
276
|
+
'.yml',
|
|
277
|
+
'.yaml',
|
|
278
|
+
'.toml',
|
|
279
|
+
])
|
|
280
|
+
|
|
281
|
+
function formattablePath(value: unknown): boolean {
|
|
282
|
+
if (typeof value !== 'string' || value.length === 0) return false
|
|
283
|
+
const dot = value.lastIndexOf('.')
|
|
284
|
+
if (dot <= value.lastIndexOf('/')) return false
|
|
285
|
+
return FORMATTABLE_EXTENSIONS.has(value.slice(dot).toLowerCase())
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Whether `format-multi-language.sh` would do anything for this tool call.
|
|
290
|
+
* The script no-ops for every other tool; skipping the spawn for those is the
|
|
291
|
+
* whole point of this gate.
|
|
292
|
+
*/
|
|
293
|
+
export function formatterApplies(tool: string, input: unknown): boolean {
|
|
294
|
+
const normalized = tool.trim().toLowerCase()
|
|
295
|
+
if (normalized === 'edit' || normalized === 'write' || normalized === 'hashline_edit') {
|
|
296
|
+
if (input !== null && typeof input === 'object') {
|
|
297
|
+
return formattablePath((input as Record<string, unknown>).file_path)
|
|
298
|
+
}
|
|
299
|
+
return false
|
|
300
|
+
}
|
|
301
|
+
if (normalized === 'bash') {
|
|
302
|
+
// The script scans the command for rewritten paths; the conservative gate
|
|
303
|
+
// lets bash through unchanged (rare, and correctness beats micro-gains).
|
|
304
|
+
return true
|
|
305
|
+
}
|
|
306
|
+
return false
|
|
307
|
+
}
|
|
@@ -38,6 +38,12 @@
|
|
|
38
38
|
|
|
39
39
|
import { randomUUID } from 'node:crypto'
|
|
40
40
|
import { type HookPayload, type HookResult, runHook } from '../plugins/hook-runner.ts'
|
|
41
|
+
import {
|
|
42
|
+
appendDelegationAuditLine,
|
|
43
|
+
delegationStartLine,
|
|
44
|
+
delegationStopLine,
|
|
45
|
+
formatterApplies,
|
|
46
|
+
} from './v2-hook-engine.ts'
|
|
41
47
|
|
|
42
48
|
/**
|
|
43
49
|
* Delegation tool names. MIRRORS `DELEGATION_TOOL_RE` in
|
|
@@ -53,10 +59,68 @@ export const FORMATTER_SCRIPT = 'format-multi-language.sh'
|
|
|
53
59
|
export const DELEGATION_START_SCRIPT = 'on-subagent-delegation-start.sh'
|
|
54
60
|
export const DELEGATION_STOP_SCRIPT = 'on-subagent-delegation-stop.sh'
|
|
55
61
|
|
|
56
|
-
/** One
|
|
62
|
+
/** One audit/formatter invocation. Injected in tests to avoid spawning a shell. */
|
|
57
63
|
export type V2ShellRunner = (script: string, payload: HookPayload) => Promise<HookResult>
|
|
58
64
|
|
|
59
|
-
const
|
|
65
|
+
const IDLE_RESULT: HookResult = { code: 0, stdout: '', stderr: '', signal: null, timedOut: false }
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* In-process dispatcher. Start/stop audit lines are written directly (same
|
|
69
|
+
* JSON shape and LOG_DIR resolution as the shell scripts); the formatter
|
|
70
|
+
* still spawns when the tool call touched a formattable file and is skipped —
|
|
71
|
+
* without a child process — for every call the script would no-op anyway.
|
|
72
|
+
*/
|
|
73
|
+
const defaultRunner: V2ShellRunner = async (script, payload) => {
|
|
74
|
+
const record = (payload ?? {}) as Record<string, unknown>
|
|
75
|
+
const tool = typeof record.tool_name === 'string' ? record.tool_name : ''
|
|
76
|
+
if (script === DELEGATION_START_SCRIPT) {
|
|
77
|
+
const delegationID = typeof record.delegation_id === 'string' ? record.delegation_id : ''
|
|
78
|
+
const agent = typeof record.agent_id === 'string' ? record.agent_id : ''
|
|
79
|
+
const sessionID = typeof record.session_id === 'string' ? record.session_id : ''
|
|
80
|
+
const task =
|
|
81
|
+
record.tool_input !== null && typeof record.tool_input === 'object'
|
|
82
|
+
? String((record.tool_input as Record<string, unknown>).description ?? '')
|
|
83
|
+
: ''
|
|
84
|
+
appendDelegationAuditLine(
|
|
85
|
+
delegationStartLine({ agent, task, sessionID, delegationID, now: Date.now() }),
|
|
86
|
+
)
|
|
87
|
+
return IDLE_RESULT
|
|
88
|
+
}
|
|
89
|
+
if (script === DELEGATION_STOP_SCRIPT) {
|
|
90
|
+
const delegationID = typeof record.delegation_id === 'string' ? record.delegation_id : ''
|
|
91
|
+
const agent = typeof record.agent_id === 'string' ? record.agent_id : ''
|
|
92
|
+
const sessionID = typeof record.session_id === 'string' ? record.session_id : ''
|
|
93
|
+
const status = typeof record.status === 'string' ? record.status : ''
|
|
94
|
+
const taskID = typeof record.task_id === 'string' ? record.task_id : ''
|
|
95
|
+
const duration =
|
|
96
|
+
typeof record.duration_ms === 'number' && Number.isFinite(record.duration_ms)
|
|
97
|
+
? Math.max(0, Math.round(record.duration_ms))
|
|
98
|
+
: null
|
|
99
|
+
appendDelegationAuditLine(
|
|
100
|
+
delegationStopLine({
|
|
101
|
+
agent,
|
|
102
|
+
status,
|
|
103
|
+
reason: status,
|
|
104
|
+
task:
|
|
105
|
+
record.tool_input !== null && typeof record.tool_input === 'object'
|
|
106
|
+
? String((record.tool_input as Record<string, unknown>).description ?? '')
|
|
107
|
+
: '',
|
|
108
|
+
sessionID,
|
|
109
|
+
result: record.tool_output ?? null,
|
|
110
|
+
delegationID,
|
|
111
|
+
taskID,
|
|
112
|
+
durationMs: duration,
|
|
113
|
+
now: Date.now(),
|
|
114
|
+
}),
|
|
115
|
+
)
|
|
116
|
+
return IDLE_RESULT
|
|
117
|
+
}
|
|
118
|
+
if (script === FORMATTER_SCRIPT) {
|
|
119
|
+
if (!formatterApplies(tool, record.tool_input)) return IDLE_RESULT
|
|
120
|
+
return runHook(script, payload)
|
|
121
|
+
}
|
|
122
|
+
return runHook(script, payload)
|
|
123
|
+
}
|
|
60
124
|
|
|
61
125
|
/** Hard cap on pending records — a tool result may never arrive. */
|
|
62
126
|
const MAX_PENDING_STARTS = 256
|
package/src/plugin-v2.ts
CHANGED
|
@@ -161,6 +161,7 @@ import {
|
|
|
161
161
|
v2ResourceTarget,
|
|
162
162
|
} from './pantheon/v2-delegation-enforce.ts'
|
|
163
163
|
import { createV2ExecuteAfter, resolveV2SandboxConfig } from './pantheon/v2-execute-after.ts'
|
|
164
|
+
import { runSecretScanInProcess } from './pantheon/v2-hook-engine.ts'
|
|
164
165
|
import { applyV2ModelOverrides, readV2ModelConfiguration } from './pantheon/v2-model-overrides.ts'
|
|
165
166
|
import type { NativeDecisionRequest } from './pantheon/v2-native-decisions.ts'
|
|
166
167
|
import { createV2ShellHooks, type V2ShellRunner } from './pantheon/v2-shell-hooks.ts'
|
|
@@ -168,7 +169,7 @@ import { createV2ToolDefinitions, type V2ToolResult } from './pantheon/v2-tools.
|
|
|
168
169
|
import { V2_UNSUPPORTED_FEATURE_SEED } from './pantheon/v2-unsupported.mjs'
|
|
169
170
|
import { buildV2VisionPromptContext, type V2VisionRuntime } from './pantheon/v2-vision.ts'
|
|
170
171
|
import { sanitizeVisionHistory } from './pantheon/vision.ts'
|
|
171
|
-
import {
|
|
172
|
+
import type { HookPayload, HookResult } from './plugins/hook-runner.ts'
|
|
172
173
|
|
|
173
174
|
// ─── Unsupported Features Registry ───────────────────────────────────────
|
|
174
175
|
|
|
@@ -1659,10 +1660,17 @@ function evaluateSecretScanResult(scan: HookResult): SecretScanDecision {
|
|
|
1659
1660
|
return { action: 'fail-closed', reason: 'scanner-unexpected-exit' }
|
|
1660
1661
|
}
|
|
1661
1662
|
|
|
1662
|
-
/** Invocation of
|
|
1663
|
+
/** Invocation of the secret scan used by the tool guard. */
|
|
1663
1664
|
type SecretScanRunner = (payload: HookPayload) => Promise<HookResult>
|
|
1664
1665
|
|
|
1665
|
-
|
|
1666
|
+
/**
|
|
1667
|
+
* The scan runs IN-PROCESS (src/pantheon/v2-hook-engine.ts, same patterns and
|
|
1668
|
+
* exit-code contract as the former scripts/hooks/scan-secrets.sh) so a tool
|
|
1669
|
+
* call no longer spawns a bash child. The runner signature and the classifier
|
|
1670
|
+
* below are unchanged; {@link setV2SecretScanRunnerForTests} still injects
|
|
1671
|
+
* structured results the in-process path cannot produce on its own.
|
|
1672
|
+
*/
|
|
1673
|
+
const defaultSecretScanRunner: SecretScanRunner = async (payload) => runSecretScanInProcess(payload)
|
|
1666
1674
|
|
|
1667
1675
|
let secretScanRunner: SecretScanRunner = defaultSecretScanRunner
|
|
1668
1676
|
|
|
@@ -5022,7 +5022,7 @@ function QuotaPluginDetails(props) {
|
|
|
5022
5022
|
setProp(_el$58, "paddingTop", 1);
|
|
5023
5023
|
insertNode(_el$59, createTextNode(`Plugin`));
|
|
5024
5024
|
setProp(_el$59, "attributes", 1);
|
|
5025
|
-
insert(_el$61, `Pantheon TUI v1.6.2-beta.
|
|
5025
|
+
insert(_el$61, `Pantheon TUI v1.6.2-beta.9`);
|
|
5026
5026
|
insertNode(_el$62, createTextNode(`Status de conexão consultado pelo OpenCode; segredos não são exibidos.`));
|
|
5027
5027
|
insert(_el$64, () => `Status da quota: ${quotaSnapshotStatusLabel(props.snapshot.status, props.snapshot.error)}`);
|
|
5028
5028
|
insert(_el$58, createComponent(Show, {
|
|
@@ -8300,7 +8300,7 @@ function Sidebar(props) {
|
|
|
8300
8300
|
setProp(_el$12, "width", "100%");
|
|
8301
8301
|
setProp(_el$12, "padding", 1);
|
|
8302
8302
|
setProp(_el$13, "attributes", 1);
|
|
8303
|
-
insert(_el$13, `Pantheon v1.6.2-beta.
|
|
8303
|
+
insert(_el$13, `Pantheon v1.6.2-beta.9`);
|
|
8304
8304
|
insert(_el$14, () => presetHeaderLine(model.preset().name ?? "", model.provider()));
|
|
8305
8305
|
insert(_el$12, createComponent(Show, {
|
|
8306
8306
|
get when() {
|
|
@@ -9027,7 +9027,7 @@ function HomeStatus(props) {
|
|
|
9027
9027
|
const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base;
|
|
9028
9028
|
return (() => {
|
|
9029
9029
|
var _el$72 = createElement("text");
|
|
9030
|
-
insert(_el$72, () => `Pantheon v1.6.2-beta.
|
|
9030
|
+
insert(_el$72, () => `Pantheon v1.6.2-beta.9${preset().name ? ` ▸ ${preset().name}` : ""}`);
|
|
9031
9031
|
effect((_$p) => setProp(_el$72, "fg", muted(), _$p));
|
|
9032
9032
|
return _el$72;
|
|
9033
9033
|
})();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "1.6.2-beta.
|
|
3
|
+
"version": "1.6.2-beta.9",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "1.6.2-beta.
|
|
9
|
+
"version": "1.6.2-beta.9",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@opencode-ai/plugin": "1.18.33",
|