pantheon-opencode 1.6.3-beta.20 → 1.6.3-beta.21
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 +6 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/jev-live-probe.mjs +4 -2
- package/src/pantheon/j1-approvals.ts +123 -0
- package/src/pantheon/jev-decision-tool.ts +7 -1
- package/src/pantheon/jev-escalation.ts +1 -1
- package/src/pantheon/jev-rank-verify.ts +32 -8
- package/src/pantheon/jev-risk-gate.ts +5 -2
- package/src/plugin-v2.ts +61 -11
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
10
10
|
<!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
|
|
11
11
|
move this section to a versioned entry and reset the template below. -->
|
|
12
12
|
|
|
13
|
+
## [v1.6.3-beta.21] - 2026-11-06
|
|
14
|
+
|
|
15
|
+
## 🆕 What's New
|
|
16
|
+
- The J1 enforce block is now an APPROVAL GATE: a high-risk call is denied with an ask — the agent questions the user under a `j1-approval-<hash>` marker; an affirmative answer mints a hash-pinned, TTL-bounded (15 min), session-scoped pass for that exact call, and the retry executes (and records). No observed answer, no pass — fail-closed.
|
|
17
|
+
- QA beta.20 fixes: verify verdict band precedence (0.35–0.65 UNVERIFIABLE inclusive; PASS strictly above), order maps scores back to the caller's candidate ids, `=shadow` no longer reads as off, scorecard count/cost honesty.
|
|
18
|
+
|
|
13
19
|
## [v1.6.3-beta.20] - 2026-11-06
|
|
14
20
|
|
|
15
21
|
## 🆕 What's New
|
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.3-beta.
|
|
4
|
+
"version": "1.6.3-beta.21",
|
|
5
5
|
"displayName": "Pantheon",
|
|
6
6
|
"description": "Conductor-Delegate orchestration platform with 14 specialized agents, 21 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.3-beta.
|
|
7
|
+
version = "1.6.3-beta.21"
|
|
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
|
|
@@ -178,7 +178,7 @@ function main(args = process.argv.slice(2)) {
|
|
|
178
178
|
`# Live J2 scorecard — ${date}`,
|
|
179
179
|
'',
|
|
180
180
|
`Route: \`${modelRef.providerID}/${modelRef.id}\`. Operator-run via \`opencode api\``,
|
|
181
|
-
|
|
181
|
+
`(consented route, billed to the user). ${rows.length} scenarios; agreement between the`,
|
|
182
182
|
'live model and the expected pick is the metric — this measures the MODEL,',
|
|
183
183
|
'unlike the offline harness that measures the plumbing.',
|
|
184
184
|
'',
|
|
@@ -189,7 +189,9 @@ function main(args = process.argv.slice(2)) {
|
|
|
189
189
|
`| ${r.state.slice(0, 48)}${r.state.length > 48 ? '…' : ''} | ${r.expect} | ${r.got ?? '—'} | ${r.cost ?? '—'} |`,
|
|
190
190
|
),
|
|
191
191
|
'',
|
|
192
|
-
|
|
192
|
+
totalCost > 0
|
|
193
|
+
? `Total cost: $${totalCost.toFixed(6)} (sum of route-reported costs). Honest caveat: one run is a smoke`
|
|
194
|
+
: `Total cost: NOT reported by the route (the cost field came empty on every call — QA beta.20). Honest caveat: one run is a smoke`,
|
|
193
195
|
'measurement, not a calibration — a claim about model quality needs',
|
|
194
196
|
'repeated runs and a bigger scenario set.',
|
|
195
197
|
'',
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* j1-approvals.ts — the human-approval registry for the J1 enforce gate.
|
|
3
|
+
*
|
|
4
|
+
* Field-driven design (the owner's call, beta.20→21): a high-risk call must
|
|
5
|
+
* not be a dead deny — it demands EXPLICIT human approval, then executes.
|
|
6
|
+
* The channel is the agent's own `question` tool: the deny message names a
|
|
7
|
+
* marker `j1-approval-<hash12>`; when the host's after-hook reports the user
|
|
8
|
+
* answered affirmatively to THAT marker, the exact call (session + tool +
|
|
9
|
+
* input hash) is minted approved for a bounded TTL, and the retry passes.
|
|
10
|
+
*
|
|
11
|
+
* Safety properties:
|
|
12
|
+
* - approval is HASH-PINNED to the exact refused call — approving one call
|
|
13
|
+
* never approves a different one, however similar;
|
|
14
|
+
* - TTL-bounded (default 15 minutes) and session-scoped;
|
|
15
|
+
* - fail-closed preserved: no approval → the retry denies exactly as
|
|
16
|
+
* before; the agent cannot mint approvals (only the observed user answer
|
|
17
|
+
* can, and only for a pending marker of its own session);
|
|
18
|
+
* - bounded memory: per-session maps with oldest-eviction at the cap.
|
|
19
|
+
*
|
|
20
|
+
* Pure and synchronous: the registry lives in-process (a restart forgets
|
|
21
|
+
* approvals, which is the conservative direction).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { createHash } from 'node:crypto'
|
|
25
|
+
|
|
26
|
+
/** Marker prefix the deny message instructs the agent to name its question with. */
|
|
27
|
+
export const J1_APPROVAL_MARKER_PREFIX = 'j1-approval-'
|
|
28
|
+
|
|
29
|
+
/** Approvals expire after this many milliseconds (bounded trust window). */
|
|
30
|
+
export const J1_APPROVAL_TTL_MS = 15 * 60 * 1000
|
|
31
|
+
|
|
32
|
+
/** Per-session approval cap; oldest evicted beyond it. */
|
|
33
|
+
const MAX_APPROVALS_PER_SESSION = 64
|
|
34
|
+
|
|
35
|
+
/** Affirmative answer tokens the user may give (case-insensitive, exact-word). */
|
|
36
|
+
const AFFIRMATIVE = new Set(['approve', 'approved', 'yes', 'y', 'sim', 'aprovar', 'aprovado'])
|
|
37
|
+
|
|
38
|
+
/** The marker name for one approval request: `j1-approval-<first 12 hash chars>`. */
|
|
39
|
+
export function j1ApprovalMarker(inputHash: string): string {
|
|
40
|
+
return `${J1_APPROVAL_MARKER_PREFIX}${inputHash.slice(0, 12)}`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Extract the hash12 from a marker name; null when the name is not one. */
|
|
44
|
+
export function hashFromMarker(name: string): string | null {
|
|
45
|
+
if (!name.startsWith(J1_APPROVAL_MARKER_PREFIX)) return null
|
|
46
|
+
const tail = name.slice(J1_APPROVAL_MARKER_PREFIX.length)
|
|
47
|
+
return /^[0-9a-f]{12}$/.test(tail) ? tail : null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether a serialized `question` tool RESULT reads as the user approving the
|
|
52
|
+
* marker. Defensive by design: the result shape is host-defined; we match the
|
|
53
|
+
* marker and an affirmative token anywhere in a bounded serialization.
|
|
54
|
+
*/
|
|
55
|
+
export function isAffirmativeAnswer(marker: string, serializedResult: string): boolean {
|
|
56
|
+
if (!serializedResult.includes(marker)) return false
|
|
57
|
+
const bounded = serializedResult.slice(0, 2000).toLowerCase()
|
|
58
|
+
for (const token of AFFIRMATIVE) {
|
|
59
|
+
if (new RegExp(`\\b${token}\\b`).test(bounded)) return true
|
|
60
|
+
}
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ApprovalStore {
|
|
65
|
+
/** hash12 -> approvedAt (ms) */
|
|
66
|
+
approved: Map<string, number>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const store = new Map<string, ApprovalStore>()
|
|
70
|
+
|
|
71
|
+
function pruneSession(session: ApprovalStore, now: number): void {
|
|
72
|
+
for (const [hash, at] of session.approved) {
|
|
73
|
+
if (now - at > J1_APPROVAL_TTL_MS) session.approved.delete(hash)
|
|
74
|
+
}
|
|
75
|
+
while (session.approved.size > MAX_APPROVALS_PER_SESSION) {
|
|
76
|
+
const oldest = [...session.approved.entries()].sort((a, b) => a[1] - b[1])[0]
|
|
77
|
+
if (oldest === undefined) break
|
|
78
|
+
session.approved.delete(oldest[0])
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Mint one approval (the after-hook, on an observed affirmative user answer). */
|
|
83
|
+
export function mintApproval(sessionID: string, inputHash: string, now = Date.now()): void {
|
|
84
|
+
if (sessionID === '' || inputHash === '') return
|
|
85
|
+
const session = store.get(sessionID) ?? { approved: new Map() }
|
|
86
|
+
session.approved.set(inputHash.slice(0, 12), now)
|
|
87
|
+
pruneSession(session, now)
|
|
88
|
+
store.set(sessionID, session)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Whether the exact call (session + input hash) carries a live approval. */
|
|
92
|
+
export function hasApproval(sessionID: string, inputHash: string, now = Date.now()): boolean {
|
|
93
|
+
const session = store.get(sessionID)
|
|
94
|
+
if (session === undefined) return false
|
|
95
|
+
const at = session.approved.get(inputHash.slice(0, 12))
|
|
96
|
+
if (at === undefined) return false
|
|
97
|
+
if (now - at > J1_APPROVAL_TTL_MS) {
|
|
98
|
+
session.approved.delete(inputHash.slice(0, 12))
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
return true
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Drop everything (tests). */
|
|
105
|
+
export function resetApprovals(): void {
|
|
106
|
+
store.clear()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Stable content hash for a tool input (same digest as the risk gate uses). */
|
|
110
|
+
export function approvalInputHash(input: unknown): string {
|
|
111
|
+
let serialized: string
|
|
112
|
+
if (typeof input === 'string') {
|
|
113
|
+
serialized = input
|
|
114
|
+
} else {
|
|
115
|
+
try {
|
|
116
|
+
const json = JSON.stringify(input)
|
|
117
|
+
serialized = json === undefined ? String(input) : json
|
|
118
|
+
} catch {
|
|
119
|
+
serialized = 'unserializable-tool-input'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return createHash('sha256').update(serialized, 'utf8').digest('hex')
|
|
123
|
+
}
|
|
@@ -516,6 +516,7 @@ export async function runJevDecision(
|
|
|
516
516
|
// neither has a telemetry point — they are tool modes, not shadow gates.
|
|
517
517
|
let prebuilt: Omit<NativeDecisionRequest, 'model'> | undefined
|
|
518
518
|
let candidateSource: JevDecisionPreparation['candidateSource'] | undefined
|
|
519
|
+
let orderCandidates: readonly string[] = []
|
|
519
520
|
if (requested.mode === 'review') {
|
|
520
521
|
const prepared = buildJevReviewRequest(input ?? {})
|
|
521
522
|
if (!prepared.ok) {
|
|
@@ -542,6 +543,7 @@ export async function runJevDecision(
|
|
|
542
543
|
} else if (requested.mode === 'order') {
|
|
543
544
|
const prepared = buildJevOrderRequest(input ?? {})
|
|
544
545
|
if (!prepared.ok) return refusal(prepared.reasonCode, prepared.detail)
|
|
546
|
+
orderCandidates = prepared.candidates
|
|
545
547
|
prebuilt = prepared.request
|
|
546
548
|
}
|
|
547
549
|
const result = await runGatedNativeJevCall({
|
|
@@ -674,7 +676,11 @@ export async function runJevDecision(
|
|
|
674
676
|
// v3.1 ordering: one fit question per candidate (2-4), sorted descending.
|
|
675
677
|
// Null score = the host answered nothing usable for that candidate —
|
|
676
678
|
// visible, placed last, never guessed.
|
|
677
|
-
const ordering = consumeJevOrderResult(
|
|
679
|
+
const ordering = consumeJevOrderResult(
|
|
680
|
+
result.call.response,
|
|
681
|
+
result.call.request,
|
|
682
|
+
orderCandidates,
|
|
683
|
+
)
|
|
678
684
|
return JSON.stringify({
|
|
679
685
|
advisory: true,
|
|
680
686
|
effect: 'none',
|
|
@@ -152,7 +152,7 @@ export const J3_ESCALATION_CHEAP_MODEL = 'opencode/mimo-v2.6-flash'
|
|
|
152
152
|
/** Bound for the composed state text (the template is ~320 chars). */
|
|
153
153
|
export const J3_ESCALATION_STATE_MAX_LENGTH = 512
|
|
154
154
|
|
|
155
|
-
const FLAG_ON = new Set(['1', 'on', 'true'])
|
|
155
|
+
const FLAG_ON = new Set(['1', 'on', 'true', 'shadow'])
|
|
156
156
|
const TOKEN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/
|
|
157
157
|
const SHA256_HEX = /^[0-9a-f]{64}$/
|
|
158
158
|
/** Largest state_chars printed into the template (8 digits). */
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* Zeus can check 1–4 named claims in ONE typed round-trip: one `predicate`
|
|
23
23
|
* question per claim (within the 4-question bound), the claim text riding that
|
|
24
24
|
* question's instructions. The consumer maps each answer: probability
|
|
25
|
-
*
|
|
25
|
+
* > {@link VERIFY_PASS_THRESHOLD} (0.65) → `PASS`; 0.35–0.65 → `UNVERIFIABLE`; below →
|
|
26
|
+
* `FAIL`; and every refusal,
|
|
26
27
|
* timeout, duplicate or malformed answer → `BLOCK` (fail-closed: an
|
|
27
28
|
* unanswered mandatory claim must never read as verified). The tool itself
|
|
28
29
|
* never acts on a verdict — `effect` stays `none` — and a gate-chain refusal
|
|
@@ -73,7 +74,13 @@ export const VERIFY_MAX_CLAIMS = 4
|
|
|
73
74
|
export const CLAIM_MAX_LENGTH = 200
|
|
74
75
|
|
|
75
76
|
/** Predicate probability at or above which a claim counts as PASS. */
|
|
76
|
-
|
|
77
|
+
/**
|
|
78
|
+
* PASS lives strictly ABOVE the UNVERIFIABLE band (QA beta.20: with PASS at
|
|
79
|
+
* 0.5 the documented 0.35-0.65 band was unreachable at its top half — 0.50
|
|
80
|
+
* and 0.65 returned PASS). Verdicts: < 0.35 FAIL, 0.35-0.65 UNVERIFIABLE,
|
|
81
|
+
* > 0.65 PASS.
|
|
82
|
+
*/
|
|
83
|
+
export const VERIFY_PASS_THRESHOLD = 0.65
|
|
77
84
|
|
|
78
85
|
const CANDIDATE_ID_MAX_LENGTH = 64
|
|
79
86
|
const CLAIM_NAME_MAX_LENGTH = 64
|
|
@@ -300,7 +307,12 @@ export type JevOrderBuildFailure =
|
|
|
300
307
|
export type JevOrderBuildDetail = 'ORDER_CANDIDATE_COUNT_RANGE'
|
|
301
308
|
|
|
302
309
|
export type JevOrderBuild =
|
|
303
|
-
| {
|
|
310
|
+
| {
|
|
311
|
+
readonly ok: true
|
|
312
|
+
readonly request: Omit<NativeDecisionRequest, 'model'>
|
|
313
|
+
/** The caller's candidate ids in question order (QA beta.20: the consumer must map scores back to THESE, not positional c1..cN). */
|
|
314
|
+
readonly candidates: readonly string[]
|
|
315
|
+
}
|
|
304
316
|
| {
|
|
305
317
|
readonly ok: false
|
|
306
318
|
readonly reasonCode: JevOrderBuildFailure
|
|
@@ -308,7 +320,11 @@ export type JevOrderBuild =
|
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
export type JevOrderPreparation =
|
|
311
|
-
| {
|
|
323
|
+
| {
|
|
324
|
+
readonly ok: true
|
|
325
|
+
readonly request: NativeDecisionRequest
|
|
326
|
+
readonly candidates: readonly string[]
|
|
327
|
+
}
|
|
312
328
|
| {
|
|
313
329
|
readonly ok: false
|
|
314
330
|
readonly reasonCode: JevOrderBuildFailure
|
|
@@ -387,7 +403,11 @@ export function buildJevOrderRequest(input: unknown): JevOrderBuild {
|
|
|
387
403
|
]),
|
|
388
404
|
questions: Object.freeze(questions.map((question) => Object.freeze(question))),
|
|
389
405
|
} satisfies Omit<NativeDecisionRequest, 'model'>
|
|
390
|
-
return {
|
|
406
|
+
return {
|
|
407
|
+
ok: true,
|
|
408
|
+
request: Object.freeze(request),
|
|
409
|
+
candidates: Object.freeze(candidates.map((c) => c.id)),
|
|
410
|
+
}
|
|
391
411
|
}
|
|
392
412
|
|
|
393
413
|
export function prepareJevOrderRequest(
|
|
@@ -403,6 +423,7 @@ export function prepareJevOrderRequest(
|
|
|
403
423
|
input: built.request.input,
|
|
404
424
|
questions: built.request.questions,
|
|
405
425
|
},
|
|
426
|
+
candidates: built.candidates,
|
|
406
427
|
}
|
|
407
428
|
}
|
|
408
429
|
|
|
@@ -420,6 +441,7 @@ export interface JevOrderEntry {
|
|
|
420
441
|
export function consumeJevOrderResult(
|
|
421
442
|
response: unknown,
|
|
422
443
|
request: NativeDecisionRequest,
|
|
444
|
+
candidates: readonly string[],
|
|
423
445
|
): ReadonlyArray<JevOrderEntry> {
|
|
424
446
|
const advice = consumeJevDecisionResult(response, request)
|
|
425
447
|
const entries: Array<{ id: string; score: number | null; order: number }> = []
|
|
@@ -429,7 +451,9 @@ export function consumeJevOrderResult(
|
|
|
429
451
|
answer !== undefined && answer.type === 'score' && typeof answer.score === 'number'
|
|
430
452
|
? answer.score
|
|
431
453
|
: null
|
|
432
|
-
|
|
454
|
+
// QA beta.20: map back to the CALLER's candidate id — positional c1..cN
|
|
455
|
+
// told the user nothing.
|
|
456
|
+
entries.push({ id: candidates[index] ?? `c${index + 1}`, score, order: index })
|
|
433
457
|
})
|
|
434
458
|
return Object.freeze(
|
|
435
459
|
entries
|
|
@@ -609,7 +633,7 @@ export type VerifyClaimVerdict = 'PASS' | 'FAIL' | 'UNVERIFIABLE' | 'BLOCK'
|
|
|
609
633
|
|
|
610
634
|
/**
|
|
611
635
|
* Consume a host Decisions response against the prepared verify request:
|
|
612
|
-
* one verdict per claim name. Probability
|
|
636
|
+
* one verdict per claim name. Probability > {@link VERIFY_PASS_THRESHOLD} is
|
|
613
637
|
* `PASS`, below is `FAIL`; error answers, missing answers and any unusable
|
|
614
638
|
* response shape are `BLOCK` — fail-closed.
|
|
615
639
|
*/
|
|
@@ -624,7 +648,7 @@ export function consumeJevVerifyResult(
|
|
|
624
648
|
if (answer !== undefined && answer.type === 'predicate') {
|
|
625
649
|
const probability = answer.probability ?? 0
|
|
626
650
|
verdicts[question.name] =
|
|
627
|
-
probability
|
|
651
|
+
probability > VERIFY_PASS_THRESHOLD
|
|
628
652
|
? 'PASS'
|
|
629
653
|
: probability >= VERIFY_UNVERIFIABLE_LOW
|
|
630
654
|
? 'UNVERIFIABLE'
|
|
@@ -89,7 +89,7 @@ export const J1_RISK_GATE_STATE_MAX_LENGTH = 512
|
|
|
89
89
|
/** Predicate probability at or above which the intent counts as consistent. */
|
|
90
90
|
export const RISK_GATE_INTENT_THRESHOLD = 0.5
|
|
91
91
|
|
|
92
|
-
const FLAG_ON = new Set(['1', 'on', 'true'])
|
|
92
|
+
const FLAG_ON = new Set(['1', 'on', 'true', 'shadow'])
|
|
93
93
|
const TOOL_NAME_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/
|
|
94
94
|
const SHA256_HEX = /^[0-9a-f]{64}$/
|
|
95
95
|
const SCOPES: ReadonlySet<string> = new Set(['write', 'execute', 'read'])
|
|
@@ -192,7 +192,10 @@ export function isRiskGateTarget(tool: unknown): tool is string {
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* sha256 hex of the serialized tool input — an opaque correlation value, the
|
|
195
|
-
* only content-derived field that ever leaves this process.
|
|
195
|
+
* only content-derived field that ever leaves this process. The hash is a
|
|
196
|
+
* DETERMINISTIC pseudonymization (unsalted SHA-256 — same input, same hash by
|
|
197
|
+
* design, so approvals can be pinned to the exact call), NOT anonymization:
|
|
198
|
+
* someone holding the dictionary can reconstruct the input. Unserializable
|
|
196
199
|
* inputs hash a stable marker; this never throws.
|
|
197
200
|
*/
|
|
198
201
|
export function hashToolInput(input: unknown): string {
|
package/src/plugin-v2.ts
CHANGED
|
@@ -116,6 +116,13 @@ import {
|
|
|
116
116
|
import { GOAL_LOOP_DEFAULTS, GoalStore } from './pantheon/goal-loop.ts'
|
|
117
117
|
import { createGuardPathResolver } from './pantheon/guard-path.ts'
|
|
118
118
|
import { createJTelemetryMirror } from './pantheon/j-telemetry-file.ts'
|
|
119
|
+
import {
|
|
120
|
+
approvalInputHash,
|
|
121
|
+
hasApproval,
|
|
122
|
+
isAffirmativeAnswer,
|
|
123
|
+
j1ApprovalMarker,
|
|
124
|
+
mintApproval,
|
|
125
|
+
} from './pantheon/j1-approvals.ts'
|
|
119
126
|
import type { V2JevDecisionRuntime } from './pantheon/jev-decision-tool.ts'
|
|
120
127
|
import { specialistCallerAllowlist } from './pantheon/jev-decision-tool.ts'
|
|
121
128
|
import {
|
|
@@ -2159,21 +2166,35 @@ async function registerV2ToolHooks(
|
|
|
2159
2166
|
// block's visible form. Unavailability never denies (fail-open by
|
|
2160
2167
|
// design: a dead budget must not brick every shell call).
|
|
2161
2168
|
if (j1Mode === 'enforce') {
|
|
2169
|
+
// The approval path (field beta.21: "exigir uma aprovação explícita
|
|
2170
|
+
// para execução" — a deny must be askable, not destructive): an
|
|
2171
|
+
// approved retry of the EXACT call (session + input hash, TTL
|
|
2172
|
+
// bounded) passes without re-asking.
|
|
2173
|
+
const enforceEvent = event as { tool?: unknown; input?: unknown; sessionID?: unknown }
|
|
2174
|
+
const sessionID =
|
|
2175
|
+
typeof enforceEvent.sessionID === 'string' ? enforceEvent.sessionID : ''
|
|
2176
|
+
const inputHash = approvalInputHash(enforceEvent.input)
|
|
2177
|
+
if (sessionID !== '' && hasApproval(sessionID, inputHash)) {
|
|
2178
|
+
// Approved by the user: execute — and still observe (the
|
|
2179
|
+
// approved execution is exactly the record the baseline wants).
|
|
2180
|
+
void j1Observer(event)
|
|
2181
|
+
return
|
|
2182
|
+
}
|
|
2162
2183
|
const verdict = (await j1Observer(event)) as J1Verdict | undefined
|
|
2163
2184
|
if (verdict?.block === true) {
|
|
2164
|
-
// The block is
|
|
2165
|
-
//
|
|
2166
|
-
//
|
|
2167
|
-
//
|
|
2168
|
-
//
|
|
2169
|
-
// its own rendering.
|
|
2185
|
+
// The block is an APPROVAL REQUEST (not an error to route
|
|
2186
|
+
// around): ask the user through the `question` tool with the
|
|
2187
|
+
// marker below; an affirmative answer mints a hash-pinned,
|
|
2188
|
+
// TTL-bounded approval and the retry passes. Never echo the
|
|
2189
|
+
// tool input here — the arguments may carry the very secret
|
|
2190
|
+
// the risk score flagged; the agent owns its own rendering.
|
|
2170
2191
|
throw new Error(
|
|
2171
2192
|
`[J1 enforce] risco ${verdict.riskScore?.toFixed(2)} >= threshold ` +
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
'e
|
|
2175
|
-
'
|
|
2176
|
-
'
|
|
2193
|
+
`— APROVAÇÃO EXPLÍCITA NECESSÁRIA: use a tool question com o nome ` +
|
|
2194
|
+
`"${j1ApprovalMarker(inputHash)}" perguntando ao USUÁRIO se aprova esta exata chamada ` +
|
|
2195
|
+
'(apresente a ferramenta e o que ela faria, sem executá-la nem contorná-la). ' +
|
|
2196
|
+
'Se ele aprovar, reintente a MESMA chamada — ela passará. Se ele recusar, siga sem o ' +
|
|
2197
|
+
'passo arriscado ou entregue a execução manual a ele.',
|
|
2177
2198
|
)
|
|
2178
2199
|
}
|
|
2179
2200
|
} else {
|
|
@@ -2222,6 +2243,35 @@ async function registerV2ToolHooks(
|
|
|
2222
2243
|
try {
|
|
2223
2244
|
subagentOrigins.forget(event)
|
|
2224
2245
|
boundedReadOrigins?.forget(event)
|
|
2246
|
+
// J1 approval minter: the user's affirmative answer to a
|
|
2247
|
+
// `j1-approval-<hash12>` question mints the hash-pinned, TTL-bounded
|
|
2248
|
+
// approval the enforce gate checks. Only the OBSERVED host result can
|
|
2249
|
+
// mint — the agent cannot fabricate an answer.
|
|
2250
|
+
if (j1Mode === 'enforce') {
|
|
2251
|
+
try {
|
|
2252
|
+
const after = (event ?? {}) as {
|
|
2253
|
+
tool?: unknown
|
|
2254
|
+
sessionID?: unknown
|
|
2255
|
+
output?: unknown
|
|
2256
|
+
input?: unknown
|
|
2257
|
+
}
|
|
2258
|
+
if (after.tool === 'question') {
|
|
2259
|
+
const sessionID = typeof after.sessionID === 'string' ? after.sessionID : ''
|
|
2260
|
+
const serialized = JSON.stringify(after.output ?? {}) ?? ''
|
|
2261
|
+
const markerMatch = serialized.match(/j1-approval-([0-9a-f]{12})/)
|
|
2262
|
+
const markerHash = markerMatch?.[1]
|
|
2263
|
+
if (sessionID !== '' && markerHash !== undefined) {
|
|
2264
|
+
const name = `j1-approval-${markerHash}`
|
|
2265
|
+
if (isAffirmativeAnswer(name, serialized)) {
|
|
2266
|
+
mintApproval(sessionID, markerHash)
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
} catch {
|
|
2271
|
+
// The minter is best-effort; a parse failure just means no
|
|
2272
|
+
// approval (fail-closed).
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2225
2275
|
await v2ExecuteAfter(event)
|
|
2226
2276
|
// Formatter + delegation audit STOP (#266). Awaited for the same
|
|
2227
2277
|
// reason V1 awaits it: the log record should exist before the tool
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "1.6.3-beta.
|
|
3
|
+
"version": "1.6.3-beta.21",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "1.6.3-beta.
|
|
9
|
+
"version": "1.6.3-beta.21",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@opencode-ai/plugin": "1.18.33",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.6.3-beta.
|
|
4
|
+
"version": "1.6.3-beta.21",
|
|
5
5
|
"description": "Pantheon TUI plugin — V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|