pantheon-opencode 1.6.2 → 1.6.3-beta.1

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 CHANGED
@@ -10,6 +10,18 @@ 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.1] - 2026-11-04
14
+
15
+ ### Added
16
+
17
+ - **routing** — The decision-provider matrix expands to the host-embedded decision modules confirmed in the 2.2.5 binary: `openrouter-jev` (OpenRouter-hosted `typesafe/jev-1.13`), `vercel-gateway-jev` (Vercel AI Gateway `typesafe-ai/jev`), and `cloudflare-workers-jev` (Workers AI `clef`; needs a custom entry with your accountId). Route resolution stays config-only; `doctor` gains route-aware rows per provider.
18
+ - **routing** — Specialist caller allowlist: `PANTHEON_JEV_SPECIALIST_CALLERS` (CSV, default empty = Zeus only) lets named agents call `pantheon_jev_decide` with explicit typed questions; preset modes stay orchestrator-owned. The permission assertion and the success output carry the real caller; caps and the `decision.egress` kill-switch are enforced per call regardless of caller.
19
+ - **routing** — `DECISION_CALL_FAILED` surfaces the provider reason class, integer status and retry window (rate limits now self-explain); `QUESTIONS_INVALID` carries a per-cause `detail` token (ten causes, one each); the tool description states the required-fields contract on its surface.
20
+
21
+ ### Fixed
22
+
23
+ - **routing** — The TypeSafe provisioner writes a **complete** custom provider entry: the `@ai-sdk/openai-compatible` adapter, the `api.typesafe.ai/v1` baseURL, and an `apiKey` env reference (`{env:TYPESAFE_API_KEY}` — the key itself never lands in the config file). Field evidence: a models-only entry is inert because models.dev has no typesafe-ai entry, so `/connect` and `opencode auth login` cannot supply it and the decisions call 404s. `doctor` now warns when the entry lacks the apiKey; the activation path is `export TYPESAFE_API_KEY=...` + restart.
24
+
13
25
  ## [v1.6.2] - 2026-11-03
14
26
 
15
27
  ### Added
@@ -1036,7 +1036,7 @@ async function main() {
1036
1036
  const provisioned = provisionTypesafeProvider()
1037
1037
  console.log(
1038
1038
  provisioned === true
1039
- ? ' TypeSafe provider entry merged into opencode.json (models.typesafe-ai, type "decision"). Sign in with `opencode auth login` (TypeSafe) or /connect.'
1039
+ ? ' TypeSafe provider entry merged into opencode.json (adapter + baseURL + apiKey via {env:TYPESAFE_API_KEY}, type "decision"). Activate: export TYPESAFE_API_KEY=<your TypeSafe key> and restart OpenCode. /connect does not carry custom providers.'
1040
1040
  : ` TypeSafe provider entry NOT merged (${provisioned}); merge it manually — see docs/reference/native-decisions.md.`,
1041
1041
  )
1042
1042
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.2",
3
+ "version": "1.6.3-beta.1",
4
4
  "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.2",
4
+ "version": "1.6.3-beta.1",
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"
7
+ version = "1.6.3-beta.1"
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
@@ -26,7 +26,10 @@ var LOCAL_DECISION_BUDGET_PROVIDERS = Object.freeze([
26
26
  "openai-decisions",
27
27
  "typesafe-jev",
28
28
  "opencode-console",
29
- "jev-free"
29
+ "jev-free",
30
+ "openrouter",
31
+ "vercel-ai-gateway",
32
+ "cloudflare-workers-ai"
30
33
  ]);
31
34
  var ALLOWED_PROVIDERS = new Set(LOCAL_DECISION_BUDGET_PROVIDERS);
32
35
  var MODEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
@@ -14,13 +14,22 @@ var DECISION_ROUTER_MODELS = Object.freeze({
14
14
  "openai-decisions": Object.freeze(["gpt-6-luna"]),
15
15
  "typesafe-jev": Object.freeze(["jev-1.14.0"]),
16
16
  "opencode-console-jev": Object.freeze(["jev-1.13"]),
17
- "opencode-console-jev-free": Object.freeze(["jev-1.13-free"])
17
+ "opencode-console-jev-free": Object.freeze(["jev-1.13-free"]),
18
+ // Host-embedded decision modules confirmed in the 2.2.5 binary; the model
19
+ // ids are the provider-side decision models (see
20
+ // docs/reference/native-decisions.md for credential acquisition).
21
+ "openrouter-jev": Object.freeze(["typesafe/jev-1.13"]),
22
+ "vercel-gateway-jev": Object.freeze(["typesafe-ai/jev"]),
23
+ "cloudflare-workers-jev": Object.freeze(["clef"])
18
24
  });
19
25
  var DECISION_PROVIDER_BUDGET_MAPPING = Object.freeze({
20
26
  "openai-decisions": "openai-decisions",
21
27
  "typesafe-jev": "typesafe-jev",
22
28
  "opencode-console-jev": "opencode-console",
23
- "opencode-console-jev-free": "jev-free"
29
+ "opencode-console-jev-free": "jev-free",
30
+ "openrouter-jev": "openrouter",
31
+ "vercel-gateway-jev": "vercel-ai-gateway",
32
+ "cloudflare-workers-jev": "cloudflare-workers-ai"
24
33
  });
25
34
  var REMOTELY_ELIGIBLE_DECISION_PROVIDERS = Object.freeze([
26
35
  "openai-decisions",
@@ -346,8 +346,8 @@ export async function runDecisionRouterCommand(
346
346
  const provision = provisionTypesafeHostProvider({ env })
347
347
  if (provision.ok) {
348
348
  stdout(
349
- `TypeSafe provider entry merged into ${provision.path} (models.typesafe-ai, type "decision"). ` +
350
- 'Sign in with `opencode auth login` (TypeSafe) or /connect.',
349
+ `TypeSafe provider entry merged into ${provision.path} (adapter + baseURL + apiKey via {env:TYPESAFE_API_KEY}, type "decision"). ` +
350
+ 'Activate: export TYPESAFE_API_KEY=<your TypeSafe key> and restart OpenCode. /connect does not carry custom providers.',
351
351
  )
352
352
  } else {
353
353
  stdout(`⚠ TypeSafe provider entry NOT merged: ${provision.reason}`)
@@ -489,18 +489,41 @@ export async function runDecisionRouterCommand(
489
489
  // Route-aware checks, not a catalog probe: decision models are not chat
490
490
  // models and never appear in `opencode models` (field evidence 2.2.5:
491
491
  // 561 entries, 0 jev, while the decisions API answers the same ref).
492
- if (target.provider === 'typesafe-jev') {
492
+ if (target.provider === 'openrouter-jev' || target.provider === 'vercel-gateway-jev') {
493
+ const envName =
494
+ target.provider === 'openrouter-jev' ? 'OPENROUTER_API_KEY' : 'AI_GATEWAY_API_KEY'
495
+ pass(
496
+ 'native-route',
497
+ `host-native ${target.provider === 'openrouter-jev' ? 'openrouter' : 'vercel-ai-gateway'} route; credential ${envName} via /connect or the environment`,
498
+ )
499
+ } else if (target.provider === 'cloudflare-workers-jev') {
500
+ warn(
501
+ 'native-route',
502
+ 'host module exists but the provider needs a custom entry with your Cloudflare accountId (models.dev does not carry it)',
503
+ 'add providers["cloudflare-workers-ai"] with accountId + CLOUDFLARE_API_TOKEN (scoped Workers AI token); model clef',
504
+ )
505
+ } else if (target.provider === 'typesafe-jev') {
493
506
  const hostProvider = inspectTypesafeHostProvider({ env })
494
- if (hostProvider.present) {
495
- pass(
507
+ if (!hostProvider.present) {
508
+ fail(
496
509
  'native-route',
497
- `typesafe-ai provider entry present (${hostProvider.path}); credential via \`opencode auth login\` (TypeSafe) or /connect`,
510
+ `opencode.json has no providers.typesafe-ai entry (${hostProvider.path})`,
511
+ 'decision-router setup-model typesafe-jev/jev-1.14.0 merges the full provider entry (adapter, baseURL, apiKey ref)',
512
+ )
513
+ } else if (!hostProvider.hasCredential) {
514
+ warn(
515
+ 'native-route',
516
+ 'provider entry has no apiKey',
517
+ 'set the TypeSafe key: export TYPESAFE_API_KEY=... and re-run setup-model (writes {env:TYPESAFE_API_KEY}), or add options.apiKey to the entry',
498
518
  )
499
519
  } else {
500
- fail(
520
+ pass(
501
521
  'native-route',
502
- `opencode.json has no providers.typesafe-ai entry (${hostProvider.path})`,
503
- 'decision-router setup-model typesafe-jev/jev-1.14.0 merges it (type: "decision")',
522
+ `typesafe-ai provider entry present (${hostProvider.path}); credential ${
523
+ hostProvider.viaEnvRef
524
+ ? `via env reference (${hostProvider.apiKeyRef}) — resolved by the host at call time`
525
+ : 'inline in the entry'
526
+ }`,
504
527
  )
505
528
  }
506
529
  } else {
@@ -30,6 +30,12 @@ export const DECISION_ROUTER_MODELS = Object.freeze({
30
30
  'typesafe-jev': Object.freeze(['jev-1.14.0']),
31
31
  'opencode-console-jev': Object.freeze(['jev-1.13']),
32
32
  'opencode-console-jev-free': Object.freeze(['jev-1.13-free']),
33
+ // Host-embedded decision modules confirmed in the 2.2.5 binary; the model
34
+ // ids are the provider-side decision models (see
35
+ // docs/reference/native-decisions.md for credential acquisition).
36
+ 'openrouter-jev': Object.freeze(['typesafe/jev-1.13']),
37
+ 'vercel-gateway-jev': Object.freeze(['typesafe-ai/jev']),
38
+ 'cloudflare-workers-jev': Object.freeze(['clef']),
33
39
  })
34
40
 
35
41
  /** Single mapping from a user-level provider ID to the local budget provider. */
@@ -38,6 +44,9 @@ export const DECISION_PROVIDER_BUDGET_MAPPING = Object.freeze({
38
44
  'typesafe-jev': 'typesafe-jev',
39
45
  'opencode-console-jev': 'opencode-console',
40
46
  'opencode-console-jev-free': 'jev-free',
47
+ 'openrouter-jev': 'openrouter',
48
+ 'vercel-gateway-jev': 'vercel-ai-gateway',
49
+ 'cloudflare-workers-jev': 'cloudflare-workers-ai',
41
50
  })
42
51
 
43
52
  /** Providers whose usage and price are documented well enough to reconcile. */
@@ -591,9 +600,22 @@ export function provisionTypesafeHostProvider({ env = process.env } = {}) {
591
600
  }
592
601
  data.providers ??= {}
593
602
  data.providers['typesafe-ai'] ??= {}
594
- data.providers['typesafe-ai'].models ??= {}
595
- if (data.providers['typesafe-ai'].models['jev-1.14.0'] === undefined) {
596
- data.providers['typesafe-ai'].models['jev-1.14.0'] = {
603
+ // A complete custom provider entry: without the npm adapter and the
604
+ // transport options (baseURL + apiKey) the host cannot resolve the
605
+ // provider at all (field evidence: a models-only entry 404s on the
606
+ // decisions API; models.dev does not carry typesafe-ai, so /connect and
607
+ // `opencode auth login` cannot supply it either). The credential rides
608
+ // the `{env:...}` reference — the key itself stays out of the config
609
+ // file; an entry the user already completed is preserved as-is.
610
+ const entry = data.providers['typesafe-ai']
611
+ entry.npm ??= '@ai-sdk/openai-compatible'
612
+ entry.name ??= 'TypeSafe AI'
613
+ entry.options ??= {}
614
+ entry.options.baseURL ??= 'https://api.typesafe.ai/v1'
615
+ entry.options.apiKey ??= '{env:TYPESAFE_API_KEY}'
616
+ entry.models ??= {}
617
+ if (entry.models['jev-1.14.0'] === undefined) {
618
+ entry.models['jev-1.14.0'] = {
597
619
  name: 'Jev (TypeSafe direct)',
598
620
  modelID: 'jev-latest',
599
621
  type: 'decision',
@@ -618,9 +640,30 @@ export function inspectTypesafeHostProvider({ env = process.env } = {}) {
618
640
  const configPath = resolveHostOpenCodeConfigPath(env)
619
641
  try {
620
642
  const parsed = JSON.parse(readFileSync(configPath, 'utf8'))
621
- const model = parsed?.providers?.['typesafe-ai']?.models?.['jev-1.14.0']
622
- return { present: model !== undefined && model !== null, path: configPath }
643
+ const entry = parsed?.providers?.['typesafe-ai']
644
+ const model = entry?.models?.['jev-1.14.0']
645
+ const present = model !== undefined && model !== null
646
+ const apiKey = entry?.options?.apiKey
647
+ // Credential states: inline key, `{env:...}` reference, or missing. The
648
+ // referenced env var is resolved by the HOST at call time — the doctor
649
+ // cannot see the host's environment, so a reference counts as present
650
+ // with a note instead of a verdict.
651
+ const hasCredential = typeof apiKey === 'string' && apiKey.length > 0
652
+ const viaEnvRef = hasCredential && apiKey.startsWith('{env:')
653
+ return {
654
+ present,
655
+ hasCredential,
656
+ viaEnvRef,
657
+ apiKeyRef: hasCredential ? apiKey : null,
658
+ path: configPath,
659
+ }
623
660
  } catch {
624
- return { present: false, path: configPath }
661
+ return {
662
+ present: false,
663
+ hasCredential: false,
664
+ viaEnvRef: false,
665
+ apiKeyRef: null,
666
+ path: configPath,
667
+ }
625
668
  }
626
669
  }
@@ -34,7 +34,7 @@ const patterns = [
34
34
  {
35
35
  label: 'literal API key value',
36
36
  regex: new RegExp(
37
- `["']${escapeRegExp(apiKeyName)}["']\\s*[:=]\\s*["'](?!\\$\\{|process\\.env|os\\.getenv|env:)[^"']{12,}["']`,
37
+ `["']${escapeRegExp(apiKeyName)}["']\\s*[:=]\\s*["'](?!\\$\\{|process\\.env|os\\.getenv|env:|\\{env:)[^"']{12,}["']`,
38
38
  'i',
39
39
  ),
40
40
  },
@@ -67,6 +67,12 @@ export interface V2JevDecisionRuntime {
67
67
  readonly listModels: () => Promise<unknown>
68
68
  /** The host's native Decisions API (`ctx.experimental.generate.decisions`). */
69
69
  readonly decide: (request: NativeDecisionRequest) => Promise<unknown>
70
+ /**
71
+ * Allowlisted specialist callers for explicit-questions mode (parsed from
72
+ * `PANTHEON_JEV_SPECIALIST_CALLERS` by the plugin wiring). Empty/absent =
73
+ * Zeus only. Preset modes stay Zeus-only regardless.
74
+ */
75
+ readonly specialistCallers?: readonly string[]
70
76
  /**
71
77
  * Raw host skill registry (`ctx.skill.list()`); optional. Its entries extend
72
78
  * the skills preset so installed Agent Skills become decidable.
@@ -88,8 +94,28 @@ export function nativeJevPermissionResource(providerID: string, id: string): str
88
94
  return `pantheon-native-decisions://${providerID}/${id}`
89
95
  }
90
96
 
97
+ export const SPECIALIST_CALLERS_FLAG_ENV = 'PANTHEON_JEV_SPECIALIST_CALLERS'
98
+
99
+ /**
100
+ * Parse the caller allowlist from the flag's CSV value. Unset/empty = Zeus
101
+ * only (the default). Preset modes (skills, delegation, review) stay
102
+ * Zeus-only regardless of the flag: owner/skill selection and result
103
+ * scoring are orchestration decisions; specialists may ask bounded typed
104
+ * questions mid-task, nothing else. Lives in the plugin wiring (which owns
105
+ * flag reads); this module receives the parsed list via the runtime.
106
+ */
107
+ export function specialistCallerAllowlist(flagValue: string | undefined): readonly string[] {
108
+ const raw = String(flagValue ?? '').trim()
109
+ if (!raw) return []
110
+ const parsed = raw
111
+ .split(',')
112
+ .map((name) => name.trim())
113
+ .filter((name) => /^[a-z][a-z0-9-]{0,31}$/.test(name))
114
+ return [...new Set(parsed)]
115
+ }
116
+
91
117
  export type JevDecisionRunFailure =
92
- | 'CALLER_NOT_ZEUS'
118
+ | 'CALLER_NOT_ALLOWED'
93
119
  | 'REVIEW_INPUT_INVALID'
94
120
  | 'CRITERIA_INVALID'
95
121
  | 'CONTEXT_UNAVAILABLE'
@@ -133,7 +159,7 @@ function reviewRefusalSkipReason(reasonCode: JevDecisionRunFailure): string {
133
159
  /**
134
160
  * Every gate-chain failure the shared runner can produce. It is
135
161
  * {@link JevDecisionRunFailure} minus the tool-surface properties:
136
- * `CALLER_NOT_ZEUS` (the caller check) and the review mode's input
162
+ * `CALLER_NOT_ALLOWED` (the caller check) and the review mode's input
137
163
  * validation (`REVIEW_INPUT_INVALID` / `CRITERIA_INVALID`) — all three are
138
164
  * properties of the explicit tool surface, whose input the caller supplies
139
165
  * directly, not of the gate chain; the J1/J3 shadow observers run the same
@@ -141,13 +167,19 @@ function reviewRefusalSkipReason(reasonCode: JevDecisionRunFailure): string {
141
167
  */
142
168
  export type GatedNativeJevFailure = Exclude<
143
169
  JevDecisionRunFailure,
144
- 'CALLER_NOT_ZEUS' | 'REVIEW_INPUT_INVALID' | 'CRITERIA_INVALID'
170
+ 'CALLER_NOT_ALLOWED' | 'REVIEW_INPUT_INVALID' | 'CRITERIA_INVALID'
145
171
  >
146
172
 
147
173
  /** The minimal runtime slice the gate chain needs. */
148
174
  export type GatedNativeJevRuntime = Pick<V2JevDecisionRuntime, 'decide'> & {
149
175
  /** Host permission kill-switch (`ctx.permission.assert`), when present. */
150
176
  readonly permissionAssert?: (input: Record<string, unknown>) => Promise<unknown>
177
+ /**
178
+ * Allowlisted specialist callers for explicit-questions mode (parsed from
179
+ * `PANTHEON_JEV_SPECIALIST_CALLERS` by the plugin wiring). Empty/absent =
180
+ * Zeus only. Preset modes stay Zeus-only regardless.
181
+ */
182
+ readonly specialistCallers?: readonly string[]
151
183
  }
152
184
 
153
185
  /** One completed, settled native Jev call: gates passed, usage reconciled. */
@@ -169,6 +201,12 @@ export type GatedNativeJevCallResult =
169
201
  readonly reasonCode: GatedNativeJevFailure
170
202
  /** Sanitized error CLASS only (`TypeError`, …); set for call failures. */
171
203
  readonly detail?: string
204
+ /** Host's provider-layer reason class (`rate_limit`, …); no message text. */
205
+ readonly providerReason?: string
206
+ /** Integer HTTP status from the provider layer, when the host sets one. */
207
+ readonly status?: number
208
+ /** Positive retry window in ms, when the host sets one (rate limits). */
209
+ readonly retryAfterMs?: number
172
210
  }
173
211
 
174
212
  /**
@@ -256,11 +294,37 @@ export async function runGatedNativeJevCall(params: {
256
294
  try {
257
295
  response = await params.runtime.decide(prepared.request)
258
296
  } catch (err) {
259
- return {
297
+ // Provider-layer errors carry bounded, non-content facts that change
298
+ // what the user does next: the host's reason class (`rate_limit` vs
299
+ // auth vs unknown) and, for rate limits, the retry window. The error
300
+ // message text NEVER crosses (it carries URLs and subscription prose).
301
+ const failure: {
302
+ ok: false
303
+ reasonCode: 'DECISION_CALL_FAILED'
304
+ detail: string
305
+ providerReason?: string
306
+ status?: number
307
+ retryAfterMs?: number
308
+ } = {
260
309
  ok: false,
261
310
  reasonCode: 'DECISION_CALL_FAILED',
262
311
  detail: err instanceof Error ? err.name : 'UnknownFailure',
263
312
  }
313
+ const errRecord = err as { reason?: unknown; status?: unknown; retryAfterMs?: unknown }
314
+ if (typeof errRecord.reason === 'string' && /^[a-z_]{1,32}$/i.test(errRecord.reason)) {
315
+ failure.providerReason = errRecord.reason
316
+ }
317
+ if (typeof errRecord.status === 'number' && Number.isInteger(errRecord.status)) {
318
+ failure.status = errRecord.status
319
+ }
320
+ if (
321
+ typeof errRecord.retryAfterMs === 'number' &&
322
+ Number.isFinite(errRecord.retryAfterMs) &&
323
+ errRecord.retryAfterMs > 0
324
+ ) {
325
+ failure.retryAfterMs = Math.round(errRecord.retryAfterMs)
326
+ }
327
+ return failure
264
328
  }
265
329
 
266
330
  const evidence = verifyNativeUsageForReservation(
@@ -344,9 +408,21 @@ export async function runJevDecision(
344
408
  toolContext !== null && typeof toolContext === 'object' && !Array.isArray(toolContext)
345
409
  ? (toolContext as JevToolContext)
346
410
  : undefined
347
- if (context?.agent !== 'zeus') return refusal('CALLER_NOT_ZEUS')
411
+ const caller = context?.agent
412
+ if (typeof caller !== 'string' || caller.length === 0) return refusal('CALLER_NOT_ALLOWED')
413
+ const allowlist = runtime.specialistCallers ?? []
414
+ if (caller !== 'zeus' && !allowlist.includes(caller)) {
415
+ return refusal('CALLER_NOT_ALLOWED')
416
+ }
348
417
 
349
418
  const requested = (input ?? {}) as { mode?: unknown; questions?: unknown }
419
+ // Preset modes stay orchestrator-owned even when the flag widens the
420
+ // caller matrix: owner/skill selection and result scoring are
421
+ // orchestration decisions; allowlisted specialists may ask bounded typed
422
+ // questions only.
423
+ if (caller !== 'zeus' && requested.mode !== undefined) {
424
+ return refusal('CALLER_NOT_ALLOWED')
425
+ }
350
426
  // Review mode (J4): the bounded request is built before any gate work, and
351
427
  // an invalid review input is a tool-surface refusal — same class as the
352
428
  // caller check, never a gate failure.
@@ -370,7 +446,7 @@ export async function runJevDecision(
370
446
  const result = await runGatedNativeJevCall({
371
447
  sessionID: context?.sessionID,
372
448
  messageID: context?.messageID,
373
- agent: 'zeus',
449
+ agent: caller,
374
450
  runtime,
375
451
  prepare: async (route) =>
376
452
  reviewRequest !== undefined
@@ -407,15 +483,21 @@ export async function runJevDecision(
407
483
  runtime.shadowSink,
408
484
  )
409
485
  }
410
- if (result.detail === undefined) return refusal(result.reasonCode)
411
- // Refusal with the error CLASS only (`TypeError`, `RangeError`, …): the
486
+ if (result.detail === undefined && result.providerReason === undefined) {
487
+ return refusal(result.reasonCode)
488
+ }
489
+ // Refusal with the error CLASS only (`TypeError`, `RangeError`, …) plus
490
+ // the bounded provider facts (`rate_limit`, status, retry window): the
412
491
  // message can carry paths, config or provider detail and never crosses
413
492
  // into the chat.
414
493
  return JSON.stringify({
415
494
  advisory: false,
416
495
  effect: 'none',
417
496
  reasonCode: result.reasonCode,
418
- detail: result.detail,
497
+ ...(result.detail === undefined ? {} : { detail: result.detail }),
498
+ ...(result.providerReason === undefined ? {} : { providerReason: result.providerReason }),
499
+ ...(result.status === undefined ? {} : { status: result.status }),
500
+ ...(result.retryAfterMs === undefined ? {} : { retryAfterMs: result.retryAfterMs }),
419
501
  })
420
502
  }
421
503
 
@@ -443,6 +525,7 @@ export async function runJevDecision(
443
525
  advisory: true,
444
526
  effect: 'none',
445
527
  reason: 'JEV_DECISION',
528
+ caller,
446
529
  route: {
447
530
  providerID: result.call.selection.route.model.providerID,
448
531
  id: result.call.selection.route.model.id,
@@ -462,6 +545,7 @@ export async function runJevDecision(
462
545
  advisory: true,
463
546
  effect: 'none',
464
547
  reason: 'JEV_DECISION',
548
+ caller,
465
549
  route: {
466
550
  providerID: result.call.selection.route.model.providerID,
467
551
  id: result.call.selection.route.model.id,
@@ -477,13 +561,15 @@ export async function runJevDecision(
477
561
 
478
562
  const TOOL_DESCRIPTION =
479
563
  'Zeus-only advisory typed decisions via the host native Jev route (OpenCode Console or a ' +
480
- 'configured decision model). Ways to ask: pass `mode: "skills"` to stack skills for the ' +
564
+ 'configured decision model). Required: schemaVersion: 1 and a non-empty state (<=12000 chars). ' +
565
+ 'Ways to ask: pass `mode: "skills"` to stack skills for the ' +
481
566
  'state text (local prefilter shortlist, catalog fallback, plus every skill installed in the ' +
482
567
  'host), `mode: "delegation"` to pick ' +
483
568
  'a specialist, `mode: "review"` to score a finished delegated result against named criteria ' +
484
569
  '(advisory quality score + needs-review flag; the result content itself is never sent — ' +
485
570
  'shape metrics and criteria only), or pass explicit typed `questions` (choice, score, ' +
486
- 'predicate). Returns probabilistic answers with confidence. Requires decision-router egress ' +
571
+ 'predicate). Invalid-input refusals carry a `detail` token naming the exact cause. Returns ' +
572
+ 'probabilistic answers with confidence. Requires decision-router egress ' +
487
573
  'consent and budget caps; asks host permission first. It never dispatches agents, runs ' +
488
574
  'skills, executes tools, blocks, retries, or alters permissions — results are advisory only.'
489
575
 
@@ -34,7 +34,12 @@ import {
34
34
  /** Config-level providers that have a native host Decisions route. */
35
35
  export type NativeJevProviderId = Extract<
36
36
  DecisionProviderId,
37
- 'typesafe-jev' | 'opencode-console-jev' | 'opencode-console-jev-free'
37
+ | 'typesafe-jev'
38
+ | 'opencode-console-jev'
39
+ | 'opencode-console-jev-free'
40
+ | 'openrouter-jev'
41
+ | 'vercel-gateway-jev'
42
+ | 'cloudflare-workers-jev'
38
43
  >
39
44
 
40
45
  /**
@@ -47,6 +52,16 @@ export const NATIVE_JEV_HOST_PROVIDERS = Object.freeze({
47
52
  'typesafe-jev': 'typesafe-ai',
48
53
  'opencode-console-jev': 'opencode',
49
54
  'opencode-console-jev-free': 'opencode',
55
+ // Host-embedded decision modules confirmed in the 2.2.5 binary
56
+ // (providers/<id>/decisions, System One transport — the host normalizes
57
+ // the request/response, so consumers only need the providerID mapping):
58
+ // openrouter (models.dev provider; credential OPENROUTER_API_KEY),
59
+ // vercel-ai-gateway (models.dev provider; AI_GATEWAY_API_KEY),
60
+ // cloudflare-workers-ai (custom entry with accountId; CLOUDFLARE_API_TOKEN),
61
+ // baseten and digitalocean (modules present, decision models undocumented).
62
+ 'openrouter-jev': 'openrouter',
63
+ 'vercel-gateway-jev': 'vercel-ai-gateway',
64
+ 'cloudflare-workers-jev': 'cloudflare-workers-ai',
50
65
  } satisfies Record<NativeJevProviderId, string>)
51
66
 
52
67
  export function isNativeJevProvider(provider: unknown): provider is NativeJevProviderId {
@@ -191,9 +206,31 @@ export type JevDecisionQuestionInput = {
191
206
 
192
207
  export type JevDecisionPreparationFailure = 'STATE_INVALID' | 'QUESTIONS_INVALID' | 'PRESET_INVALID'
193
208
 
209
+ /**
210
+ * Per-cause tokens for the validation bucket. An LLM caller cannot converge
211
+ * on a bare `QUESTIONS_INVALID` (field evidence: nine distinct causes, five
212
+ * blind retries); the tool attaches the specific token as `detail` so the
213
+ * next attempt can be exact.
214
+ */
215
+ export type JevDecisionPreparationDetail =
216
+ | 'QUESTIONS_NOT_A_LIST'
217
+ | 'QUESTION_COUNT_INVALID'
218
+ | 'QUESTION_NOT_AN_OBJECT'
219
+ | 'QUESTION_NAME_INVALID'
220
+ | 'QUESTION_NAME_BAD_PATTERN_OR_DUPLICATE'
221
+ | 'QUESTION_INSTRUCTIONS_INVALID'
222
+ | 'CHOICE_INVALID'
223
+ | 'SCORE_INVALID'
224
+ | 'PREDICATE_HAS_CHOICES_OR_LEVELS'
225
+ | 'QUESTION_TYPE_INVALID'
226
+
194
227
  export type JevDecisionPreparation =
195
228
  | { readonly ok: true; readonly request: NativeDecisionRequest }
196
- | { readonly ok: false; readonly reasonCode: JevDecisionPreparationFailure }
229
+ | {
230
+ readonly ok: false
231
+ readonly reasonCode: JevDecisionPreparationFailure
232
+ readonly detail?: JevDecisionPreparationDetail
233
+ }
197
234
 
198
235
  function isBoundedNonBlankString(value: unknown, max: number): value is string {
199
236
  return typeof value === 'string' && value.trim().length > 0 && value.length <= max
@@ -283,40 +320,52 @@ export function prepareJevDecisionRequest(
283
320
  return { ok: false, reasonCode: 'STATE_INVALID' }
284
321
  }
285
322
  const rawQuestions = input.questions
286
- if (!Array.isArray(rawQuestions)) return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
323
+ if (!Array.isArray(rawQuestions)) {
324
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTIONS_NOT_A_LIST' }
325
+ }
287
326
  if (rawQuestions.length < 1 || rawQuestions.length > JEV_DECISION_MAX_QUESTIONS) {
288
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
327
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_COUNT_INVALID' }
289
328
  }
290
329
 
291
330
  const names = new Set<string>()
292
331
  const questions: NativeDecisionRequest['questions'][number][] = []
293
332
  for (const raw of rawQuestions) {
294
333
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
295
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
334
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_NOT_AN_OBJECT' }
296
335
  }
297
336
  const question = raw as JevDecisionQuestionInput
298
337
  if (!isBoundedNonBlankString(question.name, JEV_DECISION_MAX_NAME_LENGTH)) {
299
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
338
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_NAME_INVALID' }
300
339
  }
301
340
  if (!QUESTION_NAME_PATTERN.test(question.name) || names.has(question.name)) {
302
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
341
+ return {
342
+ ok: false,
343
+ reasonCode: 'QUESTIONS_INVALID',
344
+ detail: 'QUESTION_NAME_BAD_PATTERN_OR_DUPLICATE',
345
+ }
303
346
  }
304
347
  if (!isBoundedNonBlankString(question.instructions, JEV_DECISION_MAX_INSTRUCTIONS_LENGTH)) {
305
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
348
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_INSTRUCTIONS_INVALID' }
306
349
  }
307
350
  names.add(question.name)
308
351
 
309
352
  if (question.type === 'choice') {
310
353
  const built = readChoiceQuestion(question)
311
- if (built === null) return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
354
+ if (built === null)
355
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'CHOICE_INVALID' }
312
356
  questions.push(built)
313
357
  } else if (question.type === 'score') {
314
358
  const built = readScoreQuestion(question)
315
- if (built === null) return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
359
+ if (built === null)
360
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'SCORE_INVALID' }
316
361
  questions.push(built)
317
362
  } else if (question.type === 'predicate') {
318
363
  if (question.choices !== undefined || question.levels !== undefined) {
319
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
364
+ return {
365
+ ok: false,
366
+ reasonCode: 'QUESTIONS_INVALID',
367
+ detail: 'PREDICATE_HAS_CHOICES_OR_LEVELS',
368
+ }
320
369
  }
321
370
  questions.push({
322
371
  type: 'predicate',
@@ -324,7 +373,7 @@ export function prepareJevDecisionRequest(
324
373
  instructions: question.instructions,
325
374
  })
326
375
  } else {
327
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
376
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_TYPE_INVALID' }
328
377
  }
329
378
  }
330
379
 
@@ -9,7 +9,14 @@ import {
9
9
  type VerifiedUsageEvidence,
10
10
  } from './local-decision-usage-evidence.internal.ts'
11
11
 
12
- export type BudgetProvider = 'openai-decisions' | 'typesafe-jev' | 'opencode-console' | 'jev-free'
12
+ export type BudgetProvider =
13
+ | 'openai-decisions'
14
+ | 'typesafe-jev'
15
+ | 'opencode-console'
16
+ | 'jev-free'
17
+ | 'openrouter'
18
+ | 'vercel-ai-gateway'
19
+ | 'cloudflare-workers-ai'
13
20
 
14
21
  /** Model and OpenCode Console variant keys must be configured before admission. */
15
22
  export type BudgetModel = string
@@ -127,6 +134,9 @@ export const LOCAL_DECISION_BUDGET_PROVIDERS: readonly BudgetProvider[] = Object
127
134
  'typesafe-jev',
128
135
  'opencode-console',
129
136
  'jev-free',
137
+ 'openrouter',
138
+ 'vercel-ai-gateway',
139
+ 'cloudflare-workers-ai',
130
140
  ])
131
141
  const ALLOWED_PROVIDERS = new Set<BudgetProvider>(LOCAL_DECISION_BUDGET_PROVIDERS)
132
142
  const MODEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/
@@ -17,6 +17,9 @@ export type DecisionProviderId =
17
17
  | 'typesafe-jev'
18
18
  | 'opencode-console-jev'
19
19
  | 'opencode-console-jev-free'
20
+ | 'openrouter-jev'
21
+ | 'vercel-gateway-jev'
22
+ | 'cloudflare-workers-jev'
20
23
 
21
24
  /**
22
25
  * Single provider matrix. Model and accounting IDs come from the canonical
package/src/plugin-v2.ts CHANGED
@@ -116,6 +116,7 @@ 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 type { V2JevDecisionRuntime } from './pantheon/jev-decision-tool.ts'
119
+ import { specialistCallerAllowlist } from './pantheon/jev-decision-tool.ts'
119
120
  import {
120
121
  createJ3EscalationObserver,
121
122
  isSubagentDispatchEvent,
@@ -679,6 +680,7 @@ function transformReferences(draft: ReferenceDraft): void {
679
680
  * catalog, but the tool registration contract still feature-detects both).
680
681
  */
681
682
  function buildV2JevRuntime(host: ReturnType<typeof hostDomains>): V2JevDecisionRuntime | undefined {
683
+ const specialistCallers = specialistCallerAllowlist(process.env.PANTHEON_JEV_SPECIALIST_CALLERS)
682
684
  const decisionsFn = host.experimental?.generate?.decisions
683
685
  const modelListFn = host.model?.list
684
686
  if (typeof decisionsFn !== 'function' || typeof modelListFn !== 'function') return undefined
@@ -704,6 +706,7 @@ function buildV2JevRuntime(host: ReturnType<typeof hostDomains>): V2JevDecisionR
704
706
  const j4Sink = createTelemetrySink()
705
707
  j4TelemetrySink = j4Sink
706
708
  return {
709
+ specialistCallers,
707
710
  // Every host method is invoked with its owning domain as receiver: the
708
711
  // canary records `ctx.model.list()` (bound) succeeding on 2.2.5 while a
709
712
  // detached reference threw in the field and surfaced only as
@@ -3197,7 +3197,7 @@ function Sidebar(props) {
3197
3197
  setProp(_el$12, "width", "100%");
3198
3198
  setProp(_el$12, "padding", 1);
3199
3199
  setProp(_el$13, "attributes", 1);
3200
- insert(_el$13, `Pantheon v1.6.2`);
3200
+ insert(_el$13, `Pantheon v1.6.3-beta.1`);
3201
3201
  insert(_el$14, () => presetHeaderLine(model.preset().name ?? "", model.provider()));
3202
3202
  insert(_el$12, createComponent(Show, {
3203
3203
  get when() {
@@ -3918,7 +3918,7 @@ function HomeStatus(props) {
3918
3918
  const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base;
3919
3919
  return (() => {
3920
3920
  var _el$72 = createElement("text");
3921
- insert(_el$72, () => `Pantheon v1.6.2${preset().name ? ` ▸ ${preset().name}` : ""}`);
3921
+ insert(_el$72, () => `Pantheon v1.6.3-beta.1${preset().name ? ` ▸ ${preset().name}` : ""}`);
3922
3922
  effect((_$p) => setProp(_el$72, "fg", muted(), _$p));
3923
3923
  return _el$72;
3924
3924
  })();
@@ -167,7 +167,7 @@ async function detectVersion(api) {
167
167
  if (ver) return ver;
168
168
  }
169
169
  } catch {}
170
- return "1.6.2";
170
+ return "1.6.3-beta.1";
171
171
  }
172
172
  /**
173
173
  * usage-bar — AI subscription usage gauge for the opencode TUI.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
- "version": "1.6.2",
3
+ "version": "1.6.3-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pantheon-tui",
9
- "version": "1.6.2",
9
+ "version": "1.6.3-beta.1",
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.2",
4
+ "version": "1.6.3-beta.1",
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": {