@osovv/vv-opencode 2.0.0 → 2.1.0

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 +87 -85
  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 -22
  90. package/dist/plugins/peak-hours/index.js +210 -178
  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 +19 -15
  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 -161
  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 -95
  263. package/dist/plugins/peak-hours/v2.js.map +0 -1
  264. package/dist/plugins/secrets-redaction/v2.d.ts +0 -14
  265. package/dist/plugins/secrets-redaction/v2.js +0 -100
  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 -58
  295. package/dist/plugins/workflow/v2.js +0 -181
  296. package/dist/plugins/workflow/v2.js.map +0 -1
@@ -1,174 +0,0 @@
1
- // FILE: src/plugins/v2-runtime/setup.ts
2
- // VERSION: 1.1.0
3
- // START_MODULE_CONTRACT
4
- // PURPOSE: Dispatch the v2 setup(ctx) entry for the package root across the vvoc server plugins through a shared adapter carrying per-location config resolution and config watching.
5
- // SCOPE: Central v2 registration seam: the adapter context (plugin context, location resolver, config watch helper), the ordered plugin setup registry, full-v2-context feature detection, per-plugin error isolation, and aggregated reverse-order cleanup disposal.
6
- // DEPENDS: [@opencode/plugin, src/plugins/v2-runtime/location-config.ts, src/plugins/v2-runtime/config-watcher.ts]
7
- // LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME]
8
- // ROLE: RUNTIME
9
- // MAP_MODE: EXPORTS
10
- // END_MODULE_CONTRACT
11
- //
12
- // START_MODULE_MAP
13
- // setupV2Plugins - Run the v2 registrations for every vvoc server plugin against one full OpenCode v2 plugin context and return one aggregated cleanup; no-ops under the v1 v2-bridge host where the v1 runtime already calls server().
14
- // V2_PLUGIN_SETUPS - Ordered registry of per-plugin v2 setup functions extended by later migration tasks.
15
- // V2AdapterContext - Plugin context plus the location resolver and multiplexed config watcher shared by all vvoc plugins.
16
- // createV2Adapter - Build the shared adapter context with the location resolver and multiplexed config watcher.
17
- // isFullV2Context - Feature-detect whether a setup context carries the full OpenCode v2 domain set.
18
- // END_MODULE_MAP
19
- //
20
- // START_CHANGE_SUMMARY
21
- // LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-002 - Plugin setups now receive the shared adapter context with per-location config resolution and config watching.]
22
- // END_CHANGE_SUMMARY
23
- import { createLocationResolver } from "./location-config.js";
24
- import { watchProjectVvocConfig } from "./config-watcher.js";
25
- import { setupAnalyticsV2 } from "../analytics/v2.js";
26
- import { setupSystemContextInjectionV2 } from "../system-context-injection/v2.js";
27
- import { setupModelRolesV2 } from "../model-roles/v2.js";
28
- import { setupToolHistoryCompactionV2 } from "../tool-history-compaction/v2.js";
29
- import { setupSpecGuardV2 } from "../spec-guard/v2.js";
30
- import { setupSecretsRedactionV2 } from "../secrets-redaction/v2.js";
31
- import { setupPeakHoursV2 } from "../peak-hours/v2.js";
32
- import { setupWebToolsV2 } from "../web-tools/v2.js";
33
- import { setupHashlineEditV2 } from "../hashline-edit/v2.js";
34
- import { setupGuardianV2 } from "../guardian/v2.js";
35
- import { setupWorkflowV2 } from "../workflow/v2.js";
36
- // END_BLOCK_V2_ADAPTER_CONTEXT
37
- // START_BLOCK_V2_PLUGIN_SETUPS
38
- /**
39
- * Per-plugin v2 setup functions in the canonical v1 plugin order. Migration
40
- * tasks append entries as each plugin gains its v2 registration.
41
- */
42
- export const V2_PLUGIN_SETUPS = [
43
- { name: "analytics", setup: (adapter) => setupAnalyticsV2(adapter) },
44
- { name: "system-context-injection", setup: (adapter) => setupSystemContextInjectionV2(adapter) },
45
- { name: "model-roles", setup: (adapter) => setupModelRolesV2(adapter) },
46
- { name: "tool-history-compaction", setup: (adapter) => setupToolHistoryCompactionV2(adapter) },
47
- { name: "spec-guard", setup: (adapter) => setupSpecGuardV2(adapter) },
48
- { name: "secrets-redaction", setup: (adapter) => setupSecretsRedactionV2(adapter) },
49
- { name: "peak-hours", setup: (adapter) => setupPeakHoursV2(adapter) },
50
- { name: "web-tools", setup: (adapter) => setupWebToolsV2(adapter) },
51
- { name: "hashline-edit", setup: (adapter) => setupHashlineEditV2(adapter) },
52
- { name: "guardian", setup: (adapter) => setupGuardianV2(adapter) },
53
- { name: "workflow", setup: (adapter) => setupWorkflowV2(adapter) },
54
- ];
55
- // END_BLOCK_V2_PLUGIN_SETUPS
56
- // START_BLOCK_IS_FULL_V2_CONTEXT
57
- /**
58
- * OpenCode v1 (>= 1.18.29) also invokes setup() on dual entrypoints through
59
- * its reduced v2 bridge host, whose context only carries the agent, aisdk,
60
- * catalog, command, integration, plugin, reference, and skill domains. The
61
- * full OpenCode v2 context additionally carries app, location, event, model,
62
- * provider, session, storage, tool, and the remaining runtime domains. Probe
63
- * verified against OpenCode 1.18.32: the v1 bridge lacks tool, session, event,
64
- * storage, app, and location, so their presence distinguishes the runtimes.
65
- */
66
- export function isFullV2Context(context) {
67
- const probe = context;
68
- return ("tool" in probe &&
69
- "session" in probe &&
70
- "event" in probe &&
71
- "storage" in probe &&
72
- "app" in probe &&
73
- "location" in probe);
74
- }
75
- // END_BLOCK_IS_FULL_V2_CONTEXT
76
- // START_BLOCK_CREATE_ADAPTER
77
- /**
78
- * Build the shared adapter for one plugin context: a per-location config
79
- * resolver and a config watcher multiplexer that keeps one filesystem watch
80
- * per directory regardless of how many plugins subscribe to that directory.
81
- */
82
- export function createV2Adapter(context) {
83
- const resolver = createLocationResolver();
84
- const subscriptions = new Map();
85
- const activeWatches = new Map();
86
- async function ensureWatched(directory) {
87
- if (activeWatches.has(directory))
88
- return;
89
- const listeners = subscriptions.get(directory);
90
- if (!listeners || listeners.size === 0)
91
- return;
92
- const stopWatch = await watchProjectVvocConfig(directory, () => {
93
- resolver.invalidate(directory);
94
- for (const listener of listeners.values()) {
95
- try {
96
- listener();
97
- }
98
- catch (error) {
99
- console.warn(`[vvoc][v2-runtime] config listener failed for ${directory}: ${String(error)}`);
100
- }
101
- }
102
- });
103
- activeWatches.set(directory, stopWatch);
104
- }
105
- return {
106
- ctx: context,
107
- resolver,
108
- async watchConfig(directory, onChange) {
109
- const key = Symbol("vvoc-config-listener");
110
- let listeners = subscriptions.get(directory);
111
- if (!listeners) {
112
- listeners = new Map();
113
- subscriptions.set(directory, listeners);
114
- }
115
- listeners.set(key, onChange);
116
- await ensureWatched(directory);
117
- let stopped = false;
118
- return () => {
119
- if (stopped)
120
- return;
121
- stopped = true;
122
- const current = subscriptions.get(directory);
123
- if (!current)
124
- return;
125
- current.delete(key);
126
- if (current.size === 0) {
127
- subscriptions.delete(directory);
128
- const stopWatch = activeWatches.get(directory);
129
- if (stopWatch) {
130
- activeWatches.delete(directory);
131
- stopWatch();
132
- }
133
- }
134
- };
135
- },
136
- };
137
- }
138
- // END_BLOCK_CREATE_ADAPTER
139
- // START_BLOCK_SETUP_V2_PLUGINS
140
- /**
141
- * Run every registered v2 plugin setup against the adapter, isolating failures
142
- * per plugin, and return one cleanup that disposes the successful cleanups in
143
- * reverse registration order.
144
- *
145
- * Under the v1 v2-bridge host this returns without registering anything: the
146
- * same entrypoint's server() member already provides the v1 behavior, so the
147
- * package never registers twice inside one OpenCode v1 process.
148
- */
149
- export async function setupV2Plugins(context) {
150
- if (!isFullV2Context(context))
151
- return undefined;
152
- const adapter = createV2Adapter(context);
153
- const cleanups = [];
154
- for (const entry of V2_PLUGIN_SETUPS) {
155
- try {
156
- const cleanup = await entry.setup(adapter);
157
- if (typeof cleanup === "function") {
158
- cleanups.push(cleanup);
159
- }
160
- }
161
- catch (error) {
162
- console.error(`[vvoc][v2-runtime] plugin ${entry.name} failed to load: ${String(error)}`);
163
- }
164
- }
165
- if (cleanups.length === 0)
166
- return undefined;
167
- return async () => {
168
- for (const cleanup of cleanups.reverse()) {
169
- await cleanup();
170
- }
171
- };
172
- }
173
- // END_BLOCK_SETUP_V2_PLUGINS
174
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/setup.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,iBAAiB;AACjB,wBAAwB;AACxB,wLAAwL;AACxL,wQAAwQ;AACxQ,qHAAqH;AACrH,wDAAwD;AACxD,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0OAA0O;AAC1O,4GAA4G;AAC5G,4HAA4H;AAC5H,kHAAkH;AAClH,sGAAsG;AACtG,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,iKAAiK;AACjK,qBAAqB;AAGrB,OAAO,EAAE,sBAAsB,EAAyB,MAAM,sBAAsB,CAAC;AACrF,OAAO,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,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,KAAK,IAAI,EAAE;QAChB,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YACzC,MAAM,OAAO,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,6BAA6B"}
@@ -1,11 +0,0 @@
1
- import type { Plugin as V2Plugin } from "@opencode/plugin";
2
- import type { V2AdapterContext } from "../v2-runtime/setup.js";
3
- /**
4
- * Register the web tools on the v2 runtime.
5
- *
6
- * A later valid tool registration overrides the same effective name, so
7
- * registering web_search and web_fetch replaces the OpenCode built-ins while
8
- * the plugin is enabled and disposing the registration restores them, which
9
- * replaces the v1 config-hook builtin suppression.
10
- */
11
- export declare function setupWebToolsV2(adapter: V2AdapterContext): Promise<V2Plugin.Cleanup | void>;
@@ -1,99 +0,0 @@
1
- // FILE: src/plugins/web-tools/v2.ts
2
- // VERSION: 1.0.0
3
- // START_MODULE_CONTRACT
4
- // PURPOSE: Register the canonical web_search and web_fetch tools on the OpenCode v2 runtime, overriding the built-ins while the plugin is enabled.
5
- // SCOPE: v2 setup only: publish both owned tools with their strict JSON Schema inputs through the tool transform, adapt the shared executors to the v2 executor contract with cooperative cancellation through the context signal, resolve credentials per plugin-load location, and leave unowned tool ids untouched.
6
- // DEPENDS: [@opencode/plugin, src/lib/agent-tool-contract.ts, src/lib/config-layers.ts, src/plugins/web-tools/config.ts, src/plugins/web-tools/fetch-service.ts, src/plugins/web-tools/schemas.ts, src/plugins/web-tools/search-service.ts, src/plugins/v2-runtime/setup.ts]
7
- // LINKS: [M-PLUGIN-WEB-TOOLS, V-M-PLUGIN-WEB-TOOLS, M-PLUGIN-V2-RUNTIME]
8
- // ROLE: RUNTIME
9
- // MAP_MODE: EXPORTS
10
- // END_MODULE_CONTRACT
11
- //
12
- // START_MODULE_MAP
13
- // setupWebToolsV2 - Register both web tools for one OpenCode v2 plugin context.
14
- // END_MODULE_MAP
15
- //
16
- // START_CHANGE_SUMMARY
17
- // LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-004 - Ported web tools onto the v2 tool transform with built-in override semantics.]
18
- // END_CHANGE_SUMMARY
19
- import { loadVvocConfigForRead } from "../../lib/config-layers.js";
20
- import { isVvocPluginEnabled } from "../../lib/plugin-toggle-config.js";
21
- import { resolveWebRuntimeConfig } from "./config.js";
22
- import { createWebFetchTool } from "./fetch-service.js";
23
- import { createWebSearchTool } from "./search-service.js";
24
- import { webToolContracts } from "./schemas.js";
25
- // START_BLOCK_ADAPT_V1_EXECUTOR
26
- /**
27
- * Adapt one v1 tool executor invocation to the v2 Tool.Result shape.
28
- *
29
- * The v1 executors validate their own arguments, ask for permission through
30
- * the v1 ask() surface (v2 gates these tools through session permission rules
31
- * instead), and return { title, output, metadata }; the adapter forwards the
32
- * cancellation signal and maps the output to the v2 content string.
33
- */
34
- function adaptV1Executor(execute) {
35
- return async (input, context) => {
36
- const result = (await execute(input, {
37
- ask: async () => { },
38
- abort: context.signal,
39
- }));
40
- if (typeof result === "string") {
41
- return { content: result };
42
- }
43
- return {
44
- ...(result?.title ? { title: result.title } : {}),
45
- content: result?.output ?? "",
46
- ...(result?.metadata ? { metadata: result.metadata } : {}),
47
- };
48
- };
49
- }
50
- // END_BLOCK_ADAPT_V1_EXECUTOR
51
- // START_BLOCK_SETUP_WEB_TOOLS_V2
52
- /**
53
- * Register the web tools on the v2 runtime.
54
- *
55
- * A later valid tool registration overrides the same effective name, so
56
- * registering web_search and web_fetch replaces the OpenCode built-ins while
57
- * the plugin is enabled and disposing the registration restores them, which
58
- * replaces the v1 config-hook builtin suppression.
59
- */
60
- export async function setupWebToolsV2(adapter) {
61
- const directory = adapter.ctx.location.directory;
62
- const read = await loadVvocConfigForRead({
63
- cwd: directory,
64
- scope: "effective",
65
- allowDefault: true,
66
- });
67
- if (!isVvocPluginEnabled(read.config, "web-tools"))
68
- return undefined;
69
- const resolved = resolveWebRuntimeConfig({
70
- config: read.config,
71
- source: read.source,
72
- warnings: read.warnings,
73
- });
74
- const searchContract = webToolContracts.find((contract) => contract.toolId === "web_search");
75
- const fetchContract = webToolContracts.find((contract) => contract.toolId === "web_fetch");
76
- if (!searchContract || !fetchContract) {
77
- console.error("[vvoc][web-tools] owned tool contracts missing; v2 registration skipped");
78
- return undefined;
79
- }
80
- const searchTool = createWebSearchTool(resolved.search);
81
- const fetchTool = createWebFetchTool(resolved.fetch);
82
- const registration = await adapter.ctx.tool.transform((editor) => {
83
- editor.add({
84
- name: "web_search",
85
- description: "Search the web with the configured provider and return ranked results.",
86
- input: searchContract.inputJsonSchema,
87
- execute: adaptV1Executor(searchTool.execute),
88
- });
89
- editor.add({
90
- name: "web_fetch",
91
- description: "Fetch one URL and return its content as markdown.",
92
- input: fetchContract.inputJsonSchema,
93
- execute: adaptV1Executor(fetchTool.execute),
94
- });
95
- });
96
- return () => registration.dispose();
97
- }
98
- // END_BLOCK_SETUP_WEB_TOOLS_V2
99
- //# sourceMappingURL=v2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2.js","sourceRoot":"","sources":["../../../src/plugins/web-tools/v2.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,iBAAiB;AACjB,wBAAwB;AACxB,qJAAqJ;AACrJ,yTAAyT;AACzT,+QAA+Q;AAC/Q,2EAA2E;AAC3E,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,kFAAkF;AAClF,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,iIAAiI;AACjI,qBAAqB;AAIrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;A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AgB,CAAU;SAC9D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC;AACD,+BAA+B"}
@@ -1,58 +0,0 @@
1
- import type { Plugin as V2Plugin } from "@opencode/plugin";
2
- import type { V2AdapterContext } from "../v2-runtime/setup.js";
3
- /**
4
- * A v1-shaped client built on v2 domains. Session lookups map onto
5
- * ctx.session, logging degrades to console, and the repair continuation
6
- * prompt is unsupported under the v2 prompt shape and throws so the
7
- * bounded continuation path fails closed exactly like a failed continuation.
8
- */
9
- export declare function createWorkflowClientShim(adapter: V2AdapterContext): {
10
- app: {
11
- log: () => Promise<void>;
12
- };
13
- session: {
14
- get: (input: {
15
- path: {
16
- id: string;
17
- };
18
- }) => Promise<{
19
- data: import("@opencode/client").SessionInfo;
20
- }>;
21
- message: (input: {
22
- path: {
23
- id: string;
24
- messageID: string;
25
- };
26
- }) => Promise<{
27
- data: {
28
- id?: string;
29
- };
30
- error?: undefined;
31
- } | {
32
- data: undefined;
33
- error: {
34
- name: string;
35
- };
36
- }>;
37
- prompt: (_input: unknown) => Promise<never>;
38
- };
39
- };
40
- /**
41
- * Map v2 subagent launch arguments onto the v1 task shape the launch
42
- * validation consumes: agent becomes subagent_type, the v2 resume sessionID
43
- * becomes task_id, and background passes through. The v1 reader fields stay
44
- * authoritative so every eligibility rule applies unchanged.
45
- */
46
- export declare function adaptSubagentLaunchArgs(input: unknown): unknown;
47
- /**
48
- * Bridge the workflow surface onto the v2 runtime.
49
- *
50
- * The v1 factory runs once with the shimmed client; its returned hook object
51
- * is routed onto v2 domains: tools publish with their strict JSON Schema
52
- * inputs, before and after guards run as v2 tool hooks with the launcher
53
- * renamed from task to subagent, and the profile guidance appends through
54
- * the session context hook. Protocol parsing stays fail-closed: envelope
55
- * shapes the shared parser does not recognize reject the attempt, never
56
- * accept it.
57
- */
58
- export declare function setupWorkflowV2(adapter: V2AdapterContext): Promise<V2Plugin.Cleanup | void>;
@@ -1,181 +0,0 @@
1
- // FILE: src/plugins/workflow/v2.ts
2
- // VERSION: 1.0.0
3
- // START_MODULE_CONTRACT
4
- // PURPOSE: Run the complete workflow enforcement surface on the OpenCode v2 runtime by bridging the v1 plugin factory's hooks and tools onto v2 domains.
5
- // SCOPE: v2 setup only: instantiate the v1 factory once with a shimmed client, register its five tools with their strict JSON Schema inputs through the tool transform, route execute.before and execute.after through v2 tool hooks with subagent-launch argument adaptation (v2 names the launcher subagent with agent and sessionID fields), append the profile guidance through the session context hook, and keep every fail-closed guarantee of the shared protocol unchanged.
6
- // DEPENDS: [@opencode/plugin, src/lib/config-layers.ts, src/plugins/workflow/index.ts, src/plugins/v2-runtime/setup.ts]
7
- // LINKS: [M-PLUGIN-WORKFLOW, V-M-PLUGIN-WORKFLOW, M-WORKFLOW-PROTOCOL, M-PLUGIN-V2-RUNTIME]
8
- // ROLE: RUNTIME
9
- // MAP_MODE: EXPORTS
10
- // END_MODULE_CONTRACT
11
- //
12
- // START_MODULE_MAP
13
- // setupWorkflowV2 - Bridge the full workflow surface onto one OpenCode v2 plugin context.
14
- // createWorkflowClientShim - v1-shaped client over v2 domains for the workflow authorization and repair surfaces.
15
- // adaptSubagentLaunchArgs - Map v2 subagent tool arguments onto the v1 task launch shape.
16
- // END_MODULE_MAP
17
- //
18
- // START_CHANGE_SUMMARY
19
- // LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-005 - Bridged the workflow enforcement surface onto v2 tool, session, and event domains.]
20
- // END_CHANGE_SUMMARY
21
- import { WorkflowPlugin } from "./index.js";
22
- // START_BLOCK_CREATE_WORKFLOW_CLIENT_SHIM
23
- /**
24
- * A v1-shaped client built on v2 domains. Session lookups map onto
25
- * ctx.session, logging degrades to console, and the repair continuation
26
- * prompt is unsupported under the v2 prompt shape and throws so the
27
- * bounded continuation path fails closed exactly like a failed continuation.
28
- */
29
- export function createWorkflowClientShim(adapter) {
30
- return {
31
- app: {
32
- log: async () => { },
33
- },
34
- session: {
35
- get: async (input) => {
36
- const data = await adapter.ctx.session.get({ sessionID: input.path.id });
37
- return { data };
38
- },
39
- message: async (input) => {
40
- try {
41
- const messages = await adapter.ctx.session.context({ sessionID: input.path.id });
42
- const hit = messages.find((message) => message.id === input.path.messageID);
43
- return hit ? { data: hit } : { data: undefined, error: { name: "NotFound" } };
44
- }
45
- catch {
46
- return { data: undefined, error: { name: "NotFound" } };
47
- }
48
- },
49
- prompt: async (_input) => {
50
- throw new Error("workflow continuation prompt is not available on the v2 runtime");
51
- },
52
- },
53
- };
54
- }
55
- // END_BLOCK_CREATE_WORKFLOW_CLIENT_SHIM
56
- // START_BLOCK_ADAPT_SUBAGENT_LAUNCH_ARGS
57
- /**
58
- * Map v2 subagent launch arguments onto the v1 task shape the launch
59
- * validation consumes: agent becomes subagent_type, the v2 resume sessionID
60
- * becomes task_id, and background passes through. The v1 reader fields stay
61
- * authoritative so every eligibility rule applies unchanged.
62
- */
63
- export function adaptSubagentLaunchArgs(input) {
64
- if (!input || typeof input !== "object")
65
- return input;
66
- const record = input;
67
- return {
68
- ...record,
69
- ...(typeof record.agent === "string" ? { subagent_type: record.agent } : {}),
70
- ...(typeof record.sessionID === "string" ? { task_id: record.sessionID } : {}),
71
- };
72
- }
73
- // END_BLOCK_ADAPT_SUBAGENT_LAUNCH_ARGS
74
- // START_BLOCK_SETUP_WORKFLOW_V2
75
- /**
76
- * Bridge the workflow surface onto the v2 runtime.
77
- *
78
- * The v1 factory runs once with the shimmed client; its returned hook object
79
- * is routed onto v2 domains: tools publish with their strict JSON Schema
80
- * inputs, before and after guards run as v2 tool hooks with the launcher
81
- * renamed from task to subagent, and the profile guidance appends through
82
- * the session context hook. Protocol parsing stays fail-closed: envelope
83
- * shapes the shared parser does not recognize reject the attempt, never
84
- * accept it.
85
- */
86
- export async function setupWorkflowV2(adapter) {
87
- const directory = adapter.ctx.location.directory;
88
- const hooks = (await WorkflowPlugin({
89
- client: createWorkflowClientShim(adapter),
90
- project: { id: directory, directory },
91
- directory,
92
- worktree: directory,
93
- experimental_workspace: { register: () => { } },
94
- serverUrl: new URL("http://127.0.0.1:1"),
95
- $: {},
96
- }));
97
- if (!hooks)
98
- return undefined;
99
- const cleanups = [];
100
- // Tools: publish each v1 tool entry with its contract JSON Schema input.
101
- const toolEntries = (hooks.tool ?? {});
102
- const { workflowToolContracts } = await import("./input-validation.js");
103
- const toolRegistration = await adapter.ctx.tool.transform((editor) => {
104
- for (const [name, entry] of Object.entries(toolEntries)) {
105
- const contract = workflowToolContracts.find((item) => item.toolId === name);
106
- editor.add({
107
- name,
108
- description: entry.description,
109
- input: (contract?.inputJsonSchema ?? { type: "object" }),
110
- execute: (async (input, context) => {
111
- const result = await entry.execute(input, {
112
- sessionID: context.sessionID,
113
- agent: context.agent,
114
- abort: context.signal,
115
- });
116
- return { content: typeof result === "string" ? result : JSON.stringify(result) };
117
- }),
118
- });
119
- }
120
- });
121
- cleanups.push(() => toolRegistration.dispose());
122
- // Owned validation plus task-launch tracking on execute.before.
123
- const beforeHook = await adapter.ctx.tool.hook("execute.before", (event) => {
124
- const tool = String(event.tool) === "subagent" ? "task" : String(event.tool);
125
- const args = String(event.tool) === "subagent" ? adaptSubagentLaunchArgs(event.input) : event.input;
126
- const before = hooks["tool.execute.before"];
127
- if (!before)
128
- return;
129
- return before({ tool, sessionID: event.sessionID, callID: event.id, agent: event.agent }, { args });
130
- });
131
- cleanups.push(() => beforeHook.dispose());
132
- // Delegated result tracking on execute.after.
133
- const afterHook = await adapter.ctx.tool.hook("execute.after", (event) => {
134
- if (event.status !== "completed")
135
- return;
136
- const tool = String(event.tool) === "subagent" ? "task" : String(event.tool);
137
- const args = String(event.tool) === "subagent" ? adaptSubagentLaunchArgs(event.input) : event.input;
138
- const result = event.result;
139
- const output = typeof result.content === "string"
140
- ? result.content
141
- : Array.isArray(result.content)
142
- ? result.content.map((part) => part.text ?? "").join("\n")
143
- : "";
144
- const after = hooks["tool.execute.after"];
145
- if (!after)
146
- return;
147
- return after({ tool, sessionID: event.sessionID, callID: event.id, agent: event.agent, args }, { output, metadata: {} });
148
- });
149
- cleanups.push(() => afterHook.dispose());
150
- // Profile guidance through the session context hook.
151
- const chatMessage = hooks["chat.message"];
152
- if (chatMessage) {
153
- const contextHook = await adapter.ctx.session.hook("context", (event) => {
154
- const message = {
155
- agent: event.agent,
156
- system: event.system
157
- .filter((part) => part.type === "text")
158
- .map((part) => part.text)
159
- .join("\n\n"),
160
- };
161
- const before = message.system;
162
- const result = chatMessage({}, { message });
163
- if (result instanceof Promise) {
164
- return result.then(() => {
165
- if (typeof message.system === "string" && message.system !== before) {
166
- event.system.length = 0;
167
- event.system.push({ type: "text", text: message.system });
168
- }
169
- });
170
- }
171
- return undefined;
172
- });
173
- cleanups.push(() => contextHook.dispose());
174
- }
175
- return async () => {
176
- for (const dispose of cleanups.reverse())
177
- await dispose();
178
- };
179
- }
180
- // END_BLOCK_SETUP_WORKFLOW_V2
181
- //# sourceMappingURL=v2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2.js","sourceRoot":"","sources":["../../../src/plugins/workflow/v2.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,iBAAiB;AACjB,wBAAwB;AACxB,2JAA2J;AAC3J,udAAud;AACvd,0HAA0H;AAC1H,8FAA8F;AAC9F,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,4FAA4F;AAC5F,oHAAoH;AACpH,4FAA4F;AAC5F,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,sIAAsI;AACtI,qBAAqB;AAIrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,0CAA0C;AAC1C;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAyB;IAChE,OAAO;QACL,GAAG,EAAE;YACH,GAAG,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;SACpB;QACD,OAAO,EAAE;YACP,GAAG,EAAE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