pantheon-opencode 1.6.3-beta.1 → 1.6.3-beta.11
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/AGENTS.global.md +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +20 -2
- package/bin/pantheon-init.mjs +15 -27
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +103 -4
- package/scripts/decision-router-v2-budget.mjs +2 -2
- package/scripts/decision-router-v2-egress.mjs +0 -2
- package/scripts/decision-router.mjs +88 -6
- package/scripts/install/decision-router-config.mjs +53 -2
- package/scripts/install/interactive.mjs +96 -11
- package/scripts/install/opencode.mjs +26 -0
- package/scripts/install/plugin.mjs +17 -0
- package/scripts/jev-live-probe.mjs +210 -0
- package/scripts/skill-search.mjs +242 -0
- package/scripts/sync-tui.mjs +11 -0
- package/src/agents/aphrodite.md +34 -1
- package/src/agents/apollo.md +227 -0
- package/src/agents/athena.md +24 -0
- package/src/agents/demeter.md +33 -0
- package/src/agents/gaia.md +24 -0
- package/src/agents/hephaestus.md +24 -0
- package/src/agents/hermes.md +33 -0
- package/src/agents/iris.md +24 -0
- package/src/agents/mnemosyne.md +25 -3
- package/src/agents/nyx.md +53 -22
- package/src/agents/prometheus.md +242 -1
- package/src/agents/talos.md +24 -0
- package/src/agents/themis.md +24 -0
- package/src/agents/zeus.md +46 -6
- package/src/pantheon/j-telemetry-file.ts +96 -0
- package/src/pantheon/jev-decision-tool.ts +160 -24
- package/src/pantheon/jev-decisions.ts +18 -3
- package/src/pantheon/jev-rank-verify.ts +435 -0
- package/src/pantheon/jev-risk-gate.ts +1 -0
- package/src/pantheon/local-decision-budget.ts +170 -5
- package/src/pantheon/local-decision-provider-matrix.ts +0 -1
- package/src/pantheon/local-decision-usage-evidence.internal.ts +2 -2
- package/src/pantheon/v2-decision-budget.ts +4 -2
- package/src/plugin-v2.ts +9 -2
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +457 -4
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index-v2.tsx +6 -0
- package/src/plugins/tui/src/whats-new-highlights.ts +263 -0
- package/src/plugins/tui/src/whats-new-open.ts +80 -0
- package/src/plugins/tui/src/whats-new-state.ts +128 -0
- package/src/plugins/tui/src/whats-new.tsx +119 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* j-telemetry-file.ts — field-baseline mirror for the J-series shadow
|
|
3
|
+
* records (J1 risk gate, J3 escalation, J4 review).
|
|
4
|
+
*
|
|
5
|
+
* The in-memory sink (`createTelemetrySink`) is deliberately I/O-free and
|
|
6
|
+
* "the plugin never reads back" — which made the shadow records impossible
|
|
7
|
+
* to measure in the field, and the J1/J3 activation gate requires a measured
|
|
8
|
+
* baseline. This module adds the measurement channel: an opt-in JSONL mirror
|
|
9
|
+
* (`.pantheon/logs/j-telemetry.jsonl`) written ONLY when the J-series flags
|
|
10
|
+
* are on, carrying ONLY the already-sanitized record fields (point, mode,
|
|
11
|
+
* effect, reason tokens — the same bounded vocabulary the in-memory records
|
|
12
|
+
* carry; no user content exists on this path by construction).
|
|
13
|
+
*
|
|
14
|
+
* Fire-and-forget like every plugin log: a write failure is swallowed and
|
|
15
|
+
* never reaches the hook. The file is size-capped (rotate to `.1`, drop the
|
|
16
|
+
* oldest) so a long session cannot grow it unbounded.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { appendFile, mkdir, rename, stat } from 'node:fs/promises'
|
|
20
|
+
import { dirname, join } from 'node:path'
|
|
21
|
+
|
|
22
|
+
const MAX_FILE_BYTES = 1_048_576
|
|
23
|
+
|
|
24
|
+
/** Default mirror target: the established Pantheon logs directory. */
|
|
25
|
+
export function defaultMirrorPath(cwd: string = process.cwd()): string {
|
|
26
|
+
return join(cwd, '.pantheon', 'logs', 'j-telemetry.jsonl')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The record fields allowed on the wire. Everything else is dropped. */
|
|
30
|
+
const ALLOWED_FIELDS = ['point', 'mode', 'effect', 'decision', 'reason'] as const
|
|
31
|
+
|
|
32
|
+
/** Extract the bounded projection a mirror line may carry. */
|
|
33
|
+
export function mirrorProjection(record: unknown): Record<string, unknown> | null {
|
|
34
|
+
if (record === null || typeof record !== 'object' || Array.isArray(record)) return null
|
|
35
|
+
const source = record as Record<string, unknown>
|
|
36
|
+
const projected: Record<string, unknown> = { ts: new Date().toISOString() }
|
|
37
|
+
for (const field of ALLOWED_FIELDS) {
|
|
38
|
+
const value = source[field]
|
|
39
|
+
if (value === undefined) continue
|
|
40
|
+
if (typeof value !== 'string') return null
|
|
41
|
+
if (value.length > 200) return null
|
|
42
|
+
projected[field] = value
|
|
43
|
+
}
|
|
44
|
+
return projected
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface JTelemetryMirror {
|
|
48
|
+
/**
|
|
49
|
+
* Append one sanitized record line; best-effort, never throws. Fire-and-
|
|
50
|
+
* forget at call sites (the promise may be ignored); it is returned so a
|
|
51
|
+
* test can await the write.
|
|
52
|
+
*/
|
|
53
|
+
record(record: unknown): Promise<void>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Create the opt-in JSONL mirror. Returns null when `enabled` is false so
|
|
58
|
+
* callers keep the zero-overhead path branch-free.
|
|
59
|
+
* @param {{ enabled: boolean, path?: string }} options
|
|
60
|
+
*/
|
|
61
|
+
export function createJTelemetryMirror(options: {
|
|
62
|
+
enabled: boolean
|
|
63
|
+
path?: string
|
|
64
|
+
}): JTelemetryMirror | null {
|
|
65
|
+
if (!options.enabled) return null
|
|
66
|
+
const path = options.path ?? defaultMirrorPath()
|
|
67
|
+
let rotating = false
|
|
68
|
+
return {
|
|
69
|
+
record(record: unknown): Promise<void> {
|
|
70
|
+
try {
|
|
71
|
+
const projected = mirrorProjection(record)
|
|
72
|
+
if (projected === null) return Promise.resolve()
|
|
73
|
+
const line = `${JSON.stringify(projected)}\n`
|
|
74
|
+
return (async () => {
|
|
75
|
+
try {
|
|
76
|
+
if (!rotating) {
|
|
77
|
+
const current = await stat(path).catch(() => null)
|
|
78
|
+
if (current !== null && current.size > MAX_FILE_BYTES) {
|
|
79
|
+
rotating = true
|
|
80
|
+
await rename(path, `${path}.1`).catch(() => {})
|
|
81
|
+
rotating = false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await mkdir(dirname(path), { recursive: true })
|
|
85
|
+
await appendFile(path, line, 'utf8')
|
|
86
|
+
} catch {
|
|
87
|
+
// Best-effort mirror — never break the plugin over telemetry.
|
|
88
|
+
}
|
|
89
|
+
})()
|
|
90
|
+
} catch {
|
|
91
|
+
// Swallow: projection failures are data-shaped, never fatal.
|
|
92
|
+
return Promise.resolve()
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -42,6 +42,12 @@ import {
|
|
|
42
42
|
type QualityScoreEvaluation,
|
|
43
43
|
qualityVerdict,
|
|
44
44
|
} from './jev-quality-score.ts'
|
|
45
|
+
import {
|
|
46
|
+
buildJevRankRequest,
|
|
47
|
+
buildJevVerifyRequest,
|
|
48
|
+
consumeJevRankResult,
|
|
49
|
+
consumeJevVerifyResult,
|
|
50
|
+
} from './jev-rank-verify.ts'
|
|
45
51
|
import { mapGateFailureToSkipReason } from './jev-risk-gate.ts'
|
|
46
52
|
import {
|
|
47
53
|
openLocalDecisionBudgetLedger,
|
|
@@ -70,7 +76,8 @@ export interface V2JevDecisionRuntime {
|
|
|
70
76
|
/**
|
|
71
77
|
* Allowlisted specialist callers for explicit-questions mode (parsed from
|
|
72
78
|
* `PANTHEON_JEV_SPECIALIST_CALLERS` by the plugin wiring). Empty/absent =
|
|
73
|
-
* Zeus only. Preset modes
|
|
79
|
+
* Zeus only. Preset and v3.1 modes (skills, delegation, review, rank,
|
|
80
|
+
* verify) stay Zeus-only regardless.
|
|
74
81
|
*/
|
|
75
82
|
readonly specialistCallers?: readonly string[]
|
|
76
83
|
/**
|
|
@@ -98,11 +105,12 @@ export const SPECIALIST_CALLERS_FLAG_ENV = 'PANTHEON_JEV_SPECIALIST_CALLERS'
|
|
|
98
105
|
|
|
99
106
|
/**
|
|
100
107
|
* Parse the caller allowlist from the flag's CSV value. Unset/empty = Zeus
|
|
101
|
-
* only (the default). Preset modes (skills, delegation, review
|
|
102
|
-
* Zeus-only regardless of the flag: owner/skill selection
|
|
103
|
-
* scoring
|
|
104
|
-
* questions mid-task, nothing
|
|
105
|
-
*
|
|
108
|
+
* only (the default). Preset and v3.1 modes (skills, delegation, review,
|
|
109
|
+
* rank, verify) stay Zeus-only regardless of the flag: owner/skill selection,
|
|
110
|
+
* result scoring, candidate ranking and claim verification are orchestration
|
|
111
|
+
* decisions; specialists may ask bounded typed questions mid-task, nothing
|
|
112
|
+
* else. Lives in the plugin wiring (which owns flag reads); this module
|
|
113
|
+
* receives the parsed list via the runtime.
|
|
106
114
|
*/
|
|
107
115
|
export function specialistCallerAllowlist(flagValue: string | undefined): readonly string[] {
|
|
108
116
|
const raw = String(flagValue ?? '').trim()
|
|
@@ -118,6 +126,10 @@ export type JevDecisionRunFailure =
|
|
|
118
126
|
| 'CALLER_NOT_ALLOWED'
|
|
119
127
|
| 'REVIEW_INPUT_INVALID'
|
|
120
128
|
| 'CRITERIA_INVALID'
|
|
129
|
+
| 'RANK_INPUT_INVALID'
|
|
130
|
+
| 'CANDIDATE_INVALID'
|
|
131
|
+
| 'VERIFY_INPUT_INVALID'
|
|
132
|
+
| 'CLAIM_INVALID'
|
|
121
133
|
| 'CONTEXT_UNAVAILABLE'
|
|
122
134
|
| 'CONFIG_UNAVAILABLE'
|
|
123
135
|
| 'DISABLED'
|
|
@@ -131,6 +143,7 @@ export type JevDecisionRunFailure =
|
|
|
131
143
|
| 'PRESET_INVALID'
|
|
132
144
|
| 'RESERVATION_DENIED'
|
|
133
145
|
| 'DECISION_CALL_FAILED'
|
|
146
|
+
| 'USAGE_EVIDENCE_UNAVAILABLE'
|
|
134
147
|
| 'USAGE_UNRECONCILED'
|
|
135
148
|
|
|
136
149
|
interface JevToolContext {
|
|
@@ -159,15 +172,24 @@ function reviewRefusalSkipReason(reasonCode: JevDecisionRunFailure): string {
|
|
|
159
172
|
/**
|
|
160
173
|
* Every gate-chain failure the shared runner can produce. It is
|
|
161
174
|
* {@link JevDecisionRunFailure} minus the tool-surface properties:
|
|
162
|
-
* `CALLER_NOT_ALLOWED` (the caller check) and the
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
175
|
+
* `CALLER_NOT_ALLOWED` (the caller check) and the input validation of the
|
|
176
|
+
* prebuilt-request modes — the review mode (`REVIEW_INPUT_INVALID` /
|
|
177
|
+
* `CRITERIA_INVALID`) and the v3.1 rank and verify modes
|
|
178
|
+
* (`RANK_INPUT_INVALID` / `CANDIDATE_INVALID` / `VERIFY_INPUT_INVALID` /
|
|
179
|
+
* `CLAIM_INVALID`). All of these are properties of the explicit tool surface,
|
|
180
|
+
* whose input the caller supplies directly, not of the gate chain; the
|
|
181
|
+
* J1/J3 shadow observers run the same chain for any agent and can never
|
|
182
|
+
* produce them.
|
|
167
183
|
*/
|
|
168
184
|
export type GatedNativeJevFailure = Exclude<
|
|
169
185
|
JevDecisionRunFailure,
|
|
170
|
-
|
|
186
|
+
| 'CALLER_NOT_ALLOWED'
|
|
187
|
+
| 'REVIEW_INPUT_INVALID'
|
|
188
|
+
| 'CRITERIA_INVALID'
|
|
189
|
+
| 'RANK_INPUT_INVALID'
|
|
190
|
+
| 'CANDIDATE_INVALID'
|
|
191
|
+
| 'VERIFY_INPUT_INVALID'
|
|
192
|
+
| 'CLAIM_INVALID'
|
|
171
193
|
>
|
|
172
194
|
|
|
173
195
|
/** The minimal runtime slice the gate chain needs. */
|
|
@@ -264,6 +286,14 @@ export async function runGatedNativeJevCall(params: {
|
|
|
264
286
|
)
|
|
265
287
|
if (!selection.ok) return { ok: false, reasonCode: selection.reasonCode }
|
|
266
288
|
|
|
289
|
+
// Cloudflare Workers AI has no supported native-usage evidence parser yet.
|
|
290
|
+
// Reject its Jev route before permission, request preparation, or budget
|
|
291
|
+
// reservation; otherwise the provider could be called and leave a pending
|
|
292
|
+
// reservation when reconciliation cannot be verified.
|
|
293
|
+
if (selection.selection.provider === 'cloudflare-workers-jev') {
|
|
294
|
+
return { ok: false, reasonCode: 'USAGE_EVIDENCE_UNAVAILABLE' }
|
|
295
|
+
}
|
|
296
|
+
|
|
267
297
|
if (typeof params.runtime.permissionAssert !== 'function') {
|
|
268
298
|
return { ok: false, reasonCode: 'PERMISSION_UNAVAILABLE' }
|
|
269
299
|
}
|
|
@@ -425,8 +455,10 @@ export async function runJevDecision(
|
|
|
425
455
|
}
|
|
426
456
|
// Review mode (J4): the bounded request is built before any gate work, and
|
|
427
457
|
// an invalid review input is a tool-surface refusal — same class as the
|
|
428
|
-
// caller check, never a gate failure.
|
|
429
|
-
|
|
458
|
+
// caller check, never a gate failure. The v3.1 rank and verify modes follow
|
|
459
|
+
// the same prebuilt-request pattern (no gate work for a malformed input);
|
|
460
|
+
// neither has a telemetry point — they are tool modes, not shadow gates.
|
|
461
|
+
let prebuilt: Omit<NativeDecisionRequest, 'model'> | undefined
|
|
430
462
|
if (requested.mode === 'review') {
|
|
431
463
|
const prepared = buildJevReviewRequest(input ?? {})
|
|
432
464
|
if (!prepared.ok) {
|
|
@@ -441,7 +473,15 @@ export async function runJevDecision(
|
|
|
441
473
|
)
|
|
442
474
|
return refusal(prepared.reasonCode)
|
|
443
475
|
}
|
|
444
|
-
|
|
476
|
+
prebuilt = prepared.request
|
|
477
|
+
} else if (requested.mode === 'rank') {
|
|
478
|
+
const prepared = buildJevRankRequest(input ?? {})
|
|
479
|
+
if (!prepared.ok) return refusal(prepared.reasonCode)
|
|
480
|
+
prebuilt = prepared.request
|
|
481
|
+
} else if (requested.mode === 'verify') {
|
|
482
|
+
const prepared = buildJevVerifyRequest(input ?? {})
|
|
483
|
+
if (!prepared.ok) return refusal(prepared.reasonCode)
|
|
484
|
+
prebuilt = prepared.request
|
|
445
485
|
}
|
|
446
486
|
const result = await runGatedNativeJevCall({
|
|
447
487
|
sessionID: context?.sessionID,
|
|
@@ -449,13 +489,13 @@ export async function runJevDecision(
|
|
|
449
489
|
agent: caller,
|
|
450
490
|
runtime,
|
|
451
491
|
prepare: async (route) =>
|
|
452
|
-
|
|
492
|
+
prebuilt !== undefined
|
|
453
493
|
? {
|
|
454
494
|
ok: true as const,
|
|
455
495
|
request: {
|
|
456
496
|
model: route.model,
|
|
457
|
-
input:
|
|
458
|
-
questions:
|
|
497
|
+
input: prebuilt.input,
|
|
498
|
+
questions: prebuilt.questions,
|
|
459
499
|
},
|
|
460
500
|
}
|
|
461
501
|
: requested.mode === undefined
|
|
@@ -541,6 +581,53 @@ export async function runJevDecision(
|
|
|
541
581
|
frozen: result.call.frozen,
|
|
542
582
|
})
|
|
543
583
|
}
|
|
584
|
+
if (requested.mode === 'rank') {
|
|
585
|
+
// v3.1 rank: the winner choice plus that candidate's fit score. The host
|
|
586
|
+
// API answers one scalar per question, so no runner-up or full ordering is
|
|
587
|
+
// returned — see jev-rank-verify.ts for the honest limitation.
|
|
588
|
+
const rank = consumeJevRankResult(result.call.response, result.call.request)
|
|
589
|
+
return JSON.stringify({
|
|
590
|
+
advisory: true,
|
|
591
|
+
effect: 'none',
|
|
592
|
+
reason: 'JEV_DECISION',
|
|
593
|
+
caller,
|
|
594
|
+
route: {
|
|
595
|
+
providerID: result.call.selection.route.model.providerID,
|
|
596
|
+
id: result.call.selection.route.model.id,
|
|
597
|
+
billing: result.call.selection.route.billing,
|
|
598
|
+
},
|
|
599
|
+
mode: 'rank',
|
|
600
|
+
winner: rank.winner,
|
|
601
|
+
winnerFit: rank.winnerFit,
|
|
602
|
+
answers: advice.answers,
|
|
603
|
+
missing: advice.missing,
|
|
604
|
+
usage: { costUsd: advice.costUsd, tokens: advice.tokens },
|
|
605
|
+
frozen: result.call.frozen,
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
if (requested.mode === 'verify') {
|
|
609
|
+
// v3.1 verify: one PASS/FAIL/BLOCK verdict per claim, fail-closed. The
|
|
610
|
+
// tool never acts on the verdicts; a caller that requires a verdict
|
|
611
|
+
// treats a refusal (which never reaches this branch) as BLOCK.
|
|
612
|
+
const results = consumeJevVerifyResult(result.call.response, result.call.request)
|
|
613
|
+
return JSON.stringify({
|
|
614
|
+
advisory: true,
|
|
615
|
+
effect: 'none',
|
|
616
|
+
reason: 'JEV_DECISION',
|
|
617
|
+
caller,
|
|
618
|
+
route: {
|
|
619
|
+
providerID: result.call.selection.route.model.providerID,
|
|
620
|
+
id: result.call.selection.route.model.id,
|
|
621
|
+
billing: result.call.selection.route.billing,
|
|
622
|
+
},
|
|
623
|
+
mode: 'verify',
|
|
624
|
+
results,
|
|
625
|
+
answers: advice.answers,
|
|
626
|
+
missing: advice.missing,
|
|
627
|
+
usage: { costUsd: advice.costUsd, tokens: advice.tokens },
|
|
628
|
+
frozen: result.call.frozen,
|
|
629
|
+
})
|
|
630
|
+
}
|
|
544
631
|
return JSON.stringify({
|
|
545
632
|
advisory: true,
|
|
546
633
|
effect: 'none',
|
|
@@ -567,7 +654,10 @@ const TOOL_DESCRIPTION =
|
|
|
567
654
|
'host), `mode: "delegation"` to pick ' +
|
|
568
655
|
'a specialist, `mode: "review"` to score a finished delegated result against named criteria ' +
|
|
569
656
|
'(advisory quality score + needs-review flag; the result content itself is never sent — ' +
|
|
570
|
-
'shape metrics and criteria only),
|
|
657
|
+
'shape metrics and criteria only), `mode: "rank"` to pick the best of 2-8 named candidates ' +
|
|
658
|
+
'(returns the winner and its fit score; no full ordering), `mode: "verify"` to check 1-4 ' +
|
|
659
|
+
'named claims (PASS/FAIL per claim; any refusal, timeout or malformed answer is BLOCK, ' +
|
|
660
|
+
'fail-closed), or pass explicit typed `questions` (choice, score, ' +
|
|
571
661
|
'predicate). Invalid-input refusals carry a `detail` token naming the exact cause. Returns ' +
|
|
572
662
|
'probabilistic answers with confidence. Requires decision-router egress ' +
|
|
573
663
|
'consent and budget caps; asks host permission first. It never dispatches agents, runs ' +
|
|
@@ -622,13 +712,45 @@ const REVIEW_METRICS_SCHEMA = {
|
|
|
622
712
|
},
|
|
623
713
|
} as const
|
|
624
714
|
|
|
715
|
+
const RANK_CANDIDATE_SCHEMA = {
|
|
716
|
+
type: 'object',
|
|
717
|
+
additionalProperties: false,
|
|
718
|
+
required: ['id'],
|
|
719
|
+
properties: {
|
|
720
|
+
id: {
|
|
721
|
+
type: 'string',
|
|
722
|
+
minLength: 1,
|
|
723
|
+
maxLength: 64,
|
|
724
|
+
pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$',
|
|
725
|
+
},
|
|
726
|
+
description: { type: 'string', minLength: 1, maxLength: 500 },
|
|
727
|
+
},
|
|
728
|
+
} as const
|
|
729
|
+
|
|
730
|
+
const VERIFY_CLAIM_SCHEMA = {
|
|
731
|
+
type: 'object',
|
|
732
|
+
additionalProperties: false,
|
|
733
|
+
required: ['name', 'claim'],
|
|
734
|
+
properties: {
|
|
735
|
+
name: {
|
|
736
|
+
type: 'string',
|
|
737
|
+
minLength: 1,
|
|
738
|
+
maxLength: 64,
|
|
739
|
+
pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$',
|
|
740
|
+
},
|
|
741
|
+
claim: { type: 'string', minLength: 1, maxLength: 200 },
|
|
742
|
+
},
|
|
743
|
+
} as const
|
|
744
|
+
|
|
625
745
|
/**
|
|
626
|
-
* One schema,
|
|
627
|
-
* questions carry the state text)
|
|
746
|
+
* One schema, four disjoint payloads: the state branch (presets and explicit
|
|
747
|
+
* questions carry the state text), the review branch (J4 takes structural
|
|
628
748
|
* shape metrics, a delegate id and named criteria — never a state text, never
|
|
629
749
|
* result content; the criteria are the only free text, bounded at the DSH
|
|
630
|
-
* caps: at most 4, each 1–120 chars)
|
|
631
|
-
*
|
|
750
|
+
* caps: at most 4, each 1–120 chars), the rank branch (v3.1: a state plus
|
|
751
|
+
* 2–8 named candidates) and the verify branch (v3.1: 1–4 named claims, no
|
|
752
|
+
* state). The preparers are the authority; the schema is the model-facing
|
|
753
|
+
* contract.
|
|
632
754
|
*/
|
|
633
755
|
const JEV_INPUT_SCHEMA: Record<string, unknown> = {
|
|
634
756
|
type: 'object',
|
|
@@ -637,11 +759,13 @@ const JEV_INPUT_SCHEMA: Record<string, unknown> = {
|
|
|
637
759
|
anyOf: [
|
|
638
760
|
{ required: ['state'] },
|
|
639
761
|
{ required: ['delegateId', 'resultSummaryKind', 'resultMetrics', 'criteria'] },
|
|
762
|
+
{ required: ['candidates'] },
|
|
763
|
+
{ required: ['claims'] },
|
|
640
764
|
],
|
|
641
765
|
properties: {
|
|
642
766
|
schemaVersion: { type: 'integer', const: 1 },
|
|
643
767
|
state: { type: 'string', minLength: 1, maxLength: 12_000 },
|
|
644
|
-
mode: { type: 'string', enum: ['skills', 'delegation', 'review'] },
|
|
768
|
+
mode: { type: 'string', enum: ['skills', 'delegation', 'review', 'rank', 'verify'] },
|
|
645
769
|
questions: { type: 'array', minItems: 1, maxItems: 4, items: questionSchema },
|
|
646
770
|
delegateId: {
|
|
647
771
|
type: 'string',
|
|
@@ -657,6 +781,18 @@ const JEV_INPUT_SCHEMA: Record<string, unknown> = {
|
|
|
657
781
|
maxItems: 4,
|
|
658
782
|
items: { type: 'string', minLength: 1, maxLength: 120 },
|
|
659
783
|
},
|
|
784
|
+
candidates: {
|
|
785
|
+
type: 'array',
|
|
786
|
+
minItems: 2,
|
|
787
|
+
maxItems: 8,
|
|
788
|
+
items: RANK_CANDIDATE_SCHEMA,
|
|
789
|
+
},
|
|
790
|
+
claims: {
|
|
791
|
+
type: 'array',
|
|
792
|
+
minItems: 1,
|
|
793
|
+
maxItems: 4,
|
|
794
|
+
items: VERIFY_CLAIM_SCHEMA,
|
|
795
|
+
},
|
|
660
796
|
},
|
|
661
797
|
}
|
|
662
798
|
|
|
@@ -36,7 +36,6 @@ export type NativeJevProviderId = Extract<
|
|
|
36
36
|
DecisionProviderId,
|
|
37
37
|
| 'typesafe-jev'
|
|
38
38
|
| 'opencode-console-jev'
|
|
39
|
-
| 'opencode-console-jev-free'
|
|
40
39
|
| 'openrouter-jev'
|
|
41
40
|
| 'vercel-gateway-jev'
|
|
42
41
|
| 'cloudflare-workers-jev'
|
|
@@ -51,7 +50,6 @@ export type NativeJevProviderId = Extract<
|
|
|
51
50
|
export const NATIVE_JEV_HOST_PROVIDERS = Object.freeze({
|
|
52
51
|
'typesafe-jev': 'typesafe-ai',
|
|
53
52
|
'opencode-console-jev': 'opencode',
|
|
54
|
-
'opencode-console-jev-free': 'opencode',
|
|
55
53
|
// Host-embedded decision modules confirmed in the 2.2.5 binary
|
|
56
54
|
// (providers/<id>/decisions, System One transport — the host normalizes
|
|
57
55
|
// the request/response, so consumers only need the providerID mapping):
|
|
@@ -223,6 +221,8 @@ export type JevDecisionPreparationDetail =
|
|
|
223
221
|
| 'SCORE_INVALID'
|
|
224
222
|
| 'PREDICATE_HAS_CHOICES_OR_LEVELS'
|
|
225
223
|
| 'QUESTION_TYPE_INVALID'
|
|
224
|
+
| 'SCHEMA_VERSION_INVALID'
|
|
225
|
+
| 'UNKNOWN_INPUT_KEYS'
|
|
226
226
|
|
|
227
227
|
export type JevDecisionPreparation =
|
|
228
228
|
| { readonly ok: true; readonly request: NativeDecisionRequest }
|
|
@@ -313,8 +313,23 @@ function readScoreQuestion(
|
|
|
313
313
|
*/
|
|
314
314
|
export function prepareJevDecisionRequest(
|
|
315
315
|
route: ResolvedNativeDecisionRoute,
|
|
316
|
-
input: {
|
|
316
|
+
input: {
|
|
317
|
+
readonly schemaVersion?: unknown
|
|
318
|
+
readonly state?: unknown
|
|
319
|
+
readonly questions?: unknown
|
|
320
|
+
},
|
|
317
321
|
): JevDecisionPreparation {
|
|
322
|
+
// Envelope enforcement (field report N2/N3): schemaVersion was documented
|
|
323
|
+
// as required but never checked, and unknown keys passed silently to the
|
|
324
|
+
// provider against the declared additionalProperties: false.
|
|
325
|
+
if (input.schemaVersion !== 1) {
|
|
326
|
+
return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'SCHEMA_VERSION_INVALID' }
|
|
327
|
+
}
|
|
328
|
+
const knownKeys = new Set(['schemaVersion', 'state', 'questions'])
|
|
329
|
+
const unknown = Object.keys(input).filter((key) => !knownKeys.has(key))
|
|
330
|
+
if (unknown.length > 0) {
|
|
331
|
+
return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'UNKNOWN_INPUT_KEYS' }
|
|
332
|
+
}
|
|
318
333
|
const state = input.state
|
|
319
334
|
if (!isBoundedNonBlankString(state, NATIVE_DECISION_MAX_PROMPT_LENGTH)) {
|
|
320
335
|
return { ok: false, reasonCode: 'STATE_INVALID' }
|