pantheon-opencode 1.6.2-beta.8 → 1.6.2
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 +121 -3
- package/README.md +34 -60
- package/README.pt-BR.md +10 -12
- package/bin/pantheon-init.mjs +30 -32
- package/package.json +3 -3
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router.mjs +41 -56
- package/scripts/install/decision-router-config.mjs +67 -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/sync-tui.mjs +3 -3
- package/src/agents/aphrodite.md +1 -1
- package/src/agents/apollo.md +1 -0
- package/src/agents/athena.md +1 -0
- package/src/agents/demeter.md +1 -1
- package/src/agents/gaia.md +1 -0
- package/src/agents/hephaestus.md +1 -1
- package/src/agents/hermes.md +1 -1
- package/src/agents/iris.md +1 -1
- package/src/agents/mnemosyne.md +1 -0
- package/src/agents/nyx.md +1 -1
- package/src/agents/prometheus.md +1 -1
- package/src/agents/talos.md +1 -1
- package/src/agents/themis.md +1 -1
- package/src/agents/zeus.md +5 -2
- package/src/pantheon/jev-decision-tool.ts +366 -114
- package/src/pantheon/jev-decisions.ts +11 -13
- 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-prompt.ts +12 -18
- package/src/pantheon/v2-decision-telemetry.ts +14 -4
- package/src/pantheon/v2-native-decisions.ts +1 -1
- package/src/plugin-v2.ts +201 -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,16 @@ 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
|
+
createJ3EscalationObserver,
|
|
121
|
+
isSubagentDispatchEvent,
|
|
122
|
+
j3EscalationEnabledFromEnv,
|
|
123
|
+
} from './pantheon/jev-escalation.ts'
|
|
124
|
+
import {
|
|
125
|
+
createJ1RiskGateObserver,
|
|
126
|
+
isRiskGateTarget,
|
|
127
|
+
j1RiskGateEnabledFromEnv,
|
|
128
|
+
} from './pantheon/jev-risk-gate.ts'
|
|
119
129
|
import { DECISION_EGRESS_ACTION } from './pantheon/local-decision-egress-gate.ts'
|
|
120
130
|
import { applyDecisionRouterToPrompt } from './pantheon/local-decision-prompt.ts'
|
|
121
131
|
import { getSharedBoard } from './pantheon/shared-board.ts'
|
|
@@ -660,6 +670,56 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
660
670
|
|
|
661
671
|
// ─── V2 Tool Registration ───────────────────────────────────────────────
|
|
662
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Construct the ONE Jev runtime the plugin threads everywhere: the explicit
|
|
675
|
+
* `pantheon_jev_decide` tool and the J1 risk-score shadow observer both call
|
|
676
|
+
* through this instance, so `decide` and `permissionAssert` are bound to their
|
|
677
|
+
* owning host domains exactly once. `undefined` when the host lacks either the
|
|
678
|
+
* native Decisions API or the model catalog (the route no longer consults the
|
|
679
|
+
* catalog, but the tool registration contract still feature-detects both).
|
|
680
|
+
*/
|
|
681
|
+
function buildV2JevRuntime(host: ReturnType<typeof hostDomains>): V2JevDecisionRuntime | undefined {
|
|
682
|
+
const decisionsFn = host.experimental?.generate?.decisions
|
|
683
|
+
const modelListFn = host.model?.list
|
|
684
|
+
if (typeof decisionsFn !== 'function' || typeof modelListFn !== 'function') return undefined
|
|
685
|
+
const decisionsOwner = host.experimental?.generate
|
|
686
|
+
const decide = decisionsFn
|
|
687
|
+
const listModels = modelListFn
|
|
688
|
+
// The 2.2.5 host exposes ctx.skill as the SkillEditor (list()); the SDK
|
|
689
|
+
// types this file sees declare skill as the registration hook, so the
|
|
690
|
+
// runtime shape is read through one narrow, feature-detected cast.
|
|
691
|
+
const skillDomain = (host as { skill?: { list?: () => unknown } }).skill
|
|
692
|
+
const skillList = skillDomain?.list
|
|
693
|
+
const permissionAssertFn = host.permission?.assert
|
|
694
|
+
const permissionAssert =
|
|
695
|
+
typeof permissionAssertFn === 'function'
|
|
696
|
+
? (input: Record<string, unknown>) => permissionAssertFn.call(host.permission, input)
|
|
697
|
+
: undefined
|
|
698
|
+
// The J4 output-quality review telemetry sink (jev-quality-score.ts): the
|
|
699
|
+
// review mode of `pantheon_jev_decide` records ONE observer-style shadow
|
|
700
|
+
// record per run (q-token or skip token) through the in-memory, bounded 0b
|
|
701
|
+
// path (`createTelemetrySink`, no I/O), carrying `mode: 'shadow'`. The sink
|
|
702
|
+
// is created per runtime build so it always matches the runtime that holds
|
|
703
|
+
// it; the records are advisory and never read back by the tool path.
|
|
704
|
+
const j4Sink = createTelemetrySink()
|
|
705
|
+
j4TelemetrySink = j4Sink
|
|
706
|
+
return {
|
|
707
|
+
// Every host method is invoked with its owning domain as receiver: the
|
|
708
|
+
// canary records `ctx.model.list()` (bound) succeeding on 2.2.5 while a
|
|
709
|
+
// detached reference threw in the field and surfaced only as
|
|
710
|
+
// CATALOG_UNAVAILABLE. Same discipline as permissionAssert above.
|
|
711
|
+
listModels: () => listModels.call(host.model),
|
|
712
|
+
decide: (request: NativeDecisionRequest) => decide.call(decisionsOwner, request),
|
|
713
|
+
// Sync-or-async host skill list; absent/throwing falls back to the
|
|
714
|
+
// catalog-only preset inside the tool.
|
|
715
|
+
listSkills: async () => skillList?.call(skillDomain),
|
|
716
|
+
...(permissionAssert === undefined ? {} : { permissionAssert }),
|
|
717
|
+
shadowSink: (record) => {
|
|
718
|
+
j4Sink.emit({ ...record, mode: 'shadow' })
|
|
719
|
+
},
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
663
723
|
/**
|
|
664
724
|
* Attempt to register Pantheon tools via V2 ctx.tool.transform.
|
|
665
725
|
*
|
|
@@ -675,6 +735,7 @@ function transformReferences(draft: ReferenceDraft): void {
|
|
|
675
735
|
async function registerV2Tools(
|
|
676
736
|
context: PluginContext,
|
|
677
737
|
boundedRead?: ReturnType<typeof createV2BoundedReadTool>['definition'],
|
|
738
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
678
739
|
): Promise<boolean> {
|
|
679
740
|
const host = hostDomains(context)
|
|
680
741
|
const toolCtx = host.tool
|
|
@@ -698,28 +759,10 @@ async function registerV2Tools(
|
|
|
698
759
|
const decisionsFn = host.experimental?.generate?.decisions
|
|
699
760
|
const jevReady = visionReady && typeof decisionsFn === 'function'
|
|
700
761
|
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
|
-
}
|
|
762
|
+
// The setup flow threads the ONE runtime instance it built (shared with
|
|
763
|
+
// the J1 observer in the execute.before hook); this local fallback keeps a
|
|
764
|
+
// direct registration call self-sufficient.
|
|
765
|
+
const runtime = jevRuntime ?? (jevReady ? buildV2JevRuntime(host) : undefined)
|
|
723
766
|
// P3 (complexity) declares `tool.invoke`; its construction site is the
|
|
724
767
|
// local selector's execute, fed by that tool's own input schema. The sink
|
|
725
768
|
// is the 0b record path (in-memory, bounded, I/O-free) and every record
|
|
@@ -733,7 +776,7 @@ async function registerV2Tools(
|
|
|
733
776
|
p3Sink.emit({ ...record, mode: 'shadow' })
|
|
734
777
|
},
|
|
735
778
|
},
|
|
736
|
-
|
|
779
|
+
runtime,
|
|
737
780
|
)
|
|
738
781
|
if (boundedRead !== undefined) toolDefs.push(boundedRead)
|
|
739
782
|
|
|
@@ -888,6 +931,65 @@ export function getP11TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
|
888
931
|
|
|
889
932
|
let p11TelemetrySink: TelemetrySink | undefined
|
|
890
933
|
|
|
934
|
+
/**
|
|
935
|
+
* The J1 risk-score telemetry sink created by the most recent tool-hook
|
|
936
|
+
* registration.
|
|
937
|
+
*
|
|
938
|
+
* J1 (the risk-score advisory gate, `jev-risk-gate.ts`) is NOT a registry
|
|
939
|
+
* point: it is a flag-gated shadow observer on write/execute tool calls. The
|
|
940
|
+
* sink exists only when `PANTHEON_J1_RISK_SCORE` is on AND the host runtime
|
|
941
|
+
* exposes the native Decisions API, so flag-off leaves it undefined — the
|
|
942
|
+
* zero-overhead contract. Records go through the in-memory, bounded 0b path
|
|
943
|
+
* (`createTelemetrySink`, no I/O) and carry `mode: 'shadow'`; the observer is
|
|
944
|
+
* fire-and-observe, so the tool call never waits on it. Exported only for
|
|
945
|
+
* tests/pantheon/plugin-v2-contract.test.ts.
|
|
946
|
+
*/
|
|
947
|
+
export function getJ1TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
948
|
+
return j1TelemetrySink
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
let j1TelemetrySink: TelemetrySink | undefined
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* The J3 turn-complexity escalation telemetry sink created by the most recent
|
|
955
|
+
* tool-hook registration.
|
|
956
|
+
*
|
|
957
|
+
* J3 (the escalation shadow classifier, `jev-escalation.ts`) is NOT a registry
|
|
958
|
+
* point: it is a flag-gated shadow observer on delegate dispatches (the native
|
|
959
|
+
* `subagent` tool). The sink exists only when `PANTHEON_J3_ESCALATION` is on
|
|
960
|
+
* AND the host runtime exposes the native Decisions API, so flag-off leaves it
|
|
961
|
+
* undefined — the zero-overhead contract. Records go through the in-memory,
|
|
962
|
+
* bounded 0b path (`createTelemetrySink`, no I/O) and carry `mode: 'shadow'`;
|
|
963
|
+
* the observer is fire-and-observe, so the dispatch never waits on it. The
|
|
964
|
+
* recorded verdict never changes the dispatched model: the override mechanism
|
|
965
|
+
* for the activation step lives in `jev-escalation.ts` and is unreachable from
|
|
966
|
+
* this wiring. Exported only for tests/pantheon/plugin-v2-contract.test.ts.
|
|
967
|
+
*/
|
|
968
|
+
export function getJ3TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
969
|
+
return j3TelemetrySink
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
let j3TelemetrySink: TelemetrySink | undefined
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* The J4 output-quality review telemetry sink created by the most recent Jev
|
|
976
|
+
* runtime build.
|
|
977
|
+
*
|
|
978
|
+
* J4 (the review mode of `pantheon_jev_decide`, `jev-quality-score.ts`) is
|
|
979
|
+
* NOT a registry point and has no flag: the review runs only when Zeus
|
|
980
|
+
* explicitly requests it, and the record (`point: 'J4'`, `mode: 'shadow'`,
|
|
981
|
+
* `effect: 'none'`, reason token `q-<n>-review-<yes|no|na>` or a `skip-…`
|
|
982
|
+
* token) is the whole effect — advisory, never read back by the tool path.
|
|
983
|
+
* The sink is created inside `buildV2JevRuntime`, so it exists exactly when
|
|
984
|
+
* the runtime (and with it the tool) exists. Exported only for
|
|
985
|
+
* tests/pantheon/plugin-v2-contract.test.ts.
|
|
986
|
+
*/
|
|
987
|
+
export function getJ4TelemetrySinkForTests(): TelemetrySink | undefined {
|
|
988
|
+
return j4TelemetrySink
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
let j4TelemetrySink: TelemetrySink | undefined
|
|
992
|
+
|
|
891
993
|
/**
|
|
892
994
|
* Attempt to subscribe to session events via V2 ctx.event.subscribe.
|
|
893
995
|
*
|
|
@@ -1850,6 +1952,7 @@ async function registerV2ToolHooks(
|
|
|
1850
1952
|
context: PluginContext,
|
|
1851
1953
|
subagentOrigins: V2SubagentOriginRegistry,
|
|
1852
1954
|
boundedReadOrigins?: V2BoundedReadOriginRegistry,
|
|
1955
|
+
jevRuntime?: V2JevDecisionRuntime,
|
|
1853
1956
|
): Promise<{ registered: boolean; beforeRegistered: boolean }> {
|
|
1854
1957
|
const host = hostDomains(context)
|
|
1855
1958
|
const toolCtx = host.tool
|
|
@@ -1866,6 +1969,51 @@ async function registerV2ToolHooks(
|
|
|
1866
1969
|
onUnkeyed: appendV2HookLog,
|
|
1867
1970
|
})
|
|
1868
1971
|
|
|
1972
|
+
// J1 risk-score advisory gate (jev-risk-gate.ts). Constructed ONLY when
|
|
1973
|
+
// PANTHEON_J1_RISK_SCORE is on AND the host runtime exposes the native
|
|
1974
|
+
// Decisions API (the same instance `pantheon_jev_decide` uses), so flag-off
|
|
1975
|
+
// is a hard zero: no sink, no observer, no per-call work. When enabled, the
|
|
1976
|
+
// observer runs the SAME gate chain as the explicit tool (config, consent,
|
|
1977
|
+
// ledger reservation, permission kill-switch) and records shadow records
|
|
1978
|
+
// only — it is fired WITHOUT await inside the before-handler (fire-and-
|
|
1979
|
+
// observe), self-bounds at 2s with an AbortController, and never retries.
|
|
1980
|
+
let j1Observer: ((event: unknown) => Promise<void>) | undefined
|
|
1981
|
+
if (jevRuntime !== undefined && j1RiskGateEnabledFromEnv()) {
|
|
1982
|
+
const j1Sink = createTelemetrySink()
|
|
1983
|
+
j1TelemetrySink = j1Sink
|
|
1984
|
+
j1Observer = createJ1RiskGateObserver({
|
|
1985
|
+
runtime: jevRuntime,
|
|
1986
|
+
sink: (record) => {
|
|
1987
|
+
j1Sink.emit({ ...record, mode: 'shadow' })
|
|
1988
|
+
},
|
|
1989
|
+
})
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
// J3 turn-complexity escalation (jev-escalation.ts) — SHADOW. Constructed
|
|
1993
|
+
// ONLY when PANTHEON_J3_ESCALATION is on AND the host runtime exposes the
|
|
1994
|
+
// native Decisions API (the same instance `pantheon_jev_decide` uses), so
|
|
1995
|
+
// flag-off is a hard zero: no sink, no observer, no per-dispatch work. When
|
|
1996
|
+
// enabled, the observer classifies ONE delegate dispatch (the native
|
|
1997
|
+
// `subagent` tool) through the SAME gate chain as the explicit tool and
|
|
1998
|
+
// records shadow records only — fired WITHOUT await inside the before-
|
|
1999
|
+
// handler (fire-and-observe), self-bounded at 2s with an AbortController,
|
|
2000
|
+
// never retried. The verdict NEVER changes the dispatched model in this
|
|
2001
|
+
// phase: the per-agent override mechanism for activation lives in
|
|
2002
|
+
// jev-escalation.ts and this wiring has no path to it (asserted
|
|
2003
|
+
// structurally by the contract test below — the override function's name
|
|
2004
|
+
// must not appear in this file at all).
|
|
2005
|
+
let j3Observer: ((event: unknown) => Promise<void>) | undefined
|
|
2006
|
+
if (jevRuntime !== undefined && j3EscalationEnabledFromEnv()) {
|
|
2007
|
+
const j3Sink = createTelemetrySink()
|
|
2008
|
+
j3TelemetrySink = j3Sink
|
|
2009
|
+
j3Observer = createJ3EscalationObserver({
|
|
2010
|
+
runtime: jevRuntime,
|
|
2011
|
+
sink: (record) => {
|
|
2012
|
+
j3Sink.emit({ ...record, mode: 'shadow' })
|
|
2013
|
+
},
|
|
2014
|
+
})
|
|
2015
|
+
}
|
|
2016
|
+
|
|
1869
2017
|
// Symlink resolution for the Zeus read guard (#272). The predicate is pure,
|
|
1870
2018
|
// so the filesystem work happens at this call site, rooted at the project
|
|
1871
2019
|
// directory the host reports. Same mechanism as V1's (src/plugin.ts) so the
|
|
@@ -1981,6 +2129,26 @@ async function registerV2ToolHooks(
|
|
|
1981
2129
|
if (origin !== undefined) {
|
|
1982
2130
|
writeV2AdmissionProof('tool.execute.before', { ...origin })
|
|
1983
2131
|
}
|
|
2132
|
+
// J1 risk-score shadow observation. Deliberately AFTER every guard: a
|
|
2133
|
+
// denied call must not spend decision budget. Fire-and-observe — the
|
|
2134
|
+
// promise is deliberately NOT awaited, so the hook's latency is
|
|
2135
|
+
// unchanged; the observer self-bounds at 2s (AbortController),
|
|
2136
|
+
// contains its own failures, records at most one shadow record per
|
|
2137
|
+
// event, and never blocks, retries, or queues. Undefined (no-op) when
|
|
2138
|
+
// the flag is off — the only cost of the flag-on check below is the
|
|
2139
|
+
// truthiness read.
|
|
2140
|
+
if (j1Observer !== undefined && isRiskGateTarget((event as { tool?: unknown }).tool)) {
|
|
2141
|
+
void j1Observer(event)
|
|
2142
|
+
}
|
|
2143
|
+
// J3 turn-complexity shadow classification. Same fire-and-observe
|
|
2144
|
+
// discipline as J1: the dispatch's latency is unchanged, the observer
|
|
2145
|
+
// self-bounds at 2s, contains its own failures, records at most one
|
|
2146
|
+
// shadow record per dispatch, and never blocks, retries, or queues.
|
|
2147
|
+
// The recorded verdict NEVER changes the dispatched model (shadow
|
|
2148
|
+
// contract); undefined (no-op) when the flag is off.
|
|
2149
|
+
if (j3Observer !== undefined && isSubagentDispatchEvent(event)) {
|
|
2150
|
+
void j3Observer(event)
|
|
2151
|
+
}
|
|
1984
2152
|
// Delegation audit START record (#266). Deliberately AFTER every guard
|
|
1985
2153
|
// and the secret scan: a denied call must not leave a start record with
|
|
1986
2154
|
// no matching stop. The formatter/stop halves run in `execute.after`.
|
|
@@ -2483,10 +2651,17 @@ export const plugin = define({
|
|
|
2483
2651
|
}
|
|
2484
2652
|
|
|
2485
2653
|
// ─── Phase 5: V2 Tool Hooks (best-effort) ────────────────────────
|
|
2654
|
+
// The Jev runtime is built ONCE here and threaded to both consumers — the
|
|
2655
|
+
// tool registration (Phase 6) and the J1 risk-score observer inside the
|
|
2656
|
+
// execute.before hook — so `decide` and `permissionAssert` are bound to
|
|
2657
|
+
// their owning host domains exactly once. Pure construction over the host
|
|
2658
|
+
// domains: nothing is marked unsupported here; Phase 6 keeps that job.
|
|
2659
|
+
const jevRuntime = buildV2JevRuntime(hostDomains(context))
|
|
2486
2660
|
const toolHookResult = await registerV2ToolHooks(
|
|
2487
2661
|
context,
|
|
2488
2662
|
subagentOrigins,
|
|
2489
2663
|
boundedRead?.origins,
|
|
2664
|
+
jevRuntime,
|
|
2490
2665
|
).catch(() => ({ registered: false, beforeRegistered: false }))
|
|
2491
2666
|
if (!toolHookResult.registered) {
|
|
2492
2667
|
markUnsupported('tool-execute-hooks')
|
|
@@ -2499,7 +2674,9 @@ export const plugin = define({
|
|
|
2499
2674
|
if (boundedRead !== undefined && boundedReadDefinition === undefined) {
|
|
2500
2675
|
markUnsupported('bounded-read')
|
|
2501
2676
|
}
|
|
2502
|
-
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition).catch(
|
|
2677
|
+
const toolsRegistered = await registerV2Tools(context, boundedReadDefinition, jevRuntime).catch(
|
|
2678
|
+
() => false,
|
|
2679
|
+
)
|
|
2503
2680
|
if (!toolsRegistered) markUnsupported('tool-transform')
|
|
2504
2681
|
|
|
2505
2682
|
// ─── 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"}
|