@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,5 +1,5 @@
1
1
  import type { ConfigReferenceContext, ConfigReferenceDraft } from './config-references.js';
2
- import type { CatalogActivationMode, CatalogSource, CatalogGenerationActiveV1, CatalogGenerationCandidateEvidence, CatalogGenerationSyncResult, CatalogSourceImpact, CommandProducerResult, DependencyScopeOverride, PlatformName, PlatformTarget, Scope } from '../types.js';
2
+ import type { CatalogActivationMode, CatalogSource, CatalogGenerationActiveV1, CatalogGenerationCandidateEvidence, CatalogGenerationSyncResult, CatalogSourceImpact, CommandProducerResult, ConfigApplyResult, DependencyScopeOverride, PlatformName, PlatformTarget, Scope } from '../types.js';
3
3
  import type { PortableReview, PortableInstallReceipt, PortableRetryReview } from '../portable/commands.js';
4
4
  import type { CatalogSourceUpdate } from '../utils/catalog-sources.js';
5
5
  import type { CatalogGenerationFreshnessState, CatalogGenerationFreshnessResult } from '../utils/catalog-generation-service.js';
@@ -11,12 +11,14 @@ import type { CodexReconcilePlan } from '../utils/codex-reconciler.js';
11
11
  import type { PluginConfigMutationImpact } from '../utils/plugin-config-impact.js';
12
12
  import type { OperationPlan } from '../commands/operation-plan.js';
13
13
  import type { RebuildProgressFeed, RebuildProgressSnapshot } from '../output/rebuild-progress.js';
14
+ import type { Diagnostic } from '../output/public-result.js';
14
15
  import { type ConfigPageViewModel, type ConfigProfileOptions, type ConfigReadOptions, type ConfigProfileKey, type ConfigGroupViewModel, type InstallPlacementDraftViewModel, type PluginListItemViewModel, type PluginDependencyOverviewViewModel, type PortableSkillSelectionViewModel, type SourceHealthViewModel, type SourceDetailViewModel, type TuiViewModel, type UserIssueCategory, type UserIssueViewModel } from './model.js';
15
16
  import type { PluginContentOverview } from './plugin-content.js';
16
17
  import { type PluginDetailSubject } from './plugin-detail.js';
18
+ import { type ComponentDelivery } from '../output/component-delivery.js';
17
19
  import { OperationHistoryStore, type OperationDiagnosticDetail, type OperationEffectFacts, type OperationHistorySummary, type OperationReportPreview, type SafeOperationDiagnostic, type SaveOperationReportResult } from './operation-history.js';
18
20
  import { type ScopedInventoryViewModel, type ScopedInventoryLoadResult, type InventoryRoot } from './scoped-inventory.js';
19
- import type { ScopedTuiPlan } from './scoped-flow.js';
21
+ import { type ScopedTuiPlan } from './scoped-flow.js';
20
22
  import type { RecoveryReceipt } from '../recovery/receipt.js';
21
23
  import type { RecoveryCommand } from '../recovery/coordinator.js';
22
24
  import type { AgentId } from '../intent/deployment-preferences.js';
@@ -152,10 +154,10 @@ export interface ConfigSaveBatchGroup {
152
154
  export interface ConfigSaveBatchGroupResult {
153
155
  scope: 'user';
154
156
  platform?: PlatformTarget;
155
- status: 'succeeded' | 'failed';
157
+ status: 'succeeded' | 'failed' | 'notStarted';
156
158
  configSaved: boolean;
157
159
  applyRequested: boolean;
158
- applyStatus: 'notRequested' | 'notNeeded' | 'succeeded' | 'failed';
160
+ applyStatus: 'notRequested' | 'notStarted' | 'notNeeded' | 'succeeded' | 'partial' | 'failed';
159
161
  errorCode?: string;
160
162
  execution?: unknown;
161
163
  }
@@ -556,18 +558,23 @@ export interface OperationResultSummary {
556
558
  elapsedMs?: number;
557
559
  messages?: string[];
558
560
  configApplied?: boolean;
561
+ configDiagnostics?: Diagnostic[];
559
562
  configApplySkippedReason?: 'invalidConfig';
560
563
  configScope?: Scope;
561
564
  configPlatform?: PlatformTarget;
562
565
  configContext?: Scope;
563
- configTargets?: Array<{
566
+ configTargets?: Array<ComponentDelivery & {
564
567
  pluginId?: string;
565
568
  platform: PlatformTarget;
566
569
  scope: Scope;
567
570
  state: 'completed' | 'kept' | 'failed' | 'skipped';
571
+ partialDelivery?: true;
568
572
  errorCode?: string;
573
+ diagnosticIds?: string[];
574
+ effects?: OperationEffectFacts;
569
575
  }>;
570
576
  configApplyRetryAvailable?: boolean;
577
+ configApplyRetryTargets?: PlatformTarget[];
571
578
  configRetryApply?: boolean;
572
579
  configGroups?: Array<{
573
580
  scope: Scope;
@@ -575,6 +582,8 @@ export interface OperationResultSummary {
575
582
  configSaved: boolean;
576
583
  applyRequested: boolean;
577
584
  applyStatus: ConfigSaveBatchGroupResult['applyStatus'];
585
+ notStarted?: true;
586
+ retryTargets?: PlatformTarget[];
578
587
  errorCode?: string;
579
588
  }>;
580
589
  resetDisposition?: 'absent' | 'deletedFile' | 'unlinkedSymlink' | 'quarantinedDirectory';
@@ -1026,3 +1035,4 @@ export declare class TuiController {
1026
1035
  executeOperation(reviewToken: string): Promise<OperationExecuteResult>;
1027
1036
  dispose(): void;
1028
1037
  }
1038
+ export declare function configApplyHasCompletedWork(apply: ConfigApplyResult | undefined): boolean;
@@ -4,18 +4,23 @@ import crypto from 'node:crypto';
4
4
  import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
5
5
  import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
6
6
  import { NativeCliError } from '../utils/native-cli.js';
7
+ import { ConfigApplyInterruptedError } from '../utils/plugin-config-write.js';
8
+ import { parsePluginId } from '../utils/multi-source-catalog.js';
7
9
  import { flattenStatusTargets, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, statusTargetSharedNative, } from '../commands/status-v6.js';
8
10
  import { buildRebuildReceiptJson, requestedIntentAction } from '../output/command-receipt.js';
11
+ import { SKILL_INVOCATION_NOTICE } from '../utils/skill-invocation-warning.js';
9
12
  import { buildOperationResultModel } from '../commands/operation-planner.js';
10
13
  import { buildOperationReviewProjection } from './operation-review-planner.js';
11
14
  import { buildTuiViewModel, dependencyPlacementTargets, hasScopedExtensionOwnership, } from './model.js';
12
15
  import { buildPluginDetailSubject } from './plugin-detail.js';
13
16
  import { safeDiagnosticCode, sanitizeDiagnosticText } from './diagnostics.js';
14
- import { projectExecutionDiagnostics, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
17
+ import { projectComponentDeliveryHistory, projectDeliveryNoticeHistory, projectExecutionDiagnostics, projectSkillInvocationHistory, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
18
+ import { projectComponentDelivery } from '../output/component-delivery.js';
15
19
  import { OperationHistoryStore, } from './operation-history.js';
16
20
  import { targetHasArtifactCollision } from '../utils/target-eligibility.js';
17
21
  import { hasStatusInstallationEvidence } from './scoped-inventory.js';
18
22
  import { buildScopedInventory } from './scoped-inventory.js';
23
+ import { projectScopedRecoveryHistory } from './scoped-flow.js';
19
24
  import { TuiRouter, } from './router.js';
20
25
  import { normalizeTuiRoute } from './screen-registry.js';
21
26
  import { CatalogSourcesSession } from './catalog-sources/session.js';
@@ -401,6 +406,9 @@ function sanitizeOperationSummary(summary, sensitiveValues) {
401
406
  ...(summary.messages ? { messages: summary.messages.map(text) } : {}),
402
407
  ...(summary.changes ? { changes: summary.changes.map(text) } : {}),
403
408
  ...(summary.warnings ? { warnings: summary.warnings.map(text) } : {}),
409
+ ...(summary.configDiagnostics ? { configDiagnostics: summary.configDiagnostics.map((diagnostic) => ({
410
+ ...diagnostic, message: text(diagnostic.message),
411
+ })) } : {}),
404
412
  ...(summary.recoveryActions ? { recoveryActions: summary.recoveryActions.map(text) } : {}),
405
413
  ...(summary.commandResults ? { commandResults: summary.commandResults.map((result) => ({
406
414
  ...result,
@@ -718,7 +726,7 @@ export class TuiController {
718
726
  });
719
727
  if (progressFeed) {
720
728
  this.#progressUnsubscribe = progressFeed.subscribe((progress) => {
721
- if (this.#router.snapshot.current.route.name === 'result')
729
+ if (this.#router.snapshot.current.route.name === 'result' && !this.#scopedTaskInflight)
722
730
  return;
723
731
  this.#progress = {
724
732
  ...structuredClone(progress),
@@ -964,16 +972,27 @@ export class TuiController {
964
972
  finalVerification: result.state === 'succeeded' ? 'completed' : 'unknown',
965
973
  },
966
974
  };
967
- if ('summary' in result && result.summary) {
968
- Object.assign(result.summary, sanitizeOperationSummary(result.summary, projected.sensitiveValues ?? []));
969
- }
970
- const diagnosticIds = projected.diagnostics.map((diagnostic) => diagnostic.id);
975
+ const summary = 'summary' in result ? result.summary : undefined;
976
+ if (summary) {
977
+ Object.assign(summary, sanitizeOperationSummary(summary, projected.sensitiveValues ?? []));
978
+ }
979
+ const deliveryNotices = projectDeliveryNoticeHistory(summary?.configDiagnostics ?? [], recordId, 'apply');
980
+ const configDelivery = (summary?.configTargets ?? []).map((target, index) => {
981
+ const notices = deliveryNotices.filter(({ target: notice }) => notice?.platform === target.platform
982
+ && notice.scope === target.scope && notice.pluginId === target.pluginId);
983
+ const delivery = projectComponentDeliveryHistory(target, notices, `${recordId}:${index}`, 'apply', target.state === 'completed' || target.state === 'kept');
984
+ return { target, ...delivery };
985
+ });
986
+ const diagnostics = [...projected.diagnostics, ...deliveryNotices, ...configDelivery.flatMap(({ diagnostics }) => diagnostics),
987
+ ...projectSkillInvocationHistory(summary?.configDiagnostics ?? [], recordId, 'apply')];
988
+ const diagnosticIds = diagnostics.map((diagnostic) => diagnostic.id);
989
+ const targets = summary ? summary.configTargets ?? summary.targets ?? [] : projected.targets ?? [];
971
990
  Object.assign(result, { operationRecordId: recordId, diagnosticIds, effects: projected.effects });
972
- if ('summary' in result && result.summary) {
973
- result.summary.diagnosticIds = diagnosticIds;
974
- result.summary.effects = projected.effects;
975
- for (const target of result.summary.targets ?? []) {
976
- const targetDiagnostics = projected.diagnostics.filter((diagnostic) => diagnostic.target
991
+ if (summary) {
992
+ summary.diagnosticIds = diagnosticIds;
993
+ summary.effects = projected.effects;
994
+ for (const target of targets) {
995
+ const targetDiagnostics = diagnostics.filter((diagnostic) => diagnostic.target
977
996
  && diagnostic.target.platform === target.platform
978
997
  && diagnostic.target.scope === target.scope
979
998
  && (diagnostic.target.pluginId === undefined || diagnostic.target.pluginId === target.pluginId));
@@ -996,16 +1015,15 @@ export class TuiController {
996
1015
  message,
997
1016
  ...('operationKind' in result && result.operationKind ? { operationKind: result.operationKind } : {}),
998
1017
  ...('pluginId' in result && result.pluginId ? { pluginId: result.pluginId } : {}),
999
- diagnosticCount: projected.diagnostics.length,
1018
+ diagnosticCount: diagnostics.length,
1000
1019
  effects: projected.effects,
1001
1020
  },
1002
- diagnostics: projected.diagnostics,
1003
- targets: 'summary' in result && result.summary
1004
- ? structuredClone((result.summary.targets ?? []).map((target) => ({
1005
- ...target,
1006
- diagnosticIds: target.diagnosticIds ?? [],
1007
- })))
1008
- : structuredClone(projected.targets ?? []),
1021
+ diagnostics,
1022
+ targets: targets.map((target) => {
1023
+ const delivery = configDelivery.find((entry) => entry.target === target);
1024
+ return { ...target, diagnosticIds: target.diagnosticIds ?? [],
1025
+ ...(delivery?.facts ? { componentDelivery: delivery.facts } : {}) };
1026
+ }),
1009
1027
  }, { sensitiveValues: projected.sensitiveValues });
1010
1028
  this.#operationDiagnostics.delete(result.operationId);
1011
1029
  this.#lastRecordedResultId = recordId;
@@ -1023,7 +1041,7 @@ export class TuiController {
1023
1041
  stage,
1024
1042
  fallbackCode: code,
1025
1043
  sensitiveValues,
1026
- ...(intent && 'pluginId' in intent && 'platform' in intent
1044
+ ...(!(error instanceof ConfigApplyInterruptedError) && intent && 'pluginId' in intent && 'platform' in intent
1027
1045
  && (intent.platform === 'codex' || intent.platform === 'claude')
1028
1046
  && (intent.scope === 'user' || intent.scope === 'project')
1029
1047
  ? { target: { pluginId: intent.pluginId, platform: intent.platform, scope: intent.scope } }
@@ -1661,9 +1679,29 @@ export class TuiController {
1661
1679
  this.#progressFeed?.clearCurrent();
1662
1680
  this.#progress = { messages: [], startedAtMs: this.dependencies.now?.() ?? Date.now() };
1663
1681
  this.#publish();
1664
- const promise = this.dependencies.executeScopedTask(plan).finally(() => {
1682
+ const isBatch = plan.kind === 'recovery' && (plan.plan.command === 'install' || plan.plan.command === 'sync')
1683
+ && plan.plan.receipt.requestedTargets.length > 1;
1684
+ const promise = this.dependencies.executeScopedTask(plan).then((outcome) => {
1685
+ const recordByDefault = isBatch || this.#progress.installProgress !== undefined;
1686
+ if (outcome.kind === 'recovery' && (recordByDefault || outcome.receipt.targetResults.some(({ reasons }) => reasons?.some(({ code }) => code === SKILL_INVOCATION_NOTICE)))) {
1687
+ const operationId = `scoped-${crypto.randomUUID()}`;
1688
+ const record = projectScopedRecoveryHistory(outcome.receipt, {
1689
+ operationId, recordId: `${this.#sessionEpoch}:${operationId}`, epoch: this.#sessionEpoch,
1690
+ createdAtMs: this.dependencies.now?.() ?? Date.now(),
1691
+ });
1692
+ if (recordByDefault || record.diagnostics.some(({ code }) => code === SKILL_INVOCATION_NOTICE)) {
1693
+ this.#operationHistory.record(record);
1694
+ }
1695
+ }
1696
+ return outcome;
1697
+ }, (error) => {
1698
+ if (isBatch || this.#progress.installProgress)
1699
+ this.#recordStandaloneFailure(issueCode(error), 'execute', error);
1700
+ throw error;
1701
+ }).finally(() => {
1665
1702
  if (this.#scopedTaskInflight?.promise === promise)
1666
1703
  this.#scopedTaskInflight = undefined;
1704
+ this.#publish();
1667
1705
  });
1668
1706
  this.#scopedTaskInflight = { plan, promise };
1669
1707
  return promise;
@@ -3881,20 +3919,21 @@ export class TuiController {
3881
3919
  || Array.isArray(execution.groups)
3882
3920
  && (execution.groups
3883
3921
  .some((group) => group.configSaved)));
3922
+ const configRetryReportedDelivery = ticket.intent.kind === 'configSave' && ticket.intent.retryApply
3923
+ && configApplyHasCompletedWork(configApplyResult(execution));
3884
3924
  if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configSaveBatch'
3885
- || ticket.intent.kind === 'configReset')
3886
- && configCommitted) {
3925
+ || ticket.intent.kind === 'configReset') && (configCommitted || configRetryReportedDelivery)) {
3887
3926
  const baseSummary = operationResultSummary(ticket.intent, execution);
3888
3927
  const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
3889
3928
  const summary = {
3890
3929
  ...baseSummary,
3891
3930
  code: 'operationPartial',
3892
- message: '设置已保存,但最终状态无法刷新。',
3931
+ message: configCommitted ? '设置已保存,但最终状态无法刷新。' : '部分插件内容已就绪,但最终状态无法刷新。',
3893
3932
  elapsedMs,
3894
3933
  messages: [
3895
3934
  ...this.#progress.messages,
3896
3935
  ...(baseSummary.messages ?? []),
3897
- '状态刷新失败。配置写入已经提交;请稍后刷新状态。',
3936
+ configCommitted ? '状态刷新失败。配置写入已经提交;请稍后刷新状态。' : '请稍后刷新状态。',
3898
3937
  ].slice(-8).map((message) => sanitizeDiagnosticText(message, [], collectOperationSensitiveValues(ticket.intent))),
3899
3938
  };
3900
3939
  this.#progress = { ...this.#progress, elapsedMs };
@@ -4117,9 +4156,11 @@ export class TuiController {
4117
4156
  catch (error) {
4118
4157
  if (!this.#operationIsCurrent(generation))
4119
4158
  return this.#detachedBlocked(operationId, ticket.intent);
4120
- const code = issueCode(error);
4159
+ const interruptedApply = error instanceof ConfigApplyInterruptedError ? error : undefined;
4160
+ const code = interruptedApply?.code ?? issueCode(error);
4121
4161
  const metadata = readSafeOperationError(error);
4122
4162
  const preApply = metadata?.stage === 'preApply';
4163
+ const applyCompletedWork = configApplyHasCompletedWork(interruptedApply?.apply);
4123
4164
  const configWrite = error && typeof error === 'object' && 'configWrite' in error
4124
4165
  ? error.configWrite : undefined;
4125
4166
  this.#captureThrownProjection(operationId, error, code, 'execute', ticket.intent, {
@@ -4130,6 +4171,18 @@ export class TuiController {
4130
4171
  preApplyExternalEffect: preApply ? 'possible' : 'notApplicable',
4131
4172
  finalVerification: 'notStarted',
4132
4173
  });
4174
+ if (interruptedApply) {
4175
+ const projected = this.#operationDiagnostics.get(operationId);
4176
+ const applyProjection = projectExecutionDiagnostics(interruptedApply, `${this.#sessionEpoch}:${operationId}:interrupted-apply`, projected.sensitiveValues, ticket.intent.kind);
4177
+ projected.diagnostics.push(...applyProjection.diagnostics);
4178
+ projected.effects = {
4179
+ ...applyProjection.effects,
4180
+ awWrite: applyCompletedWork ? 'partial' : projected.effects.awWrite,
4181
+ preApplyExternalEffect: preApply ? 'possible' : applyProjection.effects.preApplyExternalEffect,
4182
+ finalVerification: 'notStarted',
4183
+ };
4184
+ projected.targetEffects = applyProjection.targetEffects;
4185
+ }
4133
4186
  await this.#logOperationError(error, code, ticket.intent);
4134
4187
  if (!this.#operationIsCurrent(generation))
4135
4188
  return this.#detachedBlocked(operationId, ticket.intent);
@@ -4179,28 +4232,44 @@ export class TuiController {
4179
4232
  }
4180
4233
  if (!this.#operationIsCurrent(generation))
4181
4234
  return this.#detachedBlocked(operationId, ticket.intent);
4235
+ const applySummary = interruptedApply ? operationResultSummary(ticket.intent, interruptedApply) : undefined;
4236
+ const configMadeProgress = configWrite === 'succeeded' || applyCompletedWork;
4237
+ const retryTargets = configMadeProgress ? configApplyUnfinishedPlatforms(interruptedApply?.apply, ticket.intent.kind === 'configSave' ? ticket.intent.targets : undefined) : [];
4238
+ const interruptionMessage = interruptedApply
4239
+ ? configApplyInterruptionMessage(interruptedApply.code, retryTargets) : undefined;
4182
4240
  if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configReset')
4183
- && configWrite === 'succeeded') {
4241
+ && configMadeProgress) {
4184
4242
  const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
4185
4243
  const summary = {
4244
+ ...applySummary,
4186
4245
  code: 'operationPartial',
4187
4246
  message: ticket.intent.kind === 'configReset'
4188
4247
  ? '设置层重置已提交,但后续步骤未完成。'
4189
- : finalVerification === 'failed'
4190
- ? ticket.intent.apply
4191
- ? '设置已保存,但后续应用或状态复核失败。'
4192
- : '设置已保存,但状态复核失败。'
4193
- : ticket.intent.apply
4194
- ? '设置已保存,但后续应用失败。'
4195
- : '设置已保存,但后续步骤未完成。',
4248
+ : applyCompletedWork
4249
+ ? configWrite === 'succeeded' ? '设置已保存,部分插件内容已就绪。' : '部分插件内容已就绪。'
4250
+ : finalVerification === 'failed'
4251
+ ? ticket.intent.apply
4252
+ ? '设置已保存,但后续应用或状态复核失败。'
4253
+ : '设置已保存,但状态复核失败。'
4254
+ : ticket.intent.apply
4255
+ ? '设置已保存,但后续应用失败。'
4256
+ : '设置已保存,但后续步骤未完成。',
4196
4257
  pluginId: ticket.intent.pluginId,
4197
4258
  configScope: 'user', configPlatform: ticket.intent.platform, configContext: ticket.intent.context ?? 'user',
4259
+ ...(interruptedApply ? { configApplied: applyCompletedWork } : {}),
4198
4260
  ...(ticket.intent.kind === 'configSave' && ticket.intent.apply
4199
- ? { configApplyRetryAvailable: true } : {}),
4261
+ ? { configApplyRetryAvailable: !interruptedApply || retryTargets.length > 0 } : {}),
4262
+ ...(interruptedApply ? { configApplyRetryTargets: retryTargets } : {}),
4200
4263
  elapsedMs,
4201
- messages: [ticket.intent.kind === 'configReset'
4202
- ? '设置层重置已经提交;失败的后续步骤没有恢复旧设置。'
4203
- : '配置写入已经提交;失败的后续步骤没有回滚设置。'],
4264
+ messages: [
4265
+ ...(applySummary?.messages ?? []),
4266
+ ...(configWrite === 'succeeded' ? [ticket.intent.kind === 'configReset'
4267
+ ? '设置层重置已经提交;失败的后续步骤没有恢复旧设置。'
4268
+ : '配置写入已经提交;失败的后续步骤没有回滚设置。'] : []),
4269
+ ...(interruptionMessage ? [interruptionMessage] : []),
4270
+ ...(finalVerification === 'failed' && interruptedApply
4271
+ ? ['最终状态无法刷新。请稍后重新检查状态。'] : []),
4272
+ ],
4204
4273
  };
4205
4274
  this.#progress = { ...this.#progress, elapsedMs };
4206
4275
  const result = {
@@ -4222,6 +4291,16 @@ export class TuiController {
4222
4291
  navigation: 'result',
4223
4292
  returnRoute: ticket.returnRoute,
4224
4293
  writeMayHaveCompleted: ticket.intent.kind === 'catalogSourcesRecovery' ? false : true,
4294
+ ...(applySummary && interruptionMessage ? {
4295
+ message: interruptionMessage,
4296
+ summary: {
4297
+ ...applySummary,
4298
+ code: 'operationFailed',
4299
+ message: interruptionMessage,
4300
+ configApplyRetryAvailable: false,
4301
+ configApplyRetryTargets: [],
4302
+ },
4303
+ } : {}),
4225
4304
  });
4226
4305
  }
4227
4306
  }
@@ -4329,7 +4408,7 @@ export class TuiController {
4329
4408
  if (!this.#operationDiagnostics.has(operationId)) {
4330
4409
  this.#captureThrownProjection(operationId, undefined, code, 'execute', options?.intent);
4331
4410
  }
4332
- const message = code === 'codexCliNotFound'
4411
+ const message = options?.message ?? (code === 'codexCliNotFound'
4333
4412
  ? '操作在插件写入前停止。未找到本机 Codex CLI。请检查 PATH,或安装 Codex CLI 或 Codex App 后重试。'
4334
4413
  : code === 'codexSystemCliUnsupported'
4335
4414
  ? '操作在插件写入前停止。本机 Codex CLI 版本不受支持或无法确认。请升级或修复本机 Codex CLI 或 Codex App 后重试。'
@@ -4341,7 +4420,7 @@ export class TuiController {
4341
4420
  ? '重置执行后设置层仍然存在。请重新检查设置问题。'
4342
4421
  : code === 'issueStillPresent'
4343
4422
  ? '写入已完成,但重新检查后原问题仍然存在。'
4344
- : '操作未完成。请重新检查后重试。';
4423
+ : '操作未完成。请重新检查后重试。');
4345
4424
  const result = {
4346
4425
  state: 'blocked',
4347
4426
  operationId,
@@ -4399,6 +4478,65 @@ export class TuiController {
4399
4478
  this.#listeners.clear();
4400
4479
  }
4401
4480
  }
4481
+ function configApplyResult(execution) {
4482
+ if (!execution || typeof execution !== 'object')
4483
+ return undefined;
4484
+ return execution.apply;
4485
+ }
4486
+ export function configApplyHasCompletedWork(apply) {
4487
+ return apply?.targetResults?.some((target) => target.partialDelivery || target.state === 'completed' && target.action !== 'skipped') === true
4488
+ || apply?.commandResults?.some((result) => result.state === 'completed') === true;
4489
+ }
4490
+ function configApplyUnfinishedPlatforms(apply, reviewedPlatforms) {
4491
+ if (!apply || apply.commandResults?.length)
4492
+ return [];
4493
+ const completed = new Set(apply.targetResults.filter((result) => result.state === 'completed' || result.partialDelivery)
4494
+ .map((result) => result.target.platform));
4495
+ return [...new Set(apply.targetResults.filter((result) => (result.state === 'failed' || result.state === 'skipped' && result.errorCode)
4496
+ && !completed.has(result.target.platform)
4497
+ && (!reviewedPlatforms || reviewedPlatforms.includes(result.target.platform)))
4498
+ .map((result) => result.target.platform))];
4499
+ }
4500
+ function configApplyInterruptionMessage(code, retryTargets) {
4501
+ const nextStep = retryTargets.length > 0
4502
+ ? '可为未完成平台重新准备确认。' : CONFIG_APPLY_MANUAL_RECOVERY;
4503
+ return code === 'processCleanupUnconfirmed'
4504
+ ? `无法确认进程已清理。请先检查相关平台进程。${nextStep}`
4505
+ : `应用已中断。${nextStep}`;
4506
+ }
4507
+ const CONFIG_APPLY_MANUAL_RECOVERY = '请检查未完成位置后,从设置重新准备应用。';
4508
+ function configApplyTargets(apply) {
4509
+ return (apply?.targetResults ?? []).flatMap((entry) => {
4510
+ const target = entry.target;
4511
+ if (!target || !isPlatformTarget(target.platform)
4512
+ || (target.scope !== 'user' && target.scope !== 'project')
4513
+ || (entry.state !== 'completed' && entry.state !== 'failed' && entry.state !== 'skipped'))
4514
+ return [];
4515
+ let pluginId;
4516
+ if (typeof target.pluginId === 'string') {
4517
+ try {
4518
+ parsePluginId(target.pluginId);
4519
+ pluginId = target.pluginId;
4520
+ }
4521
+ catch {
4522
+ // Target identity can be unavailable in older receipts.
4523
+ }
4524
+ }
4525
+ return [{
4526
+ ...(pluginId ? { pluginId } : {}),
4527
+ platform: target.platform,
4528
+ scope: target.scope,
4529
+ state: entry.state === 'skipped' || entry.action === 'skipped' ? 'skipped'
4530
+ : entry.state === 'failed' ? 'failed'
4531
+ : entry.action === 'keep' ? 'kept' : 'completed',
4532
+ ...(entry.partialDelivery ? { partialDelivery: true } : {}),
4533
+ ...projectComponentDelivery(entry),
4534
+ ...(typeof entry.errorCode === 'string'
4535
+ ? { errorCode: safeDiagnosticCode(entry.errorCode, 'configApplyFailed') }
4536
+ : {}),
4537
+ }];
4538
+ });
4539
+ }
4402
4540
  function operationResultSummaryUnsafe(intent, execution) {
4403
4541
  if (intent.kind === 'catalogStorePrune') {
4404
4542
  const result = execution;
@@ -4762,9 +4900,27 @@ function operationResultSummaryUnsafe(intent, execution) {
4762
4900
  }
4763
4901
  if (intent.kind === 'configSaveBatch') {
4764
4902
  const batch = execution;
4903
+ const applies = batch.groups.map((group) => configApplyResult(group.execution));
4904
+ const configDiagnostics = applies.flatMap((apply) => apply?.diagnostics ?? []);
4905
+ const commandResults = applies.flatMap((apply) => apply?.commandResults ?? []);
4906
+ const targets = [...new Map(applies.flatMap(configApplyTargets)
4907
+ .map((target) => [[target.pluginId ?? '', target.platform, target.scope].join('\0'), target])).values()];
4765
4908
  const savedCount = batch.groups.filter((group) => group.configSaved).length;
4766
- const failedCount = batch.groups.filter((group) => group.status === 'failed').length;
4767
- const retryScopes = batch.groups.filter((group) => group.configSaved && group.applyStatus === 'failed' && group.errorCode !== 'invalidConfig');
4909
+ const targetsUpdated = applies.some(configApplyHasCompletedWork);
4910
+ const configGroups = batch.groups.map((group, index) => ({
4911
+ scope: group.scope,
4912
+ platform: group.platform,
4913
+ configSaved: group.configSaved,
4914
+ applyRequested: group.applyRequested,
4915
+ applyStatus: group.applyStatus,
4916
+ ...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
4917
+ ...(group.status === 'notStarted' ? { notStarted: true } : {}),
4918
+ ...(group.applyStatus === 'partial'
4919
+ || group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
4920
+ ? { retryTargets: configApplyUnfinishedPlatforms(applies[index]) } : {}),
4921
+ }));
4922
+ const retryScopes = configGroups.filter((group) => group.configSaved && (group.applyStatus === 'failed' || group.applyStatus === 'partial')
4923
+ && group.errorCode !== 'invalidConfig' && group.retryTargets?.length !== 0);
4768
4924
  const invalidConfig = savedCount === batch.groups.length
4769
4925
  && batch.groups.some((group) => group.configSaved && group.errorCode === 'invalidConfig')
4770
4926
  && retryScopes.length === 0;
@@ -4777,43 +4933,42 @@ function operationResultSummaryUnsafe(intent, execution) {
4777
4933
  const otherProjectsMayRequireSync = batch.groups.some((group) => group.scope === 'user' && group.execution && typeof group.execution === 'object'
4778
4934
  && group.execution.otherProjectsMayRequireSync === true);
4779
4935
  return {
4780
- code: failedCount > 0
4781
- ? savedCount > 0 ? 'operationPartial' : 'operationFailed'
4782
- : 'operationSucceeded',
4936
+ code: batch.status === 'succeeded' ? 'operationSucceeded'
4937
+ : batch.status === 'partial' || targetsUpdated ? 'operationPartial' : 'operationFailed',
4783
4938
  message: invalidConfig
4784
4939
  ? '设置已保存,但没有应用。当前配置仍无效。'
4785
- : failedCount > 0
4940
+ : batch.status !== 'succeeded'
4786
4941
  ? savedCount > 0
4787
- ? `已保存 ${savedCount} 个设置层;${failedCount} 个设置层失败。`
4942
+ ? `已保存 ${savedCount} 个设置层;${targetsUpdated ? '部分插件目标已更新。' : '部分步骤未完成。'}`
4788
4943
  : '设置没有保存。'
4789
4944
  : '设置已保存。',
4790
4945
  pluginId: intent.pluginId,
4946
+ configContext: intent.context ?? 'user',
4791
4947
  configApplyRetryAvailable: retryScopes.length > 0,
4792
4948
  ...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
4793
4949
  configApplied: intent.apply
4794
- ? batch.groups.some((group) => group.applyStatus === 'succeeded')
4950
+ ? targetsUpdated || batch.groups.some((group) => group.applyStatus === 'succeeded')
4795
4951
  : false,
4796
- configGroups: batch.groups.map((group) => ({
4797
- scope: group.scope,
4798
- platform: group.platform,
4799
- configSaved: group.configSaved,
4800
- applyRequested: group.applyRequested,
4801
- applyStatus: group.applyStatus,
4802
- ...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
4803
- })),
4804
- commandResults: batch.groups.flatMap((group) => group.execution
4805
- && typeof group.execution === 'object'
4806
- ? (group.execution.apply?.commandResults ?? [])
4807
- : []),
4952
+ configGroups,
4953
+ ...(targets.length > 0 ? { configTargets: targets } : {}),
4954
+ ...(configDiagnostics.length ? { configDiagnostics } : {}),
4955
+ commandResults,
4956
+ ...(commandResults.length ? { recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
4808
4957
  messages: [
4809
- ...batch.groups.map((group) => {
4958
+ ...configGroups.map((group) => {
4810
4959
  const label = group.platform ? `${group.platform} 平台配置` : '公共配置';
4960
+ if (group.notStarted)
4961
+ return `${label}尚未保存。`;
4811
4962
  return group.configSaved
4812
4963
  ? `${label}已保存${group.errorCode === 'invalidConfig'
4813
4964
  ? ',但当前配置无效,未应用'
4814
- : group.applyStatus === 'failed' ? ',但应用失败' : ''}。`
4965
+ : group.applyStatus === 'partial' ? ',部分插件目标已更新'
4966
+ : group.applyStatus === 'failed' ? ',但应用失败' : ''}。`
4815
4967
  : `${label}保存失败。`;
4816
4968
  }),
4969
+ ...configGroups.flatMap((group) => group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
4970
+ ? [configApplyInterruptionMessage(group.errorCode, group.retryTargets ?? [])]
4971
+ : group.retryTargets?.length === 0 ? [CONFIG_APPLY_MANUAL_RECOVERY] : []),
4817
4972
  ...publicWarnings.map((warning) => `警告:${warning}`),
4818
4973
  ...(otherProjectsMayRequireSync
4819
4974
  ? ['提示:其它项目没有被扫描,可能需要在对应项目目录中运行 aw plugin sync --context project。']
@@ -4822,43 +4977,15 @@ function operationResultSummaryUnsafe(intent, execution) {
4822
4977
  };
4823
4978
  }
4824
4979
  if (intent.kind === 'configSave' || intent.kind === 'configReset') {
4825
- const rawApply = typeof execution === 'object' && execution !== null
4826
- && typeof execution.apply === 'object'
4827
- && execution.apply !== null
4828
- ? execution.apply
4829
- : {};
4830
- const rawTargets = Array.isArray(rawApply.targetResults)
4831
- ? rawApply.targetResults
4832
- : [];
4833
- const commandResults = Array.isArray(rawApply.commandResults)
4834
- ? rawApply.commandResults : [];
4835
- const targets = rawTargets.flatMap((entry) => {
4836
- const target = typeof entry.target === 'object' && entry.target !== null
4837
- ? entry.target
4838
- : entry;
4839
- if (!isPlatformTarget(target.platform)
4840
- || (target.scope !== 'user' && target.scope !== 'project')
4841
- || (entry.state !== 'completed' && entry.state !== 'failed' && entry.state !== 'skipped'))
4842
- return [];
4843
- return [{
4844
- ...(typeof target.pluginId === 'string' ? { pluginId: target.pluginId } : {}),
4845
- platform: target.platform,
4846
- scope: target.scope,
4847
- state: entry.state === 'skipped' || entry.action === 'skipped' ? 'skipped'
4848
- : entry.state === 'failed' ? 'failed'
4849
- : entry.action === 'keep' ? 'kept'
4850
- : entry.state,
4851
- ...(typeof entry.errorCode === 'string'
4852
- ? { errorCode: safeDiagnosticCode(entry.errorCode, 'configApplyFailed') }
4853
- : {}),
4854
- }];
4855
- });
4980
+ const apply = configApplyResult(execution);
4981
+ const configDiagnostics = apply?.diagnostics ?? [];
4982
+ const commandResults = apply?.commandResults ?? [];
4983
+ const targets = configApplyTargets(apply);
4856
4984
  const overallState = typeof execution === 'object' && execution !== null
4857
4985
  ? execution.overallState
4858
4986
  : undefined;
4859
- const applyState = rawApply.state;
4860
- const applyReason = rawApply.reason;
4861
- const invalidConfig = applyState === 'unavailable' && applyReason === 'invalidConfig';
4987
+ const applyState = apply?.state;
4988
+ const invalidConfig = apply?.state === 'unavailable' && apply.reason === 'invalidConfig';
4862
4989
  const resetDisposition = typeof execution === 'object' && execution !== null
4863
4990
  ? execution.resetDisposition
4864
4991
  : undefined;
@@ -4887,18 +5014,34 @@ function operationResultSummaryUnsafe(intent, execution) {
4887
5014
  const failed = overallState === 'failed'
4888
5015
  || (targets.length > 0
4889
5016
  && targets.every((target) => target.state === 'failed' || target.state === 'skipped'));
5017
+ const retryApply = intent.kind === 'configSave' && intent.retryApply === true;
5018
+ const applied = applyState === 'succeeded' || configApplyHasCompletedWork(apply);
5019
+ const retryable = intent.kind === 'configSave'
5020
+ && intent.apply && !invalidConfig && (applyState === 'partial' || applyState === 'unavailable');
5021
+ const retryTargets = retryable && intent.kind === 'configSave'
5022
+ ? applied || commandResults.some((result) => result.state === 'partial')
5023
+ ? configApplyUnfinishedPlatforms(apply, intent.targets)
5024
+ : intent.targets
5025
+ : undefined;
5026
+ if (retryable && retryTargets?.length === 0 && !(execution instanceof ConfigApplyInterruptedError)) {
5027
+ publicMessages.push(CONFIG_APPLY_MANUAL_RECOVERY);
5028
+ }
4890
5029
  return {
4891
5030
  code: failed || partial ? 'operationPartial' : 'operationSucceeded',
4892
- message: invalidConfig ? '设置已保存,但没有应用。当前配置仍无效。'
4893
- : failed || partial ? '设置已保存,但插件内容重新应用失败或部分失败。' : '操作已完成。',
5031
+ message: retryApply
5032
+ ? invalidConfig ? '当前配置仍无效。请返回设置修复。'
5033
+ : failed || partial ? applied ? '部分插件内容已就绪。' : '插件设置应用未完成。'
5034
+ : applied ? '已应用已保存的设置。' : '应用检查完成。'
5035
+ : invalidConfig ? '设置已保存,但没有应用。当前配置仍无效。'
5036
+ : failed || partial ? '设置已保存,但插件内容重新应用失败或部分失败。' : '操作已完成。',
4894
5037
  pluginId: intent.pluginId,
4895
5038
  configScope: 'user', configPlatform: intent.platform, configContext: intent.context ?? 'user',
4896
- configApplyRetryAvailable: intent.kind === 'configSave'
4897
- && intent.apply && !invalidConfig && (applyState === 'partial' || applyState === 'unavailable'),
4898
- ...(intent.kind === 'configSave' && intent.retryApply ? { configRetryApply: true } : {}),
5039
+ configApplyRetryAvailable: retryable && retryTargets?.length !== 0,
5040
+ ...(retryTargets ? { configApplyRetryTargets: retryTargets } : {}),
5041
+ ...(retryApply ? { configRetryApply: true } : {}),
4899
5042
  ...(publicMessages.length > 0 ? { messages: publicMessages } : {}),
4900
5043
  ...(intent.kind === 'configSave'
4901
- ? { configApplied: applyState === 'succeeded' || applyState === 'partial' }
5044
+ ? { configApplied: applied }
4902
5045
  : invalidConfig ? { configApplied: false } : {}),
4903
5046
  ...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
4904
5047
  ...(intent.kind === 'configReset'
@@ -4913,6 +5056,7 @@ function operationResultSummaryUnsafe(intent, execution) {
4913
5056
  }
4914
5057
  : {}),
4915
5058
  ...(targets.length > 0 ? { configTargets: targets } : {}),
5059
+ ...(configDiagnostics.length ? { configDiagnostics } : {}),
4916
5060
  ...(commandResults.length > 0 ? { commandResults,
4917
5061
  recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
4918
5062
  };