pantheon-opencode 1.6.2-beta.9 → 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.
Files changed (73) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +34 -60
  3. package/README.pt-BR.md +10 -12
  4. package/bin/pantheon-init.mjs +23 -33
  5. package/package.json +3 -3
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/decision-router-budget.mjs +4 -1
  9. package/scripts/decision-router-v2-egress.mjs +11 -2
  10. package/scripts/decision-router.mjs +64 -56
  11. package/scripts/install/decision-router-config.mjs +110 -1
  12. package/scripts/install/npx-cache-sweep.mjs +103 -0
  13. package/scripts/install/opencode.mjs +7 -7
  14. package/scripts/install/plugin.mjs +4 -3
  15. package/scripts/install/strings.mjs +4 -0
  16. package/scripts/release-gates.mjs +6 -82
  17. package/scripts/secret-scan.mjs +1 -1
  18. package/scripts/sync-tui.mjs +3 -3
  19. package/src/agents/zeus.md +4 -2
  20. package/src/pantheon/jev-decision-tool.ts +455 -117
  21. package/src/pantheon/jev-decisions.ts +72 -25
  22. package/src/pantheon/jev-escalation.ts +639 -0
  23. package/src/pantheon/jev-quality-score.ts +432 -0
  24. package/src/pantheon/jev-risk-gate.ts +479 -0
  25. package/src/pantheon/local-decision-budget.ts +11 -1
  26. package/src/pantheon/local-decision-prompt.ts +12 -18
  27. package/src/pantheon/local-decision-provider-matrix.ts +3 -0
  28. package/src/pantheon/v2-decision-telemetry.ts +14 -4
  29. package/src/pantheon/v2-native-decisions.ts +1 -1
  30. package/src/plugin-v2.ts +204 -24
  31. package/src/plugins/tui/dist/server-v2.d.ts +19 -11
  32. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  33. package/src/plugins/tui/dist/server-v2.js +19 -789
  34. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  35. package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
  36. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  37. package/src/plugins/tui/dist/tui-v2.js +257 -5370
  38. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  39. package/src/plugins/tui/dist/tui.js +1 -1
  40. package/src/plugins/tui/package-lock.json +2 -2
  41. package/src/plugins/tui/package.json +1 -1
  42. package/src/plugins/tui/src/index-v2.tsx +213 -86
  43. package/src/plugins/tui/src/server-v2.ts +18 -982
  44. package/src/plugins/tui/tsconfig.typecheck.json +1 -6
  45. package/src/plugins/tui/tsdown.config.ts +1 -11
  46. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
  47. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
  48. package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
  49. package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
  50. package/src/plugins/tui/dist/quota-adapters.js +0 -1142
  51. package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
  52. package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
  53. package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
  54. package/src/plugins/tui/dist/quota-cli.js +0 -184
  55. package/src/plugins/tui/dist/quota-cli.js.map +0 -1
  56. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +0 -684
  57. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
  58. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
  59. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
  60. package/src/plugins/tui/dist/usage-history-worker.js +0 -25
  61. package/src/plugins/tui/dist/usage-history-worker.js.map +0 -1
  62. package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
  63. package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
  64. package/src/plugins/tui/src/quota-adapters.ts +0 -1598
  65. package/src/plugins/tui/src/quota-cli.ts +0 -237
  66. package/src/plugins/tui/src/quota-rpc.ts +0 -373
  67. package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
  68. package/src/plugins/tui/src/quota-v2.tsx +0 -1238
  69. package/src/plugins/tui/src/usage-history-contract.ts +0 -217
  70. package/src/plugins/tui/src/usage-history-validation.ts +0 -104
  71. package/src/plugins/tui/src/usage-history-view.tsx +0 -236
  72. package/src/plugins/tui/src/usage-history-worker.ts +0 -25
  73. package/src/plugins/tui/src/usage-view-model.ts +0 -272
@@ -25,19 +25,21 @@ import {
25
25
  import { selectPantheonSkills } from './local-decision-skills.ts'
26
26
  import { PANTHEON_AGENT_CATALOG, PANTHEON_SKILL_CATALOG } from './pantheon-decision-catalog.ts'
27
27
  import {
28
+ findRouteKind,
28
29
  NATIVE_DECISION_MAX_PROMPT_LENGTH,
29
30
  type NativeDecisionRequest,
30
31
  type ResolvedNativeDecisionRoute,
31
- resolveNativeDecisionRoute,
32
32
  } from './v2-native-decisions.ts'
33
33
 
34
- /** Catalog entry shape the route resolver needs from the host model list. */
35
- export type JevDecisionCatalogEntry = Parameters<typeof resolveNativeDecisionRoute>[2][number]
36
-
37
34
  /** Config-level providers that have a native host Decisions route. */
38
35
  export type NativeJevProviderId = Extract<
39
36
  DecisionProviderId,
40
- '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'
41
43
  >
42
44
 
43
45
  /**
@@ -50,13 +52,23 @@ export const NATIVE_JEV_HOST_PROVIDERS = Object.freeze({
50
52
  'typesafe-jev': 'typesafe-ai',
51
53
  'opencode-console-jev': 'opencode',
52
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',
53
65
  } satisfies Record<NativeJevProviderId, string>)
54
66
 
55
67
  export function isNativeJevProvider(provider: unknown): provider is NativeJevProviderId {
56
68
  return typeof provider === 'string' && Object.hasOwn(NATIVE_JEV_HOST_PROVIDERS, provider)
57
69
  }
58
70
 
59
- export type NativeJevRouteFailure = 'NO_ELIGIBLE_CANDIDATE' | 'ROUTE_UNRESOLVED'
71
+ export type NativeJevRouteFailure = 'NO_ELIGIBLE_CANDIDATE'
60
72
 
61
73
  export interface NativeJevRouteSelection {
62
74
  readonly route: ResolvedNativeDecisionRoute
@@ -114,7 +126,6 @@ function readEnabledCandidates(config: unknown): UserDecisionRouterCandidate[] {
114
126
  */
115
127
  export function resolveNativeJevRoute(
116
128
  config: unknown,
117
- catalog: readonly JevDecisionCatalogEntry[],
118
129
  checkAdmission: (provider: BudgetProvider, model: string) => boolean,
119
130
  ): NativeJevRouteResolution {
120
131
  const record =
@@ -153,16 +164,18 @@ export function resolveNativeJevRoute(
153
164
  }
154
165
 
155
166
  const hostProvider = NATIVE_JEV_HOST_PROVIDERS[selected.provider]
156
- const resolution = resolveNativeDecisionRoute(
157
- { providerID: hostProvider, id: selected.model },
158
- undefined,
159
- catalog,
160
- )
161
- if (!resolution.ok) return { ok: false, reasonCode: 'ROUTE_UNRESOLVED' }
167
+ // NO catalog-presence gate. Field evidence (2.2.5, 2026-11-03): decision
168
+ // models are not chat models — `model.list()` never exposes them (561
169
+ // entries, 0 jev) while the decisions API answers the exact same ref
170
+ // directly (jev-1.13-free → 200; jev-1.13 → 404 from the host itself).
171
+ // The host is the authority on model existence: an unknown model surfaces
172
+ // later as DECISION_CALL_FAILED. Consent, budget caps and the host
173
+ // permission assertion remain the actual safety gates.
174
+ const routeModel = { providerID: hostProvider, id: selected.model }
162
175
  return {
163
176
  ok: true,
164
177
  selection: {
165
- route: resolution.route,
178
+ route: Object.freeze({ model: routeModel, ...findRouteKind(routeModel) }),
166
179
  provider: selected.provider,
167
180
  accountingProvider: DECISION_PROVIDER_ADAPTERS[selected.provider].accountingProvider,
168
181
  model: selected.model,
@@ -193,9 +206,31 @@ export type JevDecisionQuestionInput = {
193
206
 
194
207
  export type JevDecisionPreparationFailure = 'STATE_INVALID' | 'QUESTIONS_INVALID' | 'PRESET_INVALID'
195
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
+
196
227
  export type JevDecisionPreparation =
197
228
  | { readonly ok: true; readonly request: NativeDecisionRequest }
198
- | { readonly ok: false; readonly reasonCode: JevDecisionPreparationFailure }
229
+ | {
230
+ readonly ok: false
231
+ readonly reasonCode: JevDecisionPreparationFailure
232
+ readonly detail?: JevDecisionPreparationDetail
233
+ }
199
234
 
200
235
  function isBoundedNonBlankString(value: unknown, max: number): value is string {
201
236
  return typeof value === 'string' && value.trim().length > 0 && value.length <= max
@@ -285,40 +320,52 @@ export function prepareJevDecisionRequest(
285
320
  return { ok: false, reasonCode: 'STATE_INVALID' }
286
321
  }
287
322
  const rawQuestions = input.questions
288
- 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
+ }
289
326
  if (rawQuestions.length < 1 || rawQuestions.length > JEV_DECISION_MAX_QUESTIONS) {
290
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
327
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_COUNT_INVALID' }
291
328
  }
292
329
 
293
330
  const names = new Set<string>()
294
331
  const questions: NativeDecisionRequest['questions'][number][] = []
295
332
  for (const raw of rawQuestions) {
296
333
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
297
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
334
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_NOT_AN_OBJECT' }
298
335
  }
299
336
  const question = raw as JevDecisionQuestionInput
300
337
  if (!isBoundedNonBlankString(question.name, JEV_DECISION_MAX_NAME_LENGTH)) {
301
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
338
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_NAME_INVALID' }
302
339
  }
303
340
  if (!QUESTION_NAME_PATTERN.test(question.name) || names.has(question.name)) {
304
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
341
+ return {
342
+ ok: false,
343
+ reasonCode: 'QUESTIONS_INVALID',
344
+ detail: 'QUESTION_NAME_BAD_PATTERN_OR_DUPLICATE',
345
+ }
305
346
  }
306
347
  if (!isBoundedNonBlankString(question.instructions, JEV_DECISION_MAX_INSTRUCTIONS_LENGTH)) {
307
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
348
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_INSTRUCTIONS_INVALID' }
308
349
  }
309
350
  names.add(question.name)
310
351
 
311
352
  if (question.type === 'choice') {
312
353
  const built = readChoiceQuestion(question)
313
- if (built === null) return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
354
+ if (built === null)
355
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'CHOICE_INVALID' }
314
356
  questions.push(built)
315
357
  } else if (question.type === 'score') {
316
358
  const built = readScoreQuestion(question)
317
- if (built === null) return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
359
+ if (built === null)
360
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'SCORE_INVALID' }
318
361
  questions.push(built)
319
362
  } else if (question.type === 'predicate') {
320
363
  if (question.choices !== undefined || question.levels !== undefined) {
321
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
364
+ return {
365
+ ok: false,
366
+ reasonCode: 'QUESTIONS_INVALID',
367
+ detail: 'PREDICATE_HAS_CHOICES_OR_LEVELS',
368
+ }
322
369
  }
323
370
  questions.push({
324
371
  type: 'predicate',
@@ -326,7 +373,7 @@ export function prepareJevDecisionRequest(
326
373
  instructions: question.instructions,
327
374
  })
328
375
  } else {
329
- return { ok: false, reasonCode: 'QUESTIONS_INVALID' }
376
+ return { ok: false, reasonCode: 'QUESTIONS_INVALID', detail: 'QUESTION_TYPE_INVALID' }
330
377
  }
331
378
  }
332
379