@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,52 @@
1
+ import { type ContextInspectionResult, type ContextInspectionSchemaConverter } from "./context-inspection-contract.js";
2
+ import type { RuntimeLocation, RuntimeRpcRegistrar, RuntimeRpcRegistration } from "./types.js";
3
+ /**
4
+ * Structural native server plugin context accepted by the registration helper.
5
+ * A real server `Plugin.Context` satisfies it; `tool` is optional so a context
6
+ * without a tool domain still registers and reports its catalog as unavailable.
7
+ */
8
+ export interface ContextInspectionServerContext {
9
+ readonly location: RuntimeLocation;
10
+ readonly rpc: RuntimeRpcRegistrar;
11
+ readonly tool?: {
12
+ list(): Promise<readonly unknown[]>;
13
+ } | undefined;
14
+ readonly session: {
15
+ get(input: {
16
+ readonly sessionID: string;
17
+ }): Promise<unknown>;
18
+ };
19
+ }
20
+ /**
21
+ * Structural runtime snapshot/config seam the handler may read. `policy` is the
22
+ * session-family capture lookup; `currentConfig` is the already-loaded effective
23
+ * config used only for a labelled current-runtime preview.
24
+ */
25
+ export interface ContextInspectionServerRuntime {
26
+ policy(sessionID: string): Promise<unknown>;
27
+ currentConfig(): unknown;
28
+ now?: (() => number) | undefined;
29
+ }
30
+ /**
31
+ * Build the read-only inspection handler. Exported so focused tests can invoke
32
+ * the exact production logic without a live RPC transport.
33
+ */
34
+ export declare function createContextInspectionHandler(ctx: ContextInspectionServerContext, runtime: ContextInspectionServerRuntime): (rawInput: unknown) => Promise<ContextInspectionResult>;
35
+ /**
36
+ * Register the versioned read-only inspection RPC. The returned registration is
37
+ * owned by the caller: disposing it removes only this registration and never
38
+ * stops the host or another plugin's registration.
39
+ */
40
+ export declare function registerContextInspectionRpc(ctx: ContextInspectionServerContext, runtime: ContextInspectionServerRuntime): Promise<RuntimeRpcRegistration>;
41
+ /**
42
+ * Resolve the Schema-owned Effect 4 codec (the exact version `@opencode/schema`
43
+ * depends on) through `@opencode/schema/tool`, so known built-in Effect schemas
44
+ * convert to JSON Schema without pulling the repository-root Effect 3 types.
45
+ * Returns undefined when no compatible converter is available.
46
+ */
47
+ export declare function loadSchemaOwnedVendorConverter(): Promise<ContextInspectionSchemaConverter | undefined>;
48
+ /**
49
+ * Validate a durable family capture before exposing any allowlisted policy. An
50
+ * arbitrary object (for example `{}`) is never treated as available defaults.
51
+ */
52
+ export declare function isMeaningfulFamilyCapture(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,324 @@
1
+ // FILE: src/runtime/context-inspection.ts
2
+ // VERSION: 2.0.0
3
+ // START_MODULE_CONTRACT
4
+ // PURPOSE: Register the read-only native context-inspection RPC on the server plugin context, projecting the registered tool catalog and an allowlisted session-family or current-runtime policy for the TUI.
5
+ // SCOPE: Structural server context/runtime seam, bounded catalog reads via ctx.tool.list with server-side vendor schema conversion (Schema-owned Effect 4 resolved from @opencode/schema), serving-location/project session validation via ctx.session.get, meaningful FamilyCapture validation via snapshots.policy, current-runtime preview from the already-loaded effective config, value-free stable error codes, and strict allowlisted output construction. It never stages/accepts work, switches models, reloads, executes tools, or connects MCP servers.
6
+ // DEPENDS: [node:module, node:url, @opencode/schema/tool, src/runtime/context-inspection-contract.ts, src/runtime/types.ts]
7
+ // LINKS: [M-NATIVE-RUNTIME, M-PLUGIN-CONTEXT-TUI, DF-CONTEXT-INSPECTION, V-M-NATIVE-RUNTIME, V-M-PLUGIN-CONTEXT-TUI]
8
+ // ROLE: RUNTIME
9
+ // MAP_MODE: EXPORTS
10
+ // END_MODULE_CONTRACT
11
+ //
12
+ // START_MODULE_MAP
13
+ // ContextInspectionServerContext - Structural native server plugin context accepted by the registration helper.
14
+ // ContextInspectionServerRuntime - Structural runtime snapshot/config seam the handler may read.
15
+ // createContextInspectionHandler - Build the production inspection handler for focused tests.
16
+ // registerContextInspectionRpc - Register the versioned read-only inspection RPC and return its registration handle.
17
+ // isMeaningfulFamilyCapture - Validate a durable capture before exposing any allowlisted policy.
18
+ // loadSchemaOwnedVendorConverter - Resolve the Schema-owned Effect 4 codec converter for known built-in tool schemas.
19
+ // END_MODULE_MAP
20
+ //
21
+ // START_CHANGE_SUMMARY
22
+ // LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-008 attempt 2 - Added value-free error codes, meaningful-capture validation, current-location session checks, undefined-preview rejection, bounded schedule reporting, and Schema-owned Effect schema conversion.]
23
+ // END_CHANGE_SUMMARY
24
+ import { createRequire } from "node:module";
25
+ import { pathToFileURL } from "node:url";
26
+ import { CONTEXT_INSPECTION_MAX_TOOLS, CONTEXT_INSPECTION_METHOD, CONTEXT_INSPECTION_VERSION, boundedWarnings, contextInspectionRpc, inspectionErrorCode, projectContextInspectionPolicy, projectContextInspectionTool, } from "./context-inspection-contract.js";
27
+ // START_BLOCK_INSPECTION_REGISTRATION
28
+ /**
29
+ * Build the read-only inspection handler. Exported so focused tests can invoke
30
+ * the exact production logic without a live RPC transport.
31
+ */
32
+ export function createContextInspectionHandler(ctx, runtime) {
33
+ return async (rawInput) => {
34
+ const input = isRecord(rawInput) ? rawInput : {};
35
+ const now = runtime.now ?? (() => Date.now());
36
+ const observedAt = now();
37
+ const location = toLocation(ctx.location);
38
+ const warnings = [];
39
+ const catalog = input.includeCatalog === false ? undefined : await readCatalog(ctx, warnings);
40
+ const policy = await readPolicy(ctx, runtime, input.sessionID, location, warnings);
41
+ return {
42
+ version: CONTEXT_INSPECTION_VERSION,
43
+ status: overallStatus(catalog, policy),
44
+ location,
45
+ observedAt,
46
+ ...(catalog === undefined ? {} : { catalog }),
47
+ policy,
48
+ warnings: boundedWarnings(warnings),
49
+ };
50
+ };
51
+ }
52
+ /**
53
+ * Register the versioned read-only inspection RPC. The returned registration is
54
+ * owned by the caller: disposing it removes only this registration and never
55
+ * stops the host or another plugin's registration.
56
+ */
57
+ export async function registerContextInspectionRpc(ctx, runtime) {
58
+ const handler = createContextInspectionHandler(ctx, runtime);
59
+ return ctx.rpc.register(contextInspectionRpc, {
60
+ [CONTEXT_INSPECTION_METHOD]: (rawInput) => handler(rawInput),
61
+ });
62
+ }
63
+ // END_BLOCK_INSPECTION_REGISTRATION
64
+ // START_BLOCK_CATALOG_READ
65
+ async function readCatalog(ctx, warnings) {
66
+ const list = ctx.tool?.list;
67
+ if (typeof list !== "function") {
68
+ warnings.push("tool_catalog_unavailable: the server context exposes no tool domain");
69
+ return { status: "unavailable", tools: [], warnings: [] };
70
+ }
71
+ let rows;
72
+ try {
73
+ rows = await list.call(ctx.tool);
74
+ }
75
+ catch {
76
+ warnings.push("tool_catalog_unavailable: the tool registry could not be read");
77
+ return { status: "unavailable", tools: [], warnings: [] };
78
+ }
79
+ if (!Array.isArray(rows)) {
80
+ warnings.push("tool_catalog_unavailable: the tool registry returned a non-list payload");
81
+ return { status: "unavailable", tools: [], warnings: [] };
82
+ }
83
+ const capped = rows.slice(0, CONTEXT_INSPECTION_MAX_TOOLS);
84
+ const cappedRows = capped.length < rows.length;
85
+ if (cappedRows)
86
+ warnings.push(`tool catalog truncated to ${CONTEXT_INSPECTION_MAX_TOOLS} rows`);
87
+ const convertVendorSchema = await loadSchemaOwnedVendorConverter();
88
+ const tools = [];
89
+ const catalogWarnings = new Set();
90
+ let unusableRows = 0;
91
+ let unavailableSchemas = 0;
92
+ for (const row of capped) {
93
+ const projected = projectContextInspectionTool(row, convertVendorSchema === undefined ? undefined : convertVendorSchema);
94
+ if (projected === undefined) {
95
+ unusableRows += 1;
96
+ continue;
97
+ }
98
+ tools.push(projected.tool);
99
+ for (const warning of projected.warnings) {
100
+ catalogWarnings.add(warning);
101
+ warnings.push(warning);
102
+ }
103
+ if (projected.tool.status === "unavailable")
104
+ unavailableSchemas += 1;
105
+ }
106
+ const status = tools.length === 0 && rows.length > 0
107
+ ? "unavailable"
108
+ : unusableRows > 0 || unavailableSchemas > 0 || cappedRows
109
+ ? "partial"
110
+ : "complete";
111
+ return { status, tools, warnings: boundedWarnings([...catalogWarnings]) };
112
+ }
113
+ /**
114
+ * Resolve the Schema-owned Effect 4 codec (the exact version `@opencode/schema`
115
+ * depends on) through `@opencode/schema/tool`, so known built-in Effect schemas
116
+ * convert to JSON Schema without pulling the repository-root Effect 3 types.
117
+ * Returns undefined when no compatible converter is available.
118
+ */
119
+ export async function loadSchemaOwnedVendorConverter() {
120
+ try {
121
+ // `@opencode/schema` exports only the `import` condition, so resolve the
122
+ // ESM entry with import.meta.resolve and create the require from it.
123
+ const schemaToolUrl = import.meta.resolve("@opencode/schema/tool");
124
+ const requireFromSchema = createRequire(schemaToolUrl);
125
+ const effectEntry = requireFromSchema.resolve("effect");
126
+ const effect = (await import(pathToFileURL(effectEntry).href));
127
+ const schema = effect.Schema;
128
+ if (schema === undefined ||
129
+ typeof schema.isSchema !== "function" ||
130
+ typeof schema.toJsonSchemaDocument !== "function") {
131
+ return undefined;
132
+ }
133
+ return (candidate) => {
134
+ if (!schema.isSchema(candidate))
135
+ return undefined;
136
+ const document = schema.toJsonSchemaDocument(candidate);
137
+ const definitions = document.definitions;
138
+ if (definitions === undefined || Object.keys(definitions).length === 0)
139
+ return document.schema;
140
+ // Preserve named definitions as `$defs` instead of flattening/refs.
141
+ return { ...document.schema, $defs: definitions };
142
+ };
143
+ }
144
+ catch {
145
+ return undefined;
146
+ }
147
+ }
148
+ // END_BLOCK_CATALOG_READ
149
+ // START_BLOCK_POLICY_READ
150
+ async function readPolicy(ctx, runtime, sessionID, location, warnings) {
151
+ if (sessionID === undefined || sessionID.length === 0) {
152
+ return readPreviewPolicy(runtime, warnings);
153
+ }
154
+ // Validate that the supplied session currently belongs to this serving
155
+ // location's project AND directory before returning any captured policy.
156
+ // The captured family directory may legitimately differ after a worktree
157
+ // move, but the session's CURRENT location must match the serving location.
158
+ let session;
159
+ try {
160
+ session = await ctx.session.get({ sessionID });
161
+ }
162
+ catch {
163
+ return unavailablePolicy("family", inspectionErrorCode("session"), warnings, "session lookup failed");
164
+ }
165
+ if (!sessionMatchesLocation(session, ctx.location)) {
166
+ return unavailablePolicy("family", inspectionErrorCode("session-location"), warnings, "session current location does not match the serving location");
167
+ }
168
+ let capture;
169
+ try {
170
+ capture = await runtime.policy(sessionID);
171
+ }
172
+ catch {
173
+ return unavailablePolicy("family", inspectionErrorCode("policy"), warnings, "policy lookup failed");
174
+ }
175
+ if (capture === undefined) {
176
+ return unavailablePolicy("family", "policy_capture_missing", warnings, "no captured family policy is bound to this session");
177
+ }
178
+ if (!isMeaningfulFamilyCapture(capture)) {
179
+ return unavailablePolicy("family", "policy_capture_invalid", warnings, "the captured family policy is corrupt or incomplete");
180
+ }
181
+ const projected = projectContextInspectionPolicy(readPolicySource(capture));
182
+ if (!projected.complete) {
183
+ return unavailablePolicy("family", "schedule_projection_exceeded", warnings, "the captured peak schedule exceeds the bounded projection");
184
+ }
185
+ const policyWarnings = projected.warnings.length === 0 ? undefined : [...projected.warnings];
186
+ for (const warning of projected.warnings)
187
+ warnings.push(warning);
188
+ return {
189
+ status: "available",
190
+ scope: "family",
191
+ contextEnabled: projected.contextEnabled,
192
+ analyticsEnabled: projected.analyticsEnabled,
193
+ peakHours: projected.peakHours,
194
+ provenance: readProvenance(capture, location),
195
+ ...(policyWarnings === undefined ? {} : { warnings: policyWarnings }),
196
+ };
197
+ }
198
+ function readPreviewPolicy(runtime, warnings) {
199
+ let config;
200
+ try {
201
+ config = runtime.currentConfig();
202
+ }
203
+ catch {
204
+ return unavailablePolicy("current-runtime", inspectionErrorCode("preview"), warnings, "current config unreadable");
205
+ }
206
+ const vvoc = isRecord(config) && isRecord(config.vvoc) ? config.vvoc : undefined;
207
+ if (vvoc === undefined || !isRecord(vvoc.plugins)) {
208
+ // An undefined or malformed current config must not default to all-enabled.
209
+ return unavailablePolicy("current-runtime", inspectionErrorCode("preview"), warnings, "current runtime configuration is unavailable");
210
+ }
211
+ const projected = projectContextInspectionPolicy({ plugins: vvoc.plugins });
212
+ if (!projected.complete) {
213
+ return unavailablePolicy("current-runtime", "schedule_projection_exceeded", warnings, "the current peak schedule exceeds the bounded projection");
214
+ }
215
+ const policyWarnings = projected.warnings.length === 0 ? undefined : [...projected.warnings];
216
+ for (const warning of projected.warnings)
217
+ warnings.push(warning);
218
+ return {
219
+ status: "preview",
220
+ scope: "current-runtime",
221
+ contextEnabled: projected.contextEnabled,
222
+ analyticsEnabled: projected.analyticsEnabled,
223
+ peakHours: projected.peakHours,
224
+ ...(policyWarnings === undefined ? {} : { warnings: policyWarnings }),
225
+ };
226
+ }
227
+ // END_BLOCK_POLICY_READ
228
+ // START_BLOCK_CAPTURE_VALIDATION
229
+ /**
230
+ * Validate a durable family capture before exposing any allowlisted policy. An
231
+ * arbitrary object (for example `{}`) is never treated as available defaults.
232
+ */
233
+ export function isMeaningfulFamilyCapture(value) {
234
+ if (!isRecord(value))
235
+ return false;
236
+ if (value.schemaVersion !== 1)
237
+ return false;
238
+ if (!nonEmptyString(value.familyId))
239
+ return false;
240
+ if (!nonEmptyString(value.snapshotId))
241
+ return false;
242
+ if (!nonEmptyString(value.integrity))
243
+ return false;
244
+ if (typeof value.capturedAt !== "number" || !Number.isFinite(value.capturedAt))
245
+ return false;
246
+ if (!isRecord(value.vvoc) || !isRecord(value.vvoc.plugins))
247
+ return false;
248
+ const location = value.location;
249
+ if (!isRecord(location) || !nonEmptyString(location.directory))
250
+ return false;
251
+ if (!nonEmptyString(location.projectID))
252
+ return false;
253
+ return true;
254
+ }
255
+ function sessionMatchesLocation(session, serving) {
256
+ if (!isRecord(session))
257
+ return false;
258
+ const projectID = session.projectID;
259
+ if (typeof projectID !== "string" || projectID !== serving.project.id)
260
+ return false;
261
+ const sessionLocation = session.location;
262
+ if (!isRecord(sessionLocation))
263
+ return false;
264
+ const directory = sessionLocation.directory;
265
+ return typeof directory === "string" && directory === serving.directory;
266
+ }
267
+ // END_BLOCK_CAPTURE_VALIDATION
268
+ function readPolicySource(capture) {
269
+ const vvoc = isRecord(capture.vvoc) ? capture.vvoc : undefined;
270
+ return vvoc === undefined ? {} : { plugins: readPlugins(vvoc) };
271
+ }
272
+ function readPlugins(vvoc) {
273
+ return isRecord(vvoc.plugins) ? vvoc.plugins : undefined;
274
+ }
275
+ function readProvenance(capture, fallback) {
276
+ const location = isRecord(capture.location) ? capture.location : undefined;
277
+ const directory = location === undefined ? undefined : readString(location.directory);
278
+ const projectID = location === undefined ? undefined : readString(location.projectID);
279
+ const workspaceID = location === undefined ? undefined : readString(location.workspaceID);
280
+ return {
281
+ familyId: readString(capture.familyId) ?? "",
282
+ snapshotId: readString(capture.snapshotId) ?? "",
283
+ capturedAt: typeof capture.capturedAt === "number" ? capture.capturedAt : 0,
284
+ location: directory === undefined
285
+ ? fallback
286
+ : {
287
+ directory,
288
+ ...(projectID === undefined ? {} : { projectID }),
289
+ ...(workspaceID === undefined ? {} : { workspaceID }),
290
+ },
291
+ };
292
+ }
293
+ function unavailablePolicy(scope, code, warnings, reason) {
294
+ warnings.push(`${code}: ${reason}`);
295
+ return { status: "unavailable", scope, error: code };
296
+ }
297
+ function overallStatus(catalog, policy) {
298
+ const catalogStatus = catalog?.status;
299
+ const policyUnavailable = policy.status === "unavailable";
300
+ if (catalogStatus === undefined)
301
+ return policyUnavailable ? "unavailable" : "complete";
302
+ if (catalogStatus === "unavailable" && policyUnavailable)
303
+ return "unavailable";
304
+ if (catalogStatus !== "complete" || policyUnavailable)
305
+ return "partial";
306
+ return "complete";
307
+ }
308
+ function toLocation(location) {
309
+ return {
310
+ directory: location.directory,
311
+ projectID: location.project.id,
312
+ ...(location.workspaceID === undefined ? {} : { workspaceID: location.workspaceID }),
313
+ };
314
+ }
315
+ function readString(value) {
316
+ return typeof value === "string" && value.length > 0 ? value : undefined;
317
+ }
318
+ function nonEmptyString(value) {
319
+ return typeof value === "string" && value.length > 0;
320
+ }
321
+ function isRecord(value) {
322
+ return typeof value === "object" && value !== null && !Array.isArray(value);
323
+ }
324
+ //# sourceMappingURL=context-inspection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-inspection.js","sourceRoot":"","sources":["../../src/runtime/context-inspection.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,iBAAiB;AACj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AG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,192 @@
1
+ import type { OpenCodeClient } from "@opencode/client";
2
+ import { type SnapshotServiceDeps } from "./snapshots.js";
3
+ import { type AdmissionOutcome, type AgentEditorLike, type AgentPolicyBinding, type AuxiliaryService, type EffectiveRuntimeConfig, type ModelEditorLike, type NativeRuntime, type PermissionService, type RuntimeClient, type RuntimeContext, type RuntimeDeps, type RuntimeEvent, type RuntimeLease, type SnapshotAdmissionRequest, type SnapshotLease, type SnapshotService, type SnapshotStore } from "./types.js";
4
+ /** Return a per-acquisition release lease for the runtime shared by one exact plugin context. */
5
+ export declare function acquireRuntime<Context extends RuntimeContext>(context: Context): RuntimeLease<Context, OpenCodeClient>;
6
+ export declare function acquireRuntime<Context extends RuntimeContext, Client extends RuntimeClient>(context: Context, deps: RuntimeDeps<Client>): RuntimeLease<Context, Client>;
7
+ /**
8
+ * Return a per-acquisition release lease for the snapshot service shared by one
9
+ * exact plugin context object and dependency instance. Distinct contexts never
10
+ * share a service, so per-location policies cannot leak across projects.
11
+ */
12
+ export declare function acquireSnapshotService<Context extends RuntimeContext>(context: Context, deps: SnapshotServiceDeps): SnapshotLease;
13
+ /** Structural native session info used for lineage and provenance. */
14
+ export interface NativeSessionInfoLike {
15
+ readonly id: string;
16
+ readonly parentID?: unknown;
17
+ readonly fork?: {
18
+ readonly sessionID: unknown;
19
+ } | undefined;
20
+ readonly projectID?: unknown;
21
+ readonly location?: {
22
+ readonly directory: unknown;
23
+ } | undefined;
24
+ readonly model?: {
25
+ readonly id: unknown;
26
+ readonly providerID: unknown;
27
+ readonly variant?: unknown;
28
+ } | undefined;
29
+ readonly agent?: unknown;
30
+ /** Host-persisted metadata; auxiliary children record their intended role here. */
31
+ readonly metadata?: unknown;
32
+ readonly time?: {
33
+ readonly idle?: number | undefined;
34
+ } | undefined;
35
+ readonly tokens?: {
36
+ readonly input?: number | undefined;
37
+ readonly output?: number | undefined;
38
+ } | undefined;
39
+ }
40
+ /** Structural native hook events used by the shared runtime. */
41
+ export interface NativeSnapshotHookEvents {
42
+ prompt: {
43
+ readonly sessionID: string;
44
+ readonly messageID?: string | undefined;
45
+ };
46
+ context: {
47
+ readonly sessionID: string;
48
+ readonly agent?: string | undefined;
49
+ };
50
+ generate: {
51
+ readonly sessionID: string;
52
+ };
53
+ title: {
54
+ readonly sessionID: string;
55
+ result?: string | undefined;
56
+ messages?: unknown;
57
+ };
58
+ "model.request": {
59
+ readonly sessionID: string;
60
+ readonly model: unknown;
61
+ readonly agent?: string | undefined;
62
+ readonly kind: string;
63
+ };
64
+ }
65
+ /**
66
+ * Narrow structural native `Plugin.Context` used to acquire the shared snapshot
67
+ * runtime. A real `Plugin.Context` satisfies it, so the runtime is keyed by the
68
+ * actual context object and later plugins share one instance.
69
+ */
70
+ export interface NativeSnapshotContext extends RuntimeContext {
71
+ readonly agent: {
72
+ transform(callback: (editor: AgentEditorLike) => void): Promise<NativeRegistration>;
73
+ reload(): Promise<void>;
74
+ };
75
+ readonly model: {
76
+ transform(callback: (editor: ModelEditorLike) => void): Promise<NativeRegistration>;
77
+ reload(): Promise<void>;
78
+ };
79
+ readonly session: {
80
+ get(input: {
81
+ readonly sessionID: string;
82
+ }): Promise<NativeSessionInfoLike>;
83
+ switchModel(input: {
84
+ readonly sessionID: string;
85
+ readonly model: {
86
+ readonly id: string;
87
+ readonly providerID: string;
88
+ readonly variant?: string;
89
+ };
90
+ }): Promise<void>;
91
+ update(input: {
92
+ readonly sessionID: string;
93
+ readonly title: string;
94
+ }): Promise<void>;
95
+ generate(input: {
96
+ readonly sessionID: string;
97
+ readonly prompt: string;
98
+ }): Promise<{
99
+ readonly text: string;
100
+ }>;
101
+ hook<Name extends keyof NativeSnapshotHookEvents>(name: Name, callback: (event: NativeSnapshotHookEvents[Name]) => void | Promise<void>): Promise<NativeRegistration>;
102
+ };
103
+ readonly event: {
104
+ subscribe(options?: {
105
+ readonly signal?: AbortSignal | undefined;
106
+ }): AsyncIterable<RuntimeEvent>;
107
+ };
108
+ /**
109
+ * Native registered-tool domain, when the host exposes one. The read-only
110
+ * context-inspection RPC uses `list()` to snapshot the registered catalog; it
111
+ * never executes a tool. Optional so a context without a tool domain still
112
+ * acquires a runtime and reports its catalog as unavailable.
113
+ */
114
+ readonly tool?: {
115
+ list(): Promise<readonly unknown[]>;
116
+ } | undefined;
117
+ }
118
+ /** Releasable native registration. */
119
+ export interface NativeRegistration {
120
+ dispose(): Promise<void> | void;
121
+ }
122
+ /**
123
+ * Structural full client needed for real native auxiliary/family work: forked
124
+ * children, imported parented children, and durable session-log reconciliation.
125
+ * The `import`/`log` parameters are intentionally `unknown` so the real
126
+ * authenticated `OpenCodeClient` (whose generated parameter types are not a
127
+ * faithful wire shape) satisfies this seam without a cast; callers pass a typed
128
+ * payload and decode the `unknown` result at the checked boundary.
129
+ */
130
+ export interface NativeForkClient extends RuntimeClient {
131
+ readonly session: {
132
+ fork(input: {
133
+ readonly sessionID: string;
134
+ }): Promise<{
135
+ readonly id: string;
136
+ }>;
137
+ /** Import a parented session; returns the created native session info. */
138
+ import(input: unknown, options?: unknown): Promise<unknown>;
139
+ /** Durable per-session event log ending in a `log.synced` marker. */
140
+ log(input: unknown, options?: unknown): AsyncIterable<unknown>;
141
+ };
142
+ }
143
+ /** Optional injectable native boundaries for the shared snapshot runtime (tests only). */
144
+ export interface NativeSnapshotRuntimeOptions<Client extends NativeForkClient = OpenCodeClient> {
145
+ readonly runtimeDeps?: RuntimeDeps<Client> | undefined;
146
+ readonly store?: SnapshotStore | undefined;
147
+ readonly now?: (() => number) | undefined;
148
+ }
149
+ /** Documented shared native runtime consumed by every later plugin. */
150
+ export interface NativeSnapshotRuntime<Client extends NativeForkClient = OpenCodeClient> {
151
+ /** Native runtime with lazy authenticated full client and resource permissions. */
152
+ readonly runtime: NativeRuntime<NativeSnapshotContext, Client>;
153
+ /** Immutable family snapshot/config/model/auxiliary service. */
154
+ readonly snapshots: SnapshotService;
155
+ /**
156
+ * Supported pre-admission gateway for owned direct generate/synthetic work.
157
+ * Stages, materializes the qualified variant, switches the session, and
158
+ * publishes the family capture BEFORE the caller triggers native model
159
+ * resolution. It performs the real admission itself; it is not a "trust this
160
+ * arbitrary acceptance" shortcut, and unbound raw external generate remains
161
+ * fail-closed. Later consumers (for example Guardian's auxiliary inference and
162
+ * T-003) should call this rather than relying on a late generate hook.
163
+ */
164
+ admitWorkload(request: SnapshotAdmissionRequest): Promise<AdmissionOutcome>;
165
+ /** Snapshot-bound auxiliary generation. */
166
+ readonly auxiliary: AuxiliaryService;
167
+ /** Lazily authenticated same-instance full native client (genuine OpenCodeClient by default). */
168
+ client(): Promise<Client>;
169
+ /** Resource permission service bound to this runtime's client. */
170
+ readonly permissions: PermissionService;
171
+ /** Current effective vvoc configuration plus captured native overlays. */
172
+ effectiveConfig(): EffectiveRuntimeConfig;
173
+ /** Enable or disable role overriding (agent models and default model) without disabling capture/guard. */
174
+ setRoleOverride(enabled: boolean): Promise<void>;
175
+ /** Reload persisted captures, variant registrations and native transforms. */
176
+ refresh(): Promise<void>;
177
+ /** Last config-watcher failure, surfaced instead of being silently swallowed. */
178
+ lastConfigError(): string | undefined;
179
+ /** Idempotent per-lease release; disposes shared state only for the last lease. */
180
+ release(): Promise<void>;
181
+ }
182
+ /**
183
+ * Recompute agent bindings from a freshly read config without trusting a cached
184
+ * selection that vvoc itself may have applied under a previous role set. A
185
+ * vvoc-role-managed agent's selection is recomputed from the current role model,
186
+ * raw OpenCode intent still wins, and an agent with no role keeps its genuine
187
+ * native literal. This is what makes `vvoc.json` role changes take effect on the
188
+ * first unbound workload even when the host emits no `config.updated`.
189
+ */
190
+ export declare function rebuildAgentBindings(cached: ReadonlyArray<AgentPolicyBinding>, config: EffectiveRuntimeConfig): AgentPolicyBinding[];
191
+ /** Acquire the shared native snapshot runtime for an actual `Plugin.Context`. */
192
+ export declare function acquireNativeSnapshotRuntime<Client extends NativeForkClient = OpenCodeClient>(ctx: NativeSnapshotContext, options?: NativeSnapshotRuntimeOptions<Client>): Promise<NativeSnapshotRuntime<Client>>;