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.
- package/CHANGELOG.md +113 -0
- package/README.md +34 -60
- package/README.pt-BR.md +10 -12
- package/bin/pantheon-init.mjs +23 -33
- package/package.json +3 -3
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +4 -1
- package/scripts/decision-router-v2-egress.mjs +11 -2
- package/scripts/decision-router.mjs +64 -56
- package/scripts/install/decision-router-config.mjs +110 -1
- package/scripts/install/npx-cache-sweep.mjs +103 -0
- package/scripts/install/opencode.mjs +7 -7
- package/scripts/install/plugin.mjs +4 -3
- package/scripts/install/strings.mjs +4 -0
- package/scripts/release-gates.mjs +6 -82
- package/scripts/secret-scan.mjs +1 -1
- package/scripts/sync-tui.mjs +3 -3
- package/src/agents/zeus.md +4 -2
- package/src/pantheon/jev-decision-tool.ts +455 -117
- package/src/pantheon/jev-decisions.ts +72 -25
- package/src/pantheon/jev-escalation.ts +639 -0
- package/src/pantheon/jev-quality-score.ts +432 -0
- package/src/pantheon/jev-risk-gate.ts +479 -0
- package/src/pantheon/local-decision-budget.ts +11 -1
- package/src/pantheon/local-decision-prompt.ts +12 -18
- package/src/pantheon/local-decision-provider-matrix.ts +3 -0
- package/src/pantheon/v2-decision-telemetry.ts +14 -4
- package/src/pantheon/v2-native-decisions.ts +1 -1
- package/src/plugin-v2.ts +204 -24
- package/src/plugins/tui/dist/server-v2.d.ts +19 -11
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +19 -789
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +257 -5370
- 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 +213 -86
- package/src/plugins/tui/src/server-v2.ts +18 -982
- package/src/plugins/tui/tsconfig.typecheck.json +1 -6
- package/src/plugins/tui/tsdown.config.ts +1 -11
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
- package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-adapters.js +0 -1142
- package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
- package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
- package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-cli.js +0 -184
- package/src/plugins/tui/dist/quota-cli.js.map +0 -1
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +0 -684
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
- package/src/plugins/tui/dist/usage-history-worker.js +0 -25
- package/src/plugins/tui/dist/usage-history-worker.js.map +0 -1
- package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
- package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
- package/src/plugins/tui/src/quota-adapters.ts +0 -1598
- package/src/plugins/tui/src/quota-cli.ts +0 -237
- package/src/plugins/tui/src/quota-rpc.ts +0 -373
- package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
- package/src/plugins/tui/src/quota-v2.tsx +0 -1238
- package/src/plugins/tui/src/usage-history-contract.ts +0 -217
- package/src/plugins/tui/src/usage-history-validation.ts +0 -104
- package/src/plugins/tui/src/usage-history-view.tsx +0 -236
- package/src/plugins/tui/src/usage-history-worker.ts +0 -25
- package/src/plugins/tui/src/usage-view-model.ts +0 -272
package/src/plugin-v2.ts
CHANGED
|
@@ -116,6 +116,17 @@ 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'
|
|
120
|
+
import {
|
|
121
|
+
createJ3EscalationObserver,
|
|
122
|
+
isSubagentDispatchEvent,
|
|
123
|
+
j3EscalationEnabledFromEnv,
|
|
124
|
+
} from './pantheon/jev-escalation.ts'
|
|
125
|
+
import {
|
|
126
|
+
createJ1RiskGateObserver,
|
|
127
|
+
isRiskGateTarget,
|
|
128
|
+
j1RiskGateEnabledFromEnv,
|
|
129
|
+
} from './pantheon/jev-risk-gate.ts'
|
|
119
130
|
import { DECISION_EGRESS_ACTION } from './pantheon/local-decision-egress-gate.ts'
|
|
120
131
|
import { applyDecisionRouterToPrompt } from './pantheon/local-decision-prompt.ts'
|
|
121
132
|
import { getSharedBoard } from './pantheon/shared-board.ts'
|
|
@@ -660,6 +671,58 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
660
671
|
|
|
661
672
|
// ─── V2 Tool Registration ───────────────────────────────────────────────
|
|
662
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Construct the ONE Jev runtime the plugin threads everywhere: the explicit
|
|
676
|
+
* `pantheon_jev_decide` tool and the J1 risk-score shadow observer both call
|
|
677
|
+
* through this instance, so `decide` and `permissionAssert` are bound to their
|
|
678
|
+
* owning host domains exactly once. `undefined` when the host lacks either the
|
|
679
|
+
* native Decisions API or the model catalog (the route no longer consults the
|
|
680
|
+
* catalog, but the tool registration contract still feature-detects both).
|
|
681
|
+
*/
|
|
682
|
+
function buildV2JevRuntime(host: ReturnType<typeof hostDomains>): V2JevDecisionRuntime | undefined {
|
|
683
|
+
const specialistCallers = specialistCallerAllowlist(process.env.PANTHEON_JEV_SPECIALIST_CALLERS)
|
|
684
|
+
const decisionsFn = host.experimental?.generate?.decisions
|
|
685
|
+
const modelListFn = host.model?.list
|
|
686
|
+
if (typeof decisionsFn !== 'function' || typeof modelListFn !== 'function') return undefined
|
|
687
|
+
const decisionsOwner = host.experimental?.generate
|
|
688
|
+
const decide = decisionsFn
|
|
689
|
+
const listModels = modelListFn
|
|
690
|
+
// The 2.2.5 host exposes ctx.skill as the SkillEditor (list()); the SDK
|
|
691
|
+
// types this file sees declare skill as the registration hook, so the
|
|
692
|
+
// runtime shape is read through one narrow, feature-detected cast.
|
|
693
|
+
const skillDomain = (host as { skill?: { list?: () => unknown } }).skill
|
|
694
|
+
const skillList = skillDomain?.list
|
|
695
|
+
const permissionAssertFn = host.permission?.assert
|
|
696
|
+
const permissionAssert =
|
|
697
|
+
typeof permissionAssertFn === 'function'
|
|
698
|
+
? (input: Record<string, unknown>) => permissionAssertFn.call(host.permission, input)
|
|
699
|
+
: undefined
|
|
700
|
+
// The J4 output-quality review telemetry sink (jev-quality-score.ts): the
|
|
701
|
+
// review mode of `pantheon_jev_decide` records ONE observer-style shadow
|
|
702
|
+
// record per run (q-token or skip token) through the in-memory, bounded 0b
|
|
703
|
+
// path (`createTelemetrySink`, no I/O), carrying `mode: 'shadow'`. The sink
|
|
704
|
+
// is created per runtime build so it always matches the runtime that holds
|
|
705
|
+
// it; the records are advisory and never read back by the tool path.
|
|
706
|
+
const j4Sink = createTelemetrySink()
|
|
707
|
+
j4TelemetrySink = j4Sink
|
|
708
|
+
return {
|
|
709
|
+
specialistCallers,
|
|
710
|
+
// Every host method is invoked with its owning domain as receiver: the
|
|
711
|
+
// canary records `ctx.model.list()` (bound) succeeding on 2.2.5 while a
|
|
712
|
+
// detached reference threw in the field and surfaced only as
|
|
713
|
+
// CATALOG_UNAVAILABLE. Same discipline as permissionAssert above.
|
|
714
|
+
listModels: () => listModels.call(host.model),
|
|
715
|
+
decide: (request: NativeDecisionRequest) => decide.call(decisionsOwner, request),
|
|
716
|
+
// Sync-or-async host skill list; absent/throwing falls back to the
|
|
717
|
+
// catalog-only preset inside the tool.
|
|
718
|
+
listSkills: async () => skillList?.call(skillDomain),
|
|
719
|
+
...(permissionAssert === undefined ? {} : { permissionAssert }),
|
|
720
|
+
shadowSink: (record) => {
|
|
721
|
+
j4Sink.emit({ ...record, mode: 'shadow' })
|
|
722
|
+
},
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
663
726
|
/**
|
|
664
727
|
* Attempt to register Pantheon tools via V2 ctx.tool.transform.
|
|
665
728
|
*
|
|
@@ -675,6 +738,7 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
675
738
|
async function registerV2Tools(
|
|
676
739
|
context: PluginContext,
|
|
677
740
|
boundedRead?: ReturnType<typeof createV2BoundedReadTool>['definition'],
|
|
741
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
678
742
|
): Promise<boolean> {
|
|
679
743
|
const host = hostDomains(context)
|
|
680
744
|
const toolCtx = host.tool
|
|
@@ -698,28 +762,10 @@ async function registerV2Tools(
|
|
|
698
762
|
const decisionsFn = host.experimental?.generate?.decisions
|
|
699
763
|
const jevReady = visionReady && typeof decisionsFn === 'function'
|
|
700
764
|
if (!jevReady) markUnsupported('jev-decision-tool')
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
const listModels = modelListFn
|
|
706
|
-
// The 2.2.5 host exposes ctx.skill as the SkillEditor (list()); the SDK
|
|
707
|
-
// types this file sees declare skill as the registration hook, so the
|
|
708
|
-
// runtime shape is read through one narrow, feature-detected cast.
|
|
709
|
-
const skillList = (host as { skill?: { list?: () => unknown } }).skill?.list
|
|
710
|
-
const permissionAssert =
|
|
711
|
-
typeof permissionAssertFn === 'function'
|
|
712
|
-
? (input: Record<string, unknown>) => permissionAssertFn.call(host.permission, input)
|
|
713
|
-
: undefined
|
|
714
|
-
jevRuntime = {
|
|
715
|
-
listModels: () => listModels(),
|
|
716
|
-
decide: (request: NativeDecisionRequest) => decide(request),
|
|
717
|
-
// Sync-or-async host skill list; absent/throwing falls back to the
|
|
718
|
-
// catalog-only preset inside the tool.
|
|
719
|
-
listSkills: async () => skillList?.(),
|
|
720
|
-
...(permissionAssert === undefined ? {} : { permissionAssert }),
|
|
721
|
-
}
|
|
722
|
-
}
|
|
765
|
+
// The setup flow threads the ONE runtime instance it built (shared with
|
|
766
|
+
// the J1 observer in the execute.before hook); this local fallback keeps a
|
|
767
|
+
// direct registration call self-sufficient.
|
|
768
|
+
const runtime = jevRuntime ?? (jevReady ? buildV2JevRuntime(host) : undefined)
|
|
723
769
|
// P3 (complexity) declares `tool.invoke`; its construction site is the
|
|
724
770
|
// local selector's execute, fed by that tool's own input schema. The sink
|
|
725
771
|
// is the 0b record path (in-memory, bounded, I/O-free) and every record
|
|
@@ -733,7 +779,7 @@ async function registerV2Tools(
|
|
|
733
779
|
p3Sink.emit({ ...record, mode: 'shadow' })
|
|
734
780
|
},
|
|
735
781
|
},
|
|
736
|
-
|
|
782
|
+
runtime,
|
|
737
783
|
)
|
|
738
784
|
if (boundedRead !== undefined) toolDefs.push(boundedRead)
|
|
739
785
|
|
|
@@ -888,6 +934,65 @@ export function getP11TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
|
888
934
|
|
|
889
935
|
let p11TelemetrySink: TelemetrySink | undefined
|
|
890
936
|
|
|
937
|
+
/**
|
|
938
|
+
* The J1 risk-score telemetry sink created by the most recent tool-hook
|
|
939
|
+
* registration.
|
|
940
|
+
*
|
|
941
|
+
* J1 (the risk-score advisory gate, `jev-risk-gate.ts`) is NOT a registry
|
|
942
|
+
* point: it is a flag-gated shadow observer on write/execute tool calls. The
|
|
943
|
+
* sink exists only when `PANTHEON_J1_RISK_SCORE` is on AND the host runtime
|
|
944
|
+
* exposes the native Decisions API, so flag-off leaves it undefined — the
|
|
945
|
+
* zero-overhead contract. Records go through the in-memory, bounded 0b path
|
|
946
|
+
* (`createTelemetrySink`, no I/O) and carry `mode: 'shadow'`; the observer is
|
|
947
|
+
* fire-and-observe, so the tool call never waits on it. Exported only for
|
|
948
|
+
* tests/pantheon/plugin-v2-contract.test.ts.
|
|
949
|
+
*/
|
|
950
|
+
export function getJ1TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
951
|
+
return j1TelemetrySink
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
let j1TelemetrySink: TelemetrySink | undefined
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* The J3 turn-complexity escalation telemetry sink created by the most recent
|
|
958
|
+
* tool-hook registration.
|
|
959
|
+
*
|
|
960
|
+
* J3 (the escalation shadow classifier, `jev-escalation.ts`) is NOT a registry
|
|
961
|
+
* point: it is a flag-gated shadow observer on delegate dispatches (the native
|
|
962
|
+
* `subagent` tool). The sink exists only when `PANTHEON_J3_ESCALATION` is on
|
|
963
|
+
* AND the host runtime exposes the native Decisions API, so flag-off leaves it
|
|
964
|
+
* undefined — the zero-overhead contract. Records go through the in-memory,
|
|
965
|
+
* bounded 0b path (`createTelemetrySink`, no I/O) and carry `mode: 'shadow'`;
|
|
966
|
+
* the observer is fire-and-observe, so the dispatch never waits on it. The
|
|
967
|
+
* recorded verdict never changes the dispatched model: the override mechanism
|
|
968
|
+
* for the activation step lives in `jev-escalation.ts` and is unreachable from
|
|
969
|
+
* this wiring. Exported only for tests/pantheon/plugin-v2-contract.test.ts.
|
|
970
|
+
*/
|
|
971
|
+
export function getJ3TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
972
|
+
return j3TelemetrySink
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
let j3TelemetrySink: TelemetrySink | undefined
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* The J4 output-quality review telemetry sink created by the most recent Jev
|
|
979
|
+
* runtime build.
|
|
980
|
+
*
|
|
981
|
+
* J4 (the review mode of `pantheon_jev_decide`, `jev-quality-score.ts`) is
|
|
982
|
+
* NOT a registry point and has no flag: the review runs only when Zeus
|
|
983
|
+
* explicitly requests it, and the record (`point: 'J4'`, `mode: 'shadow'`,
|
|
984
|
+
* `effect: 'none'`, reason token `q-<n>-review-<yes|no|na>` or a `skip-…`
|
|
985
|
+
* token) is the whole effect — advisory, never read back by the tool path.
|
|
986
|
+
* The sink is created inside `buildV2JevRuntime`, so it exists exactly when
|
|
987
|
+
* the runtime (and with it the tool) exists. Exported only for
|
|
988
|
+
* tests/pantheon/plugin-v2-contract.test.ts.
|
|
989
|
+
*/
|
|
990
|
+
export function getJ4TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
991
|
+
return j4TelemetrySink
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
let j4TelemetrySink: TelemetrySink | undefined
|
|
995
|
+
|
|
891
996
|
/**
|
|
892
997
|
* Attempt to subscribe to session events via V2 ctx.event.subscribe.
|
|
893
998
|
*
|
|
@@ -1850,6 +1955,7 @@ async function registerV2ToolHooks(
|
|
|
1850
1955
|
context: PluginContext,
|
|
1851
1956
|
subagentOrigins: V2SubagentOriginRegistry,
|
|
1852
1957
|
boundedReadOrigins?: V2BoundedReadOriginRegistry,
|
|
1958
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
1853
1959
|
): Promise<{ registered: boolean; beforeRegistered: boolean }> {
|
|
1854
1960
|
const host = hostDomains(context)
|
|
1855
1961
|
const toolCtx = host.tool
|
|
@@ -1866,6 +1972,51 @@ async function registerV2ToolHooks(
|
|
|
1866
1972
|
onUnkeyed: appendV2HookLog,
|
|
1867
1973
|
})
|
|
1868
1974
|
|
|
1975
|
+
// J1 risk-score advisory gate (jev-risk-gate.ts). Constructed ONLY when
|
|
1976
|
+
// PANTHEON_J1_RISK_SCORE is on AND the host runtime exposes the native
|
|
1977
|
+
// Decisions API (the same instance `pantheon_jev_decide` uses), so flag-off
|
|
1978
|
+
// is a hard zero: no sink, no observer, no per-call work. When enabled, the
|
|
1979
|
+
// observer runs the SAME gate chain as the explicit tool (config, consent,
|
|
1980
|
+
// ledger reservation, permission kill-switch) and records shadow records
|
|
1981
|
+
// only — it is fired WITHOUT await inside the before-handler (fire-and-
|
|
1982
|
+
// observe), self-bounds at 2s with an AbortController, and never retries.
|
|
1983
|
+
let j1Observer: ((event: unknown) => Promise<void>) | undefined
|
|
1984
|
+
if (jevRuntime !== undefined && j1RiskGateEnabledFromEnv()) {
|
|
1985
|
+
const j1Sink = createTelemetrySink()
|
|
1986
|
+
j1TelemetrySink = j1Sink
|
|
1987
|
+
j1Observer = createJ1RiskGateObserver({
|
|
1988
|
+
runtime: jevRuntime,
|
|
1989
|
+
sink: (record) => {
|
|
1990
|
+
j1Sink.emit({ ...record, mode: 'shadow' })
|
|
1991
|
+
},
|
|
1992
|
+
})
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
// J3 turn-complexity escalation (jev-escalation.ts) — SHADOW. Constructed
|
|
1996
|
+
// ONLY when PANTHEON_J3_ESCALATION is on AND the host runtime exposes the
|
|
1997
|
+
// native Decisions API (the same instance `pantheon_jev_decide` uses), so
|
|
1998
|
+
// flag-off is a hard zero: no sink, no observer, no per-dispatch work. When
|
|
1999
|
+
// enabled, the observer classifies ONE delegate dispatch (the native
|
|
2000
|
+
// `subagent` tool) through the SAME gate chain as the explicit tool and
|
|
2001
|
+
// records shadow records only — fired WITHOUT await inside the before-
|
|
2002
|
+
// handler (fire-and-observe), self-bounded at 2s with an AbortController,
|
|
2003
|
+
// never retried. The verdict NEVER changes the dispatched model in this
|
|
2004
|
+
// phase: the per-agent override mechanism for activation lives in
|
|
2005
|
+
// jev-escalation.ts and this wiring has no path to it (asserted
|
|
2006
|
+
// structurally by the contract test below — the override function's name
|
|
2007
|
+
// must not appear in this file at all).
|
|
2008
|
+
let j3Observer: ((event: unknown) => Promise<void>) | undefined
|
|
2009
|
+
if (jevRuntime !== undefined && j3EscalationEnabledFromEnv()) {
|
|
2010
|
+
const j3Sink = createTelemetrySink()
|
|
2011
|
+
j3TelemetrySink = j3Sink
|
|
2012
|
+
j3Observer = createJ3EscalationObserver({
|
|
2013
|
+
runtime: jevRuntime,
|
|
2014
|
+
sink: (record) => {
|
|
2015
|
+
j3Sink.emit({ ...record, mode: 'shadow' })
|
|
2016
|
+
},
|
|
2017
|
+
})
|
|
2018
|
+
}
|
|
2019
|
+
|
|
1869
2020
|
// Symlink resolution for the Zeus read guard (#272). The predicate is pure,
|
|
1870
2021
|
// so the filesystem work happens at this call site, rooted at the project
|
|
1871
2022
|
// directory the host reports. Same mechanism as V1's (src/plugin.ts) so the
|
|
@@ -1981,6 +2132,26 @@ async function registerV2ToolHooks(
|
|
|
1981
2132
|
if (origin !== undefined) {
|
|
1982
2133
|
writeV2AdmissionProof('tool.execute.before', { ...origin })
|
|
1983
2134
|
}
|
|
2135
|
+
// J1 risk-score shadow observation. Deliberately AFTER every guard: a
|
|
2136
|
+
// denied call must not spend decision budget. Fire-and-observe — the
|
|
2137
|
+
// promise is deliberately NOT awaited, so the hook's latency is
|
|
2138
|
+
// unchanged; the observer self-bounds at 2s (AbortController),
|
|
2139
|
+
// contains its own failures, records at most one shadow record per
|
|
2140
|
+
// event, and never blocks, retries, or queues. Undefined (no-op) when
|
|
2141
|
+
// the flag is off — the only cost of the flag-on check below is the
|
|
2142
|
+
// truthiness read.
|
|
2143
|
+
if (j1Observer !== undefined && isRiskGateTarget((event as { tool?: unknown }).tool)) {
|
|
2144
|
+
void j1Observer(event)
|
|
2145
|
+
}
|
|
2146
|
+
// J3 turn-complexity shadow classification. Same fire-and-observe
|
|
2147
|
+
// discipline as J1: the dispatch's latency is unchanged, the observer
|
|
2148
|
+
// self-bounds at 2s, contains its own failures, records at most one
|
|
2149
|
+
// shadow record per dispatch, and never blocks, retries, or queues.
|
|
2150
|
+
// The recorded verdict NEVER changes the dispatched model (shadow
|
|
2151
|
+
// contract); undefined (no-op) when the flag is off.
|
|
2152
|
+
if (j3Observer !== undefined && isSubagentDispatchEvent(event)) {
|
|
2153
|
+
void j3Observer(event)
|
|
2154
|
+
}
|
|
1984
2155
|
// Delegation audit START record (#266). Deliberately AFTER every guard
|
|
1985
2156
|
// and the secret scan: a denied call must not leave a start record with
|
|
1986
2157
|
// no matching stop. The formatter/stop halves run in `execute.after`.
|
|
@@ -2483,10 +2654,17 @@ export const plugin = define({
|
|
|
2483
2654
|
}
|
|
2484
2655
|
|
|
2485
2656
|
// ─── Phase 5: V2 Tool Hooks (best-effort) ────────────────────────
|
|
2657
|
+
// The Jev runtime is built ONCE here and threaded to both consumers — the
|
|
2658
|
+
// tool registration (Phase 6) and the J1 risk-score observer inside the
|
|
2659
|
+
// execute.before hook — so `decide` and `permissionAssert` are bound to
|
|
2660
|
+
// their owning host domains exactly once. Pure construction over the host
|
|
2661
|
+
// domains: nothing is marked unsupported here; Phase 6 keeps that job.
|
|
2662
|
+
const jevRuntime = buildV2JevRuntime(hostDomains(context))
|
|
2486
2663
|
const toolHookResult = await registerV2ToolHooks(
|
|
2487
2664
|
context,
|
|
2488
2665
|
subagentOrigins,
|
|
2489
2666
|
boundedRead?.origins,
|
|
2667
|
+
jevRuntime,
|
|
2490
2668
|
).catch(() => ({ registered: false, beforeRegistered: false }))
|
|
2491
2669
|
if (!toolHookResult.registered) {
|
|
2492
2670
|
markUnsupported('tool-execute-hooks')
|
|
@@ -2499,7 +2677,9 @@ export const plugin = define({
|
|
|
2499
2677
|
if (boundedRead !== undefined && boundedReadDefinition === undefined) {
|
|
2500
2678
|
markUnsupported('bounded-read')
|
|
2501
2679
|
}
|
|
2502
|
-
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition).catch(
|
|
2680
|
+
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition, jevRuntime).catch(
|
|
2681
|
+
() => false,
|
|
2682
|
+
)
|
|
2503
2683
|
if (!toolsRegistered) markUnsupported('tool-transform')
|
|
2504
2684
|
|
|
2505
2685
|
// ─── Phase 7: V2 Compaction Hook (best-effort) ───────────────────
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { queryAlibabaTokenPlanUsage } from "./quota-cli.js";
|
|
2
|
-
import { Context } from "@opencode/plugin/promise/plugin";
|
|
3
1
|
//#region src/server-v2.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
/**
|
|
3
|
+
* No-op server stub for the OpenCode V2 plugin loader.
|
|
4
|
+
*
|
|
5
|
+
* The OpenCode plugin host requires every plugin (TUI included) to expose a
|
|
6
|
+
* `server()` entry via `exports["./server"]` (or package.json `main`) — for the
|
|
7
|
+
* V2 copy this root `index-v2.ts` re-export resolves to this compiled entry —
|
|
8
|
+
* and it loads that server half only from a `config.plugins` entry (see
|
|
9
|
+
* `scripts/install/opencode.mjs`). When the entry is missing the host fails to
|
|
10
|
+
* attach the plugin's server half and the TUI runtime never wires the reactive
|
|
11
|
+
* channel — the initial JSX mounts but effects/refresh/events stay dead (the
|
|
12
|
+
* "mudo panel" symptom; same contract as the V1 `server.ts` stub).
|
|
13
|
+
*
|
|
14
|
+
* This stub satisfies the loader contract. The native quota RPC that used to
|
|
15
|
+
* live here was removed in 1.6.2 — provider quota/usage visibility is now the
|
|
16
|
+
* community plugin's job (`@slkiser/opencode-quota`,
|
|
17
|
+
* docs/tui-v2-quota-providers.md) — and pantheon-tui has no other background
|
|
18
|
+
* server work of its own.
|
|
19
|
+
*/
|
|
20
|
+
export default function server(): {};
|
|
12
21
|
//#endregion
|
|
13
|
-
export { _default as default };
|
|
14
22
|
//# sourceMappingURL=server-v2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-v2.d.ts","names":[],"sources":["../src/server-v2.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-v2.d.ts","names":[],"sources":["../src/server-v2.ts"],"mappings":";;;;;;;;;;;;;;;;;;;wBAkBwB"}
|