pantheon-opencode 1.6.2-beta.14 → 1.6.2-beta.16
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 +13 -0
- package/README.md +7 -1
- package/bin/pantheon-init.mjs +6 -32
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router.mjs +36 -51
- package/scripts/install/decision-router-config.mjs +67 -1
- package/src/pantheon/jev-decision-tool.ts +201 -95
- package/src/pantheon/jev-risk-gate.ts +479 -0
- package/src/pantheon/v2-decision-telemetry.ts +13 -4
- package/src/plugin-v2.ts +111 -30
- package/src/plugins/tui/dist/tui-v2.js +2 -2
- 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/plugin-v2.ts
CHANGED
|
@@ -116,6 +116,11 @@ 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 {
|
|
120
|
+
createJ1RiskGateObserver,
|
|
121
|
+
isRiskGateTarget,
|
|
122
|
+
j1RiskGateEnabledFromEnv,
|
|
123
|
+
} from './pantheon/jev-risk-gate.ts'
|
|
119
124
|
import { DECISION_EGRESS_ACTION } from './pantheon/local-decision-egress-gate.ts'
|
|
120
125
|
import { applyDecisionRouterToPrompt } from './pantheon/local-decision-prompt.ts'
|
|
121
126
|
import { getSharedBoard } from './pantheon/shared-board.ts'
|
|
@@ -660,6 +665,45 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
660
665
|
|
|
661
666
|
// ─── V2 Tool Registration ───────────────────────────────────────────────
|
|
662
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Construct the ONE Jev runtime the plugin threads everywhere: the explicit
|
|
670
|
+
* `pantheon_jev_decide` tool and the J1 risk-score shadow observer both call
|
|
671
|
+
* through this instance, so `decide` and `permissionAssert` are bound to their
|
|
672
|
+
* owning host domains exactly once. `undefined` when the host lacks either the
|
|
673
|
+
* native Decisions API or the model catalog (the route no longer consults the
|
|
674
|
+
* catalog, but the tool registration contract still feature-detects both).
|
|
675
|
+
*/
|
|
676
|
+
function buildV2JevRuntime(host: ReturnType<typeof hostDomains>): V2JevDecisionRuntime | undefined {
|
|
677
|
+
const decisionsFn = host.experimental?.generate?.decisions
|
|
678
|
+
const modelListFn = host.model?.list
|
|
679
|
+
if (typeof decisionsFn !== 'function' || typeof modelListFn !== 'function') return undefined
|
|
680
|
+
const decisionsOwner = host.experimental?.generate
|
|
681
|
+
const decide = decisionsFn
|
|
682
|
+
const listModels = modelListFn
|
|
683
|
+
// The 2.2.5 host exposes ctx.skill as the SkillEditor (list()); the SDK
|
|
684
|
+
// types this file sees declare skill as the registration hook, so the
|
|
685
|
+
// runtime shape is read through one narrow, feature-detected cast.
|
|
686
|
+
const skillDomain = (host as { skill?: { list?: () => unknown } }).skill
|
|
687
|
+
const skillList = skillDomain?.list
|
|
688
|
+
const permissionAssertFn = host.permission?.assert
|
|
689
|
+
const permissionAssert =
|
|
690
|
+
typeof permissionAssertFn === 'function'
|
|
691
|
+
? (input: Record<string, unknown>) => permissionAssertFn.call(host.permission, input)
|
|
692
|
+
: undefined
|
|
693
|
+
return {
|
|
694
|
+
// Every host method is invoked with its owning domain as receiver: the
|
|
695
|
+
// canary records `ctx.model.list()` (bound) succeeding on 2.2.5 while a
|
|
696
|
+
// detached reference threw in the field and surfaced only as
|
|
697
|
+
// CATALOG_UNAVAILABLE. Same discipline as permissionAssert above.
|
|
698
|
+
listModels: () => listModels.call(host.model),
|
|
699
|
+
decide: (request: NativeDecisionRequest) => decide.call(decisionsOwner, request),
|
|
700
|
+
// Sync-or-async host skill list; absent/throwing falls back to the
|
|
701
|
+
// catalog-only preset inside the tool.
|
|
702
|
+
listSkills: async () => skillList?.call(skillDomain),
|
|
703
|
+
...(permissionAssert === undefined ? {} : { permissionAssert }),
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
663
707
|
/**
|
|
664
708
|
* Attempt to register Pantheon tools via V2 ctx.tool.transform.
|
|
665
709
|
*
|
|
@@ -675,6 +719,7 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
675
719
|
async function registerV2Tools(
|
|
676
720
|
context: PluginContext,
|
|
677
721
|
boundedRead?: ReturnType<typeof createV2BoundedReadTool>['definition'],
|
|
722
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
678
723
|
): Promise<boolean> {
|
|
679
724
|
const host = hostDomains(context)
|
|
680
725
|
const toolCtx = host.tool
|
|
@@ -698,34 +743,10 @@ async function registerV2Tools(
|
|
|
698
743
|
const decisionsFn = host.experimental?.generate?.decisions
|
|
699
744
|
const jevReady = visionReady && typeof decisionsFn === 'function'
|
|
700
745
|
if (!jevReady) markUnsupported('jev-decision-tool')
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
const decide = decisionsFn
|
|
706
|
-
const listModels = modelListFn
|
|
707
|
-
// The 2.2.5 host exposes ctx.skill as the SkillEditor (list()); the SDK
|
|
708
|
-
// types this file sees declare skill as the registration hook, so the
|
|
709
|
-
// runtime shape is read through one narrow, feature-detected cast.
|
|
710
|
-
const skillDomain = (host as { skill?: { list?: () => unknown } }).skill
|
|
711
|
-
const skillList = skillDomain?.list
|
|
712
|
-
const permissionAssert =
|
|
713
|
-
typeof permissionAssertFn === 'function'
|
|
714
|
-
? (input: Record<string, unknown>) => permissionAssertFn.call(host.permission, input)
|
|
715
|
-
: undefined
|
|
716
|
-
jevRuntime = {
|
|
717
|
-
// Every host method is invoked with its owning domain as receiver:
|
|
718
|
-
// the canary records `ctx.model.list()` (bound) succeeding on 2.2.5
|
|
719
|
-
// while a detached reference threw in the field and surfaced only as
|
|
720
|
-
// CATALOG_UNAVAILABLE. Same discipline as permissionAssert above.
|
|
721
|
-
listModels: () => listModels.call(host.model),
|
|
722
|
-
decide: (request: NativeDecisionRequest) => decide.call(decisionsOwner, request),
|
|
723
|
-
// Sync-or-async host skill list; absent/throwing falls back to the
|
|
724
|
-
// catalog-only preset inside the tool.
|
|
725
|
-
listSkills: async () => skillList?.call(skillDomain),
|
|
726
|
-
...(permissionAssert === undefined ? {} : { permissionAssert }),
|
|
727
|
-
}
|
|
728
|
-
}
|
|
746
|
+
// The setup flow threads the ONE runtime instance it built (shared with
|
|
747
|
+
// the J1 observer in the execute.before hook); this local fallback keeps a
|
|
748
|
+
// direct registration call self-sufficient.
|
|
749
|
+
const runtime = jevRuntime ?? (jevReady ? buildV2JevRuntime(host) : undefined)
|
|
729
750
|
// P3 (complexity) declares `tool.invoke`; its construction site is the
|
|
730
751
|
// local selector's execute, fed by that tool's own input schema. The sink
|
|
731
752
|
// is the 0b record path (in-memory, bounded, I/O-free) and every record
|
|
@@ -739,7 +760,7 @@ async function registerV2Tools(
|
|
|
739
760
|
p3Sink.emit({ ...record, mode: 'shadow' })
|
|
740
761
|
},
|
|
741
762
|
},
|
|
742
|
-
|
|
763
|
+
runtime,
|
|
743
764
|
)
|
|
744
765
|
if (boundedRead !== undefined) toolDefs.push(boundedRead)
|
|
745
766
|
|
|
@@ -894,6 +915,25 @@ export function getP11TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
|
894
915
|
|
|
895
916
|
let p11TelemetrySink: TelemetrySink | undefined
|
|
896
917
|
|
|
918
|
+
/**
|
|
919
|
+
* The J1 risk-score telemetry sink created by the most recent tool-hook
|
|
920
|
+
* registration.
|
|
921
|
+
*
|
|
922
|
+
* J1 (the risk-score advisory gate, `jev-risk-gate.ts`) is NOT a registry
|
|
923
|
+
* point: it is a flag-gated shadow observer on write/execute tool calls. The
|
|
924
|
+
* sink exists only when `PANTHEON_J1_RISK_SCORE` is on AND the host runtime
|
|
925
|
+
* exposes the native Decisions API, so flag-off leaves it undefined — the
|
|
926
|
+
* zero-overhead contract. Records go through the in-memory, bounded 0b path
|
|
927
|
+
* (`createTelemetrySink`, no I/O) and carry `mode: 'shadow'`; the observer is
|
|
928
|
+
* fire-and-observe, so the tool call never waits on it. Exported only for
|
|
929
|
+
* tests/pantheon/plugin-v2-contract.test.ts.
|
|
930
|
+
*/
|
|
931
|
+
export function getJ1TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
932
|
+
return j1TelemetrySink
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
let j1TelemetrySink: TelemetrySink | undefined
|
|
936
|
+
|
|
897
937
|
/**
|
|
898
938
|
* Attempt to subscribe to session events via V2 ctx.event.subscribe.
|
|
899
939
|
*
|
|
@@ -1856,6 +1896,7 @@ async function registerV2ToolHooks(
|
|
|
1856
1896
|
context: PluginContext,
|
|
1857
1897
|
subagentOrigins: V2SubagentOriginRegistry,
|
|
1858
1898
|
boundedReadOrigins?: V2BoundedReadOriginRegistry,
|
|
1899
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
1859
1900
|
): Promise<{ registered: boolean; beforeRegistered: boolean }> {
|
|
1860
1901
|
const host = hostDomains(context)
|
|
1861
1902
|
const toolCtx = host.tool
|
|
@@ -1872,6 +1913,26 @@ async function registerV2ToolHooks(
|
|
|
1872
1913
|
onUnkeyed: appendV2HookLog,
|
|
1873
1914
|
})
|
|
1874
1915
|
|
|
1916
|
+
// J1 risk-score advisory gate (jev-risk-gate.ts). Constructed ONLY when
|
|
1917
|
+
// PANTHEON_J1_RISK_SCORE is on AND the host runtime exposes the native
|
|
1918
|
+
// Decisions API (the same instance `pantheon_jev_decide` uses), so flag-off
|
|
1919
|
+
// is a hard zero: no sink, no observer, no per-call work. When enabled, the
|
|
1920
|
+
// observer runs the SAME gate chain as the explicit tool (config, consent,
|
|
1921
|
+
// ledger reservation, permission kill-switch) and records shadow records
|
|
1922
|
+
// only — it is fired WITHOUT await inside the before-handler (fire-and-
|
|
1923
|
+
// observe), self-bounds at 2s with an AbortController, and never retries.
|
|
1924
|
+
let j1Observer: ((event: unknown) => Promise<void>) | undefined
|
|
1925
|
+
if (jevRuntime !== undefined && j1RiskGateEnabledFromEnv()) {
|
|
1926
|
+
const j1Sink = createTelemetrySink()
|
|
1927
|
+
j1TelemetrySink = j1Sink
|
|
1928
|
+
j1Observer = createJ1RiskGateObserver({
|
|
1929
|
+
runtime: jevRuntime,
|
|
1930
|
+
sink: (record) => {
|
|
1931
|
+
j1Sink.emit({ ...record, mode: 'shadow' })
|
|
1932
|
+
},
|
|
1933
|
+
})
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1875
1936
|
// Symlink resolution for the Zeus read guard (#272). The predicate is pure,
|
|
1876
1937
|
// so the filesystem work happens at this call site, rooted at the project
|
|
1877
1938
|
// directory the host reports. Same mechanism as V1's (src/plugin.ts) so the
|
|
@@ -1987,6 +2048,17 @@ async function registerV2ToolHooks(
|
|
|
1987
2048
|
if (origin !== undefined) {
|
|
1988
2049
|
writeV2AdmissionProof('tool.execute.before', { ...origin })
|
|
1989
2050
|
}
|
|
2051
|
+
// J1 risk-score shadow observation. Deliberately AFTER every guard: a
|
|
2052
|
+
// denied call must not spend decision budget. Fire-and-observe — the
|
|
2053
|
+
// promise is deliberately NOT awaited, so the hook's latency is
|
|
2054
|
+
// unchanged; the observer self-bounds at 2s (AbortController),
|
|
2055
|
+
// contains its own failures, records at most one shadow record per
|
|
2056
|
+
// event, and never blocks, retries, or queues. Undefined (no-op) when
|
|
2057
|
+
// the flag is off — the only cost of the flag-on check below is the
|
|
2058
|
+
// truthiness read.
|
|
2059
|
+
if (j1Observer !== undefined && isRiskGateTarget((event as { tool?: unknown }).tool)) {
|
|
2060
|
+
void j1Observer(event)
|
|
2061
|
+
}
|
|
1990
2062
|
// Delegation audit START record (#266). Deliberately AFTER every guard
|
|
1991
2063
|
// and the secret scan: a denied call must not leave a start record with
|
|
1992
2064
|
// no matching stop. The formatter/stop halves run in `execute.after`.
|
|
@@ -2489,10 +2561,17 @@ export const plugin = define({
|
|
|
2489
2561
|
}
|
|
2490
2562
|
|
|
2491
2563
|
// ─── Phase 5: V2 Tool Hooks (best-effort) ────────────────────────
|
|
2564
|
+
// The Jev runtime is built ONCE here and threaded to both consumers — the
|
|
2565
|
+
// tool registration (Phase 6) and the J1 risk-score observer inside the
|
|
2566
|
+
// execute.before hook — so `decide` and `permissionAssert` are bound to
|
|
2567
|
+
// their owning host domains exactly once. Pure construction over the host
|
|
2568
|
+
// domains: nothing is marked unsupported here; Phase 6 keeps that job.
|
|
2569
|
+
const jevRuntime = buildV2JevRuntime(hostDomains(context))
|
|
2492
2570
|
const toolHookResult = await registerV2ToolHooks(
|
|
2493
2571
|
context,
|
|
2494
2572
|
subagentOrigins,
|
|
2495
2573
|
boundedRead?.origins,
|
|
2574
|
+
jevRuntime,
|
|
2496
2575
|
).catch(() => ({ registered: false, beforeRegistered: false }))
|
|
2497
2576
|
if (!toolHookResult.registered) {
|
|
2498
2577
|
markUnsupported('tool-execute-hooks')
|
|
@@ -2505,7 +2584,9 @@ export const plugin = define({
|
|
|
2505
2584
|
if (boundedRead !== undefined && boundedReadDefinition === undefined) {
|
|
2506
2585
|
markUnsupported('bounded-read')
|
|
2507
2586
|
}
|
|
2508
|
-
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition).catch(
|
|
2587
|
+
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition, jevRuntime).catch(
|
|
2588
|
+
() => false,
|
|
2589
|
+
)
|
|
2509
2590
|
if (!toolsRegistered) markUnsupported('tool-transform')
|
|
2510
2591
|
|
|
2511
2592
|
// ─── Phase 7: V2 Compaction Hook (best-effort) ───────────────────
|
|
@@ -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-beta.
|
|
3200
|
+
insert(_el$13, `Pantheon v1.6.2-beta.16`);
|
|
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-beta.
|
|
3921
|
+
insert(_el$72, () => `Pantheon v1.6.2-beta.16${preset().name ? ` ▸ ${preset().name}` : ""}`);
|
|
3922
3922
|
effect((_$p) => setProp(_el$72, "fg", muted(), _$p));
|
|
3923
3923
|
return _el$72;
|
|
3924
3924
|
})();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "1.6.2-beta.
|
|
3
|
+
"version": "1.6.2-beta.16",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "1.6.2-beta.
|
|
9
|
+
"version": "1.6.2-beta.16",
|
|
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-beta.
|
|
4
|
+
"version": "1.6.2-beta.16",
|
|
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": {
|