@lesliechan721/aw 0.1.0-beta.83 → 0.1.0-beta.85

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 (250) hide show
  1. package/dist/authoring/assets/aw-runtime-config.mjs +1 -1
  2. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
  3. package/dist/index.js +2 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/commands/console.js +1 -0
  6. package/dist/src/commands/console.js.map +1 -1
  7. package/dist/src/commands/intent-command.d.ts +1 -0
  8. package/dist/src/commands/intent-command.js +6 -2
  9. package/dist/src/commands/intent-command.js.map +1 -1
  10. package/dist/src/commands/plugin-capabilities.js +3 -3
  11. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  12. package/dist/src/commands/public-lifecycle-result.d.ts +14 -13
  13. package/dist/src/commands/public-lifecycle-result.js +204 -64
  14. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  15. package/dist/src/commands/public-lifecycle.d.ts +1 -2
  16. package/dist/src/commands/public-lifecycle.js +56 -34
  17. package/dist/src/commands/public-lifecycle.js.map +1 -1
  18. package/dist/src/commands/public-plugin-query.js +44 -11
  19. package/dist/src/commands/public-plugin-query.js.map +1 -1
  20. package/dist/src/commands/rebuild-command.d.ts +13 -3
  21. package/dist/src/commands/rebuild-command.js +665 -288
  22. package/dist/src/commands/rebuild-command.js.map +1 -1
  23. package/dist/src/commands/rebuild-integration.d.ts +6 -2
  24. package/dist/src/commands/rebuild-integration.js +60 -29
  25. package/dist/src/commands/rebuild-integration.js.map +1 -1
  26. package/dist/src/commands/rebuild-operations.d.ts +1 -0
  27. package/dist/src/commands/rebuild-operations.js +28 -6
  28. package/dist/src/commands/rebuild-operations.js.map +1 -1
  29. package/dist/src/commands/rebuild-platform-integration.d.ts +20 -5
  30. package/dist/src/commands/rebuild-platform-integration.js +752 -182
  31. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  32. package/dist/src/generators/permissions.d.ts +7 -1
  33. package/dist/src/generators/permissions.js +56 -0
  34. package/dist/src/generators/permissions.js.map +1 -1
  35. package/dist/src/index.d.ts +1 -0
  36. package/dist/src/index.js +112 -54
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/intent/scope-context.d.ts +4 -2
  39. package/dist/src/intent/scope-context.js +37 -7
  40. package/dist/src/intent/scope-context.js.map +1 -1
  41. package/dist/src/output/component-delivery.d.ts +21 -0
  42. package/dist/src/output/component-delivery.js +82 -0
  43. package/dist/src/output/component-delivery.js.map +1 -0
  44. package/dist/src/output/public-result.d.ts +4 -0
  45. package/dist/src/output/public-result.js +85 -15
  46. package/dist/src/output/public-result.js.map +1 -1
  47. package/dist/src/output/rebuild-progress.d.ts +3 -0
  48. package/dist/src/output/rebuild-progress.js +12 -2
  49. package/dist/src/output/rebuild-progress.js.map +1 -1
  50. package/dist/src/output/receipt-projection.js +64 -19
  51. package/dist/src/output/receipt-projection.js.map +1 -1
  52. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  53. package/dist/src/output/skill-invocation-notices.js +84 -0
  54. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  55. package/dist/src/platforms/capabilities.d.ts +6 -1
  56. package/dist/src/platforms/capabilities.js +161 -38
  57. package/dist/src/platforms/capabilities.js.map +1 -1
  58. package/dist/src/platforms/contracts.d.ts +45 -10
  59. package/dist/src/platforms/discovery.d.ts +11 -7
  60. package/dist/src/platforms/discovery.js +176 -76
  61. package/dist/src/platforms/discovery.js.map +1 -1
  62. package/dist/src/platforms/inspection-grok.js +121 -9
  63. package/dist/src/platforms/inspection-grok.js.map +1 -1
  64. package/dist/src/platforms/inspection-native.js +53 -97
  65. package/dist/src/platforms/inspection-native.js.map +1 -1
  66. package/dist/src/platforms/inspection-pi.d.ts +7 -1
  67. package/dist/src/platforms/inspection-pi.js +295 -95
  68. package/dist/src/platforms/inspection-pi.js.map +1 -1
  69. package/dist/src/platforms/inspection-query.d.ts +6 -5
  70. package/dist/src/platforms/inspection-query.js +30 -25
  71. package/dist/src/platforms/inspection-query.js.map +1 -1
  72. package/dist/src/platforms/inspection.d.ts +4 -1
  73. package/dist/src/platforms/inspection.js +38 -6
  74. package/dist/src/platforms/inspection.js.map +1 -1
  75. package/dist/src/platforms/layout.d.ts +6 -0
  76. package/dist/src/platforms/layout.js +45 -12
  77. package/dist/src/platforms/layout.js.map +1 -1
  78. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  79. package/dist/src/platforms/lifecycle-native-services.js +14 -14
  80. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  81. package/dist/src/platforms/lifecycle-native.d.ts +1 -0
  82. package/dist/src/platforms/lifecycle-native.js +29 -89
  83. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  84. package/dist/src/platforms/lifecycle.d.ts +2 -0
  85. package/dist/src/platforms/lifecycle.js +120 -69
  86. package/dist/src/platforms/lifecycle.js.map +1 -1
  87. package/dist/src/platforms/projection-code-extension.js +9 -4
  88. package/dist/src/platforms/projection-code-extension.js.map +1 -1
  89. package/dist/src/platforms/projection.d.ts +3 -0
  90. package/dist/src/platforms/projection.js +152 -72
  91. package/dist/src/platforms/projection.js.map +1 -1
  92. package/dist/src/platforms/supplement-layout.d.ts +5 -1
  93. package/dist/src/platforms/supplement-layout.js +23 -1
  94. package/dist/src/platforms/supplement-layout.js.map +1 -1
  95. package/dist/src/platforms/supplement-state.d.ts +1 -1
  96. package/dist/src/platforms/supplement-state.js +18 -7
  97. package/dist/src/platforms/supplement-state.js.map +1 -1
  98. package/dist/src/portable/commands.js +1 -1
  99. package/dist/src/portable/commands.js.map +1 -1
  100. package/dist/src/portable/materializer.d.ts +4 -0
  101. package/dist/src/portable/materializer.js +9 -2
  102. package/dist/src/portable/materializer.js.map +1 -1
  103. package/dist/src/portable/recovery.d.ts +31 -3
  104. package/dist/src/portable/recovery.js +261 -82
  105. package/dist/src/portable/recovery.js.map +1 -1
  106. package/dist/src/recovery/coordinator.d.ts +19 -5
  107. package/dist/src/recovery/coordinator.js +433 -174
  108. package/dist/src/recovery/coordinator.js.map +1 -1
  109. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  110. package/dist/src/recovery/install-concurrency.js +196 -0
  111. package/dist/src/recovery/install-concurrency.js.map +1 -0
  112. package/dist/src/recovery/interruption.d.ts +19 -0
  113. package/dist/src/recovery/interruption.js +43 -0
  114. package/dist/src/recovery/interruption.js.map +1 -0
  115. package/dist/src/recovery/joint-coordinator.d.ts +18 -4
  116. package/dist/src/recovery/joint-coordinator.js +829 -341
  117. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  118. package/dist/src/recovery/joint-demand.d.ts +22 -2
  119. package/dist/src/recovery/joint-demand.js +104 -6
  120. package/dist/src/recovery/joint-demand.js.map +1 -1
  121. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  122. package/dist/src/recovery/joint-install-execution.js +307 -0
  123. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  124. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  125. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  126. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  127. package/dist/src/recovery/receipt.d.ts +35 -4
  128. package/dist/src/recovery/receipt.js +90 -1
  129. package/dist/src/recovery/receipt.js.map +1 -1
  130. package/dist/src/recovery/retirement.js +1 -1
  131. package/dist/src/recovery/retirement.js.map +1 -1
  132. package/dist/src/recovery/status.d.ts +20 -8
  133. package/dist/src/recovery/status.js +405 -116
  134. package/dist/src/recovery/status.js.map +1 -1
  135. package/dist/src/review/platform-profile.d.ts +4 -1
  136. package/dist/src/review/platform-profile.js +14 -4
  137. package/dist/src/review/platform-profile.js.map +1 -1
  138. package/dist/src/review/skill-materialization.d.ts +2 -0
  139. package/dist/src/review/skill-materialization.js +68 -50
  140. package/dist/src/review/skill-materialization.js.map +1 -1
  141. package/dist/src/review/source-binding.js +11 -5
  142. package/dist/src/review/source-binding.js.map +1 -1
  143. package/dist/src/tui/console-app-v4.d.ts +1 -1
  144. package/dist/src/tui/console-app-v4.js +180 -63
  145. package/dist/src/tui/console-app-v4.js.map +1 -1
  146. package/dist/src/tui/controller-runtime.js +46 -10
  147. package/dist/src/tui/controller-runtime.js.map +1 -1
  148. package/dist/src/tui/controller.d.ts +15 -5
  149. package/dist/src/tui/controller.js +246 -102
  150. package/dist/src/tui/controller.js.map +1 -1
  151. package/dist/src/tui/deployment-view.d.ts +6 -3
  152. package/dist/src/tui/deployment-view.js +43 -9
  153. package/dist/src/tui/deployment-view.js.map +1 -1
  154. package/dist/src/tui/diagnostic-projection.d.ts +11 -3
  155. package/dist/src/tui/diagnostic-projection.js +85 -4
  156. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  157. package/dist/src/tui/entity-cards.d.ts +2 -1
  158. package/dist/src/tui/entity-cards.js +34 -11
  159. package/dist/src/tui/entity-cards.js.map +1 -1
  160. package/dist/src/tui/glossary.js +5 -0
  161. package/dist/src/tui/glossary.js.map +1 -1
  162. package/dist/src/tui/model.js +2 -1
  163. package/dist/src/tui/model.js.map +1 -1
  164. package/dist/src/tui/operation-diagnostic-screens.d.ts +1 -1
  165. package/dist/src/tui/operation-diagnostic-screens.js +6 -2
  166. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  167. package/dist/src/tui/operation-history.d.ts +12 -3
  168. package/dist/src/tui/operation-history.js +34 -3
  169. package/dist/src/tui/operation-history.js.map +1 -1
  170. package/dist/src/tui/plugin-detail.d.ts +4 -1
  171. package/dist/src/tui/plugin-detail.js +9 -2
  172. package/dist/src/tui/plugin-detail.js.map +1 -1
  173. package/dist/src/tui/scoped-flow.d.ts +3 -1
  174. package/dist/src/tui/scoped-flow.js +117 -1
  175. package/dist/src/tui/scoped-flow.js.map +1 -1
  176. package/dist/src/tui/scoped-inventory.d.ts +6 -2
  177. package/dist/src/tui/scoped-inventory.js +29 -7
  178. package/dist/src/tui/scoped-inventory.js.map +1 -1
  179. package/dist/src/tui/session-console-app.d.ts +2 -0
  180. package/dist/src/tui/session-console-app.js +11 -0
  181. package/dist/src/tui/session-console-app.js.map +1 -1
  182. package/dist/src/types.d.ts +10 -2
  183. package/dist/src/types.js.map +1 -1
  184. package/dist/src/utils/artifact-plan.js +5 -1
  185. package/dist/src/utils/artifact-plan.js.map +1 -1
  186. package/dist/src/utils/artifact-renderer.d.ts +1 -1
  187. package/dist/src/utils/artifact-renderer.js +29 -8
  188. package/dist/src/utils/artifact-renderer.js.map +1 -1
  189. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  190. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  191. package/dist/src/utils/catalog-source-references.js +14 -17
  192. package/dist/src/utils/catalog-source-references.js.map +1 -1
  193. package/dist/src/utils/codex-native-observation.d.ts +6 -0
  194. package/dist/src/utils/codex-native-observation.js +32 -3
  195. package/dist/src/utils/codex-native-observation.js.map +1 -1
  196. package/dist/src/utils/component-command-preparation.d.ts +2 -0
  197. package/dist/src/utils/component-command-preparation.js +23 -4
  198. package/dist/src/utils/component-command-preparation.js.map +1 -1
  199. package/dist/src/utils/component-gap.d.ts +4 -0
  200. package/dist/src/utils/component-gap.js +20 -0
  201. package/dist/src/utils/component-gap.js.map +1 -0
  202. package/dist/src/utils/component-resources.js +2 -4
  203. package/dist/src/utils/component-resources.js.map +1 -1
  204. package/dist/src/utils/dynamic-skill-tree.js +2 -32
  205. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  206. package/dist/src/utils/managed-command-materialization.d.ts +2 -1
  207. package/dist/src/utils/managed-command-materialization.js +3 -3
  208. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  209. package/dist/src/utils/managed-command-store.d.ts +6 -0
  210. package/dist/src/utils/managed-command-store.js +90 -18
  211. package/dist/src/utils/managed-command-store.js.map +1 -1
  212. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  213. package/dist/src/utils/multi-source-catalog.js +3 -2
  214. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  215. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  216. package/dist/src/utils/native-cli-interruption.js +65 -0
  217. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  218. package/dist/src/utils/native-cli.d.ts +5 -19
  219. package/dist/src/utils/native-cli.js +168 -95
  220. package/dist/src/utils/native-cli.js.map +1 -1
  221. package/dist/src/utils/ownership.d.ts +1 -0
  222. package/dist/src/utils/ownership.js +18 -4
  223. package/dist/src/utils/ownership.js.map +1 -1
  224. package/dist/src/utils/package-content.d.ts +7 -0
  225. package/dist/src/utils/package-content.js +70 -0
  226. package/dist/src/utils/package-content.js.map +1 -0
  227. package/dist/src/utils/platform-empty-state.d.ts +32 -9
  228. package/dist/src/utils/platform-empty-state.js +135 -70
  229. package/dist/src/utils/platform-empty-state.js.map +1 -1
  230. package/dist/src/utils/plugin-config-write.d.ts +8 -0
  231. package/dist/src/utils/plugin-config-write.js +93 -25
  232. package/dist/src/utils/plugin-config-write.js.map +1 -1
  233. package/dist/src/utils/plugin-scripts.js +24 -8
  234. package/dist/src/utils/plugin-scripts.js.map +1 -1
  235. package/dist/src/utils/process-tree.d.ts +1 -1
  236. package/dist/src/utils/process-tree.js +1 -1
  237. package/dist/src/utils/process-tree.js.map +1 -1
  238. package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
  239. package/dist/src/utils/skill-invocation-warning.js +68 -0
  240. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  241. package/package.json +3 -3
  242. package/dist/src/output/native-consent.d.ts +0 -2
  243. package/dist/src/output/native-consent.js +0 -5
  244. package/dist/src/output/native-consent.js.map +0 -1
  245. package/dist/src/platforms/gemini-activation.d.ts +0 -36
  246. package/dist/src/platforms/gemini-activation.js +0 -331
  247. package/dist/src/platforms/gemini-activation.js.map +0 -1
  248. package/dist/src/platforms/gemini-consent.d.ts +0 -8
  249. package/dist/src/platforms/gemini-consent.js +0 -81
  250. package/dist/src/platforms/gemini-consent.js.map +0 -1
@@ -1,9 +1,14 @@
1
1
  import crypto from 'node:crypto';
2
2
  import path from 'node:path';
3
+ import { mapInstallReads, runInstallTasks } from '../recovery/install-concurrency.js';
4
+ import { withNativeObservationBatch } from '../platforms/inspection-query.js';
5
+ import { RebuildInterruptedError, recoveryInterruptionCode } from '../recovery/interruption.js';
3
6
  import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
4
7
  import { withNativeToolRemovalImpact } from '../utils/native-tool-review.js';
5
8
  import fs from 'fs-extra';
6
9
  import { NATIVE_PLATFORM_TARGETS } from '@lesliechan721/aw-plugin-core/manifest';
10
+ import { nativeInstallResources } from './rebuild-platform-integration.js';
11
+ import { resolvePlatformConfigRoot } from '../platforms/discovery.js';
7
12
  import { getDeploymentLayout } from '../platforms/layout.js';
8
13
  import { createNoopDebugLogger } from '../output/debug-log.js';
9
14
  import { createNoopReporter } from '../output/reporter.js';
@@ -32,7 +37,7 @@ import { supportsPlatform } from '../utils/platform-support.js';
32
37
  import { pluginConfigTargetRenderScopes } from '../utils/plugin-config-impact.js';
33
38
  import { inspectPluginConfigResetTarget, readNamespacedPluginConfigStoreIdentity, resolveEffectivePluginConfig, resolvePluginConfigStorePath, } from '../utils/plugin-config.js';
34
39
  import { resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
35
- import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
40
+ import { attachSafeOperationError, readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
36
41
  import { canonicalizePathThroughExistingAncestorSync, codexProjectConfigAliasesUserHome, getClaudeHome, getCodexHome, resolveRepoRootSync, } from '../utils/state-paths.js';
37
42
  import { AwCapabilityUnsupportedError, IMPLEMENTED_AW_CAPABILITIES, } from './aw-capabilities.js';
38
43
  import { createDependencyPlacementPlan, } from './dependency-operation-plan.js';
@@ -40,8 +45,21 @@ import { forceOfflineCleanupEvidence, intentOnlyOfflineCleanupEvidence, offlineC
40
45
  import { assertOperationPlanFingerprint, createOperationPlan, createOperationPlanConfigDigest, operationPlanNativeToolChanges, } from './operation-plan.js';
41
46
  import { deploymentConfirmationEffects } from './deployment-confirmation.js';
42
47
  import { assertNoClaudeUnboundNativeNameCollision, CodexActivationPostcheckError, createRebuildIntegration, disposePreparedPlatformRebuildSession, executeCodexReconcileActivations, inspectNativeMarketplaceRegistrations, isNativeActivationOnlyTarget, postcheckCodexReconcileActivations, removeForceCleanupCodexRoleRegistration } from './rebuild-integration.js';
43
- import { executeRebuildOperation, prepareRebuildOperation } from './rebuild-operations.js';
48
+ import { executeRebuildOperation, hasPlannedPreApply, prepareRebuildOperation } from './rebuild-operations.js';
44
49
  import { createReconcileOperationPlan, } from './reconcile-operation-plan.js';
50
+ // A read scope belongs to one Review or its independent locked recheck.
51
+ const nativePreparationReads = new WeakMap();
52
+ function preparationReads(runtime) {
53
+ const scope = runtime?.catalogReadScope;
54
+ if (!scope || !runtime.previewOperationPlan || !runtime.batchInstallPlatform)
55
+ return;
56
+ let reads = nativePreparationReads.get(scope);
57
+ if (!reads) {
58
+ reads = { plugins: new Map(), inventories: new Map() };
59
+ nativePreparationReads.set(scope, reads);
60
+ }
61
+ return reads;
62
+ }
45
63
  async function measureCommandPerformanceStage(runtime, name, operation) {
46
64
  const startedAt = Date.now();
47
65
  let phase = 'success';
@@ -294,6 +312,7 @@ async function assertClaudeVersion(options) {
294
312
  return;
295
313
  const failures = [];
296
314
  const result = await probeAgentVersion('claude', {
315
+ cache: false,
297
316
  cwd: options.cwd,
298
317
  env: options.env,
299
318
  runner: options.runtime.nativeCliRunner,
@@ -315,7 +334,6 @@ async function resolveRequestedNames(options) {
315
334
  }
316
335
  async function runSingleSourceRebuildCommand(options) {
317
336
  const runtime = {
318
- nativeConsent: options.runtime?.nativeConsent === true,
319
337
  referencePlugins: options.runtime?.referencePlugins,
320
338
  recoveryCandidates: options.runtime?.recoveryCandidates,
321
339
  sharedReferenceView: options.runtime?.executionInput?.requirements.sharedReferenceView ?? options.runtime?.sharedReferenceView,
@@ -361,19 +379,12 @@ async function runSingleSourceRebuildCommand(options) {
361
379
  ? readPluginManifest(pluginRoot, { mode: 'bundle' })
362
380
  : null;
363
381
  }))).filter((plugin) => plugin !== null);
364
- if (options.runtime?.namespacedSource) {
365
- for (const plugin of catalogPlugins) {
366
- plugin.sourceId = options.runtime.namespacedSource.sourceId;
367
- plugin.sourceIdentity = options.runtime.namespacedSource.sourceIdentity;
368
- plugin.catalogLogicalIdentity = options.runtime.namespacedSource.logicalIdentity;
369
- plugin.pluginId = formatPluginId({
370
- sourceId: options.runtime.namespacedSource.sourceId,
371
- pluginName: plugin.manifest.name,
372
- });
373
- plugin.marketplaceName = options.runtime.namespacedSource.marketplaceName;
374
- }
375
- }
376
- const catalogByName = new Map(catalogPlugins.map((plugin) => [plugin.manifest.name, plugin]));
382
+ const namespaced = options.runtime?.namespacedSource;
383
+ const catalogByName = new Map(catalogPlugins.map((plugin) => [plugin.manifest.name, namespaced ? {
384
+ ...plugin, sourceId: namespaced.sourceId, sourceIdentity: namespaced.sourceIdentity,
385
+ catalogLogicalIdentity: namespaced.logicalIdentity, marketplaceName: namespaced.marketplaceName,
386
+ pluginId: formatPluginId({ sourceId: namespaced.sourceId, pluginName: plugin.manifest.name }),
387
+ } : plugin]));
377
388
  if (options.commandOptions.platform === 'both'
378
389
  && options.command !== 'cleanup'
379
390
  && options.command !== 'uninstall') {
@@ -1096,7 +1107,7 @@ async function cleanupOfflineOwnedComponents(options) {
1096
1107
  // This offline path can revoke only independently owned files and directory-loaded packages.
1097
1108
  if (component.kind === 'owned-directory'
1098
1109
  && ((action.recoveryCandidate && needsFrozenNativeRemoval(action.recoveryCandidate))
1099
- || ['codex', 'claude', 'gemini', 'copilot', 'pi'].includes(target.platform)
1110
+ || ['codex', 'claude', 'copilot', 'pi'].includes(target.platform)
1100
1111
  || path.relative(path.join(resolveAwHome(options.env), 'platforms'), component.path).split(path.sep)[0] !== '..')) {
1101
1112
  preservedOutputs.push(component.path);
1102
1113
  continue;
@@ -1820,6 +1831,10 @@ async function runRebuildCommandInSession(options) {
1820
1831
  }
1821
1832
  const selectedExecutionTarget = (target) => executionInput.selectedTargets.some((selected) => selected.pluginId === target.pluginId && selected.platform === target.platform && selected.scope === target.scope);
1822
1833
  const runtimeEnv = executionInput.context.env;
1834
+ const admission = options.runtime?.installAdmission;
1835
+ const initialGeneration = admission?.exclusiveGeneration ?? 0;
1836
+ if (initialGeneration && requestedPlatforms.includes('codex'))
1837
+ options.runtime?.codexObservationSession?.invalidate();
1823
1838
  const retainSelectors = options.command === 'cleanup' ? options.pluginNames.map(parsePluginId) : [];
1824
1839
  const primarySourceId = retainSelectors.some((selector) => !selector.sourceId)
1825
1840
  ? await readCatalogSourcesConfigSnapshot(runtimeEnv)
@@ -1832,16 +1847,27 @@ async function runRebuildCommandInSession(options) {
1832
1847
  const retainedPackageActions = retainedPackages.map((entry) => ({ ...entry, kind: 'retainManagedCommandPackage', pluginId: `${entry.producer.sourceId}/${entry.producer.pluginName}`, scope: entry.producer.scope }));
1833
1848
  const readInventory = options.runtime?.inventoryCatalogSourceReferences
1834
1849
  ?? inventoryCatalogSourceReferences;
1850
+ const inventoryRequest = { cwd: options.commandOptions.cwd, env: runtimeEnv, scope: options.commandOptions.scope };
1851
+ const readCurrentInventory = () => {
1852
+ if (!admission || !options.runtime?.batchInstallPlatform)
1853
+ return readInventory(inventoryRequest);
1854
+ // The inventory includes other hosts' registries and owner markers. Sample them
1855
+ // outside any target or script lease, while sibling publishers are between writes.
1856
+ const roots = [resolveAwHome(runtimeEnv), resolveRepoRootSync(inventoryRequest.cwd),
1857
+ ...NATIVE_PLATFORM_TARGETS.map((platform) => resolvePlatformConfigRoot(platform, inventoryRequest))];
1858
+ return admission.run(roots.map((value) => ({ kind: 'path', value, access: 'read' })), () => readInventory(inventoryRequest), options.runtime.signal);
1859
+ };
1860
+ const readCache = preparationReads(options.runtime);
1835
1861
  let ordinaryInventory;
1836
- const readOrdinaryInventory = async () => {
1837
- ordinaryInventory ??= await measureCommandPerformanceStage(options.runtime, 'inventory', async () => {
1838
- const inventory = await readInventory({
1839
- cwd: options.commandOptions.cwd,
1840
- env: runtimeEnv,
1841
- scope: options.commandOptions.scope,
1842
- });
1843
- return inventory;
1844
- });
1862
+ const readOrdinaryInventory = () => {
1863
+ if (ordinaryInventory)
1864
+ return ordinaryInventory;
1865
+ const key = JSON.stringify([inventoryRequest.cwd, inventoryRequest.scope, Object.entries(runtimeEnv).sort(([a], [b]) => a.localeCompare(b))]);
1866
+ let reads = readCache?.inventories.get(readInventory);
1867
+ if (readCache && !reads)
1868
+ readCache.inventories.set(readInventory, reads = new Map());
1869
+ ordinaryInventory = reads?.get(key) ?? measureCommandPerformanceStage(options.runtime, 'inventory', readCurrentInventory);
1870
+ reads?.set(key, ordinaryInventory);
1845
1871
  return ordinaryInventory;
1846
1872
  };
1847
1873
  let requestedPluginNames = options.pluginNames;
@@ -2426,11 +2452,12 @@ async function runRebuildCommandInSession(options) {
2426
2452
  });
2427
2453
  }
2428
2454
  const available = await Promise.all(requiredEntryClosure.map(async (candidate) => {
2429
- const plugin = await readPluginManifest(path.join(candidate.source.rootDir, 'plugins', candidate.entry.name), { mode: 'bundle' });
2430
- plugin.sourceId = candidate.source.sourceId;
2431
- plugin.sourceIdentity = candidate.source.sourceIdentity;
2432
- plugin.catalogLogicalIdentity = candidate.source.logicalIdentity;
2433
- plugin.pluginId = candidate.pluginId;
2455
+ const root = path.join(candidate.source.rootDir, 'plugins', candidate.entry.name);
2456
+ const key = JSON.stringify([root, candidate.source.sourceIdentity, candidate.source.snapshotDigest, candidate.entry.contentDigest]);
2457
+ const read = readCache?.plugins.get(key) ?? readPluginManifest(root, { mode: 'bundle' });
2458
+ readCache?.plugins.set(key, read);
2459
+ const plugin = { ...await read, sourceId: candidate.source.sourceId, sourceIdentity: candidate.source.sourceIdentity,
2460
+ catalogLogicalIdentity: candidate.source.logicalIdentity, pluginId: candidate.pluginId };
2434
2461
  return { source: candidate.source, plugin, pluginId: candidate.pluginId };
2435
2462
  }));
2436
2463
  const selected = selectedEntries.map((entry) => available.find((candidate) => candidate.pluginId === entry.pluginId));
@@ -2551,7 +2578,7 @@ async function runRebuildCommandInSession(options) {
2551
2578
  const planExecutionKey = (target) => [
2552
2579
  target.pluginId,
2553
2580
  target.platform,
2554
- target.requestedScope ?? target.resolvedScope,
2581
+ options.runtime?.batchInstallPlatform ? target.resolvedScope : target.requestedScope ?? target.resolvedScope,
2555
2582
  ].join('\0');
2556
2583
  const dependencyTargetFor = (plan, consumer, dependencyPluginId) => {
2557
2584
  const candidates = plan.targets.filter((target) => target.pluginId === dependencyPluginId
@@ -2725,10 +2752,10 @@ async function runRebuildCommandInSession(options) {
2725
2752
  }
2726
2753
  }
2727
2754
  const executionContext = {
2728
- nativeConsent: options.runtime?.nativeConsent === true,
2729
2755
  recoveryCandidates: options.runtime?.recoveryCandidates,
2730
2756
  sharedReferenceView: options.runtime?.executionInput?.requirements.sharedReferenceView ?? options.runtime?.sharedReferenceView,
2731
2757
  platformRebuildSession: options.runtime?.platformRebuildSession,
2758
+ batchInstallPlatform: options.runtime?.batchInstallPlatform,
2732
2759
  packagePreparationCache: options.runtime?.packagePreparationCache,
2733
2760
  preparedArtifactRenderResults: options.runtime?.preparedArtifactRenderResults,
2734
2761
  interruption: options.runtime?.interruption,
@@ -2784,6 +2811,15 @@ async function runRebuildCommandInSession(options) {
2784
2811
  }
2785
2812
  return output;
2786
2813
  };
2814
+ const readSelections = async (read, existingBatch) => {
2815
+ const batchInstall = !!options.runtime?.batchInstallPlatform;
2816
+ const run = (batch) => mapInstallReads(executionSelections, (selection) => read(selection, batch), { signal: executionContext.signal, limit: batchInstall ? undefined : 1 });
2817
+ if (!batchInstall || executionSelections.length < 2)
2818
+ return run();
2819
+ if (existingBatch)
2820
+ return run(existingBatch);
2821
+ return withNativeObservationBatch({ runner: executionContext.nativeCliRunner, signal: executionContext.signal }, run);
2822
+ };
2787
2823
  const createPlan = async (inventory, _codexManager, planOptions) => {
2788
2824
  plannedOwnedTextTargets = new Map();
2789
2825
  plannedSkillMarkerTargets = new Map();
@@ -2792,19 +2828,10 @@ async function runRebuildCommandInSession(options) {
2792
2828
  const placementNodes = [];
2793
2829
  const blockingTargets = new Map();
2794
2830
  const actualStates = new Map();
2795
- for (const [order, selection] of executionSelections.entries()) {
2831
+ const observations = await readSelections(async (selection, observationBatch) => {
2796
2832
  const { entry, platform } = selection;
2797
- const relation = executionInput.selectedTargets.some((target) => target.pluginId === entry.pluginId && target.platform === platform)
2798
- ? 'requested' : 'dependency';
2799
2833
  const requestedScope = selection.requestedScope ?? options.commandOptions.scope;
2800
2834
  const requestedMethod = selection.requestedMethod ?? options.command;
2801
- const activationOnly = isNativeActivationOnlyTarget(executionContext, {
2802
- pluginId: entry.pluginId, platform, scope: requestedScope,
2803
- });
2804
- const otherScopeRetires = options.runtime?.previewOperationPlan === true
2805
- && options.runtime.nativePlannedRetirements?.some((target) => target.pluginId === entry.pluginId && target.platform === platform
2806
- && target.scope !== requestedScope) === true;
2807
- let resolvedScope = requestedScope;
2808
2835
  const inspectScope = async (scope) => {
2809
2836
  const marketplaceName = marketplaceNameFor(entry, platform, scope);
2810
2837
  entry.plugin.marketplaceName = marketplaceName;
@@ -2821,6 +2848,7 @@ async function runRebuildCommandInSession(options) {
2821
2848
  command: requestedMethod,
2822
2849
  catalog: toCatalogResolution(entry.source),
2823
2850
  readOnlyInspectionPlan: true,
2851
+ observationBatch,
2824
2852
  });
2825
2853
  const targetKey = [entry.pluginId, platform, scope].join('\0');
2826
2854
  const ownedTextTargets = plannedOwnedTextTargets.get(targetKey) ?? new Set();
@@ -2874,15 +2902,31 @@ async function runRebuildCommandInSession(options) {
2874
2902
  : hasAnyPresent ? 'present' : 'absent';
2875
2903
  return { ...result, state, platformObservations: desired.platformObservations ?? [], supplementPhysicalKeys };
2876
2904
  };
2877
- const otherScope = resolvedScope === 'user' ? 'project' : 'user';
2905
+ const otherScope = requestedScope === 'user' ? 'project' : 'user';
2878
2906
  const [requestedInspection, otherInspection] = await Promise.all([
2879
- inspectScope(resolvedScope),
2907
+ inspectScope(requestedScope),
2880
2908
  options.commandOptions.scope === 'user'
2881
2909
  ? Promise.resolve({ state: 'partial', components: [], errors: [], platformObservations: [], supplementPhysicalKeys: new Set() })
2882
- : platform === 'codex' && codexScopePathsAlias && resolvedScope === 'user'
2910
+ : platform === 'codex' && codexScopePathsAlias && requestedScope === 'user'
2883
2911
  ? Promise.resolve({ state: 'absent', components: [], errors: [], platformObservations: [], supplementPhysicalKeys: new Set() })
2884
2912
  : inspectScope(otherScope),
2885
2913
  ]);
2914
+ return { requestedInspection, otherInspection, otherScope };
2915
+ }, executionContext.nativeObservationBatch);
2916
+ for (const [order, selection] of executionSelections.entries()) {
2917
+ const { entry, platform } = selection;
2918
+ const relation = executionInput.selectedTargets.some((target) => target.pluginId === entry.pluginId && target.platform === platform)
2919
+ ? 'requested' : 'dependency';
2920
+ const requestedScope = selection.requestedScope ?? options.commandOptions.scope;
2921
+ const requestedMethod = selection.requestedMethod ?? options.command;
2922
+ const activationOnly = isNativeActivationOnlyTarget(executionContext, {
2923
+ pluginId: entry.pluginId, platform, scope: requestedScope,
2924
+ });
2925
+ const otherScopeRetires = options.runtime?.previewOperationPlan === true
2926
+ && options.runtime.nativePlannedRetirements?.some((target) => target.pluginId === entry.pluginId && target.platform === platform
2927
+ && target.scope !== requestedScope) === true;
2928
+ let resolvedScope = requestedScope;
2929
+ const { requestedInspection, otherInspection, otherScope } = observations[order];
2886
2930
  const surface = platform === 'codex'
2887
2931
  ? analyzeCodexSurface(entry.plugin.manifest)
2888
2932
  : undefined;
@@ -2963,6 +3007,15 @@ async function runRebuildCommandInSession(options) {
2963
3007
  : requestedMethod === 'reinstall' ? 'reinstall' : 'install'
2964
3008
  : requestedMethod === 'reinstall' ? 'reinstall' : 'install';
2965
3009
  let errorCode;
3010
+ // Grok rules can be complete with an empty native package slot. Let
3011
+ // component preparation determine whether the current source needs a package.
3012
+ const grokRulesWithoutPackage = platform === 'grok' && requestedMethod === 'sync'
3013
+ && requestedInspection.platformObservations.length > 0
3014
+ && requestedInspection.platformObservations.every(({ observation }) => observation.package === 'absent'
3015
+ && ['absent', 'not-applicable'].includes(observation.registration))
3016
+ && requestedInspection.components.some(({ component, state }) => component.kind === 'owned-text-file' && state === 'present')
3017
+ && requestedInspection.components.every(({ component, state }) => state === 'present'
3018
+ || component.kind === 'owned-directory' && state === 'absent');
2966
3019
  if (!dependencyEnabled && platform === 'codex'
2967
3020
  && relation === 'requested'
2968
3021
  && !uninstallForce
@@ -2986,6 +3039,7 @@ async function runRebuildCommandInSession(options) {
2986
3039
  && (requestedInspection.state === 'error'
2987
3040
  || (requestedInspection.state === 'partial'
2988
3041
  && !activationOnly
3042
+ && !grokRulesWithoutPackage
2989
3043
  && platform !== 'codex'
2990
3044
  && requestedMethod !== 'reinstall'
2991
3045
  && options.command !== 'cleanup'))) {
@@ -3116,7 +3170,7 @@ async function runRebuildCommandInSession(options) {
3116
3170
  sourceId: entry.source.sourceId,
3117
3171
  pluginName: dependency,
3118
3172
  });
3119
- return ['codex', 'claude'].flatMap((platform) => placementNodes.some((node) => node.pluginId === entry.pluginId && node.platform === platform)
3173
+ return [...closureEntriesByPlatform.keys()].flatMap((platform) => placementNodes.some((node) => node.pluginId === entry.pluginId && node.platform === platform)
3120
3174
  && placementNodes.some((node) => node.pluginId === dependencyId && node.platform === platform)
3121
3175
  ? [{ from: entry.pluginId, to: dependencyId, platform }]
3122
3176
  : []);
@@ -3191,6 +3245,37 @@ async function runRebuildCommandInSession(options) {
3191
3245
  const isHealthyWiderDependency = (target) => target.relation === 'dependency'
3192
3246
  && target.resolvedScope !== options.commandOptions.scope
3193
3247
  && target.action === 'keep';
3248
+ const lifecycleCommand = options.command === 'install'
3249
+ || options.command === 'sync' || options.command === 'reinstall';
3250
+ const preApplyAuthorizationForPlan = (plan, preparedTargets) => lifecycleCommand ? executionSelections.flatMap((selection) => {
3251
+ const { entry, platform } = selection;
3252
+ const planned = planTargetFor(plan, selection);
3253
+ if (!planned || planned.action === 'block' || isHealthyWiderDependency(planned)
3254
+ || !entry.plugin.manifest.scripts?.preApply)
3255
+ return [];
3256
+ const identity = { pluginId: entry.pluginId, platform, scope: planned.resolvedScope };
3257
+ if (isNativeActivationOnlyTarget(executionContext, identity))
3258
+ return [];
3259
+ if (preparedTargets) {
3260
+ const prepared = preparedTargets.get(executionKey(selection, plan));
3261
+ if (!prepared || !hasPlannedPreApply(prepared.target))
3262
+ return [];
3263
+ }
3264
+ return [{
3265
+ ...identity,
3266
+ pluginName: entry.plugin.manifest.name,
3267
+ sourceId: entry.source.sourceId,
3268
+ sourceIdentity: entry.source.sourceIdentity,
3269
+ relation: planned.relation === 'requested' ? 'requested'
3270
+ : planned.requiredBy.some((pluginId) => selectedIds.has(pluginId)) ? 'direct' : 'transitive',
3271
+ }];
3272
+ }) : [];
3273
+ const assertPreApplyAuthorization = (plan) => {
3274
+ if (options.commandOptions.yes === true || options.runtime?.preApplyConfirmed === true
3275
+ || !preApplyAuthorizationForPlan(plan).length)
3276
+ return;
3277
+ throw namespacedPreflightError('preApplyAuthorizationRequired: Running plugin preApply requires --yes or an accepted Review.', preflightTargets);
3278
+ };
3194
3279
  const createCodexPlans = async (_plan, _activationSupport = 'observed', _codexManager) => [];
3195
3280
  const operationNeedsNativeCli = async (platform, plan) => {
3196
3281
  for (const { entry, platform: selectedPlatform } of executionSelections) {
@@ -3270,12 +3355,12 @@ async function runRebuildCommandInSession(options) {
3270
3355
  scope: planned.resolvedScope, cwd: options.commandOptions.cwd, command: commandForTarget(selection, plan),
3271
3356
  catalog: toCatalogResolution(selection.entry.source) }];
3272
3357
  }));
3273
- for (const selection of executionSelections) {
3358
+ const builds = await readSelections(async (selection, observationBatch) => {
3274
3359
  const { entry, platform } = selection;
3275
3360
  const planned = planTargetFor(plan, selection);
3276
3361
  const key = executionKey(selection, plan);
3277
3362
  if (planned.action === 'block')
3278
- continue;
3363
+ return;
3279
3364
  const buildCommand = commandForTarget(selection, plan);
3280
3365
  const plannedNative = platform === 'codex'
3281
3366
  ? codexPlans.flatMap((codexPlan) => codexPlan.sharedNativeActions).find((action) => action.pluginId === entry.pluginId)
@@ -3299,6 +3384,7 @@ async function runRebuildCommandInSession(options) {
3299
3384
  scope: planned.resolvedScope,
3300
3385
  cwd: options.commandOptions.cwd,
3301
3386
  command: buildCommand,
3387
+ observationBatch,
3302
3388
  catalog: toCatalogResolution(entry.source),
3303
3389
  ...(platform === 'codex'
3304
3390
  && (buildCommand === 'cleanup' || buildCommand === 'uninstall')
@@ -3350,16 +3436,13 @@ async function runRebuildCommandInSession(options) {
3350
3436
  await integration.driver.preflightMutation?.(target);
3351
3437
  }
3352
3438
  }
3353
- preparedTargets.set(key, {
3354
- target,
3355
- });
3356
3439
  if (runTargetHook) {
3357
3440
  await rebuildCommandTestHooks?.afterTargetBuilt?.({
3358
3441
  command: selection.requestedMethod ?? options.command,
3359
3442
  identity: target.identity,
3360
3443
  });
3361
3444
  }
3362
- collisionSelections.push({
3445
+ const collision = {
3363
3446
  pluginId: entry.pluginId,
3364
3447
  targetKey: `${platform}/${target.identity.scope}`,
3365
3448
  artifactKeys: (target.desiredOwnedComponents ?? target.ownedComponents)
@@ -3374,14 +3457,27 @@ async function runRebuildCommandInSession(options) {
3374
3457
  : component.locator.kind === 'claude-permissions'
3375
3458
  ? `shared:claude:${path.resolve(component.locator.settingsPath)}:${component.locator.ownerKey}`
3376
3459
  : `shared:${component.label}`),
3377
- });
3460
+ };
3461
+ return { key, target, collision };
3378
3462
  }
3379
3463
  catch (error) {
3464
+ if (recoveryInterruptionCode(error) === 'processCleanupUnconfirmed')
3465
+ throw error;
3380
3466
  options.runtime?.signal?.throwIfAborted();
3381
- if (error instanceof Error && error.name === 'AbortError'
3382
- || readSafeOperationError(error))
3467
+ if (error instanceof Error && error.name === 'AbortError' || readSafeOperationError(error))
3383
3468
  throw error;
3384
- preparedTargetErrors.set(key, error);
3469
+ return { key, error };
3470
+ }
3471
+ });
3472
+ for (const build of builds) {
3473
+ if (!build)
3474
+ continue;
3475
+ if (build.target) {
3476
+ preparedTargets.set(build.key, { target: build.target });
3477
+ collisionSelections.push(build.collision);
3478
+ }
3479
+ else {
3480
+ preparedTargetErrors.set(build.key, build.error);
3385
3481
  }
3386
3482
  }
3387
3483
  const collisions = preflightDesiredArtifactCollisions(collisionSelections);
@@ -3453,28 +3549,7 @@ async function runRebuildCommandInSession(options) {
3453
3549
  assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(authorizationPlan), exactSkillMarkerTargets(authorizationPlan));
3454
3550
  const preview = mergeRebuildCommandResults([]);
3455
3551
  preview.dependencyPlan = authorizationPlan;
3456
- preview.preApplyAuthorization = executionSelections.flatMap((selection) => {
3457
- const { entry, platform } = selection;
3458
- const planned = planTargetFor(authorizationPlan, selection);
3459
- if (!planned || planned.action === 'block' || isHealthyWiderDependency(planned)
3460
- || !entry.plugin.manifest.scripts?.preApply) {
3461
- return [];
3462
- }
3463
- const relation = planned.relation === 'requested'
3464
- ? 'requested'
3465
- : planned.requiredBy.some((pluginId) => selectedIds.has(pluginId))
3466
- ? 'direct'
3467
- : 'transitive';
3468
- return [{
3469
- pluginId: entry.pluginId,
3470
- pluginName: entry.plugin.manifest.name,
3471
- sourceId: entry.source.sourceId,
3472
- sourceIdentity: entry.source.sourceIdentity,
3473
- platform,
3474
- scope: planned.resolvedScope,
3475
- relation,
3476
- }];
3477
- });
3552
+ preview.preApplyAuthorization = preApplyAuthorizationForPlan(authorizationPlan);
3478
3553
  return preview;
3479
3554
  }
3480
3555
  if (options.runtime?.previewOperationPlan) {
@@ -3486,6 +3561,7 @@ async function runRebuildCommandInSession(options) {
3486
3561
  const previewPreparation = await prepareRenderedTargets(initialPlan, initialCodexPlans, false);
3487
3562
  const preview = mergeRebuildCommandResults([]);
3488
3563
  preview.dependencyPlan = initialPlan;
3564
+ preview.preApplyAuthorization = preApplyAuthorizationForPlan(initialPlan, previewPreparation.preparedTargets);
3489
3565
  const blockedTargets = [...previewPreparation.preparedTargets.values()].flatMap(({ target }) => {
3490
3566
  const receipts = target.platformDeployment?.blockedReceipts ?? [];
3491
3567
  if (!receipts.length)
@@ -3570,19 +3646,7 @@ async function runRebuildCommandInSession(options) {
3570
3646
  }
3571
3647
  let lockedPlan = await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory));
3572
3648
  assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(lockedPlan), exactSkillMarkerTargets(lockedPlan));
3573
- const lifecycleCommand = options.command === 'install'
3574
- || options.command === 'sync'
3575
- || options.command === 'reinstall';
3576
- const preApplyRequired = lifecycleCommand && executionSelections.some(({ entry, platform }) => entry.plugin.manifest.scripts?.preApply !== undefined
3577
- && lockedPlan.targets.some((target) => target.pluginId === entry.pluginId
3578
- && target.platform === platform
3579
- && target.action !== 'block'
3580
- && !isHealthyWiderDependency(target)));
3581
- if (preApplyRequired
3582
- && options.commandOptions.yes !== true
3583
- && options.runtime?.preApplyConfirmed !== true) {
3584
- throw namespacedPreflightError('preApplyAuthorizationRequired: Running plugin preApply requires --yes or an accepted Review.', preflightTargets);
3585
- }
3649
+ assertPreApplyAuthorization(lockedPlan);
3586
3650
  const provisionalLockedCodexPlans = await createCodexPlans(lockedPlan);
3587
3651
  const codexManagerRequired = provisionalLockedCodexPlans.some((plan) => plan.sharedNativeActions.some((action) => action.action === 'install'
3588
3652
  || action.action === 'replace'
@@ -3631,6 +3695,42 @@ async function runRebuildCommandInSession(options) {
3631
3695
  return 'install';
3632
3696
  return commandForTarget(selection, lockedPlan);
3633
3697
  };
3698
+ const deferredPreApply = new Set();
3699
+ let serialScriptGeneration = 0;
3700
+ const currentGeneration = () => admission?.exclusiveGeneration ?? serialScriptGeneration;
3701
+ let observationGeneration = initialGeneration;
3702
+ const refreshCodexObservation = (includeSerial = false) => {
3703
+ if (!admission && !includeSerial)
3704
+ return;
3705
+ const generation = currentGeneration();
3706
+ if (observationGeneration === generation)
3707
+ return;
3708
+ executionContext.codexObservationSession?.invalidate();
3709
+ observationGeneration = generation;
3710
+ };
3711
+ const prepareOperation = async (input) => {
3712
+ refreshCodexObservation();
3713
+ const prepared = await prepareRebuildOperation({ ...input, onActionEvent: async (event) => {
3714
+ if (event.data.name === 'preApply' && event.data.phase === 'start') {
3715
+ if (!admission)
3716
+ serialScriptGeneration++;
3717
+ try {
3718
+ options.runtime?.onInstallTargetState?.(input.target.identity, 'running');
3719
+ }
3720
+ catch { /* Progress observers cannot change execution. */ }
3721
+ }
3722
+ await emitRebuildActionEvent(executionContext, event);
3723
+ } });
3724
+ if (prepared.status === 'failed') {
3725
+ const diagnostic = prepared.result.failures.map((failure) => failure.operationDiagnostic)
3726
+ .find((failure) => failure && recoveryInterruptionCode(failure));
3727
+ if (diagnostic) {
3728
+ throw attachSafeOperationError(new Error(diagnostic.safeMessage), diagnostic);
3729
+ }
3730
+ executionContext.signal?.throwIfAborted();
3731
+ }
3732
+ return prepared;
3733
+ };
3634
3734
  const prepareLockedTargets = async (preparationOptions) => {
3635
3735
  const preparations = new Map();
3636
3736
  const failures = new Map();
@@ -3644,6 +3744,12 @@ async function runRebuildCommandInSession(options) {
3644
3744
  const { entry, platform } = selection;
3645
3745
  const key = executionKey(selection, lockedPlan);
3646
3746
  const planned = planTargetFor(lockedPlan, selection);
3747
+ const blocked = options.runtime?.nativeInstallBlockers?.get(key);
3748
+ if (blocked) {
3749
+ failures.set(key, failedResult(options.command, targetIdentity(selection, planned.resolvedScope), `${blocked}: ${entry.pluginId} requires a verified provider.`));
3750
+ states.set(key, 'failed');
3751
+ continue;
3752
+ }
3647
3753
  if (preparationOptions.eligibleKeys
3648
3754
  && !preparationOptions.eligibleKeys.has(key)) {
3649
3755
  states.set(key, isHealthyWiderDependency(planned) ? 'ready' : 'skipped');
@@ -3691,19 +3797,26 @@ async function runRebuildCommandInSession(options) {
3691
3797
  states.set(key, 'ready');
3692
3798
  continue;
3693
3799
  }
3694
- const preparedOperation = await prepareRebuildOperation({
3800
+ // A consumer's script can change external state. Wait for the provider's
3801
+ // actual execution result even when both targets passed native preflight.
3802
+ const hasScript = hasPlannedPreApply(prepared.target);
3803
+ if (entry.plugin.manifest.dependencies?.length && hasScript)
3804
+ deferredPreApply.add(key);
3805
+ const skipPreApply = preparationOptions.skipPreApply || deferredPreApply.has(key);
3806
+ const prepare = () => prepareOperation({
3695
3807
  command: executionCommand,
3696
3808
  target: prepared.target,
3697
3809
  driver: integration.driver,
3698
- ...(preparationOptions.skipPreApply ? { skipPreApply: true } : {}),
3810
+ skipPreApply,
3699
3811
  ...(preparationOptions.deferCodexNativeInspection
3700
3812
  && platform === 'codex'
3701
3813
  && executionContext.codexManager === undefined
3702
3814
  && (prepared.target.writeNativeRequired ?? prepared.target.requiresNative)
3703
3815
  ? { deferNativeInspection: true }
3704
3816
  : {}),
3705
- onActionEvent: (event) => emitRebuildActionEvent(executionContext, event),
3706
3817
  });
3818
+ const preparedOperation = admission && hasScript && !skipPreApply
3819
+ ? await admission.run([{ kind: 'exclusive' }], prepare, executionContext.signal) : await prepare();
3707
3820
  if (preparedOperation.status === 'failed') {
3708
3821
  failures.set(key, preparedOperation.result);
3709
3822
  states.set(key, 'failed');
@@ -3811,6 +3924,7 @@ async function runRebuildCommandInSession(options) {
3811
3924
  assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(lockedPlan), exactSkillMarkerTargets(lockedPlan));
3812
3925
  }
3813
3926
  lockedCodexPlans = await createCodexPlans(lockedPlan, 'observed', executionContext.codexManager);
3927
+ assertPreApplyAuthorization(lockedPlan);
3814
3928
  lockedPreparation = await prepareRenderedTargets(lockedPlan, lockedCodexPlans, false);
3815
3929
  const eligibleKeys = new Set(operationPreparations.keys());
3816
3930
  const initialOperationPreparations = new Map(operationPreparations);
@@ -3986,14 +4100,18 @@ async function runRebuildCommandInSession(options) {
3986
4100
  const preparedTargets = lockedPreparation.preparedTargets;
3987
4101
  const preparedTargetErrors = lockedPreparation.preparedTargetErrors;
3988
4102
  const removalRequiredConsumers = new Map();
4103
+ // A wider dependency that execution keeps cannot withdraw consumer output.
4104
+ const consumerCheckSelections = options.command === 'sync' ? executionSelections.filter((selection) => {
4105
+ const planned = planTargetFor(lockedPlan, selection);
4106
+ return !planned || !isHealthyWiderDependency(planned);
4107
+ }) : executionSelections;
4108
+ // Sync checks live references for Codex/Claude providers. Without a possible
4109
+ // consumer the second inventory cannot add a dependency to this plan.
4110
+ const syncNeedsConsumerCheck = options.command === 'sync' && consumerCheckSelections.some(({ platform, entry }) => (platform === 'codex' || platform === 'claude') && availableEntries.some((candidate) => candidate.source.sourceId === entry.source.sourceId && candidate.entry.dependencies.includes(entry.plugin.manifest.name)));
3989
4111
  if ((options.command === 'cleanup' && !cleanupForce)
3990
4112
  || (options.command === 'uninstall' && !uninstallForce)
3991
- || options.command === 'sync') {
3992
- const removalStateInventory = await readInventory({
3993
- cwd: options.commandOptions.cwd,
3994
- env: runtimeEnv,
3995
- scope: options.commandOptions.scope,
3996
- });
4113
+ || syncNeedsConsumerCheck) {
4114
+ const removalStateInventory = await readCurrentInventory();
3997
4115
  if (options.command !== 'cleanup') {
3998
4116
  const checked = options.command === 'uninstall'
3999
4117
  ? omitSelectedPluginConfigErrors(removalStateInventory, preflightTargets)
@@ -4072,7 +4190,7 @@ async function runRebuildCommandInSession(options) {
4072
4190
  projectKey: reference.projectKey ?? null,
4073
4191
  }]];
4074
4192
  })).values()];
4075
- for (const dependencyTarget of executionSelections) {
4193
+ for (const dependencyTarget of consumerCheckSelections) {
4076
4194
  const dependencyPluginName = dependencyTarget.entry.plugin.manifest.name;
4077
4195
  for (const consumer of currentConsumerCandidates) {
4078
4196
  if (consumer.entry.source.sourceId
@@ -4138,6 +4256,66 @@ async function runRebuildCommandInSession(options) {
4138
4256
  }
4139
4257
  const results = [];
4140
4258
  const dependencyStates = new Map();
4259
+ const directProviders = new Map(executionSelections.map((selection) => {
4260
+ const planned = planTargetFor(lockedPlan, selection);
4261
+ const dependencies = (selection.entry.plugin.manifest.dependencies ?? []).flatMap((pluginName) => {
4262
+ const pluginId = formatPluginId({ sourceId: selection.entry.source.sourceId, pluginName });
4263
+ const provider = dependencyTargetFor(lockedPlan, planned, pluginId);
4264
+ return provider ? [planExecutionKey(provider)] : [];
4265
+ });
4266
+ return [executionKey(selection, lockedPlan), dependencies];
4267
+ }));
4268
+ const providerKeys = new Set([...directProviders.values()].flat());
4269
+ const verifiedGenerations = new Map();
4270
+ const providerReady = (key) => ['completed', 'kept'].includes(dependencyStates.get(key) ?? '');
4271
+ const providersReady = (key) => directProviders.get(key).every(providerReady);
4272
+ const providerDeployment = (key) => {
4273
+ const deployment = preparedTargets.get(key)?.target.platformDeployment;
4274
+ return deployment?.plans.length && !deployment.blockedReceipts.length ? deployment : undefined;
4275
+ };
4276
+ // A provider's package check does not read its own providers. Include the
4277
+ // whole resolved closure after a script can invalidate earlier readback.
4278
+ const providerClosure = (key) => {
4279
+ const providers = new Set();
4280
+ const visit = (consumerKey) => {
4281
+ for (const providerKey of directProviders.get(consumerKey) ?? []) {
4282
+ if (providers.has(providerKey))
4283
+ continue;
4284
+ providers.add(providerKey);
4285
+ visit(providerKey);
4286
+ }
4287
+ };
4288
+ visit(key);
4289
+ return providers;
4290
+ };
4291
+ const verifyProviders = async (selection, key) => {
4292
+ const generation = currentGeneration();
4293
+ const target = preparedTargets.get(key)?.target;
4294
+ if (generation === initialGeneration || !directProviders.get(key)?.length
4295
+ || !target || !providersReady(key) || operationPreparationFailures.has(key))
4296
+ return;
4297
+ refreshCodexObservation(true);
4298
+ for (const provider of providerClosure(key)) {
4299
+ if (verifiedGenerations.get(provider) === generation)
4300
+ continue;
4301
+ try {
4302
+ const deployment = providerDeployment(provider);
4303
+ if (!providerReady(provider) || !deployment) {
4304
+ throw new Error('Dependency evidence is unavailable.');
4305
+ }
4306
+ await deployment.verify();
4307
+ }
4308
+ catch (error) {
4309
+ if (recoveryInterruptionCode(error, executionContext.signal))
4310
+ throw error;
4311
+ const failure = failedResult(selection.requestedMethod ?? options.command, target.identity, `dependencyInstallFailed: ${provider.split('\0', 1)[0]} could not be reverified before publishing ${selection.entry.pluginId}.`);
4312
+ failure.actions = operationPreparations.get(key)?.actions ?? [];
4313
+ operationPreparationFailures.set(key, failure);
4314
+ return;
4315
+ }
4316
+ verifiedGenerations.set(provider, generation);
4317
+ }
4318
+ };
4141
4319
  const nativeTargetExecution = lifecycleCommand ? options.runtime?.nativeTargetExecution : undefined;
4142
4320
  const recordTargetCommands = (commands) => {
4143
4321
  executionContext.commandResults ??= [];
@@ -4146,19 +4324,29 @@ async function runRebuildCommandInSession(options) {
4146
4324
  executionContext.commandResults.push(result);
4147
4325
  }
4148
4326
  };
4149
- for (const selection of executionSelections) {
4327
+ const prepareDependentScript = async (selection, key) => {
4328
+ if (!deferredPreApply.has(key) || operationPreparationFailures.has(key))
4329
+ return;
4330
+ const target = preparedTargets.get(key).target;
4331
+ const command = executionCommandFor(selection);
4332
+ if (command === 'cleanup' || command === 'uninstall')
4333
+ return;
4334
+ const preparation = await prepareOperation({ command, target, driver: lockedPreparation.integration.driver });
4335
+ if (preparation.status === 'failed')
4336
+ operationPreparationFailures.set(key, preparation.result);
4337
+ else
4338
+ operationPreparations.set(key, preparation.preparation);
4339
+ };
4340
+ const executeSelection = async (selection, index) => {
4341
+ const record = (result) => { results[index] = result; };
4150
4342
  const { entry, platform } = selection;
4151
4343
  const planned = planTargetFor(lockedPlan, selection);
4152
4344
  const key = executionKey(selection, lockedPlan);
4153
4345
  const requestedMethod = selection.requestedMethod ?? options.command;
4154
- const directDependencyIds = (entry.plugin.manifest.dependencies ?? []).map((pluginName) => formatPluginId({ sourceId: entry.source.sourceId, pluginName }));
4155
- const failedDependency = directDependencyIds.find((pluginId) => {
4156
- const dependency = dependencyTargetFor(lockedPlan, planned, pluginId);
4157
- const state = dependency
4158
- ? dependencyStates.get(planExecutionKey(dependency))
4159
- : undefined;
4346
+ const failedDependency = directProviders.get(key).find((provider) => {
4347
+ const state = dependencyStates.get(provider);
4160
4348
  return state === 'failed' || state === 'skipped';
4161
- });
4349
+ })?.split('\0', 1)[0];
4162
4350
  const failedConsumer = [...(removalRequiredConsumers.get(key) ?? [])]
4163
4351
  .find((consumerKey) => {
4164
4352
  const state = dependencyStates.get(consumerKey);
@@ -4197,7 +4385,7 @@ async function runRebuildCommandInSession(options) {
4197
4385
  ? `${entry.pluginId} remains required by an unselected declared root.`
4198
4386
  : `${entry.pluginId} dependency preflight is blocked.`}`;
4199
4387
  const result = failedResult(requestedMethod, identity, message);
4200
- results.push({
4388
+ record({
4201
4389
  platforms: [platform], plugins: [], warnings: [], rebuildResults: [result],
4202
4390
  targetResults: [{
4203
4391
  target: identity,
@@ -4219,10 +4407,25 @@ async function runRebuildCommandInSession(options) {
4219
4407
  }],
4220
4408
  });
4221
4409
  dependencyStates.set(key, failedDependency || failedConsumer ? 'skipped' : 'failed');
4222
- continue;
4410
+ return;
4411
+ }
4412
+ // Target execution normally verifies its deployment immediately before writing.
4413
+ // A producer or a retained target can finish without entering that executor.
4414
+ if ((admission || providerKeys.has(key)) && currentGeneration() !== initialGeneration
4415
+ && (planned.action === 'keep' || reconcileActivationOnly || nativeTargetExecution && (nativeTargetExecution.produces?.(identity) ?? true))
4416
+ && !operationPreparationFailures.has(key)) {
4417
+ try {
4418
+ refreshCodexObservation(true);
4419
+ await preparedTargets.get(key)?.target.platformDeployment?.verify();
4420
+ }
4421
+ catch (error) {
4422
+ if (recoveryInterruptionCode(error, executionContext.signal))
4423
+ throw error;
4424
+ operationPreparationFailures.set(key, failedResult(requestedMethod, identity, error instanceof Error ? error.message : String(error)));
4425
+ }
4223
4426
  }
4224
- if (isHealthyWiderDependency(planned)) {
4225
- results.push({
4427
+ if (isHealthyWiderDependency(planned) && !operationPreparationFailures.has(key)) {
4428
+ record({
4226
4429
  platforms: [platform], plugins: [identity.pluginName], warnings: [], rebuildResults: [],
4227
4430
  targetResults: [{ target: identity, action: 'keep', state: 'completed' }],
4228
4431
  overallState: 'succeeded',
@@ -4232,13 +4435,13 @@ async function runRebuildCommandInSession(options) {
4232
4435
  }],
4233
4436
  });
4234
4437
  dependencyStates.set(key, 'kept');
4235
- continue;
4438
+ return;
4236
4439
  }
4237
4440
  const operationPreparationFailure = operationPreparationFailures.get(key);
4238
4441
  if (operationPreparationFailure) {
4239
4442
  const targetResult = toTargetResult(operationPreparationFailure);
4240
4443
  recordTargetCommands(nativeTargetExecution?.blocked?.(identity, targetResult.errorCode ?? 'targetPreparationFailed') ?? []);
4241
- results.push({
4444
+ record({
4242
4445
  platforms: [platform],
4243
4446
  plugins: [],
4244
4447
  warnings: [],
@@ -4254,7 +4457,7 @@ async function runRebuildCommandInSession(options) {
4254
4457
  }],
4255
4458
  });
4256
4459
  dependencyStates.set(key, 'failed');
4257
- continue;
4460
+ return;
4258
4461
  }
4259
4462
  if (nativeTargetExecution) {
4260
4463
  let packageFailure;
@@ -4266,15 +4469,14 @@ async function runRebuildCommandInSession(options) {
4266
4469
  }
4267
4470
  }
4268
4471
  catch (error) {
4269
- executionContext.signal?.throwIfAborted();
4270
- if (error instanceof Error && error.name === 'AbortError')
4472
+ if (recoveryInterruptionCode(error, executionContext.signal))
4271
4473
  throw error;
4272
4474
  packageFailure = 'commandPackageApplyFailed';
4273
4475
  recordTargetCommands(nativeTargetExecution.blocked?.(identity, packageFailure) ?? []);
4274
4476
  }
4275
4477
  if (packageFailure) {
4276
4478
  const result = failedResult(requestedMethod, identity, `${packageFailure}: ${entry.pluginId} requires a completed command package provider.`);
4277
- results.push({
4479
+ record({
4278
4480
  platforms: [platform], plugins: [], warnings: [], rebuildResults: [result],
4279
4481
  targetResults: [{ ...toTargetResult(result), action: planned.action }],
4280
4482
  overallState: 'failed',
@@ -4284,7 +4486,7 @@ async function runRebuildCommandInSession(options) {
4284
4486
  }],
4285
4487
  });
4286
4488
  dependencyStates.set(key, 'failed');
4287
- continue;
4489
+ return;
4288
4490
  }
4289
4491
  }
4290
4492
  if (reconcileActivationOnly) {
@@ -4294,7 +4496,7 @@ async function runRebuildCommandInSession(options) {
4294
4496
  ? preparedError.message
4295
4497
  : String(preparedError);
4296
4498
  const result = failedResult(requestedMethod, identity, message);
4297
- results.push({
4499
+ record({
4298
4500
  platforms: [platform], plugins: [], warnings: [], rebuildResults: [result],
4299
4501
  targetResults: [{
4300
4502
  target: identity,
@@ -4310,7 +4512,7 @@ async function runRebuildCommandInSession(options) {
4310
4512
  }],
4311
4513
  });
4312
4514
  dependencyStates.set(key, 'failed');
4313
- continue;
4515
+ return;
4314
4516
  }
4315
4517
  const actions = operationPreparations.get(key)?.actions
4316
4518
  ?? [];
@@ -4320,7 +4522,7 @@ async function runRebuildCommandInSession(options) {
4320
4522
  actions,
4321
4523
  cleanupAttempted: false, removed: [], absent: [], residual: [], quarantined: [], failures: [],
4322
4524
  };
4323
- results.push({
4525
+ record({
4324
4526
  platforms: [platform],
4325
4527
  plugins: result.status === 'succeeded' ? [identity.pluginName] : [],
4326
4528
  warnings: result.failures.map((failure) => failure.message),
@@ -4340,7 +4542,7 @@ async function runRebuildCommandInSession(options) {
4340
4542
  }],
4341
4543
  });
4342
4544
  dependencyStates.set(key, result.status === 'succeeded' ? 'completed' : 'failed');
4343
- continue;
4545
+ return;
4344
4546
  }
4345
4547
  if (planned.action === 'keep'
4346
4548
  && !(preparedTargets.get(key)?.target.writeNativeRequired ?? false)
@@ -4352,7 +4554,7 @@ async function runRebuildCommandInSession(options) {
4352
4554
  ? preparedError.message
4353
4555
  : String(preparedError);
4354
4556
  const result = failedResult(requestedMethod, identity, message);
4355
- results.push({
4557
+ record({
4356
4558
  platforms: [platform], plugins: [], warnings: [], rebuildResults: [result],
4357
4559
  targetResults: [{
4358
4560
  target: identity,
@@ -4368,7 +4570,7 @@ async function runRebuildCommandInSession(options) {
4368
4570
  }],
4369
4571
  });
4370
4572
  dependencyStates.set(key, 'failed');
4371
- continue;
4573
+ return;
4372
4574
  }
4373
4575
  const actions = operationPreparations.get(key)?.actions
4374
4576
  ?? [];
@@ -4377,7 +4579,7 @@ async function runRebuildCommandInSession(options) {
4377
4579
  actions,
4378
4580
  cleanupAttempted: false, removed: [], absent: [], residual: [], quarantined: [], failures: [],
4379
4581
  };
4380
- results.push({
4582
+ record({
4381
4583
  platforms: [platform], plugins: [identity.pluginName], warnings: [], rebuildResults: [result],
4382
4584
  targetResults: [{ target: identity, action: 'keep', state: 'completed' }],
4383
4585
  overallState: 'succeeded',
@@ -4387,7 +4589,7 @@ async function runRebuildCommandInSession(options) {
4387
4589
  }],
4388
4590
  });
4389
4591
  dependencyStates.set(key, 'kept');
4390
- continue;
4592
+ return;
4391
4593
  }
4392
4594
  const marketplaceName = marketplaceNameFor(entry, platform, planned.resolvedScope);
4393
4595
  const namespacedSource = {
@@ -4442,11 +4644,11 @@ async function runRebuildCommandInSession(options) {
4442
4644
  preparationError: preparedTargetErrors.get(key),
4443
4645
  },
4444
4646
  });
4445
- results.push(executionResult);
4647
+ record(executionResult);
4446
4648
  dependencyStates.set(key, executionResult.overallState === 'succeeded' ? 'completed' : 'failed');
4447
- }
4649
+ };
4448
4650
  const failCompletedCodexTarget = (options_) => {
4449
- const resultIndex = results.findIndex((candidate) => candidate.targetResults.some((target) => target.target.pluginId === options_.identity.pluginId
4651
+ const resultIndex = results.findIndex((candidate) => candidate?.targetResults.some((target) => target.target.pluginId === options_.identity.pluginId
4450
4652
  && target.target.platform === 'codex'
4451
4653
  && target.target.scope === options_.identity.scope));
4452
4654
  if (resultIndex === -1)
@@ -4496,182 +4698,356 @@ async function runRebuildCommandInSession(options) {
4496
4698
  ].join('\0'), 'failed');
4497
4699
  return true;
4498
4700
  };
4499
- const activationMutationPluginIds = new Set(lockedCodexPlans.flatMap((plan) => [
4500
- ...plan.activationActions.user,
4501
- ...plan.activationActions.project,
4502
- ].flatMap((action) => action.action === 'none' ? [] : [action.pluginId])));
4503
- for (const selection of executionSelections) {
4504
- const { entry, platform } = selection;
4505
- const key = executionKey(selection, lockedPlan);
4506
- if (platform !== 'codex'
4507
- || !activationMutationPluginIds.has(entry.pluginId)
4508
- || (dependencyStates.get(key) !== 'completed'
4509
- && dependencyStates.get(key) !== 'kept'))
4510
- continue;
4511
- const prepared = preparedTargets.get(key)?.target;
4512
- if (!prepared)
4513
- continue;
4701
+ const codexSelections = executionSelections.filter(({ platform }) => platform === 'codex');
4702
+ const codexProviders = new Set(options.runtime?.batchInstallPlatform === 'codex' || deferredPreApply.size || serialScriptGeneration
4703
+ ? codexSelections.flatMap((selection) => directProviders.get(executionKey(selection, lockedPlan))) : []);
4704
+ const reportTargetState = (selection, state) => {
4705
+ const identity = targetIdentity(selection, planTargetFor(lockedPlan, selection).resolvedScope);
4514
4706
  try {
4515
- await lockedPreparation.integration.prepareNativeMarketplaceGroup(prepared);
4707
+ options.runtime?.onInstallTargetState?.(identity, state);
4516
4708
  }
4517
- catch (error) {
4518
- const message = error instanceof Error ? error.message : String(error);
4519
- failCompletedCodexTarget({ identity: prepared.identity, message, phase: 'native.write' });
4520
- }
4521
- }
4522
- const successfulCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
4523
- && (dependencyStates.get(executionKey(selection, lockedPlan)) === 'completed'
4524
- || dependencyStates.get(executionKey(selection, lockedPlan)) === 'kept')
4525
- ? [`${selection.entry.pluginId}\0${planTargetFor(lockedPlan, selection).resolvedScope}`]
4526
- : []));
4527
- const activationUserBefore = await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'user', runtimeEnv).configTomlPath);
4528
- const activationProjectBefore = options.commandOptions.scope === 'project'
4529
- ? await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'project', runtimeEnv).configTomlPath)
4530
- : undefined;
4531
- const preservedActivations = {
4532
- user: new Map(Object.entries(activationUserBefore.snapshot.plugins)
4533
- .map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
4534
- project: new Map(Object.entries(activationProjectBefore?.snapshot.plugins ?? {})
4535
- .map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
4709
+ catch { /* Progress observers cannot change a target's outcome. */ }
4536
4710
  };
4537
- const activationPlans = selectCodexActivationPlans(lockedCodexPlans, successfulCodexTargetScopes, preservedActivations, originalUserActivations);
4538
- if (activationPlans.length > 0
4539
- || lockedPreparation.integration.driver.completePostchecks) {
4540
- let activationError;
4541
- const activationMutationMarketplaces = new Set();
4542
- try {
4543
- if (activationPlans.length > 0) {
4544
- await executeCodexReconcileActivations({
4545
- plans: activationPlans,
4546
- cwd: options.commandOptions.cwd,
4547
- env: runtimeEnv,
4548
- manager: executionContext.codexManager,
4549
- runner: executionContext.nativeCliRunner,
4550
- observationSession: executionContext.codexObservationSession,
4551
- preflightCompleted: true,
4552
- mutationMarketplaces: activationMutationMarketplaces,
4553
- observationScopeByMarketplace: codexObservationScopeByMarketplace,
4554
- });
4711
+ const pendingCodex = new Set();
4712
+ const runSelection = async (selection, index) => {
4713
+ reportTargetState(selection, 'running');
4714
+ refreshCodexObservation();
4715
+ await executeSelection(selection, index);
4716
+ const key = executionKey(selection, lockedPlan);
4717
+ if (selection.platform === 'codex')
4718
+ pendingCodex.add(selection);
4719
+ const unconfirmed = results[index]?.rebuildResults.flatMap((result) => [
4720
+ ...result.failures.flatMap((failure) => failure.operationDiagnostic ? [failure.operationDiagnostic] : []),
4721
+ ...(result.deploymentReceipts ?? []).flatMap((receipt) => receipt.diagnostics),
4722
+ ]).find((diagnostic) => recoveryInterruptionCode(diagnostic) === 'processCleanupUnconfirmed');
4723
+ if (unconfirmed) {
4724
+ const message = 'safeMessage' in unconfirmed ? unconfirmed.safeMessage : unconfirmed.message;
4725
+ throw attachSafeOperationError(new Error(message), { code: unconfirmed.code, safeMessage: message });
4726
+ }
4727
+ if (selection.platform === 'codex') {
4728
+ const prepared = preparedTargets.get(key)?.target;
4729
+ if (codexProviders.has(key) && prepared && providerReady(key)) {
4730
+ try {
4731
+ await lockedPreparation.integration.postcheckCodexProvider(prepared);
4732
+ }
4733
+ catch (error) {
4734
+ if (recoveryInterruptionCode(error, executionContext.signal))
4735
+ throw error;
4736
+ failCompletedCodexTarget({ identity: prepared.identity, message: error instanceof Error ? error.message : String(error) });
4737
+ }
4555
4738
  }
4739
+ if (providerReady(key) && providerDeployment(key))
4740
+ verifiedGenerations.set(key, currentGeneration());
4741
+ if (!codexProviders.has(key))
4742
+ return;
4743
+ pendingCodex.delete(selection);
4556
4744
  }
4557
- catch (error) {
4558
- activationError = error;
4745
+ else if (providerReady(key) && providerDeployment(key)) {
4746
+ verifiedGenerations.set(key, currentGeneration());
4559
4747
  }
4560
- try {
4561
- await lockedPreparation.integration.captureCodexPostMutationSnapshots([...activationMutationMarketplaces]);
4748
+ reportTargetState(selection, 'completed');
4749
+ };
4750
+ const finishCodex = async () => {
4751
+ refreshCodexObservation();
4752
+ for (const selection of codexSelections) {
4753
+ const key = executionKey(selection, lockedPlan);
4754
+ if (!admission || admission.exclusiveGeneration === verifiedGenerations.get(key))
4755
+ continue;
4756
+ const target = preparedTargets.get(key)?.target;
4757
+ if (target && ['completed', 'kept'].includes(dependencyStates.get(key) ?? '')) {
4758
+ try {
4759
+ await target.platformDeployment?.verify();
4760
+ }
4761
+ catch (error) {
4762
+ if (recoveryInterruptionCode(error, executionContext.signal))
4763
+ throw error;
4764
+ failCompletedCodexTarget({ identity: target.identity, message: error instanceof Error ? error.message : String(error) });
4765
+ }
4766
+ }
4562
4767
  }
4563
- catch (error) {
4564
- activationError ??= error;
4768
+ const activationMutationPluginIds = new Set(lockedCodexPlans.flatMap((plan) => [
4769
+ ...plan.activationActions.user,
4770
+ ...plan.activationActions.project,
4771
+ ].flatMap((action) => action.action === 'none' ? [] : [action.pluginId])));
4772
+ for (const selection of executionSelections) {
4773
+ const { entry, platform } = selection;
4774
+ const key = executionKey(selection, lockedPlan);
4775
+ if (platform !== 'codex'
4776
+ || !activationMutationPluginIds.has(entry.pluginId)
4777
+ || (dependencyStates.get(key) !== 'completed'
4778
+ && dependencyStates.get(key) !== 'kept'))
4779
+ continue;
4780
+ const prepared = preparedTargets.get(key)?.target;
4781
+ if (!prepared)
4782
+ continue;
4783
+ try {
4784
+ await lockedPreparation.integration.prepareNativeMarketplaceGroup(prepared);
4785
+ }
4786
+ catch (error) {
4787
+ const message = error instanceof Error ? error.message : String(error);
4788
+ failCompletedCodexTarget({ identity: prepared.identity, message, phase: 'native.write' });
4789
+ }
4565
4790
  }
4566
- const failedCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
4567
- && (dependencyStates.get(executionKey(selection, lockedPlan)) === 'failed'
4568
- || dependencyStates.get(executionKey(selection, lockedPlan)) === 'skipped')
4791
+ const successfulCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
4792
+ && (dependencyStates.get(executionKey(selection, lockedPlan)) === 'completed'
4793
+ || dependencyStates.get(executionKey(selection, lockedPlan)) === 'kept')
4569
4794
  ? [`${selection.entry.pluginId}\0${planTargetFor(lockedPlan, selection).resolvedScope}`]
4570
4795
  : []));
4571
- for (const failure of await lockedPreparation.integration.driver.completePostchecks?.() ?? []) {
4572
- const message = failure.error instanceof Error
4573
- ? failure.error.message
4574
- : String(failure.error);
4575
- if (failCompletedCodexTarget({ identity: failure.target.identity, message })) {
4576
- const failedPluginId = failure.target.identity.pluginId
4577
- ?? failure.target.identity.pluginName;
4578
- failedCodexTargetScopes.add(`${failedPluginId}\0${failure.target.identity.scope}`);
4579
- }
4580
- }
4581
- if (!activationError && activationPlans.length > 0) {
4582
- const postcheckTargetScopes = new Set([...successfulCodexTargetScopes]
4583
- .filter((key) => !failedCodexTargetScopes.has(key)));
4584
- const postcheckPlans = selectCodexActivationPlans(activationPlans, postcheckTargetScopes, preservedActivations, originalUserActivations);
4796
+ const activationUserBefore = await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'user', runtimeEnv).configTomlPath);
4797
+ const activationProjectBefore = options.commandOptions.scope === 'project'
4798
+ ? await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'project', runtimeEnv).configTomlPath)
4799
+ : undefined;
4800
+ const preservedActivations = {
4801
+ user: new Map(Object.entries(activationUserBefore.snapshot.plugins)
4802
+ .map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
4803
+ project: new Map(Object.entries(activationProjectBefore?.snapshot.plugins ?? {})
4804
+ .map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
4805
+ };
4806
+ const activationPlans = selectCodexActivationPlans(lockedCodexPlans, successfulCodexTargetScopes, preservedActivations, originalUserActivations);
4807
+ if (activationPlans.length > 0
4808
+ || lockedPreparation.integration.driver.completePostchecks) {
4809
+ let activationError;
4810
+ const activationMutationMarketplaces = new Set();
4585
4811
  try {
4586
- await postcheckCodexReconcileActivations({
4587
- plans: postcheckPlans,
4588
- cwd: options.commandOptions.cwd,
4589
- env: runtimeEnv,
4590
- manager: executionContext.codexManager,
4591
- runner: executionContext.nativeCliRunner,
4592
- observationScopeByMarketplace: codexObservationScopeByMarketplace,
4593
- observationSession: executionContext.codexObservationSession,
4594
- });
4812
+ if (activationPlans.length > 0) {
4813
+ await executeCodexReconcileActivations({
4814
+ plans: activationPlans,
4815
+ cwd: options.commandOptions.cwd,
4816
+ env: runtimeEnv,
4817
+ manager: executionContext.codexManager,
4818
+ runner: executionContext.nativeCliRunner,
4819
+ observationSession: executionContext.codexObservationSession,
4820
+ preflightCompleted: true,
4821
+ mutationMarketplaces: activationMutationMarketplaces,
4822
+ observationScopeByMarketplace: codexObservationScopeByMarketplace,
4823
+ });
4824
+ }
4595
4825
  }
4596
4826
  catch (error) {
4597
4827
  activationError = error;
4598
4828
  }
4599
- }
4600
- if (activationError) {
4601
- const failedActivationTargetScopes = failedCodexActivationTargetScopes({
4602
- error: activationError,
4603
- plans: activationPlans,
4604
- successfulTargetScopes: successfulCodexTargetScopes,
4605
- });
4606
- const message = activationError instanceof Error
4607
- ? activationError.message
4608
- : String(activationError);
4609
- const failedSelections = executionSelections.filter((candidate) => candidate.platform === 'codex'
4610
- && failedActivationTargetScopes.has(`${candidate.entry.pluginId}\0${planTargetFor(lockedPlan, candidate).resolvedScope}`));
4611
- if (failedSelections.length === 0)
4612
- throw activationError;
4613
- for (const selection of failedSelections) {
4614
- const planned = planTargetFor(lockedPlan, selection);
4615
- const identity = {
4616
- sourceId: selection.entry.source.sourceId,
4617
- sourceIdentity: selection.entry.source.sourceIdentity,
4618
- pluginId: selection.entry.pluginId,
4619
- pluginName: selection.entry.plugin.manifest.name,
4620
- pluginVersion: selection.entry.plugin.manifest.version,
4621
- platform: 'codex',
4622
- scope: planned.resolvedScope,
4623
- cwd: options.commandOptions.cwd,
4624
- };
4625
- if (!failCompletedCodexTarget({ identity, message }))
4829
+ try {
4830
+ await lockedPreparation.integration.captureCodexPostMutationSnapshots([...activationMutationMarketplaces]);
4831
+ }
4832
+ catch (error) {
4833
+ activationError ??= error;
4834
+ }
4835
+ const failedCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
4836
+ && (dependencyStates.get(executionKey(selection, lockedPlan)) === 'failed'
4837
+ || dependencyStates.get(executionKey(selection, lockedPlan)) === 'skipped')
4838
+ ? [`${selection.entry.pluginId}\0${planTargetFor(lockedPlan, selection).resolvedScope}`]
4839
+ : []));
4840
+ for (const failure of await lockedPreparation.integration.driver.completePostchecks?.() ?? []) {
4841
+ if (recoveryInterruptionCode(failure.error, executionContext.signal))
4842
+ throw failure.error;
4843
+ const message = failure.error instanceof Error
4844
+ ? failure.error.message
4845
+ : String(failure.error);
4846
+ if (failCompletedCodexTarget({ identity: failure.target.identity, message })) {
4847
+ const failedPluginId = failure.target.identity.pluginId
4848
+ ?? failure.target.identity.pluginName;
4849
+ failedCodexTargetScopes.add(`${failedPluginId}\0${failure.target.identity.scope}`);
4850
+ }
4851
+ }
4852
+ if (!activationError && activationPlans.length > 0) {
4853
+ const postcheckTargetScopes = new Set([...successfulCodexTargetScopes]
4854
+ .filter((key) => !failedCodexTargetScopes.has(key)));
4855
+ const postcheckPlans = selectCodexActivationPlans(activationPlans, postcheckTargetScopes, preservedActivations, originalUserActivations);
4856
+ try {
4857
+ await postcheckCodexReconcileActivations({
4858
+ plans: postcheckPlans,
4859
+ cwd: options.commandOptions.cwd,
4860
+ env: runtimeEnv,
4861
+ manager: executionContext.codexManager,
4862
+ runner: executionContext.nativeCliRunner,
4863
+ observationScopeByMarketplace: codexObservationScopeByMarketplace,
4864
+ observationSession: executionContext.codexObservationSession,
4865
+ });
4866
+ }
4867
+ catch (error) {
4868
+ activationError = error;
4869
+ }
4870
+ }
4871
+ if (activationError) {
4872
+ if (recoveryInterruptionCode(activationError, executionContext.signal))
4873
+ throw activationError;
4874
+ const failedActivationTargetScopes = failedCodexActivationTargetScopes({
4875
+ error: activationError,
4876
+ plans: activationPlans,
4877
+ successfulTargetScopes: successfulCodexTargetScopes,
4878
+ });
4879
+ const message = activationError instanceof Error
4880
+ ? activationError.message
4881
+ : String(activationError);
4882
+ const failedSelections = executionSelections.filter((candidate) => candidate.platform === 'codex'
4883
+ && failedActivationTargetScopes.has(`${candidate.entry.pluginId}\0${planTargetFor(lockedPlan, candidate).resolvedScope}`));
4884
+ if (failedSelections.length === 0)
4626
4885
  throw activationError;
4627
- failedCodexTargetScopes.add(`${selection.entry.pluginId}\0${planned.resolvedScope}`);
4886
+ for (const selection of failedSelections) {
4887
+ const planned = planTargetFor(lockedPlan, selection);
4888
+ const identity = {
4889
+ sourceId: selection.entry.source.sourceId,
4890
+ sourceIdentity: selection.entry.source.sourceIdentity,
4891
+ pluginId: selection.entry.pluginId,
4892
+ pluginName: selection.entry.plugin.manifest.name,
4893
+ pluginVersion: selection.entry.plugin.manifest.version,
4894
+ platform: 'codex',
4895
+ scope: planned.resolvedScope,
4896
+ cwd: options.commandOptions.cwd,
4897
+ };
4898
+ if (!failCompletedCodexTarget({ identity, message }))
4899
+ throw activationError;
4900
+ failedCodexTargetScopes.add(`${selection.entry.pluginId}\0${planned.resolvedScope}`);
4901
+ }
4902
+ }
4903
+ let propagated = true;
4904
+ while (propagated) {
4905
+ propagated = false;
4906
+ for (const selection of executionSelections.filter((candidate) => candidate.platform === 'codex')) {
4907
+ const planned = planTargetFor(lockedPlan, selection);
4908
+ const targetScopeKey = `${selection.entry.pluginId}\0${planned.resolvedScope}`;
4909
+ if (failedCodexTargetScopes.has(targetScopeKey))
4910
+ continue;
4911
+ const failedDependency = (selection.entry.plugin.manifest.dependencies ?? [])
4912
+ .map((pluginName) => formatPluginId({
4913
+ sourceId: selection.entry.source.sourceId,
4914
+ pluginName,
4915
+ }))
4916
+ .find((pluginId) => {
4917
+ const dependency = dependencyTargetFor(lockedPlan, planned, pluginId);
4918
+ return dependency
4919
+ ? failedCodexTargetScopes.has(`${pluginId}\0${dependency.requestedScope ?? dependency.resolvedScope}`)
4920
+ : false;
4921
+ });
4922
+ if (!failedDependency)
4923
+ continue;
4924
+ const identity = {
4925
+ sourceId: selection.entry.source.sourceId,
4926
+ sourceIdentity: selection.entry.source.sourceIdentity,
4927
+ pluginId: selection.entry.pluginId,
4928
+ pluginName: selection.entry.plugin.manifest.name,
4929
+ pluginVersion: selection.entry.plugin.manifest.version,
4930
+ platform: 'codex',
4931
+ scope: planned.resolvedScope,
4932
+ cwd: options.commandOptions.cwd,
4933
+ };
4934
+ const message = `dependencyInstallFailed: ${selection.entry.pluginId} requires failed dependency ${failedDependency}.`;
4935
+ if (failCompletedCodexTarget({
4936
+ identity,
4937
+ message,
4938
+ recoveryActions: [
4939
+ `run aw plugin sync ${selection.entry.pluginId} --target codex --context ${planned.resolvedScope}`,
4940
+ ],
4941
+ })) {
4942
+ failedCodexTargetScopes.add(targetScopeKey);
4943
+ dependencyStates.set(executionKey(selection, lockedPlan), 'failed');
4944
+ propagated = true;
4945
+ }
4946
+ }
4628
4947
  }
4629
4948
  }
4630
- let propagated = true;
4631
- while (propagated) {
4632
- propagated = false;
4633
- for (const selection of executionSelections.filter((candidate) => candidate.platform === 'codex')) {
4634
- const planned = planTargetFor(lockedPlan, selection);
4635
- const targetScopeKey = `${selection.entry.pluginId}\0${planned.resolvedScope}`;
4636
- if (failedCodexTargetScopes.has(targetScopeKey))
4637
- continue;
4638
- const failedDependency = (selection.entry.plugin.manifest.dependencies ?? [])
4639
- .map((pluginName) => formatPluginId({
4640
- sourceId: selection.entry.source.sourceId,
4641
- pluginName,
4642
- }))
4643
- .find((pluginId) => {
4644
- const dependency = dependencyTargetFor(lockedPlan, planned, pluginId);
4645
- return dependency
4646
- ? failedCodexTargetScopes.has(`${pluginId}\0${dependency.requestedScope ?? dependency.resolvedScope}`)
4647
- : false;
4648
- });
4649
- if (!failedDependency)
4650
- continue;
4651
- const identity = {
4652
- sourceId: selection.entry.source.sourceId,
4653
- sourceIdentity: selection.entry.source.sourceIdentity,
4654
- pluginId: selection.entry.pluginId,
4655
- pluginName: selection.entry.plugin.manifest.name,
4656
- pluginVersion: selection.entry.plugin.manifest.version,
4657
- platform: 'codex',
4658
- scope: planned.resolvedScope,
4659
- cwd: options.commandOptions.cwd,
4660
- };
4661
- const message = `dependencyInstallFailed: ${selection.entry.pluginId} requires failed dependency ${failedDependency}.`;
4662
- if (failCompletedCodexTarget({
4663
- identity,
4664
- message,
4665
- recoveryActions: [
4666
- `run aw plugin sync ${selection.entry.pluginId} --target codex --context ${planned.resolvedScope}`,
4667
- ],
4668
- })) {
4669
- failedCodexTargetScopes.add(targetScopeKey);
4670
- dependencyStates.set(executionKey(selection, lockedPlan), 'failed');
4671
- propagated = true;
4949
+ };
4950
+ const privatePackages = [];
4951
+ try {
4952
+ if (admission && options.runtime?.batchInstallPlatform) {
4953
+ const selectedKeys = new Set(executionSelections.map((selection) => executionKey(selection, lockedPlan)));
4954
+ const tasks = executionSelections.flatMap((selection, index) => {
4955
+ const id = executionKey(selection, lockedPlan);
4956
+ const dependencies = directProviders.get(id).filter((key) => selectedKeys.has(key));
4957
+ const target = lockedPreparation.preparedTargets.get(id)?.target;
4958
+ const deployment = target?.platformDeployment;
4959
+ const resources = nativeInstallResources(deployment?.plans ?? []);
4960
+ const producesCommands = target && nativeTargetExecution
4961
+ && (nativeTargetExecution.produces?.(target.identity) ?? true);
4962
+ if (deployment?.writesManagedCommands || producesCommands
4963
+ || target?.operationActions?.some((action) => action.kind === 'syncManagedCommandPackage')) {
4964
+ resources.push({ kind: 'path', value: path.join(resolveAwHome(runtimeEnv), 'commands') });
4965
+ }
4966
+ const leaves = [];
4967
+ let prerequisites = dependencies;
4968
+ const providerPlans = [...providerClosure(id)].flatMap((key) => preparedTargets.get(key)?.target.platformDeployment?.plans ?? []);
4969
+ if (providerPlans.length)
4970
+ for (const resource of nativeInstallResources(providerPlans)) {
4971
+ resources.push(resource.kind === 'exclusive' ? resource : { ...resource, access: 'read' });
4972
+ }
4973
+ if (deferredPreApply.has(id) && operationPreparations.has(id)) {
4974
+ const script = `preApply:\0${id}`;
4975
+ leaves.push({ id: script, dependencies, resources: [{ kind: 'exclusive' }], run: async () => {
4976
+ if (!providersReady(id))
4977
+ return;
4978
+ await verifyProviders(selection, id);
4979
+ await prepareDependentScript(selection, id);
4980
+ } });
4981
+ prerequisites = [script];
4982
+ }
4983
+ const staging = deployment?.privatePackage;
4984
+ if (staging && executionSelections.length >= 2 && operationPreparations.has(id)) {
4985
+ privatePackages.push(staging);
4986
+ const stage = `package-staging:\0${id}`;
4987
+ leaves.push({ id: stage, dependencies: prerequisites, resources: [], run: async () => {
4988
+ if (!providersReady(id) || operationPreparationFailures.has(id))
4989
+ return;
4990
+ reportTargetState(selection, 'running');
4991
+ try {
4992
+ await staging.prepare();
4993
+ }
4994
+ catch (error) {
4995
+ if (recoveryInterruptionCode(error, executionContext.signal))
4996
+ throw error;
4997
+ operationPreparationFailures.set(id, failedResult(options.command, target.identity, error instanceof Error ? error.message : String(error)));
4998
+ }
4999
+ } });
5000
+ prerequisites = [stage];
5001
+ }
5002
+ leaves.push({ id, dependencies: prerequisites, resources, run: async () => {
5003
+ await verifyProviders(selection, id);
5004
+ await runSelection(selection, index);
5005
+ } });
5006
+ return leaves;
5007
+ });
5008
+ await runInstallTasks(tasks, { admission, signal: executionContext.signal });
5009
+ }
5010
+ else {
5011
+ for (const [index, selection] of executionSelections.entries()) {
5012
+ if (options.runtime?.batchInstallPlatform)
5013
+ executionContext.signal?.throwIfAborted();
5014
+ const key = executionKey(selection, lockedPlan);
5015
+ if (deferredPreApply.has(key) && providersReady(key)) {
5016
+ await verifyProviders(selection, key);
5017
+ await prepareDependentScript(selection, key);
4672
5018
  }
5019
+ await verifyProviders(selection, key);
5020
+ await runSelection(selection, index);
4673
5021
  }
4674
5022
  }
5023
+ if (options.runtime?.batchInstallPlatform)
5024
+ executionContext.signal?.throwIfAborted();
5025
+ if (codexSelections.length) {
5026
+ if (admission)
5027
+ await admission.run(nativeInstallResources(lockedOperationPlan.deploymentPlans ?? []), finishCodex, executionContext.signal);
5028
+ else
5029
+ await finishCodex();
5030
+ }
5031
+ if (options.runtime?.batchInstallPlatform)
5032
+ executionContext.signal?.throwIfAborted();
5033
+ for (const selection of pendingCodex)
5034
+ reportTargetState(selection, 'completed');
5035
+ }
5036
+ catch (error) {
5037
+ const code = recoveryInterruptionCode(error, executionContext.signal);
5038
+ if (!code)
5039
+ throw error;
5040
+ for (const selection of pendingCodex) {
5041
+ const state = dependencyStates.get(executionKey(selection, lockedPlan));
5042
+ if (state !== 'completed' && state !== 'kept')
5043
+ continue;
5044
+ failCompletedCodexTarget({ identity: targetIdentity(selection, planTargetFor(lockedPlan, selection).resolvedScope),
5045
+ message: `${code}: Codex postcheck did not complete.` });
5046
+ }
5047
+ throw new RebuildInterruptedError(mergeRebuildCommandResults(results.filter(Boolean)), error);
5048
+ }
5049
+ finally {
5050
+ await Promise.all(privatePackages.map((staging) => staging.dispose()));
4675
5051
  }
4676
5052
  const merged = mergeRebuildCommandResults(results);
4677
5053
  if (malformedSelectedConfigPreserved) {
@@ -4763,7 +5139,8 @@ export async function runRebuildCommand(options) {
4763
5139
  runtime: { ...options.runtime, env: executionInput.context.env },
4764
5140
  };
4765
5141
  try {
4766
- if (scopedOptions.runtime?.codexObservationSession) {
5142
+ if (scopedOptions.runtime?.codexObservationSession
5143
+ || scopedOptions.runtime?.batchInstallPlatform && scopedOptions.runtime.batchInstallPlatform !== 'codex') {
4767
5144
  return withCommands(await runRebuildCommandInSession(scopedOptions));
4768
5145
  }
4769
5146
  const env = executionInput.context.env;