@lesliechan721/aw 0.1.0-beta.73 → 0.1.0-beta.74

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 (361) hide show
  1. package/dist/authoring/assets/aw-runtime-config.mjs +65 -43
  2. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
  3. package/dist/authoring/scripts/add-skill.mjs +5 -14
  4. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  5. package/dist/authoring/scripts/init-plugin.mjs +4 -28
  6. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  7. package/dist/authoring/scripts/lib/plugin-version-check.mjs +2 -2
  8. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  9. package/dist/authoring/scripts/lib/skill-scaffold.mjs +0 -1
  10. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  11. package/dist/authoring/scripts/validate-plugin.mjs +234 -1422
  12. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  13. package/dist/scripts/aw-skill-eval-materializer.d.ts +2 -0
  14. package/dist/scripts/aw-skill-eval-materializer.js +19 -80
  15. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  16. package/dist/scripts/bundle-plugins.js.map +1 -1
  17. package/dist/scripts/test-plugin-scripts.js +6 -8
  18. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  19. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  20. package/dist/src/commands/aw-capabilities.js +2 -2
  21. package/dist/src/commands/aw-capabilities.js.map +1 -1
  22. package/dist/src/commands/dependency-operation-plan.js +3 -3
  23. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  24. package/dist/src/commands/deployment-confirmation.d.ts +4 -0
  25. package/dist/src/commands/deployment-confirmation.js +20 -0
  26. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  27. package/dist/src/commands/managed-commands.js +4 -2
  28. package/dist/src/commands/managed-commands.js.map +1 -1
  29. package/dist/src/commands/offline-cleanup-evidence.d.ts +3 -1
  30. package/dist/src/commands/offline-cleanup-evidence.js +9 -4
  31. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  32. package/dist/src/commands/operation-plan.d.ts +6 -0
  33. package/dist/src/commands/operation-plan.js +29 -2
  34. package/dist/src/commands/operation-plan.js.map +1 -1
  35. package/dist/src/commands/options.d.ts +6 -2
  36. package/dist/src/commands/options.js +5 -4
  37. package/dist/src/commands/options.js.map +1 -1
  38. package/dist/src/commands/plugin-capabilities.js +29 -41
  39. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  40. package/dist/src/commands/public-config-confirmation.js +5 -5
  41. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  42. package/dist/src/commands/public-lifecycle-result.d.ts +47 -0
  43. package/dist/src/commands/public-lifecycle-result.js +119 -4
  44. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  45. package/dist/src/commands/public-lifecycle.d.ts +1 -0
  46. package/dist/src/commands/public-lifecycle.js +15 -2
  47. package/dist/src/commands/public-lifecycle.js.map +1 -1
  48. package/dist/src/commands/public-plugin-query.d.ts +1 -0
  49. package/dist/src/commands/public-plugin-query.js +28 -8
  50. package/dist/src/commands/public-plugin-query.js.map +1 -1
  51. package/dist/src/commands/rebuild-command.d.ts +12 -11
  52. package/dist/src/commands/rebuild-command.js +529 -769
  53. package/dist/src/commands/rebuild-command.js.map +1 -1
  54. package/dist/src/commands/rebuild-integration.d.ts +21 -43
  55. package/dist/src/commands/rebuild-integration.js +306 -3600
  56. package/dist/src/commands/rebuild-integration.js.map +1 -1
  57. package/dist/src/commands/rebuild-operations.d.ts +13 -0
  58. package/dist/src/commands/rebuild-operations.js +60 -15
  59. package/dist/src/commands/rebuild-operations.js.map +1 -1
  60. package/dist/src/commands/rebuild-platform-integration.d.ts +59 -0
  61. package/dist/src/commands/rebuild-platform-integration.js +1200 -0
  62. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  63. package/dist/src/commands/review-inspection.js +41 -4
  64. package/dist/src/commands/review-inspection.js.map +1 -1
  65. package/dist/src/commands/review-preparation.d.ts +2 -0
  66. package/dist/src/commands/review-preparation.js +23 -60
  67. package/dist/src/commands/review-preparation.js.map +1 -1
  68. package/dist/src/commands/skill-eval.js +1 -0
  69. package/dist/src/commands/skill-eval.js.map +1 -1
  70. package/dist/src/commands/status-v6.d.ts +3 -1
  71. package/dist/src/commands/status-v6.js +24 -15
  72. package/dist/src/commands/status-v6.js.map +1 -1
  73. package/dist/src/commands/targets-command.d.ts +9 -0
  74. package/dist/src/commands/targets-command.js +57 -6
  75. package/dist/src/commands/targets-command.js.map +1 -1
  76. package/dist/src/commands/write-commands.js +43 -28
  77. package/dist/src/commands/write-commands.js.map +1 -1
  78. package/dist/src/constants.d.ts +2 -2
  79. package/dist/src/constants.js +2 -2
  80. package/dist/src/constants.js.map +1 -1
  81. package/dist/src/generators/local-plugin.js +59 -248
  82. package/dist/src/generators/local-plugin.js.map +1 -1
  83. package/dist/src/index.js +40 -14
  84. package/dist/src/index.js.map +1 -1
  85. package/dist/src/output/command-receipt.d.ts +1 -1
  86. package/dist/src/output/command-receipt.js +3 -1
  87. package/dist/src/output/command-receipt.js.map +1 -1
  88. package/dist/src/output/native-consent.d.ts +2 -0
  89. package/dist/src/output/native-consent.js +5 -0
  90. package/dist/src/output/native-consent.js.map +1 -0
  91. package/dist/src/output/public-result.js +60 -0
  92. package/dist/src/output/public-result.js.map +1 -1
  93. package/dist/src/output/rebuild-progress.js +5 -5
  94. package/dist/src/output/rebuild-progress.js.map +1 -1
  95. package/dist/src/output/receipt-projection.js +19 -2
  96. package/dist/src/output/receipt-projection.js.map +1 -1
  97. package/dist/src/platforms/capabilities.d.ts +10 -0
  98. package/dist/src/platforms/capabilities.js +158 -0
  99. package/dist/src/platforms/capabilities.js.map +1 -0
  100. package/dist/src/platforms/contracts.d.ts +338 -0
  101. package/dist/src/platforms/contracts.js +2 -0
  102. package/dist/src/platforms/contracts.js.map +1 -0
  103. package/dist/src/platforms/cursor-workspace-hook.d.ts +22 -0
  104. package/dist/src/platforms/cursor-workspace-hook.js +185 -0
  105. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  106. package/dist/src/platforms/discovery.d.ts +74 -0
  107. package/dist/src/platforms/discovery.js +582 -0
  108. package/dist/src/platforms/discovery.js.map +1 -0
  109. package/dist/src/platforms/gemini-activation.d.ts +36 -0
  110. package/dist/src/platforms/gemini-activation.js +331 -0
  111. package/dist/src/platforms/gemini-activation.js.map +1 -0
  112. package/dist/src/platforms/gemini-consent.d.ts +8 -0
  113. package/dist/src/platforms/gemini-consent.js +79 -0
  114. package/dist/src/platforms/gemini-consent.js.map +1 -0
  115. package/dist/src/platforms/identity.d.ts +4 -0
  116. package/dist/src/platforms/identity.js +22 -0
  117. package/dist/src/platforms/identity.js.map +1 -0
  118. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  119. package/dist/src/platforms/inspection-grok.js +173 -0
  120. package/dist/src/platforms/inspection-grok.js.map +1 -0
  121. package/dist/src/platforms/inspection-native.d.ts +6 -0
  122. package/dist/src/platforms/inspection-native.js +379 -0
  123. package/dist/src/platforms/inspection-native.js.map +1 -0
  124. package/dist/src/platforms/inspection-pi.d.ts +4 -0
  125. package/dist/src/platforms/inspection-pi.js +212 -0
  126. package/dist/src/platforms/inspection-pi.js.map +1 -0
  127. package/dist/src/platforms/inspection.d.ts +13 -0
  128. package/dist/src/platforms/inspection.js +189 -0
  129. package/dist/src/platforms/inspection.js.map +1 -0
  130. package/dist/src/platforms/layout.d.ts +21 -0
  131. package/dist/src/platforms/layout.js +239 -0
  132. package/dist/src/platforms/layout.js.map +1 -0
  133. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  134. package/dist/src/platforms/lifecycle-native-services.js +147 -0
  135. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  136. package/dist/src/platforms/lifecycle-native.d.ts +9 -0
  137. package/dist/src/platforms/lifecycle-native.js +252 -0
  138. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  139. package/dist/src/platforms/lifecycle.d.ts +25 -0
  140. package/dist/src/platforms/lifecycle.js +452 -0
  141. package/dist/src/platforms/lifecycle.js.map +1 -0
  142. package/dist/src/platforms/managed-command-placement.d.ts +8 -0
  143. package/dist/src/platforms/managed-command-placement.js +79 -0
  144. package/dist/src/platforms/managed-command-placement.js.map +1 -0
  145. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  146. package/dist/src/platforms/projection-code-extension.js +121 -0
  147. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  148. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  149. package/dist/src/platforms/projection-command-resources.js +74 -0
  150. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  151. package/dist/src/platforms/projection-files.d.ts +27 -0
  152. package/dist/src/platforms/projection-files.js +111 -0
  153. package/dist/src/platforms/projection-files.js.map +1 -0
  154. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  155. package/dist/src/platforms/projection-marketplace.js +42 -0
  156. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  157. package/dist/src/platforms/projection.d.ts +10 -0
  158. package/dist/src/platforms/projection.js +446 -0
  159. package/dist/src/platforms/projection.js.map +1 -0
  160. package/dist/src/platforms/registry.d.ts +4 -0
  161. package/dist/src/platforms/registry.js +30 -0
  162. package/dist/src/platforms/registry.js.map +1 -0
  163. package/dist/src/platforms/supplement-layout.d.ts +16 -0
  164. package/dist/src/platforms/supplement-layout.js +31 -0
  165. package/dist/src/platforms/supplement-layout.js.map +1 -0
  166. package/dist/src/portable/commands.d.ts +7 -5
  167. package/dist/src/portable/commands.js +6 -1
  168. package/dist/src/portable/commands.js.map +1 -1
  169. package/dist/src/portable/materializer.d.ts +8 -6
  170. package/dist/src/portable/materializer.js +47 -245
  171. package/dist/src/portable/materializer.js.map +1 -1
  172. package/dist/src/portable/recovery-layout.js +2 -15
  173. package/dist/src/portable/recovery-layout.js.map +1 -1
  174. package/dist/src/portable/recovery.d.ts +10 -1
  175. package/dist/src/portable/recovery.js +34 -8
  176. package/dist/src/portable/recovery.js.map +1 -1
  177. package/dist/src/recovery/coordinator.d.ts +4 -7
  178. package/dist/src/recovery/coordinator.js +151 -119
  179. package/dist/src/recovery/coordinator.js.map +1 -1
  180. package/dist/src/recovery/demand.d.ts +1 -1
  181. package/dist/src/recovery/demand.js +10 -42
  182. package/dist/src/recovery/demand.js.map +1 -1
  183. package/dist/src/recovery/joint-coordinator.js +112 -52
  184. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  185. package/dist/src/recovery/joint-demand.d.ts +4 -22
  186. package/dist/src/recovery/joint-demand.js +43 -40
  187. package/dist/src/recovery/joint-demand.js.map +1 -1
  188. package/dist/src/recovery/receipt.d.ts +23 -8
  189. package/dist/src/recovery/retirement.d.ts +1 -1
  190. package/dist/src/recovery/retirement.js +122 -29
  191. package/dist/src/recovery/retirement.js.map +1 -1
  192. package/dist/src/recovery/status.d.ts +13 -6
  193. package/dist/src/recovery/status.js +479 -79
  194. package/dist/src/recovery/status.js.map +1 -1
  195. package/dist/src/recovery/types.d.ts +3 -3
  196. package/dist/src/review/platform-profile.d.ts +3 -0
  197. package/dist/src/review/platform-profile.js +16 -0
  198. package/dist/src/review/platform-profile.js.map +1 -0
  199. package/dist/src/review/review-profile.d.ts +1 -0
  200. package/dist/src/review/review-profile.js +8 -2
  201. package/dist/src/review/review-profile.js.map +1 -1
  202. package/dist/src/review/review-selection.d.ts +2 -11
  203. package/dist/src/review/review-selection.js +97 -71
  204. package/dist/src/review/review-selection.js.map +1 -1
  205. package/dist/src/review/review-types.d.ts +3 -0
  206. package/dist/src/review/review-types.js.map +1 -1
  207. package/dist/src/review/skill-materialization.d.ts +44 -9
  208. package/dist/src/review/skill-materialization.js +112 -136
  209. package/dist/src/review/skill-materialization.js.map +1 -1
  210. package/dist/src/review/source-binding.d.ts +8 -5
  211. package/dist/src/review/source-binding.js +99 -41
  212. package/dist/src/review/source-binding.js.map +1 -1
  213. package/dist/src/tui/agent-management.js +112 -10
  214. package/dist/src/tui/agent-management.js.map +1 -1
  215. package/dist/src/tui/agent-settings.d.ts +3 -0
  216. package/dist/src/tui/agent-settings.js +10 -11
  217. package/dist/src/tui/agent-settings.js.map +1 -1
  218. package/dist/src/tui/console-app-v4.js +58 -20
  219. package/dist/src/tui/console-app-v4.js.map +1 -1
  220. package/dist/src/tui/content-item-card.js +2 -2
  221. package/dist/src/tui/content-item-card.js.map +1 -1
  222. package/dist/src/tui/controller-runtime.js +198 -152
  223. package/dist/src/tui/controller-runtime.js.map +1 -1
  224. package/dist/src/tui/controller.d.ts +5 -9
  225. package/dist/src/tui/controller.js +40 -18
  226. package/dist/src/tui/controller.js.map +1 -1
  227. package/dist/src/tui/deployment-view.d.ts +10 -0
  228. package/dist/src/tui/deployment-view.js +91 -0
  229. package/dist/src/tui/deployment-view.js.map +1 -0
  230. package/dist/src/tui/glossary.js +4 -4
  231. package/dist/src/tui/glossary.js.map +1 -1
  232. package/dist/src/tui/model.d.ts +5 -0
  233. package/dist/src/tui/model.js +73 -12
  234. package/dist/src/tui/model.js.map +1 -1
  235. package/dist/src/tui/operation-diagnostic-screens.js +2 -1
  236. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  237. package/dist/src/tui/operation-history.d.ts +5 -4
  238. package/dist/src/tui/operation-history.js.map +1 -1
  239. package/dist/src/tui/operation-review-planner.d.ts +7 -2
  240. package/dist/src/tui/operation-review-planner.js +97 -42
  241. package/dist/src/tui/operation-review-planner.js.map +1 -1
  242. package/dist/src/tui/plugin-content.d.ts +5 -3
  243. package/dist/src/tui/plugin-content.js +70 -508
  244. package/dist/src/tui/plugin-content.js.map +1 -1
  245. package/dist/src/tui/plugin-detail.d.ts +3 -2
  246. package/dist/src/tui/plugin-detail.js +33 -25
  247. package/dist/src/tui/plugin-detail.js.map +1 -1
  248. package/dist/src/tui/scoped-inventory.d.ts +10 -6
  249. package/dist/src/tui/scoped-inventory.js +34 -1
  250. package/dist/src/tui/scoped-inventory.js.map +1 -1
  251. package/dist/src/types.d.ts +4 -63
  252. package/dist/src/types.js.map +1 -1
  253. package/dist/src/utils/agent-version.d.ts +10 -4
  254. package/dist/src/utils/agent-version.js.map +1 -1
  255. package/dist/src/utils/artifact-plan.d.ts +26 -2
  256. package/dist/src/utils/artifact-plan.js +113 -489
  257. package/dist/src/utils/artifact-plan.js.map +1 -1
  258. package/dist/src/utils/artifact-renderer.d.ts +100 -93
  259. package/dist/src/utils/artifact-renderer.js +173 -346
  260. package/dist/src/utils/artifact-renderer.js.map +1 -1
  261. package/dist/src/utils/artifact-request.d.ts +21 -11
  262. package/dist/src/utils/artifact-request.js +56 -80
  263. package/dist/src/utils/artifact-request.js.map +1 -1
  264. package/dist/src/utils/bundle-layout.js +30 -146
  265. package/dist/src/utils/bundle-layout.js.map +1 -1
  266. package/dist/src/utils/catalog-digests.d.ts +2 -12
  267. package/dist/src/utils/catalog-digests.js +0 -39
  268. package/dist/src/utils/catalog-digests.js.map +1 -1
  269. package/dist/src/utils/catalog-source-references.d.ts +7 -0
  270. package/dist/src/utils/catalog-source-references.js +234 -19
  271. package/dist/src/utils/catalog-source-references.js.map +1 -1
  272. package/dist/src/utils/codex-config-observation.d.ts +19 -0
  273. package/dist/src/utils/codex-config-observation.js +145 -0
  274. package/dist/src/utils/codex-config-observation.js.map +1 -0
  275. package/dist/src/utils/codex-executable-discovery.d.ts +2 -0
  276. package/dist/src/utils/codex-executable-discovery.js +47 -13
  277. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  278. package/dist/src/utils/codex-manager.js +1 -1
  279. package/dist/src/utils/codex-manager.js.map +1 -1
  280. package/dist/src/utils/codex-native-observation.d.ts +3 -0
  281. package/dist/src/utils/codex-native-observation.js +53 -0
  282. package/dist/src/utils/codex-native-observation.js.map +1 -1
  283. package/dist/src/utils/codex-shared-native.d.ts +3 -1
  284. package/dist/src/utils/codex-shared-native.js +46 -5
  285. package/dist/src/utils/codex-shared-native.js.map +1 -1
  286. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  287. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  288. package/dist/src/utils/codex-surface-analysis.d.ts +5 -2
  289. package/dist/src/utils/codex-surface-analysis.js +28 -57
  290. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  291. package/dist/src/utils/component-command-preparation.d.ts +34 -0
  292. package/dist/src/utils/component-command-preparation.js +228 -0
  293. package/dist/src/utils/component-command-preparation.js.map +1 -0
  294. package/dist/src/utils/component-resources.d.ts +43 -0
  295. package/dist/src/utils/component-resources.js +304 -0
  296. package/dist/src/utils/component-resources.js.map +1 -0
  297. package/dist/src/utils/dynamic-skill-tree.d.ts +17 -6
  298. package/dist/src/utils/dynamic-skill-tree.js +7 -3
  299. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  300. package/dist/src/utils/local-marketplace.d.ts +11 -44
  301. package/dist/src/utils/local-marketplace.js +11 -638
  302. package/dist/src/utils/local-marketplace.js.map +1 -1
  303. package/dist/src/utils/managed-command-evidence.d.ts +2 -2
  304. package/dist/src/utils/managed-command-evidence.js +5 -81
  305. package/dist/src/utils/managed-command-evidence.js.map +1 -1
  306. package/dist/src/utils/managed-command-materialization.d.ts +5 -2
  307. package/dist/src/utils/managed-command-materialization.js +35 -35
  308. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  309. package/dist/src/utils/managed-command-preparation.d.ts +67 -0
  310. package/dist/src/utils/managed-command-preparation.js +146 -0
  311. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  312. package/dist/src/utils/managed-command-review.d.ts +26 -0
  313. package/dist/src/utils/managed-command-review.js +68 -0
  314. package/dist/src/utils/managed-command-review.js.map +1 -0
  315. package/dist/src/utils/managed-command-store.js +26 -15
  316. package/dist/src/utils/managed-command-store.js.map +1 -1
  317. package/dist/src/utils/native-cli.d.ts +19 -0
  318. package/dist/src/utils/native-cli.js +45 -2
  319. package/dist/src/utils/native-cli.js.map +1 -1
  320. package/dist/src/utils/native-demand.d.ts +20 -1
  321. package/dist/src/utils/native-demand.js.map +1 -1
  322. package/dist/src/utils/native-tool-review.d.ts +3 -6
  323. package/dist/src/utils/native-tool-review.js +25 -11
  324. package/dist/src/utils/native-tool-review.js.map +1 -1
  325. package/dist/src/utils/ownership.d.ts +26 -3
  326. package/dist/src/utils/ownership.js +95 -9
  327. package/dist/src/utils/ownership.js.map +1 -1
  328. package/dist/src/utils/paths.d.ts +1 -1
  329. package/dist/src/utils/paths.js +2 -0
  330. package/dist/src/utils/paths.js.map +1 -1
  331. package/dist/src/utils/platform-empty-state.d.ts +46 -0
  332. package/dist/src/utils/platform-empty-state.js +123 -0
  333. package/dist/src/utils/platform-empty-state.js.map +1 -0
  334. package/dist/src/utils/plugin-config-impact.d.ts +17 -11
  335. package/dist/src/utils/plugin-config-impact.js +46 -62
  336. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  337. package/dist/src/utils/plugin-config-write.js +52 -53
  338. package/dist/src/utils/plugin-config-write.js.map +1 -1
  339. package/dist/src/utils/plugin-config.d.ts +0 -2
  340. package/dist/src/utils/plugin-config.js +0 -6
  341. package/dist/src/utils/plugin-config.js.map +1 -1
  342. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  343. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  344. package/dist/src/utils/runtime-config.d.ts +5 -7
  345. package/dist/src/utils/runtime-config.js +12 -25
  346. package/dist/src/utils/runtime-config.js.map +1 -1
  347. package/dist/src/utils/windows-npm-shim.js +19 -2
  348. package/dist/src/utils/windows-npm-shim.js.map +1 -1
  349. package/package.json +3 -3
  350. package/dist/src/utils/claude-native-render-receipt.d.ts +0 -14
  351. package/dist/src/utils/claude-native-render-receipt.js +0 -26
  352. package/dist/src/utils/claude-native-render-receipt.js.map +0 -1
  353. package/dist/src/utils/claude-skills-root.d.ts +0 -8
  354. package/dist/src/utils/claude-skills-root.js +0 -87
  355. package/dist/src/utils/claude-skills-root.js.map +0 -1
  356. package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
  357. package/dist/src/utils/codex-native-render-receipt.js +0 -205
  358. package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
  359. package/dist/src/utils/slash-commands.d.ts +0 -1
  360. package/dist/src/utils/slash-commands.js +0 -2
  361. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -1,31 +1,20 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
3
  import fs from 'fs-extra';
4
- import { selectPluginConfigProfile } from '@lesliechan721/aw-plugin-core/manifest';
5
- import { assertReadyPluginConfigStore, readPluginConfigStore, resolveEffectivePluginConfig, } from './plugin-config.js';
4
+ import { normalizeStaticPluginComponents, assertPlatformRenderContext, selectPluginConfigProfile, assertNoDuplicateHookHandlers, } from '@lesliechan721/aw-plugin-core/manifest';
5
+ import { assertReadyPluginConfigStore, readPluginConfigStore, resolveEffectivePluginConfig } from './plugin-config.js';
6
6
  import { assertNoSensitiveConfigValues, buildNodeScriptInvocation, buildPluginScriptSpawnEnv, calculateFileDigest, collectSensitivePluginConfigValues, defaultPluginProcessRunner, preparePluginScriptDirectories, redactPluginScriptOutput, resolveBundledPluginFilePath, resolvePluginScriptTimeoutMs, summarizePluginScriptOutput, } from './plugin-scripts.js';
7
- import { getArtifactSourceBundleRelativePath, resolveCommandSourceDirectory } from './artifact-sources.js';
8
- import { resolveArtifactRequest } from './artifact-request.js';
9
- import { validateArtifactPlan } from './artifact-plan.js';
7
+ import { resolveArtifactRequest, resolvePlatformComponentBatches, selectPlatformRenderConfig, selectPlatformRenderConfigKeys } from './artifact-request.js';
8
+ import { artifactValueDigest, mergeExpectedComponentSets, validateArtifactPlan, validatePlatformComponentPlan } from './artifact-plan.js';
9
+ import { resolveCommandSourceDirectory } from './artifact-sources.js';
10
+ import { resolvePlatformComponentResources, verifyPlatformComponentResources } from './component-resources.js';
10
11
  import { createArtifactRuntimeConfigSnapshots } from './runtime-config.js';
12
+ import { prepareWindowsJobHelper } from './process-tree.js';
11
13
  import { attachSafeOperationError, readSafeOperationError } from './safe-operation-diagnostic.js';
12
- const SUPPORTED_ARTIFACT_RENDER_EVENTS = new Set([
13
- 'install',
14
- 'refresh',
15
- 'materialize',
16
- ]);
14
+ export const ARTIFACT_RENDERER_MAX_STDOUT_BYTES = 16 * 1024 * 1024;
17
15
  function isRecord(value) {
18
16
  return typeof value === 'object' && value !== null && !Array.isArray(value);
19
17
  }
20
- function assertArtifactRenderEvent(value) {
21
- if (!SUPPORTED_ARTIFACT_RENDER_EVENTS.has(value)) {
22
- throw new Error(`Artifact renderer only supports install, refresh, and materialize events; received "${value}".`);
23
- }
24
- return value;
25
- }
26
- function selectConfigKeys(values, selectedKeys) {
27
- return Object.fromEntries(Object.entries(values).filter(([key]) => selectedKeys.has(key)));
28
- }
29
18
  export async function resolveArtifactRenderConfig(options) {
30
19
  const pluginName = options.pluginName ?? options.manifest.name;
31
20
  const schema = options.manifest.config ? selectPluginConfigProfile(options.manifest.config, options.platform).fields : undefined;
@@ -106,360 +95,198 @@ export async function resolveArtifactRendererTarget(plugin) {
106
95
  rendererDigest: await calculateFileDigest(entryPath),
107
96
  };
108
97
  }
109
- export async function writeArtifactRendererContext(options) {
110
- const event = assertArtifactRenderEvent(options.event);
111
- if (options.target.noOp ||
112
- !options.target.entry ||
113
- !options.target.entryPath ||
114
- !options.target.bundleRoot ||
115
- !options.target.sourceManifest ||
116
- !options.target.manifestPath ||
117
- !options.target.manifestDigest ||
118
- !options.target.rendererDigest) {
119
- throw new Error('Cannot write artifact renderer context for a no-op target.');
120
- }
121
- if (options.platform === 'agent-skills') {
122
- throw new Error('artifactTargetRequired: Portable Skill rendering requires a concrete platform target.');
98
+ /** One process boundary for all surfaces. Surface owners validate their response schema. */
99
+ export async function runPreparedArtifactRenderer(options) {
100
+ options.signal?.throwIfAborted();
101
+ if (!isRecord(options.context) || (options.context.scope !== 'user' && options.context.scope !== 'project')) {
102
+ throw new Error('artifactRendererContextInvalid: A prepared context must contain its render scope.');
123
103
  }
124
- const awSurface = options.platform === 'managed-commands';
125
- const platform = options.platform === 'managed-commands' ? undefined : options.platform;
126
- const distribution = platform && platform !== 'codex' && platform !== 'claude' ? 'agent-skills' : undefined;
127
- const request = resolveArtifactRequest({
128
- manifest: options.target.sourceManifest,
129
- platform: options.platform,
130
- scope: options.scope,
131
- requestedArtifactIds: options.requestedArtifactIds,
132
- });
133
- const requestedConfigKeys = new Set(request.declarations.flatMap((target) => target.refreshKeys));
134
- const config = await resolveArtifactRenderConfig({
135
- sourceId: options.sourceId,
136
- sourceIdentity: options.sourceIdentity,
137
- logicalIdentity: options.logicalIdentity,
138
- pluginName: options.target.sourceManifest.name,
139
- manifest: options.target.sourceManifest,
140
- platform,
141
- referencePlugins: options.referencePlugins,
142
- scope: options.configScope ?? options.scope,
143
- cwd: options.cwd,
144
- env: options.commandEnv,
145
- });
146
- const rendererConfig = {
147
- mode: config.mode,
148
- targetScope: config.targetScope,
149
- schema: config.schema === undefined
150
- ? undefined
151
- : selectConfigKeys(config.schema, requestedConfigKeys),
152
- values: selectConfigKeys(config.values, requestedConfigKeys),
153
- sources: selectConfigKeys(config.sources, requestedConfigKeys),
154
- issues: config.issues.filter((issue) => requestedConfigKeys.has(issue.key)),
155
- };
156
- const runtimeConfigSnapshots = platform === 'codex' || platform === 'claude' ? createArtifactRuntimeConfigSnapshots({
157
- sourceId: options.sourceId,
158
- sourceIdentity: options.sourceIdentity,
159
- logicalIdentity: options.logicalIdentity,
160
- manifest: options.target.sourceManifest,
161
- platform,
162
- scope: options.scope,
163
- config,
164
- requestedArtifactIds: request.requestedArtifactIds,
165
- }) : {};
166
- const artifactSources = await Promise.all((options.target.sourceManifest.artifacts?.targets ?? [])
167
- .filter((target) => (target.target === 'codex.skill' || target.target === 'claude.skill' || target.target === 'agent-skills.skill')
168
- && target.platform === platform
169
- && target.distribution === distribution
170
- && ((target.target === 'codex.skill' || target.target === 'claude.skill')
171
- || target.scopes.includes(options.scope)))
172
- .map(async (target) => ({
173
- id: target.id,
174
- target: target.target,
175
- sourceDirs: await Promise.all((target.sourceDirs ?? []).map((_, index) => resolveBundledPluginFilePath({
176
- bundleRoot: options.target.bundleRoot,
177
- pluginRelativePath: `./${getArtifactSourceBundleRelativePath({
178
- platform: target.platform,
179
- distribution: target.distribution,
180
- artifactId: target.id,
181
- index,
182
- })}`,
183
- fieldName: `Artifact source ${target.id}[${index}]`,
184
- }))),
185
- })));
186
- const packageKeys = new Set(request.declarations.flatMap((declaration) => 'producer' in declaration && declaration.producer.kind === 'package' ? [declaration.producer.packageKey] : []));
187
- const commandSources = await Promise.all((options.target.sourceManifest.managedCommands?.packages ?? [])
188
- .filter((entry) => packageKeys.has(entry.key))
189
- .map(async (entry) => ({
190
- packageKey: entry.key,
191
- sourceDir: await resolveCommandSourceDirectory({ bundleRoot: options.target.bundleRoot, pluginRelativePath: entry.sourceDir }),
192
- })));
104
+ const target = await resolveArtifactRendererTarget(options.plugin);
105
+ if (target.noOp)
106
+ throw new Error(`Plugin "${options.plugin.manifest.name}" does not declare scripts.artifacts.render.`);
193
107
  const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-plugin-artifact-render-'));
108
+ const isolatedHomes = { awHome: path.join(tempDir, 'aw-home'), codexHome: path.join(tempDir, 'codex-home'), claudeHome: path.join(tempDir, 'claude-home') };
194
109
  try {
195
- const context = {
196
- event,
197
- surface: awSurface ? { kind: 'aw', name: 'managed-commands' } : distribution
198
- ? { kind: 'distribution', name: distribution }
199
- : { kind: 'platform', name: platform },
200
- platform,
201
- distribution,
202
- scope: options.scope,
203
- plugin: {
204
- name: options.target.sourceManifest.name,
205
- version: options.target.sourceManifest.version,
206
- rootDir: options.target.bundleRoot,
207
- },
208
- config: rendererConfig,
209
- changedConfigKeys: (options.changedConfigKeys ?? [])
210
- .filter((key) => requestedConfigKeys.has(key)),
211
- requestedArtifactIds: request.requestedArtifactIds,
212
- previousArtifacts: options.previousArtifacts ?? [],
213
- artifactSources,
214
- commandSources,
215
- runtimeImports: request.declarations
216
- .flatMap((target) => (target.runtimeImports ?? []).map((runtimeImport) => {
217
- if (!runtimeImport.resolved) {
218
- throw new Error(`Artifact runtime import "${target.id}/${runtimeImport.name}" is not resolved in the bundle.`);
219
- }
220
- return {
221
- artifactId: target.id,
222
- name: runtimeImport.name,
223
- providerPluginId: runtimeImport.resolved.providerPluginId,
224
- exportName: runtimeImport.export,
225
- path: path.join(options.target.bundleRoot, runtimeImport.resolved.path.replace(/^\.\//u, '')),
226
- digest: runtimeImport.resolved.digest,
227
- };
228
- })),
229
- paths: {
230
- awHome: path.join(tempDir, 'aw-home'),
231
- codexHome: path.join(tempDir, 'codex-home'),
232
- claudeHome: path.join(tempDir, 'claude-home'),
233
- manifestPath: options.target.manifestPath,
234
- },
235
- renderer: {
236
- runner: options.target.entry.runner,
237
- path: options.target.entryPath,
238
- args: options.target.entry.args ?? [],
239
- manifestDigest: options.target.manifestDigest,
240
- rendererDigest: options.target.rendererDigest,
241
- },
242
- };
243
110
  const contextPath = path.join(tempDir, 'context.json');
244
- await fs.writeJson(contextPath, context, { spaces: 2 });
111
+ await fs.writeJson(contextPath, options.context, { spaces: 2 });
112
+ await fs.chmod(contextPath, 0o600).catch(() => undefined);
113
+ await preparePluginScriptDirectories(tempDir);
114
+ if (process.platform === 'win32')
115
+ await prepareWindowsJobHelper();
116
+ for (const location of Object.values(isolatedHomes))
117
+ await fs.ensureDir(location);
118
+ const commandEnv = options.commandEnv ?? process.env;
119
+ const surface = options.context.surface;
120
+ const platform = typeof options.context.platform === 'string' ? options.context.platform : undefined;
121
+ const env = buildPluginScriptSpawnEnv({ commandEnv, contextPath, tempDir, isolatedHomes,
122
+ plugin: options.plugin.manifest, event: options.event ?? 'materialize',
123
+ platform, scope: options.context.scope, bundleRoot: target.bundleRoot });
124
+ env.AW_PLUGIN_SURFACE = typeof surface === 'string' ? surface : 'managed-commands';
125
+ const invocation = buildNodeScriptInvocation({ entryPath: target.entryPath, cwd: options.cwd, env, args: target.entry.args });
126
+ const timeoutMs = resolvePluginScriptTimeoutMs({ cliTimeoutMs: options.scriptTimeoutMs });
127
+ const preparationKey = options.preparedResults ? artifactValueDigest({ context: options.context,
128
+ manifestDigest: target.manifestDigest, rendererDigest: target.rendererDigest, cwd: options.cwd,
129
+ commandEnv, scriptTimeoutMs: options.scriptTimeoutMs }) : undefined;
130
+ const runOptions = { timeoutMs, maxStdoutBytes: ARTIFACT_RENDERER_MAX_STDOUT_BYTES, ...(options.signal ? { signal: options.signal } : {}) };
131
+ const result = (preparationKey ? options.preparedResults?.get(preparationKey) : undefined)
132
+ ?? await (options.runner ? options.runner.run(invocation, runOptions)
133
+ : defaultPluginProcessRunner.run(invocation, { ...runOptions, sensitiveValues: options.sensitiveValues }));
134
+ const summary = (text) => summarizePluginScriptOutput(text, options.sensitiveValues) || '<empty>';
135
+ const stdout = summary(result.stdout);
136
+ const stderr = summary(result.stderr);
137
+ if (result.stdoutTruncated || Buffer.byteLength(result.stdout, 'utf8') > ARTIFACT_RENDERER_MAX_STDOUT_BYTES)
138
+ throw new Error('artifactRendererOutputTooLarge: Artifact renderer JSON exceeds the 16 MiB limit.');
139
+ if (result.timedOut)
140
+ throw new Error(`Artifact renderer timed out after ${timeoutMs} ms. stderr: ${stderr}`);
141
+ if (result.exitCode !== 0 || result.signal !== null)
142
+ throw new Error(`Artifact renderer failed with exit code ${result.exitCode}. stderr: ${stderr}`);
143
+ let value;
245
144
  try {
246
- await fs.chmod(contextPath, 0o600);
145
+ value = JSON.parse(result.stdout.trim());
247
146
  }
248
147
  catch {
249
- // Best effort on non-POSIX filesystems.
148
+ throw new Error(`Artifact renderer must write JSON to stdout. stdout: ${stdout}. stderr: ${stderr}`);
250
149
  }
251
- return {
252
- context,
253
- contextPath,
254
- tempDir,
255
- sensitiveValues: collectSensitivePluginConfigValues(options.target.sourceManifest, config.values, platform),
256
- runtimeConfigSnapshots,
257
- cleanup: async () => {
258
- await fs.remove(tempDir);
259
- },
260
- };
150
+ assertNoSensitiveConfigValues(value, options.sensitiveValues, 'artifactRendererSensitiveConfigExposed: Artifact renderer output contains sensitive config.');
151
+ // This cache is scoped to one operation. Every consumer still validates its surface and resources.
152
+ if (preparationKey)
153
+ options.preparedResults.set(preparationKey, result);
154
+ return { value, target, exitCode: result.exitCode, signal: result.signal, stdout, stderr, timedOut: result.timedOut };
261
155
  }
262
156
  catch (error) {
263
- await fs.remove(tempDir).catch(() => undefined);
264
- throw error;
265
- }
266
- }
267
- function summarizeRenderOutput(value, sensitiveValues) {
268
- const summary = summarizePluginScriptOutput(value, sensitiveValues);
269
- return summary === '' ? '<empty>' : summary;
270
- }
271
- export const ARTIFACT_RENDERER_MAX_STDOUT_BYTES = 16 * 1024 * 1024;
272
- function assertArtifactPlanEnvelope(value, output) {
273
- if (!isRecord(value)) {
274
- throw new Error(`Artifact renderer must write a JSON object to stdout. stdout: ${output.stdoutSummary}. stderr: ${output.stderrSummary}`);
275
- }
276
- if (value.version !== 2) {
277
- const migrationHint = value.version === 1
278
- ? ' ArtifactPlan V1 is not supported by AW 1.0.0-beta.30; upgrade or reinstall the plugin.'
279
- : '';
280
- throw new Error(`Artifact renderer returned unsupported plan version "${String(value.version)}".${migrationHint} stderr: ${output.stderrSummary}`);
281
- }
282
- if (!Array.isArray(value.artifacts)) {
283
- throw new Error(`Artifact renderer returned an invalid plan: "artifacts" must be an array. stdout: ${output.stdoutSummary}. stderr: ${output.stderrSummary}`);
157
+ const message = error instanceof Error ? error.message : String(error);
158
+ const redacted = redactPluginScriptOutput(message, options.sensitiveValues);
159
+ if (redacted === message)
160
+ throw error;
161
+ const failure = new Error(redacted, { cause: error });
162
+ if (error instanceof Error)
163
+ failure.name = error.name;
164
+ const diagnostic = readSafeOperationError(error);
165
+ throw diagnostic ? attachSafeOperationError(failure, diagnostic) : failure;
284
166
  }
285
- return value;
286
- }
287
- function buildArtifactRendererInvocation(options) {
288
- return buildNodeScriptInvocation({
289
- entryPath: options.entryPath,
290
- cwd: options.cwd,
291
- env: options.env,
292
- args: options.entry.args,
293
- });
294
- }
295
- function assertRefreshKeysForEvent(event, changedConfigKeys) {
296
- assertArtifactRenderEvent(event);
297
- const keys = changedConfigKeys ? [...changedConfigKeys] : [];
298
- if (event === 'refresh' && keys.length === 0) {
299
- throw new Error('Artifact renderer refresh requires changedConfigKeys.');
167
+ finally {
168
+ await fs.remove(tempDir);
300
169
  }
301
- return keys;
302
170
  }
303
- async function runArtifactRendererProcess(options) {
304
- const runOptions = {
305
- timeoutMs: options.timeoutMs,
306
- maxStdoutBytes: ARTIFACT_RENDERER_MAX_STDOUT_BYTES,
307
- ...(options.signal ? { signal: options.signal } : {}),
308
- };
309
- return options.runner
310
- ? options.runner.run(options.invocation, runOptions)
311
- : defaultPluginProcessRunner.run(options.invocation, {
312
- ...runOptions,
313
- sensitiveValues: options.sensitiveValues,
314
- });
315
- }
316
- export async function runArtifactRenderer(options) {
171
+ export async function preparePlatformComponents(options) {
317
172
  options.signal?.throwIfAborted();
318
- const event = assertArtifactRenderEvent(options.event);
319
- const commandEnv = options.commandEnv ?? process.env;
320
- const changedConfigKeys = assertRefreshKeysForEvent(event, options.changedConfigKeys);
173
+ if (options.capabilities.platform !== options.platform || options.capabilities.scope !== options.renderScope
174
+ || options.config.targetScope !== options.renderScope)
175
+ throw new Error('componentRenderUnitMismatch: Config and capability scope must match the render unit.');
321
176
  const target = await resolveArtifactRendererTarget(options.plugin);
322
- if (target.noOp) {
323
- throw new Error(`Plugin "${options.plugin.manifest.name}" does not declare scripts.artifacts.render.`);
324
- }
325
- const writtenContext = await writeArtifactRendererContext({
326
- sourceId: options.plugin.sourceId,
327
- sourceIdentity: options.plugin.sourceIdentity,
328
- logicalIdentity: options.plugin.catalogLogicalIdentity,
329
- target,
330
- referencePlugins: options.referencePlugins,
331
- event,
332
- platform: options.platform,
333
- scope: options.scope,
334
- ...(options.configScope ? { configScope: options.configScope } : {}),
335
- cwd: options.cwd,
336
- commandEnv,
337
- changedConfigKeys,
338
- previousArtifacts: options.previousArtifacts,
339
- requestedArtifactIds: options.requestedArtifactIds,
340
- });
177
+ const sensitiveValues = collectSensitivePluginConfigValues(options.plugin.manifest, options.config.values, options.platform);
341
178
  try {
342
- if (writtenContext.context.config.issues.length > 0) {
343
- throw new Error(`Invalid AW config for ${writtenContext.context.plugin.name}: ${writtenContext.context.config.issues.map((issue) => `${issue.key} (${issue.type})`).join(', ')}.`);
179
+ const resources = await resolvePlatformComponentResources(options.plugin);
180
+ const sets = [options.staticExpected ?? await normalizeStaticPluginComponents({
181
+ pluginRoot: options.plugin.rootDir, staticResourceRoot: options.staticResourceRoot, manifest: options.plugin.manifest, platform: options.platform,
182
+ capabilities: options.capabilities, allowedOutputKinds: options.kinds,
183
+ })];
184
+ const contexts = [];
185
+ for (const allowedOutputKinds of resolvePlatformComponentBatches({ ...options, manifest: options.plugin.manifest })) {
186
+ const nonSensitive = allowedOutputKinds.includes('skill');
187
+ const keys = options.plugin.manifest.artifacts.configKeys;
188
+ const config = selectPlatformRenderConfig({ resolved: options.config, keys, nonSensitive });
189
+ if (config.issues.length)
190
+ throw new Error(`Invalid AW config for ${options.plugin.manifest.name}: ${config.issues.map((issue) => issue.path.field).join(', ')}.`);
191
+ const context = {
192
+ schemaVersion: 1, surface: 'agent-plugin', platform: options.platform, scope: options.renderScope,
193
+ plugin: { pluginId: options.plugin.pluginId ?? `${options.plugin.sourceId ?? 'authoring'}/${options.plugin.manifest.name}`,
194
+ name: options.plugin.manifest.name, version: options.plugin.manifest.version },
195
+ config, changedConfigKeys: (options.changedConfigKeys ?? []).filter((key) => Object.hasOwn(config.sources, key)),
196
+ allowedOutputKinds, platformCapabilities: options.capabilities, resources,
197
+ previousComponents: (options.previousComponents ?? []).filter((entry) => allowedOutputKinds.includes(entry.kind))
198
+ .map(({ id, kind, name }) => ({ id, kind, name })),
199
+ };
200
+ assertPlatformRenderContext(context);
201
+ contexts.push(context);
202
+ const rendered = await runPreparedArtifactRenderer({ ...options, context, sensitiveValues });
203
+ const plan = validatePlatformComponentPlan({ plan: rendered.value, platform: options.platform, scope: options.renderScope,
204
+ allowedOutputKinds, platformCapabilities: options.capabilities, configKeys: keys,
205
+ nonSensitiveConfigKeys: selectPlatformRenderConfigKeys({ resolved: options.config, keys, nonSensitive: true }),
206
+ resources, sourceDirs: options.plugin.manifest.artifacts?.sourceDirs,
207
+ requiredAwCapabilities: options.plugin.manifest.requires?.aw.capabilities });
208
+ sets.push({ components: plan.components, omitted: plan.omitted, unmet: plan.unmet,
209
+ sources: Object.fromEntries([...plan.components, ...plan.omitted, ...plan.unmet].map((entry) => [entry.id, 'dynamic'])) });
344
210
  }
345
- await Promise.all([
346
- preparePluginScriptDirectories(writtenContext.tempDir),
347
- fs.ensureDir(writtenContext.context.paths.awHome),
348
- fs.ensureDir(writtenContext.context.paths.codexHome),
349
- fs.ensureDir(writtenContext.context.paths.claudeHome),
350
- ]);
351
- const timeoutMs = resolvePluginScriptTimeoutMs({
352
- cliTimeoutMs: options.scriptTimeoutMs,
353
- manifestTimeoutMs: undefined,
354
- });
355
- const spawnEnv = buildPluginScriptSpawnEnv({
356
- commandEnv,
357
- isolatedHomes: writtenContext.context.paths,
358
- contextPath: writtenContext.contextPath,
359
- tempDir: writtenContext.tempDir,
360
- plugin: writtenContext.context.plugin,
361
- event,
362
- ...(options.platform === 'managed-commands'
363
- ? {}
364
- : { platform: writtenContext.context.platform,
365
- ...(writtenContext.context.distribution ? { distribution: writtenContext.context.distribution } : {}) }),
366
- scope: options.scope,
367
- bundleRoot: writtenContext.context.plugin.rootDir,
211
+ const expected = mergeExpectedComponentSets(sets);
212
+ assertNoDuplicateHookHandlers(expected.components, options.platform);
213
+ const closure = await verifyPlatformComponentResources({ plugin: options.plugin, expected, resources,
214
+ capabilities: options.capabilities, sensitiveValues, staticResourceRoot: options.staticResourceRoot });
215
+ // Only the exact static receipt, already matched to the verified manifest above, is metadata rather than plugin text.
216
+ const scannedComponents = expected.components.map((component) => component.kind === 'skill' && expected.sources[component.id] === 'static'
217
+ ? { ...component, content: { files: Object.fromEntries(Object.entries(component.content.files).filter(([file]) => file !== 'aw-plugin-requirements.json')) } }
218
+ : component);
219
+ assertNoSensitiveConfigValues({ ...expected, components: scannedComponents }, sensitiveValues, 'componentSensitiveConfigExposed: Components contain sensitive config.');
220
+ const runtimeConfigSnapshots = createArtifactRuntimeConfigSnapshots({
221
+ sourceId: options.plugin.sourceId, sourceIdentity: options.plugin.sourceIdentity,
222
+ logicalIdentity: options.plugin.catalogLogicalIdentity, manifest: options.plugin.manifest,
223
+ platform: options.platform, scope: options.renderScope, config: options.config, components: expected.components,
368
224
  });
369
- if (options.platform === 'managed-commands')
370
- spawnEnv.AW_PLUGIN_SURFACE = 'managed-commands';
371
- const invocation = buildArtifactRendererInvocation({
372
- entry: target.entry,
373
- entryPath: target.entryPath,
374
- cwd: options.cwd,
375
- env: spawnEnv,
376
- });
377
- // Temporary homes change on every preparation. The remaining context binds
378
- // the renderer, exact request, config, sources and previous artifacts.
379
- const preparationKey = options.preparedResults ? JSON.stringify({
380
- ...writtenContext.context,
381
- paths: { manifestPath: writtenContext.context.paths.manifestPath },
382
- cwd: options.cwd,
383
- commandEnv,
384
- scriptTimeoutMs: options.scriptTimeoutMs,
385
- }) : undefined;
386
- const result = (preparationKey ? options.preparedResults?.get(preparationKey) : undefined)
387
- ?? await runArtifactRendererProcess({
388
- invocation,
389
- timeoutMs,
390
- sensitiveValues: writtenContext.sensitiveValues,
391
- signal: options.signal,
392
- runner: options.runner,
393
- });
394
- const stdoutSummary = summarizeRenderOutput(result.stdout, writtenContext.sensitiveValues);
395
- const stderrSummary = summarizeRenderOutput(result.stderr, writtenContext.sensitiveValues);
396
- if (result.stdoutTruncated || Buffer.byteLength(result.stdout, 'utf8') > ARTIFACT_RENDERER_MAX_STDOUT_BYTES) {
397
- throw new Error('artifactRendererOutputTooLarge: Artifact renderer JSON exceeds the 16 MiB limit.');
398
- }
399
- if (result.timedOut) {
400
- throw new Error(`Artifact renderer timed out after ${timeoutMs} ms. stderr: ${stderrSummary}`);
401
- }
402
- if (result.exitCode !== 0) {
403
- throw new Error(`Artifact renderer failed with exit code ${result.exitCode}. stderr: ${stderrSummary}`);
404
- }
405
- const rawStdout = result.stdout.trim();
406
- let parsed;
407
- try {
408
- parsed = JSON.parse(rawStdout);
409
- }
410
- catch {
411
- throw new Error(`Artifact renderer must write JSON to stdout. stdout: ${stdoutSummary}. stderr: ${stderrSummary}`);
412
- }
413
- let plan;
414
- try {
415
- assertNoSensitiveConfigValues(parsed, writtenContext.sensitiveValues, 'artifactRendererSensitiveConfigExposed: Artifact renderer output contains sensitive config.');
416
- plan = assertArtifactPlanEnvelope(parsed, {
417
- stdoutSummary,
418
- stderrSummary,
419
- });
420
- validateArtifactPlan({
421
- manifest: options.plugin.manifest,
422
- plan,
423
- platform: options.platform,
424
- scope: options.scope,
425
- requestedArtifactIds: writtenContext.context.requestedArtifactIds,
426
- renderConfig: writtenContext.context.config,
427
- rendererDigest: target.rendererDigest,
428
- manifestDigest: target.manifestDigest,
429
- });
430
- }
431
- catch (error) {
432
- throw new Error(redactPluginScriptOutput(error instanceof Error ? error.message : String(error), writtenContext.sensitiveValues));
433
- }
434
- // Cache only validated success. Reused output still passes the current
435
- // sensitive-value and artifact checks above.
436
- if (preparationKey)
437
- options.preparedResults.set(preparationKey, result);
438
- return {
439
- plan,
440
- target,
441
- context: writtenContext.context,
442
- runtimeConfigSnapshots: writtenContext.runtimeConfigSnapshots,
443
- exitCode: result.exitCode,
444
- signal: result.signal,
445
- stdout: stdoutSummary,
446
- stderr: stderrSummary,
447
- timedOut: result.timedOut,
225
+ const evidence = {
226
+ manifestDigest: target.manifestDigest, ...(target.rendererDigest ? { rendererDigest: target.rendererDigest } : {}),
227
+ configDigest: artifactValueDigest(selectPlatformRenderConfig({ resolved: options.config,
228
+ keys: options.plugin.manifest.artifacts?.configKeys ?? [], nonSensitive: false })),
229
+ capabilitiesDigest: artifactValueDigest(options.capabilities), resourceDigest: closure.digest,
230
+ renderInputDigest: artifactValueDigest({ contexts, static: sets[0], manifestDigest: target.manifestDigest,
231
+ rendererDigest: target.rendererDigest, resources: closure.digest }),
448
232
  };
233
+ return { expected, resources: closure, evidence, runtimeConfigSnapshots,
234
+ empty: expected.components.length ? null : expected.unmet.length ? 'unmet' : 'intentional' };
449
235
  }
450
236
  catch (error) {
451
237
  const message = error instanceof Error ? error.message : String(error);
452
- const redacted = redactPluginScriptOutput(message, writtenContext.sensitiveValues);
453
- if (redacted === message)
238
+ const redacted = redactPluginScriptOutput(message, sensitiveValues);
239
+ if (message === redacted)
454
240
  throw error;
455
- const failure = new Error(redacted, { cause: error });
456
- if (error instanceof Error)
457
- failure.name = error.name;
241
+ const failure = new Error(redacted);
458
242
  const diagnostic = readSafeOperationError(error);
459
243
  throw diagnostic ? attachSafeOperationError(failure, diagnostic) : failure;
460
244
  }
245
+ }
246
+ /** The independent command-package surface retains its v2 protocol. */
247
+ export async function runArtifactRenderer(options) {
248
+ const written = await createManagedCommandRendererContext({ ...options, target: await resolveArtifactRendererTarget(options.plugin),
249
+ sourceId: options.plugin.sourceId, sourceIdentity: options.plugin.sourceIdentity,
250
+ logicalIdentity: options.plugin.catalogLogicalIdentity, commandEnv: options.commandEnv ?? process.env });
251
+ try {
252
+ const rendered = await runPreparedArtifactRenderer({ ...options, context: written.context, sensitiveValues: written.sensitiveValues });
253
+ const plan = validateArtifactPlan({ ...options, manifest: options.plugin.manifest, plan: rendered.value,
254
+ renderConfig: written.renderConfig, manifestDigest: rendered.target.manifestDigest, rendererDigest: rendered.target.rendererDigest });
255
+ return { ...rendered, plan, context: written.context, runtimeConfigSnapshots: {} };
256
+ }
461
257
  finally {
462
- await writtenContext.cleanup();
258
+ await written.cleanup();
463
259
  }
464
260
  }
261
+ async function createManagedCommandRendererContext(options) {
262
+ if (options.platform !== 'managed-commands')
263
+ throw new Error('Platform components require preparePlatformComponents and the v3 component protocol.');
264
+ if (!options.target.sourceManifest || !options.target.bundleRoot)
265
+ throw new Error('Cannot write a command context for an unresolved target.');
266
+ const manifest = options.target.sourceManifest;
267
+ const request = resolveArtifactRequest({ manifest, platform: 'managed-commands', scope: options.scope, requestedArtifactIds: options.requestedArtifactIds });
268
+ const resolved = await resolveArtifactRenderConfig({ ...options, manifest, platform: undefined, scope: options.configScope ?? options.scope, env: options.commandEnv });
269
+ const requestedKeys = request.declarations.flatMap((entry) => entry.refreshKeys);
270
+ const selected = selectPlatformRenderConfig({ resolved, keys: requestedKeys, nonSensitive: true });
271
+ if (requestedKeys.some((key) => !Object.hasOwn(selected.sources, key)))
272
+ throw new Error('managedCommandSensitiveConfigDenied: Command inputs must be non-sensitive.');
273
+ const keySet = new Set(Object.keys(selected.sources));
274
+ const renderConfig = { ...resolved, schema: selected.schema.fields,
275
+ values: selected.values, sources: selected.sources, issues: resolved.issues.filter((issue) => keySet.has(issue.key)) };
276
+ if (renderConfig.issues.length)
277
+ throw new Error('Invalid AW config for managed commands.');
278
+ const packageKeys = new Set(request.declarations.flatMap((entry) => entry.producer.kind === 'package' ? [entry.producer.packageKey] : []));
279
+ const commandSources = await Promise.all((manifest.managedCommands?.packages ?? []).filter((entry) => packageKeys.has(entry.key))
280
+ .map(async (entry) => ({ packageKey: entry.key, sourceDir: await resolveCommandSourceDirectory({ bundleRoot: options.target.bundleRoot, pluginRelativePath: entry.sourceDir }) })));
281
+ return { context: { event: options.event, surface: { kind: 'aw', name: 'managed-commands' }, scope: options.scope,
282
+ plugin: { name: manifest.name, version: manifest.version, rootDir: options.target.bundleRoot },
283
+ config: { mode: 'artifact-render', targetScope: resolved.targetScope, schema: renderConfig.schema,
284
+ values: renderConfig.values, sources: renderConfig.sources, issues: renderConfig.issues },
285
+ changedConfigKeys: (options.changedConfigKeys ?? []).filter((key) => keySet.has(key)),
286
+ requestedArtifactIds: request.requestedArtifactIds,
287
+ previousArtifacts: (options.previousArtifacts ?? []).filter((value) => isRecord(value)
288
+ && request.requestedArtifactIds.includes(String(value.id)) && (value.kind === 'commandSet' || value.kind === 'commandPackage')),
289
+ commandSources, artifactSources: [], runtimeImports: [] }, renderConfig,
290
+ sensitiveValues: collectSensitivePluginConfigValues(manifest, resolved.values), cleanup: async () => undefined };
291
+ }
465
292
  //# sourceMappingURL=artifact-renderer.js.map