vgxness 1.20.4 → 1.20.6

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 (375) hide show
  1. package/dist/adapters/claude/agent-renderer.js +82 -0
  2. package/dist/{mcp → adapters/claude/install}/claude-code-agent-config.js +64 -9
  3. package/dist/{mcp → adapters/claude/install}/claude-code-config.js +28 -6
  4. package/dist/{mcp → adapters/claude/install}/claude-code-project-memory.js +35 -5
  5. package/dist/{mcp → adapters/claude/install}/claude-code-scope.js +12 -3
  6. package/dist/{mcp → adapters/claude/install}/claude-code-user-config.js +26 -5
  7. package/dist/{mcp → adapters/claude/install}/claude-code-user-memory.js +47 -7
  8. package/dist/{mcp → adapters/claude/install}/client-install-claude-code-contract.js +45 -8
  9. package/dist/{mcp → adapters/claude/install}/client-install-claude-code.js +98 -14
  10. package/dist/adapters/json/agent-renderer.js +104 -0
  11. package/dist/adapters/opencode/agent-renderer.js +113 -0
  12. package/dist/{mcp → adapters/opencode/install}/client-install-opencode-contract.js +2 -2
  13. package/dist/{mcp → adapters/opencode/install}/client-install-opencode.js +1 -1
  14. package/dist/{mcp → adapters/opencode/install}/opencode-default-agent-config.js +2 -2
  15. package/dist/{mcp → adapters/opencode/install}/opencode-handoff-preview.js +60 -7
  16. package/dist/{mcp → adapters/opencode/install}/opencode-visibility.js +1 -1
  17. package/dist/adapters/provider-renderer.js +6 -0
  18. package/dist/agents/agent-activation-service.js +1 -263
  19. package/dist/agents/agent-lookup-contexts.js +1 -28
  20. package/dist/agents/agent-registry-service.js +1 -81
  21. package/dist/agents/agent-resolver.js +1 -287
  22. package/dist/agents/agent-seed-service.js +1 -157
  23. package/dist/agents/agent-seed-upgrade-service.js +1 -231
  24. package/dist/agents/agent-selector-resolver.js +1 -28
  25. package/dist/agents/boot-upgrade.js +1 -59
  26. package/dist/agents/canonical-agent-manifest.js +1 -245
  27. package/dist/agents/canonical-agent-projection.js +1 -236
  28. package/dist/agents/manager-profile-overlay-service.js +1 -60
  29. package/dist/agents/profile-model-routing.js +1 -30
  30. package/dist/agents/renderers/claude-renderer.js +1 -82
  31. package/dist/agents/renderers/index.js +1 -14
  32. package/dist/agents/renderers/json-renderer.js +1 -104
  33. package/dist/agents/renderers/opencode-renderer.js +1 -113
  34. package/dist/agents/renderers/provider-adapter.js +1 -6
  35. package/dist/agents/repositories/agent-seed-history.js +1 -128
  36. package/dist/agents/repositories/agents.js +1 -200
  37. package/dist/agents/repositories/manager-profile-overlays.js +1 -90
  38. package/dist/agents/schema.js +1 -1
  39. package/dist/application/agents/agent-activation-service.js +261 -0
  40. package/dist/application/agents/agent-lookup-contexts.js +28 -0
  41. package/dist/application/agents/agent-registry-service.js +81 -0
  42. package/dist/application/agents/agent-resolver.js +287 -0
  43. package/dist/application/agents/agent-seed-service.js +157 -0
  44. package/dist/application/agents/agent-seed-upgrade-service.js +231 -0
  45. package/dist/application/agents/agent-selector-resolver.js +28 -0
  46. package/dist/application/agents/boot-upgrade.js +59 -0
  47. package/dist/application/agents/canonical-agent-projection.js +236 -0
  48. package/dist/application/agents/manager-profile-overlay-service.js +68 -0
  49. package/dist/application/agents/profile-model-routing.js +30 -0
  50. package/dist/application/agents/renderers/claude-renderer.js +1 -0
  51. package/dist/application/agents/renderers/index.js +14 -0
  52. package/dist/application/agents/renderers/json-renderer.js +1 -0
  53. package/dist/application/agents/renderers/opencode-renderer.js +1 -0
  54. package/dist/application/agents/renderers/provider-adapter.js +1 -0
  55. package/dist/application/memory/active-work-preview.js +75 -0
  56. package/dist/application/memory/agent-memory-capture-service.js +498 -0
  57. package/dist/application/memory/import/dry-run-planner.js +58 -0
  58. package/dist/application/memory/import/index.js +3 -0
  59. package/dist/application/memory/import/observation-writer.js +226 -0
  60. package/dist/application/memory/import/package.js +179 -0
  61. package/dist/application/memory/memory-service.js +202 -0
  62. package/dist/application/memory/search.js +11 -0
  63. package/dist/{mcp → application/provider-setup}/provider-change-plan.js +74 -13
  64. package/dist/{mcp → application/provider-setup}/provider-doctor.js +201 -31
  65. package/dist/{mcp → application/provider-setup}/provider-health-types.js +1 -1
  66. package/dist/{mcp → application/provider-setup}/provider-status.js +170 -33
  67. package/dist/application/runs/execution-planning.js +180 -0
  68. package/dist/application/runs/operation-execution.js +1 -0
  69. package/dist/application/runs/operation-retry.js +129 -0
  70. package/dist/application/runs/resume-after-approval-result.js +88 -0
  71. package/dist/application/runs/run-insights.js +270 -0
  72. package/dist/application/runs/run-service.js +1480 -0
  73. package/dist/application/runs/run-snapshot-export-service.js +31 -0
  74. package/dist/application/runs/sandbox-process-execution.js +244 -0
  75. package/dist/application/runs/sandbox-worktree-planning.js +59 -0
  76. package/dist/application/runs/task-scoped-command-grant-service.js +224 -0
  77. package/dist/application/sdd/artifact-portability-service.js +137 -0
  78. package/dist/application/sdd/cockpit-read-model.js +195 -0
  79. package/dist/application/sdd/sdd-continuation-plan.js +265 -0
  80. package/dist/application/sdd/sdd-workflow-service.js +892 -0
  81. package/dist/application/skills/boot-seed.js +42 -0
  82. package/dist/application/skills/personal-skills.js +41 -0
  83. package/dist/application/skills/skill-export-service.js +34 -0
  84. package/dist/application/skills/skill-index-service.js +126 -0
  85. package/dist/application/skills/skill-payload.js +186 -0
  86. package/dist/application/skills/skill-registry-service.js +648 -0
  87. package/dist/application/skills/skill-resolver.js +368 -0
  88. package/dist/application/skills/skill-seed-service.js +242 -0
  89. package/dist/application/skills/skill-status-service.js +147 -0
  90. package/dist/cli/bun-bin.js +0 -0
  91. package/dist/cli/cli-flags.js +1 -387
  92. package/dist/cli/cli-help.js +1 -173
  93. package/dist/cli/cli-helpers.js +1 -77
  94. package/dist/cli/cli-types.js +1 -1
  95. package/dist/cli/commands/agent-skill-dispatcher.js +1 -700
  96. package/dist/cli/commands/index.js +1 -9
  97. package/dist/cli/commands/interactive-entrypoint-dispatcher.js +1 -14
  98. package/dist/cli/commands/mcp-dispatcher.js +1 -232
  99. package/dist/cli/commands/memory-sdd-dispatcher.js +1 -367
  100. package/dist/cli/commands/run-permission-dispatcher.js +1 -455
  101. package/dist/cli/commands/setup-dispatcher.js +1 -496
  102. package/dist/cli/commands/status-dispatcher.js +1 -130
  103. package/dist/cli/commands/verification-dispatcher.js +1 -47
  104. package/dist/cli/commands/workflow-dispatcher.js +1 -566
  105. package/dist/cli/dispatcher.js +1 -247
  106. package/dist/cli/doctor-renderer.js +1 -26
  107. package/dist/cli/home-tui-app.js +1 -411
  108. package/dist/cli/home-tui-controller.js +1 -314
  109. package/dist/cli/mcp-start-path.js +1 -21
  110. package/dist/cli/product-resume-renderer.js +1 -32
  111. package/dist/cli/product-status-renderer.js +1 -81
  112. package/dist/cli/sdd-renderer.js +1 -247
  113. package/dist/cli/setup-plan-renderer.js +1 -79
  114. package/dist/cli/setup-status-renderer.js +1 -50
  115. package/dist/cli/setup-tui-app.js +1 -130
  116. package/dist/cli/setup-tui-controller.js +1 -89
  117. package/dist/cli/tui/focus-reducer.js +1 -0
  118. package/dist/cli/tui/focus-types.js +1 -0
  119. package/dist/cli/tui/ink/app-shell.js +1 -0
  120. package/dist/cli/tui/ink/components.js +1 -38
  121. package/dist/cli/tui/ink/help-overlay.js +1 -0
  122. package/dist/cli/tui/ink/state-components.js +1 -0
  123. package/dist/cli/tui/ink/theme.js +1 -36
  124. package/dist/cli/tui/key-intents.js +1 -0
  125. package/dist/cli/tui/keymap.js +1 -20
  126. package/dist/cli/tui/navigation.js +1 -10
  127. package/dist/cli/tui/screen-registry.js +1 -0
  128. package/dist/cli/tui/terminal-capabilities.js +1 -12
  129. package/dist/cli/tui/tui-types.js +1 -1
  130. package/dist/cli/tui/visual/badges.js +1 -19
  131. package/dist/cli/tui/visual/footer.js +1 -27
  132. package/dist/cli/tui/visual/index.js +1 -3
  133. package/dist/cli/tui/visual/viewport.js +1 -11
  134. package/dist/cli/tui-render-helpers.js +1 -200
  135. package/dist/cli/verification-plan-renderer.js +1 -25
  136. package/dist/cli/verification-report-renderer.js +1 -19
  137. package/dist/domain/agents/canonical-agent-manifest.js +355 -0
  138. package/dist/domain/agents/schema.js +1 -0
  139. package/dist/domain/memory/active-work-topics.js +64 -0
  140. package/dist/domain/memory/memory-capture-schema.js +1 -0
  141. package/dist/domain/memory/schema.js +1 -0
  142. package/dist/domain/runs/schema.js +5 -0
  143. package/dist/domain/sdd/cockpit-types.js +1 -0
  144. package/dist/domain/sdd/schema.js +111 -0
  145. package/dist/domain/skills/schema.js +1 -0
  146. package/dist/governance/risk-classifier.js +2 -0
  147. package/dist/interfaces/cli/bun-bin.js +46 -0
  148. package/dist/interfaces/cli/cli-flags.js +391 -0
  149. package/dist/interfaces/cli/cli-help.js +173 -0
  150. package/dist/interfaces/cli/cli-helpers.js +77 -0
  151. package/dist/interfaces/cli/cli-types.js +1 -0
  152. package/dist/interfaces/cli/commands/agent-skill-dispatcher.js +700 -0
  153. package/dist/interfaces/cli/commands/index.js +9 -0
  154. package/dist/interfaces/cli/commands/interactive-entrypoint-dispatcher.js +14 -0
  155. package/dist/interfaces/cli/commands/mcp-dispatcher.js +252 -0
  156. package/dist/interfaces/cli/commands/memory-sdd-dispatcher.js +367 -0
  157. package/dist/interfaces/cli/commands/run-permission-dispatcher.js +460 -0
  158. package/dist/interfaces/cli/commands/setup-dispatcher.js +496 -0
  159. package/dist/interfaces/cli/commands/status-dispatcher.js +130 -0
  160. package/dist/interfaces/cli/commands/verification-dispatcher.js +47 -0
  161. package/dist/interfaces/cli/commands/workflow-dispatcher.js +566 -0
  162. package/dist/interfaces/cli/dispatcher.js +247 -0
  163. package/dist/interfaces/cli/doctor-renderer.js +26 -0
  164. package/dist/interfaces/cli/home-tui-app.js +462 -0
  165. package/dist/interfaces/cli/home-tui-controller.js +341 -0
  166. package/dist/interfaces/cli/index.js +27 -0
  167. package/dist/interfaces/cli/mcp-start-path.js +21 -0
  168. package/dist/interfaces/cli/product-resume-renderer.js +32 -0
  169. package/dist/interfaces/cli/product-status-renderer.js +81 -0
  170. package/dist/interfaces/cli/sdd-renderer.js +247 -0
  171. package/dist/interfaces/cli/setup-plan-renderer.js +79 -0
  172. package/dist/interfaces/cli/setup-status-renderer.js +50 -0
  173. package/dist/interfaces/cli/setup-tui-app.js +135 -0
  174. package/dist/interfaces/cli/setup-tui-controller.js +89 -0
  175. package/dist/interfaces/cli/tui/focus-reducer.js +60 -0
  176. package/dist/interfaces/cli/tui/focus-types.js +10 -0
  177. package/dist/interfaces/cli/tui/ink/app-shell.js +16 -0
  178. package/dist/interfaces/cli/tui/ink/components.js +38 -0
  179. package/dist/interfaces/cli/tui/ink/help-overlay.js +6 -0
  180. package/dist/interfaces/cli/tui/ink/state-components.js +22 -0
  181. package/dist/interfaces/cli/tui/ink/theme.js +36 -0
  182. package/dist/interfaces/cli/tui/key-intents.js +33 -0
  183. package/dist/interfaces/cli/tui/keymap.js +20 -0
  184. package/dist/interfaces/cli/tui/navigation.js +10 -0
  185. package/dist/interfaces/cli/tui/screen-registry.js +43 -0
  186. package/dist/interfaces/cli/tui/terminal-capabilities.js +12 -0
  187. package/dist/interfaces/cli/tui/tui-types.js +1 -0
  188. package/dist/interfaces/cli/tui/visual/badges.js +19 -0
  189. package/dist/interfaces/cli/tui/visual/footer.js +27 -0
  190. package/dist/interfaces/cli/tui/visual/index.js +3 -0
  191. package/dist/interfaces/cli/tui/visual/viewport.js +11 -0
  192. package/dist/interfaces/cli/tui-render-helpers.js +200 -0
  193. package/dist/interfaces/cli/verification-plan-renderer.js +25 -0
  194. package/dist/interfaces/cli/verification-report-renderer.js +19 -0
  195. package/dist/interfaces/mcp/contracts/agents.js +1 -0
  196. package/dist/interfaces/mcp/contracts/context.js +1 -0
  197. package/dist/interfaces/mcp/contracts/governance.js +1 -0
  198. package/dist/interfaces/mcp/contracts/index.js +1 -0
  199. package/dist/interfaces/mcp/contracts/memory.js +1 -0
  200. package/dist/interfaces/mcp/contracts/providers.js +1 -0
  201. package/dist/interfaces/mcp/contracts/runs.js +1 -0
  202. package/dist/interfaces/mcp/contracts/sdd.js +1 -0
  203. package/dist/interfaces/mcp/contracts/sessions.js +1 -0
  204. package/dist/interfaces/mcp/contracts/skills.js +1 -0
  205. package/dist/interfaces/mcp/contracts/verification.js +1 -0
  206. package/dist/interfaces/mcp/control-plane/handlers/agents.js +38 -0
  207. package/dist/interfaces/mcp/control-plane/handlers/context.js +12 -0
  208. package/dist/interfaces/mcp/control-plane/handlers/memory.js +95 -0
  209. package/dist/interfaces/mcp/control-plane/handlers/providers.js +19 -0
  210. package/dist/interfaces/mcp/control-plane/handlers/runs.js +134 -0
  211. package/dist/interfaces/mcp/control-plane/handlers/sdd.js +225 -0
  212. package/dist/interfaces/mcp/control-plane/handlers/sessions.js +39 -0
  213. package/dist/interfaces/mcp/control-plane/handlers/skills.js +82 -0
  214. package/dist/interfaces/mcp/control-plane/handlers/verification.js +11 -0
  215. package/dist/interfaces/mcp/control-plane/types.js +1 -0
  216. package/dist/interfaces/mcp/control-plane.js +235 -0
  217. package/dist/interfaces/mcp/schema.js +174 -0
  218. package/dist/interfaces/mcp/schemas/common.js +121 -0
  219. package/dist/interfaces/mcp/schemas/inputs/agents.js +69 -0
  220. package/dist/interfaces/mcp/schemas/inputs/context.js +32 -0
  221. package/dist/interfaces/mcp/schemas/inputs/governance.js +23 -0
  222. package/dist/interfaces/mcp/schemas/inputs/index.js +10 -0
  223. package/dist/interfaces/mcp/schemas/inputs/memory.js +50 -0
  224. package/dist/interfaces/mcp/schemas/inputs/providers.js +35 -0
  225. package/dist/interfaces/mcp/schemas/inputs/runs.js +146 -0
  226. package/dist/interfaces/mcp/schemas/inputs/sdd.js +102 -0
  227. package/dist/interfaces/mcp/schemas/inputs/sessions.js +32 -0
  228. package/dist/interfaces/mcp/schemas/inputs/skills.js +231 -0
  229. package/dist/interfaces/mcp/schemas/inputs/verification.js +9 -0
  230. package/dist/interfaces/mcp/schemas/outputs/index.js +2 -0
  231. package/dist/interfaces/mcp/schemas/outputs/providers.js +28 -0
  232. package/dist/interfaces/mcp/schemas/outputs/sdd.js +166 -0
  233. package/dist/interfaces/mcp/stdio-server.js +116 -0
  234. package/dist/interfaces/mcp/validation/agents.js +189 -0
  235. package/dist/interfaces/mcp/validation/common.js +415 -0
  236. package/dist/interfaces/mcp/validation/governance.js +50 -0
  237. package/dist/interfaces/mcp/validation/memory.js +133 -0
  238. package/dist/interfaces/mcp/validation/providers.js +94 -0
  239. package/dist/interfaces/mcp/validation/runs.js +514 -0
  240. package/dist/interfaces/mcp/validation/sdd.js +247 -0
  241. package/dist/interfaces/mcp/validation/sessions.js +51 -0
  242. package/dist/interfaces/mcp/validation/skills.js +685 -0
  243. package/dist/interfaces/mcp/validation/verification.js +24 -0
  244. package/dist/interfaces/mcp/validation.js +149 -0
  245. package/dist/mcp/control-plane-snapshot-service.js +65 -2
  246. package/dist/mcp/control-plane.js +1 -646
  247. package/dist/mcp/doctor.js +1 -1
  248. package/dist/mcp/index.js +17 -17
  249. package/dist/mcp/schema.js +1 -1072
  250. package/dist/mcp/stdio-server.js +1 -116
  251. package/dist/mcp/validation.js +1 -2239
  252. package/dist/memory/active-work-preview.js +1 -75
  253. package/dist/memory/active-work-topics.js +1 -64
  254. package/dist/memory/agent-memory-capture-service.js +1 -497
  255. package/dist/memory/import/dry-run-planner.js +1 -58
  256. package/dist/memory/import/index.js +1 -3
  257. package/dist/memory/import/observation-writer.js +1 -226
  258. package/dist/memory/import/package.js +1 -179
  259. package/dist/memory/memory-capture-schema.js +1 -1
  260. package/dist/memory/memory-service.js +1 -201
  261. package/dist/memory/repositories/artifacts.js +1 -67
  262. package/dist/memory/repositories/observations.js +1 -217
  263. package/dist/memory/repositories/sessions.js +1 -125
  264. package/dist/memory/repositories/traces.js +1 -78
  265. package/dist/memory/schema.js +1 -1
  266. package/dist/memory/search.js +1 -11
  267. package/dist/memory/sqlite/database.js +1 -228
  268. package/dist/memory/storage-paths.js +1 -72
  269. package/dist/payload/context-budget-policy.js +10 -0
  270. package/dist/payload/context-budget-service.js +26 -0
  271. package/dist/payload/payload-diagnostics.js +50 -0
  272. package/dist/permissions/explicit-request-authorization.js +126 -0
  273. package/dist/permissions/policy-evaluator.js +54 -14
  274. package/dist/runs/execution-planning.js +1 -178
  275. package/dist/runs/operation-execution.js +1 -1
  276. package/dist/runs/operation-retry.js +1 -129
  277. package/dist/runs/repositories/runs.js +1 -676
  278. package/dist/runs/repositories/task-scoped-command-grants.js +1 -462
  279. package/dist/runs/resume-after-approval-result.js +1 -84
  280. package/dist/runs/run-insights.js +1 -270
  281. package/dist/runs/run-service.js +1 -1439
  282. package/dist/runs/run-snapshot-export-service.js +1 -31
  283. package/dist/runs/sandbox-process-execution.js +1 -240
  284. package/dist/runs/sandbox-worktree-planning.js +1 -59
  285. package/dist/runs/schema.js +1 -5
  286. package/dist/runs/task-scoped-command-grant-service.js +1 -216
  287. package/dist/sdd/artifact-portability-service.js +1 -137
  288. package/dist/sdd/cockpit-read-model.js +1 -195
  289. package/dist/sdd/cockpit-types.js +1 -1
  290. package/dist/sdd/schema.js +1 -111
  291. package/dist/sdd/sdd-continuation-plan.js +1 -265
  292. package/dist/sdd/sdd-workflow-service.js +1 -822
  293. package/dist/setup/providers/claude-setup-adapter.js +11 -4
  294. package/dist/setup/providers/opencode-setup-adapter.js +10 -7
  295. package/dist/setup/setup-plan.js +20 -7
  296. package/dist/skills/boot-seed.js +1 -42
  297. package/dist/skills/personal-skills.js +1 -41
  298. package/dist/skills/repositories/skill-evaluation-requests.js +1 -190
  299. package/dist/skills/repositories/skill-evaluation-scenarios.js +1 -305
  300. package/dist/skills/repositories/skill-improvement-proposals.js +1 -355
  301. package/dist/skills/repositories/skills.js +1 -1077
  302. package/dist/skills/schema.js +1 -1
  303. package/dist/skills/skill-export-service.js +1 -34
  304. package/dist/skills/skill-index-service.js +1 -126
  305. package/dist/skills/skill-payload.js +1 -186
  306. package/dist/skills/skill-registry-service.js +1 -644
  307. package/dist/skills/skill-resolver.js +1 -368
  308. package/dist/skills/skill-seed-service.js +1 -242
  309. package/dist/skills/skill-status-service.js +1 -147
  310. package/dist/storage/agents/repositories/agent-seed-history.js +128 -0
  311. package/dist/storage/agents/repositories/agents.js +200 -0
  312. package/dist/storage/agents/repositories/manager-profile-overlays.js +90 -0
  313. package/dist/storage/memory/repositories/artifacts.js +67 -0
  314. package/dist/storage/memory/repositories/observations.js +217 -0
  315. package/dist/storage/memory/repositories/sessions.js +125 -0
  316. package/dist/storage/memory/repositories/traces.js +78 -0
  317. package/dist/storage/memory/sqlite/database.js +228 -0
  318. package/dist/storage/memory/storage-paths.js +72 -0
  319. package/dist/storage/runs/repositories/runs.js +676 -0
  320. package/dist/storage/runs/repositories/task-scoped-command-grants.js +464 -0
  321. package/dist/storage/skills/repositories/skill-evaluation-requests.js +190 -0
  322. package/dist/storage/skills/repositories/skill-evaluation-scenarios.js +305 -0
  323. package/dist/storage/skills/repositories/skill-improvement-proposals.js +355 -0
  324. package/dist/storage/skills/repositories/skills.js +1084 -0
  325. package/docs/architecture.md +2 -2
  326. package/docs/glossary.md +1 -1
  327. package/docs/mcp.md +1 -1
  328. package/docs/module-boundaries.md +114 -0
  329. package/docs/prd.md +1 -1
  330. package/docs/project-health-audit-v1.10.x.md +1 -1
  331. package/docs/providers.md +2 -2
  332. package/docs/safety.md +3 -3
  333. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/apply-progress.md +122 -0
  334. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/archive-report.md +61 -0
  335. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/design.md +66 -0
  336. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/proposal.md +79 -0
  337. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/spec.md +67 -0
  338. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/tasks.md +63 -0
  339. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/verify-report.md +71 -0
  340. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/apply-progress.md +68 -0
  341. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/archive-report.md +61 -0
  342. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/design.md +43 -0
  343. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/proposal.md +61 -0
  344. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/spec.md +31 -0
  345. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/tasks.md +27 -0
  346. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/verify-report.md +58 -0
  347. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/apply-progress.md +65 -0
  348. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/archive-report.md +53 -0
  349. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/design.md +64 -0
  350. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/proposal.md +62 -0
  351. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/spec.md +51 -0
  352. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/tasks.md +50 -0
  353. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/verify-report.md +66 -0
  354. package/docs/storage.md +2 -2
  355. package/package.json +2 -2
  356. /package/dist/{mcp → adapters/claude/install}/claude-code-cli.js +0 -0
  357. /package/dist/{memory → storage/memory}/sqlite/migrations/001_initial.sql +0 -0
  358. /package/dist/{memory → storage/memory}/sqlite/migrations/002_observation_revisions.sql +0 -0
  359. /package/dist/{memory → storage/memory}/sqlite/migrations/003_agent_registry.sql +0 -0
  360. /package/dist/{memory → storage/memory}/sqlite/migrations/004_run_runtime.sql +0 -0
  361. /package/dist/{memory → storage/memory}/sqlite/migrations/005_run_approvals.sql +0 -0
  362. /package/dist/{memory → storage/memory}/sqlite/migrations/006_run_operation_attempts.sql +0 -0
  363. /package/dist/{memory → storage/memory}/sqlite/migrations/007_abandoned_operation_attempts.sql +0 -0
  364. /package/dist/{memory → storage/memory}/sqlite/migrations/008_run_execution_plan_events.sql +0 -0
  365. /package/dist/{memory → storage/memory}/sqlite/migrations/009_multiple_operation_attempts.sql +0 -0
  366. /package/dist/{memory → storage/memory}/sqlite/migrations/010_skill_registry.sql +0 -0
  367. /package/dist/{memory → storage/memory}/sqlite/migrations/011_skill_usage_resolution_outcomes.sql +0 -0
  368. /package/dist/{memory → storage/memory}/sqlite/migrations/012_skill_improvement_proposals.sql +0 -0
  369. /package/dist/{memory → storage/memory}/sqlite/migrations/013_skill_evaluation_scenarios.sql +0 -0
  370. /package/dist/{memory → storage/memory}/sqlite/migrations/014_manager_profile_overlays.sql +0 -0
  371. /package/dist/{memory → storage/memory}/sqlite/migrations/015_artifact_metadata.sql +0 -0
  372. /package/dist/{memory → storage/memory}/sqlite/migrations/016_agent_seed_history.sql +0 -0
  373. /package/dist/{memory → storage/memory}/sqlite/migrations/017_intent_signal_skill_targets.sql +0 -0
  374. /package/dist/{memory → storage/memory}/sqlite/migrations/018_skill_system_v2.sql +0 -0
  375. /package/dist/{memory → storage/memory}/sqlite/migrations/019_task_scoped_command_grants.sql +0 -0
@@ -1,228 +1 @@
1
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
- import { createRequire } from 'node:module';
3
- import { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- const migrationsDirectory = join(dirname(fileURLToPath(import.meta.url)), 'migrations');
6
- export const sqliteBusyTimeoutMs = 5000;
7
- const bunRequiredGuidance = 'Real local SQLite storage requires Bun. Use the installed Bun-backed vgxness/vgx runtime, or run Bun storage verification with bun run verify:bun-sqlite.';
8
- export class MemoryDatabase {
9
- connection;
10
- constructor(connection) {
11
- this.connection = connection;
12
- }
13
- static open(options) {
14
- try {
15
- const connection = openSqliteConnection(options);
16
- connection.pragma('foreign_keys = ON');
17
- connection.pragma(`busy_timeout = ${sqliteBusyTimeoutMs}`);
18
- const memoryDatabase = new MemoryDatabase(connection);
19
- if (!(options.readonly ?? false)) {
20
- const migration = memoryDatabase.applyMigrations();
21
- if (!migration.ok) {
22
- connection.close();
23
- return migration;
24
- }
25
- }
26
- return { ok: true, value: memoryDatabase };
27
- }
28
- catch (cause) {
29
- return {
30
- ok: false,
31
- error: {
32
- code: 'store_unavailable',
33
- message: buildMemoryStoreUnavailableMessage(options.path, cause),
34
- cause,
35
- },
36
- };
37
- }
38
- }
39
- applyMigrations() {
40
- if (!existsSync(migrationsDirectory)) {
41
- return migrationFailure(`Migrations directory not found: ${migrationsDirectory}`);
42
- }
43
- const migrationFiles = readdirSync(migrationsDirectory)
44
- .filter((file) => file.endsWith('.sql'))
45
- .sort();
46
- try {
47
- const run = this.connection.transaction(() => {
48
- this.connection.exec(`
49
- CREATE TABLE IF NOT EXISTS schema_migrations (
50
- version TEXT PRIMARY KEY,
51
- applied_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
52
- );
53
- `);
54
- const hasMigration = this.connection.prepare('SELECT 1 FROM schema_migrations WHERE version = ?');
55
- const recordMigration = this.connection.prepare('INSERT INTO schema_migrations(version) VALUES (?)');
56
- for (const file of migrationFiles) {
57
- if (hasMigration.get(file))
58
- continue;
59
- this.connection.exec(readFileSync(join(migrationsDirectory, file), 'utf8'));
60
- recordMigration.run(file);
61
- }
62
- });
63
- run();
64
- return { ok: true, value: undefined };
65
- }
66
- catch (cause) {
67
- return migrationFailure('Failed to apply local memory migrations', cause);
68
- }
69
- }
70
- transaction(operation) {
71
- try {
72
- const run = this.connection.transaction(operation);
73
- return { ok: true, value: run.immediate() };
74
- }
75
- catch (cause) {
76
- return {
77
- ok: false,
78
- error: {
79
- code: 'transaction_failed',
80
- message: 'Local memory transaction failed and was rolled back',
81
- cause,
82
- },
83
- };
84
- }
85
- }
86
- close() {
87
- this.connection.close();
88
- }
89
- }
90
- export function openMemoryDatabase(options) {
91
- return MemoryDatabase.open(options);
92
- }
93
- export function buildMemoryStoreUnavailableMessage(path, cause) {
94
- const message = `Unable to open local memory store at ${path}`;
95
- if (!isUnsupportedSqliteRuntimeError(cause))
96
- return message;
97
- return `${message}. ${bunRequiredGuidance}`;
98
- }
99
- function openSqliteConnection(options) {
100
- return resolveSqliteDriver()(options);
101
- }
102
- function resolveSqliteDriver() {
103
- if (isBunRuntime())
104
- return resolveBunSqliteDriver();
105
- throw createUnsupportedSqliteRuntimeError();
106
- }
107
- function isBunRuntime() {
108
- return typeof globalThis.Bun !== 'undefined';
109
- }
110
- function resolveBunSqliteDriver() {
111
- const require = createRequire(import.meta.url);
112
- const module = require('bun:sqlite');
113
- const BunDatabase = module.Database;
114
- if (typeof BunDatabase !== 'function')
115
- throw new Error('bun:sqlite Database constructor is unavailable');
116
- return (options) => createBunSqliteConnection(new BunDatabase(options.path, { readonly: options.readonly ?? false, strict: true }));
117
- }
118
- function createUnsupportedSqliteRuntimeError() {
119
- const error = new Error(bunRequiredGuidance);
120
- error.name = 'UnsupportedSqliteRuntimeError';
121
- return error;
122
- }
123
- function isUnsupportedSqliteRuntimeError(cause) {
124
- return cause instanceof Error && cause.name === 'UnsupportedSqliteRuntimeError';
125
- }
126
- function createBunSqliteConnection(database) {
127
- const record = database;
128
- return {
129
- prepare(sql) {
130
- const prepare = record.prepare;
131
- if (typeof prepare !== 'function')
132
- throw new Error('bun:sqlite prepare() is unavailable');
133
- return createBunSqliteStatement(prepare.call(database, sql));
134
- },
135
- exec(sql) {
136
- const exec = record.exec;
137
- if (typeof exec === 'function')
138
- return exec.call(database, sql);
139
- const run = record.run;
140
- if (typeof run === 'function')
141
- return run.call(database, sql);
142
- throw new Error('bun:sqlite exec() is unavailable');
143
- },
144
- pragma(statement) {
145
- return runBunPragma(database, statement);
146
- },
147
- transaction(operation) {
148
- const transaction = record.transaction;
149
- if (typeof transaction !== 'function')
150
- throw new Error('bun:sqlite transaction() is unavailable');
151
- const run = transaction.call(database, operation);
152
- if (typeof run !== 'function')
153
- throw new Error('bun:sqlite transaction() did not return a callable transaction');
154
- const transactionRunner = run;
155
- if (typeof transactionRunner.immediate !== 'function') {
156
- throw new Error('bun:sqlite transaction().immediate() is unavailable');
157
- }
158
- return transactionRunner;
159
- },
160
- close() {
161
- const close = record.close;
162
- if (typeof close !== 'function')
163
- return;
164
- close.call(database, false);
165
- },
166
- };
167
- }
168
- function createBunSqliteStatement(statement) {
169
- const record = statement;
170
- return {
171
- get(...params) {
172
- const get = record.get;
173
- if (typeof get !== 'function')
174
- throw new Error('bun:sqlite statement.get() is unavailable');
175
- const row = get.call(statement, ...params);
176
- return row === null ? undefined : row;
177
- },
178
- all(...params) {
179
- const all = record.all;
180
- if (typeof all !== 'function')
181
- throw new Error('bun:sqlite statement.all() is unavailable');
182
- return all.call(statement, ...params);
183
- },
184
- run(...params) {
185
- const run = record.run;
186
- if (typeof run !== 'function')
187
- throw new Error('bun:sqlite statement.run() is unavailable');
188
- return run.call(statement, ...params);
189
- },
190
- };
191
- }
192
- function runBunPragma(database, statement) {
193
- const normalizedStatement = statement.trim();
194
- if (isPragmaSetter(normalizedStatement)) {
195
- const exec = database.exec;
196
- if (typeof exec !== 'function')
197
- throw new Error('bun:sqlite exec() is unavailable for PRAGMA setter');
198
- return exec.call(database, `PRAGMA ${normalizedStatement}`);
199
- }
200
- const prepare = database.prepare;
201
- if (typeof prepare !== 'function')
202
- throw new Error('bun:sqlite prepare() is unavailable for PRAGMA reader');
203
- const rows = prepare.call(database, `PRAGMA ${normalizedStatement}`).all();
204
- if (/^busy_timeout\b/i.test(normalizedStatement))
205
- return normalizeBusyTimeoutRows(rows);
206
- return rows;
207
- }
208
- function isPragmaSetter(statement) {
209
- return /=/.test(statement);
210
- }
211
- function normalizeBusyTimeoutRows(rows) {
212
- return rows.map((row) => {
213
- if (row === null || typeof row !== 'object')
214
- return row;
215
- const record = row;
216
- if (typeof record.timeout === 'number')
217
- return row;
218
- if (typeof record.busy_timeout === 'number')
219
- return { timeout: record.busy_timeout };
220
- return row;
221
- });
222
- }
223
- function migrationFailure(message, cause) {
224
- const error = { code: 'migration_failed', message };
225
- if (cause !== undefined)
226
- error.cause = cause;
227
- return { ok: false, error };
228
- }
1
+ export * from '../../storage/memory/sqlite/database.js';
@@ -1,72 +1 @@
1
- import { mkdirSync } from 'node:fs';
2
- import path, { dirname, resolve } from 'node:path';
3
- export function resolveMemoryDatabasePath(input) {
4
- if (hasPathValue(input.explicitPath)) {
5
- return { ok: true, value: { path: absolutePath(input.cwd, input.explicitPath), source: 'flag' } };
6
- }
7
- if (hasPathValue(input.env.VGXNESS_DB_PATH)) {
8
- return { ok: true, value: { path: absolutePath(input.cwd, input.env.VGXNESS_DB_PATH), source: 'environment' } };
9
- }
10
- const globalPath = defaultGlobalMemoryDatabasePath({ env: input.env, platform: input.platform });
11
- return globalPath.ok ? { ok: true, value: { path: globalPath.value, source: 'global-default' } } : globalPath;
12
- }
13
- export function defaultGlobalMemoryDatabasePath(input) {
14
- const platform = input.platform ?? process.platform;
15
- if (platform === 'darwin')
16
- return homeRelativePath(input.env, ['Library', 'Application Support', 'vgxness', 'memory.sqlite']);
17
- if (platform === 'win32')
18
- return windowsAppDataPath(input.env);
19
- return linuxDataPath(input.env);
20
- }
21
- export function prepareMemoryDatabasePath(databasePath) {
22
- try {
23
- mkdirSync(dirname(databasePath), { recursive: true });
24
- return { ok: true, value: databasePath };
25
- }
26
- catch (cause) {
27
- return {
28
- ok: false,
29
- error: {
30
- code: 'store_unavailable',
31
- message: `Unable to prepare local memory store directory at ${dirname(databasePath)}`,
32
- cause,
33
- },
34
- };
35
- }
36
- }
37
- function linuxDataPath(env) {
38
- if (hasPathValue(env.XDG_DATA_HOME))
39
- return { ok: true, value: path.join(env.XDG_DATA_HOME, 'vgxness', 'memory.sqlite') };
40
- return homeRelativePath(env, ['.local', 'share', 'vgxness', 'memory.sqlite']);
41
- }
42
- function windowsAppDataPath(env) {
43
- if (hasPathValue(env.LOCALAPPDATA))
44
- return { ok: true, value: path.win32.join(env.LOCALAPPDATA, 'vgxness', 'memory.sqlite') };
45
- if (hasPathValue(env.APPDATA))
46
- return { ok: true, value: path.win32.join(env.APPDATA, 'vgxness', 'memory.sqlite') };
47
- return missingBase('LOCALAPPDATA or APPDATA');
48
- }
49
- function homeRelativePath(env, segments) {
50
- const home = userHome(env);
51
- if (!hasPathValue(home))
52
- return missingBase('HOME');
53
- return { ok: true, value: path.join(home, ...segments) };
54
- }
55
- function userHome(env) {
56
- return env.HOME;
57
- }
58
- function missingBase(variable) {
59
- return {
60
- ok: false,
61
- error: {
62
- code: 'store_unavailable',
63
- message: `Unable to resolve global memory store path because ${variable} is not set. Provide --db or VGXNESS_DB_PATH to select an explicit database.`,
64
- },
65
- };
66
- }
67
- function absolutePath(cwd, configuredPath) {
68
- return path.isAbsolute(configuredPath) ? configuredPath : resolve(cwd, configuredPath);
69
- }
70
- function hasPathValue(value) {
71
- return value !== undefined && value.trim().length > 0;
72
- }
1
+ export * from '../storage/memory/storage-paths.js';
@@ -7,6 +7,16 @@ export const defaultContextBudgetPolicy = {
7
7
  { id: 'snapshotExpanded', label: 'Expanded snapshot', targetBytes: 30_720, hardLimitBytes: 46_080, enforcement: 'report' },
8
8
  { id: 'subagentVerbosePayload', label: 'Subagent verbose payload', targetBytes: 122_880, hardLimitBytes: 184_320, enforcement: 'report' },
9
9
  { id: 'initialMcpCalls', label: 'Initial MCP calls', targetBytes: 3, hardLimitBytes: 5, enforcement: 'report' },
10
+ { id: 'providerManagerPayload', label: 'Provider manager payload', targetBytes: 24_576, hardLimitBytes: 36_864, enforcement: 'warn' },
11
+ { id: 'providerArtifactSection', label: 'Provider artifact section', targetBytes: 12_288, hardLimitBytes: 18_432, enforcement: 'warn' },
12
+ { id: 'sddArtifactCompact', label: 'Compact SDD artifact', targetBytes: 8_192, hardLimitBytes: 12_288, enforcement: 'warn' },
13
+ { id: 'sddArtifactVerbose', label: 'Verbose SDD artifact', targetBytes: 65_536, hardLimitBytes: 98_304, enforcement: 'report' },
14
+ { id: 'skillPayloadCompact', label: 'Compact skill payload', targetBytes: 12_288, hardLimitBytes: 18_432, enforcement: 'warn' },
15
+ { id: 'skillPayloadVerbose', label: 'Verbose skill payload', targetBytes: 65_536, hardLimitBytes: 98_304, enforcement: 'report' },
16
+ { id: 'contextCockpitCompact', label: 'Compact context cockpit', targetBytes: 10_240, hardLimitBytes: 15_360, enforcement: 'warn' },
17
+ { id: 'contextCockpitExpanded', label: 'Expanded context cockpit', targetBytes: 30_720, hardLimitBytes: 46_080, enforcement: 'report' },
18
+ { id: 'opencodeHandoffPreview', label: 'OpenCode handoff preview', targetBytes: 16_384, hardLimitBytes: 24_576, enforcement: 'warn' },
19
+ { id: 'subagentResultDraft', label: 'Subagent result draft', targetBytes: 16_384, hardLimitBytes: 24_576, enforcement: 'warn' },
10
20
  ],
11
21
  };
12
22
  export function getContextBudgetLimit(policy, id) {
@@ -17,6 +17,12 @@ export class ContextBudgetService {
17
17
  reportJson(id, value) {
18
18
  return this.buildReport(id, this.measureJsonBytes(value));
19
19
  }
20
+ reportContentV2(id, content, options = {}) {
21
+ return this.buildReportV2(id, this.measureUtf8Bytes(content), options);
22
+ }
23
+ reportJsonV2(id, value, options = {}) {
24
+ return this.buildReportV2(id, this.measureJsonBytes(value), options);
25
+ }
20
26
  buildReport(id, measuredBytes) {
21
27
  if (!Number.isSafeInteger(measuredBytes) || measuredBytes < 0)
22
28
  throw new RangeError('measuredBytes must be a non-negative safe integer');
@@ -34,6 +40,26 @@ export class ContextBudgetService {
34
40
  recommendations: budgetRecommendations(budget, excessTargetBytes, excessHardLimitBytes),
35
41
  };
36
42
  }
43
+ buildReportV2(id, measuredBytes, options = {}) {
44
+ const report = this.buildReport(id, measuredBytes);
45
+ return {
46
+ ...report,
47
+ severity: budgetSeverity(report),
48
+ ...(options.includeApproximateTokens === true ? { approximateTokens: approximateTokenEstimate(measuredBytes) } : {}),
49
+ };
50
+ }
51
+ }
52
+ export function approximateTokenEstimate(measuredBytes) {
53
+ if (!Number.isSafeInteger(measuredBytes) || measuredBytes < 0)
54
+ throw new RangeError('measuredBytes must be a non-negative safe integer');
55
+ return Math.ceil(measuredBytes / 4);
56
+ }
57
+ function budgetSeverity(report) {
58
+ if (!report.withinHardLimit)
59
+ return 'hard-limit-exceeded';
60
+ if (!report.withinTarget)
61
+ return 'target-exceeded';
62
+ return 'ok';
37
63
  }
38
64
  function budgetRecommendations(budget, excessTargetBytes, excessHardLimitBytes) {
39
65
  if (excessHardLimitBytes > 0)
@@ -0,0 +1,50 @@
1
+ import { responseByteAccounting, sha256Hex, utf8ByteCount } from './payload-summary.js';
2
+ export function buildPayloadSectionAccounting(input) {
3
+ const bytes = resolveSectionBytes(input);
4
+ const contentHash = input.contentHash ?? (input.content === undefined ? undefined : sha256Hex(input.content));
5
+ return {
6
+ id: input.id,
7
+ ...(input.label === undefined ? {} : { label: input.label }),
8
+ bytes,
9
+ ...(contentHash === undefined ? {} : { contentHash }),
10
+ included: input.included,
11
+ ...(input.omittedBytes === undefined ? {} : { omittedBytes: input.omittedBytes }),
12
+ ...(input.ref === undefined ? {} : { ref: input.ref }),
13
+ ...(input.notes === undefined ? {} : { notes: input.notes }),
14
+ };
15
+ }
16
+ export function buildCompositePayloadDiagnostics(sections, largestSectionLimit = sections.length) {
17
+ if (!Number.isSafeInteger(largestSectionLimit) || largestSectionLimit < 0)
18
+ throw new RangeError('largestSectionLimit must be a non-negative safe integer');
19
+ const totalBytes = sections.reduce((total, section) => total + section.bytes, 0);
20
+ const includedBytes = sections.filter((section) => section.included).reduce((total, section) => total + section.bytes, 0);
21
+ const omittedBytes = sections.reduce((total, section) => total + (section.included ? (section.omittedBytes ?? 0) : section.bytes), 0);
22
+ return {
23
+ totalBytes,
24
+ includedBytes,
25
+ omittedBytes,
26
+ sections,
27
+ largestSections: [...sections].sort((left, right) => right.bytes - left.bytes).slice(0, largestSectionLimit),
28
+ };
29
+ }
30
+ export function buildCompactVerboseDiagnostics(verboseValue, compactValue, options = {}) {
31
+ const verboseJson = JSON.stringify(verboseValue);
32
+ const compactJson = JSON.stringify(compactValue);
33
+ return {
34
+ accounting: responseByteAccounting(verboseValue, compactValue),
35
+ compact: { bytes: utf8ByteCount(compactJson), contentHash: sha256Hex(compactJson) },
36
+ verbose: { bytes: utf8ByteCount(verboseJson), contentHash: sha256Hex(verboseJson) },
37
+ ...(options.retrievalRef === undefined ? {} : { retrievalRef: options.retrievalRef }),
38
+ ...(options.notes === undefined ? {} : { notes: options.notes }),
39
+ };
40
+ }
41
+ function resolveSectionBytes(input) {
42
+ if (input.bytes !== undefined) {
43
+ if (!Number.isSafeInteger(input.bytes) || input.bytes < 0)
44
+ throw new RangeError('bytes must be a non-negative safe integer');
45
+ return input.bytes;
46
+ }
47
+ if (input.content !== undefined)
48
+ return utf8ByteCount(input.content);
49
+ throw new Error('Payload section accounting requires either bytes or content.');
50
+ }
@@ -0,0 +1,126 @@
1
+ import { isAbsolute, resolve } from 'node:path';
2
+ export function evaluateExplicitRequestAuthorization(input) {
3
+ const explicit = input.request.explicitRequest;
4
+ if (explicit === undefined)
5
+ return evaluation(input, 'ask', 'missing-context', ['explicit_request_missing']);
6
+ if (explicit.actor.type !== 'human')
7
+ return evaluation(input, 'ask', 'actor-mismatch', ['explicit_request_actor_mismatch']);
8
+ if (!validIsoTimestamp(explicit.request.requestedAt))
9
+ return evaluation(input, 'ask', 'timestamp-invalid', ['explicit_request_timestamp_invalid']);
10
+ if (explicit.request.runId !== undefined && input.request.runId !== undefined && explicit.request.runId !== input.request.runId)
11
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
12
+ if (explicit.parser.exact !== true || explicit.parser.confidence === 'medium' || explicit.parser.confidence === 'low' || hasItems(explicit.parser.ambiguityReasons))
13
+ return evaluation(input, 'ask', 'ambiguous-request', ['explicit_request_ambiguous']);
14
+ if (hasItems(explicit.parser.expansionReasons))
15
+ return evaluation(input, 'ask', 'scope-expanded', ['explicit_request_scope_expanded']);
16
+ if (isSddAcceptanceAttempt(input.request))
17
+ return evaluation(input, 'deny', 'hard-stop', ['sdd_human_acceptance_required']);
18
+ if (input.request.category === 'secrets' || input.risk.reasonCodes.includes('secret_access') || explicit.riskAttributes.secrets === true)
19
+ return evaluation(input, 'deny', 'hard-stop', ['explicit_request_secret_access']);
20
+ if (explicit.requestedOperation.category !== input.request.category)
21
+ return evaluation(input, 'ask', 'category-mismatch', ['explicit_request_category_mismatch']);
22
+ if (normalizeOperation(explicit.requestedOperation.operation) !== normalizeOperation(input.request.operation))
23
+ return evaluation(input, 'ask', 'operation-mismatch', ['explicit_request_operation_mismatch']);
24
+ if (!optionalExact(explicit.requestedOperation.commandId, input.request.commandId))
25
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
26
+ if (!optionalExact(explicit.requestedOperation.providerToolName, input.request.providerToolName))
27
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
28
+ if (!optionalPathExact(explicit.requestedOperation.workspaceRoot, input.request.workspaceRoot, input.request.workspaceRoot))
29
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
30
+ if (!optionalPathExact(explicit.requestedOperation.cwd, input.request.cwd, input.request.workspaceRoot))
31
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
32
+ if (!targetSetMatches(input.request, explicit.requestedOperation))
33
+ return evaluation(input, 'ask', 'scope-mismatch', ['explicit_request_scope_mismatch']);
34
+ const riskMismatch = riskMismatchReasons(input.request, input.risk, explicit.riskAttributes);
35
+ if (riskMismatch.length > 0)
36
+ return evaluation(input, 'ask', 'risk-attribute-mismatch', riskMismatch);
37
+ return evaluation(input, 'allow', 'exact-match', ['explicit_request_exact_match']);
38
+ }
39
+ function evaluation(input, decision, matchStatus, reasonCodes) {
40
+ const explicit = input.request.explicitRequest;
41
+ return {
42
+ decision,
43
+ audit: {
44
+ authorization: 'explicit-request',
45
+ matched: decision === 'allow',
46
+ matchStatus,
47
+ ...(explicit?.request.id === undefined ? {} : { requestRef: explicit.request.id }),
48
+ ...(explicit?.actor === undefined ? {} : { actor: explicit.actor }),
49
+ ...(explicit?.request.requestedAt === undefined ? {} : { requestedAt: explicit.request.requestedAt }),
50
+ evaluatedAt: input.evaluatedAt,
51
+ runId: input.request.runId ?? explicit?.request.runId ?? '',
52
+ category: input.request.category,
53
+ operation: input.request.operation,
54
+ scopeSummary: explicit?.requestedOperation.scopeSummary ?? '',
55
+ riskAttributes: explicitRiskAttributes(explicit?.riskAttributes),
56
+ reasonCodes,
57
+ },
58
+ };
59
+ }
60
+ function riskMismatchReasons(request, risk, explicit) {
61
+ const reasons = [];
62
+ if (request.destructive === true && explicit.destructive !== true)
63
+ reasons.push('explicit_request_destructive_not_explicit');
64
+ if (request.privileged === true && explicit.privileged !== true)
65
+ reasons.push('explicit_request_privileged_not_explicit');
66
+ if ((request.external === true || risk.reasonCodes.includes('external_operation')) && explicit.external !== true && explicit.network !== true && explicit.install !== true)
67
+ reasons.push('explicit_request_external_not_explicit');
68
+ if (request.ambiguous === true && explicit.ambiguous !== true)
69
+ reasons.push('explicit_request_ambiguous');
70
+ if (request.globalConfigMutation === true && explicit.globalConfigMutation !== true)
71
+ reasons.push('explicit_request_global_config_not_explicit');
72
+ if (request.providerConfigMutation === true && explicit.providerConfigMutation !== true)
73
+ reasons.push('explicit_request_provider_config_not_explicit');
74
+ if (request.providerConfigMutation !== true && request.globalConfigMutation !== true && risk.reasonCodes.includes('provider_config_write') && explicit.providerConfigMutation !== true)
75
+ reasons.push('explicit_request_provider_config_not_explicit');
76
+ if (request.category === 'network' && explicit.network !== true)
77
+ reasons.push('explicit_request_risk_mismatch');
78
+ if (request.category === 'install' && explicit.install !== true)
79
+ reasons.push('explicit_request_risk_mismatch');
80
+ return [...new Set(reasons)];
81
+ }
82
+ function targetSetMatches(request, explicit) {
83
+ const requested = targetSet(request.targetPath, request.targetPaths, request.workspaceRoot);
84
+ const authorized = targetSet(explicit.targetPath, explicit.targetPaths, request.workspaceRoot ?? explicit.workspaceRoot);
85
+ if (requested.length === 0 && authorized.length === 0)
86
+ return true;
87
+ if (requested.length === 0 || authorized.length === 0)
88
+ return false;
89
+ if (requested.length !== authorized.length)
90
+ return false;
91
+ return requested.every((value, index) => value === authorized[index]);
92
+ }
93
+ function targetSet(targetPath, targetPaths, workspaceRoot) {
94
+ return [...new Set([...(targetPath === undefined ? [] : [targetPath]), ...(targetPaths ?? [])].map((path) => normalizePath(path, workspaceRoot)))].sort();
95
+ }
96
+ function optionalExact(explicit, actual) {
97
+ return actual === undefined ? explicit === undefined : explicit === actual;
98
+ }
99
+ function optionalPathExact(explicit, actual, workspaceRoot) {
100
+ return actual === undefined ? explicit === undefined : explicit !== undefined && normalizePath(explicit, workspaceRoot) === normalizePath(actual, workspaceRoot);
101
+ }
102
+ function normalizePath(path, workspaceRoot) {
103
+ const base = workspaceRoot === undefined ? undefined : resolve(workspaceRoot);
104
+ return resolve(isAbsolute(path) || base === undefined ? path : resolve(base, path));
105
+ }
106
+ function normalizeOperation(value) {
107
+ return value.trim().replace(/\s+/g, ' ');
108
+ }
109
+ function hasItems(values) {
110
+ return values !== undefined && values.length > 0;
111
+ }
112
+ function validIsoTimestamp(value) {
113
+ const timestamp = Date.parse(value);
114
+ return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value && timestamp <= Date.now() + 60_000;
115
+ }
116
+ function explicitRiskAttributes(value) {
117
+ const output = {};
118
+ for (const key of ['destructive', 'privileged', 'external', 'ambiguous', 'secrets', 'providerConfigMutation', 'globalConfigMutation', 'network', 'install']) {
119
+ output[key] = value?.[key] === true;
120
+ }
121
+ return output;
122
+ }
123
+ function isSddAcceptanceAttempt(request) {
124
+ const text = `${request.category} ${request.operation} ${request.providerToolName ?? ''}`.toLowerCase();
125
+ return /vgxness_sdd_accept_artifact|sdd_accept_artifact|artifact acceptance|accept artifact|acceptedby/.test(text);
126
+ }