@lesliechan721/aw 0.1.0-beta.10 → 0.1.0-beta.100

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 (820) hide show
  1. package/dist/authoring/assets/aw-config.d.mts +1 -50
  2. package/dist/authoring/assets/aw-config.mjs +58 -928
  3. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  4. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
  6. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  7. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  8. package/dist/authoring/assets/command-runtime-config.mjs +134 -0
  9. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  10. package/dist/authoring/scripts/add-skill.mjs +16 -39
  11. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  12. package/dist/authoring/scripts/init-plugin.mjs +43 -71
  13. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  14. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  15. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  16. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  17. package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
  18. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  19. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +3 -3
  20. package/dist/authoring/scripts/lib/skill-scaffold.mjs +5 -8
  21. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  22. package/dist/authoring/scripts/remove-plugin.mjs +1 -1
  23. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  24. package/dist/authoring/scripts/validate-plugin.mjs +408 -1748
  25. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  26. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  27. package/dist/index.js +2 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/native-runtime/reader-runtime.mjs +34 -0
  30. package/dist/native-runtime/reader.d.mts +6 -0
  31. package/dist/native-runtime/reader.mjs +11 -0
  32. package/dist/scripts/aw-skill-eval-materializer.d.ts +11 -1
  33. package/dist/scripts/aw-skill-eval-materializer.js +119 -114
  34. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  35. package/dist/scripts/bundle-plugins.js +32 -7
  36. package/dist/scripts/bundle-plugins.js.map +1 -1
  37. package/dist/scripts/plugin-staging.d.ts +1 -1
  38. package/dist/scripts/plugin-staging.js +5 -2
  39. package/dist/scripts/plugin-staging.js.map +1 -1
  40. package/dist/scripts/plugin-test-context-guard.d.mts +1 -0
  41. package/dist/scripts/plugin-test-context-guard.mjs +59 -0
  42. package/dist/scripts/plugin-test-context-guard.mjs.map +1 -0
  43. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  44. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  45. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  46. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  47. package/dist/scripts/test-plugin-scripts.js +343 -58
  48. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  49. package/dist/scripts/test-workers.d.mts +24 -0
  50. package/dist/scripts/test-workers.mjs +59 -0
  51. package/dist/scripts/test-workers.mjs.map +1 -0
  52. package/dist/src/adapters/helpers.d.ts +7 -0
  53. package/dist/src/adapters/helpers.js.map +1 -1
  54. package/dist/src/authoring/workspace-commands.d.ts +3 -0
  55. package/dist/src/authoring/workspace-commands.js +7 -2
  56. package/dist/src/authoring/workspace-commands.js.map +1 -1
  57. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  58. package/dist/src/commands/aw-capabilities.js +48 -19
  59. package/dist/src/commands/aw-capabilities.js.map +1 -1
  60. package/dist/src/commands/catalog-dev-source.d.ts +40 -3
  61. package/dist/src/commands/catalog-dev-source.js +333 -42
  62. package/dist/src/commands/catalog-dev-source.js.map +1 -1
  63. package/dist/src/commands/catalog-generation.d.ts +5 -0
  64. package/dist/src/commands/catalog-generation.js.map +1 -1
  65. package/dist/src/commands/catalog-publication-inspection.d.ts +11 -3
  66. package/dist/src/commands/catalog-publication-inspection.js +211 -59
  67. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  68. package/dist/src/commands/catalog-publication-journal.d.ts +12 -0
  69. package/dist/src/commands/catalog-publication-journal.js +78 -1
  70. package/dist/src/commands/catalog-publication-journal.js.map +1 -1
  71. package/dist/src/commands/catalog-publish.d.ts +21 -1
  72. package/dist/src/commands/catalog-publish.js +133 -92
  73. package/dist/src/commands/catalog-publish.js.map +1 -1
  74. package/dist/src/commands/catalog-source.d.ts +25 -5
  75. package/dist/src/commands/catalog-source.js +153 -27
  76. package/dist/src/commands/catalog-source.js.map +1 -1
  77. package/dist/src/commands/catalog-status.js +2 -2
  78. package/dist/src/commands/catalog-status.js.map +1 -1
  79. package/dist/src/commands/catalog-store.d.ts +31 -7
  80. package/dist/src/commands/catalog-store.js +379 -42
  81. package/dist/src/commands/catalog-store.js.map +1 -1
  82. package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
  83. package/dist/src/commands/catalog-workspace-resolution.js +18 -3
  84. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
  85. package/dist/src/commands/console.js +33 -20
  86. package/dist/src/commands/console.js.map +1 -1
  87. package/dist/src/commands/dependency-operation-plan.d.ts +7 -0
  88. package/dist/src/commands/dependency-operation-plan.js +66 -30
  89. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  90. package/dist/src/commands/deployment-confirmation.d.ts +11 -0
  91. package/dist/src/commands/deployment-confirmation.js +101 -0
  92. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  93. package/dist/src/commands/init.js +1 -1
  94. package/dist/src/commands/init.js.map +1 -1
  95. package/dist/src/commands/intent-command.d.ts +34 -0
  96. package/dist/src/commands/intent-command.js +174 -0
  97. package/dist/src/commands/intent-command.js.map +1 -0
  98. package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
  99. package/dist/src/commands/lifecycle-command-package.js +199 -0
  100. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  101. package/dist/src/commands/managed-commands.d.ts +41 -0
  102. package/dist/src/commands/managed-commands.js +404 -0
  103. package/dist/src/commands/managed-commands.js.map +1 -0
  104. package/dist/src/commands/offline-cleanup-evidence.d.ts +12 -2
  105. package/dist/src/commands/offline-cleanup-evidence.js +57 -35
  106. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  107. package/dist/src/commands/operation-plan.d.ts +72 -2
  108. package/dist/src/commands/operation-plan.js +54 -3
  109. package/dist/src/commands/operation-plan.js.map +1 -1
  110. package/dist/src/commands/operation-planner.d.ts +6 -5
  111. package/dist/src/commands/operation-planner.js +23 -20
  112. package/dist/src/commands/operation-planner.js.map +1 -1
  113. package/dist/src/commands/options.d.ts +11 -16
  114. package/dist/src/commands/options.js +31 -25
  115. package/dist/src/commands/options.js.map +1 -1
  116. package/dist/src/commands/permission-batch.d.ts +5 -0
  117. package/dist/src/commands/permission-batch.js +83 -0
  118. package/dist/src/commands/permission-batch.js.map +1 -0
  119. package/dist/src/commands/plugin-capabilities.js +128 -58
  120. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  121. package/dist/src/commands/public-config-confirmation.d.ts +14 -0
  122. package/dist/src/commands/public-config-confirmation.js +73 -0
  123. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  124. package/dist/src/commands/public-interruption.d.ts +9 -0
  125. package/dist/src/commands/public-interruption.js +23 -0
  126. package/dist/src/commands/public-interruption.js.map +1 -0
  127. package/dist/src/commands/public-lifecycle-result.d.ts +106 -0
  128. package/dist/src/commands/public-lifecycle-result.js +536 -0
  129. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  130. package/dist/src/commands/public-lifecycle.d.ts +27 -0
  131. package/dist/src/commands/public-lifecycle.js +569 -0
  132. package/dist/src/commands/public-lifecycle.js.map +1 -0
  133. package/dist/src/commands/public-plugin-query.d.ts +16 -0
  134. package/dist/src/commands/public-plugin-query.js +231 -0
  135. package/dist/src/commands/public-plugin-query.js.map +1 -0
  136. package/dist/src/commands/rebuild-command.d.ts +177 -16
  137. package/dist/src/commands/rebuild-command.js +3370 -1559
  138. package/dist/src/commands/rebuild-command.js.map +1 -1
  139. package/dist/src/commands/rebuild-integration.d.ts +100 -55
  140. package/dist/src/commands/rebuild-integration.js +866 -3275
  141. package/dist/src/commands/rebuild-integration.js.map +1 -1
  142. package/dist/src/commands/rebuild-operations.d.ts +68 -13
  143. package/dist/src/commands/rebuild-operations.js +309 -120
  144. package/dist/src/commands/rebuild-operations.js.map +1 -1
  145. package/dist/src/commands/rebuild-platform-integration.d.ts +99 -0
  146. package/dist/src/commands/rebuild-platform-integration.js +2329 -0
  147. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  148. package/dist/src/commands/reconcile-operation-plan.d.ts +14 -9
  149. package/dist/src/commands/reconcile-operation-plan.js +26 -6
  150. package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
  151. package/dist/src/commands/review-inspection.d.ts +60 -0
  152. package/dist/src/commands/review-inspection.js +437 -0
  153. package/dist/src/commands/review-inspection.js.map +1 -0
  154. package/dist/src/commands/review-preparation.d.ts +51 -0
  155. package/dist/src/commands/review-preparation.js +400 -0
  156. package/dist/src/commands/review-preparation.js.map +1 -0
  157. package/dist/src/commands/runtime.d.ts +5 -1
  158. package/dist/src/commands/runtime.js +41 -8
  159. package/dist/src/commands/runtime.js.map +1 -1
  160. package/dist/src/commands/skill-eval.d.ts +8 -0
  161. package/dist/src/commands/skill-eval.js +126 -73
  162. package/dist/src/commands/skill-eval.js.map +1 -1
  163. package/dist/src/commands/status-v6.d.ts +148 -35
  164. package/dist/src/commands/status-v6.js +1166 -307
  165. package/dist/src/commands/status-v6.js.map +1 -1
  166. package/dist/src/commands/targets-command.d.ts +38 -0
  167. package/dist/src/commands/targets-command.js +182 -0
  168. package/dist/src/commands/targets-command.js.map +1 -0
  169. package/dist/src/commands/wizard.d.ts +7 -3
  170. package/dist/src/commands/wizard.js +7 -4
  171. package/dist/src/commands/wizard.js.map +1 -1
  172. package/dist/src/commands/write-commands.d.ts +7 -1
  173. package/dist/src/commands/write-commands.js +129 -38
  174. package/dist/src/commands/write-commands.js.map +1 -1
  175. package/dist/src/constants.d.ts +2 -3
  176. package/dist/src/constants.js +2 -3
  177. package/dist/src/constants.js.map +1 -1
  178. package/dist/src/eval/manifest-v1.d.ts +6 -3
  179. package/dist/src/eval/manifest-v1.js +44 -33
  180. package/dist/src/eval/manifest-v1.js.map +1 -1
  181. package/dist/src/generators/local-plugin.d.ts +4 -2
  182. package/dist/src/generators/local-plugin.js +319 -353
  183. package/dist/src/generators/local-plugin.js.map +1 -1
  184. package/dist/src/generators/permissions.d.ts +20 -2
  185. package/dist/src/generators/permissions.js +82 -15
  186. package/dist/src/generators/permissions.js.map +1 -1
  187. package/dist/src/index.d.ts +2 -33
  188. package/dist/src/index.js +1575 -1919
  189. package/dist/src/index.js.map +1 -1
  190. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  191. package/dist/src/intent/deployment-preferences.js +170 -0
  192. package/dist/src/intent/deployment-preferences.js.map +1 -0
  193. package/dist/src/intent/diagnostics.d.ts +11 -0
  194. package/dist/src/intent/diagnostics.js +14 -0
  195. package/dist/src/intent/diagnostics.js.map +1 -0
  196. package/dist/src/intent/intent-codec.d.ts +19 -0
  197. package/dist/src/intent/intent-codec.js +117 -0
  198. package/dist/src/intent/intent-codec.js.map +1 -0
  199. package/dist/src/intent/intent-store.d.ts +43 -0
  200. package/dist/src/intent/intent-store.js +118 -0
  201. package/dist/src/intent/intent-store.js.map +1 -0
  202. package/dist/src/intent/scope-context.d.ts +35 -0
  203. package/dist/src/intent/scope-context.js +179 -0
  204. package/dist/src/intent/scope-context.js.map +1 -0
  205. package/dist/src/intent/work-context.d.ts +13 -0
  206. package/dist/src/intent/work-context.js +22 -0
  207. package/dist/src/intent/work-context.js.map +1 -0
  208. package/dist/src/output/command-receipt.d.ts +6 -2
  209. package/dist/src/output/command-receipt.js +67 -32
  210. package/dist/src/output/command-receipt.js.map +1 -1
  211. package/dist/src/output/component-delivery.d.ts +28 -0
  212. package/dist/src/output/component-delivery.js +141 -0
  213. package/dist/src/output/component-delivery.js.map +1 -0
  214. package/dist/src/output/public-result.d.ts +69 -0
  215. package/dist/src/output/public-result.js +403 -0
  216. package/dist/src/output/public-result.js.map +1 -0
  217. package/dist/src/output/rebuild-progress.d.ts +3 -0
  218. package/dist/src/output/rebuild-progress.js +34 -9
  219. package/dist/src/output/rebuild-progress.js.map +1 -1
  220. package/dist/src/output/receipt-projection.d.ts +7 -0
  221. package/dist/src/output/receipt-projection.js +664 -0
  222. package/dist/src/output/receipt-projection.js.map +1 -0
  223. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  224. package/dist/src/output/skill-invocation-notices.js +84 -0
  225. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  226. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  227. package/dist/src/platforms/antigravity-permissions.js +388 -0
  228. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  229. package/dist/src/platforms/capabilities.d.ts +9 -0
  230. package/dist/src/platforms/capabilities.js +125 -0
  231. package/dist/src/platforms/capabilities.js.map +1 -0
  232. package/dist/src/platforms/contracts.d.ts +394 -0
  233. package/dist/src/platforms/contracts.js +2 -0
  234. package/dist/src/platforms/contracts.js.map +1 -0
  235. package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
  236. package/dist/src/platforms/cursor-workspace-hook.js +198 -0
  237. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  238. package/dist/src/platforms/discovery.d.ts +100 -0
  239. package/dist/src/platforms/discovery.js +779 -0
  240. package/dist/src/platforms/discovery.js.map +1 -0
  241. package/dist/src/platforms/grok-permission-config.d.ts +23 -0
  242. package/dist/src/platforms/grok-permission-config.js +184 -0
  243. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  244. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  245. package/dist/src/platforms/grok-permission-document.js +145 -0
  246. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  247. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  248. package/dist/src/platforms/grok-permissions.js +311 -0
  249. package/dist/src/platforms/grok-permissions.js.map +1 -0
  250. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  251. package/dist/src/platforms/host-permission-policy.js +86 -0
  252. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  253. package/dist/src/platforms/identity.d.ts +4 -0
  254. package/dist/src/platforms/identity.js +22 -0
  255. package/dist/src/platforms/identity.js.map +1 -0
  256. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  257. package/dist/src/platforms/inspection-grok.js +380 -0
  258. package/dist/src/platforms/inspection-grok.js.map +1 -0
  259. package/dist/src/platforms/inspection-native.d.ts +8 -0
  260. package/dist/src/platforms/inspection-native.js +584 -0
  261. package/dist/src/platforms/inspection-native.js.map +1 -0
  262. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  263. package/dist/src/platforms/inspection-opencode.js +98 -0
  264. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  265. package/dist/src/platforms/inspection-pi.d.ts +9 -0
  266. package/dist/src/platforms/inspection-pi.js +490 -0
  267. package/dist/src/platforms/inspection-pi.js.map +1 -0
  268. package/dist/src/platforms/inspection-query.d.ts +26 -0
  269. package/dist/src/platforms/inspection-query.js +118 -0
  270. package/dist/src/platforms/inspection-query.js.map +1 -0
  271. package/dist/src/platforms/inspection.d.ts +20 -0
  272. package/dist/src/platforms/inspection.js +259 -0
  273. package/dist/src/platforms/inspection.js.map +1 -0
  274. package/dist/src/platforms/layout.d.ts +35 -0
  275. package/dist/src/platforms/layout.js +332 -0
  276. package/dist/src/platforms/layout.js.map +1 -0
  277. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  278. package/dist/src/platforms/lifecycle-native-services.js +213 -0
  279. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  280. package/dist/src/platforms/lifecycle-native.d.ts +14 -0
  281. package/dist/src/platforms/lifecycle-native.js +234 -0
  282. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  283. package/dist/src/platforms/lifecycle.d.ts +29 -0
  284. package/dist/src/platforms/lifecycle.js +688 -0
  285. package/dist/src/platforms/lifecycle.js.map +1 -0
  286. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  287. package/dist/src/platforms/opencode-permission-config.js +253 -0
  288. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  289. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  290. package/dist/src/platforms/opencode-permissions.js +212 -0
  291. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  292. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  293. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  294. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  295. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  296. package/dist/src/platforms/permission-ownership.js +543 -0
  297. package/dist/src/platforms/permission-ownership.js.map +1 -0
  298. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  299. package/dist/src/platforms/permission-sidecar.js +215 -0
  300. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  301. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  302. package/dist/src/platforms/projection-code-extension.js +126 -0
  303. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  304. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  305. package/dist/src/platforms/projection-command-resources.js +74 -0
  306. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  307. package/dist/src/platforms/projection-files.d.ts +28 -0
  308. package/dist/src/platforms/projection-files.js +113 -0
  309. package/dist/src/platforms/projection-files.js.map +1 -0
  310. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  311. package/dist/src/platforms/projection-marketplace.js +42 -0
  312. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  313. package/dist/src/platforms/projection.d.ts +13 -0
  314. package/dist/src/platforms/projection.js +578 -0
  315. package/dist/src/platforms/projection.js.map +1 -0
  316. package/dist/src/platforms/read-only-retry-policy.d.ts +34 -0
  317. package/dist/src/platforms/read-only-retry-policy.js +70 -0
  318. package/dist/src/platforms/read-only-retry-policy.js.map +1 -0
  319. package/dist/src/platforms/registry.d.ts +4 -0
  320. package/dist/src/platforms/registry.js +30 -0
  321. package/dist/src/platforms/registry.js.map +1 -0
  322. package/dist/src/platforms/retirement-native.d.ts +6 -0
  323. package/dist/src/platforms/retirement-native.js +95 -0
  324. package/dist/src/platforms/retirement-native.js.map +1 -0
  325. package/dist/src/platforms/supplement-layout.d.ts +20 -0
  326. package/dist/src/platforms/supplement-layout.js +54 -0
  327. package/dist/src/platforms/supplement-layout.js.map +1 -0
  328. package/dist/src/platforms/supplement-state.d.ts +13 -0
  329. package/dist/src/platforms/supplement-state.js +93 -0
  330. package/dist/src/platforms/supplement-state.js.map +1 -0
  331. package/dist/src/portable/commands.d.ts +60 -11
  332. package/dist/src/portable/commands.js +88 -346
  333. package/dist/src/portable/commands.js.map +1 -1
  334. package/dist/src/portable/historical-materialization.d.ts +25 -0
  335. package/dist/src/portable/historical-materialization.js +148 -0
  336. package/dist/src/portable/historical-materialization.js.map +1 -0
  337. package/dist/src/portable/materializer.d.ts +46 -2
  338. package/dist/src/portable/materializer.js +262 -259
  339. package/dist/src/portable/materializer.js.map +1 -1
  340. package/dist/src/portable/recovery-layout.d.ts +17 -0
  341. package/dist/src/portable/recovery-layout.js +42 -0
  342. package/dist/src/portable/recovery-layout.js.map +1 -0
  343. package/dist/src/portable/recovery.d.ts +177 -0
  344. package/dist/src/portable/recovery.js +597 -0
  345. package/dist/src/portable/recovery.js.map +1 -0
  346. package/dist/src/portable/writer.d.ts +67 -0
  347. package/dist/src/portable/writer.js +321 -0
  348. package/dist/src/portable/writer.js.map +1 -0
  349. package/dist/src/recovery/coordinator.d.ts +175 -0
  350. package/dist/src/recovery/coordinator.js +1624 -0
  351. package/dist/src/recovery/coordinator.js.map +1 -0
  352. package/dist/src/recovery/demand.d.ts +53 -0
  353. package/dist/src/recovery/demand.js +189 -0
  354. package/dist/src/recovery/demand.js.map +1 -0
  355. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  356. package/dist/src/recovery/install-concurrency.js +196 -0
  357. package/dist/src/recovery/install-concurrency.js.map +1 -0
  358. package/dist/src/recovery/interruption.d.ts +19 -0
  359. package/dist/src/recovery/interruption.js +43 -0
  360. package/dist/src/recovery/interruption.js.map +1 -0
  361. package/dist/src/recovery/joint-coordinator.d.ts +46 -0
  362. package/dist/src/recovery/joint-coordinator.js +1723 -0
  363. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  364. package/dist/src/recovery/joint-demand.d.ts +72 -0
  365. package/dist/src/recovery/joint-demand.js +332 -0
  366. package/dist/src/recovery/joint-demand.js.map +1 -0
  367. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  368. package/dist/src/recovery/joint-install-execution.js +308 -0
  369. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  370. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  371. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  372. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  373. package/dist/src/recovery/performance.d.ts +4 -0
  374. package/dist/src/recovery/performance.js +26 -0
  375. package/dist/src/recovery/performance.js.map +1 -0
  376. package/dist/src/recovery/receipt.d.ts +131 -0
  377. package/dist/src/recovery/receipt.js +91 -0
  378. package/dist/src/recovery/receipt.js.map +1 -0
  379. package/dist/src/recovery/retirement.d.ts +47 -0
  380. package/dist/src/recovery/retirement.js +499 -0
  381. package/dist/src/recovery/retirement.js.map +1 -0
  382. package/dist/src/recovery/status.d.ts +143 -0
  383. package/dist/src/recovery/status.js +1528 -0
  384. package/dist/src/recovery/status.js.map +1 -0
  385. package/dist/src/recovery/types.d.ts +85 -0
  386. package/dist/src/recovery/types.js +2 -0
  387. package/dist/src/recovery/types.js.map +1 -0
  388. package/dist/src/review/eval-source-input.d.ts +44 -0
  389. package/dist/src/review/eval-source-input.js +213 -0
  390. package/dist/src/review/eval-source-input.js.map +1 -0
  391. package/dist/src/review/platform-profile.d.ts +5 -0
  392. package/dist/src/review/platform-profile.js +13 -0
  393. package/dist/src/review/platform-profile.js.map +1 -0
  394. package/dist/src/review/review-profile.d.ts +20 -0
  395. package/dist/src/review/review-profile.js +286 -0
  396. package/dist/src/review/review-profile.js.map +1 -0
  397. package/dist/src/review/review-selection.d.ts +20 -0
  398. package/dist/src/review/review-selection.js +502 -0
  399. package/dist/src/review/review-selection.js.map +1 -0
  400. package/dist/src/review/review-types.d.ts +71 -0
  401. package/dist/src/review/review-types.js +16 -0
  402. package/dist/src/review/review-types.js.map +1 -0
  403. package/dist/src/review/skill-materialization.d.ts +67 -0
  404. package/dist/src/review/skill-materialization.js +235 -0
  405. package/dist/src/review/skill-materialization.js.map +1 -0
  406. package/dist/src/review/source-binding.d.ts +203 -0
  407. package/dist/src/review/source-binding.js +791 -0
  408. package/dist/src/review/source-binding.js.map +1 -0
  409. package/dist/src/tui/agent-management.d.ts +23 -0
  410. package/dist/src/tui/agent-management.js +319 -0
  411. package/dist/src/tui/agent-management.js.map +1 -0
  412. package/dist/src/tui/agent-settings.d.ts +47 -0
  413. package/dist/src/tui/agent-settings.js +97 -0
  414. package/dist/src/tui/agent-settings.js.map +1 -0
  415. package/dist/src/tui/catalog-generation.d.ts +9 -0
  416. package/dist/src/tui/catalog-generation.js +96 -6
  417. package/dist/src/tui/catalog-generation.js.map +1 -1
  418. package/dist/src/tui/catalog-sources/projection.d.ts +2 -2
  419. package/dist/src/tui/catalog-sources/screens.js +19 -12
  420. package/dist/src/tui/catalog-sources/screens.js.map +1 -1
  421. package/dist/src/tui/catalog-sources/session.d.ts +11 -1
  422. package/dist/src/tui/catalog-sources/session.js +80 -5
  423. package/dist/src/tui/catalog-sources/session.js.map +1 -1
  424. package/dist/src/tui/catalog-sources/types.d.ts +15 -2
  425. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  426. package/dist/src/tui/catalog-store-task.js +19 -0
  427. package/dist/src/tui/catalog-store-task.js.map +1 -0
  428. package/dist/src/tui/clipboard.d.ts +13 -0
  429. package/dist/src/tui/clipboard.js +95 -0
  430. package/dist/src/tui/clipboard.js.map +1 -0
  431. package/dist/src/tui/components.d.ts +113 -3
  432. package/dist/src/tui/components.js +201 -34
  433. package/dist/src/tui/components.js.map +1 -1
  434. package/dist/src/tui/config-array-draft.d.ts +30 -0
  435. package/dist/src/tui/config-array-draft.js +51 -0
  436. package/dist/src/tui/config-array-draft.js.map +1 -0
  437. package/dist/src/tui/config-leaf-editor.d.ts +44 -0
  438. package/dist/src/tui/config-leaf-editor.js +227 -0
  439. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  440. package/dist/src/tui/config-object-suggestions.d.ts +15 -0
  441. package/dist/src/tui/config-object-suggestions.js +71 -0
  442. package/dist/src/tui/config-object-suggestions.js.map +1 -0
  443. package/dist/src/tui/config-references.d.ts +38 -0
  444. package/dist/src/tui/config-references.js +82 -0
  445. package/dist/src/tui/config-references.js.map +1 -0
  446. package/dist/src/tui/config-suggestions.d.ts +27 -0
  447. package/dist/src/tui/config-suggestions.js +62 -0
  448. package/dist/src/tui/config-suggestions.js.map +1 -0
  449. package/dist/src/tui/config-value-presentation.d.ts +23 -0
  450. package/dist/src/tui/config-value-presentation.js +151 -0
  451. package/dist/src/tui/config-value-presentation.js.map +1 -0
  452. package/dist/src/tui/console-app-v4.d.ts +14 -5
  453. package/dist/src/tui/console-app-v4.js +9779 -2488
  454. package/dist/src/tui/console-app-v4.js.map +1 -1
  455. package/dist/src/tui/content-item-card.d.ts +13 -0
  456. package/dist/src/tui/content-item-card.js +51 -0
  457. package/dist/src/tui/content-item-card.js.map +1 -0
  458. package/dist/src/tui/controller-runtime.d.ts +4 -3
  459. package/dist/src/tui/controller-runtime.js +1610 -590
  460. package/dist/src/tui/controller-runtime.js.map +1 -1
  461. package/dist/src/tui/controller.d.ts +583 -80
  462. package/dist/src/tui/controller.js +3362 -263
  463. package/dist/src/tui/controller.js.map +1 -1
  464. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  465. package/dist/src/tui/dependency-graph-view.js +121 -0
  466. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  467. package/dist/src/tui/dependency-graph.d.ts +81 -0
  468. package/dist/src/tui/dependency-graph.js +452 -0
  469. package/dist/src/tui/dependency-graph.js.map +1 -0
  470. package/dist/src/tui/deployment-view.d.ts +14 -0
  471. package/dist/src/tui/deployment-view.js +175 -0
  472. package/dist/src/tui/deployment-view.js.map +1 -0
  473. package/dist/src/tui/diagnostic-projection.d.ts +31 -0
  474. package/dist/src/tui/diagnostic-projection.js +681 -0
  475. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  476. package/dist/src/tui/diagnostics.d.ts +6 -2
  477. package/dist/src/tui/diagnostics.js +14 -2
  478. package/dist/src/tui/diagnostics.js.map +1 -1
  479. package/dist/src/tui/entity-cards.d.ts +56 -0
  480. package/dist/src/tui/entity-cards.js +327 -0
  481. package/dist/src/tui/entity-cards.js.map +1 -0
  482. package/dist/src/tui/glossary.d.ts +25 -0
  483. package/dist/src/tui/glossary.js +78 -0
  484. package/dist/src/tui/glossary.js.map +1 -0
  485. package/dist/src/tui/guided-setup.d.ts +25 -0
  486. package/dist/src/tui/guided-setup.js +101 -0
  487. package/dist/src/tui/guided-setup.js.map +1 -0
  488. package/dist/src/tui/index.d.ts +4 -1
  489. package/dist/src/tui/index.js +4 -1
  490. package/dist/src/tui/index.js.map +1 -1
  491. package/dist/src/tui/input-display.d.ts +1 -0
  492. package/dist/src/tui/input-display.js +23 -1
  493. package/dist/src/tui/input-display.js.map +1 -1
  494. package/dist/src/tui/keys.d.ts +44 -0
  495. package/dist/src/tui/keys.js +43 -15
  496. package/dist/src/tui/keys.js.map +1 -1
  497. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  498. package/dist/src/tui/lifecycle-action-view.js +36 -0
  499. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  500. package/dist/src/tui/model.d.ts +141 -28
  501. package/dist/src/tui/model.js +968 -285
  502. package/dist/src/tui/model.js.map +1 -1
  503. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  504. package/dist/src/tui/operation-diagnostic-screens.js +76 -0
  505. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  506. package/dist/src/tui/operation-history.d.ts +91 -0
  507. package/dist/src/tui/operation-history.js +167 -0
  508. package/dist/src/tui/operation-history.js.map +1 -0
  509. package/dist/src/tui/operation-review-planner.d.ts +7 -0
  510. package/dist/src/tui/operation-review-planner.js +980 -146
  511. package/dist/src/tui/operation-review-planner.js.map +1 -1
  512. package/dist/src/tui/plugin-content.d.ts +33 -0
  513. package/dist/src/tui/plugin-content.js +245 -0
  514. package/dist/src/tui/plugin-content.js.map +1 -0
  515. package/dist/src/tui/plugin-detail.d.ts +75 -0
  516. package/dist/src/tui/plugin-detail.js +267 -0
  517. package/dist/src/tui/plugin-detail.js.map +1 -0
  518. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  519. package/dist/src/tui/plugin-write-task.js +286 -0
  520. package/dist/src/tui/plugin-write-task.js.map +1 -0
  521. package/dist/src/tui/query-header.d.ts +30 -0
  522. package/dist/src/tui/query-header.js +40 -0
  523. package/dist/src/tui/query-header.js.map +1 -0
  524. package/dist/src/tui/reader.d.ts +38 -0
  525. package/dist/src/tui/reader.js +49 -0
  526. package/dist/src/tui/reader.js.map +1 -0
  527. package/dist/src/tui/router.d.ts +170 -39
  528. package/dist/src/tui/router.js +338 -50
  529. package/dist/src/tui/router.js.map +1 -1
  530. package/dist/src/tui/scoped-flow.d.ts +49 -0
  531. package/dist/src/tui/scoped-flow.js +212 -0
  532. package/dist/src/tui/scoped-flow.js.map +1 -0
  533. package/dist/src/tui/scoped-inventory.d.ts +139 -0
  534. package/dist/src/tui/scoped-inventory.js +295 -0
  535. package/dist/src/tui/scoped-inventory.js.map +1 -0
  536. package/dist/src/tui/screen-registry.d.ts +696 -0
  537. package/dist/src/tui/screen-registry.js +226 -0
  538. package/dist/src/tui/screen-registry.js.map +1 -0
  539. package/dist/src/tui/session-console-app.d.ts +8 -0
  540. package/dist/src/tui/session-console-app.js +24 -0
  541. package/dist/src/tui/session-console-app.js.map +1 -0
  542. package/dist/src/tui/session-host.d.ts +45 -0
  543. package/dist/src/tui/session-host.js +219 -0
  544. package/dist/src/tui/session-host.js.map +1 -0
  545. package/dist/src/tui/source-detail-card.d.ts +29 -0
  546. package/dist/src/tui/source-detail-card.js +45 -0
  547. package/dist/src/tui/source-detail-card.js.map +1 -0
  548. package/dist/src/tui/theme.d.ts +12 -0
  549. package/dist/src/tui/theme.js +12 -0
  550. package/dist/src/tui/theme.js.map +1 -1
  551. package/dist/src/tui/viewport.d.ts +1 -0
  552. package/dist/src/tui/viewport.js +23 -0
  553. package/dist/src/tui/viewport.js.map +1 -1
  554. package/dist/src/tui/wizard.js +26 -4
  555. package/dist/src/tui/wizard.js.map +1 -1
  556. package/dist/src/types.d.ts +105 -83
  557. package/dist/src/types.js +1 -1
  558. package/dist/src/types.js.map +1 -1
  559. package/dist/src/utils/agent-version.d.ts +10 -4
  560. package/dist/src/utils/agent-version.js +6 -8
  561. package/dist/src/utils/agent-version.js.map +1 -1
  562. package/dist/src/utils/artifact-plan.d.ts +18 -25
  563. package/dist/src/utils/artifact-plan.js +59 -445
  564. package/dist/src/utils/artifact-plan.js.map +1 -1
  565. package/dist/src/utils/artifact-renderer.d.ts +64 -90
  566. package/dist/src/utils/artifact-renderer.js +202 -303
  567. package/dist/src/utils/artifact-renderer.js.map +1 -1
  568. package/dist/src/utils/artifact-request.d.ts +19 -14
  569. package/dist/src/utils/artifact-request.js +51 -36
  570. package/dist/src/utils/artifact-request.js.map +1 -1
  571. package/dist/src/utils/artifact-sources.d.ts +4 -8
  572. package/dist/src/utils/artifact-sources.js +15 -6
  573. package/dist/src/utils/artifact-sources.js.map +1 -1
  574. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  575. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  576. package/dist/src/utils/bundle-layout.d.ts +2 -0
  577. package/dist/src/utils/bundle-layout.js +88 -158
  578. package/dist/src/utils/bundle-layout.js.map +1 -1
  579. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  580. package/dist/src/utils/catalog-capability-projection.js +14 -0
  581. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  582. package/dist/src/utils/catalog-digests.d.ts +2 -12
  583. package/dist/src/utils/catalog-digests.js +7 -55
  584. package/dist/src/utils/catalog-digests.js.map +1 -1
  585. package/dist/src/utils/catalog-generation-resolver.d.ts +28 -4
  586. package/dist/src/utils/catalog-generation-resolver.js +146 -40
  587. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  588. package/dist/src/utils/catalog-generation-service.d.ts +24 -2
  589. package/dist/src/utils/catalog-generation-service.js +92 -48
  590. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  591. package/dist/src/utils/catalog-generation-state.js +1 -1
  592. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  593. package/dist/src/utils/catalog-generation-store.d.ts +4 -0
  594. package/dist/src/utils/catalog-generation-store.js +68 -10
  595. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  596. package/dist/src/utils/catalog-operation-context.d.ts +61 -4
  597. package/dist/src/utils/catalog-operation-context.js +225 -4
  598. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  599. package/dist/src/utils/catalog-public-error.js +4 -0
  600. package/dist/src/utils/catalog-public-error.js.map +1 -1
  601. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
  602. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  603. package/dist/src/utils/catalog-snapshot.d.ts +3 -0
  604. package/dist/src/utils/catalog-snapshot.js +4 -1
  605. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  606. package/dist/src/utils/catalog-source-impact.d.ts +3 -2
  607. package/dist/src/utils/catalog-source-impact.js +142 -20
  608. package/dist/src/utils/catalog-source-impact.js.map +1 -1
  609. package/dist/src/utils/catalog-source-references.d.ts +57 -1
  610. package/dist/src/utils/catalog-source-references.js +755 -162
  611. package/dist/src/utils/catalog-source-references.js.map +1 -1
  612. package/dist/src/utils/catalog-sources.d.ts +1 -1
  613. package/dist/src/utils/catalog-sources.js +21 -5
  614. package/dist/src/utils/catalog-sources.js.map +1 -1
  615. package/dist/src/utils/codex-config.d.ts +3 -0
  616. package/dist/src/utils/codex-config.js +7 -0
  617. package/dist/src/utils/codex-config.js.map +1 -1
  618. package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
  619. package/dist/src/utils/codex-executable-discovery.js +431 -0
  620. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  621. package/dist/src/utils/codex-manager.d.ts +23 -42
  622. package/dist/src/utils/codex-manager.js +79 -767
  623. package/dist/src/utils/codex-manager.js.map +1 -1
  624. package/dist/src/utils/codex-native-observation.d.ts +40 -1
  625. package/dist/src/utils/codex-native-observation.js +172 -0
  626. package/dist/src/utils/codex-native-observation.js.map +1 -1
  627. package/dist/src/utils/codex-reconciler.d.ts +2 -7
  628. package/dist/src/utils/codex-reconciler.js +33 -5
  629. package/dist/src/utils/codex-reconciler.js.map +1 -1
  630. package/dist/src/utils/codex-shared-native.d.ts +8 -26
  631. package/dist/src/utils/codex-shared-native.js +63 -83
  632. package/dist/src/utils/codex-shared-native.js.map +1 -1
  633. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  634. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  635. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  636. package/dist/src/utils/codex-skills-root.js +29 -0
  637. package/dist/src/utils/codex-skills-root.js.map +1 -0
  638. package/dist/src/utils/codex-surface-analysis.d.ts +6 -2
  639. package/dist/src/utils/codex-surface-analysis.js +31 -56
  640. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  641. package/dist/src/utils/component-agent-binding.d.ts +17 -0
  642. package/dist/src/utils/component-agent-binding.js +119 -0
  643. package/dist/src/utils/component-agent-binding.js.map +1 -0
  644. package/dist/src/utils/component-command-preparation.d.ts +33 -0
  645. package/dist/src/utils/component-command-preparation.js +129 -0
  646. package/dist/src/utils/component-command-preparation.js.map +1 -0
  647. package/dist/src/utils/component-gap.d.ts +4 -0
  648. package/dist/src/utils/component-gap.js +16 -0
  649. package/dist/src/utils/component-gap.js.map +1 -0
  650. package/dist/src/utils/component-resources.d.ts +53 -0
  651. package/dist/src/utils/component-resources.js +340 -0
  652. package/dist/src/utils/component-resources.js.map +1 -0
  653. package/dist/src/utils/config-platforms.d.ts +21 -0
  654. package/dist/src/utils/config-platforms.js +51 -0
  655. package/dist/src/utils/config-platforms.js.map +1 -0
  656. package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
  657. package/dist/src/utils/dynamic-skill-tree.js +33 -40
  658. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  659. package/dist/src/utils/git-catalog-provider.d.ts +3 -0
  660. package/dist/src/utils/git-catalog-provider.js +49 -3
  661. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  662. package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
  663. package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
  664. package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
  665. package/dist/src/utils/local-marketplace.d.ts +19 -12
  666. package/dist/src/utils/local-marketplace.js +97 -194
  667. package/dist/src/utils/local-marketplace.js.map +1 -1
  668. package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
  669. package/dist/src/utils/managed-command-cli-review.js +431 -0
  670. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  671. package/dist/src/utils/managed-command-closure.d.ts +14 -0
  672. package/dist/src/utils/managed-command-closure.js +156 -0
  673. package/dist/src/utils/managed-command-closure.js.map +1 -0
  674. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  675. package/dist/src/utils/managed-command-errors.js +10 -0
  676. package/dist/src/utils/managed-command-errors.js.map +1 -0
  677. package/dist/src/utils/managed-command-materialization.d.ts +90 -0
  678. package/dist/src/utils/managed-command-materialization.js +375 -0
  679. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  680. package/dist/src/utils/managed-command-preparation.d.ts +30 -0
  681. package/dist/src/utils/managed-command-preparation.js +39 -0
  682. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  683. package/dist/src/utils/managed-command-review.d.ts +33 -0
  684. package/dist/src/utils/managed-command-review.js +80 -0
  685. package/dist/src/utils/managed-command-review.js.map +1 -0
  686. package/dist/src/utils/managed-command-runtime.d.ts +36 -0
  687. package/dist/src/utils/managed-command-runtime.js +126 -0
  688. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  689. package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
  690. package/dist/src/utils/managed-command-snapshots.js +89 -0
  691. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  692. package/dist/src/utils/managed-command-store.d.ts +141 -0
  693. package/dist/src/utils/managed-command-store.js +839 -0
  694. package/dist/src/utils/managed-command-store.js.map +1 -0
  695. package/dist/src/utils/multi-source-catalog.d.ts +6 -1
  696. package/dist/src/utils/multi-source-catalog.js +9 -4
  697. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  698. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  699. package/dist/src/utils/native-cli-interruption.js +65 -0
  700. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  701. package/dist/src/utils/native-cli.d.ts +37 -6
  702. package/dist/src/utils/native-cli.js +523 -60
  703. package/dist/src/utils/native-cli.js.map +1 -1
  704. package/dist/src/utils/native-demand.d.ts +29 -0
  705. package/dist/src/utils/native-demand.js +4 -0
  706. package/dist/src/utils/native-demand.js.map +1 -0
  707. package/dist/src/utils/native-tool-context.d.ts +17 -0
  708. package/dist/src/utils/native-tool-context.js +40 -0
  709. package/dist/src/utils/native-tool-context.js.map +1 -0
  710. package/dist/src/utils/native-tool-review.d.ts +8 -0
  711. package/dist/src/utils/native-tool-review.js +14 -0
  712. package/dist/src/utils/native-tool-review.js.map +1 -0
  713. package/dist/src/utils/ownership.d.ts +38 -3
  714. package/dist/src/utils/ownership.js +118 -11
  715. package/dist/src/utils/ownership.js.map +1 -1
  716. package/dist/src/utils/package-content.d.ts +7 -0
  717. package/dist/src/utils/package-content.js +70 -0
  718. package/dist/src/utils/package-content.js.map +1 -0
  719. package/dist/src/utils/path-catalog-provider.js +2 -0
  720. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  721. package/dist/src/utils/paths.d.ts +1 -1
  722. package/dist/src/utils/paths.js +5 -2
  723. package/dist/src/utils/paths.js.map +1 -1
  724. package/dist/src/utils/platform-empty-state.d.ts +69 -0
  725. package/dist/src/utils/platform-empty-state.js +249 -0
  726. package/dist/src/utils/platform-empty-state.js.map +1 -0
  727. package/dist/src/utils/platform-support.d.ts +1 -1
  728. package/dist/src/utils/platform-support.js +1 -1
  729. package/dist/src/utils/platform-support.js.map +1 -1
  730. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  731. package/dist/src/utils/plugin-config-command-apply.js +142 -0
  732. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  733. package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
  734. package/dist/src/utils/plugin-config-diagnostics.js +44 -0
  735. package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
  736. package/dist/src/utils/plugin-config-impact.d.ts +76 -0
  737. package/dist/src/utils/plugin-config-impact.js +359 -0
  738. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  739. package/dist/src/utils/plugin-config-references.d.ts +116 -0
  740. package/dist/src/utils/plugin-config-references.js +379 -0
  741. package/dist/src/utils/plugin-config-references.js.map +1 -0
  742. package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
  743. package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
  744. package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
  745. package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
  746. package/dist/src/utils/plugin-config-suggestions.js +322 -0
  747. package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
  748. package/dist/src/utils/plugin-config-write.d.ts +108 -19
  749. package/dist/src/utils/plugin-config-write.js +781 -568
  750. package/dist/src/utils/plugin-config-write.js.map +1 -1
  751. package/dist/src/utils/plugin-config.d.ts +122 -43
  752. package/dist/src/utils/plugin-config.js +574 -610
  753. package/dist/src/utils/plugin-config.js.map +1 -1
  754. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  755. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  756. package/dist/src/utils/plugin-scripts.d.ts +41 -17
  757. package/dist/src/utils/plugin-scripts.js +586 -123
  758. package/dist/src/utils/plugin-scripts.js.map +1 -1
  759. package/dist/src/utils/process-lock.js +14 -5
  760. package/dist/src/utils/process-lock.js.map +1 -1
  761. package/dist/src/utils/process-tree.d.ts +2 -2
  762. package/dist/src/utils/process-tree.js +1 -1
  763. package/dist/src/utils/process-tree.js.map +1 -1
  764. package/dist/src/utils/project-boundary.d.ts +11 -1
  765. package/dist/src/utils/project-boundary.js +33 -11
  766. package/dist/src/utils/project-boundary.js.map +1 -1
  767. package/dist/src/utils/rendered-contract.js +24 -1
  768. package/dist/src/utils/rendered-contract.js.map +1 -1
  769. package/dist/src/utils/runtime-config.d.ts +18 -0
  770. package/dist/src/utils/runtime-config.js +64 -0
  771. package/dist/src/utils/runtime-config.js.map +1 -0
  772. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  773. package/dist/src/utils/runtime-skill-closure.js +50 -7
  774. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  775. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  776. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  777. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  778. package/dist/src/utils/sensitive-content.d.ts +4 -0
  779. package/dist/src/utils/sensitive-content.js +36 -0
  780. package/dist/src/utils/sensitive-content.js.map +1 -0
  781. package/dist/src/utils/skill-invocation-warning.d.ts +19 -0
  782. package/dist/src/utils/skill-invocation-warning.js +43 -0
  783. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  784. package/dist/src/utils/skill-validation.js +0 -5
  785. package/dist/src/utils/skill-validation.js.map +1 -1
  786. package/dist/src/utils/state-paths.d.ts +8 -3
  787. package/dist/src/utils/state-paths.js +53 -16
  788. package/dist/src/utils/state-paths.js.map +1 -1
  789. package/dist/src/utils/target-eligibility.d.ts +2 -2
  790. package/dist/src/utils/target-eligibility.js.map +1 -1
  791. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  792. package/dist/src/utils/windows-claude-shim.js +10 -0
  793. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  794. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  795. package/dist/src/utils/windows-npm-shim.js +155 -0
  796. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  797. package/dist/vitest.config.js +109 -9
  798. package/dist/vitest.config.js.map +1 -1
  799. package/package.json +20 -12
  800. package/dist/authoring/templates/aw-config-runtime.d.mts +0 -2
  801. package/dist/authoring/templates/aw-config-runtime.mjs +0 -407
  802. package/dist/authoring/templates/aw-config-runtime.mjs.map +0 -1
  803. package/dist/src/commands/review-publication.d.ts +0 -99
  804. package/dist/src/commands/review-publication.js +0 -904
  805. package/dist/src/commands/review-publication.js.map +0 -1
  806. package/dist/src/commands/sync-command.d.ts +0 -23
  807. package/dist/src/commands/sync-command.js +0 -242
  808. package/dist/src/commands/sync-command.js.map +0 -1
  809. package/dist/src/portable/skills-cli.d.ts +0 -43
  810. package/dist/src/portable/skills-cli.js +0 -148
  811. package/dist/src/portable/skills-cli.js.map +0 -1
  812. package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
  813. package/dist/src/utils/codex-native-render-receipt.js +0 -205
  814. package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
  815. package/dist/src/utils/plugin-intent-state.d.ts +0 -34
  816. package/dist/src/utils/plugin-intent-state.js +0 -289
  817. package/dist/src/utils/plugin-intent-state.js.map +0 -1
  818. package/dist/src/utils/slash-commands.d.ts +0 -1
  819. package/dist/src/utils/slash-commands.js +0 -2
  820. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -0,0 +1,1528 @@
1
+ import path from 'node:path';
2
+ import { isPlatformTarget, normalizeStaticPluginComponents, resolveInvocationPolicy } from '@lesliechan721/aw-plugin-core/manifest';
3
+ import { selectAgents } from '../intent/deployment-preferences.js';
4
+ import { createScopeContext } from '../intent/scope-context.js';
5
+ import { resolveIntentPath } from '../intent/intent-store.js';
6
+ import { parsePluginId } from '../utils/multi-source-catalog.js';
7
+ import { inspectPortableExtraInstalled, inspectPortableRecovery, portablePreparationDiagnostic } from '../portable/recovery.js';
8
+ import { readJointDemand, deriveJointDemand, projectSkillCandidates, isInstalledSkillProvider, hasReadyProviderSkills } from './joint-demand.js';
9
+ import { readDemand, resolveDelivery } from './demand.js';
10
+ import { retainedOutputDiagnostic, scopeNativeComponentGaps, uniqueRecoveryComponentGaps } from './receipt.js';
11
+ import { rethrowFatalError } from '../utils/codex-executable-discovery.js';
12
+ import { createCodexNativeObservationSession } from '../utils/codex-native-observation.js';
13
+ import { getAgentPluginAdapter } from '../platforms/registry.js';
14
+ import { getQualifiedPlatformProfile } from '../platforms/capabilities.js';
15
+ import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
16
+ import { piAgentConsumerDiagnostic, piProjectListsUserSkills } from '../platforms/inspection-pi.js';
17
+ import { gapSupplementFiles } from '../platforms/supplement-layout.js';
18
+ import { inspectPlatformSupplementState } from '../platforms/supplement-state.js';
19
+ import { resolveArtifactRenderConfig } from '../utils/artifact-renderer.js';
20
+ import { resolveActiveConfigPlatforms } from '../utils/config-platforms.js';
21
+ import { configStatusDiagnostics, configReadDiagnostic, isConfigDiagnostic } from '../utils/plugin-config-diagnostics.js';
22
+ import { createPlatformInputEvidence, matchesPlatformEmptyState, readPlatformDeliveryState, platformPackageInputDigest, readPlatformPackageContentDigest } from '../utils/platform-empty-state.js';
23
+ import { deliveryNoticeMessage, INVOCATION_POLICY_NOT_APPLIED } from '../output/component-delivery.js';
24
+ import { piProjectEmptyDeliveryObserved } from '../platforms/lifecycle-native.js';
25
+ import { getDeploymentLayout, hasSharedUserPackage } from '../platforms/layout.js';
26
+ import { identityDigest } from '../platforms/identity.js';
27
+ import { deploymentPackageComponent, inspectStaticSupplements, requiredDeploymentActivation } from '../platforms/inspection.js';
28
+ import { resolveStaticPlatformResourceRoot } from '../utils/component-resources.js';
29
+ import { inspectOwnedComponents, readSkillOwnerMarker } from '../utils/ownership.js';
30
+ import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
31
+ import { resolvePartialCatalogOperationContext } from '../utils/catalog-operation-context.js';
32
+ import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
33
+ import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
34
+ import { resolvePluginDependencyClosure, resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
35
+ import { installationInvocation, selectNativeProduct } from '../platforms/discovery.js';
36
+ import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
37
+ import { measureRecoveryPerformanceStage } from './performance.js';
38
+ import { withNativeObservationBatch } from '../platforms/inspection-query.js';
39
+ import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
40
+ import { mapInstallReads } from './install-concurrency.js';
41
+ import { selectPlatformInvocationPolicy, hostPermissionClaims } from '../generators/permissions.js';
42
+ import { isPermissionHost } from '../platforms/host-permission-policy.js';
43
+ import { inspectHostPermissionDelivery } from '../platforms/permission-ownership.js';
44
+ import { readManagedCommandPackage } from '../utils/managed-command-store.js';
45
+ const NATIVE_READ_ERRORS = new Set(['nativeStateUnreadable', 'stateInventoryFailed', 'configReadFailed', 'componentInspectionFailed', 'targetInspectionFailed', 'codexNativeObservationFailed',
46
+ 'nativeObservationFailed', 'nativeObservationUnavailable']);
47
+ function isNativeReadError({ code, detail }, needsOwnership = true) {
48
+ return NATIVE_READ_ERRORS.has(code) || (code === 'configInvalid' && detail?.reasonCode === 'configReadFailed')
49
+ || needsOwnership && (code === 'nativeConfigurationUnreadable'
50
+ || code === 'nativeMarketplaceUnconfirmed' && detail !== undefined);
51
+ }
52
+ export function isTargetObservationReadError(entry) {
53
+ const { code } = entry;
54
+ return isNativeReadError(entry) || code === 'portableObservationFailed' || code === 'portablePreparationFailed'
55
+ || /(?:VerificationFailed|ReadFailed|LockInvalid)/u.test(code);
56
+ }
57
+ function diagnostic(code) { return { code, message: `目标尚未满足:${code}。` }; }
58
+ function withStatusNativeQueries(options, read) {
59
+ if (options.nativeQuerySession)
60
+ return read(options);
61
+ return withNativeObservationBatch({ runner: options.nativeCliRunner, signal: options.signal }, (batch) => read({ ...options,
62
+ discoveryCache: options.discoveryCache ?? batch.discoveryCache, nativeQuerySession: batch.nativeQuerySession,
63
+ nativeCliRunner: batch.runner }));
64
+ }
65
+ async function readAdapterObservations(options, context, demand, inventory) {
66
+ let selected;
67
+ try {
68
+ selected = selectAgents({ preferences: demand.preferences, targets: options.targets }).agents
69
+ .filter((agent) => agent !== 'generic');
70
+ }
71
+ catch {
72
+ return { observations: [], existing: [], owned: [] };
73
+ }
74
+ const commandPackages = new Map();
75
+ const platforms = await mapInstallReads(selected, async (platform) => {
76
+ const observations = [];
77
+ const existing = [];
78
+ const owned = [];
79
+ const ctx = { cwd: context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
80
+ discoveryCache: options.discoveryCache, nativeQuerySession: options.nativeQuerySession,
81
+ codexObservationSession: platform === 'codex' ? options.codexObservationSession : undefined,
82
+ observeNative: options.observeNative };
83
+ options.signal?.throwIfAborted();
84
+ const roots = (demand.roots ?? []).filter((root) => root.plugin
85
+ && resolveDelivery(root.plugin.manifest, platform, demand.scope)?.kind === 'native'
86
+ && (!demand.targetRequirements || demand.targetRequirements.some((item) => item.pluginId === root.pluginId && item.target === platform)));
87
+ if (!roots.length)
88
+ return { observations, existing, owned };
89
+ // Configuration is independent of the host's availability. Preserve these blockers if discovery fails.
90
+ const configuredRoots = await mapInstallReads(roots, async (root) => {
91
+ options.signal?.throwIfAborted();
92
+ const observation = { pluginId: root.pluginId, expectedVersion: root.plugin?.manifest.version, platform, content: 'unknown', blockers: [], reasons: [], deploymentObservations: [] };
93
+ observations.push(observation);
94
+ const plugin = root.plugin;
95
+ const active = demand.preferences.state === 'valid'
96
+ && resolveActiveConfigPlatforms(root.pluginId, plugin.manifest, demand.preferences).includes(platform);
97
+ const configSubject = { pluginId: root.pluginId, target: platform, scope: demand.scope };
98
+ const configForScope = async (scope, cwd) => {
99
+ try {
100
+ const config = await resolveArtifactRenderConfig({ pluginName: plugin.manifest.name, sourceId: plugin.sourceId ?? root.sourceId,
101
+ sourceIdentity: plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity,
102
+ manifest: plugin.manifest, platform, scope, cwd, env: context.env, referencePlugins: demand.plugins });
103
+ const blockers = configStatusDiagnostics(config.issues);
104
+ if (active)
105
+ observation.blockers.push(...blockers.map((blocker) => ({ ...blocker, subject: configSubject })));
106
+ return blockers.length ? undefined : config;
107
+ }
108
+ catch (error) {
109
+ options.signal?.throwIfAborted();
110
+ const blocker = configReadDiagnostic(error);
111
+ if (active)
112
+ observation.blockers.push({ ...blocker, subject: configSubject });
113
+ return undefined;
114
+ }
115
+ };
116
+ // Missing clients/bindings cannot hide a known configuration problem. Keep inspecting live ownership.
117
+ const scopedConfig = await configForScope(demand.scope, context.executionCwd);
118
+ return { root, observation, configForScope, scopedConfig };
119
+ }, { signal: options.signal, limit: 1 });
120
+ const adapter = getAgentPluginAdapter(platform);
121
+ let ownedSession;
122
+ try {
123
+ const discovery = await measureRecoveryPerformanceStage(options, 'status.discovery', () => adapter.discover(ctx));
124
+ if (platform === 'codex') {
125
+ const product = selectNativeProduct(discovery.installations);
126
+ if (product) {
127
+ const invocation = await installationInvocation(product, ctx, []);
128
+ const manager = { kind: product.product === 'app' ? 'app' : 'system', version: product.version ?? 'unknown',
129
+ command: invocation.command, argsPrefix: invocation.args };
130
+ if (ctx.codexObservationSession)
131
+ ctx.codexObservationSession.setManager(manager);
132
+ else {
133
+ ownedSession = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env, manager,
134
+ runner: options.nativeCliRunner, probe: { platform: ctx.platform, signal: options.signal } });
135
+ ctx.codexObservationSession = ownedSession;
136
+ }
137
+ }
138
+ }
139
+ for (const { root, observation, configForScope, scopedConfig } of configuredRoots) {
140
+ options.signal?.throwIfAborted();
141
+ let nativePackage;
142
+ try {
143
+ const plugin = root.plugin;
144
+ const resolution = await adapter.resolve(ctx, { plugin: {
145
+ sourceId: plugin.sourceId ?? root.sourceId, sourceIdentity: plugin.sourceIdentity,
146
+ pluginId: root.pluginId, version: plugin.manifest.version,
147
+ }, scope: demand.scope === 'project' ? { kind: 'project', projectRoot: context.projectRoot } : { kind: 'user' },
148
+ operation: 'ensure', discovery, recoveryCandidates: [] });
149
+ observation.deploymentExclusions = resolution.exclusions.flatMap((entry) => entry.productId ? [{
150
+ platform, pluginId: root.pluginId,
151
+ scope: demand.scope === 'project' ? { kind: 'project', projectRoot: context.projectRoot } : { kind: 'user' },
152
+ productId: entry.productId, product: discovery.installations.find((product) => product.id === entry.productId) ?? null,
153
+ reasonCode: entry.reasonCode, execution: 'not-run',
154
+ recoveryActions: ['aw target list', `aw plugin sync ${root.pluginId} --context ${demand.scope} --target ${platform}`],
155
+ }] : []);
156
+ observation.blockers.push(...resolution.diagnostics.map((entry) => ({ ...entry })));
157
+ if (!resolution.bindings.length) {
158
+ observation.blockers.push(...resolution.exclusions.map((entry) => diagnostic(entry.reasonCode)));
159
+ observation.blockers.push(...discovery.diagnostics.map((entry) => ({ code: entry.code, message: entry.message })));
160
+ if (!observation.blockers.some((blocker) => !isConfigDiagnostic(blocker)))
161
+ observation.blockers.push(diagnostic(discovery.availability === 'missing' ? 'client-missing' : 'nativeObservationUnavailable'));
162
+ continue;
163
+ }
164
+ const states = [];
165
+ const emptyMatches = [];
166
+ const currentMatches = [];
167
+ const versions = [];
168
+ const deliveredIds = new Set();
169
+ const staticResourceRoot = await resolveStaticPlatformResourceRoot(plugin.rootDir, platform);
170
+ let commandRoutes;
171
+ if (plugin.sourceIdentity && plugin.manifest.command?.platforms.includes(platform)) {
172
+ let commandPackage = commandPackages.get(root.pluginId);
173
+ if (!commandPackage) {
174
+ commandPackage = readManagedCommandPackage({ sourceId: root.sourceId,
175
+ sourceIdentity: plugin.sourceIdentity, pluginName: plugin.manifest.name }, context.env).catch(() => undefined);
176
+ commandPackages.set(root.pluginId, commandPackage);
177
+ }
178
+ commandRoutes = (await commandPackage)?.record.routes;
179
+ }
180
+ for (const binding of resolution.bindings) {
181
+ const subject = { pluginId: root.pluginId, target: platform, scope: binding.scope.kind };
182
+ const warn = (code) => observation.reasons.push({ ...diagnostic(code), subject });
183
+ const block = (code) => observation.blockers.push({ ...diagnostic(code), subject });
184
+ const live = await measureRecoveryPerformanceStage(options, 'status.adapter.inspect', () => adapter.inspect(ctx, binding));
185
+ versions.push(live.packageVersion);
186
+ options.signal?.throwIfAborted();
187
+ observation.deploymentObservations.push({ bindingId: binding.id, products: binding.consumers, after: live });
188
+ if (isPermissionHost(platform)) {
189
+ const { policy } = selectPlatformInvocationPolicy(resolveInvocationPolicy(plugin.manifest, platform, root.pluginId), subject, commandRoutes ?? null);
190
+ const claims = hostPermissionClaims(policy.permissions, policy.invocationSelector);
191
+ const previous = inventory.some(({ ownedComponent }) => ownedComponent?.kind === 'shared-config'
192
+ && ownedComponent.locator.kind === 'host-permissions' && ownedComponent.identity.pluginId === root.pluginId
193
+ && ownedComponent.identity.sourceIdentity === binding.plugin.sourceIdentity && ownedComponent.identity.platform === platform
194
+ && ownedComponent.identity.scope === binding.scope.kind);
195
+ if (claims.length || previous) {
196
+ const permissions = await inspectHostPermissionDelivery(ctx, binding, claims, live.grokScopeAuthorization);
197
+ if (permissions) {
198
+ states.push(permissions.content);
199
+ observation.reasons.push(permissions.diagnostic);
200
+ }
201
+ }
202
+ }
203
+ const shared = ['codex-marketplace', 'claude-marketplace', 'copilot-marketplace'].includes(binding.route);
204
+ const scopedNativeConsumer = shared ? live.registration === 'present'
205
+ && live.consumers.some((consumer) => consumer.activation === 'enabled')
206
+ : live.package === 'present' && live.ownership === 'aw';
207
+ if (scopedNativeConsumer && (live.ownership === 'aw' || live.ownership === 'shared')) {
208
+ owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
209
+ if (!shared)
210
+ nativePackage ??= { sourceIdentity: binding.plugin.sourceIdentity, skillsReady: false };
211
+ existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope,
212
+ ...(nativePackage ? { nativePackage } : {}) });
213
+ }
214
+ if (!scopedConfig) {
215
+ states.push('unknown');
216
+ continue;
217
+ }
218
+ const unmet = [];
219
+ const staticPackageIds = new Set();
220
+ const staticSupplements = [];
221
+ const dynamicUnits = new Set();
222
+ const inputUnits = [];
223
+ const profile = getQualifiedPlatformProfile(platform);
224
+ const renderUnits = resolution.renderUnits.filter((unit) => binding.renderUnitIds.includes(unit.id));
225
+ for (const unit of renderUnits) {
226
+ const artifacts = plugin.manifest.artifacts;
227
+ if (artifacts && unit.kinds.length && (!artifacts.scopes || artifacts.scopes.includes(unit.renderScope.kind))) {
228
+ dynamicUnits.add(unit.output);
229
+ }
230
+ const capabilities = adapter.capabilities({ binding, renderUnit: unit,
231
+ profile });
232
+ const config = unit.renderScope.kind === demand.scope ? scopedConfig
233
+ : await configForScope(unit.renderScope.kind, unit.renderScope.kind === 'project' ? unit.renderScope.projectRoot : context.executionCwd);
234
+ if (config)
235
+ inputUnits.push({ renderUnit: unit, capabilities, config });
236
+ }
237
+ // Do not feed invalid config to input-evidence creation or report a native read failure for it.
238
+ if (inputUnits.length !== renderUnits.length) {
239
+ states.push('unknown');
240
+ continue;
241
+ }
242
+ const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits, commandRoutes }).catch((error) => {
243
+ rethrowFatalError(error);
244
+ options.signal?.throwIfAborted();
245
+ const systemCode = error?.code;
246
+ if (systemCode !== 'ENOENT' && systemCode !== 'ENOTDIR')
247
+ throw error;
248
+ observation.blockers.push({ code: 'componentResourceMissing', message: 'A required plugin source file or directory is missing.',
249
+ subject, detail: { reasonCode: systemCode } });
250
+ return undefined;
251
+ });
252
+ if (!inputEvidence) {
253
+ states.push('unknown');
254
+ continue;
255
+ }
256
+ const readPackageProjection = async () => {
257
+ const layout = await getDeploymentLayout(ctx, binding);
258
+ const marker = await readSkillOwnerMarker({ skillRoot: layout.packageRoot, allowedRoot: path.dirname(layout.packageRoot),
259
+ expectedIdentity: deploymentPackageComponent(binding, layout).identity });
260
+ return { layout, projection: marker?.nativeProjection };
261
+ };
262
+ const packageUnit = renderUnits.find((unit) => unit.output === 'package');
263
+ const rolePackage = (platform === 'copilot' || platform === 'grok') && packageUnit?.kinds.includes('agent')
264
+ && dynamicUnits.has('package') && plugin.manifest.extensions?.instructions?.length
265
+ && live.package === 'present' && live.ownership === 'aw' ? await readPackageProjection() : undefined;
266
+ // The current package projection identifies renderer-produced roles. File presence and bytes are checked below.
267
+ const roleProjection = rolePackage?.projection;
268
+ const projectedRole = rolePackage && roleProjection?.preparation === 'complete'
269
+ && roleProjection.inputDigest === platformPackageInputDigest(inputEvidence)
270
+ && identityDigest(roleProjection.physicalIdentity) === identityDigest(rolePackage.layout.physicalIdentity)
271
+ && roleProjection.components.some(({ nativeName, relativeOutputs }) => relativeOutputs.includes(platform === 'copilot'
272
+ ? `com.github.copilot/agents/${nativeName}.agent.md` : `agents/${nativeName}.md`));
273
+ let expectedCount = 0;
274
+ let grokAgentRecipientScope;
275
+ for (const { renderUnit: unit, capabilities } of inputUnits) {
276
+ // Static Agent references are resolved by Core; dynamic references stay deferred to current delivery evidence.
277
+ const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
278
+ manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds,
279
+ hasInstructionAgentRecipients: platform === 'grok' && unit.output === 'supplement'
280
+ ? grokAgentRecipientScope === identityDigest(unit.renderScope) : projectedRole || undefined });
281
+ if (platform === 'grok' && unit.output === 'package'
282
+ && (projectedRole || expected.components.some(({ kind }) => kind === 'agent'))) {
283
+ grokAgentRecipientScope = identityDigest(unit.renderScope);
284
+ }
285
+ expectedCount += expected.components.length;
286
+ for (const component of expected.components) {
287
+ const grokRoleText = platform === 'grok' && component.kind === 'instruction' && !component.content.coverage.includes('main');
288
+ if (unit.output === 'supplement' && !grokRoleText)
289
+ staticSupplements.push(component);
290
+ else
291
+ staticPackageIds.add(component.id);
292
+ }
293
+ unmet.push(...expected.unmet);
294
+ }
295
+ const recordedDelivery = await readPlatformDeliveryState({ input: inputEvidence, env: context.env });
296
+ const recordedGaps = recordedDelivery?.result === 'capability-gaps' && recordedDelivery.gaps.length ? recordedDelivery : undefined;
297
+ for (const { field, ...detail } of recordedDelivery?.permissionNotices ?? []) {
298
+ observation.reasons.push({ code: INVOCATION_POLICY_NOT_APPLIED, subject: { ...subject, field }, detail,
299
+ message: deliveryNoticeMessage(INVOCATION_POLICY_NOT_APPLIED, detail, field) });
300
+ }
301
+ const currentIds = recordedGaps ? new Set(recordedGaps.installedComponentIds) : undefined;
302
+ if (currentIds && recordedGaps) {
303
+ // A renderer receipt can add dynamic expectations. A positive static
304
+ // expectation remains unless that specific component was skipped.
305
+ const skipped = new Set(recordedGaps.gaps.filter((gap) => !gap.componentId).map((gap) => gap.id));
306
+ for (const id of [...staticPackageIds, ...staticSupplements.map((component) => component.id)]) {
307
+ if (!skipped.has(id))
308
+ currentIds.add(id);
309
+ }
310
+ }
311
+ let packageExpectedCount = staticPackageIds.size;
312
+ const expectedSupplements = currentIds ? staticSupplements.filter(({ id }) => currentIds.has(id)) : staticSupplements;
313
+ const supplements = await inspectStaticSupplements(ctx, binding, expectedSupplements);
314
+ const gaps = recordedGaps?.gaps ?? unmet;
315
+ const blockingGaps = gaps.filter((gap) => !isDeliveryCapabilityGap(gap));
316
+ if (gaps.length) {
317
+ (observation.componentGaps ??= []).push(...scopeNativeComponentGaps(gaps, { pluginId: root.pluginId, agent: platform, scope: binding.scope.kind }, renderUnits));
318
+ }
319
+ const supplementInput = inputEvidence.units.find((unit) => unit.output === 'supplement');
320
+ const emptyPackageIds = recordedDelivery?.result === 'intentional-empty-package' ? recordedDelivery.installedComponentIds : undefined;
321
+ const recordedSupplements = dynamicUnits.has('supplement') && supplementInput
322
+ ? await inspectPlatformSupplementState(ctx, binding, supplementInput.inputDigest, emptyPackageIds) : null;
323
+ if (recordedSupplements) {
324
+ const staticIds = new Set(supplements.components.map((component) => component.id));
325
+ const dynamicComponents = recordedSupplements.components.filter((component) => !staticIds.has(component.id));
326
+ supplements.components.push(...dynamicComponents);
327
+ expectedCount += dynamicComponents.length;
328
+ }
329
+ const supplementIds = new Set(supplements.components.map(({ id }) => id));
330
+ if (currentIds) {
331
+ expectedCount = currentIds.size;
332
+ packageExpectedCount = [...currentIds].filter((id) => !supplementIds.has(id)).length;
333
+ }
334
+ const supplementSetUnconfirmed = emptyPackageIds
335
+ && (emptyPackageIds.length !== supplementIds.size || emptyPackageIds.some((id) => !supplementIds.has(id)));
336
+ const supplementConflict = supplements.components.some((component) => component.reasonCodes.includes('supplementOwnershipConflict'));
337
+ const supplementMissing = supplements.components.some((component) => component.presence === 'absent');
338
+ const supplementDrift = supplements.components.some((component) => component.reasonCodes.includes('componentContentDrift'));
339
+ const supplementUnknown = supplements.components.some((component) => component.presence === 'unknown');
340
+ const supplementInputDrift = Boolean(recordedSupplements && !recordedSupplements.inputMatches
341
+ && recordedSupplements.components.every((component) => component.presence === 'present'));
342
+ if (supplementConflict)
343
+ block('supplementOwnershipConflict');
344
+ if (supplementDrift)
345
+ warn('platformContentDrift');
346
+ if (supplementInputDrift)
347
+ warn('platformInputDrift');
348
+ if (supplementMissing)
349
+ warn('componentOutputMissing');
350
+ if (supplementUnknown && !supplementConflict)
351
+ warn('componentOutputUnconfirmed');
352
+ if (supplements.owned && !existing.some((target) => target.pluginId === root.pluginId && target.agent === platform && target.scope === demand.scope)) {
353
+ owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
354
+ existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
355
+ }
356
+ const onlyCapabilityGaps = expectedCount === 0 && gaps.length > 0 && !blockingGaps.length;
357
+ const capabilityEmpty = onlyCapabilityGaps && recordedGaps !== undefined;
358
+ const confirmedEmpty = capabilityEmpty || Boolean(plugin.manifest.artifacts && expectedCount === 0 && gaps.length === 0
359
+ && recordedDelivery?.result === 'intentional-empty');
360
+ const confirmedEmptyPackage = packageExpectedCount === 0 && (Boolean(currentIds?.size)
361
+ || dynamicUnits.has('package') && (recordedDelivery?.result === 'intentional-empty-package'
362
+ || binding.route === 'codex-marketplace' && recordedSupplements !== null
363
+ && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty',
364
+ units: inputEvidence.units.filter((unit) => unit.output === 'package') }, env: context.env })));
365
+ const dynamicSupplementsUnconfirmed = dynamicUnits.has('supplement') && !confirmedEmpty
366
+ && !recordedSupplements?.inputMatches && !supplementInputDrift;
367
+ if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed)
368
+ warn('dynamicExpectationUnconfirmed');
369
+ const hasPackageExpectation = packageExpectedCount > 0 || !currentIds && dynamicUnits.has('package') && !confirmedEmpty && !confirmedEmptyPackage;
370
+ const inheritsUserNative = demand.targetRequirements?.find((item) => item.pluginId === root.pluginId
371
+ && item.target === platform)?.inheritsUserNative;
372
+ const requiredActivation = requiredDeploymentActivation(binding, live, !inheritsUserNative);
373
+ for (const entry of live.diagnostics) {
374
+ if (entry.code === 'codexProjectActivationUnconfirmed' && inheritsUserNative && requiredActivation === 'enabled')
375
+ continue;
376
+ const needsOwnership = live.ownership === 'unknown' && live.package !== 'absent' && live.registration !== 'absent';
377
+ const destination = entry.severity === 'error' || (hasPackageExpectation || confirmedEmpty || confirmedEmptyPackage) && isNativeReadError(entry, needsOwnership)
378
+ ? observation.blockers : observation.reasons;
379
+ destination.push({ code: entry.code, message: entry.message, subject: { ...subject, ...entry.subject }, detail: entry.detail });
380
+ }
381
+ const legacyAntigravityPackage = live.antigravityLegacyProjectPackage;
382
+ if (legacyAntigravityPackage?.state === 'owned')
383
+ observation.reasons.push({
384
+ code: 'antigravityProjectPackageMigrationPending',
385
+ message: 'Sync this plugin to finish moving it to the short Antigravity project path.',
386
+ subject,
387
+ detail: { reasonCode: 'antigravityProjectPackageMigrationPending', path: legacyAntigravityPackage.path },
388
+ });
389
+ const requiresScopeRegistration = binding.route === 'claude-marketplace' && !inheritsUserNative;
390
+ const registration = requiresScopeRegistration ? live.scopeRegistration ?? 'unknown' : live.registration;
391
+ const ownershipConflict = live.ownership === 'foreign' || live.ownership === 'shared'
392
+ || legacyAntigravityPackage?.state === 'unconfirmed';
393
+ if (ownershipConflict)
394
+ block('deploymentOwnershipConflict');
395
+ const missing = hasPackageExpectation && (live.package === 'absent' && packageExpectedCount > 0
396
+ || registration === 'absent' && (packageExpectedCount > 0 || live.package === 'present')
397
+ || live.nativePackage === 'absent');
398
+ if (missing) {
399
+ if (live.package === 'absent')
400
+ warn('platformPackageMissing');
401
+ if (registration === 'absent')
402
+ warn('nativeRegistrationMissing');
403
+ if (live.nativePackage === 'absent')
404
+ warn('nativePackageMissing');
405
+ }
406
+ let inputDrift = false;
407
+ let packageExpectationConfirmed = false;
408
+ let projectionUnconfirmed = false;
409
+ let componentMissing = false;
410
+ let componentUnknown = false;
411
+ let nativeContentDrift = false;
412
+ let nativeContentUnconfirmed = false;
413
+ if (hasPackageExpectation && live.package === 'present' && live.ownership === 'aw' && !missing) {
414
+ const { layout, projection } = rolePackage ?? await readPackageProjection();
415
+ const contentDigest = projection ? await readPlatformPackageContentDigest(layout.packageRoot) : undefined;
416
+ if (['grok-cli', 'antigravity-cli'].includes(binding.route) && live.registration === 'present') {
417
+ nativeContentUnconfirmed = !contentDigest || !live.nativePackageContentDigest;
418
+ nativeContentDrift = Boolean(contentDigest && live.nativePackageContentDigest
419
+ && contentDigest !== live.nativePackageContentDigest);
420
+ if (nativeContentUnconfirmed)
421
+ warn('nativePackageContentUnconfirmed');
422
+ if (nativeContentDrift)
423
+ warn('nativePackageContentDrift');
424
+ }
425
+ projectionUnconfirmed = !projection || projection.preparation !== 'complete' || !contentDigest;
426
+ const packageInputDigest = platformPackageInputDigest(inputEvidence, projection?.components);
427
+ inputDrift = Boolean(projection && (projection.inputDigest !== packageInputDigest
428
+ || contentDigest && projection.contentDigest !== contentDigest));
429
+ if (projectionUnconfirmed)
430
+ warn(projection?.preparation === 'partial'
431
+ ? 'platformPreparationPartial' : 'platformExpectationUnconfirmed');
432
+ else if (inputDrift) {
433
+ if (projection.inputDigest !== packageInputDigest)
434
+ warn('platformInputDrift');
435
+ if (projection.contentDigest !== contentDigest)
436
+ warn('platformContentDrift');
437
+ }
438
+ componentMissing = live.components.some((component) => component.presence === 'absent');
439
+ componentUnknown = live.components.some((component) => component.presence === 'unknown'
440
+ && !component.reasonCodes.includes('nativePackageContentDrift'));
441
+ if (componentMissing)
442
+ warn('componentOutputMissing');
443
+ if (componentUnknown && !nativeContentUnconfirmed)
444
+ warn('componentOutputUnconfirmed');
445
+ packageExpectationConfirmed = Boolean(!projectionUnconfirmed && projection.inputDigest === packageInputDigest
446
+ && projection.components.length > 0);
447
+ if (packageExpectationConfirmed) {
448
+ expectedCount = Math.max(expectedCount, projection.components.length);
449
+ if (platform === 'pi' && !inputDrift) {
450
+ const roles = projection.components.filter((component) => component.relativeOutputs.some((output) => /^agents\/[^/]+\.md$/u.test(output))
451
+ && live.components.some((entry) => entry.id === component.id && entry.presence === 'present' && !entry.reasonCodes.length));
452
+ const warning = piAgentConsumerDiagnostic(binding, live, roles.map(({ id }) => id));
453
+ if (warning)
454
+ observation.reasons.push(warning);
455
+ }
456
+ }
457
+ }
458
+ const confirmedPackage = packageExpectationConfirmed && !inputDrift && !nativeContentDrift && !nativeContentUnconfirmed;
459
+ const confirmedComponents = [...(confirmedPackage ? live.components : []), ...supplements.components];
460
+ for (const component of confirmedComponents) {
461
+ if (component.presence === 'present' && !component.reasonCodes.length && (!currentIds || currentIds.has(component.id))) {
462
+ deliveredIds.add(component.id);
463
+ }
464
+ }
465
+ live.components.push(...supplements.components);
466
+ currentMatches.push(Boolean(currentIds) || !dynamicUnits.size || confirmedEmpty || packageExpectationConfirmed || missing
467
+ || !dynamicSupplementsUnconfirmed && confirmedEmptyPackage || recordedSupplements !== null && !hasPackageExpectation);
468
+ emptyMatches.push(confirmedEmpty && !capabilityEmpty);
469
+ for (const entry of blockingGaps)
470
+ block(entry.reasonCode);
471
+ if (legacyAntigravityPackage?.state === 'owned' && !ownershipConflict
472
+ && live.ownership !== 'unknown' && !blockingGaps.length) {
473
+ states.push('drifted');
474
+ continue;
475
+ }
476
+ const inactiveScope = live.registration === 'absent'
477
+ || live.package === 'absent' && live.registration === 'not-applicable'
478
+ || live.scopeRegistration === 'absent'
479
+ || binding.scope.kind === 'project' && shared && live.configuration?.activation === 'absent'
480
+ || live.consumers.every((consumer) => ['disabled', 'not-applicable'].includes(consumer.activation));
481
+ const skippedFiles = gaps.filter((gap) => supplementInput?.kinds.includes(gap.kind) && gap.name
482
+ && !currentIds?.has(gap.componentId ?? gap.id)
483
+ && !expectedSupplements.some((component) => component.kind === gap.kind && component.name === gap.name));
484
+ if (skippedFiles.length) {
485
+ const slots = gapSupplementFiles(binding, await getDeploymentLayout(ctx, binding), skippedFiles);
486
+ const checked = await inspectOwnedComponents({ components: slots });
487
+ const retained = checked.components.filter((item) => item.state !== 'absent');
488
+ if (retained.length) {
489
+ for (const item of retained)
490
+ if ('path' in item.component) {
491
+ observation.blockers.push(retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, item.component.path));
492
+ }
493
+ states.push(retained.some((item) => item.state === 'foreign') ? 'conflict'
494
+ : retained.some((item) => item.state === 'error') ? 'unknown' : 'drifted');
495
+ continue;
496
+ }
497
+ }
498
+ if (onlyCapabilityGaps) {
499
+ const supplementKey = supplementInput?.physicalKey;
500
+ const retained = supplementKey ? inventory.flatMap(({ ownedComponent }) => ownedComponent?.kind === 'owned-text-file' && ownedComponent.identity.physicalKey === supplementKey
501
+ && ownedComponent.identity.sourceIdentity === binding.plugin.sourceIdentity && ownedComponent.identity.pluginId === root.pluginId
502
+ ? [ownedComponent.path] : []) : [];
503
+ const piRegistrationRemaining = binding.route === 'pi-package'
504
+ && (live.registration === 'present' || live.configuration?.activation === 'enabled');
505
+ if ((live.package === 'present' && (!shared || !inactiveScope) || piRegistrationRemaining) && live.nativeIdentity) {
506
+ retained.push(live.nativeIdentity.sourceLocation);
507
+ }
508
+ if (binding.route === 'cursor-workspace-hook' && live.workspaceOpen === 'present') {
509
+ retained.push((await getDeploymentLayout(ctx, binding)).activationPath);
510
+ }
511
+ if (retained.length) {
512
+ observation.blockers.push(...retained.map((file) => retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, file)));
513
+ states.push(ownershipConflict ? 'conflict' : 'drifted');
514
+ continue;
515
+ }
516
+ }
517
+ if (confirmedEmpty) {
518
+ const hiddenEmptyPi = capabilityEmpty && piProjectEmptyDeliveryObserved(binding, live);
519
+ const cursorHookUnconfirmed = capabilityEmpty && binding.route === 'cursor-workspace-hook' && live.workspaceOpen !== 'absent';
520
+ const piConfigUnconfirmed = capabilityEmpty && binding.route === 'pi-package' && live.configuration?.activation !== 'absent';
521
+ states.push(ownershipConflict ? 'conflict' : live.package === 'unknown' || live.registration === 'unknown' && !hiddenEmptyPi
522
+ || live.ownership === 'unknown' || observation.blockers.length || cursorHookUnconfirmed || piConfigUnconfirmed || !inactiveScope && !hiddenEmptyPi ? 'unknown'
523
+ : live.package === 'absent' || shared ? 'satisfied' : 'drifted');
524
+ continue;
525
+ }
526
+ if (hasPackageExpectation && !missing) {
527
+ if (registration === 'unknown')
528
+ warn('nativeRegistrationUnconfirmed');
529
+ if (requiredActivation === 'unknown')
530
+ warn('nativeActivationUnconfirmed');
531
+ if (requiredActivation === 'disabled')
532
+ warn('nativeActivationDisabled');
533
+ if (requiredActivation === 'blocked')
534
+ block(binding.route === 'grok-directory'
535
+ ? 'grokProjectAuthorizationDenied' : 'nativeActivationBlocked');
536
+ if (binding.route === 'cursor-workspace-hook') {
537
+ if (live.workspaceOpen === 'absent')
538
+ warn('cursorWorkspaceOpenMissing');
539
+ if (live.workspaceOpen === 'unknown')
540
+ warn('cursorWorkspaceOpenUnconfirmed');
541
+ }
542
+ }
543
+ if (ownershipConflict || supplementConflict)
544
+ states.push('conflict');
545
+ else if (confirmedEmptyPackage && (live.package === 'unknown' || live.registration === 'unknown' || live.ownership === 'unknown'))
546
+ states.push('unknown');
547
+ else if (confirmedEmptyPackage && (!inactiveScope || !shared && live.package === 'present')) {
548
+ warn('platformContentDrift');
549
+ states.push('drifted');
550
+ }
551
+ else if (onlyCapabilityGaps) {
552
+ warn('platformExpectationUnconfirmed');
553
+ states.push('unknown');
554
+ }
555
+ else if (blockingGaps.length || hasPackageExpectation && registration === 'unknown')
556
+ states.push('unknown');
557
+ else if (missing)
558
+ states.push('absent');
559
+ else if (supplementUnknown || hasPackageExpectation && (live.package === 'unknown' || live.ownership === 'unknown'
560
+ || requiredActivation === 'unknown' || live.workspaceOpen === 'unknown'
561
+ || componentUnknown || nativeContentUnconfirmed || projectionUnconfirmed))
562
+ states.push('unknown');
563
+ else if (componentMissing || supplementMissing && !dynamicSupplementsUnconfirmed)
564
+ states.push('absent');
565
+ else if (hasPackageExpectation && ['disabled', 'blocked'].includes(requiredActivation)
566
+ || live.workspaceOpen === 'absent' && live.package === 'present' || inputDrift || supplementDrift || supplementInputDrift || nativeContentDrift)
567
+ states.push('drifted');
568
+ else if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed || hasPackageExpectation && !packageExpectationConfirmed)
569
+ states.push('unknown');
570
+ else if (!expectedCount)
571
+ states.push(live.package === 'absent' && ['absent', 'not-applicable'].includes(live.registration) ? 'satisfied' : 'drifted');
572
+ else
573
+ states.push('satisfied');
574
+ }
575
+ observation.intentionalEmpty = emptyMatches.length === resolution.bindings.length && emptyMatches.every(Boolean);
576
+ observation.expectationConfirmed = currentMatches.length === resolution.bindings.length && currentMatches.every(Boolean);
577
+ if (versions.length && versions[0] && versions.every((version) => version === versions[0]))
578
+ observation.installedVersion = versions[0];
579
+ observation.content = ['conflict', 'drifted', 'absent', 'unknown']
580
+ .find((state) => states.includes(state)) ?? 'satisfied';
581
+ if (observation.content === 'satisfied' || observation.content === 'absent' || deliveredIds.size) {
582
+ observation.installedComponentIds = [...deliveredIds];
583
+ }
584
+ if (nativePackage)
585
+ nativePackage.skillsReady = hasReadyProviderSkills({ ...observation, installedComponentCount: deliveredIds.size });
586
+ }
587
+ catch (error) {
588
+ rethrowFatalError(error);
589
+ options.signal?.throwIfAborted();
590
+ observation.content = 'unknown';
591
+ observation.blockers.push(diagnostic('nativeObservationFailed'));
592
+ }
593
+ }
594
+ }
595
+ catch (error) {
596
+ rethrowFatalError(error);
597
+ options.signal?.throwIfAborted();
598
+ for (const { observation } of configuredRoots) {
599
+ observation.content = 'unknown';
600
+ observation.blockers.push(diagnostic('nativeObservationFailed'));
601
+ }
602
+ }
603
+ finally {
604
+ await ownedSession?.dispose();
605
+ }
606
+ return { observations, existing, owned };
607
+ }, { signal: options.signal });
608
+ return { observations: platforms.flatMap((result) => result.observations),
609
+ existing: platforms.flatMap((result) => result.existing), owned: platforms.flatMap((result) => result.owned) };
610
+ }
611
+ function safeNativePlacement(target) {
612
+ const component = ({ kind, key, state, metadata }) => ({
613
+ kind, key, state,
614
+ ...(metadata ? { metadata: Object.fromEntries(Object.entries(metadata).filter(([name]) => ['enabled', 'scopes', 'relation', 'errorCode', 'shared', 'version', 'desiredVersion',
615
+ 'staleCacheObserved', 'effective', 'requiredMinVersion', 'detectedVersion', 'code',
616
+ 'kinds', 'platform', 'scope', 'project', 'rootIssueId', 'rootIssueCode'].includes(name)
617
+ || (kind === 'systemConsumer' && name === 'diagnostics'))) } : {}),
618
+ });
619
+ const reason = ({ code, severity, dependencyPluginId, dependencyPlatform, dependencyScope, dependencyProject, rootIssueId, rootIssueCode }) => ({
620
+ code, severity, dependencyPluginId, dependencyPlatform, dependencyScope, dependencyProject,
621
+ rootIssueId, rootIssueCode,
622
+ });
623
+ return {
624
+ pluginId: target.pluginId, platform: target.platform, scope: target.scope,
625
+ state: target.state,
626
+ components: target.components.map(component), reasons: target.reasons.map(reason),
627
+ recoveryActions: target.recoveryActions.map(({ command, scope }) => ({ command, scope })),
628
+ ...(target.sharedComponents ? { sharedComponents: target.sharedComponents.map(component) } : {}),
629
+ ...(target.sharedReasons ? { sharedReasons: target.sharedReasons.map(reason) } : {}),
630
+ };
631
+ }
632
+ export async function statusFromObservations(options) {
633
+ options.signal?.throwIfAborted();
634
+ const { demand } = options;
635
+ const errors = [...demand.errors, ...(options.nativeReadErrors ?? [])];
636
+ let selection;
637
+ try {
638
+ selection = selectAgents({ preferences: demand.preferences, targets: options.targets });
639
+ }
640
+ catch {
641
+ selection = { agents: [], origin: 'none', preferences: demand.preferences.state };
642
+ errors.push(diagnostic('targetSelectionInvalid'));
643
+ }
644
+ const inventory = demand.roots === null ? null : [];
645
+ for (const root of demand.roots ?? []) {
646
+ options.signal?.throwIfAborted();
647
+ const blockers = root.blockers.map(diagnostic);
648
+ if (root.plugin) {
649
+ try {
650
+ const closure = root.plugin.manifest.dependencies?.length
651
+ ? resolvePluginMetaDependencyClosure(demand.plugins.filter((plugin) => plugin.sourceId === root.sourceId), [root.plugin.manifest.name])
652
+ : [root.plugin];
653
+ for (const plugin of closure) {
654
+ const support = checkAwCapabilitySupport(plugin.manifest.requires?.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
655
+ if (!support.supported)
656
+ blockers.push({ ...diagnostic('awCapabilityUnsupported'), pluginId: plugin.pluginId });
657
+ }
658
+ }
659
+ catch {
660
+ blockers.push(diagnostic('dependencyContractInvalid'));
661
+ }
662
+ }
663
+ if (!selection.agents.length)
664
+ blockers.push(diagnostic('localTargetsRequired'));
665
+ const targetResults = [];
666
+ for (const agent of selection.agents) {
667
+ if (demand.targetRequirements && !demand.targetRequirements.some((item) => item.pluginId === root.pluginId && item.target === agent))
668
+ continue;
669
+ options.signal?.throwIfAborted();
670
+ const delivery = root.plugin ? resolveDelivery(root.plugin.manifest, agent, options.scope) ?? null : null;
671
+ const target = { pluginId: root.pluginId, agent, scope: options.scope, delivery,
672
+ execution: 'not-run', observation: 'unknown', content: 'unknown', blockers: [...blockers],
673
+ requiredBy: [root.pluginId], relation: 'root',
674
+ ...(root.plugin?.manifest.version ? { expectedVersion: root.plugin.manifest.version } : {}) };
675
+ if (blockers.length) {
676
+ targetResults.push(target);
677
+ continue;
678
+ }
679
+ if (!delivery)
680
+ target.blockers.push(diagnostic('deliveryUnsupported'));
681
+ else if (delivery.kind === 'native') {
682
+ const native = options.nativeObservations.find((entry) => entry.pluginId === root.pluginId
683
+ && entry.platform === delivery.platform);
684
+ if (native) {
685
+ target.content = native.content;
686
+ if (native.componentGaps?.length)
687
+ target.componentGaps = native.componentGaps;
688
+ if (native.installedComponentIds) {
689
+ target.installedComponentIds = native.installedComponentIds;
690
+ target.installedComponentCount = native.installedComponentIds.length;
691
+ }
692
+ if (native.installedVersion)
693
+ target.installedVersion = native.installedVersion;
694
+ if (native.deploymentObservations)
695
+ target.deploymentObservations = native.deploymentObservations;
696
+ if (native.deploymentExclusions)
697
+ target.deploymentExclusions = native.deploymentExclusions;
698
+ target.blockers.push(...native.blockers);
699
+ if (native.reasons?.length)
700
+ target.reasons = [...native.reasons];
701
+ errors.push(...native.blockers.filter((entry) => isNativeReadError(entry))
702
+ .map((entry) => ({ ...entry, pluginId: root.pluginId })));
703
+ target.backend = { ...(native.assumedActivation ? { assumedActivation: true } : {}),
704
+ ...(native.backend ? { live: safeNativePlacement(native.backend) } : {}) };
705
+ }
706
+ else {
707
+ target.blockers.push(diagnostic('nativeObservationUnavailable'));
708
+ errors.push({ ...diagnostic('nativeObservationUnavailable'), pluginId: root.pluginId });
709
+ }
710
+ }
711
+ else {
712
+ try {
713
+ const portable = await inspectPortableRecovery({ scope: options.scope, context: options.context,
714
+ selector: root.pluginId, agents: [agent], env: options.env, signal: options.signal,
715
+ cliVersion: options.cliVersion ?? '0.0.0', catalogOperationContext: demand.catalogOperationContext,
716
+ excludedPluginIds: demand.userProviders?.[agent] }, options.catalogReadScope);
717
+ options.signal?.throwIfAborted();
718
+ const activeConfig = root.plugin && demand.preferences.state === 'valid'
719
+ && resolveActiveConfigPlatforms(root.pluginId, root.plugin.manifest, demand.preferences).includes(agent);
720
+ target.blockers.push(...portable.blockers.filter((code) => code !== 'previousDeploymentRetained'
721
+ && (activeConfig || !isConfigDiagnostic({ code }))).map((code) => portablePreparationDiagnostic(portable, diagnostic(code), agent)));
722
+ if (portable.policyNotices?.length)
723
+ target.reasons = [...target.reasons ?? [], ...portable.policyNotices];
724
+ const gaps = (portable.unmet ?? []).filter((gap) => gap.agent === agent);
725
+ const blockingGap = gaps.some((gap) => !isDeliveryCapabilityGap(gap));
726
+ if (gaps.length)
727
+ target.componentGaps = gaps;
728
+ if (blockingGap && !target.blockers.some((entry) => entry.code === 'portableComponentsUnmet'))
729
+ target.blockers.push(diagnostic('portableComponentsUnmet'));
730
+ const observed = portable.targets.filter((entry) => entry.agent === agent);
731
+ if (!portable.globalBlockers?.length) {
732
+ const installed = observed.filter((entry) => entry.providerPluginId === root.pluginId
733
+ && entry.disposition === 'write' && entry.observation === 'satisfied' && !entry.blocker);
734
+ if (installed.length || observed.every((entry) => entry.disposition === 'retain'
735
+ || entry.observation === 'satisfied' || entry.observation === 'absent')) {
736
+ target.installedComponentCount = installed.length;
737
+ if (installed.every((entry) => entry.componentId))
738
+ target.installedComponentIds = installed.map((entry) => entry.componentId);
739
+ }
740
+ }
741
+ target.blockers.push(...observed.flatMap((entry) => entry.disposition === 'retain'
742
+ ? [retainedOutputDiagnostic(entry.providerPluginId, agent, options.scope, entry.physicalPath, `skill.${entry.skill}`)]
743
+ : entry.blocker ? [diagnostic(entry.blocker)] : []));
744
+ target.content = ['conflict', 'drifted', 'absent', 'unknown']
745
+ .find((state) => observed.some((entry) => entry.observation === state))
746
+ ?? (!portable.blockers.length && (observed.length || portable.intentionalEmpty || gaps.length && !blockingGap) ? 'satisfied' : 'unknown');
747
+ if (observed.length === 0 && portable.blockers.includes('needs-preparation') && options.portableCoverage === true
748
+ && options.portableInstalled && !options.portableInstalled.some((item) => item.pluginId === root.pluginId && item.agent === agent)) {
749
+ target.content = 'absent';
750
+ target.blockers = target.blockers.filter((item) => item.code !== 'needs-preparation');
751
+ }
752
+ if ((blockingGap || observed.some((entry) => entry.disposition === 'retain')) && target.content !== 'conflict')
753
+ target.content = 'unknown';
754
+ target.backend = observed.map((entry) => ({ skill: entry.skill, agent: entry.agent,
755
+ ownership: entry.ownership, observation: entry.observation, associatedAgents: entry.associatedAgents }));
756
+ if (target.blockers.some((entry) => !isConfigDiagnostic(entry) && isTargetObservationReadError(entry))) {
757
+ errors.push({ ...diagnostic('portableObservationFailed'), pluginId: root.pluginId });
758
+ }
759
+ }
760
+ catch (error) {
761
+ rethrowFatalError(error);
762
+ options.signal?.throwIfAborted();
763
+ target.blockers.push(diagnostic('portableObservationFailed'));
764
+ errors.push({ ...diagnostic('portableObservationFailed'), pluginId: root.pluginId });
765
+ }
766
+ }
767
+ const dynamicExpectationConfirmed = delivery?.kind === 'native' && options.nativeObservations.some((entry) => entry.pluginId === root.pluginId && entry.platform === delivery.platform && (entry.intentionalEmpty === true || entry.expectationConfirmed === true));
768
+ if (delivery?.kind === 'native' && root.plugin?.manifest.artifacts && !dynamicExpectationConfirmed) {
769
+ if (target.content === 'satisfied' || target.content === 'absent')
770
+ target.content = 'unknown';
771
+ if (target.content === 'unknown' && !target.reasons?.some((entry) => entry.code === 'dynamicExpectationUnconfirmed')) {
772
+ target.reasons = [...target.reasons ?? [], diagnostic('dynamicExpectationUnconfirmed')];
773
+ }
774
+ }
775
+ if (target.content === 'satisfied' && !target.blockers.length && target.installedComponentCount === 0
776
+ && target.componentGaps?.some((gap) => gap.providerPluginId === target.pluginId) && target.componentGaps.every(isDeliveryCapabilityGap)) {
777
+ target.satisfaction = 'not-applicable';
778
+ }
779
+ target.observation = target.content === 'satisfied' ? 'verified'
780
+ : target.content === 'absent' ? 'missing' : 'unknown';
781
+ targetResults.push(target);
782
+ }
783
+ inventory.push({ pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
784
+ blockers, targetResults });
785
+ }
786
+ const counts = { blocked: 0, unconfirmed: 0, pending: 0, ready: 0 };
787
+ let definiteFailure = false;
788
+ let uncertain = inventory === null;
789
+ for (const root of inventory ?? []) {
790
+ const targets = root.targetResults;
791
+ if (root.blockers.length || targets.some((target) => target.blockers.length || target.content === 'conflict'
792
+ || target.delivery === null)) {
793
+ counts.blocked++;
794
+ }
795
+ else if (!targets.length || targets.some((target) => target.content === 'unknown')) {
796
+ counts.unconfirmed++;
797
+ uncertain = true;
798
+ }
799
+ else if (targets.some((target) => target.content === 'absent' || target.content === 'drifted'))
800
+ counts.pending++;
801
+ else
802
+ counts.ready++;
803
+ if (!targets.length || root.blockers.some((entry) => !/^(?:pluginUnavailable|sourceMissing|sourceIdentityMismatch)$/u.test(entry.code))) {
804
+ uncertain = true;
805
+ }
806
+ if (root.blockers.some((entry) => /^(?:pluginUnavailable|sourceMissing|sourceIdentityMismatch)$/u.test(entry.code))) {
807
+ definiteFailure = true;
808
+ }
809
+ for (const target of targets) {
810
+ if (target.content === 'absent' || target.content === 'drifted' || target.content === 'conflict'
811
+ || target.blockers.some((entry) => entry.code === 'deliveryUnsupported')) {
812
+ definiteFailure = true;
813
+ }
814
+ else if (target.blockers.some((entry) => entry.code === 'awCapabilityUnsupported'))
815
+ definiteFailure = true;
816
+ else if (target.content === 'unknown' || target.observation === 'unknown' || target.blockers.length)
817
+ uncertain = true;
818
+ }
819
+ }
820
+ const allSatisfied = definiteFailure ? false : uncertain ? null : true;
821
+ options.signal?.throwIfAborted();
822
+ return { schemaVersion: 1, kind: 'aw-recovery-status', scope: options.scope, ok: errors.length === 0,
823
+ intent: { state: demand.intent.state, ...('digest' in demand.intent ? { digest: demand.intent.digest } : {}) },
824
+ selection, inventory, extraObserved: options.extraObserved ?? [],
825
+ coverage: { native: (options.nativeReadErrors?.length ?? 0) === 0, portable: options.portableCoverage ?? true },
826
+ counts, allSatisfied, inSync: aggregateConvergence(allSatisfied, (options.extraObserved?.length ?? 0) > 0 ? 'present' : options.portableCoverage === false ? 'unknown' : 'absent'), errors };
827
+ }
828
+ export async function readScopedRecoveryStatus(options) {
829
+ options.signal?.throwIfAborted();
830
+ const context = await createScopeContext({ scope: options.scope, cwd: options.cwd, env: options.env, readOnly: true });
831
+ try {
832
+ options.signal?.throwIfAborted();
833
+ const demand = options.demandOverride ?? await readDemand({ scope: options.scope, cwd: context.executionCwd, env: context.env,
834
+ catalogOperationContext: options.catalogOperationContext, signal: options.signal, catalogReadScope: options.catalogReadScope });
835
+ options.signal?.throwIfAborted();
836
+ options.onDemand?.(demand);
837
+ options.signal?.throwIfAborted();
838
+ const ownerInventory = options.nativeObservations ? { references: [], errors: [] }
839
+ : await measureRecoveryPerformanceStage(options, 'status.inventory', () => inventoryCatalogSourceReferences({ cwd: context.executionCwd, env: context.env, scope: options.scope,
840
+ knownPluginNames: demand.plugins.map((plugin) => plugin.manifest.name), collectPathEvidence: false,
841
+ observationPlugins: options.observationPlugins }));
842
+ options.signal?.throwIfAborted();
843
+ const candidates = ownerInventory.references.filter((entry) => entry.scope === options.scope
844
+ && entry.sourceId && entry.pluginName && isPlatformTarget(entry.platform) && entry.platform !== 'generic'
845
+ && (!options.observationPlugins || options.observationPlugins.has(`${entry.sourceId}/${entry.pluginName}`)
846
+ || options.observationPlugins.has(entry.pluginName))
847
+ && (!options.targets || options.targets.includes(entry.platform)));
848
+ const portableExtra = options.targets && !options.targets.includes('generic') ? { targets: [], complete: true }
849
+ : await inspectPortableExtraInstalled({
850
+ scope: options.scope, context, env: context.env, signal: options.signal, plugins: options.observationPlugins,
851
+ });
852
+ options.signal?.throwIfAborted();
853
+ const sourceCandidates = [...candidates, ...portableExtra.targets.flatMap((target) => {
854
+ if (demand.preferences.state !== 'valid' || !demand.preferences.value.targets.includes(target.agent))
855
+ return [];
856
+ if (options.observationPlugins && !options.observationPlugins.has(target.pluginId)
857
+ && !options.observationPlugins.has(parsePluginId(target.pluginId).pluginName))
858
+ return [];
859
+ const { sourceId, pluginName } = parsePluginId(target.pluginId);
860
+ return [{ sourceId, pluginName }];
861
+ })];
862
+ const observedPlugins = new Map(demand.plugins.map((plugin) => [plugin.pluginId, plugin]));
863
+ const catalog = demand.catalogOperationContext ?? options.catalogOperationContext;
864
+ const catalogSources = options.catalogSources ?? new Map();
865
+ for (const source of catalog?.catalog.sources ?? [])
866
+ if (!catalogSources.has(source.sourceId))
867
+ catalogSources.set(source.sourceId, source);
868
+ if (sourceCandidates.some((entry) => !observedPlugins.has(`${entry.sourceId}/${entry.pluginName}`))) {
869
+ try {
870
+ const missing = [...new Set(sourceCandidates.map((entry) => entry.sourceId))].filter((id) => !catalogSources.has(id));
871
+ if (missing.length) {
872
+ const config = await readCatalogSourcesConfigSnapshot(context.env);
873
+ const configured = new Set(config.config.sources.map((source) => source.id));
874
+ const sourceIds = missing.filter((id) => configured.has(id));
875
+ if (sourceIds.length) {
876
+ const additional = await resolvePartialCatalogOperationContext({ env: context.env, signal: options.signal,
877
+ configSnapshot: config, sourceIds }, options.catalogReadScope);
878
+ for (const source of additional.catalog.sources)
879
+ catalogSources.set(source.sourceId, source);
880
+ }
881
+ }
882
+ }
883
+ catch (error) {
884
+ rethrowFatalError(error);
885
+ options.signal?.throwIfAborted();
886
+ }
887
+ for (const candidate of sourceCandidates) {
888
+ const pluginId = `${candidate.sourceId}/${candidate.pluginName}`;
889
+ if (observedPlugins.has(pluginId))
890
+ continue;
891
+ const source = catalogSources.get(candidate.sourceId)?.resolution;
892
+ if (!source?.manifest.entries.some((entry) => entry.name === candidate.pluginName))
893
+ continue;
894
+ // Configuration references need the retained plugin's dependency closure as well as its own manifest.
895
+ let dependencyEntries;
896
+ try {
897
+ dependencyEntries = resolvePluginDependencyClosure(source.manifest.entries, [candidate.pluginName]);
898
+ }
899
+ catch {
900
+ dependencyEntries = [{ name: candidate.pluginName }];
901
+ }
902
+ for (const { name } of dependencyEntries) {
903
+ const id = `${source.sourceId}/${name}`;
904
+ if (observedPlugins.has(id))
905
+ continue;
906
+ try {
907
+ const plugin = await readPluginManifest(path.join(source.rootDir, 'plugins', name), { mode: 'bundle' });
908
+ Object.assign(plugin, { pluginId: id, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
909
+ catalogLogicalIdentity: source.logicalIdentity });
910
+ observedPlugins.set(id, plugin);
911
+ }
912
+ catch (error) {
913
+ rethrowFatalError(error);
914
+ options.signal?.throwIfAborted();
915
+ }
916
+ }
917
+ }
918
+ }
919
+ let selectedAgents = [];
920
+ try {
921
+ selectedAgents = selectAgents({ preferences: demand.preferences, targets: options.targets }).agents;
922
+ }
923
+ catch { /* The status result reports invalid strong state without extending observations. */ }
924
+ // Keep old owners in the residual/cleanup inventory. Only bind a current
925
+ // manifest for native observation when the recorded identity is compatible.
926
+ // Older Native owners may omit the source identity; keep their existing observation path.
927
+ const currentCandidates = candidates.filter((candidate) => {
928
+ const plugin = observedPlugins.get(`${candidate.sourceId}/${candidate.pluginName}`);
929
+ return plugin && (!candidate.sourceIdentity || candidate.sourceIdentity === plugin.sourceIdentity);
930
+ });
931
+ const observationDemand = { ...demand, plugins: [...observedPlugins.values()],
932
+ roots: [...new Map([...(demand.roots ?? []), ...currentCandidates.flatMap((candidate) => {
933
+ const pluginId = `${candidate.sourceId}/${candidate.pluginName}`;
934
+ const plugin = observedPlugins.get(pluginId);
935
+ return plugin ? [{ pluginId, sourceId: candidate.sourceId, plugin, sourceState: 'ready', blockers: [] }] : [];
936
+ })].map((root) => [root.pluginId, root])).values()],
937
+ targetRequirements: demand.targetRequirements ? [...demand.targetRequirements,
938
+ ...currentCandidates.map((entry) => ({ pluginId: `${entry.sourceId}/${entry.pluginName}`, target: entry.platform }))] : undefined };
939
+ const adapters = options.nativeObservations ? { observations: [], existing: [], owned: [] }
940
+ : await withStatusNativeQueries({ ...options, targets: [...new Set([...selectedAgents, ...candidates.map((entry) => entry.platform)])] }, (nativeOptions) => readAdapterObservations(nativeOptions, context, observationDemand, candidates));
941
+ const roots = new Set(demand.roots?.map((root) => root.pluginId) ?? []);
942
+ const queue = [...(demand.roots ?? []).map((root) => root.plugin).filter((plugin) => plugin !== undefined)];
943
+ const byId = new Map(demand.plugins.map((plugin) => [plugin.pluginId, plugin]));
944
+ while (queue.length) {
945
+ const plugin = queue.shift();
946
+ for (const name of plugin.manifest.dependencies ?? []) {
947
+ const id = `${plugin.sourceId}/${name}`;
948
+ if (roots.has(id))
949
+ continue;
950
+ roots.add(id);
951
+ const dependency = byId.get(id);
952
+ if (dependency)
953
+ queue.push(dependency);
954
+ }
955
+ }
956
+ const expected = (pluginId, agent) => demand.targetRequirements
957
+ ? demand.targetRequirements.some((item) => item.pluginId === pluginId && item.target === agent)
958
+ : roots.has(pluginId) && agent !== null && demand.preferences.state === 'valid' && demand.preferences.value.targets.includes(agent);
959
+ const nativeExtraObserved = adapters.owned
960
+ .filter((entry) => !expected(entry.pluginId, entry.agent))
961
+ .map((entry) => ({ ...entry,
962
+ expectedVersion: adapters.observations.find((item) => item.pluginId === entry.pluginId && item.platform === entry.agent)?.expectedVersion,
963
+ installedVersion: adapters.observations.find((item) => item.pluginId === entry.pluginId && item.platform === entry.agent)?.installedVersion,
964
+ delivery: { kind: 'native', platform: entry.agent },
965
+ observation: 'unknown', content: 'unknown', blockers: adapters.observations.find((observation) => observation.pluginId === entry.pluginId && observation.platform === entry.agent)?.blockers.filter(isConfigDiagnostic),
966
+ deploymentObservations: adapters.observations.find((observation) => observation.pluginId === entry.pluginId && observation.platform === entry.agent)?.deploymentObservations }));
967
+ const inventoryOwned = candidates.flatMap((entry) => {
968
+ // A verified Antigravity copy remains a native retirement candidate when
969
+ // its AW source is gone. Execution still verifies the live registration;
970
+ // the copy is not an owned filesystem output or AW source authority.
971
+ const nativeCopy = entry.platform === 'antigravity' && entry.scope === 'user'
972
+ && entry.kind === 'namespacedMarketplace' && entry.recoveryCandidate?.evidence === 'verified'
973
+ && entry.recoveryCandidate.binding.route === 'antigravity-cli';
974
+ const shared = ['codex', 'claude', 'copilot'].includes(entry.platform);
975
+ const pluginId = `${entry.sourceId}/${entry.pluginName}`;
976
+ const source = catalogSources.get(entry.sourceId)?.resolution;
977
+ // With no usable Catalog entry, native observation cannot resolve a normal
978
+ // deployment. Keep scoped marketplace residue visible using local evidence,
979
+ // without inventing ownership/activation or treating inherited current
980
+ // packages as separate project installations.
981
+ const sharedResidue = shared && !observedPlugins.has(pluginId)
982
+ && (!source || !source.manifest.entries.some((item) => item.name === entry.pluginName))
983
+ && (entry.kind === 'namespacedMarketplace' || entry.ownedComponent !== undefined);
984
+ return nativeCopy || sharedResidue || entry.ownedComponent && !shared
985
+ ? [{ pluginId, agent: entry.platform, scope: options.scope }] : [];
986
+ });
987
+ for (const entry of inventoryOwned) {
988
+ if (!expected(entry.pluginId, entry.agent) && !nativeExtraObserved.some((target) => target.pluginId === entry.pluginId && target.agent === entry.agent)) {
989
+ const current = currentCandidates.some((candidate) => `${candidate.sourceId}/${candidate.pluginName}` === entry.pluginId
990
+ && candidate.platform === entry.agent);
991
+ nativeExtraObserved.push({ ...entry, delivery: { kind: 'native', platform: entry.agent }, observation: 'unknown', content: 'unknown',
992
+ ...(current ? { blockers: adapters.observations.find((observation) => observation.pluginId === entry.pluginId && observation.platform === entry.agent)?.blockers.filter(isConfigDiagnostic) } : {}) });
993
+ }
994
+ }
995
+ const retainedProjectPackages = [];
996
+ for (const entry of candidates) {
997
+ const component = entry.ownedComponent;
998
+ const recovery = entry.recoveryCandidate;
999
+ if (component?.kind !== 'owned-directory' || recovery?.evidence !== 'verified' || component.identity.scope !== options.scope
1000
+ || component.identity.sourceId !== entry.sourceId || component.identity.sourceIdentity !== entry.sourceIdentity
1001
+ || component.identity.platform !== entry.platform || component.identity.pluginId !== `${entry.sourceId}/${entry.pluginName}`
1002
+ || component.identity.physicalKey !== recovery.binding.physicalKey)
1003
+ continue;
1004
+ const pluginId = component.identity.pluginId;
1005
+ const agent = entry.platform;
1006
+ const sourceIdentity = recovery.binding.plugin.sourceIdentity;
1007
+ if (!hasSharedUserPackage(agent)) {
1008
+ const location = recovery.binding.scope;
1009
+ if (location.kind !== 'project' || location.projectRoot !== context.projectRoot
1010
+ || adapters.existing.some((target) => target.pluginId === pluginId && target.agent === agent
1011
+ && target.nativePackage?.sourceIdentity === sourceIdentity))
1012
+ continue;
1013
+ const source = catalogSources.get(entry.sourceId)?.resolution;
1014
+ let dependencies = null;
1015
+ if (source?.sourceIdentity === sourceIdentity && source.manifest.entries.some((plugin) => plugin.name === entry.pluginName)) {
1016
+ try {
1017
+ dependencies = resolvePluginDependencyClosure(source.manifest.entries, [entry.pluginName])
1018
+ .filter((plugin) => plugin.name !== entry.pluginName).map((plugin) => `${entry.sourceId}/${plugin.name}`);
1019
+ }
1020
+ catch { /* An unavailable closure retains only same-source candidates. */ }
1021
+ }
1022
+ retainedProjectPackages.push({ pluginId, agent, scope: 'project', dependencies,
1023
+ nativePackage: { sourceIdentity, skillsReady: false } });
1024
+ continue;
1025
+ }
1026
+ if (observedPlugins.get(pluginId)?.sourceIdentity === component.identity.sourceIdentity)
1027
+ continue;
1028
+ nativeExtraObserved.push({ pluginId, agent, scope: component.identity.scope,
1029
+ delivery: { kind: 'native', platform: agent }, observation: 'unknown', content: 'unknown',
1030
+ backend: { retainedPackage: true, ownedComponents: [{ ...component, state: 'present' }] } });
1031
+ }
1032
+ const portableConfigBlockers = new Map();
1033
+ const portableObserved = [];
1034
+ for (const entry of portableExtra.targets.filter((item) => !expected(item.pluginId, item.agent))) {
1035
+ const plugin = observedPlugins.get(entry.pluginId);
1036
+ const key = `${entry.pluginId}\0${entry.agent}`;
1037
+ const current = plugin?.catalogLogicalIdentity !== undefined && plugin.catalogLogicalIdentity === entry.logicalIdentity;
1038
+ if (current && !portableConfigBlockers.has(key) && demand.preferences.state === 'valid'
1039
+ && (!options.observationPlugins || options.observationPlugins.has(entry.pluginId)
1040
+ || options.observationPlugins.has(parsePluginId(entry.pluginId).pluginName))
1041
+ && resolveActiveConfigPlatforms(entry.pluginId, plugin.manifest, demand.preferences).includes(entry.agent)) {
1042
+ let blockers;
1043
+ try {
1044
+ const config = await resolveArtifactRenderConfig({ pluginName: plugin.manifest.name, sourceId: plugin.sourceId,
1045
+ sourceIdentity: plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity, manifest: plugin.manifest,
1046
+ platform: entry.agent, scope: options.scope, cwd: context.executionCwd, env: context.env, referencePlugins: [...observedPlugins.values()] });
1047
+ blockers = configStatusDiagnostics(config.issues);
1048
+ }
1049
+ catch (error) {
1050
+ options.signal?.throwIfAborted();
1051
+ blockers = [configReadDiagnostic(error)];
1052
+ }
1053
+ portableConfigBlockers.set(key, blockers.map((blocker) => ({ ...blocker, subject: { pluginId: entry.pluginId, target: entry.agent, scope: options.scope } })));
1054
+ }
1055
+ const blockers = current ? portableConfigBlockers.get(key) : undefined;
1056
+ portableObserved.push({ pluginId: entry.pluginId, agent: entry.agent, scope: options.scope,
1057
+ delivery: { kind: 'agent-skills', provider: 'aw', agentId: 'generic' },
1058
+ observation: entry.observation, content: entry.content, ...(blockers?.length ? { blockers } : {}),
1059
+ backend: { skill: entry.skill, logicalIdentity: entry.logicalIdentity } });
1060
+ }
1061
+ const extraObserved = [...nativeExtraObserved, ...portableObserved];
1062
+ const relevantErrors = ownerInventory.errors.filter((error) => {
1063
+ const relevance = error.relevance;
1064
+ if (relevance.global)
1065
+ return true;
1066
+ if (options.targets && relevance.platform && !options.targets.includes(relevance.platform))
1067
+ return false;
1068
+ if (!options.observationPlugins)
1069
+ return true;
1070
+ if (!relevance.pluginName && !relevance.sourceId)
1071
+ return true;
1072
+ return [...options.observationPlugins].some((id) => {
1073
+ const parsed = parsePluginId(id);
1074
+ const plugin = observedPlugins.get(id);
1075
+ return (!relevance.sourceId || !parsed.sourceId || relevance.sourceId === parsed.sourceId)
1076
+ && (!relevance.pluginName || relevance.pluginName === parsed.pluginName
1077
+ || relevance.componentName && plugin?.manifest.extensions?.agents?.some((agent) => agent.name === relevance.componentName));
1078
+ });
1079
+ });
1080
+ const result = await statusFromObservations({ ...options, context, demand,
1081
+ nativeObservations: options.nativeObservations ?? adapters.observations, extraObserved,
1082
+ portableCoverage: portableExtra.complete, portableInstalled: portableExtra.targets,
1083
+ nativeReadErrors: [
1084
+ ...relevantErrors.map(inventoryRecoveryDiagnostic),
1085
+ ...adapters.observations.flatMap((entry) => entry.blockers.filter((error) => isNativeReadError(error))),
1086
+ ] });
1087
+ result.coverage.requestComplete = result.coverage.native && result.coverage.portable;
1088
+ result.coverage.native &&= ownerInventory.errors.length === 0;
1089
+ // The project scan includes User Intent. Demand accounts for its effect on
1090
+ // shared providers, while this loop attributes failures to local outputs.
1091
+ const userIntentPath = options.scope === 'project' && relevantErrors.some((error) => error.kind === 'lifecycleIntentRead')
1092
+ ? await resolveIntentPath({ ...options, scope: 'user' }) : undefined;
1093
+ const targetErrors = relevantErrors.filter((error) => !(userIntentPath && error.kind === 'lifecycleIntentRead'
1094
+ && error.recoveryPath === userIntentPath));
1095
+ for (const target of result.inventory?.flatMap((entry) => entry.targetResults) ?? []) {
1096
+ for (const error of targetErrors) {
1097
+ const relevance = error.relevance;
1098
+ const identity = parsePluginId(target.pluginId);
1099
+ if (!relevance.global && (relevance.platform && relevance.platform !== target.agent
1100
+ || relevance.sourceId && relevance.sourceId !== identity.sourceId
1101
+ || relevance.scope && relevance.scope !== target.scope
1102
+ && !(relevance.scope === 'user' && target.scope === 'project' && ['codex', 'claude', 'copilot'].includes(target.agent))
1103
+ || relevance.projectLocationKey && relevance.projectLocationKey !== context.projectKey
1104
+ || relevance.pluginName && relevance.pluginName !== identity.pluginName
1105
+ && !(relevance.componentName && observedPlugins.get(target.pluginId)?.manifest.extensions?.agents?.some((agent) => agent.name === relevance.componentName))))
1106
+ continue;
1107
+ target.blockers.push(inventoryRecoveryDiagnostic(error));
1108
+ if (target.content === 'satisfied') {
1109
+ target.content = 'unknown';
1110
+ target.observation = 'unknown';
1111
+ }
1112
+ }
1113
+ }
1114
+ // Installed-current evidence must not bind a retained old Catalog's Skill to
1115
+ // the new source. Unresolved sources remain observable, and ownedTargets
1116
+ // below still keeps every exact residual for cleanup.
1117
+ const portableCurrent = (target) => {
1118
+ const identity = observedPlugins.get(target.pluginId)?.catalogLogicalIdentity
1119
+ ?? catalogSources.get(parsePluginId(target.pluginId).sourceId)?.resolution?.logicalIdentity;
1120
+ return identity === undefined || target.logicalIdentity === identity;
1121
+ };
1122
+ result.existingTargets = [
1123
+ ...adapters.existing,
1124
+ ...portableExtra.targets.filter(portableCurrent).map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
1125
+ ];
1126
+ result.retainedProjectPackages = retainedProjectPackages;
1127
+ result.ownedTargets = [
1128
+ ...adapters.owned, ...inventoryOwned,
1129
+ ...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
1130
+ ];
1131
+ await options.onNativeStatus?.(result, demand);
1132
+ options.signal?.throwIfAborted();
1133
+ return result;
1134
+ }
1135
+ finally {
1136
+ await context.dispose();
1137
+ }
1138
+ }
1139
+ export async function checkRecovery(selectors, options) {
1140
+ const status = await readRecoveryStatus(options);
1141
+ const blockers = [];
1142
+ const roots = [...new Set(status.inventory?.map((root) => root.pluginId) ?? [])];
1143
+ const requested = [];
1144
+ if (options.all && selectors.length)
1145
+ blockers.push(diagnostic('syncSelectorConflict'));
1146
+ else if (!selectors.length)
1147
+ requested.push(...roots);
1148
+ else
1149
+ for (const selector of selectors) {
1150
+ const parsed = parsePluginId(selector);
1151
+ const matches = roots.filter((id) => parsed.sourceId ? id === selector : parsePluginId(id).pluginName === parsed.pluginName);
1152
+ if (matches.length !== 1)
1153
+ blockers.push(diagnostic('syncPluginNotDesired'));
1154
+ else if (!requested.includes(matches[0]))
1155
+ requested.push(matches[0]);
1156
+ }
1157
+ const selectedRoots = status.inventory?.filter((root) => requested.includes(root.pluginId)) ?? [];
1158
+ blockers.push(...selectedRoots.flatMap((root) => root.blockers));
1159
+ if (requested.length && status.selection.agents.length === 0)
1160
+ blockers.push(diagnostic('targetsNotConfigured'));
1161
+ const targetResults = selectedRoots.flatMap((root) => root.targetResults)
1162
+ .filter((target) => !options.targets || options.targets.includes(target.agent));
1163
+ const remainingTargets = targetResults.filter((target) => target.blockers.length || target.observation !== 'verified')
1164
+ .map(({ pluginId, agent, scope, delivery }) => ({ pluginId, agent, scope, delivery }));
1165
+ if (status.intent.state !== 'valid' && status.intent.state !== 'absent')
1166
+ blockers.push(diagnostic('pluginIntentStateInvalid'));
1167
+ const errors = status.errors;
1168
+ const ok = blockers.length === 0 && remainingTargets.length === 0 && errors.length === 0
1169
+ && !(requested.length === 0 && status.allSatisfied === null);
1170
+ return { schemaVersion: 1, kind: 'aw-recovery', scope: status.scope, command: 'sync:check', ok,
1171
+ intent: { ...status.intent, roots: status.inventory === null ? null : roots },
1172
+ requestedRoots: requested, requestedTargets: targetResults.map(({ pluginId, agent, scope, delivery }) => ({ pluginId, agent, scope, delivery })), selection: status.selection, blockers, errors,
1173
+ targetResults, remainingTargets, recoveryActions: ok ? [] : ['aw plugin status --json'],
1174
+ allSatisfied: status.allSatisfied, inSync: status.inSync,
1175
+ coverage: { scopes: status.coverage.scopes ?? [status.scope], ...(status.coverage.projectRoot ? { projectRoot: status.coverage.projectRoot } : {}) },
1176
+ declarationChanged: false, preferencesChanged: false, configChanged: false, outputsMayHaveChanged: false };
1177
+ }
1178
+ function observedSatisfaction(content, provider, inheritsUser) {
1179
+ if (!content || content === 'unknown')
1180
+ return 'unknown';
1181
+ if (content !== 'satisfied')
1182
+ return 'pending';
1183
+ if (provider?.satisfaction === 'not-applicable')
1184
+ return 'not-applicable';
1185
+ return inheritsUser ? 'inherited-user' : 'installed';
1186
+ }
1187
+ export function aggregateConvergence(allSatisfied, residue) {
1188
+ return allSatisfied === false || residue === 'present' ? false
1189
+ : allSatisfied === null || residue === 'unknown' ? null : true;
1190
+ }
1191
+ export async function readRecoveryStatus(options, preparedDemand) {
1192
+ return withStatusNativeQueries(options, (nativeOptions) => readRecoveryStatusWithQueries(nativeOptions, preparedDemand));
1193
+ }
1194
+ async function readRecoveryStatusWithQueries(options, preparedDemand) {
1195
+ options = { ...options, discoveryCache: options.discoveryCache ?? new Map(), catalogSources: new Map() };
1196
+ const snapshot = preparedDemand ?? await measureRecoveryPerformanceStage(options, 'status.demand', () => readJointDemand(options));
1197
+ if (options.codexObservationSession || options.nativeObservations || options.targets && !options.targets.includes('codex')) {
1198
+ return readRecoveryStatusInSession(options, snapshot);
1199
+ }
1200
+ const context = await createScopeContext({ scope: snapshot.context.context,
1201
+ cwd: snapshot.context.projectRoot ?? options.cwd, env: options.env, readOnly: true });
1202
+ let session;
1203
+ try {
1204
+ options.signal?.throwIfAborted();
1205
+ session = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env,
1206
+ runner: options.nativeCliRunner, probe: { signal: options.signal } });
1207
+ // User reads use only this session's neutral cwd. Project reads add the
1208
+ // exact project snapshot without repeating the same neutral observation.
1209
+ return await readRecoveryStatusInSession({ ...options, codexObservationSession: session }, snapshot);
1210
+ }
1211
+ finally {
1212
+ try {
1213
+ await session?.dispose();
1214
+ }
1215
+ finally {
1216
+ await context.dispose();
1217
+ }
1218
+ }
1219
+ }
1220
+ /** An empty demand or inventory does not establish that the selected Catalog is readable. */
1221
+ async function checkUndeclaredSelection(options, snapshot) {
1222
+ const demands = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
1223
+ const known = new Set(demands.flatMap((demand) => demand.plugins.map((plugin) => plugin.pluginId)));
1224
+ const selectors = (options.plugins ?? []).filter((selector) => ![...known].some((id) => id === selector || !selector.includes('/') && parsePluginId(id).pluginName === selector));
1225
+ if (!selectors.length)
1226
+ return [];
1227
+ const sources = options.catalogSources ?? new Map();
1228
+ for (const source of [options.catalogOperationContext, ...demands.map((demand) => demand.catalogOperationContext)]
1229
+ .flatMap((context) => context?.catalog.sources ?? []))
1230
+ if (!sources.has(source.sourceId))
1231
+ sources.set(source.sourceId, source);
1232
+ const errors = [];
1233
+ try {
1234
+ const config = await readCatalogSourcesConfigSnapshot(options.env);
1235
+ const configured = new Set(config.config.sources.map((source) => source.id));
1236
+ const wanted = new Set(selectors.flatMap((selector) => parsePluginId(selector).sourceId
1237
+ ? [parsePluginId(selector).sourceId] : [...configured]));
1238
+ const missing = [...wanted].filter((id) => configured.has(id) && !sources.has(id));
1239
+ if (missing.length) {
1240
+ const context = await resolvePartialCatalogOperationContext({ sourceIds: missing, configSnapshot: config,
1241
+ env: options.env, signal: options.signal }, options.catalogReadScope);
1242
+ for (const source of context.catalog.sources)
1243
+ sources.set(source.sourceId, source);
1244
+ }
1245
+ for (const selector of selectors) {
1246
+ const { sourceId, pluginName } = parsePluginId(selector);
1247
+ const candidates = sourceId ? [sourceId] : [...configured];
1248
+ const code = sourceId && !configured.has(sourceId) ? 'sourceMissing'
1249
+ : candidates.some((id) => !sources.get(id)?.resolution) ? 'sourceActiveUnavailable'
1250
+ : !candidates.some((id) => sources.get(id)?.resolution?.manifest.entries.some((entry) => entry.name === pluginName))
1251
+ ? 'pluginUnavailable' : undefined;
1252
+ if (code)
1253
+ errors.push({ code, message: 'The selected plugin or its Catalog source could not be confirmed.',
1254
+ ...(sourceId ? { pluginId: selector, subject: { pluginId: selector, sourceId } } : {}) });
1255
+ }
1256
+ }
1257
+ catch (error) {
1258
+ rethrowFatalError(error);
1259
+ options.signal?.throwIfAborted();
1260
+ errors.push({ code: 'catalogReadFailed', message: 'The selected Catalog source could not be read.' });
1261
+ }
1262
+ return errors;
1263
+ }
1264
+ /** Decide whether a project location can consume the exact User Skills observed this round. */
1265
+ function projectSkillCopy(user, project, userAbsent) {
1266
+ const deployments = project.deploymentObservations;
1267
+ if (!deployments?.length || project.blockers.length)
1268
+ return 'blocked';
1269
+ const userDeployments = user.deploymentObservations ?? [];
1270
+ for (const { after, products } of deployments) {
1271
+ if (!products.every((product) => userDeployments.some((deployment) => deployment.products.some((item) => item.id === product.id))))
1272
+ return 'blocked';
1273
+ if (!userAbsent && project.agent === 'pi' && !userDeployments.some((deployment) => deployment.after.nativeIdentity
1274
+ && piProjectListsUserSkills(after, deployment.after.nativeIdentity.sourceLocation)))
1275
+ return 'blocked';
1276
+ if (after.configuration?.activation === 'disabled' || after.configuration?.activation === 'unknown'
1277
+ || after.antigravityLegacyProjectPackage?.state === 'unconfirmed' || after.grokScopeAuthorization === 'denied')
1278
+ return 'blocked';
1279
+ if (after.package === 'present' && after.ownership === 'aw') {
1280
+ // A previous input generation can retire if its own published bytes are still intact.
1281
+ const staleInput = project.content === 'drifted' && project.reasons?.some((reason) => reason.code === 'platformInputDrift' || reason.code === 'antigravityProjectPackageMigrationPending')
1282
+ && project.reasons.every((reason) => ['platformInputDrift', 'antigravityProjectPackageMigrationPending',
1283
+ 'opencodeNativeObservationRequired', INVOCATION_POLICY_NOT_APPLIED].includes(reason.code));
1284
+ if (project.content === 'satisfied' || staleInput)
1285
+ continue;
1286
+ }
1287
+ if (after.package !== 'absent' || after.ownership !== 'absent')
1288
+ return 'blocked';
1289
+ if (project.agent === 'pi') {
1290
+ const hiddenSection = after.registration === 'unknown' && after.diagnostics.some((entry) => entry.code === 'piProjectRegistrationNotVisible');
1291
+ if ((!hiddenSection && after.registration !== 'absent') || after.configuration?.activation !== 'absent')
1292
+ return 'blocked';
1293
+ }
1294
+ if (!userAbsent && project.agent === 'grok') {
1295
+ const name = after.nativeIdentity?.packageId;
1296
+ const native = after.prerequisites.nativeSources;
1297
+ const sources = native?.sources.filter((source) => source.name === name);
1298
+ const personal = user.deploymentObservations?.flatMap(({ after }) => after.prerequisites.nativeSources?.sources ?? [])
1299
+ .find((source) => source.name === name && source.scope === 'user' && source.enabled && source.origin === 'native');
1300
+ if (after.grokScopeAuthorization !== 'granted' || native?.observation !== 'complete' || !personal || sources?.length !== 1
1301
+ || sources[0].scope !== 'user' || !sources[0].enabled || sources[0].path !== personal.path
1302
+ || !user.installedComponentIds?.every((id) => sources[0].effectiveComponents.includes(id.replace(/^skill:/u, 'skills:'))))
1303
+ return 'blocked';
1304
+ }
1305
+ }
1306
+ return deployments.some(({ after }) => after.package === 'present' || after.antigravityLegacyProjectPackage?.state === 'owned') ? 'owned' : 'absent';
1307
+ }
1308
+ async function readRecoveryStatusInSession(options, snapshot) {
1309
+ const selectionErrors = await checkUndeclaredSelection(options, snapshot);
1310
+ const requestedDemand = options.targets ? { ...snapshot, preferences: snapshot.preferences
1311
+ ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null } : snapshot;
1312
+ let globalPlan = deriveJointDemand(snapshot);
1313
+ let plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand);
1314
+ const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
1315
+ const selected = Boolean(options.plugins?.length || options.targets);
1316
+ const observationPlugins = options.plugins?.length ? new Set(plan.placements.filter((item) => matchesPlugin(item.pluginId)
1317
+ || item.contributions.some((contribution) => matchesPlugin(contribution.root))).map((item) => item.pluginId)) : undefined;
1318
+ if (observationPlugins) {
1319
+ const plugins = [...new Map([snapshot.user, ...(snapshot.project ? [snapshot.project] : [])]
1320
+ .flatMap((demand) => demand.plugins).map((plugin) => [plugin.pluginId, plugin])).values()];
1321
+ for (const id of observationPlugins) {
1322
+ const plugin = plugins.find((entry) => entry.pluginId === id);
1323
+ if (!plugin)
1324
+ continue;
1325
+ for (const dependency of plugin.manifest.dependencies ?? [])
1326
+ observationPlugins.add(`${plugin.sourceId}/${dependency}`);
1327
+ const slots = new Set(plugin.manifest.extensions?.agents?.map((agent) => agent.name) ?? []);
1328
+ for (const candidate of plugins)
1329
+ if (candidate.manifest.extensions?.agents?.some((agent) => slots.has(agent.name))) {
1330
+ observationPlugins.add(candidate.pluginId);
1331
+ }
1332
+ }
1333
+ }
1334
+ if (observationPlugins)
1335
+ for (const plugin of options.plugins ?? [])
1336
+ observationPlugins.add(plugin);
1337
+ const selectedPlacement = (item) => (!options.targets || options.targets.includes(item.target)) && (!observationPlugins || observationPlugins.has(item.pluginId));
1338
+ const candidates = [...new Map([...projectSkillCandidates(plan), ...(options.projectSkillProbes ?? [])]
1339
+ .filter(selectedPlacement).map((item) => [`${item.pluginId}\0${item.target}`, item])).values()];
1340
+ const scopes = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
1341
+ const observed = [];
1342
+ // Scope order gives User discovery the neutral cwd before equivalent Project
1343
+ // probes reuse it. Codex also shares a mutable manager and neutral inventory.
1344
+ for (const demand of scopes) {
1345
+ const nodes = [...plan.placements, ...(options.projectSkillProbes ?? [])].filter((item) => selectedPlacement(item) && (item.scope === demand.scope
1346
+ || demand.scope === 'project' && ['codex', 'claude', 'copilot'].includes(item.target)
1347
+ && item.contributions.some((contribution) => contribution.scope === 'project')));
1348
+ const expanded = { ...demand,
1349
+ plugins: [...new Map([...demand.plugins, ...nodes.map((item) => item.plugin)]
1350
+ .map((plugin) => [plugin.pluginId, plugin])).values()],
1351
+ catalogOperationContext: demand.catalogOperationContext ?? snapshot.user.catalogOperationContext
1352
+ ?? snapshot.project?.catalogOperationContext,
1353
+ userProviders: demand.scope === 'project' ? Object.fromEntries((snapshot.preferences?.targets ?? []).map((target) => [target,
1354
+ plan.placements.filter((item) => item.scope === 'user' && item.target === target
1355
+ && !nodes.some((project) => project.scope === 'project' && project.pluginId === item.pluginId && project.target === item.target)).map((item) => item.pluginId)])) : {},
1356
+ targetRequirements: nodes.map((item) => ({ pluginId: item.pluginId, target: item.target,
1357
+ ...(item.scope === 'user' && demand.scope === 'project' ? { inheritsUserNative: true } : {}) })),
1358
+ roots: demand.roots === null ? null : [...new Map(nodes.map((item) => [item.pluginId, {
1359
+ pluginId: item.pluginId, sourceId: item.plugin.sourceId, sourceState: 'ready',
1360
+ blockers: [], plugin: item.plugin,
1361
+ }])).values()] };
1362
+ observed.push(await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope,
1363
+ cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded }));
1364
+ }
1365
+ const scopedTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []);
1366
+ const skillProviders = candidates.flatMap((candidate) => {
1367
+ const matches = (target) => target.pluginId === candidate.pluginId && target.agent === candidate.target;
1368
+ const user = scopedTargets.find((target) => matches(target) && target.scope === 'user');
1369
+ const project = scopedTargets.find((target) => matches(target) && target.scope === 'project');
1370
+ if (!user || !project)
1371
+ return [];
1372
+ const absent = user.deploymentObservations?.length && user.deploymentObservations.every(({ after }) => after.package === 'absent' && after.ownership === 'absent' && (after.registration === 'absent' || after.registration === 'not-applicable'));
1373
+ return [{ pluginId: candidate.pluginId, target: candidate.target, sourceIdentity: candidate.plugin.sourceIdentity,
1374
+ projectCopy: projectSkillCopy(user, project, !!absent), userAbsent: !!absent, userNeedsRepair: !absent && !isInstalledSkillProvider(user) }];
1375
+ });
1376
+ if (skillProviders.length) {
1377
+ globalPlan = deriveJointDemand(snapshot, skillProviders);
1378
+ plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand, skillProviders);
1379
+ }
1380
+ const allTargets = scopedTargets.flatMap((target) => {
1381
+ const providers = plan.placements.filter((placement) => placement.pluginId === target.pluginId && placement.target === target.agent
1382
+ && (placement.scope === target.scope || target.scope === 'project'
1383
+ && ['codex', 'claude', 'copilot'].includes(target.agent) && placement.scope === 'user'
1384
+ && placement.contributions.some((entry) => entry.scope === 'project')));
1385
+ if (!providers.length)
1386
+ return [];
1387
+ const contributions = providers.flatMap((provider) => provider.contributions
1388
+ .filter((entry) => provider.scope === target.scope || entry.scope === target.scope));
1389
+ return { ...target, contributions: contributions.map((entry) => ({ root: entry.root, scope: entry.scope, path: [...entry.path] })),
1390
+ requiredBy: [...new Set(contributions.map((entry) => entry.root))], providerScope: providers[0]?.scope,
1391
+ relation: contributions.some((entry) => entry.path.length === 1 && entry.scope === target.scope) ? 'root' : 'dependency' };
1392
+ });
1393
+ const inventory = scopes.some((demand) => demand.roots !== null) ? [] : null;
1394
+ const expected = new Set(plan.placements.map((item) => `${item.pluginId}\0${item.target}\0${item.scope}`));
1395
+ const surplusSkills = scopedTargets.filter((target) => target.scope === 'project'
1396
+ && !expected.has(`${target.pluginId}\0${target.agent}\0project`)
1397
+ && skillProviders.some((provider) => provider.projectCopy === 'owned' && !provider.userAbsent && !provider.userNeedsRepair
1398
+ && provider.pluginId === target.pluginId && provider.target === target.agent))
1399
+ .map((target) => ({ ...target, reasons: [{ code: 'projectSkillDuplicatePending', pluginId: target.pluginId,
1400
+ subject: { pluginId: target.pluginId, target: target.agent, scope: target.scope },
1401
+ message: 'Sync the Project plugin to remove the previous copy of its User Skill dependency.' }] }));
1402
+ const visibleInventory = [];
1403
+ for (const demand of scopes)
1404
+ for (const root of demand.roots ?? []) {
1405
+ const targetResults = [];
1406
+ for (const requirement of plan.roots.filter((entry) => entry.scope === demand.scope && entry.pluginId === root.pluginId)) {
1407
+ const placement = plan.placements.find((item) => item.pluginId === root.pluginId && item.target === requirement.target
1408
+ && item.contributions.some((contribution) => contribution.scope === demand.scope && contribution.root === root.pluginId));
1409
+ const target = { pluginId: root.pluginId, agent: requirement.target, scope: demand.scope,
1410
+ requirementScope: demand.scope, providerScope: placement?.scope,
1411
+ delivery: root.plugin ? resolveDelivery(root.plugin.manifest, requirement.target, demand.scope) ?? null : null,
1412
+ execution: 'not-run', observation: 'unknown', content: 'unknown', requiredBy: [root.pluginId], relation: 'root',
1413
+ ...(root.plugin?.manifest.version ? { expectedVersion: root.plugin.manifest.version } : {}), blockers: [...requirement.blockers] };
1414
+ if (requirement.state === 'excluded' || requirement.state === 'unsupported') {
1415
+ target.satisfaction = requirement.state;
1416
+ target.content = 'satisfied';
1417
+ target.observation = 'verified';
1418
+ if (requirement.reasons?.length)
1419
+ target.reasons = requirement.reasons;
1420
+ }
1421
+ else if (requirement.state === 'required') {
1422
+ const providers = requirement.dependencies.map((id) => {
1423
+ const provider = plan.placements.find((item) => item.pluginId === id && item.target === requirement.target
1424
+ && item.contributions.some((contribution) => contribution.scope === demand.scope && contribution.root === root.pluginId));
1425
+ if (!provider)
1426
+ return undefined;
1427
+ // These observations check the same physical package and the demand's own effective scope.
1428
+ const scope = hasSharedUserPackage(requirement.target) ? demand.scope : provider.scope;
1429
+ return allTargets.find((item) => item.pluginId === id && item.agent === requirement.target && item.scope === scope);
1430
+ });
1431
+ const ownProvider = providers.find((provider) => provider?.pluginId === root.pluginId);
1432
+ if (ownProvider?.installedComponentIds)
1433
+ target.installedComponentIds = ownProvider.installedComponentIds;
1434
+ if (ownProvider?.installedComponentCount !== undefined)
1435
+ target.installedComponentCount = ownProvider.installedComponentCount;
1436
+ if (ownProvider?.installedVersion)
1437
+ target.installedVersion = ownProvider.installedVersion;
1438
+ target.blockers.push(...providers.flatMap((item) => item?.blockers ?? []));
1439
+ const reasons = providers.flatMap((item) => item?.reasons ?? []);
1440
+ if (demand.scope === 'project') {
1441
+ for (const copy of surplusSkills) {
1442
+ if (copy.agent !== requirement.target || !requirement.dependencies.includes(copy.pluginId))
1443
+ continue;
1444
+ reasons.push(...copy.reasons);
1445
+ }
1446
+ }
1447
+ if (reasons.length)
1448
+ target.reasons = reasons;
1449
+ const componentGaps = providers.flatMap((item) => item?.componentGaps ?? []);
1450
+ if (componentGaps.length)
1451
+ target.componentGaps = uniqueRecoveryComponentGaps(componentGaps);
1452
+ const exclusions = providers.flatMap((item) => item?.deploymentExclusions ?? []);
1453
+ if (exclusions.length)
1454
+ target.deploymentExclusions = [...new Map(exclusions.map((exclusion) => [JSON.stringify([exclusion.pluginId, exclusion.platform, exclusion.scope, exclusion.productId, exclusion.reasonCode]), exclusion])).values()];
1455
+ const deployments = providers.flatMap((item) => item?.deploymentObservations ?? []);
1456
+ if (deployments.length)
1457
+ target.deploymentObservations = [...new Map(deployments.map((item) => [item.bindingId, item])).values()];
1458
+ target.content = ['conflict', 'drifted', 'absent', 'unknown'].find((state) => providers.some((item) => (item?.content ?? 'unknown') === state)) ?? 'satisfied';
1459
+ target.observation = target.content === 'satisfied' ? 'verified' : target.content === 'absent' ? 'missing' : 'unknown';
1460
+ target.satisfaction = observedSatisfaction(target.content, ownProvider, demand.scope === 'project' && placement?.scope === 'user');
1461
+ target.backend = providers.map((provider) => ({ pluginId: provider?.pluginId, scope: provider?.scope, content: provider?.content, live: provider?.backend }));
1462
+ }
1463
+ targetResults.push(target);
1464
+ }
1465
+ visibleInventory.push({ pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
1466
+ blockers: root.blockers.map(diagnostic), targetResults });
1467
+ }
1468
+ const extraObserved = [...observed.flatMap((status) => status.extraObserved), ...surplusSkills]
1469
+ .filter((item) => !expected.has(`${item.pluginId}\0${item.agent}\0${item.scope}`));
1470
+ const targets = visibleInventory.flatMap((item) => item.targetResults);
1471
+ const globalTargets = targets.filter((target) => globalPlan.roots.some((root) => root.pluginId === target.pluginId && root.target === target.agent && root.scope === target.scope));
1472
+ const fullObservation = !selected || globalPlan.placements.every(selectedPlacement);
1473
+ const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict', 'projectSkillProviderConflict', 'userSkillProviderNotReady'].includes(error.code))
1474
+ || globalTargets.some((target) => ['absent', 'drifted', 'conflict'].includes(target.content ?? 'unknown')
1475
+ || target.blockers.some((entry) => entry.code === 'awCapabilityUnsupported'));
1476
+ const uncertain = !fullObservation || !globalPlan.complete || globalTargets.some((target) => target.content === 'unknown' || target.blockers.length > 0);
1477
+ const allSatisfied = knownFailure ? false : uncertain ? null : true;
1478
+ const nativeCoverage = !selected && observed.every((status) => status.coverage.native);
1479
+ const portableCoverage = !selected && observed.every((status) => status.coverage.portable);
1480
+ const errors = [...new Map([...selectionErrors, ...plan.errors.filter((error) => !selected || !error.pluginId
1481
+ || !observationPlugins || observationPlugins.has(error.pluginId)), ...observed.flatMap((status) => status.errors)]
1482
+ .map((error) => [JSON.stringify(error), error])).values()];
1483
+ const result = { schemaVersion: 1, kind: 'aw-recovery-status', scope: snapshot.context.context, ok: errors.length === 0,
1484
+ intent: { state: scopes.some((demand) => demand.intent.state === 'invalid') ? 'invalid'
1485
+ : scopes.some((demand) => demand.intent.state === 'unreadable') ? 'unreadable'
1486
+ : scopes.some((demand) => demand.intent.state === 'unsupported-version') ? 'unsupported-version'
1487
+ : scopes.some((demand) => demand.intent.state === 'valid') ? 'valid' : 'absent' },
1488
+ selection: { agents: snapshot.preferences?.targets ?? [], origin: snapshot.preferences?.targets.length ? 'preference' : 'none', preferences: snapshot.user.preferences.state },
1489
+ inventory: inventory === null ? null : visibleInventory, extraObserved, observedTargets: allTargets, projectSkillProviders: skillProviders,
1490
+ existingTargets: observed.flatMap((status) => status.existingTargets ?? []), ownedTargets: observed.flatMap((status) => status.ownedTargets ?? []),
1491
+ retainedProjectPackages: observed.flatMap((status) => status.retainedProjectPackages ?? []),
1492
+ coverage: { native: nativeCoverage, portable: portableCoverage, scopes: snapshot.context.scopes,
1493
+ ...(snapshot.context.projectRoot ? { projectRoot: snapshot.context.projectRoot } : {}) },
1494
+ counts: { blocked: targets.filter((target) => target.blockers.length).length,
1495
+ pending: targets.filter((target) => target.satisfaction === 'pending').length,
1496
+ unconfirmed: targets.filter((target) => target.content === 'unknown').length,
1497
+ ready: targets.filter((target) => target.content === 'satisfied').length },
1498
+ allSatisfied, inSync: aggregateConvergence(allSatisfied, extraObserved.length ? 'present' : nativeCoverage && portableCoverage ? 'absent' : 'unknown'), errors };
1499
+ if (options.plugins?.length) {
1500
+ for (const target of allTargets.filter((target) => matchesPlugin(target.pluginId))) {
1501
+ if (visibleInventory.some((entry) => entry.pluginId === target.pluginId))
1502
+ continue;
1503
+ visibleInventory.push({ pluginId: target.pluginId, source: parsePluginId(target.pluginId).sourceId, sourceState: 'ready', blockers: [],
1504
+ targetResults: allTargets.filter((entry) => entry.pluginId === target.pluginId).map((entry) => ({ ...entry,
1505
+ requirementScope: entry.contributions?.[0]?.scope,
1506
+ satisfaction: observedSatisfaction(entry.content, entry, entry.scope === 'user' && entry.contributions.some((contribution) => contribution.scope === 'project')) })) });
1507
+ }
1508
+ }
1509
+ if (selected) {
1510
+ result.inventory = result.inventory?.filter((entry) => matchesPlugin(entry.pluginId)).map((entry) => ({ ...entry,
1511
+ targetResults: entry.targetResults.filter((target) => !options.targets || options.targets.includes(target.agent)) })) ?? null;
1512
+ const requested = result.inventory?.flatMap((entry) => entry.targetResults) ?? [];
1513
+ result.coverage.requestComplete = observed.every((status) => status.coverage.requestComplete ?? (status.coverage.native && status.coverage.portable))
1514
+ && result.errors.length === 0 && result.inventory !== null
1515
+ && result.inventory.every((entry) => entry.sourceState === 'ready' && entry.blockers.length === 0)
1516
+ && allTargets.every((target) => target.content !== 'unknown'
1517
+ && target.blockers.every((blocker) => blocker.code === 'needs-preparation' && ['absent', 'drifted'].includes(target.content ?? '')))
1518
+ && requested.every((target) => target.content !== 'unknown');
1519
+ result.counts = { blocked: requested.filter((target) => target.blockers.length).length,
1520
+ pending: requested.filter((target) => target.satisfaction === 'pending').length,
1521
+ unconfirmed: requested.filter((target) => target.content === 'unknown').length,
1522
+ ready: requested.filter((target) => target.content === 'satisfied').length };
1523
+ }
1524
+ await options.onNativeStatus?.(result, snapshot.context.context === 'project' ? snapshot.project : snapshot.user);
1525
+ options.signal?.throwIfAborted();
1526
+ return result;
1527
+ }
1528
+ //# sourceMappingURL=status.js.map