@osovv/vv-opencode 2.0.1 → 2.1.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 (296) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +88 -87
  3. package/dist/commands/completion.js +0 -1
  4. package/dist/commands/completion.js.map +1 -1
  5. package/dist/commands/doctor.js +6 -9
  6. package/dist/commands/doctor.js.map +1 -1
  7. package/dist/commands/init.d.ts +2 -1
  8. package/dist/commands/init.js +7 -12
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/install.d.ts +4 -0
  11. package/dist/commands/install.js +40 -37
  12. package/dist/commands/install.js.map +1 -1
  13. package/dist/commands/launch.d.ts +2 -1
  14. package/dist/commands/launch.js +18 -14
  15. package/dist/commands/launch.js.map +1 -1
  16. package/dist/commands/patch-provider.d.ts +225 -307
  17. package/dist/commands/patch-provider.js +92 -296
  18. package/dist/commands/patch-provider.js.map +1 -1
  19. package/dist/commands/status.js +7 -10
  20. package/dist/commands/status.js.map +1 -1
  21. package/dist/commands/sync.d.ts +4 -0
  22. package/dist/commands/sync.js +38 -35
  23. package/dist/commands/sync.js.map +1 -1
  24. package/dist/index.d.ts +25 -5
  25. package/dist/index.js +73 -34
  26. package/dist/index.js.map +1 -1
  27. package/dist/lib/agent-tool-catalog.d.ts +1 -1
  28. package/dist/lib/agent-tool-catalog.js +3 -6
  29. package/dist/lib/agent-tool-catalog.js.map +1 -1
  30. package/dist/lib/agent-tool-contract.d.ts +22 -13
  31. package/dist/lib/agent-tool-contract.js +20 -20
  32. package/dist/lib/agent-tool-contract.js.map +1 -1
  33. package/dist/lib/analytics/types.d.ts +7 -1
  34. package/dist/lib/analytics/types.js +2 -2
  35. package/dist/lib/analytics/types.js.map +1 -1
  36. package/dist/lib/config-layers.d.ts +28 -6
  37. package/dist/lib/config-layers.js +268 -73
  38. package/dist/lib/config-layers.js.map +1 -1
  39. package/dist/lib/managed-agents.d.ts +24 -2
  40. package/dist/lib/managed-agents.js +45 -15
  41. package/dist/lib/managed-agents.js.map +1 -1
  42. package/dist/lib/model-roles.d.ts +5 -0
  43. package/dist/lib/model-roles.js +22 -1
  44. package/dist/lib/model-roles.js.map +1 -1
  45. package/dist/lib/opencode/agent-registrations.d.ts +4 -4
  46. package/dist/lib/opencode/agent-registrations.js +386 -197
  47. package/dist/lib/opencode/agent-registrations.js.map +1 -1
  48. package/dist/lib/opencode/inspection.d.ts +13 -13
  49. package/dist/lib/opencode/inspection.js +69 -106
  50. package/dist/lib/opencode/inspection.js.map +1 -1
  51. package/dist/lib/opencode/model-overrides.d.ts +2 -2
  52. package/dist/lib/opencode/model-overrides.js +192 -47
  53. package/dist/lib/opencode/model-overrides.js.map +1 -1
  54. package/dist/lib/opencode/paths.d.ts +6 -2
  55. package/dist/lib/opencode/paths.js +12 -11
  56. package/dist/lib/opencode/paths.js.map +1 -1
  57. package/dist/lib/opencode/plugin-registration.d.ts +10 -11
  58. package/dist/lib/opencode/plugin-registration.js +76 -138
  59. package/dist/lib/opencode/plugin-registration.js.map +1 -1
  60. package/dist/lib/opencode/shared-utils.d.ts +47 -3
  61. package/dist/lib/opencode/shared-utils.js +346 -15
  62. package/dist/lib/opencode/shared-utils.js.map +1 -1
  63. package/dist/lib/opencode.d.ts +5 -6
  64. package/dist/lib/opencode.js +10 -10
  65. package/dist/lib/opencode.js.map +1 -1
  66. package/dist/lib/vvoc-config.js +4 -4
  67. package/dist/lib/vvoc-config.js.map +1 -1
  68. package/dist/lib/vvoc-paths.d.ts +7 -0
  69. package/dist/lib/vvoc-paths.js +15 -1
  70. package/dist/lib/vvoc-paths.js.map +1 -1
  71. package/dist/lib/vvoc-preset-registry.d.ts +38 -50
  72. package/dist/lib/vvoc-preset-registry.js +38 -48
  73. package/dist/lib/vvoc-preset-registry.js.map +1 -1
  74. package/dist/plugins/analytics/index.d.ts +20 -14
  75. package/dist/plugins/analytics/index.js +281 -133
  76. package/dist/plugins/analytics/index.js.map +1 -1
  77. package/dist/plugins/guardian/index.d.ts +63 -42
  78. package/dist/plugins/guardian/index.js +217 -759
  79. package/dist/plugins/guardian/index.js.map +1 -1
  80. package/dist/plugins/hashline-edit/index.d.ts +145 -31
  81. package/dist/plugins/hashline-edit/index.js +679 -244
  82. package/dist/plugins/hashline-edit/index.js.map +1 -1
  83. package/dist/plugins/hashline-edit/schemas.d.ts +1 -1
  84. package/dist/plugins/hashline-edit/schemas.js +3 -3
  85. package/dist/plugins/hashline-edit/schemas.js.map +1 -1
  86. package/dist/plugins/model-roles/index.d.ts +18 -4
  87. package/dist/plugins/model-roles/index.js +44 -181
  88. package/dist/plugins/model-roles/index.js.map +1 -1
  89. package/dist/plugins/peak-hours/index.d.ts +23 -23
  90. package/dist/plugins/peak-hours/index.js +211 -180
  91. package/dist/plugins/peak-hours/index.js.map +1 -1
  92. package/dist/plugins/secrets-redaction/deep.js +35 -51
  93. package/dist/plugins/secrets-redaction/deep.js.map +1 -1
  94. package/dist/plugins/secrets-redaction/index.d.ts +96 -8
  95. package/dist/plugins/secrets-redaction/index.js +290 -102
  96. package/dist/plugins/secrets-redaction/index.js.map +1 -1
  97. package/dist/plugins/secrets-redaction/session.d.ts +9 -0
  98. package/dist/plugins/secrets-redaction/session.js +21 -4
  99. package/dist/plugins/secrets-redaction/session.js.map +1 -1
  100. package/dist/plugins/secrets-redaction/stream.d.ts +92 -0
  101. package/dist/plugins/secrets-redaction/stream.js +772 -0
  102. package/dist/plugins/secrets-redaction/stream.js.map +1 -0
  103. package/dist/plugins/spec-guard/index.d.ts +49 -18
  104. package/dist/plugins/spec-guard/index.js +231 -129
  105. package/dist/plugins/spec-guard/index.js.map +1 -1
  106. package/dist/plugins/system-context-injection/index.d.ts +10 -4
  107. package/dist/plugins/system-context-injection/index.js +271 -78
  108. package/dist/plugins/system-context-injection/index.js.map +1 -1
  109. package/dist/plugins/tool-history-compaction/index.d.ts +26 -4
  110. package/dist/plugins/tool-history-compaction/index.js +170 -32
  111. package/dist/plugins/tool-history-compaction/index.js.map +1 -1
  112. package/dist/plugins/tool-history-compaction/transform.d.ts +47 -16
  113. package/dist/plugins/tool-history-compaction/transform.js +173 -55
  114. package/dist/plugins/tool-history-compaction/transform.js.map +1 -1
  115. package/dist/plugins/web-tools/fetch-service.d.ts +51 -13
  116. package/dist/plugins/web-tools/fetch-service.js +106 -75
  117. package/dist/plugins/web-tools/fetch-service.js.map +1 -1
  118. package/dist/plugins/web-tools/index.d.ts +58 -16
  119. package/dist/plugins/web-tools/index.js +202 -91
  120. package/dist/plugins/web-tools/index.js.map +1 -1
  121. package/dist/plugins/web-tools/media-loader.d.ts +3 -3
  122. package/dist/plugins/web-tools/media-loader.js +3 -3
  123. package/dist/plugins/web-tools/media-loader.js.map +1 -1
  124. package/dist/plugins/web-tools/providers/native-fetch.d.ts +2 -2
  125. package/dist/plugins/web-tools/providers/native-fetch.js +1 -1
  126. package/dist/plugins/web-tools/providers/native-fetch.js.map +1 -1
  127. package/dist/plugins/web-tools/providers/spider.d.ts +2 -2
  128. package/dist/plugins/web-tools/providers/spider.js +1 -1
  129. package/dist/plugins/web-tools/providers/spider.js.map +1 -1
  130. package/dist/plugins/web-tools/providers/zai.d.ts +2 -2
  131. package/dist/plugins/web-tools/providers/zai.js +1 -1
  132. package/dist/plugins/web-tools/providers/zai.js.map +1 -1
  133. package/dist/plugins/web-tools/schemas.d.ts +1 -1
  134. package/dist/plugins/web-tools/schemas.js +3 -3
  135. package/dist/plugins/web-tools/schemas.js.map +1 -1
  136. package/dist/plugins/web-tools/search-service.d.ts +81 -12
  137. package/dist/plugins/web-tools/search-service.js +104 -57
  138. package/dist/plugins/web-tools/search-service.js.map +1 -1
  139. package/dist/plugins/workflow/authorization.d.ts +44 -10
  140. package/dist/plugins/workflow/authorization.js +113 -73
  141. package/dist/plugins/workflow/authorization.js.map +1 -1
  142. package/dist/plugins/workflow/cancellation.d.ts +86 -0
  143. package/dist/plugins/workflow/cancellation.js +202 -0
  144. package/dist/plugins/workflow/cancellation.js.map +1 -0
  145. package/dist/plugins/workflow/checkpoints.d.ts +7 -1
  146. package/dist/plugins/workflow/checkpoints.js +141 -21
  147. package/dist/plugins/workflow/checkpoints.js.map +1 -1
  148. package/dist/plugins/workflow/delegated.d.ts +14 -0
  149. package/dist/plugins/workflow/delegated.js +6 -5
  150. package/dist/plugins/workflow/delegated.js.map +1 -1
  151. package/dist/plugins/workflow/host.d.ts +81 -0
  152. package/dist/plugins/workflow/host.js +189 -0
  153. package/dist/plugins/workflow/host.js.map +1 -0
  154. package/dist/plugins/workflow/index.d.ts +69 -4
  155. package/dist/plugins/workflow/index.js +1391 -1026
  156. package/dist/plugins/workflow/index.js.map +1 -1
  157. package/dist/plugins/workflow/recovery.d.ts +3 -5
  158. package/dist/plugins/workflow/recovery.js +18 -33
  159. package/dist/plugins/workflow/recovery.js.map +1 -1
  160. package/dist/plugins/workflow/repair.d.ts +31 -5
  161. package/dist/plugins/workflow/repair.js +116 -48
  162. package/dist/plugins/workflow/repair.js.map +1 -1
  163. package/dist/plugins/workflow/results.d.ts +31 -31
  164. package/dist/plugins/workflow/results.js +4 -4
  165. package/dist/plugins/workflow/results.js.map +1 -1
  166. package/dist/plugins/workflow/schemas.d.ts +3 -3
  167. package/dist/plugins/workflow/schemas.js +5 -5
  168. package/dist/plugins/workflow/schemas.js.map +1 -1
  169. package/dist/plugins/workflow/system-instruction.md +4 -0
  170. package/dist/plugins/workflow/tooling.d.ts +6 -0
  171. package/dist/plugins/workflow/tooling.js +3 -1
  172. package/dist/plugins/workflow/tooling.js.map +1 -1
  173. package/dist/runtime/auxiliary.d.ts +13 -0
  174. package/dist/runtime/auxiliary.js +108 -0
  175. package/dist/runtime/auxiliary.js.map +1 -0
  176. package/dist/runtime/client.d.ts +88 -0
  177. package/dist/runtime/client.js +174 -0
  178. package/dist/runtime/client.js.map +1 -0
  179. package/dist/runtime/context-inspection-contract.d.ts +397 -0
  180. package/dist/runtime/context-inspection-contract.js +622 -0
  181. package/dist/runtime/context-inspection-contract.js.map +1 -0
  182. package/dist/runtime/context-inspection.d.ts +52 -0
  183. package/dist/runtime/context-inspection.js +324 -0
  184. package/dist/runtime/context-inspection.js.map +1 -0
  185. package/dist/runtime/context.d.ts +192 -0
  186. package/dist/runtime/context.js +1246 -0
  187. package/dist/runtime/context.js.map +1 -0
  188. package/dist/runtime/coordination.d.ts +40 -0
  189. package/dist/runtime/coordination.js +87 -0
  190. package/dist/runtime/coordination.js.map +1 -0
  191. package/dist/runtime/model-registry.d.ts +34 -0
  192. package/dist/runtime/model-registry.js +227 -0
  193. package/dist/runtime/model-registry.js.map +1 -0
  194. package/dist/runtime/permissions.d.ts +20 -0
  195. package/dist/runtime/permissions.js +250 -0
  196. package/dist/runtime/permissions.js.map +1 -0
  197. package/dist/runtime/snapshot-config.d.ts +80 -0
  198. package/dist/runtime/snapshot-config.js +268 -0
  199. package/dist/runtime/snapshot-config.js.map +1 -0
  200. package/dist/runtime/snapshot-store.d.ts +25 -0
  201. package/dist/runtime/snapshot-store.js +519 -0
  202. package/dist/runtime/snapshot-store.js.map +1 -0
  203. package/dist/runtime/snapshots.d.ts +59 -0
  204. package/dist/runtime/snapshots.js +721 -0
  205. package/dist/runtime/snapshots.js.map +1 -0
  206. package/dist/runtime/types.d.ts +713 -0
  207. package/dist/runtime/types.js +190 -0
  208. package/dist/runtime/types.js.map +1 -0
  209. package/dist/tui/analytics/indicator.d.ts +25 -26
  210. package/dist/tui/analytics/indicator.js +66 -74
  211. package/dist/tui/analytics/indicator.js.map +1 -1
  212. package/dist/tui/branding/footer.d.ts +7 -12
  213. package/dist/tui/branding/footer.js +16 -24
  214. package/dist/tui/branding/footer.js.map +1 -1
  215. package/dist/tui/context/analyze.d.ts +20 -9
  216. package/dist/tui/context/analyze.js +295 -257
  217. package/dist/tui/context/analyze.js.map +1 -1
  218. package/dist/tui/context/collect.d.ts +29 -3
  219. package/dist/tui/context/collect.js +450 -66
  220. package/dist/tui/context/collect.js.map +1 -1
  221. package/dist/tui/context/plugin.d.ts +21 -7
  222. package/dist/tui/context/plugin.js +65 -70
  223. package/dist/tui/context/plugin.js.map +1 -1
  224. package/dist/tui/context/types.d.ts +174 -43
  225. package/dist/tui/context/types.js +25 -19
  226. package/dist/tui/context/types.js.map +1 -1
  227. package/dist/tui/context/view.d.ts +33 -7
  228. package/dist/tui/context/view.js +136 -81
  229. package/dist/tui/context/view.js.map +1 -1
  230. package/dist/tui/peak-hours/banner.d.ts +13 -11
  231. package/dist/tui/peak-hours/banner.js +48 -80
  232. package/dist/tui/peak-hours/banner.js.map +1 -1
  233. package/dist/tui/policy.d.ts +69 -0
  234. package/dist/tui/policy.js +169 -0
  235. package/dist/tui/policy.js.map +1 -0
  236. package/dist/tui.d.ts +3 -8
  237. package/dist/tui.js +72 -68
  238. package/dist/tui.js.map +1 -1
  239. package/package.json +18 -14
  240. package/schemas/vvoc/v3.json +1 -1
  241. package/server.js +3 -5
  242. package/templates/agents/enhancer.md +10 -5
  243. package/templates/agents/guardian.md +10 -4
  244. package/templates/agents/investigator.md +4 -2
  245. package/templates/agents/vv-code-reviewer.md +4 -2
  246. package/templates/agents/vv-spec-reviewer.md +4 -2
  247. package/templates/skills/vv-execute/references/tool-contracts.md +1 -1
  248. package/tui.js +3 -5
  249. package/dist/plugins/analytics/v2.d.ts +0 -21
  250. package/dist/plugins/analytics/v2.js +0 -133
  251. package/dist/plugins/analytics/v2.js.map +0 -1
  252. package/dist/plugins/guardian/v2.d.ts +0 -13
  253. package/dist/plugins/guardian/v2.js +0 -204
  254. package/dist/plugins/guardian/v2.js.map +0 -1
  255. package/dist/plugins/hashline-edit/v2.d.ts +0 -12
  256. package/dist/plugins/hashline-edit/v2.js +0 -145
  257. package/dist/plugins/hashline-edit/v2.js.map +0 -1
  258. package/dist/plugins/model-roles/v2.d.ts +0 -24
  259. package/dist/plugins/model-roles/v2.js +0 -274
  260. package/dist/plugins/model-roles/v2.js.map +0 -1
  261. package/dist/plugins/peak-hours/v2.d.ts +0 -12
  262. package/dist/plugins/peak-hours/v2.js +0 -99
  263. package/dist/plugins/peak-hours/v2.js.map +0 -1
  264. package/dist/plugins/secrets-redaction/v2.d.ts +0 -19
  265. package/dist/plugins/secrets-redaction/v2.js +0 -138
  266. package/dist/plugins/secrets-redaction/v2.js.map +0 -1
  267. package/dist/plugins/spec-guard/v2.d.ts +0 -12
  268. package/dist/plugins/spec-guard/v2.js +0 -139
  269. package/dist/plugins/spec-guard/v2.js.map +0 -1
  270. package/dist/plugins/system-context-injection/agent-contexts.d.ts +0 -5
  271. package/dist/plugins/system-context-injection/agent-contexts.js +0 -164
  272. package/dist/plugins/system-context-injection/agent-contexts.js.map +0 -1
  273. package/dist/plugins/system-context-injection/v2.d.ts +0 -13
  274. package/dist/plugins/system-context-injection/v2.js +0 -60
  275. package/dist/plugins/system-context-injection/v2.js.map +0 -1
  276. package/dist/plugins/tool-history-compaction/v2.d.ts +0 -11
  277. package/dist/plugins/tool-history-compaction/v2.js +0 -56
  278. package/dist/plugins/tool-history-compaction/v2.js.map +0 -1
  279. package/dist/plugins/v2-runtime/config-watcher.d.ts +0 -26
  280. package/dist/plugins/v2-runtime/config-watcher.js +0 -111
  281. package/dist/plugins/v2-runtime/config-watcher.js.map +0 -1
  282. package/dist/plugins/v2-runtime/index.d.ts +0 -50
  283. package/dist/plugins/v2-runtime/index.js +0 -114
  284. package/dist/plugins/v2-runtime/index.js.map +0 -1
  285. package/dist/plugins/v2-runtime/location-config.d.ts +0 -51
  286. package/dist/plugins/v2-runtime/location-config.js +0 -91
  287. package/dist/plugins/v2-runtime/location-config.js.map +0 -1
  288. package/dist/plugins/v2-runtime/setup.d.ts +0 -48
  289. package/dist/plugins/v2-runtime/setup.js +0 -174
  290. package/dist/plugins/v2-runtime/setup.js.map +0 -1
  291. package/dist/plugins/web-tools/v2.d.ts +0 -11
  292. package/dist/plugins/web-tools/v2.js +0 -99
  293. package/dist/plugins/web-tools/v2.js.map +0 -1
  294. package/dist/plugins/workflow/v2.d.ts +0 -76
  295. package/dist/plugins/workflow/v2.js +0 -283
  296. package/dist/plugins/workflow/v2.js.map +0 -1
@@ -0,0 +1,190 @@
1
+ // FILE: src/runtime/types.ts
2
+ // VERSION: 1.0.0
3
+ // START_MODULE_CONTRACT
4
+ // PURPOSE: Define the shared native runtime vocabulary: the exact supported host version, the structural plugin-context seam, lazy full-client/dependency interfaces, resource-permission request/decision types, and the durable family-snapshot/model-capture/admission/auxiliary contracts consumed by later native plugins.
5
+ // SCOPE: Type-only native contracts plus pure location/identity/key helpers and error constructors. No service discovery, authentication, RPC registration, permission flow, snapshot persistence, filesystem, or network I/O.
6
+ // DEPENDS: [@opencode/plugin, @opencode/client, @opencode/schema/agent, @opencode/schema/location, @opencode/schema/permission, @opencode/schema/rpc, @opencode/schema/session]
7
+ // LINKS: [M-NATIVE-RUNTIME, V-M-NATIVE-RUNTIME]
8
+ // ROLE: TYPES
9
+ // MAP_MODE: EXPORTS
10
+ // END_MODULE_CONTRACT
11
+ //
12
+ // START_MODULE_MAP
13
+ // SUPPORTED_SERVICE_VERSION - Exact native OpenCode service version this runtime is compatible with.
14
+ // RuntimeLocation - Structural subset of Location.Info the runtime needs for identity and routing.
15
+ // RuntimeIdentity - Stable per-location identity used to share one runtime inside a host.
16
+ // RuntimeRpcRegistration - Releasable native RPC registration handle.
17
+ // RuntimeRpcRegistrar - Narrow structural view of the native plugin context RPC registrar.
18
+ // RuntimeContext - Narrow structural view of a native Plugin.Context used to acquire a runtime.
19
+ // RuntimeRpcCallOptions - Location and cancellation options for an authenticated client RPC call.
20
+ // RuntimeRpcMethods - Method map projected from a portable RPC definition.
21
+ // RuntimeRpcClient - Callable projection of an authenticated native client RPC.
22
+ // RuntimeEvent - Structural native event envelope.
23
+ // RuntimeEventApi - Structural native live-event subscription API.
24
+ // RuntimePermissionApi - Structural native session permission create/get/reply API.
25
+ // RuntimeClient - Structural subset of the native client used by the runtime foundation.
26
+ // RuntimeEndpoint - Native local-service endpoint handed to a full client.
27
+ // RuntimeDeps - Injectable native boundary: discovery, auth headers, and full-client construction.
28
+ // ResourcePermissionRequest - Resource-specific permission request passed to the native host.
29
+ // PermissionDecision - Terminal permission decision: allow or deny.
30
+ // PermissionRequestOptions - Cancellation and bounded-readiness options for an awaited permission decision.
31
+ // PermissionService - Awaited resource permission service consumed before side effects.
32
+ // NativeRuntime - Shared lifecycle-managed native runtime exposed to later plugins.
33
+ // RuntimeLease - Per-acquisition idempotent release handle for a shared runtime.
34
+ // RuntimeUnavailableError - No compatible already-running service could be discovered.
35
+ // RuntimeChallengeError - The discovered service did not prove the loading plugin instance.
36
+ // RuntimeDisposedError - The runtime was released and can no longer serve work.
37
+ // PERMISSION_REPLIED_EVENT - Native event type carrying a terminal permission reply.
38
+ // SERVER_CONNECTED_EVENT - Native event proving the live event transport finished its handshake.
39
+ // ModelSelection - Concrete native provider/model/variant selection.
40
+ // ModelVariantCapture - Persisted model variant overlay materialized as a native variant.
41
+ // CapturedVvocConfig - Opaque deep-copied effective vvoc configuration captured for replay.
42
+ // CapturedModelSettings - Captured native model/provider overlay needed to replay a request payload.
43
+ // CaptureIntent - Explicit/implicit/staged provenance of a captured selection.
44
+ // CaptureIntentMode - Capture selection provenance mode.
45
+ // CaptureIntentSource - Native source that produced a captured selection.
46
+ // PermissionCreateInput - Minimal input accepted by the native permission create call.
47
+ // AgentPolicyBinding - Captured agent-to-role and resolved-model binding.
48
+ // FamilyCapture - Durable immutable policy/model capture bound to one session family.
49
+ // StagedCandidate - Persisted pre-dispatch admission candidate.
50
+ // SnapshotAcceptRequest - Correlated acceptance input for committing a staged candidate.
51
+ // SnapshotOwnedAdmissionRequest - Owned generated-work admission request carrying a runtime-minted operation token.
52
+ // SnapshotStore - Durable per-family capture and staged-candidate persistence contract.
53
+ // stagedCandidateKey - Stable identity of one staged candidate within a family.
54
+ // stagedCandidateIdentity - Stable candidate identity from its raw owner fields.
55
+ // AcceptedInput - One native accepted input with ordering signals for first-accepted selection.
56
+ // AcceptedInputReconciliation - Accepted inputs for a session plus whether the durable replay was complete.
57
+ // NativeSessionView - Structural native session view used for host-verified lineage.
58
+ // ModelEditorLike - Structural native model transform editor used for variant materialization.
59
+ // AgentEditorLike - Structural native agent transform editor used for snapshot-bound role selection.
60
+ // VariantRegistration - Snapshot-qualified variant to publish on one real provider/model.
61
+ // AdmissionOutcome - Result of one awaited family admission attempt.
62
+ // EffectiveRuntimeConfig - Structural effective vvoc policy input to the snapshot service.
63
+ // SnapshotAdmissionRequest - Per-workload admission request.
64
+ // SnapshotService - Documented snapshot/config/model/auxiliary service consumed by later plugins.
65
+ // SnapshotLease - Per-acquisition release handle for a shared snapshot service.
66
+ // AuxiliaryMessageContent - Text carried by a native title request as generation input.
67
+ // AuxiliarySessionApi - Structural native child-session/generate boundary for auxiliary work.
68
+ // AuxiliaryWorkloadMetadata - Host-owned auxiliary workload metadata recorded on a child session.
69
+ // decodeAuxiliaryMetadata - Decode the auxiliary workload metadata from native session metadata.
70
+ // NativeSessionImportPayload - Typed payload forwarded to the native import route for a parented auxiliary child.
71
+ // decodeImportedSessionID - Decode the id of an imported native session from the unchecked client result.
72
+ // AuxiliaryService - Snapshot-bound auxiliary generation consumed by title and Guardian.
73
+ // SnapshotStoreError - Durable capture state was corrupt or unreadable, so work must fail closed.
74
+ // SnapshotAdmissionError - An awaited admission failed and no policy was published.
75
+ // SnapshotUnboundError - A dispatch was refused because no family policy was bound.
76
+ // runtimeIdentity - Build the stable identity from a runtime location.
77
+ // runtimeKey - Render a deterministic location identity string for diagnostics.
78
+ // END_MODULE_MAP
79
+ //
80
+ // START_CHANGE_SUMMARY
81
+ // LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-009 - Added the immutable caller-supplied admission config to SnapshotAdmissionRequest and the native app coordination identity to RuntimeContext.]
82
+ // PREVIOUS: [C-OPENCODE-V2-NATIVE T-002 attempt 7 - Added the per-input candidate store contract, accepted-input ordering/source vocabulary, owned-operation identity, and the imported parented auxiliary session seam.]
83
+ // END_CHANGE_SUMMARY
84
+ /** Exact native host version this runtime authenticates against; the pinned host is 2.0.18. */
85
+ export const SUPPORTED_SERVICE_VERSION = "2.0.18";
86
+ /** Native event type carrying a terminal permission reply. */
87
+ export const PERMISSION_REPLIED_EVENT = "permission.replied";
88
+ /** Native event proving the live event transport finished its handshake. */
89
+ export const SERVER_CONNECTED_EVENT = "server.connected";
90
+ /** No compatible already-running service could be discovered. */
91
+ export class RuntimeUnavailableError extends Error {
92
+ code = "RUNTIME_UNAVAILABLE";
93
+ constructor() {
94
+ super(`No compatible OpenCode ${SUPPORTED_SERVICE_VERSION} service is registered for this plugin instance.`);
95
+ this.name = "RuntimeUnavailableError";
96
+ }
97
+ }
98
+ /** The discovered service did not prove the loading plugin instance and location. */
99
+ export class RuntimeChallengeError extends Error {
100
+ code = "RUNTIME_CHALLENGE_FAILED";
101
+ constructor(reason, options) {
102
+ super(`Native runtime challenge failed: ${reason}. The discovered service is not this loading plugin instance.`, options);
103
+ this.name = "RuntimeChallengeError";
104
+ }
105
+ }
106
+ /** The runtime was released and can no longer serve work. */
107
+ export class RuntimeDisposedError extends Error {
108
+ code = "RUNTIME_DISPOSED";
109
+ constructor() {
110
+ super("The native runtime has been released.");
111
+ this.name = "RuntimeDisposedError";
112
+ }
113
+ }
114
+ /** Stable identity of one staged candidate within a family. */
115
+ export function stagedCandidateIdentity(input) {
116
+ return [input.sessionID, input.inboxID ?? "", input.operationID ?? "", input.workload ?? ""].join("\u0000");
117
+ }
118
+ /** Stable identity of one staged candidate within a family. */
119
+ export function stagedCandidateKey(candidate) {
120
+ return stagedCandidateIdentity(candidate);
121
+ }
122
+ /** Decode the auxiliary workload metadata embedded in native session metadata. */
123
+ export function decodeAuxiliaryMetadata(metadata) {
124
+ if (metadata === undefined)
125
+ return undefined;
126
+ const raw = metadata["vvocAuxiliary"];
127
+ if (typeof raw !== "object" || raw === null)
128
+ return undefined;
129
+ const record = raw;
130
+ const kind = record.kind;
131
+ if (kind !== "title" && kind !== "compaction" && kind !== "generate")
132
+ return undefined;
133
+ const role = record.role;
134
+ if (role !== undefined && typeof role !== "string")
135
+ return undefined;
136
+ return { kind, ...(role === undefined ? {} : { role }) };
137
+ }
138
+ /** Decode the id of an imported native session from the unchecked client result. */
139
+ export function decodeImportedSessionID(value) {
140
+ if (typeof value !== "object" || value === null)
141
+ return undefined;
142
+ const id = value.id;
143
+ return typeof id === "string" && id.length > 0 ? id : undefined;
144
+ }
145
+ /** Durable capture state was corrupt or unreadable, so work must fail closed. */
146
+ export class SnapshotStoreError extends Error {
147
+ code = "SNAPSHOT_STORE_INVALID";
148
+ constructor(message, options) {
149
+ super(message, options);
150
+ this.name = "SnapshotStoreError";
151
+ }
152
+ }
153
+ /** An awaited admission failed and no policy was published. */
154
+ export class SnapshotAdmissionError extends Error {
155
+ code = "SNAPSHOT_ADMISSION_FAILED";
156
+ constructor(message, options) {
157
+ super(message, options);
158
+ this.name = "SnapshotAdmissionError";
159
+ }
160
+ }
161
+ /** A dispatch was refused because no family policy was bound. */
162
+ export class SnapshotUnboundError extends Error {
163
+ code = "SNAPSHOT_UNBOUND";
164
+ constructor(message = "No family snapshot is bound for this workload.") {
165
+ super(message);
166
+ this.name = "SnapshotUnboundError";
167
+ }
168
+ }
169
+ // END_BLOCK_SNAPSHOT_VOCABULARY
170
+ // START_BLOCK_IDENTITY_HELPERS
171
+ /** Build the stable identity from a runtime location. */
172
+ export function runtimeIdentity(location) {
173
+ return {
174
+ directory: location.directory,
175
+ ...(location.workspaceID === undefined ? {} : { workspaceID: location.workspaceID }),
176
+ projectID: location.project.id,
177
+ canonical: location.project.canonical,
178
+ };
179
+ }
180
+ /** Render a deterministic location identity string for diagnostics. */
181
+ export function runtimeKey(identity) {
182
+ return [
183
+ identity.directory,
184
+ identity.workspaceID ?? "",
185
+ identity.projectID,
186
+ identity.canonical,
187
+ ].join("\u0000");
188
+ }
189
+ // END_BLOCK_IDENTITY_HELPERS
190
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.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"@opentui/core";
3
- import type { TuiPluginApi } from "@opencode-ai/plugin/tui";
4
- import type { PluginOptions } from "@opencode-ai/plugin";
5
- import type { IndicatorTokens } from "../../lib/analytics/types.js";
6
- /** Structural step-finish shape accepted from either SDK generation. */
7
- export type StepFinishLike = {
8
- type: string;
9
- tokens?: {
10
- input?: unknown;
11
- cache?: {
12
- read?: unknown;
13
- write?: unknown;
14
- };
15
- };
3
+ import type { Plugin } from "@opencode/plugin/tui";
4
+ import type { ContextPolicySnapshot } from "../policy.js";
5
+ export type IndicatorTokens = {
6
+ steps: number;
7
+ eligibleSteps: number;
8
+ cacheRead: number;
9
+ cacheWrite: number;
10
+ input: number;
16
11
  };
17
12
  export type IndicatorLabel = {
18
13
  text: string;
19
14
  tone: "muted" | "red" | "yellow" | "green";
20
15
  };
21
- export type IndicatorDependencies = {
22
- enabled: (api: TuiPluginApi) => Promise<boolean>;
23
- /** Renders the label node; defaults to the themed text element. */
16
+ /** Structural native usage payload accepted by the accumulator. */
17
+ export type IndicatorUsageLike = {
18
+ input?: unknown;
19
+ cache?: {
20
+ read?: unknown;
21
+ write?: unknown;
22
+ } | undefined;
23
+ };
24
+ export type AnalyticsIndicatorDependencies = {
25
+ isEnabled: () => boolean;
24
26
  renderLabel: (label: IndicatorLabel, color: RGBA) => JSX.Element;
25
27
  };
26
- export declare const DEFAULT_DEPENDENCIES: IndicatorDependencies;
27
- /** Rolling per-session sums fed by step-finish parts. Same eligibility rule as metrics. */
28
+ /** Rolling per-session sums fed by native usage events. */
28
29
  export declare function createIndicatorAccumulator(): {
29
- applyPart(part: StepFinishLike): void;
30
+ applyUsage(usage: IndicatorUsageLike): void;
30
31
  get(): IndicatorTokens;
31
32
  };
32
33
  /** Label and tone for the current state; muted "cache n/a" until the first eligible step. */
33
34
  export declare function indicatorLabel(state: IndicatorTokens): IndicatorLabel;
34
35
  /**
35
- * Registers the live indicator for the current session route.
36
- * Disabled toggle or options.enabled === false: returns without subscribing or
37
- * registering. Subscribes to message.part.updated (session-filtered), renders
38
- * through the "session_prompt_right" host slot, and cleans up the subscription
39
- * via api.lifecycle.onDispose. Slot registration failures disable the visual
40
- * element silently for the session.
36
+ * Register the live indicator for the active session in the native
37
+ * `prompt.footer.status` slot (the native placement for the old
38
+ * `session_prompt_right` slot). Disabled policy: no subscription and no slot.
39
+ * Returns a disposer that unsubscribes and removes the claim.
41
40
  */
42
- export declare function registerAnalyticsIndicator(api: TuiPluginApi, options?: PluginOptions, dependencies?: IndicatorDependencies): Promise<void>;
41
+ export declare function registerAnalyticsIndicator(ctx: Plugin.Context, policy: () => ContextPolicySnapshot | undefined, options: Readonly<Record<string, unknown>> | undefined, dependencies?: Partial<AnalyticsIndicatorDependencies>): () => void;
@@ -1,19 +1,8 @@
1
- import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
2
- import { loadVvocConfigForRead } from "../../lib/config-layers.js";
3
- import { isVvocPluginEnabled } from "../../lib/plugin-toggle-config.js";
4
- export const DEFAULT_DEPENDENCIES = {
5
- enabled: async (api) => {
6
- const vvoc = await loadVvocConfigForRead({
7
- scope: "effective",
8
- allowDefault: true,
9
- cwd: api.state.path.directory,
10
- });
11
- return isVvocPluginEnabled(vvoc.config, "analytics");
12
- },
13
- renderLabel: (label, color) => (_jsx("text", { children: _jsx("span", { style: { fg: color }, children: label.text }) })),
14
- };
1
+ import { jsx as _jsx, Fragment as _Fragment } from "@opentui/solid/jsx-runtime";
2
+ import { createSignal } from "solid-js";
3
+ import { policyAnalyticsEnabled } from "../policy.js";
15
4
  // START_BLOCK_INDICATOR_ACCUMULATOR
16
- /** Rolling per-session sums fed by step-finish parts. Same eligibility rule as metrics. */
5
+ /** Rolling per-session sums fed by native usage events. */
17
6
  export function createIndicatorAccumulator() {
18
7
  let state = {
19
8
  steps: 0,
@@ -23,18 +12,15 @@ export function createIndicatorAccumulator() {
23
12
  input: 0,
24
13
  };
25
14
  return {
26
- applyPart(part) {
27
- if (part.type !== "step-finish")
28
- return;
29
- const tokens = (part.tokens ?? {});
30
- const cacheRead = toCount(tokens.cache?.read);
31
- const cacheWrite = toCount(tokens.cache?.write);
15
+ applyUsage(usage) {
16
+ const cacheRead = toCount(usage.cache?.read);
17
+ const cacheWrite = toCount(usage.cache?.write);
32
18
  state = {
33
19
  steps: state.steps + 1,
34
20
  eligibleSteps: state.eligibleSteps + (cacheRead + cacheWrite > 0 ? 1 : 0),
35
21
  cacheRead: state.cacheRead + cacheRead,
36
22
  cacheWrite: state.cacheWrite + cacheWrite,
37
- input: state.input + toCount(tokens.input),
23
+ input: state.input + toCount(usage.input),
38
24
  };
39
25
  },
40
26
  get: () => state,
@@ -55,68 +41,74 @@ function toCount(value) {
55
41
  // END_BLOCK_INDICATOR_ACCUMULATOR
56
42
  // START_BLOCK_REGISTER_INDICATOR
57
43
  /**
58
- * Registers the live indicator for the current session route.
59
- * Disabled toggle or options.enabled === false: returns without subscribing or
60
- * registering. Subscribes to message.part.updated (session-filtered), renders
61
- * through the "session_prompt_right" host slot, and cleans up the subscription
62
- * via api.lifecycle.onDispose. Slot registration failures disable the visual
63
- * element silently for the session.
44
+ * Register the live indicator for the active session in the native
45
+ * `prompt.footer.status` slot (the native placement for the old
46
+ * `session_prompt_right` slot). Disabled policy: no subscription and no slot.
47
+ * Returns a disposer that unsubscribes and removes the claim.
64
48
  */
65
- export async function registerAnalyticsIndicator(api, options, dependencies = DEFAULT_DEPENDENCIES) {
49
+ export function registerAnalyticsIndicator(ctx, policy, options, dependencies) {
66
50
  if (options?.enabled === false)
67
- return;
68
- if (!(await dependencies.enabled(api)))
69
- return;
70
- const accumulator = createIndicatorAccumulator();
71
- const unsubscribe = api.event.on("message.part.updated", (event) => {
72
- const sessionID = currentSessionID(api);
73
- if (event.properties.part.sessionID === sessionID) {
74
- accumulator.applyPart(event.properties.part);
51
+ return () => undefined;
52
+ const deps = {
53
+ isEnabled: () => policyAnalyticsEnabled(policy()),
54
+ renderLabel: (label, color) => (_jsx("text", { children: _jsx("span", { style: { fg: color }, children: label.text }) })),
55
+ ...dependencies,
56
+ };
57
+ // The slot is claimed even while the policy is still loading, so the
58
+ // indicator appears as soon as an allowlisted policy enables analytics
59
+ // without needing a plugin reload. Rendering stays policy-gated below.
60
+ const accumulators = new Map();
61
+ const [tokensBySession, setTokensBySession] = createSignal({});
62
+ const unsubscribe = ctx.data.on("session.usage.updated", (event) => {
63
+ const sessionID = event.data.sessionID;
64
+ let accumulator = accumulators.get(sessionID);
65
+ if (accumulator === undefined) {
66
+ accumulator = createIndicatorAccumulator();
67
+ accumulators.set(sessionID, accumulator);
75
68
  }
69
+ accumulator.applyUsage({
70
+ input: event.data.tokens.input,
71
+ cache: { read: event.data.tokens.cache.read, write: event.data.tokens.cache.write },
72
+ });
73
+ setTokensBySession((prev) => ({ ...prev, [sessionID]: accumulator.get() }));
76
74
  });
77
- api.lifecycle.onDispose(unsubscribe);
75
+ let unregister;
78
76
  try {
79
- // OpenCode's runtime requires a string plugin id on slot registrations, while
80
- // the SDK's TuiSlotPlugin type still types id as never; cast bridges the two.
81
- const plugin = {
82
- id: "vvoc-analytics-indicator",
83
- order: 900,
84
- slots: {
85
- session_prompt_right: (_ctx, props) => {
86
- if (props.session_id !== currentSessionID(api))
87
- return undefined;
88
- const label = indicatorLabel(accumulator.get());
89
- if (label.tone === "muted")
90
- return undefined;
91
- return dependencies.renderLabel(label, toneColor(api, label.tone));
92
- },
77
+ unregister = ctx.ui.slot({
78
+ append: "prompt.footer.status",
79
+ render: (input) => {
80
+ if (!deps.isEnabled())
81
+ return _jsx(_Fragment, {});
82
+ const sessionID = input.sessionID;
83
+ if (sessionID === undefined)
84
+ return _jsx(_Fragment, {});
85
+ const tokens = tokensBySession()[sessionID];
86
+ if (tokens === undefined)
87
+ return _jsx(_Fragment, {});
88
+ const label = indicatorLabel(tokens);
89
+ if (label.tone === "muted")
90
+ return _jsx(_Fragment, {});
91
+ return deps.renderLabel(label, toneColor(ctx, label.tone));
93
92
  },
94
- };
95
- api.slots.register(plugin);
93
+ });
96
94
  }
97
95
  catch {
98
96
  // Fail-soft: no indicator for this session.
99
97
  }
98
+ return () => {
99
+ unsubscribe();
100
+ unregister?.();
101
+ };
100
102
  }
101
- /** Reads the currently open sessionID from the TUI route, or "". */
102
- function currentSessionID(api) {
103
- const route = api.route.current;
104
- if (route.name === "session" && "params" in route) {
105
- const sessionID = route.params?.sessionID;
106
- return typeof sessionID === "string" ? sessionID : "";
107
- }
108
- return "";
109
- }
110
- /** Maps an indicator tone to the theme RGBA color instance. */
111
- function toneColor(api, tone) {
112
- const theme = api.theme.current;
113
- const rgba = tone === "green"
114
- ? theme.success
115
- : tone === "yellow"
116
- ? theme.warning
117
- : tone === "red"
118
- ? theme.error
119
- : theme.textMuted;
120
- return rgba;
103
+ /** Maps an indicator tone to a native theme feedback color. */
104
+ function toneColor(ctx, tone) {
105
+ const feedback = ctx.theme.text.feedback;
106
+ if (tone === "green")
107
+ return feedback.success.base;
108
+ if (tone === "yellow")
109
+ return feedback.warning.base;
110
+ if (tone === "red")
111
+ return feedback.error.base;
112
+ return ctx.theme.text.muted;
121
113
  }
122
114
  //# sourceMappingURL=indicator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"indicator.js","sourceRoot":"","sources":["../../../src/tui/analytics/indicator.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAoBxE,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IACzD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC;YACvC,KAAK,EAAE,WAAW;YAClB,YAAY,EAAE,IAAI;YAClB,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS;SAC9B,CAAC,CAAC;QACH,OAAO,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvD,CA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IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;IACnD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;IACpD,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;IAC/C,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AAC9B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { JSX } from "@opentui/solid";
2
2
  import type { RGBA } from "@opentui/core";
3
- import type { TuiPluginApi } from "@opencode-ai/plugin/tui";
3
+ import type { Plugin } from "@opencode/plugin/tui";
4
4
  export type BrandingVersionInfo = {
5
5
  opencodeVersion: string;
6
6
  vvocLabel: string;
@@ -11,20 +11,15 @@ export type BrandingColors = {
11
11
  text: RGBA;
12
12
  };
13
13
  export type BrandingDependencies = {
14
- /** Renders the combined version line; defaults to the native-looking OpenCode footer line extended with the vvoc label. */
14
+ /** Renders the combined version line; defaults to the native-looking footer line extended with the vvoc label. */
15
15
  renderLabel: (info: BrandingVersionInfo, colors: BrandingColors) => JSX.Element;
16
16
  };
17
- /** The vvoc label text, e.g. "vvoc v1.2.11". */
17
+ /** The vvoc label text, e.g. "vvoc v1.7.0". */
18
18
  export declare function brandingFooterLabel(): string;
19
19
  /**
20
- * Registers the combined version line in the "sidebar_footer" host slot.
21
- *
22
- * sidebar_footer renders in single_winner mode: only the first registered
23
- * plugin (lowest order) is displayed. OpenCode's internal footer registers
24
- * with order 100; this plugin uses order 50 so it deterministically wins the
25
- * slot and renders the stock-looking footer line extended with the vvoc
26
- * version ("• OpenCode <oc> · vvoc v<x>"). Always on (independent of analytics
27
- * config); returns silently when the slot API is unavailable or registration
20
+ * Claim the native `sidebar.footer` slot and render the stock-looking footer
21
+ * line extended with the vvoc version. Always on (independent of analytics
22
+ * config); returns a no-op when the slot API is unavailable or registration
28
23
  * fails.
29
24
  */
30
- export declare function registerBrandingFooter(api: TuiPluginApi, dependencies?: BrandingDependencies): void;
25
+ export declare function registerBrandingFooter(ctx: Plugin.Context, dependencies?: BrandingDependencies): () => void;
@@ -3,42 +3,34 @@ import { getPackageVersionSync } from "../../lib/package.js";
3
3
  const DEFAULT_DEPENDENCIES = {
4
4
  renderLabel: (info, colors) => (_jsxs("text", { fg: colors.muted, children: [_jsx("span", { style: { fg: colors.success }, children: "\u2022" }), " ", _jsx("b", { children: "Open" }), _jsx("span", { style: { fg: colors.text }, children: _jsx("b", { children: "Code" }) }), " ", _jsx("span", { children: info.opencodeVersion }), _jsxs("span", { children: [" \u00B7 ", info.vvocLabel] })] })),
5
5
  };
6
- /** The vvoc label text, e.g. "vvoc v1.2.11". */
6
+ /** The vvoc label text, e.g. "vvoc v1.7.0". */
7
7
  export function brandingFooterLabel() {
8
8
  return `vvoc v${getPackageVersionSync()}`;
9
9
  }
10
10
  // START_BLOCK_REGISTER_BRANDING_FOOTER
11
11
  /**
12
- * Registers the combined version line in the "sidebar_footer" host slot.
13
- *
14
- * sidebar_footer renders in single_winner mode: only the first registered
15
- * plugin (lowest order) is displayed. OpenCode's internal footer registers
16
- * with order 100; this plugin uses order 50 so it deterministically wins the
17
- * slot and renders the stock-looking footer line extended with the vvoc
18
- * version ("• OpenCode <oc> · vvoc v<x>"). Always on (independent of analytics
19
- * config); returns silently when the slot API is unavailable or registration
12
+ * Claim the native `sidebar.footer` slot and render the stock-looking footer
13
+ * line extended with the vvoc version. Always on (independent of analytics
14
+ * config); returns a no-op when the slot API is unavailable or registration
20
15
  * fails.
21
16
  */
22
- export function registerBrandingFooter(api, dependencies = DEFAULT_DEPENDENCIES) {
23
- if (typeof api.slots?.register !== "function")
24
- return;
17
+ export function registerBrandingFooter(ctx, dependencies = DEFAULT_DEPENDENCIES) {
25
18
  try {
26
- // OpenCode's runtime requires a string plugin id on slot registrations, while
27
- // the SDK's TuiSlotPlugin type still types id as never; cast bridges the two.
28
- const plugin = {
29
- id: "vvoc-branding",
30
- order: 50,
31
- slots: {
32
- sidebar_footer: (ctx) => {
33
- const theme = ctx.theme.current;
34
- return dependencies.renderLabel({ opencodeVersion: api.app.version, vvocLabel: brandingFooterLabel() }, { muted: theme.textMuted, success: theme.success, text: theme.text });
35
- },
19
+ return ctx.ui.slot({
20
+ replace: "sidebar.footer",
21
+ render: () => {
22
+ const theme = ctx.theme;
23
+ return dependencies.renderLabel({ opencodeVersion: ctx.app.version, vvocLabel: brandingFooterLabel() }, {
24
+ muted: theme.text.muted,
25
+ success: theme.text.feedback.success.base,
26
+ text: theme.text.base,
27
+ });
36
28
  },
37
- };
38
- api.slots.register(plugin);
29
+ });
39
30
  }
40
31
  catch {
41
32
  // Fail-soft: no combined footer for this session.
33
+ return () => undefined;
42
34
  }
43
35
  }
44
36
  //# sourceMappingURL=footer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../src/tui/branding/footer.tsx"],"names":[],"mappings":";AA0BA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAkB7D,MAAM,oBAAoB,GAAyB;IACjD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAC7B,gBAAM,EAAE,EAAE,MAAM,CAAC,KAAK,aACpB,eAAM,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,uBAAU,OAAC,+BAAW,EACzD,eAAM,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,YAC9B,+BAAW,GACN,EAAC,GAAG,EACX,yBAAO,IAAI,CAAC,eAAe,GAAQ,EACnC,uCAAU,IAAI,CAAC,SAAS,IAAQ,IAC3B,CACR;CACF,CAAC;AAEF,gDAAgD;AAChD,MAAM,UAAU,mBAAmB;IACjC,OAAO,SAAS,qBAAqB,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED,uCAAuC;AACvC;;;;;;;;;;GAUG;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AAC,GAAG,EACX,yBAAO,IAAI,CAAC,eAAe,GAAQ,EACnC,uCAAU,IAAI,CAAC,SAAS,IAAQ,IAC3B,CACR;CACF,CAAC;AAEF,+CAA+C;AAC/C,MAAM,UAAU,mBAAmB;IACjC,OAAO,SAAS,qBAAqB,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED,uCAAuC;AACvC;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAmB,EACnB,eAAqC,oBAAoB;IAEzD,IAAI,CAAC;QACH,OAAO,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;YACjB,OAAO,EAAE,gBAAgB;YACzB,MAAM,EAAE,GAAG,EAAE;gBACX,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACxB,OAAO,YAAY,CAAC,WAAW,CAC7B,EAAE,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,EACtE;oBACE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;oBACvB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI;oBACzC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI;iBACtB,CACF,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,kDAAkD;QAClD,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -1,12 +1,23 @@
1
- import type { Message } from "@opencode-ai/sdk/v2";
2
- import type { ContextAnalysis, ContextAnalysisInput, ContextMcpServer, ContextTokenMetric, ContextToolSource, ContextToolUsage } from "./types.js";
3
- export type ContextToolClassification = {
4
- source: ContextToolSource;
5
- ambiguousServers?: string[];
6
- };
1
+ import type { ContextAnalysis, ContextAnalysisInput, ContextMessage, ContextModelRef, ContextTokenMetric, ContextToolSource, ContextToolUsage } from "./types.js";
7
2
  export declare function analyzeContext(input: ContextAnalysisInput): ContextAnalysis;
8
- export declare function selectActiveMessages(messages: readonly Message[]): readonly Message[];
9
3
  export declare function createTokenMetric(estimatedTokens: number, contextLimit: number | undefined): ContextTokenMetric;
10
- export declare function sanitizeMcpName(value: string): string;
11
- export declare function classifyToolSource(toolID: string, mcpServers: readonly ContextMcpServer[]): ContextToolClassification;
4
+ /**
5
+ * Classify known native built-in and vvoc tools; every other tool is left
6
+ * explicitly unattributed. The registered namespace is a hint only and is never
7
+ * treated as authoritative MCP server provenance.
8
+ */
9
+ export declare function classifyToolSource(tool: {
10
+ effectiveID: string;
11
+ name: string;
12
+ namespace?: string;
13
+ }): ContextToolSource;
12
14
  export declare function compareToolUsage(left: ContextToolUsage, right: ContextToolUsage): number;
15
+ /** Latest completed compaction message with its active-context index. */
16
+ export declare function findCompactionCutoff(messages: readonly ContextMessage[]): {
17
+ readonly message: Extract<ContextMessage, {
18
+ kind: "compaction";
19
+ }>;
20
+ readonly index: number;
21
+ } | undefined;
22
+ /** True when two provider/model/variant references refer to the same real selection. */
23
+ export declare function sameModelRef(left: ContextModelRef, right: ContextModelRef): boolean;