@lesliechan721/aw 0.1.0-beta.10 → 0.1.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-config.d.mts +1 -50
- package/dist/authoring/assets/aw-config.mjs +58 -928
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
- package/dist/authoring/assets/command-runtime-config.mjs +134 -0
- package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +16 -39
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +43 -71
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +3 -3
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +5 -8
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +408 -1748
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-skill.mjs +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/native-runtime/reader-runtime.mjs +34 -0
- package/dist/native-runtime/reader.d.mts +6 -0
- package/dist/native-runtime/reader.mjs +11 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +11 -1
- package/dist/scripts/aw-skill-eval-materializer.js +119 -114
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js +32 -7
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +1 -1
- package/dist/scripts/plugin-staging.js +5 -2
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-context-guard.d.mts +1 -0
- package/dist/scripts/plugin-test-context-guard.mjs +59 -0
- package/dist/scripts/plugin-test-context-guard.mjs.map +1 -0
- package/dist/scripts/plugin-test-reporter.d.mts +2 -0
- package/dist/scripts/plugin-test-reporter.mjs +21 -0
- package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +5 -0
- package/dist/scripts/test-plugin-scripts.js +343 -58
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/scripts/test-workers.d.mts +24 -0
- package/dist/scripts/test-workers.mjs +59 -0
- package/dist/scripts/test-workers.mjs.map +1 -0
- package/dist/src/adapters/helpers.d.ts +7 -0
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +3 -0
- package/dist/src/authoring/workspace-commands.js +7 -2
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +48 -19
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +40 -3
- package/dist/src/commands/catalog-dev-source.js +333 -42
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-generation.d.ts +5 -0
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +11 -3
- package/dist/src/commands/catalog-publication-inspection.js +211 -59
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +12 -0
- package/dist/src/commands/catalog-publication-journal.js +78 -1
- package/dist/src/commands/catalog-publication-journal.js.map +1 -1
- package/dist/src/commands/catalog-publish.d.ts +21 -1
- package/dist/src/commands/catalog-publish.js +133 -92
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +25 -5
- package/dist/src/commands/catalog-source.js +153 -27
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.js +2 -2
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +31 -7
- package/dist/src/commands/catalog-store.js +379 -42
- package/dist/src/commands/catalog-store.js.map +1 -1
- package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
- package/dist/src/commands/catalog-workspace-resolution.js +18 -3
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
- package/dist/src/commands/console.js +33 -20
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +7 -0
- package/dist/src/commands/dependency-operation-plan.js +66 -30
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +11 -0
- package/dist/src/commands/deployment-confirmation.js +101 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +34 -0
- package/dist/src/commands/intent-command.js +174 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
- package/dist/src/commands/lifecycle-command-package.js +199 -0
- package/dist/src/commands/lifecycle-command-package.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +41 -0
- package/dist/src/commands/managed-commands.js +404 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +12 -2
- package/dist/src/commands/offline-cleanup-evidence.js +57 -35
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +72 -2
- package/dist/src/commands/operation-plan.js +54 -3
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/operation-planner.d.ts +6 -5
- package/dist/src/commands/operation-planner.js +23 -20
- package/dist/src/commands/operation-planner.js.map +1 -1
- package/dist/src/commands/options.d.ts +11 -16
- package/dist/src/commands/options.js +31 -25
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/permission-batch.d.ts +5 -0
- package/dist/src/commands/permission-batch.js +83 -0
- package/dist/src/commands/permission-batch.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.js +128 -58
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +14 -0
- package/dist/src/commands/public-config-confirmation.js +73 -0
- package/dist/src/commands/public-config-confirmation.js.map +1 -0
- package/dist/src/commands/public-interruption.d.ts +9 -0
- package/dist/src/commands/public-interruption.js +23 -0
- package/dist/src/commands/public-interruption.js.map +1 -0
- package/dist/src/commands/public-lifecycle-result.d.ts +106 -0
- package/dist/src/commands/public-lifecycle-result.js +536 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -0
- package/dist/src/commands/public-lifecycle.d.ts +27 -0
- package/dist/src/commands/public-lifecycle.js +569 -0
- package/dist/src/commands/public-lifecycle.js.map +1 -0
- package/dist/src/commands/public-plugin-query.d.ts +16 -0
- package/dist/src/commands/public-plugin-query.js +231 -0
- package/dist/src/commands/public-plugin-query.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +177 -16
- package/dist/src/commands/rebuild-command.js +3370 -1559
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +100 -55
- package/dist/src/commands/rebuild-integration.js +866 -3275
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +68 -13
- package/dist/src/commands/rebuild-operations.js +309 -120
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +99 -0
- package/dist/src/commands/rebuild-platform-integration.js +2329 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +14 -9
- package/dist/src/commands/reconcile-operation-plan.js +26 -6
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +437 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +51 -0
- package/dist/src/commands/review-preparation.js +400 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +5 -1
- package/dist/src/commands/runtime.js +41 -8
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +8 -0
- package/dist/src/commands/skill-eval.js +126 -73
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +148 -35
- package/dist/src/commands/status-v6.js +1166 -307
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/targets-command.d.ts +38 -0
- package/dist/src/commands/targets-command.js +182 -0
- package/dist/src/commands/targets-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +7 -3
- package/dist/src/commands/wizard.js +7 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +7 -1
- package/dist/src/commands/write-commands.js +129 -38
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +2 -3
- package/dist/src/constants.js +2 -3
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +6 -3
- package/dist/src/eval/manifest-v1.js +44 -33
- package/dist/src/eval/manifest-v1.js.map +1 -1
- package/dist/src/generators/local-plugin.d.ts +4 -2
- package/dist/src/generators/local-plugin.js +319 -353
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +20 -2
- package/dist/src/generators/permissions.js +82 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +2 -33
- package/dist/src/index.js +1575 -1919
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.d.ts +63 -0
- package/dist/src/intent/deployment-preferences.js +170 -0
- package/dist/src/intent/deployment-preferences.js.map +1 -0
- package/dist/src/intent/diagnostics.d.ts +11 -0
- package/dist/src/intent/diagnostics.js +14 -0
- package/dist/src/intent/diagnostics.js.map +1 -0
- package/dist/src/intent/intent-codec.d.ts +19 -0
- package/dist/src/intent/intent-codec.js +117 -0
- package/dist/src/intent/intent-codec.js.map +1 -0
- package/dist/src/intent/intent-store.d.ts +43 -0
- package/dist/src/intent/intent-store.js +118 -0
- package/dist/src/intent/intent-store.js.map +1 -0
- package/dist/src/intent/scope-context.d.ts +35 -0
- package/dist/src/intent/scope-context.js +179 -0
- package/dist/src/intent/scope-context.js.map +1 -0
- package/dist/src/intent/work-context.d.ts +13 -0
- package/dist/src/intent/work-context.js +22 -0
- package/dist/src/intent/work-context.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +6 -2
- package/dist/src/output/command-receipt.js +67 -32
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +28 -0
- package/dist/src/output/component-delivery.js +141 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +69 -0
- package/dist/src/output/public-result.js +403 -0
- package/dist/src/output/public-result.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +3 -0
- package/dist/src/output/rebuild-progress.js +34 -9
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.d.ts +7 -0
- package/dist/src/output/receipt-projection.js +664 -0
- package/dist/src/output/receipt-projection.js.map +1 -0
- package/dist/src/output/skill-invocation-notices.d.ts +18 -0
- package/dist/src/output/skill-invocation-notices.js +84 -0
- package/dist/src/output/skill-invocation-notices.js.map +1 -0
- package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
- package/dist/src/platforms/antigravity-permissions.js +388 -0
- package/dist/src/platforms/antigravity-permissions.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +9 -0
- package/dist/src/platforms/capabilities.js +125 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +394 -0
- package/dist/src/platforms/contracts.js +2 -0
- package/dist/src/platforms/contracts.js.map +1 -0
- package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
- package/dist/src/platforms/cursor-workspace-hook.js +198 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +100 -0
- package/dist/src/platforms/discovery.js +779 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/grok-permission-config.d.ts +23 -0
- package/dist/src/platforms/grok-permission-config.js +184 -0
- package/dist/src/platforms/grok-permission-config.js.map +1 -0
- package/dist/src/platforms/grok-permission-document.d.ts +4 -0
- package/dist/src/platforms/grok-permission-document.js +145 -0
- package/dist/src/platforms/grok-permission-document.js.map +1 -0
- package/dist/src/platforms/grok-permissions.d.ts +17 -0
- package/dist/src/platforms/grok-permissions.js +311 -0
- package/dist/src/platforms/grok-permissions.js.map +1 -0
- package/dist/src/platforms/host-permission-policy.d.ts +38 -0
- package/dist/src/platforms/host-permission-policy.js +86 -0
- package/dist/src/platforms/host-permission-policy.js.map +1 -0
- package/dist/src/platforms/identity.d.ts +4 -0
- package/dist/src/platforms/identity.js +22 -0
- package/dist/src/platforms/identity.js.map +1 -0
- package/dist/src/platforms/inspection-grok.d.ts +4 -0
- package/dist/src/platforms/inspection-grok.js +380 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +8 -0
- package/dist/src/platforms/inspection-native.js +584 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-opencode.d.ts +4 -0
- package/dist/src/platforms/inspection-opencode.js +98 -0
- package/dist/src/platforms/inspection-opencode.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +9 -0
- package/dist/src/platforms/inspection-pi.js +490 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection-query.d.ts +26 -0
- package/dist/src/platforms/inspection-query.js +118 -0
- package/dist/src/platforms/inspection-query.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +20 -0
- package/dist/src/platforms/inspection.js +259 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +35 -0
- package/dist/src/platforms/layout.js +332 -0
- package/dist/src/platforms/layout.js.map +1 -0
- package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
- package/dist/src/platforms/lifecycle-native-services.js +213 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +14 -0
- package/dist/src/platforms/lifecycle-native.js +234 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +29 -0
- package/dist/src/platforms/lifecycle.js +688 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
- package/dist/src/platforms/opencode-permission-config.js +253 -0
- package/dist/src/platforms/opencode-permission-config.js.map +1 -0
- package/dist/src/platforms/opencode-permissions.d.ts +39 -0
- package/dist/src/platforms/opencode-permissions.js +212 -0
- package/dist/src/platforms/opencode-permissions.js.map +1 -0
- package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
- package/dist/src/platforms/opencode-related-permissions.js +177 -0
- package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
- package/dist/src/platforms/permission-ownership.d.ts +89 -0
- package/dist/src/platforms/permission-ownership.js +543 -0
- package/dist/src/platforms/permission-ownership.js.map +1 -0
- package/dist/src/platforms/permission-sidecar.d.ts +70 -0
- package/dist/src/platforms/permission-sidecar.js +215 -0
- package/dist/src/platforms/permission-sidecar.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +126 -0
- package/dist/src/platforms/projection-code-extension.js.map +1 -0
- package/dist/src/platforms/projection-command-resources.d.ts +7 -0
- package/dist/src/platforms/projection-command-resources.js +74 -0
- package/dist/src/platforms/projection-command-resources.js.map +1 -0
- package/dist/src/platforms/projection-files.d.ts +28 -0
- package/dist/src/platforms/projection-files.js +113 -0
- package/dist/src/platforms/projection-files.js.map +1 -0
- package/dist/src/platforms/projection-marketplace.d.ts +19 -0
- package/dist/src/platforms/projection-marketplace.js +42 -0
- package/dist/src/platforms/projection-marketplace.js.map +1 -0
- package/dist/src/platforms/projection.d.ts +13 -0
- package/dist/src/platforms/projection.js +578 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/read-only-retry-policy.d.ts +34 -0
- package/dist/src/platforms/read-only-retry-policy.js +70 -0
- package/dist/src/platforms/read-only-retry-policy.js.map +1 -0
- package/dist/src/platforms/registry.d.ts +4 -0
- package/dist/src/platforms/registry.js +30 -0
- package/dist/src/platforms/registry.js.map +1 -0
- package/dist/src/platforms/retirement-native.d.ts +6 -0
- package/dist/src/platforms/retirement-native.js +95 -0
- package/dist/src/platforms/retirement-native.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +20 -0
- package/dist/src/platforms/supplement-layout.js +54 -0
- package/dist/src/platforms/supplement-layout.js.map +1 -0
- package/dist/src/platforms/supplement-state.d.ts +13 -0
- package/dist/src/platforms/supplement-state.js +93 -0
- package/dist/src/platforms/supplement-state.js.map +1 -0
- package/dist/src/portable/commands.d.ts +60 -11
- package/dist/src/portable/commands.js +88 -346
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +25 -0
- package/dist/src/portable/historical-materialization.js +148 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +46 -2
- package/dist/src/portable/materializer.js +262 -259
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.d.ts +17 -0
- package/dist/src/portable/recovery-layout.js +42 -0
- package/dist/src/portable/recovery-layout.js.map +1 -0
- package/dist/src/portable/recovery.d.ts +177 -0
- package/dist/src/portable/recovery.js +597 -0
- package/dist/src/portable/recovery.js.map +1 -0
- package/dist/src/portable/writer.d.ts +67 -0
- package/dist/src/portable/writer.js +321 -0
- package/dist/src/portable/writer.js.map +1 -0
- package/dist/src/recovery/coordinator.d.ts +175 -0
- package/dist/src/recovery/coordinator.js +1624 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +53 -0
- package/dist/src/recovery/demand.js +189 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/install-concurrency.d.ts +48 -0
- package/dist/src/recovery/install-concurrency.js +196 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -0
- package/dist/src/recovery/interruption.d.ts +19 -0
- package/dist/src/recovery/interruption.js +43 -0
- package/dist/src/recovery/interruption.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +46 -0
- package/dist/src/recovery/joint-coordinator.js +1723 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +72 -0
- package/dist/src/recovery/joint-demand.js +332 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/joint-install-execution.d.ts +19 -0
- package/dist/src/recovery/joint-install-execution.js +308 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -0
- package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
- package/dist/src/recovery/joint-install-native-rebase.js +67 -0
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
- package/dist/src/recovery/performance.d.ts +4 -0
- package/dist/src/recovery/performance.js +26 -0
- package/dist/src/recovery/performance.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +131 -0
- package/dist/src/recovery/receipt.js +91 -0
- package/dist/src/recovery/receipt.js.map +1 -0
- package/dist/src/recovery/retirement.d.ts +47 -0
- package/dist/src/recovery/retirement.js +499 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +143 -0
- package/dist/src/recovery/status.js +1528 -0
- package/dist/src/recovery/status.js.map +1 -0
- package/dist/src/recovery/types.d.ts +85 -0
- package/dist/src/recovery/types.js +2 -0
- package/dist/src/recovery/types.js.map +1 -0
- package/dist/src/review/eval-source-input.d.ts +44 -0
- package/dist/src/review/eval-source-input.js +213 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/platform-profile.d.ts +5 -0
- package/dist/src/review/platform-profile.js +13 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +20 -0
- package/dist/src/review/review-profile.js +286 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +20 -0
- package/dist/src/review/review-selection.js +502 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +71 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +67 -0
- package/dist/src/review/skill-materialization.js +235 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +203 -0
- package/dist/src/review/source-binding.js +791 -0
- package/dist/src/review/source-binding.js.map +1 -0
- package/dist/src/tui/agent-management.d.ts +23 -0
- package/dist/src/tui/agent-management.js +319 -0
- package/dist/src/tui/agent-management.js.map +1 -0
- package/dist/src/tui/agent-settings.d.ts +47 -0
- package/dist/src/tui/agent-settings.js +97 -0
- package/dist/src/tui/agent-settings.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +9 -0
- package/dist/src/tui/catalog-generation.js +96 -6
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/projection.d.ts +2 -2
- package/dist/src/tui/catalog-sources/screens.js +19 -12
- package/dist/src/tui/catalog-sources/screens.js.map +1 -1
- package/dist/src/tui/catalog-sources/session.d.ts +11 -1
- package/dist/src/tui/catalog-sources/session.js +80 -5
- package/dist/src/tui/catalog-sources/session.js.map +1 -1
- package/dist/src/tui/catalog-sources/types.d.ts +15 -2
- package/dist/src/tui/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +113 -3
- package/dist/src/tui/components.js +201 -34
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +30 -0
- package/dist/src/tui/config-array-draft.js +51 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +44 -0
- package/dist/src/tui/config-leaf-editor.js +227 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-object-suggestions.d.ts +15 -0
- package/dist/src/tui/config-object-suggestions.js +71 -0
- package/dist/src/tui/config-object-suggestions.js.map +1 -0
- package/dist/src/tui/config-references.d.ts +38 -0
- package/dist/src/tui/config-references.js +82 -0
- package/dist/src/tui/config-references.js.map +1 -0
- package/dist/src/tui/config-suggestions.d.ts +27 -0
- package/dist/src/tui/config-suggestions.js +62 -0
- package/dist/src/tui/config-suggestions.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +23 -0
- package/dist/src/tui/config-value-presentation.js +151 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +14 -5
- package/dist/src/tui/console-app-v4.js +9779 -2488
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +4 -3
- package/dist/src/tui/controller-runtime.js +1610 -590
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +583 -80
- package/dist/src/tui/controller.js +3362 -263
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/deployment-view.d.ts +14 -0
- package/dist/src/tui/deployment-view.js +175 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +31 -0
- package/dist/src/tui/diagnostic-projection.js +681 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +6 -2
- package/dist/src/tui/diagnostics.js +14 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +56 -0
- package/dist/src/tui/entity-cards.js +327 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +25 -0
- package/dist/src/tui/glossary.js +78 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/guided-setup.d.ts +25 -0
- package/dist/src/tui/guided-setup.js +101 -0
- package/dist/src/tui/guided-setup.js.map +1 -0
- package/dist/src/tui/index.d.ts +4 -1
- package/dist/src/tui/index.js +4 -1
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +1 -0
- package/dist/src/tui/input-display.js +23 -1
- package/dist/src/tui/input-display.js.map +1 -1
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +141 -28
- package/dist/src/tui/model.js +968 -285
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +76 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +91 -0
- package/dist/src/tui/operation-history.js +167 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +7 -0
- package/dist/src/tui/operation-review-planner.js +980 -146
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/plugin-content.d.ts +33 -0
- package/dist/src/tui/plugin-content.js +245 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +75 -0
- package/dist/src/tui/plugin-detail.js +267 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +38 -0
- package/dist/src/tui/reader.js +49 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +170 -39
- package/dist/src/tui/router.js +338 -50
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +49 -0
- package/dist/src/tui/scoped-flow.js +212 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +139 -0
- package/dist/src/tui/scoped-inventory.js +295 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +696 -0
- package/dist/src/tui/screen-registry.js +226 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +8 -0
- package/dist/src/tui/session-console-app.js +24 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +219 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.js.map +1 -0
- package/dist/src/tui/theme.d.ts +12 -0
- package/dist/src/tui/theme.js +12 -0
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +1 -0
- package/dist/src/tui/viewport.js +23 -0
- package/dist/src/tui/viewport.js.map +1 -1
- package/dist/src/tui/wizard.js +26 -4
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +105 -83
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +10 -4
- package/dist/src/utils/agent-version.js +6 -8
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +18 -25
- package/dist/src/utils/artifact-plan.js +59 -445
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +64 -90
- package/dist/src/utils/artifact-renderer.js +202 -303
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +19 -14
- package/dist/src/utils/artifact-request.js +51 -36
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/artifact-sources.d.ts +4 -8
- package/dist/src/utils/artifact-sources.js +15 -6
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.js +2 -1
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-layout.d.ts +2 -0
- package/dist/src/utils/bundle-layout.js +88 -158
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +2 -12
- package/dist/src/utils/catalog-digests.js +7 -55
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +28 -4
- package/dist/src/utils/catalog-generation-resolver.js +146 -40
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +24 -2
- package/dist/src/utils/catalog-generation-service.js +92 -48
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.js +1 -1
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +4 -0
- package/dist/src/utils/catalog-generation-store.js +68 -10
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +61 -4
- package/dist/src/utils/catalog-operation-context.js +225 -4
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +4 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +3 -0
- package/dist/src/utils/catalog-snapshot.js +4 -1
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +3 -2
- package/dist/src/utils/catalog-source-impact.js +142 -20
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +57 -1
- package/dist/src/utils/catalog-source-references.js +755 -162
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +1 -1
- package/dist/src/utils/catalog-sources.js +21 -5
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +3 -0
- package/dist/src/utils/codex-config.js +7 -0
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
- package/dist/src/utils/codex-executable-discovery.js +431 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +23 -42
- package/dist/src/utils/codex-manager.js +79 -767
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +40 -1
- package/dist/src/utils/codex-native-observation.js +172 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-reconciler.d.ts +2 -7
- package/dist/src/utils/codex-reconciler.js +33 -5
- package/dist/src/utils/codex-reconciler.js.map +1 -1
- package/dist/src/utils/codex-shared-native.d.ts +8 -26
- package/dist/src/utils/codex-shared-native.js +63 -83
- package/dist/src/utils/codex-shared-native.js.map +1 -1
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +29 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +6 -2
- package/dist/src/utils/codex-surface-analysis.js +31 -56
- package/dist/src/utils/codex-surface-analysis.js.map +1 -1
- package/dist/src/utils/component-agent-binding.d.ts +17 -0
- package/dist/src/utils/component-agent-binding.js +119 -0
- package/dist/src/utils/component-agent-binding.js.map +1 -0
- package/dist/src/utils/component-command-preparation.d.ts +33 -0
- package/dist/src/utils/component-command-preparation.js +129 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-gap.d.ts +4 -0
- package/dist/src/utils/component-gap.js +16 -0
- package/dist/src/utils/component-gap.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +53 -0
- package/dist/src/utils/component-resources.js +340 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/config-platforms.d.ts +21 -0
- package/dist/src/utils/config-platforms.js +51 -0
- package/dist/src/utils/config-platforms.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
- package/dist/src/utils/dynamic-skill-tree.js +33 -40
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +3 -0
- package/dist/src/utils/git-catalog-provider.js +49 -3
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +19 -12
- package/dist/src/utils/local-marketplace.js +97 -194
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
- package/dist/src/utils/managed-command-cli-review.js +431 -0
- package/dist/src/utils/managed-command-cli-review.js.map +1 -0
- package/dist/src/utils/managed-command-closure.d.ts +14 -0
- package/dist/src/utils/managed-command-closure.js +156 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-errors.d.ts +5 -0
- package/dist/src/utils/managed-command-errors.js +10 -0
- package/dist/src/utils/managed-command-errors.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +90 -0
- package/dist/src/utils/managed-command-materialization.js +375 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- package/dist/src/utils/managed-command-preparation.d.ts +30 -0
- package/dist/src/utils/managed-command-preparation.js +39 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +33 -0
- package/dist/src/utils/managed-command-review.js +80 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-runtime.d.ts +36 -0
- package/dist/src/utils/managed-command-runtime.js +126 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
- package/dist/src/utils/managed-command-snapshots.js +89 -0
- package/dist/src/utils/managed-command-snapshots.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +141 -0
- package/dist/src/utils/managed-command-store.js +839 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +6 -1
- package/dist/src/utils/multi-source-catalog.js +9 -4
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +8 -0
- package/dist/src/utils/native-cli-interruption.js +65 -0
- package/dist/src/utils/native-cli-interruption.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +37 -6
- package/dist/src/utils/native-cli.js +523 -60
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +29 -0
- package/dist/src/utils/native-demand.js +4 -0
- package/dist/src/utils/native-demand.js.map +1 -0
- package/dist/src/utils/native-tool-context.d.ts +17 -0
- package/dist/src/utils/native-tool-context.js +40 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +8 -0
- package/dist/src/utils/native-tool-review.js +14 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +38 -3
- package/dist/src/utils/ownership.js +118 -11
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/package-content.d.ts +7 -0
- package/dist/src/utils/package-content.js +70 -0
- package/dist/src/utils/package-content.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.js +2 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +5 -2
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +69 -0
- package/dist/src/utils/platform-empty-state.js +249 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -1
- package/dist/src/utils/platform-support.js +1 -1
- package/dist/src/utils/platform-support.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
- package/dist/src/utils/plugin-config-command-apply.js +142 -0
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
- package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
- package/dist/src/utils/plugin-config-diagnostics.js +44 -0
- package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.d.ts +76 -0
- package/dist/src/utils/plugin-config-impact.js +359 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-references.d.ts +116 -0
- package/dist/src/utils/plugin-config-references.js +379 -0
- package/dist/src/utils/plugin-config-references.js.map +1 -0
- package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
- package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
- package/dist/src/utils/plugin-config-suggestions.js +322 -0
- package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +108 -19
- package/dist/src/utils/plugin-config-write.js +781 -568
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +122 -43
- package/dist/src/utils/plugin-config.js +574 -610
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-dependencies.d.ts +1 -1
- package/dist/src/utils/plugin-dependencies.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +41 -17
- package/dist/src/utils/plugin-scripts.js +586 -123
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-lock.js +14 -5
- package/dist/src/utils/process-lock.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -1
- package/dist/src/utils/project-boundary.js +33 -11
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +24 -1
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +18 -0
- package/dist/src/utils/runtime-config.js +64 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
- package/dist/src/utils/runtime-skill-closure.js +50 -7
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/skill-invocation-warning.d.ts +19 -0
- package/dist/src/utils/skill-invocation-warning.js +43 -0
- package/dist/src/utils/skill-invocation-warning.js.map +1 -0
- package/dist/src/utils/skill-validation.js +0 -5
- package/dist/src/utils/skill-validation.js.map +1 -1
- package/dist/src/utils/state-paths.d.ts +8 -3
- package/dist/src/utils/state-paths.js +53 -16
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +2 -2
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +7 -0
- package/dist/src/utils/windows-claude-shim.js +10 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/src/utils/windows-npm-shim.d.ts +16 -0
- package/dist/src/utils/windows-npm-shim.js +155 -0
- package/dist/src/utils/windows-npm-shim.js.map +1 -0
- package/dist/vitest.config.js +109 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +20 -12
- package/dist/authoring/templates/aw-config-runtime.d.mts +0 -2
- package/dist/authoring/templates/aw-config-runtime.mjs +0 -407
- package/dist/authoring/templates/aw-config-runtime.mjs.map +0 -1
- package/dist/src/commands/review-publication.d.ts +0 -99
- package/dist/src/commands/review-publication.js +0 -904
- package/dist/src/commands/review-publication.js.map +0 -1
- package/dist/src/commands/sync-command.d.ts +0 -23
- package/dist/src/commands/sync-command.js +0 -242
- package/dist/src/commands/sync-command.js.map +0 -1
- package/dist/src/portable/skills-cli.d.ts +0 -43
- package/dist/src/portable/skills-cli.js +0 -148
- package/dist/src/portable/skills-cli.js.map +0 -1
- package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
- package/dist/src/utils/codex-native-render-receipt.js +0 -205
- package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
- package/dist/src/utils/plugin-intent-state.d.ts +0 -34
- package/dist/src/utils/plugin-intent-state.js +0 -289
- package/dist/src/utils/plugin-intent-state.js.map +0 -1
- package/dist/src/utils/slash-commands.d.ts +0 -1
- package/dist/src/utils/slash-commands.js +0 -2
- package/dist/src/utils/slash-commands.js.map +0 -1
|
@@ -1,14 +1,95 @@
|
|
|
1
|
+
import { hasRecommendedHints } from '../utils/plugin-config-suggestion-runner.js';
|
|
2
|
+
import { isPlatformTarget, PLATFORM_TARGETS } from '@lesliechan721/aw-plugin-core/manifest';
|
|
3
|
+
import { agentLabel } from './glossary.js';
|
|
1
4
|
import crypto from 'node:crypto';
|
|
2
5
|
import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
|
|
6
|
+
import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
|
|
7
|
+
import { NativeCliError } from '../utils/native-cli.js';
|
|
8
|
+
import { ConfigApplyInterruptedError } from '../utils/plugin-config-write.js';
|
|
9
|
+
import { PluginConfigReferenceBlockedError } from '../utils/plugin-config-references.js';
|
|
10
|
+
import { parsePluginId } from '../utils/multi-source-catalog.js';
|
|
11
|
+
import { flattenStatusTargets, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, statusTargetSharedNative, } from '../commands/status-v6.js';
|
|
3
12
|
import { buildRebuildReceiptJson, requestedIntentAction } from '../output/command-receipt.js';
|
|
13
|
+
import { SKILL_INVOCATION_NOTICE } from '../utils/skill-invocation-warning.js';
|
|
4
14
|
import { buildOperationResultModel } from '../commands/operation-planner.js';
|
|
5
15
|
import { buildOperationReviewProjection } from './operation-review-planner.js';
|
|
6
|
-
import { buildTuiViewModel, dependencyPlacementTargets,
|
|
7
|
-
import {
|
|
16
|
+
import { buildTuiViewModel, dependencyPlacementTargets, hasScopedExtensionOwnership, } from './model.js';
|
|
17
|
+
import { buildPluginDetailSubject } from './plugin-detail.js';
|
|
18
|
+
import { safeDiagnosticCode, sanitizeDiagnosticText } from './diagnostics.js';
|
|
19
|
+
import { projectComponentDeliveryHistory, projectDeliveryNoticeHistory, projectExecutionDiagnostics, projectSkillInvocationHistory, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
|
|
20
|
+
import { projectComponentDelivery } from '../output/component-delivery.js';
|
|
21
|
+
import { OperationHistoryStore, } from './operation-history.js';
|
|
8
22
|
import { targetHasArtifactCollision } from '../utils/target-eligibility.js';
|
|
23
|
+
import { hasStatusInstallationEvidence } from './scoped-inventory.js';
|
|
24
|
+
import { buildScopedInventory, inventoryPluginIds } from './scoped-inventory.js';
|
|
25
|
+
import { guidedSkipWarning } from './guided-setup.js';
|
|
26
|
+
import { projectScopedRecoveryHistory } from './scoped-flow.js';
|
|
9
27
|
import { TuiRouter, } from './router.js';
|
|
28
|
+
import { normalizeTuiRoute } from './screen-registry.js';
|
|
10
29
|
import { CatalogSourcesSession } from './catalog-sources/session.js';
|
|
11
30
|
import { catalogSourceAutoCheckOnlyValue, projectCatalogSourceMutationWarnings, } from './catalog-sources/review.js';
|
|
31
|
+
import { buildPluginWriteTaskCandidates, pluginWriteTaskTargetKey, } from './plugin-write-task.js';
|
|
32
|
+
export const PLUGIN_WRITE_BATCH_ACTIONS = [
|
|
33
|
+
'install',
|
|
34
|
+
'sync',
|
|
35
|
+
'reinstall',
|
|
36
|
+
'uninstall',
|
|
37
|
+
'cleanup',
|
|
38
|
+
];
|
|
39
|
+
export function pluginWriteBatchTargets(action, pluginIds, statusTargets) {
|
|
40
|
+
const selected = new Set(pluginIds);
|
|
41
|
+
const targets = [];
|
|
42
|
+
const add = (target, scope) => {
|
|
43
|
+
targets.push({ pluginId: target.pluginId, platform: target.platform, scope });
|
|
44
|
+
};
|
|
45
|
+
for (const target of statusTargets) {
|
|
46
|
+
if (!selected.has(target.pluginId))
|
|
47
|
+
continue;
|
|
48
|
+
const intent = statusTargetIntent(target);
|
|
49
|
+
const ownership = statusTargetOwnershipState(target);
|
|
50
|
+
const activation = statusTargetActivation(target);
|
|
51
|
+
const hasManagedOutput = ownership !== 'absent';
|
|
52
|
+
const hasCleanupEvidence = ownership === 'present' || ownership === 'partial'
|
|
53
|
+
|| intent.relation === 'managed'
|
|
54
|
+
|| target.reasons.some((reason) => reason.code === 'removedPluginCleanupRequired')
|
|
55
|
+
|| (target.platform === 'codex' && activation?.evidence === 'observed'
|
|
56
|
+
&& (activation.user !== undefined || activation.project !== undefined));
|
|
57
|
+
if (action === 'sync' || action === 'reinstall') {
|
|
58
|
+
intent.scopes.forEach((scope) => add(target, scope));
|
|
59
|
+
if (hasManagedOutput)
|
|
60
|
+
add(target, target.scope);
|
|
61
|
+
if (target.platform === 'codex') {
|
|
62
|
+
if (activation?.user === true)
|
|
63
|
+
add(target, 'user');
|
|
64
|
+
if (activation?.project === true)
|
|
65
|
+
add(target, 'project');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (action === 'uninstall') {
|
|
69
|
+
if (hasManagedOutput)
|
|
70
|
+
add(target, target.scope);
|
|
71
|
+
if (target.platform === 'codex') {
|
|
72
|
+
if (activation?.user === true)
|
|
73
|
+
add(target, 'user');
|
|
74
|
+
if (activation?.project === true)
|
|
75
|
+
add(target, 'project');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (hasCleanupEvidence) {
|
|
79
|
+
add(target, target.scope);
|
|
80
|
+
if (target.platform === 'codex') {
|
|
81
|
+
if (activation?.user !== undefined)
|
|
82
|
+
add(target, 'user');
|
|
83
|
+
if (activation?.project !== undefined)
|
|
84
|
+
add(target, 'project');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [...new Map(targets.map((target) => [
|
|
89
|
+
[target.pluginId, target.platform, target.scope].join('\0'), target,
|
|
90
|
+
])).values()].sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
91
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en'));
|
|
92
|
+
}
|
|
12
93
|
function reviewPreparationStageLabel(stage) {
|
|
13
94
|
return {
|
|
14
95
|
refresh: '刷新相关来源',
|
|
@@ -24,11 +105,44 @@ function reviewPreparationStageLabel(stage) {
|
|
|
24
105
|
}
|
|
25
106
|
export class TuiOperationBlockedError extends Error {
|
|
26
107
|
code;
|
|
27
|
-
|
|
108
|
+
diagnostics;
|
|
109
|
+
constructor(code, message, diagnostics) {
|
|
28
110
|
super(message);
|
|
29
111
|
this.name = 'TuiOperationBlockedError';
|
|
30
112
|
this.code = code;
|
|
113
|
+
if (diagnostics?.length)
|
|
114
|
+
this.diagnostics = [...structuredClone(diagnostics)];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Classify the original error, before any generic operation-error wrapping. */
|
|
118
|
+
export function configSaveFailureDetail(error) {
|
|
119
|
+
if (error instanceof PluginConfigReferenceBlockedError) {
|
|
120
|
+
return { kind: 'referenceBlocked', blockers: error.blockers };
|
|
121
|
+
}
|
|
122
|
+
if (error instanceof TuiOperationBlockedError
|
|
123
|
+
|| (error instanceof Error && 'code' in error && error.code === 'configReferenceInvalid')) {
|
|
124
|
+
return { kind: 'message', message: error.message };
|
|
31
125
|
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
function configSaveFailureMessage(detail, sensitiveValues) {
|
|
129
|
+
const sanitize = (message) => sanitizeDiagnosticText(message, [], sensitiveValues);
|
|
130
|
+
if (detail.kind === 'message')
|
|
131
|
+
return sanitize(detail.message);
|
|
132
|
+
const [blocker, ...others] = detail.blockers;
|
|
133
|
+
const more = others.length ? `另有 ${others.length} 个阻断原因。` : '';
|
|
134
|
+
if (!blocker)
|
|
135
|
+
return 'configReferenceInUse';
|
|
136
|
+
if (blocker.kind === 'unreadable') {
|
|
137
|
+
return `无法核实配置引用,请检查并修复相关配置或来源。${more}\n${sanitize(`configReferenceInUse: ${blocker.location}`)}`;
|
|
138
|
+
}
|
|
139
|
+
// Redact before shortening the key so a sensitive token cannot be displayed partially.
|
|
140
|
+
const safeKey = sanitize(blocker.key);
|
|
141
|
+
const key = safeKey.length > 48 ? `${safeKey.slice(0, 47)}…` : safeKey;
|
|
142
|
+
const guidance = blocker.issueCode === 'valueRef' ? '仍有配置引用,请先修改引用。'
|
|
143
|
+
: blocker.issueCode === 'valueRefReserved' ? '配置键与保留值冲突,请修改该键。'
|
|
144
|
+
: '引用配置校验失败,请检查相关配置。';
|
|
145
|
+
return `${guidance}${more}\n${sanitize(`configReferenceInUse: ${blocker.consumer} · ${blocker.issuePath} · key ${key} · ${blocker.issueMessage}`)}`;
|
|
32
146
|
}
|
|
33
147
|
export class TuiConfigInvalidStoreError extends Error {
|
|
34
148
|
code = 'invalidConfigStores';
|
|
@@ -48,6 +162,301 @@ function stableValue(value) {
|
|
|
48
162
|
.sort(([left], [right]) => left.localeCompare(right, 'en'))
|
|
49
163
|
.map(([key, entry]) => [key, stableValue(entry)]));
|
|
50
164
|
}
|
|
165
|
+
function canonicalPluginIds(pluginIds) {
|
|
166
|
+
return [...new Set(pluginIds)].sort((left, right) => left.localeCompare(right, 'en'));
|
|
167
|
+
}
|
|
168
|
+
function canonicalBatchTargets(targets) {
|
|
169
|
+
const byKey = new Map();
|
|
170
|
+
for (const target of targets) {
|
|
171
|
+
byKey.set([target.pluginId, target.platform, target.scope].join('\0'), target);
|
|
172
|
+
}
|
|
173
|
+
return [...byKey.values()].sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
174
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en'));
|
|
175
|
+
}
|
|
176
|
+
function canonicalPluginWriteTaskTargets(targets) {
|
|
177
|
+
return [...new Map(targets.map((target) => [pluginWriteTaskTargetKey(target), target])).values()]
|
|
178
|
+
.sort((left, right) => pluginWriteTaskTargetKey(left)
|
|
179
|
+
.localeCompare(pluginWriteTaskTargetKey(right), 'en'));
|
|
180
|
+
}
|
|
181
|
+
function normalizeOperationIntent(intent) {
|
|
182
|
+
if (intent.kind === 'configSave' || intent.kind === 'configReset' || intent.kind === 'configSaveBatch') {
|
|
183
|
+
return { ...intent, context: intent.context ?? 'user',
|
|
184
|
+
...(intent.kind === 'configSave' ? { scope: 'user',
|
|
185
|
+
apply: intent.retryApply ? true : intent.apply } : {}) };
|
|
186
|
+
}
|
|
187
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
188
|
+
return { ...intent, targets: canonicalPluginWriteTaskTargets(intent.targets) };
|
|
189
|
+
}
|
|
190
|
+
if (intent.kind !== 'pluginWriteBatch')
|
|
191
|
+
return intent;
|
|
192
|
+
if (intent.selection.kind === 'targets') {
|
|
193
|
+
return {
|
|
194
|
+
...intent,
|
|
195
|
+
selection: {
|
|
196
|
+
kind: intent.selection.kind,
|
|
197
|
+
targets: canonicalBatchTargets(intent.selection.targets),
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (intent.selection.kind !== 'selected')
|
|
202
|
+
return intent;
|
|
203
|
+
return {
|
|
204
|
+
...intent,
|
|
205
|
+
selection: {
|
|
206
|
+
kind: 'selected',
|
|
207
|
+
pluginIds: canonicalPluginIds(intent.selection.pluginIds),
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function assertPluginWriteTaskEvidence(intent, evidence) {
|
|
212
|
+
const candidate = evidence;
|
|
213
|
+
const plan = candidate.taskPlan;
|
|
214
|
+
if (!plan || plan.goal !== intent.goal || !Array.isArray(plan.requestedTargets)
|
|
215
|
+
|| !Array.isArray(plan.executableTargets) || !Array.isArray(plan.blockedTargets)
|
|
216
|
+
|| !Array.isArray(plan.causes) || !Array.isArray(plan.sources)
|
|
217
|
+
|| typeof plan.targetFingerprint !== 'string' || typeof plan.planFingerprint !== 'string'
|
|
218
|
+
|| JSON.stringify(plan.requestedTargets) !== JSON.stringify(intent.targets)
|
|
219
|
+
|| plan.executableTargets.length === 0) {
|
|
220
|
+
throw new TuiOperationBlockedError('taskEvidenceInvalid', '任务确认信息不完整。');
|
|
221
|
+
}
|
|
222
|
+
if (plan.planFingerprint !== operationEvidenceFingerprint(evidence)) {
|
|
223
|
+
throw new TuiOperationBlockedError('taskEvidenceInvalid', '任务确认指纹无效。');
|
|
224
|
+
}
|
|
225
|
+
if (intent.executionPolicy === 'all' && plan.blockedTargets.length > 0) {
|
|
226
|
+
throw new TuiOperationBlockedError('taskHasBlockedTargets', '部分目标需要先处理,不能作为完整任务执行。');
|
|
227
|
+
}
|
|
228
|
+
const requested = new Set(plan.requestedTargets.map(pluginWriteTaskTargetKey));
|
|
229
|
+
const executable = new Set(plan.executableTargets.map(pluginWriteTaskTargetKey));
|
|
230
|
+
const blocked = new Set(plan.blockedTargets.map((target) => pluginWriteTaskTargetKey(target.target)));
|
|
231
|
+
if (executable.size !== plan.executableTargets.length || blocked.size !== plan.blockedTargets.length
|
|
232
|
+
|| [...executable].some((key) => !requested.has(key) || blocked.has(key))
|
|
233
|
+
|| [...blocked].some((key) => !requested.has(key))
|
|
234
|
+
|| [...requested].some((key) => !executable.has(key) && !blocked.has(key))) {
|
|
235
|
+
throw new TuiOperationBlockedError('taskEvidenceInvalid', '任务目标分区无效。');
|
|
236
|
+
}
|
|
237
|
+
const grouped = new Set();
|
|
238
|
+
for (const source of plan.sources) {
|
|
239
|
+
if (!source.sourceId || !source.sourceIdentity || source.requestedTargets.length === 0
|
|
240
|
+
|| source.executable !== Boolean(source.preview.operationPlan)
|
|
241
|
+
|| source.requestedTargets.some((target) => !executable.has(pluginWriteTaskTargetKey(target))
|
|
242
|
+
|| sourceIdFromPluginId(target.pluginId) !== source.sourceId)
|
|
243
|
+
|| source.causes.some((cause) => cause.sourceId !== source.sourceId
|
|
244
|
+
|| cause.sourceIdentity !== source.sourceIdentity
|
|
245
|
+
|| cause.consumers.some((consumer) => !executable.has(pluginWriteTaskTargetKey(consumer))))) {
|
|
246
|
+
throw new TuiOperationBlockedError('taskEvidenceInvalid', '任务来源计划无效。');
|
|
247
|
+
}
|
|
248
|
+
source.requestedTargets.forEach((target) => grouped.add(pluginWriteTaskTargetKey(target)));
|
|
249
|
+
}
|
|
250
|
+
if ([...executable].some((key) => !grouped.has(key))) {
|
|
251
|
+
throw new TuiOperationBlockedError('taskEvidenceInvalid', '任务来源计划缺少可执行目标。');
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function assertPluginWriteBatchEvidence(evidence) {
|
|
255
|
+
const candidate = evidence;
|
|
256
|
+
if (!Array.isArray(candidate.requestedPluginIds) || !Array.isArray(candidate.groups)) {
|
|
257
|
+
throw new TuiOperationBlockedError('batchEvidenceInvalid', '批量确认信息不完整。');
|
|
258
|
+
}
|
|
259
|
+
const requestedPluginIds = canonicalPluginIds(candidate.requestedPluginIds);
|
|
260
|
+
if (requestedPluginIds.length === 0
|
|
261
|
+
|| JSON.stringify(requestedPluginIds) !== JSON.stringify(candidate.requestedPluginIds)) {
|
|
262
|
+
throw new TuiOperationBlockedError('batchEvidenceInvalid', '批量根插件集合无效。');
|
|
263
|
+
}
|
|
264
|
+
const requested = new Set(requestedPluginIds);
|
|
265
|
+
const groupIds = new Set();
|
|
266
|
+
const groupedRoots = new Set();
|
|
267
|
+
for (const group of candidate.groups) {
|
|
268
|
+
if (!group || typeof group.groupId !== 'string' || group.groupId.length === 0
|
|
269
|
+
|| typeof group.sourceId !== 'string' || group.sourceId.length === 0
|
|
270
|
+
|| groupIds.has(group.groupId)
|
|
271
|
+
|| !Array.isArray(group.requestedPluginIds)
|
|
272
|
+
|| group.requestedPluginIds.length === 0
|
|
273
|
+
|| JSON.stringify(canonicalPluginIds(group.requestedPluginIds))
|
|
274
|
+
!== JSON.stringify(group.requestedPluginIds)
|
|
275
|
+
|| group.requestedPluginIds.some((pluginId) => !requested.has(pluginId))
|
|
276
|
+
|| group.executable !== Boolean(group.preview?.operationPlan)) {
|
|
277
|
+
throw new TuiOperationBlockedError('batchEvidenceInvalid', '批量分组确认信息无效。');
|
|
278
|
+
}
|
|
279
|
+
groupIds.add(group.groupId);
|
|
280
|
+
group.requestedPluginIds.forEach((pluginId) => groupedRoots.add(pluginId));
|
|
281
|
+
}
|
|
282
|
+
if (requestedPluginIds.some((pluginId) => !groupedRoots.has(pluginId))) {
|
|
283
|
+
throw new TuiOperationBlockedError('batchEvidenceInvalid', '批量分组缺少请求根插件。');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export function pluginWriteBatchFailedRequestedTargets(execution) {
|
|
287
|
+
const failed = [];
|
|
288
|
+
for (const group of execution.groupResults) {
|
|
289
|
+
const roots = new Set(group.requestedPluginIds);
|
|
290
|
+
const targetsByPlugin = new Map();
|
|
291
|
+
for (const target of group.result.targetResults) {
|
|
292
|
+
const pluginId = target.target.pluginId;
|
|
293
|
+
if (!pluginId)
|
|
294
|
+
continue;
|
|
295
|
+
const entries = targetsByPlugin.get(pluginId) ?? [];
|
|
296
|
+
entries.push(target);
|
|
297
|
+
targetsByPlugin.set(pluginId, entries);
|
|
298
|
+
}
|
|
299
|
+
const successfulRootKeys = new Set(group.result.targetResults.flatMap((target) => {
|
|
300
|
+
const pluginId = target.target.pluginId;
|
|
301
|
+
return pluginId && roots.has(pluginId)
|
|
302
|
+
&& target.state !== 'failed' && target.action !== 'skipped'
|
|
303
|
+
? [[pluginId, target.target.platform, target.target.scope].join('\0')]
|
|
304
|
+
: [];
|
|
305
|
+
}));
|
|
306
|
+
const unsuccessful = group.result.targetResults.filter((target) => target.state === 'failed' || target.action === 'skipped');
|
|
307
|
+
for (const target of unsuccessful) {
|
|
308
|
+
const pending = target.target.pluginId
|
|
309
|
+
? [{ pluginId: target.target.pluginId, platform: target.target.platform }]
|
|
310
|
+
: [];
|
|
311
|
+
const visited = new Set();
|
|
312
|
+
while (pending.length > 0) {
|
|
313
|
+
const current = pending.shift();
|
|
314
|
+
const visitKey = [current.pluginId, current.platform].join('\0');
|
|
315
|
+
if (visited.has(visitKey))
|
|
316
|
+
continue;
|
|
317
|
+
visited.add(visitKey);
|
|
318
|
+
const candidates = (targetsByPlugin.get(current.pluginId) ?? [])
|
|
319
|
+
.filter((candidate) => candidate.target.platform === current.platform);
|
|
320
|
+
if (roots.has(current.pluginId)) {
|
|
321
|
+
if (candidates.length === 0) {
|
|
322
|
+
const retryTarget = {
|
|
323
|
+
pluginId: current.pluginId,
|
|
324
|
+
platform: current.platform,
|
|
325
|
+
scope: group.scope,
|
|
326
|
+
};
|
|
327
|
+
const key = [retryTarget.pluginId, retryTarget.platform, retryTarget.scope].join('\0');
|
|
328
|
+
if (!successfulRootKeys.has(key))
|
|
329
|
+
failed.push(retryTarget);
|
|
330
|
+
}
|
|
331
|
+
for (const candidate of candidates) {
|
|
332
|
+
const retryTarget = {
|
|
333
|
+
pluginId: current.pluginId,
|
|
334
|
+
platform: candidate.target.platform,
|
|
335
|
+
scope: candidate.target.scope,
|
|
336
|
+
};
|
|
337
|
+
const key = [current.pluginId, retryTarget.platform, retryTarget.scope].join('\0');
|
|
338
|
+
if (!successfulRootKeys.has(key))
|
|
339
|
+
failed.push(retryTarget);
|
|
340
|
+
}
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
for (const candidate of candidates) {
|
|
344
|
+
pending.push(...(candidate.requiredBy ?? []).map((pluginId) => ({
|
|
345
|
+
pluginId, platform: current.platform,
|
|
346
|
+
})));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return canonicalBatchTargets(failed);
|
|
352
|
+
}
|
|
353
|
+
export function pluginWriteBatchFailedRequestedPluginIds(execution) {
|
|
354
|
+
return canonicalPluginIds(pluginWriteBatchFailedRequestedTargets(execution)
|
|
355
|
+
.map((target) => target.pluginId));
|
|
356
|
+
}
|
|
357
|
+
export function pluginWriteTaskFailedRequestedTargets(execution) {
|
|
358
|
+
const requested = new Map(execution.taskPlan.requestedTargets.map((target) => [
|
|
359
|
+
pluginWriteTaskTargetKey(target), target,
|
|
360
|
+
]));
|
|
361
|
+
const failed = new Set();
|
|
362
|
+
const succeeded = new Set();
|
|
363
|
+
for (const source of execution.sourceResults) {
|
|
364
|
+
const sourceRequested = new Set(source.requestedTargets.map(pluginWriteTaskTargetKey));
|
|
365
|
+
if (source.result.targetResults.length === 0 && source.result.overallState !== 'succeeded') {
|
|
366
|
+
sourceRequested.forEach((key) => failed.add(key));
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
for (const result of source.result.targetResults) {
|
|
370
|
+
const pluginId = result.target.pluginId;
|
|
371
|
+
if (!pluginId)
|
|
372
|
+
continue;
|
|
373
|
+
const exactKey = pluginWriteTaskTargetKey({
|
|
374
|
+
pluginId,
|
|
375
|
+
platform: result.target.platform,
|
|
376
|
+
scope: result.target.scope,
|
|
377
|
+
});
|
|
378
|
+
if (sourceRequested.has(exactKey)) {
|
|
379
|
+
if (result.state === 'failed' || result.action === 'skipped')
|
|
380
|
+
failed.add(exactKey);
|
|
381
|
+
else
|
|
382
|
+
succeeded.add(exactKey);
|
|
383
|
+
}
|
|
384
|
+
if (result.state !== 'failed' && result.action !== 'skipped')
|
|
385
|
+
continue;
|
|
386
|
+
for (const cause of source.requestedTargets.length > 0
|
|
387
|
+
? execution.taskPlan.causes.filter((cause) => cause.sourceId === source.sourceId) : []) {
|
|
388
|
+
if (pluginWriteTaskTargetKey(cause.repairTarget) !== exactKey)
|
|
389
|
+
continue;
|
|
390
|
+
cause.consumers.forEach((consumer) => failed.add(pluginWriteTaskTargetKey(consumer)));
|
|
391
|
+
}
|
|
392
|
+
const placement = source.result.dependencyPlan?.targets.find((target) => target.pluginId === pluginId && target.platform === result.target.platform
|
|
393
|
+
&& (target.requestedScope ?? target.resolvedScope) === result.target.scope);
|
|
394
|
+
for (const consumer of placement?.requiredByTargets ?? []) {
|
|
395
|
+
failed.add(pluginWriteTaskTargetKey(consumer));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
for (const key of succeeded)
|
|
400
|
+
failed.delete(key);
|
|
401
|
+
return canonicalPluginWriteTaskTargets([...failed].flatMap((key) => {
|
|
402
|
+
const target = requested.get(key);
|
|
403
|
+
return target ? [target] : [];
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
function collectOperationSensitiveValues(intent) {
|
|
407
|
+
const values = [];
|
|
408
|
+
const visit = (value) => {
|
|
409
|
+
if (typeof value === 'string')
|
|
410
|
+
values.push(value);
|
|
411
|
+
else if (Array.isArray(value))
|
|
412
|
+
value.forEach(visit);
|
|
413
|
+
else if (value && typeof value === 'object')
|
|
414
|
+
Object.values(value).forEach(visit);
|
|
415
|
+
};
|
|
416
|
+
const collect = (operation) => {
|
|
417
|
+
const sensitiveKeys = new Set([
|
|
418
|
+
...(operation.sensitiveKeys ?? []),
|
|
419
|
+
...(operation.privateKeys ?? []),
|
|
420
|
+
]);
|
|
421
|
+
for (const [key, value] of Object.entries(operation.updates ?? {})) {
|
|
422
|
+
if (sensitiveKeys.has(key))
|
|
423
|
+
visit(value);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
if (intent.kind === 'configSave')
|
|
427
|
+
collect(intent);
|
|
428
|
+
else if (intent.kind === 'configSaveBatch') {
|
|
429
|
+
for (const group of intent.groups)
|
|
430
|
+
collect(group);
|
|
431
|
+
}
|
|
432
|
+
return values;
|
|
433
|
+
}
|
|
434
|
+
function sanitizeOperationSummary(summary, sensitiveValues) {
|
|
435
|
+
const text = (value) => sanitizeDiagnosticText(value, [], sensitiveValues);
|
|
436
|
+
return {
|
|
437
|
+
...summary,
|
|
438
|
+
message: text(summary.message),
|
|
439
|
+
...(summary.messages ? { messages: summary.messages.map(text) } : {}),
|
|
440
|
+
...(summary.changes ? { changes: summary.changes.map(text) } : {}),
|
|
441
|
+
...(summary.warnings ? { warnings: summary.warnings.map(text) } : {}),
|
|
442
|
+
...(summary.configDiagnostics ? { configDiagnostics: summary.configDiagnostics.map((diagnostic) => ({
|
|
443
|
+
...diagnostic, message: text(diagnostic.message),
|
|
444
|
+
})) } : {}),
|
|
445
|
+
...(summary.recoveryActions ? { recoveryActions: summary.recoveryActions.map(text) } : {}),
|
|
446
|
+
...(summary.commandResults ? { commandResults: summary.commandResults.map((result) => ({
|
|
447
|
+
...result,
|
|
448
|
+
errors: result.errors.map((error) => ({ ...error, message: text(error.message) })),
|
|
449
|
+
recoveryActions: result.recoveryActions.map(text),
|
|
450
|
+
})) } : {}),
|
|
451
|
+
...(summary.quarantineBasename ? { quarantineBasename: text(summary.quarantineBasename) } : {}),
|
|
452
|
+
...(summary.portable ? {
|
|
453
|
+
portable: {
|
|
454
|
+
...summary.portable,
|
|
455
|
+
...(summary.portable.recovery ? { recovery: text(summary.portable.recovery) } : {}),
|
|
456
|
+
},
|
|
457
|
+
} : {}),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
51
460
|
function deepFreeze(value) {
|
|
52
461
|
if (typeof value !== 'object' || value === null || Object.isFrozen(value))
|
|
53
462
|
return value;
|
|
@@ -58,27 +467,72 @@ function deepFreeze(value) {
|
|
|
58
467
|
function cloneFrozen(value) {
|
|
59
468
|
return deepFreeze(structuredClone(value));
|
|
60
469
|
}
|
|
61
|
-
function publicReviewPreparation(snapshot) {
|
|
62
|
-
if (snapshot.intent.kind !== 'catalogGeneration' || !snapshot.intent.sourceMutation)
|
|
63
|
-
return snapshot;
|
|
64
|
-
const mutation = snapshot.intent.sourceMutation;
|
|
65
|
-
const sourceMutation = mutation.action === 'add'
|
|
66
|
-
? {
|
|
67
|
-
...mutation,
|
|
68
|
-
source: mutation.source.type === 'path'
|
|
69
|
-
? { ...mutation.source, path: '<private>' }
|
|
70
|
-
: { ...mutation.source, url: '<private>' },
|
|
71
|
-
}
|
|
72
|
-
: {
|
|
73
|
-
...mutation,
|
|
74
|
-
update: 'url' in mutation.update
|
|
75
|
-
? { ...mutation.update, ...(mutation.update.url ? { url: '<private>' } : {}) }
|
|
76
|
-
: { ...mutation.update, ...('path' in mutation.update && mutation.update.path
|
|
77
|
-
? { path: '<private>' } : {}) },
|
|
78
|
-
};
|
|
79
|
-
return { ...snapshot, intent: { ...snapshot.intent, sourceMutation } };
|
|
80
|
-
}
|
|
81
470
|
export function operationEvidenceFingerprint(evidence) {
|
|
471
|
+
if (evidence.catalogStore) {
|
|
472
|
+
return crypto.createHash('sha256')
|
|
473
|
+
.update(JSON.stringify(stableValue({
|
|
474
|
+
catalog: evidence.catalog,
|
|
475
|
+
authorizedItems: evidence.catalogStore.authorizedItems,
|
|
476
|
+
})))
|
|
477
|
+
.digest('hex');
|
|
478
|
+
}
|
|
479
|
+
if ('taskPlan' in evidence) {
|
|
480
|
+
const task = evidence.taskPlan;
|
|
481
|
+
return crypto.createHash('sha256')
|
|
482
|
+
.update(JSON.stringify(stableValue({
|
|
483
|
+
catalog: evidence.catalog,
|
|
484
|
+
goal: task.goal,
|
|
485
|
+
requestedTargets: task.requestedTargets,
|
|
486
|
+
executableTargets: task.executableTargets,
|
|
487
|
+
causes: task.causes,
|
|
488
|
+
blockedTargets: task.blockedTargets,
|
|
489
|
+
targetFingerprint: task.targetFingerprint,
|
|
490
|
+
sources: task.sources.map((source) => ({
|
|
491
|
+
sourceId: source.sourceId,
|
|
492
|
+
sourceIdentity: source.sourceIdentity,
|
|
493
|
+
requestedTargets: source.requestedTargets,
|
|
494
|
+
causes: source.causes,
|
|
495
|
+
executable: source.executable,
|
|
496
|
+
planFingerprint: source.preview.operationPlan?.planFingerprint,
|
|
497
|
+
targetResults: source.preview.targetResults.map((target) => ({
|
|
498
|
+
pluginId: target.target.pluginId,
|
|
499
|
+
platform: target.target.platform,
|
|
500
|
+
scope: target.target.scope,
|
|
501
|
+
state: target.state,
|
|
502
|
+
action: target.action,
|
|
503
|
+
errorCode: target.errorCode,
|
|
504
|
+
requiredBy: target.requiredBy,
|
|
505
|
+
})),
|
|
506
|
+
})),
|
|
507
|
+
})))
|
|
508
|
+
.digest('hex');
|
|
509
|
+
}
|
|
510
|
+
if ('groups' in evidence && 'requestedPluginIds' in evidence) {
|
|
511
|
+
const batch = evidence;
|
|
512
|
+
return crypto.createHash('sha256')
|
|
513
|
+
.update(JSON.stringify(stableValue({
|
|
514
|
+
requestedPluginIds: batch.requestedPluginIds,
|
|
515
|
+
groups: batch.groups.map((group) => ({
|
|
516
|
+
groupId: group.groupId,
|
|
517
|
+
sourceId: group.sourceId,
|
|
518
|
+
platform: group.platform,
|
|
519
|
+
requestedPluginIds: group.requestedPluginIds,
|
|
520
|
+
executable: group.executable,
|
|
521
|
+
planFingerprint: group.preview.operationPlan?.planFingerprint,
|
|
522
|
+
overallState: group.preview.overallState,
|
|
523
|
+
targetResults: group.preview.targetResults.map((target) => ({
|
|
524
|
+
pluginId: target.target.pluginId,
|
|
525
|
+
platform: target.target.platform,
|
|
526
|
+
scope: target.target.scope,
|
|
527
|
+
state: target.state,
|
|
528
|
+
action: target.action,
|
|
529
|
+
errorCode: target.errorCode,
|
|
530
|
+
requiredBy: target.requiredBy,
|
|
531
|
+
})),
|
|
532
|
+
})),
|
|
533
|
+
})))
|
|
534
|
+
.digest('hex');
|
|
535
|
+
}
|
|
82
536
|
if (evidence.operationPlan)
|
|
83
537
|
return evidence.operationPlan.planFingerprint;
|
|
84
538
|
if (evidence.resetTarget) {
|
|
@@ -90,8 +544,23 @@ export function operationEvidenceFingerprint(evidence) {
|
|
|
90
544
|
.digest('hex');
|
|
91
545
|
}
|
|
92
546
|
const { codexManager: _runtimeSelection, ...staleEvidence } = evidence;
|
|
547
|
+
const config = staleEvidence.config
|
|
548
|
+
? (({ shareability: _shareability, ...identity }) => identity)(staleEvidence.config)
|
|
549
|
+
: undefined;
|
|
550
|
+
const configBatch = staleEvidence.configBatch
|
|
551
|
+
? {
|
|
552
|
+
groups: staleEvidence.configBatch.groups.map((group) => ({
|
|
553
|
+
...group,
|
|
554
|
+
config: (({ shareability: _shareability, ...identity }) => identity)(group.config),
|
|
555
|
+
})),
|
|
556
|
+
}
|
|
557
|
+
: undefined;
|
|
93
558
|
return crypto.createHash('sha256')
|
|
94
|
-
.update(JSON.stringify(stableValue(
|
|
559
|
+
.update(JSON.stringify(stableValue({
|
|
560
|
+
...staleEvidence,
|
|
561
|
+
...(config ? { config } : {}),
|
|
562
|
+
...(configBatch ? { configBatch } : {}),
|
|
563
|
+
})))
|
|
95
564
|
.digest('hex');
|
|
96
565
|
}
|
|
97
566
|
export function operationEvidenceMatches(expected, current) {
|
|
@@ -100,11 +569,22 @@ export function operationEvidenceMatches(expected, current) {
|
|
|
100
569
|
!== JSON.stringify(stableValue(current.resetTarget))) {
|
|
101
570
|
return false;
|
|
102
571
|
}
|
|
103
|
-
if (
|
|
572
|
+
if (expected.source && (current.source === undefined
|
|
573
|
+
|| JSON.stringify(stableValue(expected.source))
|
|
574
|
+
!== JSON.stringify(stableValue(current.source)))) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
if (expected.targetFingerprint !== undefined
|
|
578
|
+
&& expected.targetFingerprint !== current.targetFingerprint) {
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
if (expected.config?.impactState !== 'known')
|
|
104
582
|
return true;
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
583
|
+
return JSON.stringify(stableValue({
|
|
584
|
+
config: expected.config,
|
|
585
|
+
})) === JSON.stringify(stableValue({
|
|
586
|
+
config: current.config,
|
|
587
|
+
}));
|
|
108
588
|
}
|
|
109
589
|
return operationEvidenceFingerprint(expected) === operationEvidenceFingerprint(current);
|
|
110
590
|
}
|
|
@@ -124,7 +604,22 @@ export function userIssueKey(issue) {
|
|
|
124
604
|
issue.sourceId ?? '', issue.sourceIdentity ?? '', issue.platform ?? '', issue.scope ?? '']
|
|
125
605
|
.join('\0');
|
|
126
606
|
}
|
|
127
|
-
function
|
|
607
|
+
function originIssueRemains(issue, origin) {
|
|
608
|
+
if (!origin.consumerPluginId || !origin.consumerPlatform || !origin.consumerScope) {
|
|
609
|
+
return userIssueKey(issue) === origin.issueKey;
|
|
610
|
+
}
|
|
611
|
+
return issue.category === origin.category
|
|
612
|
+
&& issue.dependencyPluginId === origin.dependencyPluginId
|
|
613
|
+
&& issue.dependencyPlatform === origin.dependencyPlatform
|
|
614
|
+
&& issue.dependencyScope === origin.dependencyScope
|
|
615
|
+
&& issue.affectedTargets?.some((target) => target.pluginId === origin.consumerPluginId
|
|
616
|
+
&& target.platform === origin.consumerPlatform
|
|
617
|
+
&& target.scope === origin.consumerScope) === true;
|
|
618
|
+
}
|
|
619
|
+
function explicitIssueCode(error) {
|
|
620
|
+
const safeOperationError = readSafeOperationError(error);
|
|
621
|
+
if (safeOperationError)
|
|
622
|
+
return safeDiagnosticCode(safeOperationError.code, 'operationBlocked');
|
|
128
623
|
if (error instanceof TuiOperationBlockedError)
|
|
129
624
|
return error.code;
|
|
130
625
|
if (error instanceof CatalogGenerationError)
|
|
@@ -132,10 +627,34 @@ function issueCode(error) {
|
|
|
132
627
|
if (error instanceof Error && error.name === 'CatalogSourcesConfigConflictError') {
|
|
133
628
|
return 'operationReviewStale';
|
|
134
629
|
}
|
|
630
|
+
return undefined;
|
|
631
|
+
}
|
|
632
|
+
function issueCode(error) {
|
|
633
|
+
const explicit = explicitIssueCode(error);
|
|
634
|
+
if (explicit !== undefined)
|
|
635
|
+
return explicit;
|
|
135
636
|
const message = error instanceof Error ? error.message : String(error);
|
|
136
637
|
const prefix = message.split(':', 1)[0];
|
|
137
638
|
return /^[A-Za-z][A-Za-z0-9]*$/u.test(prefix) ? prefix : 'operationBlocked';
|
|
138
639
|
}
|
|
640
|
+
function isPortableInstallReceipt(value) {
|
|
641
|
+
return typeof value === 'object' && value !== null
|
|
642
|
+
&& value.receiptSchemaVersion === 5
|
|
643
|
+
&& value.command === 'skill:install';
|
|
644
|
+
}
|
|
645
|
+
function completedSinglePluginId(intent, result) {
|
|
646
|
+
if (result.state !== 'succeeded' || result.summary.warnings?.length)
|
|
647
|
+
return undefined;
|
|
648
|
+
if (intent.kind === 'pluginWrite')
|
|
649
|
+
return intent.originIssue ? undefined : intent.pluginId;
|
|
650
|
+
const pluginIds = intent.kind === 'pluginWriteBatch'
|
|
651
|
+
? result.summary.batch?.requestedPluginIds ?? []
|
|
652
|
+
: intent.kind === 'pluginWriteTask'
|
|
653
|
+
? intent.targets.map((target) => target.pluginId)
|
|
654
|
+
: [];
|
|
655
|
+
const unique = [...new Set(pluginIds)];
|
|
656
|
+
return unique.length === 1 ? unique[0] : undefined;
|
|
657
|
+
}
|
|
139
658
|
export function extractPortableError(error) {
|
|
140
659
|
const typedCode = typeof error === 'object' && error !== null
|
|
141
660
|
&& 'code' in error && typeof error.code === 'string'
|
|
@@ -160,12 +679,19 @@ export class TuiController {
|
|
|
160
679
|
#listeners = new Set();
|
|
161
680
|
#health = new Map();
|
|
162
681
|
#tickets = new Map();
|
|
682
|
+
#reviewPreparationIntents = new Map();
|
|
163
683
|
#inflightOperations = new Map();
|
|
684
|
+
#pendingReads = new Set();
|
|
685
|
+
#readCleanupError;
|
|
686
|
+
#pluginContent = new Map();
|
|
687
|
+
#pluginContentInflight = new Map();
|
|
688
|
+
#pluginContentEpoch = 0;
|
|
164
689
|
#abort = new AbortController();
|
|
165
690
|
#progressUnsubscribe;
|
|
166
691
|
#progressFeed;
|
|
167
692
|
#phase = 'idle';
|
|
168
693
|
#status;
|
|
694
|
+
#statusReadAtMs;
|
|
169
695
|
#catalogGenerations = new Map();
|
|
170
696
|
#catalogFreshness = new Map();
|
|
171
697
|
#catalogSourcesSession;
|
|
@@ -177,18 +703,43 @@ export class TuiController {
|
|
|
177
703
|
#reviewPreparation;
|
|
178
704
|
#reviewPreparationToken = 0;
|
|
179
705
|
#result;
|
|
706
|
+
#resultAnchor;
|
|
707
|
+
#portableResultSkills;
|
|
708
|
+
#portableResultReceipt;
|
|
709
|
+
#portableResultIntent;
|
|
710
|
+
#portableResultLifecycle = 0;
|
|
711
|
+
#portableResultRecheck;
|
|
712
|
+
#completionNotice;
|
|
713
|
+
#scopedInventories = {};
|
|
714
|
+
#lastRefreshedScope;
|
|
715
|
+
#scopedInventoryRefresh = {};
|
|
716
|
+
#scopedRefreshToken = { user: 0, project: 0 };
|
|
717
|
+
#scopedPreparationAbort;
|
|
718
|
+
#scopedExecuted = new WeakSet();
|
|
719
|
+
#scopedTaskInflight;
|
|
720
|
+
#configSaveInflight;
|
|
180
721
|
#loadError;
|
|
181
722
|
#portableDraft;
|
|
723
|
+
#recoverablePortableDraft;
|
|
182
724
|
#portableRepreparePluginId;
|
|
183
725
|
#portableRequestToken = 0;
|
|
184
726
|
#portableRequestAbort;
|
|
185
727
|
#portablePending;
|
|
186
728
|
#installPlacementDraft;
|
|
729
|
+
#recoverableInstallPlacementDraft;
|
|
187
730
|
#installPlacementRequestToken = 0;
|
|
188
731
|
#installPlacementRequestAbort;
|
|
189
732
|
#generation = 0;
|
|
190
733
|
#disposed = false;
|
|
191
|
-
#
|
|
734
|
+
#retiring = false;
|
|
735
|
+
#externalDrafts = [];
|
|
736
|
+
#batchRetryIntent;
|
|
737
|
+
#taskRetryIntent;
|
|
738
|
+
#operationHistory = new OperationHistoryStore();
|
|
739
|
+
#sessionEpoch = 0;
|
|
740
|
+
#configSuggestions = new Map();
|
|
741
|
+
#lastRecordedResultId;
|
|
742
|
+
#operationDiagnostics = new Map();
|
|
192
743
|
constructor(dependencies, progressFeed) {
|
|
193
744
|
this.dependencies = dependencies;
|
|
194
745
|
this.#progressFeed = progressFeed;
|
|
@@ -205,12 +756,18 @@ export class TuiController {
|
|
|
205
756
|
this.#project();
|
|
206
757
|
this.#publish();
|
|
207
758
|
},
|
|
208
|
-
onError: (error, code) => {
|
|
759
|
+
onError: (error, code, context) => {
|
|
209
760
|
void this.#logErrorSafe(error, code);
|
|
761
|
+
return this.#recordStandaloneFailure(code, context.fullValidation
|
|
762
|
+
? 'validate-catalog-source'
|
|
763
|
+
: context.automatic ? 'auto-check-catalog-source' : 'check-catalog-source', error);
|
|
210
764
|
},
|
|
765
|
+
now: this.dependencies.now,
|
|
211
766
|
});
|
|
212
767
|
if (progressFeed) {
|
|
213
768
|
this.#progressUnsubscribe = progressFeed.subscribe((progress) => {
|
|
769
|
+
if (this.#router.snapshot.current.route.name === 'result' && !this.#scopedTaskInflight)
|
|
770
|
+
return;
|
|
214
771
|
this.#progress = {
|
|
215
772
|
...structuredClone(progress),
|
|
216
773
|
messages: progress.messages.slice(-8),
|
|
@@ -219,10 +776,9 @@ export class TuiController {
|
|
|
219
776
|
const current = progress.current;
|
|
220
777
|
if (current) {
|
|
221
778
|
const [pluginName, placement = ''] = current.target.split(' · ', 2);
|
|
222
|
-
const platform = placement.startsWith(
|
|
223
|
-
: placement.startsWith('Claude Code') ? 'claude' : undefined;
|
|
779
|
+
const platform = PLATFORM_TARGETS.find((candidate) => placement.startsWith(agentLabel(candidate)));
|
|
224
780
|
const scope = placement.endsWith('当前项目') ? 'project'
|
|
225
|
-
: placement.endsWith('当前用户') ? 'user' : undefined;
|
|
781
|
+
: placement.endsWith('当前用户') || placement.endsWith('所有项目') ? 'user' : undefined;
|
|
226
782
|
if (pluginName && platform && scope) {
|
|
227
783
|
this.#progressTargets = this.#progressTargets.map((target) => pluginNameFromId(target.pluginId) === pluginName
|
|
228
784
|
&& target.platform === platform && target.scope === scope
|
|
@@ -239,6 +795,7 @@ export class TuiController {
|
|
|
239
795
|
get snapshot() {
|
|
240
796
|
return cloneFrozen({
|
|
241
797
|
phase: this.#phase,
|
|
798
|
+
...(this.#statusReadAtMs !== undefined ? { statusReadAtMs: this.#statusReadAtMs } : {}),
|
|
242
799
|
...(this.#status?.cliChannel ? { cliChannel: this.#status.cliChannel } : {}),
|
|
243
800
|
router: this.#router.snapshot,
|
|
244
801
|
...(this.#viewModel ? { viewModel: this.#viewModel } : {}),
|
|
@@ -252,15 +809,20 @@ export class TuiController {
|
|
|
252
809
|
progressTargets: this.#progressTargets,
|
|
253
810
|
...(this.#activeReview ? { activeReview: this.#activeReview } : {}),
|
|
254
811
|
...(this.#reviewPreparation
|
|
255
|
-
? { reviewPreparation:
|
|
812
|
+
? { reviewPreparation: this.#reviewPreparation.snapshot }
|
|
256
813
|
: {}),
|
|
257
814
|
...(this.#result ? { result: this.#result } : {}),
|
|
815
|
+
...(this.#recoverableInstallPlacementDraft ? { canResumeInstallDraft: true } : {}),
|
|
816
|
+
operationHistorySummaries: this.#operationHistory.list(),
|
|
817
|
+
...(this.#portableResultSkills ? { portableResultSkills: this.#portableResultSkills } : {}),
|
|
258
818
|
...(this.#loadError ? { loadError: this.#loadError } : {}),
|
|
259
819
|
...(this.#portableDraft ? { portableDraft: this.#portableDraft } : {}),
|
|
260
820
|
...(this.#installPlacementDraft
|
|
261
821
|
? { installPlacementDraft: {
|
|
262
822
|
pluginId: this.#installPlacementDraft.pluginId,
|
|
263
823
|
rootScope: this.#installPlacementDraft.rootScope,
|
|
824
|
+
...(this.#installPlacementDraft.exactRootTargets
|
|
825
|
+
? { exactRootTargets: this.#installPlacementDraft.exactRootTargets } : {}),
|
|
264
826
|
platforms: this.#installPlacementDraft.platforms,
|
|
265
827
|
dependencyScopeOverrides: this.#installPlacementDraft.dependencyScopeOverrides,
|
|
266
828
|
state: this.#installPlacementDraft.state,
|
|
@@ -271,6 +833,10 @@ export class TuiController {
|
|
|
271
833
|
: {}),
|
|
272
834
|
} }
|
|
273
835
|
: {}),
|
|
836
|
+
...(this.#completionNotice ? { completionNotice: this.#completionNotice } : {}),
|
|
837
|
+
...(this.#status?.projectRoot ? { projectRoot: this.#status.projectRoot } : {}),
|
|
838
|
+
scopedInventories: this.#scopedInventories,
|
|
839
|
+
scopedInventoryRefresh: this.#scopedInventoryRefresh,
|
|
274
840
|
});
|
|
275
841
|
}
|
|
276
842
|
subscribe(listener) {
|
|
@@ -278,13 +844,341 @@ export class TuiController {
|
|
|
278
844
|
listener(this.snapshot);
|
|
279
845
|
return () => this.#listeners.delete(listener);
|
|
280
846
|
}
|
|
847
|
+
get hasActiveWrite() {
|
|
848
|
+
return this.#inflightOperations.size > 0 || this.#scopedTaskInflight !== undefined
|
|
849
|
+
|| this.#configSaveInflight !== undefined;
|
|
850
|
+
}
|
|
851
|
+
get retiring() {
|
|
852
|
+
return this.#retiring;
|
|
853
|
+
}
|
|
854
|
+
get hasSessionDraft() {
|
|
855
|
+
return this.#externalDrafts.length > 0
|
|
856
|
+
|| this.#portableDraft !== undefined
|
|
857
|
+
|| this.#installPlacementDraft !== undefined;
|
|
858
|
+
}
|
|
859
|
+
get externalDrafts() {
|
|
860
|
+
return structuredClone(this.#externalDrafts);
|
|
861
|
+
}
|
|
862
|
+
attachOperationHistory(history, epoch) {
|
|
863
|
+
if (epoch !== this.#sessionEpoch)
|
|
864
|
+
this.#configSuggestions.clear();
|
|
865
|
+
this.#operationHistory = history;
|
|
866
|
+
this.#sessionEpoch = epoch;
|
|
867
|
+
}
|
|
868
|
+
listOperationHistory() {
|
|
869
|
+
return this.#operationHistory.list();
|
|
870
|
+
}
|
|
871
|
+
getOperationDiagnostic(recordId) {
|
|
872
|
+
return this.#operationHistory.get(recordId);
|
|
873
|
+
}
|
|
874
|
+
previewOperationReport(recordId) {
|
|
875
|
+
return this.#operationHistory.preview(recordId);
|
|
876
|
+
}
|
|
877
|
+
saveOperationReport(recordId, filePath) {
|
|
878
|
+
return this.#operationHistory.save(recordId, filePath);
|
|
879
|
+
}
|
|
880
|
+
/** @internal Test-only observability for bounded private diagnostic ownership. */
|
|
881
|
+
operationDiagnosticRetentionCountForTests() {
|
|
882
|
+
return this.#operationDiagnostics.size;
|
|
883
|
+
}
|
|
884
|
+
recordUiFailure(error, context) {
|
|
885
|
+
const recordId = this.#recordStandaloneFailure(context.code, context.stage, error);
|
|
886
|
+
this.#publish();
|
|
887
|
+
return recordId;
|
|
888
|
+
}
|
|
889
|
+
#recordStandaloneFailure(code, stage, error) {
|
|
890
|
+
const operationId = `ui-${crypto.randomUUID()}`;
|
|
891
|
+
const recordId = `${this.#sessionEpoch}:${operationId}`;
|
|
892
|
+
const diagnostic = projectThrownOperationDiagnostic({
|
|
893
|
+
error,
|
|
894
|
+
id: `${recordId}:failure`,
|
|
895
|
+
stage: safeDiagnosticCode(stage, 'ui'),
|
|
896
|
+
fallbackCode: safeDiagnosticCode(code, 'uiOperationFailed'),
|
|
897
|
+
});
|
|
898
|
+
this.#operationHistory.record({
|
|
899
|
+
summary: {
|
|
900
|
+
recordId,
|
|
901
|
+
epoch: this.#sessionEpoch,
|
|
902
|
+
operationId,
|
|
903
|
+
createdAtMs: this.dependencies.now?.() ?? Date.now(),
|
|
904
|
+
state: 'blocked',
|
|
905
|
+
code: diagnostic.code,
|
|
906
|
+
message: diagnostic.safeMessage,
|
|
907
|
+
diagnosticCount: 1,
|
|
908
|
+
effects: {
|
|
909
|
+
configCommit: 'notApplicable', awWrite: 'notStarted',
|
|
910
|
+
preApplyExternalEffect: 'notApplicable', finalVerification: 'notStarted',
|
|
911
|
+
},
|
|
912
|
+
},
|
|
913
|
+
diagnostics: [diagnostic],
|
|
914
|
+
targets: [],
|
|
915
|
+
});
|
|
916
|
+
return recordId;
|
|
917
|
+
}
|
|
918
|
+
#trackRead(promise) {
|
|
919
|
+
const tracked = promise.catch(async (error) => {
|
|
920
|
+
if (error instanceof NativeCliError && error.cleanupError) {
|
|
921
|
+
this.#readCleanupError ??= error;
|
|
922
|
+
await this.#logErrorSafe(error, issueCode(error));
|
|
923
|
+
}
|
|
924
|
+
throw error;
|
|
925
|
+
});
|
|
926
|
+
this.#pendingReads.add(tracked);
|
|
927
|
+
void tracked.finally(() => this.#pendingReads.delete(tracked)).catch(() => undefined);
|
|
928
|
+
return tracked;
|
|
929
|
+
}
|
|
930
|
+
beginRetirement() {
|
|
931
|
+
this.#retiring = true;
|
|
932
|
+
this.#invalidatePortableResultRecheck();
|
|
933
|
+
}
|
|
934
|
+
async waitForWrites() {
|
|
935
|
+
this.beginRetirement();
|
|
936
|
+
while (this.hasActiveWrite) {
|
|
937
|
+
await Promise.allSettled([
|
|
938
|
+
...[...this.#inflightOperations.values()].map((operation) => operation.promise),
|
|
939
|
+
...(this.#scopedTaskInflight ? [this.#scopedTaskInflight.promise] : []),
|
|
940
|
+
...(this.#configSaveInflight ? [this.#configSaveInflight] : []),
|
|
941
|
+
]);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
async cancelAndWaitForReads() {
|
|
945
|
+
if (this.hasActiveWrite)
|
|
946
|
+
return false;
|
|
947
|
+
this.beginRetirement();
|
|
948
|
+
this.#generation += 1;
|
|
949
|
+
this.#cancelReviewPreparation();
|
|
950
|
+
this.#cancelPortableRequest();
|
|
951
|
+
this.#cancelInstallPlacementRequest();
|
|
952
|
+
this.#abort.abort();
|
|
953
|
+
const catalogDrain = this.#catalogSourcesSession.cancelAndWait();
|
|
954
|
+
while (this.#pendingReads.size > 0) {
|
|
955
|
+
await Promise.allSettled([...this.#pendingReads]);
|
|
956
|
+
}
|
|
957
|
+
await catalogDrain;
|
|
958
|
+
if (this.#readCleanupError)
|
|
959
|
+
throw this.#readCleanupError;
|
|
960
|
+
return !this.hasActiveWrite;
|
|
961
|
+
}
|
|
962
|
+
#assertAcceptingActions() {
|
|
963
|
+
if (this.#retiring || this.#disposed) {
|
|
964
|
+
throw new DOMException('Controller session is retiring.', 'AbortError');
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
goHome(options = {}) {
|
|
968
|
+
if (this.hasSessionDraft && !options.discardDrafts)
|
|
969
|
+
return false;
|
|
970
|
+
this.#invalidatePortableResultRecheck();
|
|
971
|
+
this.#cancelReviewPreparation();
|
|
972
|
+
this.#cancelPortableRequest();
|
|
973
|
+
this.#cancelInstallPlacementRequest();
|
|
974
|
+
this.#tickets.clear();
|
|
975
|
+
this.#activeReview = undefined;
|
|
976
|
+
this.#portableDraft = undefined;
|
|
977
|
+
this.#recoverablePortableDraft = undefined;
|
|
978
|
+
this.#installPlacementDraft = undefined;
|
|
979
|
+
this.#recoverableInstallPlacementDraft = undefined;
|
|
980
|
+
this.#batchRetryIntent = undefined;
|
|
981
|
+
this.#taskRetryIntent = undefined;
|
|
982
|
+
this.#externalDrafts = [];
|
|
983
|
+
this.#result = undefined;
|
|
984
|
+
this.#resultAnchor = undefined;
|
|
985
|
+
this.#portableResultSkills = undefined;
|
|
986
|
+
this.#completionNotice = undefined;
|
|
987
|
+
this.#progress = { messages: [] };
|
|
988
|
+
this.#progressTargets = [];
|
|
989
|
+
this.#router.resetToRoot();
|
|
990
|
+
this.#publish();
|
|
991
|
+
return true;
|
|
992
|
+
}
|
|
281
993
|
#publish() {
|
|
282
994
|
if (this.#disposed)
|
|
283
995
|
return;
|
|
996
|
+
this.#recordTerminalResult();
|
|
284
997
|
const snapshot = this.snapshot;
|
|
285
998
|
for (const listener of this.#listeners)
|
|
286
999
|
listener(snapshot);
|
|
287
1000
|
}
|
|
1001
|
+
#recordTerminalResult() {
|
|
1002
|
+
const result = this.#result;
|
|
1003
|
+
if (!result || result.state === 'stale')
|
|
1004
|
+
return;
|
|
1005
|
+
const recordId = `${this.#sessionEpoch}:${result.operationId}`;
|
|
1006
|
+
if (this.#lastRecordedResultId === recordId)
|
|
1007
|
+
return;
|
|
1008
|
+
const projected = this.#operationDiagnostics.get(result.operationId) ?? {
|
|
1009
|
+
diagnostics: [],
|
|
1010
|
+
effects: {
|
|
1011
|
+
configCommit: 'notApplicable',
|
|
1012
|
+
awWrite: result.state === 'succeeded' ? 'completed' : 'unknown',
|
|
1013
|
+
preApplyExternalEffect: 'notApplicable',
|
|
1014
|
+
finalVerification: result.state === 'succeeded' ? 'completed' : 'unknown',
|
|
1015
|
+
},
|
|
1016
|
+
};
|
|
1017
|
+
const summary = 'summary' in result ? result.summary : undefined;
|
|
1018
|
+
if (summary) {
|
|
1019
|
+
Object.assign(summary, sanitizeOperationSummary(summary, projected.sensitiveValues ?? []));
|
|
1020
|
+
}
|
|
1021
|
+
const deliveryNotices = projectDeliveryNoticeHistory(summary?.configDiagnostics ?? [], recordId, 'apply');
|
|
1022
|
+
const configDelivery = (summary?.configTargets ?? []).map((target, index) => {
|
|
1023
|
+
const notices = deliveryNotices.filter(({ target: notice }) => notice?.platform === target.platform
|
|
1024
|
+
&& notice.scope === target.scope && notice.pluginId === target.pluginId);
|
|
1025
|
+
const delivery = projectComponentDeliveryHistory(target, notices, `${recordId}:${index}`, 'apply', target.state === 'completed' || target.state === 'kept');
|
|
1026
|
+
return { target, ...delivery };
|
|
1027
|
+
});
|
|
1028
|
+
const diagnostics = [...projected.diagnostics, ...deliveryNotices, ...configDelivery.flatMap(({ diagnostics }) => diagnostics),
|
|
1029
|
+
...projectSkillInvocationHistory(summary?.configDiagnostics ?? [], recordId, 'apply')];
|
|
1030
|
+
const diagnosticIds = diagnostics.map((diagnostic) => diagnostic.id);
|
|
1031
|
+
const targets = summary ? summary.configTargets ?? summary.targets ?? [] : projected.targets ?? [];
|
|
1032
|
+
Object.assign(result, { operationRecordId: recordId, diagnosticIds, effects: projected.effects });
|
|
1033
|
+
if (summary) {
|
|
1034
|
+
summary.diagnosticIds = diagnosticIds;
|
|
1035
|
+
summary.effects = projected.effects;
|
|
1036
|
+
for (const target of targets) {
|
|
1037
|
+
const targetDiagnostics = diagnostics.filter((diagnostic) => diagnostic.target
|
|
1038
|
+
&& diagnostic.target.platform === target.platform
|
|
1039
|
+
&& diagnostic.target.scope === target.scope
|
|
1040
|
+
&& (diagnostic.target.pluginId === undefined || diagnostic.target.pluginId === target.pluginId));
|
|
1041
|
+
target.diagnosticIds = targetDiagnostics.map((diagnostic) => diagnostic.id);
|
|
1042
|
+
target.effects = projected.targetEffects?.get(`${target.pluginId ?? ''}\0${target.platform}\0${target.scope}`);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
const code = result.state === 'succeeded' || result.state === 'partial'
|
|
1046
|
+
? result.summary.code : result.summary?.code ?? result.code;
|
|
1047
|
+
const message = result.state === 'succeeded' || result.state === 'partial'
|
|
1048
|
+
? result.summary.message : result.summary?.message ?? result.message;
|
|
1049
|
+
this.#operationHistory.record({
|
|
1050
|
+
summary: {
|
|
1051
|
+
recordId,
|
|
1052
|
+
epoch: this.#sessionEpoch,
|
|
1053
|
+
operationId: result.operationId,
|
|
1054
|
+
createdAtMs: this.dependencies.now?.() ?? Date.now(),
|
|
1055
|
+
state: result.state,
|
|
1056
|
+
code,
|
|
1057
|
+
message,
|
|
1058
|
+
...('operationKind' in result && result.operationKind ? { operationKind: result.operationKind } : {}),
|
|
1059
|
+
...('pluginId' in result && result.pluginId ? { pluginId: result.pluginId } : {}),
|
|
1060
|
+
diagnosticCount: diagnostics.length,
|
|
1061
|
+
effects: projected.effects,
|
|
1062
|
+
},
|
|
1063
|
+
diagnostics,
|
|
1064
|
+
targets: targets.map((target) => {
|
|
1065
|
+
const delivery = configDelivery.find((entry) => entry.target === target);
|
|
1066
|
+
return { ...target, diagnosticIds: target.diagnosticIds ?? [],
|
|
1067
|
+
...(delivery?.facts ? { componentDelivery: delivery.facts } : {}) };
|
|
1068
|
+
}),
|
|
1069
|
+
}, { sensitiveValues: projected.sensitiveValues });
|
|
1070
|
+
this.#operationDiagnostics.delete(result.operationId);
|
|
1071
|
+
this.#lastRecordedResultId = recordId;
|
|
1072
|
+
}
|
|
1073
|
+
#captureThrownProjection(operationId, error, code, stage, intent, effects) {
|
|
1074
|
+
const sensitiveValues = intent ? collectOperationSensitiveValues(intent) : [];
|
|
1075
|
+
const carried = error instanceof TuiOperationBlockedError ? error.diagnostics : undefined;
|
|
1076
|
+
this.#operationDiagnostics.set(operationId, {
|
|
1077
|
+
diagnostics: carried?.length ? carried.map((diagnostic, index) => ({
|
|
1078
|
+
...structuredClone(diagnostic),
|
|
1079
|
+
id: `${this.#sessionEpoch}:${operationId}:failure:${index}`,
|
|
1080
|
+
})) : [projectThrownOperationDiagnostic({
|
|
1081
|
+
error,
|
|
1082
|
+
id: `${this.#sessionEpoch}:${operationId}:failure`,
|
|
1083
|
+
stage,
|
|
1084
|
+
fallbackCode: code,
|
|
1085
|
+
sensitiveValues,
|
|
1086
|
+
...(!(error instanceof ConfigApplyInterruptedError) && intent && 'pluginId' in intent && 'platform' in intent
|
|
1087
|
+
&& (intent.platform === 'codex' || intent.platform === 'claude')
|
|
1088
|
+
&& (intent.scope === 'user' || intent.scope === 'project')
|
|
1089
|
+
? { target: { pluginId: intent.pluginId, platform: intent.platform, scope: intent.scope } }
|
|
1090
|
+
: {}),
|
|
1091
|
+
})],
|
|
1092
|
+
effects: effects ?? {
|
|
1093
|
+
configCommit: 'notApplicable', awWrite: 'notStarted',
|
|
1094
|
+
preApplyExternalEffect: 'notApplicable', finalVerification: 'notStarted',
|
|
1095
|
+
},
|
|
1096
|
+
sensitiveValues,
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
#appendThrownProjection(operationId, error, code, stage, intent) {
|
|
1100
|
+
const existing = this.#operationDiagnostics.get(operationId);
|
|
1101
|
+
if (!existing) {
|
|
1102
|
+
this.#captureThrownProjection(operationId, error, code, stage, intent);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
const carried = error instanceof TuiOperationBlockedError ? error.diagnostics : undefined;
|
|
1106
|
+
const diagnostics = carried?.length ? carried : [projectThrownOperationDiagnostic({
|
|
1107
|
+
error,
|
|
1108
|
+
id: `${this.#sessionEpoch}:${operationId}:failure:${existing.diagnostics.length}`,
|
|
1109
|
+
stage,
|
|
1110
|
+
fallbackCode: code,
|
|
1111
|
+
sensitiveValues: existing.sensitiveValues,
|
|
1112
|
+
})];
|
|
1113
|
+
const offset = existing.diagnostics.length;
|
|
1114
|
+
const appended = diagnostics.map((diagnostic, index) => ({
|
|
1115
|
+
...structuredClone(diagnostic),
|
|
1116
|
+
id: `${this.#sessionEpoch}:${operationId}:failure:${offset + index}`,
|
|
1117
|
+
}));
|
|
1118
|
+
existing.diagnostics.push(...appended);
|
|
1119
|
+
const targetDiagnostics = appended.filter((diagnostic) => diagnostic.target !== undefined);
|
|
1120
|
+
if (targetDiagnostics.length > 0) {
|
|
1121
|
+
existing.targets = [...new Map([
|
|
1122
|
+
...(existing.targets ?? []).map((target) => [[
|
|
1123
|
+
target.pluginId ?? '', target.platform, target.scope,
|
|
1124
|
+
].join('\0'), target]),
|
|
1125
|
+
...targetDiagnostics.map((diagnostic) => [[
|
|
1126
|
+
diagnostic.target.pluginId ?? '', diagnostic.target.platform, diagnostic.target.scope,
|
|
1127
|
+
].join('\0'), {
|
|
1128
|
+
...diagnostic.target,
|
|
1129
|
+
state: 'skipped',
|
|
1130
|
+
errorCode: diagnostic.code,
|
|
1131
|
+
diagnosticIds: targetDiagnostics.filter((candidate) => candidate.target
|
|
1132
|
+
&& candidate.target.pluginId === diagnostic.target.pluginId
|
|
1133
|
+
&& candidate.target.platform === diagnostic.target.platform
|
|
1134
|
+
&& candidate.target.scope === diagnostic.target.scope).map((candidate) => candidate.id),
|
|
1135
|
+
}]),
|
|
1136
|
+
]).values()];
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
#recordStaleAttempt(operationId, intent) {
|
|
1140
|
+
if (!this.#operationDiagnostics.has(operationId)) {
|
|
1141
|
+
this.#captureThrownProjection(operationId, undefined, 'operationReviewStale', 'reviewValidation', intent);
|
|
1142
|
+
}
|
|
1143
|
+
const projected = this.#operationDiagnostics.get(operationId);
|
|
1144
|
+
const recordId = `${this.#sessionEpoch}:${operationId}`;
|
|
1145
|
+
const diagnosticsByTarget = new Map();
|
|
1146
|
+
for (const diagnostic of projected.diagnostics) {
|
|
1147
|
+
if (!diagnostic.target)
|
|
1148
|
+
continue;
|
|
1149
|
+
const key = [diagnostic.target.pluginId ?? '', diagnostic.target.platform, diagnostic.target.scope].join('\0');
|
|
1150
|
+
diagnosticsByTarget.set(key, [...(diagnosticsByTarget.get(key) ?? []), diagnostic]);
|
|
1151
|
+
}
|
|
1152
|
+
const targets = projected.targets ?? [...diagnosticsByTarget.entries()].map(([key, diagnostics]) => {
|
|
1153
|
+
const [pluginId, platform, scope] = key.split('\0');
|
|
1154
|
+
return {
|
|
1155
|
+
...(pluginId ? { pluginId } : {}),
|
|
1156
|
+
platform,
|
|
1157
|
+
scope,
|
|
1158
|
+
state: 'skipped',
|
|
1159
|
+
errorCode: diagnostics[0].code,
|
|
1160
|
+
diagnosticIds: diagnostics.map((diagnostic) => diagnostic.id),
|
|
1161
|
+
};
|
|
1162
|
+
});
|
|
1163
|
+
this.#operationHistory.record({
|
|
1164
|
+
summary: {
|
|
1165
|
+
recordId,
|
|
1166
|
+
epoch: this.#sessionEpoch,
|
|
1167
|
+
operationId,
|
|
1168
|
+
createdAtMs: this.dependencies.now?.() ?? Date.now(),
|
|
1169
|
+
state: 'blocked',
|
|
1170
|
+
code: projected.diagnostics[0]?.code ?? 'operationReviewStale',
|
|
1171
|
+
message: '状态已变化,原确认没有执行。已准备新的确认信息。',
|
|
1172
|
+
operationKind: intent.kind,
|
|
1173
|
+
...('pluginId' in intent ? { pluginId: intent.pluginId } : {}),
|
|
1174
|
+
diagnosticCount: projected.diagnostics.length,
|
|
1175
|
+
effects: projected.effects,
|
|
1176
|
+
},
|
|
1177
|
+
diagnostics: projected.diagnostics,
|
|
1178
|
+
targets,
|
|
1179
|
+
}, { sensitiveValues: projected.sensitiveValues });
|
|
1180
|
+
this.#operationDiagnostics.delete(operationId);
|
|
1181
|
+
}
|
|
288
1182
|
async #logErrorSafe(error, code, context) {
|
|
289
1183
|
try {
|
|
290
1184
|
await this.dependencies.logError?.(error, code, context);
|
|
@@ -296,74 +1190,355 @@ export class TuiController {
|
|
|
296
1190
|
#project() {
|
|
297
1191
|
if (!this.#status)
|
|
298
1192
|
return;
|
|
1193
|
+
const retainedNativePluginIds = Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => (status.extraObserved ?? []).flatMap((extra) => {
|
|
1194
|
+
if (extra.scope !== status.scope || !extra.agent || extra.agent === 'generic' || extra.delivery?.kind !== 'native')
|
|
1195
|
+
return [];
|
|
1196
|
+
const backend = extra.backend && typeof extra.backend === 'object'
|
|
1197
|
+
? extra.backend : undefined;
|
|
1198
|
+
if (backend?.retainedPackage !== true || !Array.isArray(backend.ownedComponents))
|
|
1199
|
+
return [];
|
|
1200
|
+
const owned = backend.ownedComponents.some((value) => {
|
|
1201
|
+
if (!value || typeof value !== 'object')
|
|
1202
|
+
return false;
|
|
1203
|
+
const component = value;
|
|
1204
|
+
return component.kind === 'owned-directory' && component.state === 'present'
|
|
1205
|
+
&& component.identity?.pluginId === extra.pluginId && component.identity.platform === extra.agent
|
|
1206
|
+
&& component.identity.scope === extra.scope;
|
|
1207
|
+
});
|
|
1208
|
+
return owned ? [extra.pluginId] : [];
|
|
1209
|
+
}));
|
|
299
1210
|
this.#viewModel = buildTuiViewModel({
|
|
300
1211
|
status: this.#status.payload,
|
|
301
1212
|
pluginSummaries: this.#status.pluginSummaries,
|
|
302
1213
|
targetRevisions: this.#status.targetRevisions,
|
|
1214
|
+
recoveryDiagnostics: Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => [
|
|
1215
|
+
...status.errors,
|
|
1216
|
+
...(status.extraObserved ?? []).flatMap((target) => !target.agent ? [] :
|
|
1217
|
+
(target.blockers ?? []).filter(({ code }) => ['requiredConfigMissing', 'configInvalid', 'invalidConfig'].includes(code))
|
|
1218
|
+
.map((entry) => ({ ...entry, subject: { pluginId: target.pluginId, target: target.agent, scope: target.scope, ...entry.subject } }))),
|
|
1219
|
+
]),
|
|
1220
|
+
recoveryTargets: Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => [
|
|
1221
|
+
...(status.inventory ?? []).flatMap((root) => root.targetResults),
|
|
1222
|
+
...(status.observedTargets ?? []).filter((target) => target.scope === status.scope
|
|
1223
|
+
&& (target.providerScope === undefined || target.providerScope === target.scope)),
|
|
1224
|
+
]),
|
|
1225
|
+
retainedNativePluginIds,
|
|
1226
|
+
residualPluginIds: Object.values(this.#status.scopedRecovery ?? {}).flatMap(inventoryPluginIds),
|
|
1227
|
+
retirementSourceChecks: this.#status.retirementSourceChecks,
|
|
303
1228
|
sourceHealth: this.#health,
|
|
304
1229
|
sourceDetails: this.#status.sourceDetails,
|
|
305
1230
|
catalogFreshness: this.#catalogFreshness,
|
|
306
1231
|
catalogGenerations: this.#catalogGenerations,
|
|
307
1232
|
dependencyOverviews: this.#status.dependencyOverviews,
|
|
1233
|
+
contentOverviews: {
|
|
1234
|
+
...(this.#status.contentOverviews ?? {}),
|
|
1235
|
+
...Object.fromEntries(this.#pluginContent),
|
|
1236
|
+
},
|
|
308
1237
|
portablePluginIds: this.#status.portablePluginIds,
|
|
1238
|
+
configStoreInventory: this.#status.configStoreInventory,
|
|
309
1239
|
});
|
|
1240
|
+
for (const issue of this.#viewModel.issues) {
|
|
1241
|
+
// Cross-scope recovery needs separate Intent, cleanup, and sync reviews.
|
|
1242
|
+
issue.actions = issue.actions.filter((action) => action.id !== 'keepProjectScope' && action.id !== 'keepUserScope');
|
|
1243
|
+
}
|
|
1244
|
+
for (const scope of ['user', 'project']) {
|
|
1245
|
+
const recovery = this.#status.scopedRecovery?.[scope];
|
|
1246
|
+
if (!recovery) {
|
|
1247
|
+
delete this.#scopedInventories[scope];
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
this.#scopedInventories[scope] = buildScopedInventory({
|
|
1251
|
+
recovery,
|
|
1252
|
+
retirementSourceChecks: this.#status.retirementSourceChecks,
|
|
1253
|
+
status: this.#status.payload,
|
|
1254
|
+
pluginSummaries: this.#status.pluginSummaries,
|
|
1255
|
+
sourceHealth: this.#health,
|
|
1256
|
+
catalogGenerations: this.#catalogGenerations,
|
|
1257
|
+
targetRevisions: this.#status.targetRevisions,
|
|
1258
|
+
dependencyOverviews: recovery.dependencyOverviews ?? this.#status.dependencyOverviews,
|
|
1259
|
+
...(scope === 'project' && this.#status.projectRoot
|
|
1260
|
+
? { projectRoot: this.#status.projectRoot } : {}),
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
310
1263
|
}
|
|
311
1264
|
#normalizeRoute(route) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
1265
|
+
const state = this.#routeEntityState();
|
|
1266
|
+
if (route.name === 'pluginDetail' || route.name === 'pluginPreview'
|
|
1267
|
+
|| route.name === 'pluginDependencies' && route.view !== 'removeBlocked'
|
|
1268
|
+
|| route.name === 'pluginDependencyNode') {
|
|
1269
|
+
return normalizeTuiRoute(route, {
|
|
1270
|
+
...state,
|
|
1271
|
+
hasPlugin: (pluginId) => this.getPluginDetailSubject(pluginId) !== undefined,
|
|
1272
|
+
});
|
|
315
1273
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|| route.name === 'dependencyPlacement' || route.name === 'dependencyPlacementEditor'
|
|
342
|
-
? 'browse'
|
|
343
|
-
: 'installed',
|
|
344
|
-
};
|
|
1274
|
+
return normalizeTuiRoute(route, state);
|
|
1275
|
+
}
|
|
1276
|
+
#routeEntityState() {
|
|
1277
|
+
return {
|
|
1278
|
+
hasPlugin: (pluginId) => this.#viewModel?.plugins.some((plugin) => plugin.pluginId === pluginId)
|
|
1279
|
+
|| Object.values(this.#scopedInventories).some((inventory) => inventory.declaredRoots.some((root) => root.pluginId === pluginId) || inventory.extraInstalledRoots.some((root) => root.pluginId === pluginId))
|
|
1280
|
+
|| false,
|
|
1281
|
+
hasSource: (sourceId) => this.#viewModel?.sourceTabs.some((source) => source.id === sourceId) ?? false,
|
|
1282
|
+
hasIssue: (issueId) => this.#viewModel?.issues.some((issue) => issue.issueId === issueId) ?? false,
|
|
1283
|
+
hasHistoryRecord: (recordId) => this.#operationHistory.get(recordId) !== undefined,
|
|
1284
|
+
hasActiveOperation: (candidate) => candidate.name === 'reviewPreparing'
|
|
1285
|
+
? this.#reviewPreparation?.snapshot.id === candidate.preparationId
|
|
1286
|
+
: candidate.name === 'result'
|
|
1287
|
+
? this.#result?.operationId === candidate.operationId
|
|
1288
|
+
: this.#activeReview?.operationId === candidate.operationId,
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
#normalizeCurrentRoute() {
|
|
1292
|
+
this.#router.normalizeRoutes((route) => this.#normalizeRoute(route));
|
|
1293
|
+
if (this.#resultAnchor)
|
|
1294
|
+
this.#resultAnchor = this.#normalizeRoute(this.#resultAnchor);
|
|
1295
|
+
for (const ticket of this.#tickets.values())
|
|
1296
|
+
ticket.returnRoute = this.#normalizeRoute(ticket.returnRoute);
|
|
1297
|
+
if (this.#reviewPreparation) {
|
|
1298
|
+
this.#reviewPreparation.returnRoute = this.#normalizeRoute(this.#reviewPreparation.returnRoute);
|
|
345
1299
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
1300
|
+
}
|
|
1301
|
+
#ensureOperationFlow(intent) {
|
|
1302
|
+
const active = this.#router.activeFlow();
|
|
1303
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
1304
|
+
if (active?.kind === 'pluginWriteTask')
|
|
1305
|
+
return;
|
|
1306
|
+
this.#router.beginFlow('pluginWriteTask', this.#router.snapshot.current.route);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
if (intent.kind === 'pluginWriteBatch') {
|
|
1310
|
+
if (active?.kind === 'batchWrite')
|
|
1311
|
+
return;
|
|
1312
|
+
if (active?.kind === 'pluginInstall' && intent.action === 'install'
|
|
1313
|
+
&& intent.selection.kind === 'targets' && this.#installPlacementDraft
|
|
1314
|
+
&& intent.selection.targets.every((target) => target.pluginId === this.#installPlacementDraft.pluginId))
|
|
1315
|
+
return;
|
|
1316
|
+
this.#router.beginFlow('batchWrite', { name: 'pluginList', mode: 'installed' });
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
if (intent.kind === 'pluginWrite') {
|
|
1320
|
+
const kind = intent.action === 'install' ? 'pluginInstall' : 'pluginMaintenance';
|
|
1321
|
+
if (active?.kind === kind)
|
|
1322
|
+
return;
|
|
1323
|
+
this.#router.beginPluginFlow(kind, intent.pluginId);
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
if (intent.kind === 'portableInstall') {
|
|
1327
|
+
if (active?.kind === 'portableInstall')
|
|
1328
|
+
return;
|
|
1329
|
+
this.#router.beginPortableFlow(intent.pluginId);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
1333
|
+
if (active?.kind === 'catalogStore')
|
|
1334
|
+
return;
|
|
1335
|
+
this.#router.beginFlow('catalogStore', { name: 'catalogStoreOverview' });
|
|
1336
|
+
return;
|
|
349
1337
|
}
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
1338
|
+
if (intent.kind === 'configSave' || intent.kind === 'configSaveBatch' || intent.kind === 'configReset') {
|
|
1339
|
+
if (active?.kind === 'configEdit')
|
|
1340
|
+
return;
|
|
1341
|
+
const route = this.#router.snapshot.current.route;
|
|
1342
|
+
if ((route.name === 'pluginPreview' || route.name === 'pluginDetail')
|
|
1343
|
+
&& route.pluginId === intent.pluginId) {
|
|
1344
|
+
this.#router.beginConfigFlow(intent.pluginId);
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
this.#router.beginFlow('configEdit', { name: 'pluginDetail', pluginId: intent.pluginId });
|
|
1348
|
+
}
|
|
1349
|
+
return;
|
|
356
1350
|
}
|
|
357
|
-
|
|
1351
|
+
const kind = intent.kind === 'catalogSourcesRecovery' ? 'sourceRecovery' : 'sourceEdit';
|
|
1352
|
+
if (active?.kind === 'sourceRecovery'
|
|
1353
|
+
&& (intent.kind === 'catalogSourcesRecovery'
|
|
1354
|
+
|| intent.kind === 'catalogGeneration'
|
|
1355
|
+
|| intent.kind === 'sourceMutation'))
|
|
1356
|
+
return;
|
|
1357
|
+
if (active?.kind === kind)
|
|
1358
|
+
return;
|
|
1359
|
+
this.#router.beginFlow(kind, active ? this.#router.snapshot.current.route
|
|
1360
|
+
: intent.kind === 'sourceMutation' && intent.action !== 'remove'
|
|
1361
|
+
? { name: 'sourceDetail', sourceId: intent.sourceId }
|
|
1362
|
+
: intent.kind === 'catalogGeneration'
|
|
1363
|
+
? this.#router.snapshot.current.route.name === 'pluginWriteTask'
|
|
1364
|
+
? this.#router.snapshot.current.route
|
|
1365
|
+
: { name: 'sourceDetail', sourceId: intent.sourceId }
|
|
1366
|
+
: { name: 'sourceList' });
|
|
358
1367
|
}
|
|
359
|
-
#
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
1368
|
+
#stableResultRoute(intent, result) {
|
|
1369
|
+
const active = this.#router.activeFlow();
|
|
1370
|
+
if (intent.kind === 'pluginWriteTask' && active?.kind === 'pluginWriteTask'
|
|
1371
|
+
&& active.returnTarget.name === 'pluginWriteTask'
|
|
1372
|
+
&& active.returnTarget.goal !== intent.goal) {
|
|
1373
|
+
return this.#normalizeRoute(active.returnTarget);
|
|
1374
|
+
}
|
|
1375
|
+
if (intent.kind === 'pluginWriteTask'
|
|
1376
|
+
&& result.state === 'succeeded'
|
|
1377
|
+
&& 'returnRoute' in result
|
|
1378
|
+
&& result.returnRoute?.name === 'pluginWriteTask'
|
|
1379
|
+
&& result.returnRoute.goal === result.summary.task?.goal
|
|
1380
|
+
&& result.returnRoute.batchOrigin?.owner === 'batch-write') {
|
|
1381
|
+
return { name: 'pluginList', mode: 'installed' };
|
|
1382
|
+
}
|
|
1383
|
+
const completedPluginId = completedSinglePluginId(intent, result);
|
|
1384
|
+
if (completedPluginId) {
|
|
1385
|
+
return this.#normalizeRoute({ name: 'pluginDetail', pluginId: completedPluginId });
|
|
1386
|
+
}
|
|
1387
|
+
if (intent.kind === 'pluginWriteTask' && active?.kind === 'pluginWriteTask'
|
|
1388
|
+
&& active.parentFlowId) {
|
|
1389
|
+
return this.#normalizeRoute(active.returnTarget);
|
|
1390
|
+
}
|
|
1391
|
+
if (intent.kind === 'portableInstall' && result.state === 'succeeded') {
|
|
1392
|
+
return this.#normalizeRoute({ name: 'pluginDetail', pluginId: intent.pluginId });
|
|
1393
|
+
}
|
|
1394
|
+
if (intent.kind === 'catalogStorePrune')
|
|
1395
|
+
return { name: 'catalogStoreOverview' };
|
|
1396
|
+
if (active?.parentFlowId)
|
|
1397
|
+
return this.#normalizeRoute(active.returnTarget);
|
|
1398
|
+
if (active && (intent.kind === 'portableInstall'
|
|
1399
|
+
|| intent.kind === 'configSave' || intent.kind === 'configSaveBatch' || intent.kind === 'configReset')) {
|
|
1400
|
+
return this.#normalizeRoute(active.returnTarget);
|
|
1401
|
+
}
|
|
1402
|
+
if (intent.kind === 'pluginWrite') {
|
|
1403
|
+
if (intent.originIssue && result.state === 'succeeded')
|
|
1404
|
+
return { name: 'issueList' };
|
|
1405
|
+
return this.#normalizeRoute({ name: 'pluginDetail', pluginId: intent.pluginId });
|
|
1406
|
+
}
|
|
1407
|
+
if (intent.kind === 'pluginWriteBatch' && intent.selection.kind === 'targets') {
|
|
1408
|
+
const pluginIds = [...new Set(intent.selection.targets.map((target) => target.pluginId))];
|
|
1409
|
+
if (pluginIds.length === 1) {
|
|
1410
|
+
return this.#normalizeRoute({ name: 'pluginDetail', pluginId: pluginIds[0] });
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
if (intent.kind === 'pluginWriteBatch')
|
|
1414
|
+
return { name: 'pluginList', mode: 'installed' };
|
|
1415
|
+
if (intent.kind === 'pluginWriteTask')
|
|
1416
|
+
return { name: 'pluginList', mode: 'installed' };
|
|
1417
|
+
if (intent.kind === 'portableInstall' || intent.kind === 'configSave'
|
|
1418
|
+
|| intent.kind === 'configSaveBatch' || intent.kind === 'configReset') {
|
|
1419
|
+
return this.#normalizeRoute({ name: 'pluginDetail', pluginId: intent.pluginId });
|
|
1420
|
+
}
|
|
1421
|
+
if (intent.kind === 'sourceMutation' && intent.action === 'update') {
|
|
1422
|
+
return this.#normalizeRoute({ name: 'sourceDetail', sourceId: intent.sourceId });
|
|
1423
|
+
}
|
|
1424
|
+
if (intent.kind === 'catalogGeneration') {
|
|
1425
|
+
if ('returnRoute' in result && result.returnRoute?.name === 'pluginWriteTask') {
|
|
1426
|
+
return this.#normalizeRoute(result.returnRoute);
|
|
1427
|
+
}
|
|
1428
|
+
return this.#normalizeRoute({ name: 'sourceDetail', sourceId: intent.sourceId });
|
|
1429
|
+
}
|
|
1430
|
+
return { name: 'sourceList' };
|
|
1431
|
+
}
|
|
1432
|
+
#showResult(result, intent) {
|
|
1433
|
+
this.#invalidatePortableResultRecheck();
|
|
1434
|
+
const terminal = { name: 'result', operationId: result.operationId };
|
|
1435
|
+
const target = this.#stableResultRoute(intent, result);
|
|
1436
|
+
this.#resultAnchor = structuredClone(target);
|
|
1437
|
+
this.#cancelReviewPreparation();
|
|
1438
|
+
this.#progress = { messages: [] };
|
|
1439
|
+
this.#progressTargets = [];
|
|
1440
|
+
const installDraft = this.#installPlacementDraft;
|
|
1441
|
+
const ownsInstallDraft = installDraft && (intent.kind === 'pluginWrite'
|
|
1442
|
+
&& intent.action === 'install' && installDraft.pluginId === intent.pluginId
|
|
1443
|
+
|| intent.kind === 'pluginWriteBatch' && intent.action === 'install'
|
|
1444
|
+
&& this.#router.activeFlow()?.kind === 'pluginInstall'
|
|
1445
|
+
&& intent.selection.kind === 'targets' && installDraft.exactRootTargets
|
|
1446
|
+
&& JSON.stringify(canonicalBatchTargets(intent.selection.targets))
|
|
1447
|
+
=== JSON.stringify(installDraft.exactRootTargets));
|
|
1448
|
+
this.#recoverableInstallPlacementDraft = result.state === 'blocked'
|
|
1449
|
+
&& 'returnRoute' in result && result.returnRoute && ownsInstallDraft
|
|
1450
|
+
? structuredClone(installDraft)
|
|
1451
|
+
: undefined;
|
|
1452
|
+
this.#installPlacementDraft = undefined;
|
|
1453
|
+
this.#recoverablePortableDraft = result.state !== 'succeeded'
|
|
1454
|
+
&& intent.kind === 'portableInstall'
|
|
1455
|
+
&& this.#portableDraft?.pluginId === intent.pluginId
|
|
1456
|
+
? structuredClone(this.#portableDraft)
|
|
1457
|
+
: undefined;
|
|
1458
|
+
this.#portableResultSkills = intent.kind === 'portableInstall'
|
|
1459
|
+
? this.#portableDraft?.candidates
|
|
1460
|
+
.filter((candidate) => candidate.selected)
|
|
1461
|
+
.map((candidate) => candidate.name)
|
|
1462
|
+
: undefined;
|
|
1463
|
+
this.#portableDraft = undefined;
|
|
1464
|
+
this.#batchRetryIntent = intent.kind === 'pluginWriteBatch'
|
|
1465
|
+
&& 'summary' in result
|
|
1466
|
+
&& result.summary?.batch
|
|
1467
|
+
&& (result.summary.batch.retryTargets?.length ?? 0) > 0
|
|
1468
|
+
? {
|
|
1469
|
+
...structuredClone(intent),
|
|
1470
|
+
selection: {
|
|
1471
|
+
kind: 'targets',
|
|
1472
|
+
targets: structuredClone(result.summary.batch.retryTargets),
|
|
1473
|
+
},
|
|
1474
|
+
}
|
|
1475
|
+
: undefined;
|
|
1476
|
+
this.#taskRetryIntent = intent.kind === 'pluginWriteTask'
|
|
1477
|
+
&& 'summary' in result
|
|
1478
|
+
&& result.summary?.task
|
|
1479
|
+
&& (result.summary.task.retryTargets?.length ?? 0) > 0
|
|
1480
|
+
? {
|
|
1481
|
+
...structuredClone(intent),
|
|
1482
|
+
targets: result.summary.task.retryTargets.map((target) => {
|
|
1483
|
+
const current = this.listPluginWriteTaskCandidates(intent.goal).find((candidate) => pluginWriteTaskTargetKey(candidate.target) === pluginWriteTaskTargetKey(target));
|
|
1484
|
+
return structuredClone(current?.eligible ? current.target : target);
|
|
1485
|
+
}),
|
|
1486
|
+
executionPolicy: 'all',
|
|
1487
|
+
}
|
|
1488
|
+
: undefined;
|
|
1489
|
+
const batchFlowId = result.state === 'succeeded'
|
|
1490
|
+
&& intent.kind === 'pluginWriteTask'
|
|
1491
|
+
&& 'returnRoute' in result
|
|
1492
|
+
&& result.returnRoute?.name === 'pluginWriteTask'
|
|
1493
|
+
&& result.returnRoute.goal === result.summary.task?.goal
|
|
1494
|
+
&& result.returnRoute.batchOrigin?.owner === 'batch-write'
|
|
1495
|
+
? result.returnRoute.batchOrigin.flowId
|
|
1496
|
+
: undefined;
|
|
1497
|
+
const completedPluginId = completedSinglePluginId(intent, result);
|
|
1498
|
+
const hasUnreviewedTaskTargets = intent.kind === 'pluginWriteTask'
|
|
1499
|
+
&& 'returnRoute' in result && result.returnRoute?.name === 'pluginWriteTask'
|
|
1500
|
+
&& result.returnRoute.targetKeys?.some((key) => !intent.targets.some((candidate) => pluginWriteTaskTargetKey(candidate) === key));
|
|
1501
|
+
if (completedPluginId && target.name === 'pluginDetail' && !hasUnreviewedTaskTargets) {
|
|
1502
|
+
this.#recordTerminalResult();
|
|
1503
|
+
const action = intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch'
|
|
1504
|
+
? intent.action : 'sync';
|
|
1505
|
+
this.#completionNotice = {
|
|
1506
|
+
pluginId: completedPluginId,
|
|
1507
|
+
title: intent.kind === 'pluginWriteTask'
|
|
1508
|
+
? intent.goal === 'update' ? '插件更新完成' : '插件恢复完成'
|
|
1509
|
+
: action === 'uninstall' ? '插件卸载完成'
|
|
1510
|
+
: action === 'install' ? '插件安装完成'
|
|
1511
|
+
: action === 'reinstall' ? '插件重新安装完成'
|
|
1512
|
+
: action === 'refreshAndSync' ? '插件更新完成'
|
|
1513
|
+
: action === 'cleanup' ? '插件清理完成' : '插件同步完成',
|
|
1514
|
+
description: action === 'uninstall'
|
|
1515
|
+
? '所选实际位置已处理。插件设置保持不变。'
|
|
1516
|
+
: '状态已重新检查。下方详情显示当前实际位置。',
|
|
1517
|
+
...(result.operationRecordId ? { operationRecordId: result.operationRecordId } : {}),
|
|
1518
|
+
};
|
|
1519
|
+
const finished = this.#router.finishFlow(target);
|
|
1520
|
+
if (!finished)
|
|
1521
|
+
this.#router.replace(target);
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
const portableParentFlowId = result.state === 'succeeded'
|
|
1525
|
+
&& intent.kind === 'portableInstall'
|
|
1526
|
+
&& this.#router.activeFlow()?.parentFlowId;
|
|
1527
|
+
const finished = batchFlowId
|
|
1528
|
+
? this.#router.finishFlowById(batchFlowId, 'batchWrite', target, terminal)
|
|
1529
|
+
: portableParentFlowId
|
|
1530
|
+
? this.#router.finishFlowById(portableParentFlowId, 'pluginInstall', target, terminal)
|
|
1531
|
+
: this.#router.finishFlow(target, terminal);
|
|
1532
|
+
if (!finished)
|
|
1533
|
+
this.#router.replace(terminal);
|
|
364
1534
|
}
|
|
365
1535
|
#applyStatus(status) {
|
|
1536
|
+
this.#lastRefreshedScope = undefined;
|
|
1537
|
+
this.#pluginContentEpoch += 1;
|
|
1538
|
+
this.#pluginContent.clear();
|
|
1539
|
+
this.#pluginContentInflight.clear();
|
|
366
1540
|
this.#status = structuredClone(status);
|
|
1541
|
+
this.#statusReadAtMs = this.dependencies.now?.() ?? Date.now();
|
|
367
1542
|
if (status.catalogGenerations) {
|
|
368
1543
|
this.#catalogGenerations.clear();
|
|
369
1544
|
for (const source of status.catalogGenerations) {
|
|
@@ -378,11 +1553,11 @@ export class TuiController {
|
|
|
378
1553
|
}
|
|
379
1554
|
this.#health.clear();
|
|
380
1555
|
for (const source of status.payload.catalog.sources) {
|
|
1556
|
+
const unavailable = source.error !== undefined || source.errorCode !== undefined;
|
|
381
1557
|
this.#health.set(source.id, {
|
|
382
1558
|
sourceId: source.id,
|
|
383
|
-
state:
|
|
384
|
-
|
|
385
|
-
...(source.error ? { message: '来源当前没有可用数据。' } : {}),
|
|
1559
|
+
state: unavailable ? 'unavailable' : 'ready',
|
|
1560
|
+
...(unavailable ? { message: '来源当前没有可用数据。' } : {}),
|
|
386
1561
|
});
|
|
387
1562
|
if (!this.#catalogFreshness.has(source.id)) {
|
|
388
1563
|
this.#catalogFreshness.set(source.id, { sourceId: source.id, state: 'notChecked' });
|
|
@@ -398,14 +1573,18 @@ export class TuiController {
|
|
|
398
1573
|
this.#catalogSourcesSession.configure(status.payload.catalog.sources.map((source) => {
|
|
399
1574
|
const generation = this.#catalogGenerations.get(source.id);
|
|
400
1575
|
const detail = details.get(source.id);
|
|
1576
|
+
const probeFingerprint = JSON.stringify({
|
|
1577
|
+
sourceIdentity: source.identity,
|
|
1578
|
+
requestedRef: source.requestedRef,
|
|
1579
|
+
});
|
|
401
1580
|
return {
|
|
402
1581
|
sourceId: source.id,
|
|
403
1582
|
primary: source.primary,
|
|
404
1583
|
autoCheck: this.dependencies.probeCatalogFreshness !== undefined
|
|
405
1584
|
&& (detail?.autoCheck ?? true),
|
|
1585
|
+
probeFingerprint,
|
|
406
1586
|
fingerprint: JSON.stringify({
|
|
407
|
-
|
|
408
|
-
requestedRef: source.requestedRef,
|
|
1587
|
+
probeFingerprint,
|
|
409
1588
|
activeStoreKey: generation?.active?.storeKey,
|
|
410
1589
|
generationState: generation?.state,
|
|
411
1590
|
generationErrorCode: generation?.errorCode,
|
|
@@ -420,22 +1599,39 @@ export class TuiController {
|
|
|
420
1599
|
this.#project();
|
|
421
1600
|
this.#normalizeCurrentRoute();
|
|
422
1601
|
}
|
|
1602
|
+
#beginCatalogSession(options) {
|
|
1603
|
+
this.#configSuggestions.clear();
|
|
1604
|
+
this.dependencies.beginCatalogSession?.(options);
|
|
1605
|
+
}
|
|
423
1606
|
async load() {
|
|
424
|
-
this
|
|
1607
|
+
this.#assertAcceptingActions();
|
|
1608
|
+
this.#beginCatalogSession();
|
|
425
1609
|
const generation = ++this.#generation;
|
|
1610
|
+
this.#scopedRefreshToken.user += 1;
|
|
1611
|
+
this.#scopedRefreshToken.project += 1;
|
|
1612
|
+
this.#scopedInventoryRefresh = {};
|
|
1613
|
+
this.#scopedInventories = {};
|
|
1614
|
+
this.#pluginContentEpoch += 1;
|
|
1615
|
+
this.#pluginContent.clear();
|
|
1616
|
+
this.#pluginContentInflight.clear();
|
|
426
1617
|
this.#phase = 'loading';
|
|
427
1618
|
this.#publish();
|
|
1619
|
+
if (!this.#operationIsCurrent(generation))
|
|
1620
|
+
return;
|
|
428
1621
|
let status;
|
|
429
1622
|
try {
|
|
430
|
-
status = await this.dependencies.loadStatus(this.#abort.signal);
|
|
1623
|
+
status = await this.#trackRead(this.dependencies.loadStatus(this.#abort.signal));
|
|
431
1624
|
}
|
|
432
1625
|
catch (error) {
|
|
433
1626
|
if (this.#disposed || generation !== this.#generation)
|
|
434
1627
|
return;
|
|
435
1628
|
const code = issueCode(error);
|
|
436
1629
|
await this.#logErrorSafe(error, code);
|
|
1630
|
+
if (!this.#operationIsCurrent(generation))
|
|
1631
|
+
return;
|
|
437
1632
|
this.#phase = 'error';
|
|
438
1633
|
this.#loadError = { code, message: '无法安全读取插件状态。请检查诊断后重试或退出。' };
|
|
1634
|
+
this.#recordStandaloneFailure(code, 'statusReload', error);
|
|
439
1635
|
this.#publish();
|
|
440
1636
|
return;
|
|
441
1637
|
}
|
|
@@ -446,37 +1642,198 @@ export class TuiController {
|
|
|
446
1642
|
this.#loadError = undefined;
|
|
447
1643
|
this.#publish();
|
|
448
1644
|
}
|
|
1645
|
+
listScopedInventoryRoots(scope, section = 'declared') {
|
|
1646
|
+
const inventory = this.#scopedInventories[scope];
|
|
1647
|
+
return cloneFrozen(section === 'declared'
|
|
1648
|
+
? inventory?.declaredRoots ?? [] : inventory?.extraInstalledRoots ?? []);
|
|
1649
|
+
}
|
|
1650
|
+
async refreshScopedInventory(scope) {
|
|
1651
|
+
this.#assertAcceptingActions();
|
|
1652
|
+
if (!this.#status || this.#phase !== 'ready' || !this.dependencies.loadScopedStatus)
|
|
1653
|
+
return false;
|
|
1654
|
+
const token = ++this.#scopedRefreshToken[scope];
|
|
1655
|
+
const generation = this.#generation;
|
|
1656
|
+
this.#scopedInventoryRefresh[scope] = { state: 'checking' };
|
|
1657
|
+
this.#publish();
|
|
1658
|
+
try {
|
|
1659
|
+
const recovery = await this.#trackRead(this.dependencies.loadScopedStatus(scope, this.#abort.signal));
|
|
1660
|
+
if (this.#disposed || generation !== this.#generation || token !== this.#scopedRefreshToken[scope])
|
|
1661
|
+
return false;
|
|
1662
|
+
this.#status.retirementSourceChecks = { ...this.#status.retirementSourceChecks, ...recovery.retirementSourceChecks };
|
|
1663
|
+
const inventory = buildScopedInventory({
|
|
1664
|
+
recovery, status: { ...this.#status.payload, targets: [] }, pluginSummaries: this.#status.pluginSummaries,
|
|
1665
|
+
retirementSourceChecks: this.#status.retirementSourceChecks,
|
|
1666
|
+
sourceHealth: this.#health,
|
|
1667
|
+
catalogGenerations: this.#catalogGenerations,
|
|
1668
|
+
dependencyOverviews: recovery.dependencyOverviews ?? this.#status.dependencyOverviews,
|
|
1669
|
+
...(scope === 'project' && this.#status.projectRoot ? { projectRoot: this.#status.projectRoot } : {}),
|
|
1670
|
+
});
|
|
1671
|
+
this.#status.scopedRecovery = { ...this.#status.scopedRecovery, [scope]: structuredClone(recovery) };
|
|
1672
|
+
this.#project();
|
|
1673
|
+
this.#scopedInventories[scope] = inventory;
|
|
1674
|
+
this.#lastRefreshedScope = scope;
|
|
1675
|
+
this.#scopedInventoryRefresh[scope] = { state: 'idle' };
|
|
1676
|
+
this.#publish();
|
|
1677
|
+
return true;
|
|
1678
|
+
}
|
|
1679
|
+
catch (error) {
|
|
1680
|
+
if (this.#disposed || generation !== this.#generation || token !== this.#scopedRefreshToken[scope])
|
|
1681
|
+
return false;
|
|
1682
|
+
const code = issueCode(error);
|
|
1683
|
+
await this.#logErrorSafe(error, code);
|
|
1684
|
+
if (this.#disposed || generation !== this.#generation || token !== this.#scopedRefreshToken[scope])
|
|
1685
|
+
return false;
|
|
1686
|
+
this.#scopedInventoryRefresh[scope] = { state: 'error', errorCode: code };
|
|
1687
|
+
this.#publish();
|
|
1688
|
+
return false;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
async prepareScopedTask(request) {
|
|
1692
|
+
this.#assertAcceptingActions();
|
|
1693
|
+
if (!this.dependencies.prepareScopedTask)
|
|
1694
|
+
throw new Error('recoveryUnavailable');
|
|
1695
|
+
this.#scopedPreparationAbort?.abort();
|
|
1696
|
+
const abort = new AbortController();
|
|
1697
|
+
this.#scopedPreparationAbort = abort;
|
|
1698
|
+
try {
|
|
1699
|
+
return await this.#trackRead(this.dependencies.prepareScopedTask(request, AbortSignal.any([this.#abort.signal, abort.signal])));
|
|
1700
|
+
}
|
|
1701
|
+
finally {
|
|
1702
|
+
if (this.#scopedPreparationAbort === abort)
|
|
1703
|
+
this.#scopedPreparationAbort = undefined;
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
async readAgentSettings() {
|
|
1707
|
+
if (!this.dependencies.readAgentSettings)
|
|
1708
|
+
throw new Error('agentSettingsUnavailable');
|
|
1709
|
+
return this.#trackRead(this.dependencies.readAgentSettings());
|
|
1710
|
+
}
|
|
1711
|
+
async previewAgentSettings(preferences, pluginId) {
|
|
1712
|
+
if (!this.dependencies.previewAgentSettings)
|
|
1713
|
+
throw new Error('agentSettingsUnavailable');
|
|
1714
|
+
return this.#trackRead(this.dependencies.previewAgentSettings(preferences, pluginId));
|
|
1715
|
+
}
|
|
1716
|
+
async saveAgentSettings(request) {
|
|
1717
|
+
this.#assertAcceptingActions();
|
|
1718
|
+
if (this.hasActiveWrite || !this.dependencies.saveAgentSettings)
|
|
1719
|
+
throw new Error('agentSettingsUnavailable');
|
|
1720
|
+
return this.dependencies.saveAgentSettings(request);
|
|
1721
|
+
}
|
|
1722
|
+
cancelScopedPreparation() { this.#scopedPreparationAbort?.abort(); }
|
|
1723
|
+
async discardScopedPlan(plan) {
|
|
1724
|
+
this.#scopedExecuted.add(plan);
|
|
1725
|
+
if (plan.kind === 'recovery' || plan.kind === 'retire')
|
|
1726
|
+
await plan.plan.context.dispose();
|
|
1727
|
+
}
|
|
1728
|
+
executeScopedTask(plan) {
|
|
1729
|
+
if (this.#retiring || this.#disposed)
|
|
1730
|
+
return Promise.reject(new Error('sessionRetiring'));
|
|
1731
|
+
if (!this.dependencies.executeScopedTask)
|
|
1732
|
+
return Promise.reject(new Error('recoveryUnavailable'));
|
|
1733
|
+
if (this.#scopedTaskInflight?.plan === plan)
|
|
1734
|
+
return this.#scopedTaskInflight.promise;
|
|
1735
|
+
if (this.hasActiveWrite || this.#scopedExecuted.has(plan)) {
|
|
1736
|
+
return Promise.reject(new Error('reviewTicketInvalid'));
|
|
1737
|
+
}
|
|
1738
|
+
this.#scopedExecuted.add(plan);
|
|
1739
|
+
this.#progressFeed?.clearCurrent();
|
|
1740
|
+
this.#progress = { messages: [], startedAtMs: this.dependencies.now?.() ?? Date.now() };
|
|
1741
|
+
this.#publish();
|
|
1742
|
+
const isBatch = plan.kind === 'recovery' && (plan.plan.command === 'install' || plan.plan.command === 'sync')
|
|
1743
|
+
&& plan.plan.receipt.requestedTargets.length > 1;
|
|
1744
|
+
const promise = this.dependencies.executeScopedTask(plan).then((outcome) => {
|
|
1745
|
+
const skipped = plan.kind === 'recovery' ? plan.skippedConfigTargets ?? [] : [];
|
|
1746
|
+
const recordByDefault = isBatch || skipped.length > 0 || this.#progress.installProgress !== undefined;
|
|
1747
|
+
if (outcome.kind === 'recovery' && (recordByDefault || outcome.receipt.targetResults.some(({ reasons }) => reasons?.some(({ code }) => code === SKILL_INVOCATION_NOTICE)))) {
|
|
1748
|
+
const operationId = `scoped-${crypto.randomUUID()}`;
|
|
1749
|
+
const record = projectScopedRecoveryHistory(outcome.receipt, {
|
|
1750
|
+
operationId, recordId: `${this.#sessionEpoch}:${operationId}`, epoch: this.#sessionEpoch,
|
|
1751
|
+
createdAtMs: this.dependencies.now?.() ?? Date.now(),
|
|
1752
|
+
});
|
|
1753
|
+
for (const target of skipped) {
|
|
1754
|
+
const id = `${record.summary.recordId}:skipped-config:${record.diagnostics.length}`;
|
|
1755
|
+
const position = target.profile === 'common' ? undefined
|
|
1756
|
+
: { pluginId: target.pluginId, platform: target.profile, scope: target.context };
|
|
1757
|
+
record.diagnostics.push({ id, code: 'requiredConfigMissing', stage: 'preflight',
|
|
1758
|
+
safeMessage: guidedSkipWarning([target]), causes: [],
|
|
1759
|
+
detailLines: target.fieldKeys,
|
|
1760
|
+
...(position ? { target: position } : {}),
|
|
1761
|
+
});
|
|
1762
|
+
if (position)
|
|
1763
|
+
record.targets.push({ ...position, state: 'skipped', errorCode: 'requiredConfigMissing', diagnosticIds: [id] });
|
|
1764
|
+
}
|
|
1765
|
+
if (skipped.length > 0) {
|
|
1766
|
+
record.summary.message = outcome.receipt.ok ? '已就绪平台恢复完成;待配置平台保留 requiredConfigMissing 告警。'
|
|
1767
|
+
: `${record.summary.message} 待配置平台保留 requiredConfigMissing 告警。`;
|
|
1768
|
+
}
|
|
1769
|
+
record.summary.diagnosticCount = record.diagnostics.length;
|
|
1770
|
+
if (recordByDefault || record.diagnostics.some(({ code }) => code === SKILL_INVOCATION_NOTICE)) {
|
|
1771
|
+
this.#operationHistory.record(record);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
return outcome;
|
|
1775
|
+
}, (error) => {
|
|
1776
|
+
if (isBatch || this.#progress.installProgress)
|
|
1777
|
+
this.#recordStandaloneFailure(issueCode(error), 'execute', error);
|
|
1778
|
+
throw error;
|
|
1779
|
+
}).finally(() => {
|
|
1780
|
+
if (this.#scopedTaskInflight?.promise === promise)
|
|
1781
|
+
this.#scopedTaskInflight = undefined;
|
|
1782
|
+
this.#publish();
|
|
1783
|
+
});
|
|
1784
|
+
this.#scopedTaskInflight = { plan, promise };
|
|
1785
|
+
return promise;
|
|
1786
|
+
}
|
|
449
1787
|
push(route, context) {
|
|
1788
|
+
if (this.#router.snapshot.current.route.name === 'result') {
|
|
1789
|
+
this.#invalidatePortableResultRecheck();
|
|
1790
|
+
}
|
|
450
1791
|
this.#cancelReviewPreparation();
|
|
451
1792
|
this.#cancelPortableRequest();
|
|
452
1793
|
this.#cancelInstallPlacementRequest();
|
|
453
1794
|
this.#discardPortableDraftForRoute(route);
|
|
454
|
-
|
|
1795
|
+
if ((route.name === 'sourceAdd' || route.name === 'sourceEdit' || route.name === 'sourceSave')
|
|
1796
|
+
&& this.#router.activeFlow()?.kind !== 'sourceEdit') {
|
|
1797
|
+
this.#router.beginFlow('sourceEdit', this.#router.snapshot.current.route);
|
|
1798
|
+
}
|
|
1799
|
+
this.#router.push(route.name === 'pluginPreview' ? this.#normalizeRoute(route) : route, context);
|
|
455
1800
|
this.#publish();
|
|
456
1801
|
}
|
|
457
1802
|
hasPortableSkills(pluginId) {
|
|
458
1803
|
return this.#status?.portablePluginIds?.includes(pluginId) ?? false;
|
|
459
1804
|
}
|
|
460
1805
|
preparePortableInstall(pluginId, navigation = 'push') {
|
|
1806
|
+
this.#assertAcceptingActions();
|
|
461
1807
|
if (!this.hasPortableSkills(pluginId)) {
|
|
462
1808
|
throw new TuiOperationBlockedError('portableUnsupported', '插件不提供通用 Skills。');
|
|
463
1809
|
}
|
|
1810
|
+
const requestKey = `prepare:${pluginId}`;
|
|
1811
|
+
if (this.#portablePending?.key === requestKey) {
|
|
1812
|
+
return this.#portablePending.promise;
|
|
1813
|
+
}
|
|
464
1814
|
this.#router.beginPortableFlow(pluginId);
|
|
1815
|
+
this.#router[navigation]({ name: 'portablePreparing', pluginId });
|
|
1816
|
+
this.#publish();
|
|
465
1817
|
const expectedRoute = this.#router.snapshot.current.route;
|
|
466
|
-
return this.#runPortableRequest(
|
|
1818
|
+
return this.#runPortableRequest(requestKey, async (signal, token) => {
|
|
467
1819
|
const draft = await this.#buildPortableDraft(pluginId, false, signal);
|
|
468
1820
|
this.#assertPortableRequestCurrent(token, expectedRoute);
|
|
469
1821
|
this.#portableDraft = draft;
|
|
470
|
-
this.#router
|
|
1822
|
+
this.#router.replace({ name: 'portableSkillSelect', pluginId });
|
|
471
1823
|
this.#publish();
|
|
472
1824
|
return cloneFrozen(draft);
|
|
473
1825
|
});
|
|
474
1826
|
}
|
|
475
1827
|
refreshPortableInstallDraft(pluginId) {
|
|
1828
|
+
this.#assertAcceptingActions();
|
|
476
1829
|
const expectedRoute = this.#router.snapshot.current.route;
|
|
477
1830
|
return this.#runPortableRequest(`refresh:${pluginId}`, async (signal, token) => {
|
|
478
1831
|
const draft = await this.#buildPortableDraft(pluginId, true, signal);
|
|
479
1832
|
this.#assertPortableRequestCurrent(token, expectedRoute);
|
|
1833
|
+
if (this.#activeReview?.operationKind === 'portableInstall') {
|
|
1834
|
+
this.#tickets.delete(this.#activeReview.reviewToken);
|
|
1835
|
+
this.#activeReview = undefined;
|
|
1836
|
+
}
|
|
480
1837
|
this.#portableDraft = draft;
|
|
481
1838
|
this.#publish();
|
|
482
1839
|
return cloneFrozen(draft);
|
|
@@ -488,12 +1845,12 @@ export class TuiController {
|
|
|
488
1845
|
: undefined;
|
|
489
1846
|
const prepared = await Promise.allSettled(['project', 'user'].map(async (scope) => ({
|
|
490
1847
|
scope,
|
|
491
|
-
evidence: await this.dependencies.captureEvidence({
|
|
1848
|
+
evidence: await this.#trackRead(this.dependencies.captureEvidence({
|
|
492
1849
|
kind: 'portableInstall',
|
|
493
1850
|
pluginId,
|
|
494
1851
|
scope,
|
|
495
1852
|
selectedSkills: [],
|
|
496
|
-
}, signal),
|
|
1853
|
+
}, signal)),
|
|
497
1854
|
})));
|
|
498
1855
|
const available = prepared.flatMap((entry) => entry.status === 'fulfilled' && entry.value.evidence.portable ? [entry.value] : []);
|
|
499
1856
|
if (available.length === 0) {
|
|
@@ -568,6 +1925,14 @@ export class TuiController {
|
|
|
568
1925
|
this.#portableDraft.canContinue = this.#portableDraft.totalCount > 0;
|
|
569
1926
|
this.#publish();
|
|
570
1927
|
}
|
|
1928
|
+
clearPortableSkills() {
|
|
1929
|
+
if (!this.#portableDraft)
|
|
1930
|
+
return;
|
|
1931
|
+
this.#portableDraft.candidates = this.#portableDraft.candidates.map((candidate) => ({ ...candidate, selected: false }));
|
|
1932
|
+
this.#portableDraft.selectedCount = 0;
|
|
1933
|
+
this.#portableDraft.canContinue = false;
|
|
1934
|
+
this.#publish();
|
|
1935
|
+
}
|
|
571
1936
|
setPortableAgentMode(mode, requestedAgents = []) {
|
|
572
1937
|
if (!this.#portableDraft)
|
|
573
1938
|
return;
|
|
@@ -612,42 +1977,300 @@ export class TuiController {
|
|
|
612
1977
|
const intent = this.#portableInstallIntent();
|
|
613
1978
|
return this.startReviewPreparation(intent, this.#router.portableOrigin(intent.pluginId));
|
|
614
1979
|
}
|
|
1980
|
+
async recheckPortableResult() {
|
|
1981
|
+
this.#assertAcceptingActions();
|
|
1982
|
+
if (this.#router.snapshot.current.route.name !== 'result'
|
|
1983
|
+
|| this.#result?.operationKind !== 'portableInstall'
|
|
1984
|
+
|| !this.#portableResultReceipt
|
|
1985
|
+
|| !this.#portableResultIntent
|
|
1986
|
+
|| !this.dependencies.recheckPortableInstall) {
|
|
1987
|
+
throw new TuiOperationBlockedError('portableRecheckUnavailable', '当前结果不能执行只读复查。');
|
|
1988
|
+
}
|
|
1989
|
+
const currentResult = this.#result;
|
|
1990
|
+
if (currentResult.state !== 'succeeded' && currentResult.state !== 'partial') {
|
|
1991
|
+
throw new TuiOperationBlockedError('portableRecheckUnavailable', '当前结果不能执行只读复查。');
|
|
1992
|
+
}
|
|
1993
|
+
const previous = structuredClone(currentResult);
|
|
1994
|
+
const originalReceipt = structuredClone(this.#portableResultReceipt);
|
|
1995
|
+
const originalIntent = structuredClone(this.#portableResultIntent);
|
|
1996
|
+
const lifecycle = this.#portableResultLifecycle;
|
|
1997
|
+
if (this.#portableResultRecheck?.lifecycle === lifecycle
|
|
1998
|
+
&& this.#portableResultRecheck.operationId === previous.operationId) {
|
|
1999
|
+
return await this.#portableResultRecheck.promise;
|
|
2000
|
+
}
|
|
2001
|
+
const abort = new AbortController();
|
|
2002
|
+
const signal = AbortSignal.any([this.#abort.signal, abort.signal]);
|
|
2003
|
+
const isCurrent = () => !this.#disposed
|
|
2004
|
+
&& !this.#retiring
|
|
2005
|
+
&& !signal.aborted
|
|
2006
|
+
&& lifecycle === this.#portableResultLifecycle
|
|
2007
|
+
&& this.#router.snapshot.current.route.name === 'result'
|
|
2008
|
+
&& this.#result?.operationId === previous.operationId
|
|
2009
|
+
&& this.#result.operationRecordId === previous.operationRecordId;
|
|
2010
|
+
const promise = (async () => {
|
|
2011
|
+
let checked;
|
|
2012
|
+
try {
|
|
2013
|
+
checked = await this.#trackRead(this.dependencies.recheckPortableInstall(structuredClone(originalReceipt), signal));
|
|
2014
|
+
}
|
|
2015
|
+
catch (error) {
|
|
2016
|
+
if (!isCurrent())
|
|
2017
|
+
return cloneFrozen(originalReceipt);
|
|
2018
|
+
throw error;
|
|
2019
|
+
}
|
|
2020
|
+
if (!isCurrent())
|
|
2021
|
+
return cloneFrozen(originalReceipt);
|
|
2022
|
+
this.#portableResultReceipt = structuredClone(checked);
|
|
2023
|
+
const summary = operationResultSummary(originalIntent, checked);
|
|
2024
|
+
const verificationState = summary.portable?.verificationUnknown
|
|
2025
|
+
? 'unknown' : 'completed';
|
|
2026
|
+
const effects = previous.effects
|
|
2027
|
+
? { ...previous.effects, finalVerification: verificationState }
|
|
2028
|
+
: undefined;
|
|
2029
|
+
const updatedSummary = {
|
|
2030
|
+
...summary,
|
|
2031
|
+
...(previous.summary.elapsedMs !== undefined
|
|
2032
|
+
? { elapsedMs: previous.summary.elapsedMs } : {}),
|
|
2033
|
+
...(previous.summary.diagnosticIds
|
|
2034
|
+
? { diagnosticIds: structuredClone(previous.summary.diagnosticIds) } : {}),
|
|
2035
|
+
...(effects ? { effects } : {}),
|
|
2036
|
+
};
|
|
2037
|
+
const updated = checked.status === 'succeeded'
|
|
2038
|
+
? { ...previous, state: 'succeeded', summary: updatedSummary, ...(effects ? { effects } : {}) }
|
|
2039
|
+
: { ...previous, state: 'partial', summary: updatedSummary, ...(effects ? { effects } : {}) };
|
|
2040
|
+
this.#result = updated;
|
|
2041
|
+
if (updated.operationRecordId) {
|
|
2042
|
+
const record = this.#operationHistory.get(updated.operationRecordId);
|
|
2043
|
+
if (record) {
|
|
2044
|
+
record.summary = {
|
|
2045
|
+
...record.summary,
|
|
2046
|
+
state: updated.state,
|
|
2047
|
+
code: updated.summary.code,
|
|
2048
|
+
message: updated.summary.message,
|
|
2049
|
+
effects: effects ?? record.summary.effects,
|
|
2050
|
+
};
|
|
2051
|
+
this.#operationHistory.record(record);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
this.#publish();
|
|
2055
|
+
return cloneFrozen(checked);
|
|
2056
|
+
})();
|
|
2057
|
+
this.#portableResultRecheck = {
|
|
2058
|
+
lifecycle,
|
|
2059
|
+
operationId: previous.operationId,
|
|
2060
|
+
abort,
|
|
2061
|
+
promise,
|
|
2062
|
+
};
|
|
2063
|
+
void promise.finally(() => {
|
|
2064
|
+
if (this.#portableResultRecheck?.promise === promise) {
|
|
2065
|
+
this.#portableResultRecheck = undefined;
|
|
2066
|
+
}
|
|
2067
|
+
}).catch(() => undefined);
|
|
2068
|
+
return await promise;
|
|
2069
|
+
}
|
|
2070
|
+
startPortableRetryReviewPreparation() {
|
|
2071
|
+
this.#assertAcceptingActions();
|
|
2072
|
+
const receipt = this.#portableResultReceipt;
|
|
2073
|
+
const original = this.#portableResultIntent;
|
|
2074
|
+
if (this.#router.snapshot.current.route.name !== 'result' || !receipt || !original) {
|
|
2075
|
+
throw new TuiOperationBlockedError('portableRetryUnavailable', '当前结果不能准备精确重试。');
|
|
2076
|
+
}
|
|
2077
|
+
if ((receipt.verification.unknown?.length ?? 0) > 0) {
|
|
2078
|
+
throw new TuiOperationBlockedError('portableRetryNotExact', '结果仍有未知目标。请先只读复查。');
|
|
2079
|
+
}
|
|
2080
|
+
const retryPairs = receipt.verification.missing;
|
|
2081
|
+
if (retryPairs.length === 0 || retryPairs.some((target) => !target.agent)) {
|
|
2082
|
+
throw new TuiOperationBlockedError('portableRetryNotExact', '没有可绑定到 Skill 与 Agent 的精确失败目标。');
|
|
2083
|
+
}
|
|
2084
|
+
const intent = {
|
|
2085
|
+
kind: 'portableInstall',
|
|
2086
|
+
pluginId: original.pluginId,
|
|
2087
|
+
scope: original.scope,
|
|
2088
|
+
selectedSkills: [...new Set(retryPairs.map((target) => target.skill))],
|
|
2089
|
+
requestedAgents: [...new Set(retryPairs.flatMap((target) => target.agent ? [target.agent] : []))],
|
|
2090
|
+
retry: { receipt: structuredClone(receipt) },
|
|
2091
|
+
};
|
|
2092
|
+
return this.startReviewPreparation(intent, {
|
|
2093
|
+
name: 'pluginDetail',
|
|
2094
|
+
pluginId: original.pluginId,
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
615
2097
|
discardPortableDraft() {
|
|
616
2098
|
this.#cancelPortableRequest();
|
|
617
2099
|
this.#portableDraft = undefined;
|
|
618
2100
|
this.#publish();
|
|
619
2101
|
}
|
|
620
2102
|
replace(route, context) {
|
|
2103
|
+
if (this.#router.snapshot.current.route.name === 'result') {
|
|
2104
|
+
this.#invalidatePortableResultRecheck();
|
|
2105
|
+
}
|
|
621
2106
|
this.#cancelReviewPreparation();
|
|
622
2107
|
this.#cancelPortableRequest();
|
|
623
2108
|
this.#cancelInstallPlacementRequest();
|
|
624
2109
|
const current = this.#router.snapshot.current.route;
|
|
625
2110
|
if (current.name === 'portableBlocker' && current.code === 'requiredConfigMissing'
|
|
626
|
-
&& route.name === '
|
|
2111
|
+
&& route.name === 'configFields' && route.pluginId === current.pluginId) {
|
|
627
2112
|
this.#portableRepreparePluginId = current.pluginId;
|
|
628
2113
|
}
|
|
629
2114
|
this.#discardPortableDraftForRoute(route);
|
|
630
|
-
this.#
|
|
2115
|
+
const nextRoute = route.name === 'pluginPreview' ? this.#normalizeRoute(route) : route;
|
|
2116
|
+
const preserveConfigOverview = current.name === 'configFields'
|
|
2117
|
+
&& route.name === 'configUnavailable'
|
|
2118
|
+
&& route.pluginId === current.pluginId
|
|
2119
|
+
&& this.#router.activeFlow()?.kind === 'configEdit';
|
|
2120
|
+
if (preserveConfigOverview)
|
|
2121
|
+
this.#router.push(nextRoute, context);
|
|
2122
|
+
else
|
|
2123
|
+
this.#router.replace(nextRoute, context);
|
|
631
2124
|
this.#publish();
|
|
632
2125
|
}
|
|
633
|
-
beginConfigFlow(pluginId) {
|
|
2126
|
+
beginConfigFlow(pluginId, options = {}) {
|
|
634
2127
|
this.#router.beginConfigFlow(pluginId);
|
|
635
2128
|
this.#router.push({
|
|
636
2129
|
name: 'configFields',
|
|
637
2130
|
pluginId,
|
|
638
|
-
layer: {
|
|
2131
|
+
layer: { profile: options.platform ?? 'common', context: options.context ?? 'user' },
|
|
2132
|
+
});
|
|
2133
|
+
this.#publish();
|
|
2134
|
+
}
|
|
2135
|
+
beginGuidedConfig(pluginId, layer) {
|
|
2136
|
+
this.#assertAcceptingActions();
|
|
2137
|
+
const origin = this.#router.snapshot.current;
|
|
2138
|
+
const flow = this.#router.beginFlow('configEdit', origin.route, this.#router.snapshot.currentFrameId, origin.context);
|
|
2139
|
+
this.#router.push({ name: 'configFields', pluginId, layer });
|
|
2140
|
+
this.#publish();
|
|
2141
|
+
return flow.id;
|
|
2142
|
+
}
|
|
2143
|
+
finishGuidedConfig(flowId) {
|
|
2144
|
+
this.#router.finishFlowById(flowId, 'configEdit');
|
|
2145
|
+
this.#publish();
|
|
2146
|
+
}
|
|
2147
|
+
beginConfigReferenceSource(pluginId, fieldKey) {
|
|
2148
|
+
this.#assertAcceptingActions();
|
|
2149
|
+
const current = this.#router.snapshot.current;
|
|
2150
|
+
const route = current.route;
|
|
2151
|
+
if (!['configFieldEditor', 'configObjectPropertyEditor'].includes(route.name)
|
|
2152
|
+
|| !('pluginId' in route)
|
|
2153
|
+
|| sourceIdFromPluginId(route.pluginId) !== sourceIdFromPluginId(pluginId)
|
|
2154
|
+
|| route.pluginId === pluginId) {
|
|
2155
|
+
throw new TuiOperationBlockedError('configReferenceSourceUnavailable', '引用来源必须是同一来源中的其他插件。');
|
|
2156
|
+
}
|
|
2157
|
+
this.#cancelReviewPreparation();
|
|
2158
|
+
if (this.#activeReview)
|
|
2159
|
+
this.#tickets.delete(this.#activeReview.reviewToken);
|
|
2160
|
+
this.#activeReview = undefined;
|
|
2161
|
+
this.#router.beginFlow('configEdit', route, this.#router.snapshot.currentFrameId, current.context);
|
|
2162
|
+
const layer = ('layer' in route ? route.layer : undefined) ?? { profile: 'common', context: 'user' };
|
|
2163
|
+
this.#router.push({ name: 'configFields', pluginId, layer });
|
|
2164
|
+
this.#router.push({ name: 'configFieldEditor', pluginId, layer, fieldKey, editor: 'array', mode: 'choices' });
|
|
2165
|
+
this.#publish();
|
|
2166
|
+
}
|
|
2167
|
+
beginSavedConfigRecovery(pluginId) {
|
|
2168
|
+
this.#assertAcceptingActions();
|
|
2169
|
+
const plugin = this.#viewModel?.plugins.find((entry) => entry.pluginId === pluginId);
|
|
2170
|
+
if (!plugin?.configOnly || plugin.savedConfigScopes.length === 0) {
|
|
2171
|
+
throw new TuiOperationBlockedError('savedConfigUnavailable', '没有可识别的已保存设置。');
|
|
2172
|
+
}
|
|
2173
|
+
this.#router.beginConfigFlow(pluginId);
|
|
2174
|
+
this.#router.push({
|
|
2175
|
+
name: 'configUnavailable',
|
|
2176
|
+
pluginId,
|
|
2177
|
+
storedScopes: plugin.savedConfigScopes,
|
|
2178
|
+
layer: { profile: 'common', context: 'user' },
|
|
2179
|
+
diagnosticCode: 'catalogSourceUnavailable',
|
|
2180
|
+
diagnosticStage: 'read-config',
|
|
639
2181
|
});
|
|
640
2182
|
this.#publish();
|
|
641
2183
|
}
|
|
2184
|
+
beginConfigSourceRecovery(sourceId) {
|
|
2185
|
+
this.#assertAcceptingActions();
|
|
2186
|
+
const route = this.#router.snapshot.current.route;
|
|
2187
|
+
const active = this.#router.activeFlow();
|
|
2188
|
+
if (route.name !== 'configUnavailable'
|
|
2189
|
+
|| active?.kind !== 'configEdit'
|
|
2190
|
+
|| route.storedScopes !== undefined
|
|
2191
|
+
|| sourceIdFromPluginId(route.pluginId) !== sourceId
|
|
2192
|
+
|| !this.#viewModel?.sourceTabs.some((source) => source.id === sourceId)) {
|
|
2193
|
+
throw new TuiOperationBlockedError('configSourceRecoveryUnavailable', '来源恢复只能从不可用的设置流程开始。');
|
|
2194
|
+
}
|
|
2195
|
+
const layer = route.layer ?? route.resumeRoute?.layer ?? { profile: 'common', context: 'user' };
|
|
2196
|
+
const returnTarget = route.resumeRoute ?? {
|
|
2197
|
+
name: 'configFields',
|
|
2198
|
+
pluginId: route.pluginId,
|
|
2199
|
+
layer,
|
|
2200
|
+
};
|
|
2201
|
+
this.#router.beginFlow('sourceRecovery', returnTarget, undefined, route.resumeContext);
|
|
2202
|
+
this.#router.push({ name: 'sourceDetail', sourceId });
|
|
2203
|
+
this.#publish();
|
|
2204
|
+
}
|
|
2205
|
+
async getForceCleanupCandidate(pluginId, platform, scope) {
|
|
2206
|
+
this.#assertAcceptingActions();
|
|
2207
|
+
const intent = {
|
|
2208
|
+
kind: 'pluginWrite', action: 'cleanup', pluginId, platform, scope, force: true,
|
|
2209
|
+
};
|
|
2210
|
+
try {
|
|
2211
|
+
const prepared = await this.prepareScopedTask({ kind: 'recovery', command: 'cleanup',
|
|
2212
|
+
scope, selectors: [pluginId], targets: [platform],
|
|
2213
|
+
exactTargets: [{ pluginId, agent: platform }], force: true });
|
|
2214
|
+
if (prepared.kind !== 'recovery')
|
|
2215
|
+
return undefined;
|
|
2216
|
+
try {
|
|
2217
|
+
const candidate = prepared.plan.nativeGroups.flatMap((group) => group.preview.operationPlan ? group.preview.offlineCleanupPlans ?? [] : [])
|
|
2218
|
+
.find((entry) => entry.pluginId === pluginId && entry.platform === platform && entry.scope === scope);
|
|
2219
|
+
if (prepared.plan.blockExecution || !candidate || candidate.forceExclusive !== true
|
|
2220
|
+
|| candidate.plan.actions.length === 0)
|
|
2221
|
+
return undefined;
|
|
2222
|
+
return cloneFrozen({ pluginId, platform, scope, actionCount: candidate.plan.actions.length });
|
|
2223
|
+
}
|
|
2224
|
+
finally {
|
|
2225
|
+
await this.discardScopedPlan(prepared);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
catch (error) {
|
|
2229
|
+
await this.#logOperationError(error, issueCode(error), intent);
|
|
2230
|
+
return undefined;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
startForceCleanupReview(candidate) {
|
|
2234
|
+
const agent = candidate.platform;
|
|
2235
|
+
return this.prepareScopedTask({ kind: 'recovery', command: 'cleanup',
|
|
2236
|
+
scope: candidate.scope, selectors: [candidate.pluginId], targets: [agent],
|
|
2237
|
+
exactTargets: [{ pluginId: candidate.pluginId, agent }], force: true });
|
|
2238
|
+
}
|
|
642
2239
|
configOrigin(pluginId) {
|
|
643
|
-
|
|
2240
|
+
const origin = this.#router.configOrigin(pluginId);
|
|
2241
|
+
if (origin)
|
|
2242
|
+
return origin;
|
|
2243
|
+
if (this.#router.snapshot.current.route.name === 'result'
|
|
2244
|
+
&& this.#resultAnchor
|
|
2245
|
+
&& (this.#resultAnchor.name === 'pluginPreview' || this.#resultAnchor.name === 'pluginDetail'
|
|
2246
|
+
|| this.#resultAnchor.name === 'pluginWriteTask')
|
|
2247
|
+
&& (this.#resultAnchor.pluginId === pluginId
|
|
2248
|
+
|| this.#resultAnchor.name === 'pluginWriteTask'
|
|
2249
|
+
&& this.#resultAnchor.targetKeys?.some((key) => key.startsWith(`${pluginId}\0`)))) {
|
|
2250
|
+
return structuredClone(this.#resultAnchor);
|
|
2251
|
+
}
|
|
2252
|
+
return undefined;
|
|
644
2253
|
}
|
|
645
2254
|
updatePageContext(context) {
|
|
646
2255
|
this.#router.updateContext(context);
|
|
647
2256
|
this.#publish();
|
|
648
2257
|
}
|
|
2258
|
+
returnToConfigOverview(flowId, overviewFrameId, pluginId, context) {
|
|
2259
|
+
const returned = this.#router.returnToConfigOverview(flowId, overviewFrameId, pluginId, context);
|
|
2260
|
+
if (!returned)
|
|
2261
|
+
return false;
|
|
2262
|
+
this.#normalizeCurrentRoute();
|
|
2263
|
+
this.#publish();
|
|
2264
|
+
return true;
|
|
2265
|
+
}
|
|
2266
|
+
configOverviewFrameId(flowId, pluginId) {
|
|
2267
|
+
return this.#router.configOverviewFrameId(flowId, pluginId);
|
|
2268
|
+
}
|
|
649
2269
|
back() {
|
|
650
2270
|
const route = this.#router.snapshot.current.route;
|
|
2271
|
+
if (route.name === 'result')
|
|
2272
|
+
this.#invalidatePortableResultRecheck();
|
|
2273
|
+
const activeFlow = this.#router.activeFlow();
|
|
651
2274
|
this.#cancelReviewPreparation();
|
|
652
2275
|
this.#cancelPortableRequest();
|
|
653
2276
|
this.#cancelInstallPlacementRequest();
|
|
@@ -655,7 +2278,21 @@ export class TuiController {
|
|
|
655
2278
|
this.#tickets.delete(this.#activeReview.reviewToken);
|
|
656
2279
|
this.#activeReview = undefined;
|
|
657
2280
|
}
|
|
658
|
-
|
|
2281
|
+
if (route.name === 'batchSelection' && activeFlow?.kind === 'batchWrite'
|
|
2282
|
+
&& this.#router.snapshot.currentFrameId === activeFlow.originFrameId) {
|
|
2283
|
+
this.#router.finishFlow();
|
|
2284
|
+
}
|
|
2285
|
+
else
|
|
2286
|
+
this.#router.back();
|
|
2287
|
+
if (activeFlow
|
|
2288
|
+
&& this.#router.snapshot.currentFrameId === activeFlow.originFrameId
|
|
2289
|
+
&& this.#router.snapshot.currentFlowId !== activeFlow.id) {
|
|
2290
|
+
this.#router.abandonFlow(activeFlow.id);
|
|
2291
|
+
if (activeFlow.kind === 'pluginInstall')
|
|
2292
|
+
this.#installPlacementDraft = undefined;
|
|
2293
|
+
if (activeFlow.kind === 'portableInstall')
|
|
2294
|
+
this.#portableDraft = undefined;
|
|
2295
|
+
}
|
|
659
2296
|
this.#normalizeCurrentRoute();
|
|
660
2297
|
this.#discardPortableDraftForRoute(this.#router.snapshot.current.route);
|
|
661
2298
|
this.#publish();
|
|
@@ -666,13 +2303,36 @@ export class TuiController {
|
|
|
666
2303
|
this.#activeReview = undefined;
|
|
667
2304
|
}
|
|
668
2305
|
this.#result = undefined;
|
|
669
|
-
this.#router.
|
|
2306
|
+
const activeFlow = this.#router.activeFlow();
|
|
2307
|
+
if (activeFlow?.kind === 'sourceEdit') {
|
|
2308
|
+
this.#router.abandonFlow(activeFlow.id);
|
|
2309
|
+
if (JSON.stringify(this.#router.snapshot.current.route) !== JSON.stringify(returnRoute)) {
|
|
2310
|
+
this.#router.replace(returnRoute);
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
else {
|
|
2314
|
+
this.#router.discardSourceFlow(owner, returnRoute);
|
|
2315
|
+
}
|
|
670
2316
|
this.#normalizeCurrentRoute();
|
|
671
2317
|
this.#publish();
|
|
672
2318
|
}
|
|
673
2319
|
leaveResult(target) {
|
|
674
2320
|
if (this.#router.snapshot.current.route.name !== 'result')
|
|
675
2321
|
return;
|
|
2322
|
+
this.#invalidatePortableResultRecheck();
|
|
2323
|
+
if (target?.name === 'home') {
|
|
2324
|
+
this.#router.resetToRoot();
|
|
2325
|
+
this.#portableDraft = undefined;
|
|
2326
|
+
this.#recoverablePortableDraft = undefined;
|
|
2327
|
+
this.#installPlacementDraft = undefined;
|
|
2328
|
+
this.#recoverableInstallPlacementDraft = undefined;
|
|
2329
|
+
this.#result = undefined;
|
|
2330
|
+
this.#resultAnchor = undefined;
|
|
2331
|
+
this.#portableResultSkills = undefined;
|
|
2332
|
+
this.#completionNotice = undefined;
|
|
2333
|
+
this.#publish();
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
676
2336
|
if (this.#result?.operationKind === 'portableInstall'
|
|
677
2337
|
&& 'pluginId' in this.#result && this.#result.pluginId) {
|
|
678
2338
|
const preserveDraft = target?.name === 'portableSkillSelect'
|
|
@@ -681,27 +2341,78 @@ export class TuiController {
|
|
|
681
2341
|
return;
|
|
682
2342
|
}
|
|
683
2343
|
if (this.#result?.state === 'succeeded'
|
|
684
|
-
&& (this.#result.operationKind === 'configSave' || this.#result.operationKind === '
|
|
2344
|
+
&& (this.#result.operationKind === 'configSave' || this.#result.operationKind === 'configSaveBatch'
|
|
2345
|
+
|| this.#result.operationKind === 'configReset')
|
|
685
2346
|
&& this.#result.pluginId
|
|
686
2347
|
&& this.#router.resetConfigFlow(this.#result.pluginId, target)) {
|
|
687
2348
|
this.#result = undefined;
|
|
688
2349
|
this.#publish();
|
|
689
2350
|
return;
|
|
690
2351
|
}
|
|
691
|
-
const route = target ?? (this.#result && 'returnRoute' in this.#result
|
|
692
|
-
? this.#result.returnRoute
|
|
693
|
-
: undefined);
|
|
694
2352
|
this.#router.back();
|
|
695
|
-
if (
|
|
696
|
-
this.#router.replace(this.#normalizeRoute(
|
|
2353
|
+
if (target)
|
|
2354
|
+
this.#router.replace(this.#normalizeRoute(target));
|
|
697
2355
|
else
|
|
698
2356
|
this.#normalizeCurrentRoute();
|
|
699
2357
|
this.#discardPortableDraftForRoute(this.#router.snapshot.current.route);
|
|
700
2358
|
this.#result = undefined;
|
|
2359
|
+
this.#resultAnchor = undefined;
|
|
2360
|
+
this.#portableResultSkills = undefined;
|
|
2361
|
+
this.#completionNotice = undefined;
|
|
2362
|
+
this.#recoverableInstallPlacementDraft = undefined;
|
|
2363
|
+
this.#recoverablePortableDraft = undefined;
|
|
2364
|
+
this.#publish();
|
|
2365
|
+
}
|
|
2366
|
+
resumeResultDraft() {
|
|
2367
|
+
const result = this.#result;
|
|
2368
|
+
if (this.#router.snapshot.current.route.name !== 'result' || !result
|
|
2369
|
+
|| !('returnRoute' in result) || !result.returnRoute)
|
|
2370
|
+
return;
|
|
2371
|
+
if (result.operationKind === 'pluginWriteBatch' && !this.#recoverableInstallPlacementDraft)
|
|
2372
|
+
return;
|
|
2373
|
+
this.#invalidatePortableResultRecheck();
|
|
2374
|
+
const returnRoute = this.#normalizeRoute(result.returnRoute);
|
|
2375
|
+
this.#router.back();
|
|
2376
|
+
const kind = this.#recoverableInstallPlacementDraft
|
|
2377
|
+
? 'pluginInstall'
|
|
2378
|
+
: result.operationKind === 'configSave' || result.operationKind === 'configSaveBatch'
|
|
2379
|
+
|| result.operationKind === 'configReset'
|
|
2380
|
+
? 'configEdit'
|
|
2381
|
+
: result.operationKind === 'portableInstall'
|
|
2382
|
+
? 'portableInstall'
|
|
2383
|
+
: result.operationKind === 'sourceMutation' || result.operationKind === 'catalogGeneration'
|
|
2384
|
+
|| result.operationKind === 'catalogSourcesRecovery'
|
|
2385
|
+
? 'sourceEdit'
|
|
2386
|
+
: 'pluginMaintenance';
|
|
2387
|
+
this.#router.beginFlow(kind, this.#router.snapshot.current.route);
|
|
2388
|
+
if (this.#recoverableInstallPlacementDraft) {
|
|
2389
|
+
this.#installPlacementDraft = this.#recoverableInstallPlacementDraft;
|
|
2390
|
+
if (this.#installPlacementDraft.exactRootTargets) {
|
|
2391
|
+
this.#installPlacementDraft.state = 'selecting';
|
|
2392
|
+
this.#installPlacementDraft.targets = [];
|
|
2393
|
+
this.#installPlacementDraft.canContinue = false;
|
|
2394
|
+
this.#installPlacementDraft.error = undefined;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
if (result.operationKind === 'portableInstall') {
|
|
2398
|
+
this.#portableDraft = this.#recoverablePortableDraft;
|
|
2399
|
+
}
|
|
2400
|
+
this.#router.push(returnRoute);
|
|
2401
|
+
this.#recoverableInstallPlacementDraft = undefined;
|
|
2402
|
+
this.#recoverablePortableDraft = undefined;
|
|
2403
|
+
this.#result = undefined;
|
|
2404
|
+
this.#resultAnchor = undefined;
|
|
2405
|
+
this.#portableResultSkills = undefined;
|
|
701
2406
|
this.#publish();
|
|
702
2407
|
}
|
|
703
2408
|
#discardPortableDraftForRoute(route) {
|
|
704
|
-
const
|
|
2409
|
+
const readOnlyHistoryRoute = route.name === 'operationHistory'
|
|
2410
|
+
|| route.name === 'operationDiagnostic'
|
|
2411
|
+
|| route.name === 'operationReportPreview';
|
|
2412
|
+
if (readOnlyHistoryRoute && this.#router.activeFlow()?.kind === 'portableInstall')
|
|
2413
|
+
return;
|
|
2414
|
+
const portableRoute = route.name === 'portablePreparing'
|
|
2415
|
+
|| route.name === 'portableSkillSelect'
|
|
705
2416
|
|| route.name === 'portableDependencies'
|
|
706
2417
|
|| route.name === 'portableAgentMode'
|
|
707
2418
|
|| route.name === 'portableAgentInput'
|
|
@@ -709,7 +2420,8 @@ export class TuiController {
|
|
|
709
2420
|
|| route.name === 'portableBlocker';
|
|
710
2421
|
const portableOperationRoute = (route.name === 'reviewPreparing' || route.name === 'review'
|
|
711
2422
|
|| route.name === 'progress' || route.name === 'result')
|
|
712
|
-
&& (this.#reviewPreparation
|
|
2423
|
+
&& (this.#reviewPreparation !== undefined
|
|
2424
|
+
&& this.#reviewPreparationIntents.get(this.#reviewPreparation.snapshot.id)?.kind === 'portableInstall'
|
|
713
2425
|
|| this.#activeReview?.operationKind === 'portableInstall'
|
|
714
2426
|
|| this.#result?.operationKind === 'portableInstall');
|
|
715
2427
|
if (!portableRoute && !portableOperationRoute) {
|
|
@@ -718,16 +2430,26 @@ export class TuiController {
|
|
|
718
2430
|
}
|
|
719
2431
|
}
|
|
720
2432
|
resetPortableFlowToPreview(pluginId, target, preserveDraft = false) {
|
|
2433
|
+
this.#invalidatePortableResultRecheck();
|
|
721
2434
|
this.#cancelPortableRequest();
|
|
2435
|
+
if (preserveDraft && !this.#portableDraft) {
|
|
2436
|
+
this.#portableDraft = this.#recoverablePortableDraft;
|
|
2437
|
+
}
|
|
722
2438
|
if (!preserveDraft)
|
|
723
2439
|
this.#portableDraft = undefined;
|
|
2440
|
+
this.#recoverablePortableDraft = undefined;
|
|
724
2441
|
if (this.#activeReview?.operationKind === 'portableInstall') {
|
|
725
2442
|
this.#tickets.delete(this.#activeReview.reviewToken);
|
|
726
2443
|
this.#activeReview = undefined;
|
|
727
2444
|
}
|
|
728
2445
|
if (this.#result?.operationKind === 'portableInstall')
|
|
729
2446
|
this.#result = undefined;
|
|
730
|
-
this.#
|
|
2447
|
+
this.#resultAnchor = undefined;
|
|
2448
|
+
this.#portableResultSkills = undefined;
|
|
2449
|
+
if (this.#router.snapshot.current.route.name === 'result')
|
|
2450
|
+
this.#router.back();
|
|
2451
|
+
else
|
|
2452
|
+
this.#router.resetPortableFlow(pluginId);
|
|
731
2453
|
if (target && JSON.stringify(this.#router.snapshot.current.route) !== JSON.stringify(target)) {
|
|
732
2454
|
this.#router.beginPortableFlow(pluginId);
|
|
733
2455
|
this.#router.push(this.#normalizeRoute(target));
|
|
@@ -740,6 +2462,11 @@ export class TuiController {
|
|
|
740
2462
|
this.#portableRequestAbort = undefined;
|
|
741
2463
|
this.#portablePending = undefined;
|
|
742
2464
|
}
|
|
2465
|
+
#invalidatePortableResultRecheck() {
|
|
2466
|
+
this.#portableResultLifecycle += 1;
|
|
2467
|
+
this.#portableResultRecheck?.abort.abort();
|
|
2468
|
+
this.#portableResultRecheck = undefined;
|
|
2469
|
+
}
|
|
743
2470
|
#runPortableRequest(key, action) {
|
|
744
2471
|
if (this.#portablePending?.key === key) {
|
|
745
2472
|
return this.#portablePending.promise;
|
|
@@ -764,8 +2491,11 @@ export class TuiController {
|
|
|
764
2491
|
throw new DOMException('Portable request was cancelled.', 'AbortError');
|
|
765
2492
|
}
|
|
766
2493
|
}
|
|
767
|
-
beginInstallFlow(pluginId, rootScope
|
|
2494
|
+
beginInstallFlow(pluginId, rootScope) {
|
|
768
2495
|
this.#cancelInstallPlacementRequest();
|
|
2496
|
+
const active = this.#router.activeFlow();
|
|
2497
|
+
if (active?.kind !== 'pluginInstall')
|
|
2498
|
+
this.#router.beginPluginFlow('pluginInstall', pluginId);
|
|
769
2499
|
this.#installPlacementDraft = {
|
|
770
2500
|
pluginId,
|
|
771
2501
|
rootScope,
|
|
@@ -774,7 +2504,6 @@ export class TuiController {
|
|
|
774
2504
|
state: 'selecting',
|
|
775
2505
|
targets: [],
|
|
776
2506
|
canContinue: false,
|
|
777
|
-
adjustingExisting: options.adjustingExisting === true,
|
|
778
2507
|
};
|
|
779
2508
|
this.#publish();
|
|
780
2509
|
}
|
|
@@ -784,8 +2513,9 @@ export class TuiController {
|
|
|
784
2513
|
return;
|
|
785
2514
|
this.#cancelInstallPlacementRequest();
|
|
786
2515
|
draft.rootScope = rootScope;
|
|
2516
|
+
draft.exactRootTargets = undefined;
|
|
2517
|
+
draft.dependencyScopeOverrides = draft.dependencyScopeOverrides.filter((override) => rootScope !== 'user' || override.scope === 'user');
|
|
787
2518
|
draft.platforms = [];
|
|
788
|
-
draft.plan = undefined;
|
|
789
2519
|
draft.targets = [];
|
|
790
2520
|
draft.state = 'selecting';
|
|
791
2521
|
draft.canContinue = false;
|
|
@@ -799,21 +2529,41 @@ export class TuiController {
|
|
|
799
2529
|
this.#cancelInstallPlacementRequest();
|
|
800
2530
|
const selected = [...new Set(platforms)].sort();
|
|
801
2531
|
draft.platforms = selected;
|
|
2532
|
+
draft.exactRootTargets = undefined;
|
|
802
2533
|
draft.dependencyScopeOverrides = draft.dependencyScopeOverrides.filter((override) => selected.includes(override.platform));
|
|
803
|
-
draft.plan = undefined;
|
|
804
2534
|
draft.targets = [];
|
|
805
2535
|
draft.state = 'selecting';
|
|
806
2536
|
draft.canContinue = selected.length > 0;
|
|
807
2537
|
draft.error = undefined;
|
|
808
2538
|
this.#publish();
|
|
809
2539
|
}
|
|
2540
|
+
setInstallRootTargets(targets) {
|
|
2541
|
+
const draft = this.#installPlacementDraft;
|
|
2542
|
+
if (!draft)
|
|
2543
|
+
return;
|
|
2544
|
+
const selected = canonicalBatchTargets(structuredClone(targets));
|
|
2545
|
+
if (selected.length === 0 || selected.some((target) => target.pluginId !== draft.pluginId)
|
|
2546
|
+
|| new Set(selected.map((target) => target.platform)).size !== selected.length) {
|
|
2547
|
+
throw new TuiOperationBlockedError('installPlacementIncomplete', '请为每个所选平台确定一个根插件位置。');
|
|
2548
|
+
}
|
|
2549
|
+
this.#cancelInstallPlacementRequest();
|
|
2550
|
+
draft.exactRootTargets = selected;
|
|
2551
|
+
draft.rootScope = selected[0].scope;
|
|
2552
|
+
draft.platforms = selected.map((target) => target.platform);
|
|
2553
|
+
draft.dependencyScopeOverrides = draft.dependencyScopeOverrides.filter((override) => selected.some((target) => target.platform === override.platform
|
|
2554
|
+
&& (target.scope === 'project' || override.scope === 'user')));
|
|
2555
|
+
draft.targets = [];
|
|
2556
|
+
draft.state = 'selecting';
|
|
2557
|
+
draft.canContinue = true;
|
|
2558
|
+
draft.error = undefined;
|
|
2559
|
+
this.#publish();
|
|
2560
|
+
}
|
|
810
2561
|
#cancelInstallPlacementRequest() {
|
|
811
2562
|
const cancelled = this.#installPlacementRequestAbort !== undefined;
|
|
812
2563
|
this.#installPlacementRequestToken += 1;
|
|
813
2564
|
this.#installPlacementRequestAbort?.abort();
|
|
814
2565
|
this.#installPlacementRequestAbort = undefined;
|
|
815
2566
|
if (cancelled && this.#installPlacementDraft?.state === 'loading') {
|
|
816
|
-
this.#installPlacementDraft.plan = undefined;
|
|
817
2567
|
this.#installPlacementDraft.targets = [];
|
|
818
2568
|
this.#installPlacementDraft.state = 'selecting';
|
|
819
2569
|
this.#installPlacementDraft.canContinue = false;
|
|
@@ -825,6 +2575,16 @@ export class TuiController {
|
|
|
825
2575
|
if (!draft || draft.platforms.length === 0) {
|
|
826
2576
|
throw new TuiOperationBlockedError('installPlacementIncomplete', '请先明确选择目标平台。');
|
|
827
2577
|
}
|
|
2578
|
+
if (draft.exactRootTargets)
|
|
2579
|
+
return {
|
|
2580
|
+
kind: 'pluginWriteBatch',
|
|
2581
|
+
action: 'install',
|
|
2582
|
+
selection: { kind: 'targets', targets: structuredClone(draft.exactRootTargets) },
|
|
2583
|
+
platform: draft.platforms.length === 2 ? 'both' : draft.platforms[0],
|
|
2584
|
+
scope: draft.rootScope,
|
|
2585
|
+
...(draft.dependencyScopeOverrides.length > 0
|
|
2586
|
+
? { dependencyScopeOverrides: structuredClone(draft.dependencyScopeOverrides), saveDependencyScopeOverrides: true } : {}),
|
|
2587
|
+
};
|
|
828
2588
|
return {
|
|
829
2589
|
kind: 'pluginWrite',
|
|
830
2590
|
action: 'install',
|
|
@@ -832,12 +2592,12 @@ export class TuiController {
|
|
|
832
2592
|
platform: draft.platforms.length === 2 ? 'both' : draft.platforms[0],
|
|
833
2593
|
scope: draft.rootScope,
|
|
834
2594
|
...(draft.dependencyScopeOverrides.length > 0
|
|
835
|
-
? { dependencyScopeOverrides: draft.dependencyScopeOverrides }
|
|
2595
|
+
? { dependencyScopeOverrides: draft.dependencyScopeOverrides, saveDependencyScopeOverrides: true }
|
|
836
2596
|
: {}),
|
|
837
|
-
...(draft.adjustingExisting ? { dependencyPlacementAdjustment: true } : {}),
|
|
838
2597
|
};
|
|
839
2598
|
}
|
|
840
2599
|
async prepareInstallDependencyPlacement() {
|
|
2600
|
+
this.#assertAcceptingActions();
|
|
841
2601
|
const draft = this.#installPlacementDraft;
|
|
842
2602
|
if (!draft)
|
|
843
2603
|
throw new TuiOperationBlockedError('installPlacementMissing', '安装位置草稿不存在。');
|
|
@@ -859,19 +2619,22 @@ export class TuiController {
|
|
|
859
2619
|
throw new DOMException('Dependency placement preview was cancelled.', 'AbortError');
|
|
860
2620
|
}
|
|
861
2621
|
};
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
draft.
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
2622
|
+
const placementIntent = this.#installPlacementIntent();
|
|
2623
|
+
const intents = placementIntent.kind === 'pluginWrite'
|
|
2624
|
+
? [placementIntent]
|
|
2625
|
+
: (draft.exactRootTargets ?? []).map((target) => ({
|
|
2626
|
+
kind: 'pluginWrite', action: 'install', ...target,
|
|
2627
|
+
dependencyScopeOverrides: draft.dependencyScopeOverrides.filter((override) => override.platform === target.platform),
|
|
2628
|
+
}));
|
|
2629
|
+
const plans = [];
|
|
2630
|
+
for (const intent of intents) {
|
|
2631
|
+
const plan = await this.#trackRead(preview(intent));
|
|
2632
|
+
throwIfCancelled();
|
|
2633
|
+
if (plan)
|
|
2634
|
+
plans.push(plan);
|
|
871
2635
|
}
|
|
872
|
-
draft.
|
|
873
|
-
|
|
874
|
-
const blocker = plan.targets.find((target) => target.action === 'block');
|
|
2636
|
+
draft.targets = plans.flatMap(dependencyPlacementTargets);
|
|
2637
|
+
const blocker = plans.flatMap((plan) => plan.targets).find((target) => target.action === 'block');
|
|
875
2638
|
draft.state = blocker ? 'blocked' : 'ready';
|
|
876
2639
|
draft.canContinue = !blocker;
|
|
877
2640
|
draft.error = blocker
|
|
@@ -881,7 +2644,10 @@ export class TuiController {
|
|
|
881
2644
|
}
|
|
882
2645
|
: undefined;
|
|
883
2646
|
this.#publish();
|
|
884
|
-
|
|
2647
|
+
const editableDependencies = draft.targets.filter((target) => !target.locked);
|
|
2648
|
+
return editableDependencies.some((target) => draft.targets.some((candidate) => candidate.pluginId === target.pluginId
|
|
2649
|
+
&& candidate.platform !== target.platform
|
|
2650
|
+
&& candidate.scope !== target.scope));
|
|
885
2651
|
}
|
|
886
2652
|
catch (error) {
|
|
887
2653
|
if (error instanceof Error && error.name === 'AbortError')
|
|
@@ -924,20 +2690,265 @@ export class TuiController {
|
|
|
924
2690
|
}
|
|
925
2691
|
listPlugins(options) {
|
|
926
2692
|
const query = options.query?.trim().toLocaleLowerCase('en');
|
|
2693
|
+
const actualScopes = new Map();
|
|
2694
|
+
const portableObservedScopes = new Set();
|
|
2695
|
+
const uncertainPortablePlugins = new Set();
|
|
2696
|
+
const statusTargets = flattenStatusTargets(this.#status?.payload.targets ?? []);
|
|
2697
|
+
const targetsByPlugin = new Map();
|
|
2698
|
+
for (const target of statusTargets) {
|
|
2699
|
+
targetsByPlugin.set(target.pluginId, [...(targetsByPlugin.get(target.pluginId) ?? []), target]);
|
|
2700
|
+
const owned = target.platform === 'claude'
|
|
2701
|
+
? ['present', 'partial'].includes(statusTargetOwnershipState(target))
|
|
2702
|
+
: target.components.some((component) => component.kind === 'ownership'
|
|
2703
|
+
&& component.key !== 'native'
|
|
2704
|
+
&& !component.key.startsWith('activation-')
|
|
2705
|
+
&& !component.key.startsWith('marketplace-')
|
|
2706
|
+
&& (component.state === 'present' || component.state === 'partial'));
|
|
2707
|
+
const activation = target.platform === 'codex' ? statusTargetActivation(target) : undefined;
|
|
2708
|
+
if (!owned && !(activation?.evidence === 'observed'
|
|
2709
|
+
&& activation[target.scope] === true)
|
|
2710
|
+
&& !hasStatusInstallationEvidence(target))
|
|
2711
|
+
continue;
|
|
2712
|
+
const scopes = actualScopes.get(target.pluginId) ?? new Set();
|
|
2713
|
+
scopes.add(target.scope);
|
|
2714
|
+
actualScopes.set(target.pluginId, scopes);
|
|
2715
|
+
}
|
|
2716
|
+
for (const inventory of Object.values(this.#scopedInventories)) {
|
|
2717
|
+
if (inventory.coverage?.portable) {
|
|
2718
|
+
for (const scope of inventory.coverage.scopes ?? [inventory.scope])
|
|
2719
|
+
portableObservedScopes.add(scope);
|
|
2720
|
+
}
|
|
2721
|
+
for (const root of [...inventory.declaredRoots, ...inventory.extraInstalledRoots]) {
|
|
2722
|
+
for (const plugin of [root, ...root.dependencies]) {
|
|
2723
|
+
for (const target of plugin.targets) {
|
|
2724
|
+
if (target.delivery !== 'agent-skills')
|
|
2725
|
+
continue;
|
|
2726
|
+
if (target.actual !== true) {
|
|
2727
|
+
if (target.observation !== 'known')
|
|
2728
|
+
uncertainPortablePlugins.add(plugin.pluginId);
|
|
2729
|
+
continue;
|
|
2730
|
+
}
|
|
2731
|
+
const scopes = actualScopes.get(plugin.pluginId) ?? new Set();
|
|
2732
|
+
scopes.add(target.scope);
|
|
2733
|
+
actualScopes.set(plugin.pluginId, scopes);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
const portableAbsenceObserved = portableObservedScopes.has('user')
|
|
2739
|
+
&& (!this.#status?.projectRoot || portableObservedScopes.has('project'));
|
|
927
2740
|
return cloneFrozen((this.#viewModel?.plugins ?? []).filter((plugin) => (!options.sourceId || plugin.sourceId === options.sourceId)
|
|
928
|
-
&& (options.
|
|
929
|
-
|
|
2741
|
+
&& (options.installFilter !== 'installed'
|
|
2742
|
+
|| (actualScopes.get(plugin.pluginId)?.size ?? 0) > 0)
|
|
2743
|
+
&& (options.installFilter !== 'uninstalled'
|
|
2744
|
+
|| plugin.aggregateStatus === 'available'
|
|
2745
|
+
&& ((targetsByPlugin.get(plugin.pluginId)?.length ?? 0) > 0
|
|
2746
|
+
|| plugin.portableSkills && portableAbsenceObserved)
|
|
2747
|
+
&& (targetsByPlugin.get(plugin.pluginId) ?? []).every((target) => target.state === 'absent')
|
|
2748
|
+
&& !uncertainPortablePlugins.has(plugin.pluginId)
|
|
2749
|
+
&& (actualScopes.get(plugin.pluginId)?.size ?? 0) === 0)
|
|
2750
|
+
&& (options.installFilter !== 'project'
|
|
2751
|
+
|| actualScopes.get(plugin.pluginId)?.has('project') === true)
|
|
2752
|
+
&& (options.installFilter !== 'user'
|
|
2753
|
+
|| actualScopes.get(plugin.pluginId)?.has('user') === true)
|
|
2754
|
+
&& (options.installFilter !== 'updateAvailable' || plugin.update?.state === 'available')
|
|
2755
|
+
&& (options.installFilter !== 'attention'
|
|
2756
|
+
|| plugin.aggregateStatus === 'needsAttention' || plugin.aggregateStatus === 'unavailable'
|
|
2757
|
+
|| plugin.primaryAttention !== undefined || plugin.sourceUnavailable === true
|
|
2758
|
+
|| plugin.capabilityUnsupported === true)
|
|
930
2759
|
&& (!query || `${plugin.displayName}\n${plugin.description}\n${plugin.sourceId}`.toLocaleLowerCase('en').includes(query))));
|
|
931
2760
|
}
|
|
932
2761
|
getPluginOverview(pluginId) {
|
|
933
2762
|
const plugin = this.#viewModel?.plugins.find((entry) => entry.pluginId === pluginId);
|
|
934
2763
|
return plugin ? cloneFrozen(plugin) : undefined;
|
|
935
2764
|
}
|
|
2765
|
+
getPluginDetailSubject(pluginId) {
|
|
2766
|
+
if (!this.#status || !this.#viewModel)
|
|
2767
|
+
return undefined;
|
|
2768
|
+
const subject = buildPluginDetailSubject({
|
|
2769
|
+
pluginId,
|
|
2770
|
+
status: this.#status.payload,
|
|
2771
|
+
pluginSummaries: this.#status.pluginSummaries,
|
|
2772
|
+
targetRevisions: this.#status.targetRevisions,
|
|
2773
|
+
plugins: this.#viewModel.plugins,
|
|
2774
|
+
scopedInventories: this.#scopedInventories,
|
|
2775
|
+
currentScopes: ['user', 'project'].filter((scope) => this.#status.scopedRecovery?.[scope] !== undefined),
|
|
2776
|
+
dependencyObservations: { user: this.#status.scopedRecovery?.user?.dependencyOverviews,
|
|
2777
|
+
project: this.#status.scopedRecovery?.project?.dependencyOverviews },
|
|
2778
|
+
latestScope: this.#lastRefreshedScope,
|
|
2779
|
+
dependencyOverviews: this.#status.dependencyOverviews,
|
|
2780
|
+
});
|
|
2781
|
+
return subject ? cloneFrozen(subject) : undefined;
|
|
2782
|
+
}
|
|
2783
|
+
getPluginContentOverview(pluginId) {
|
|
2784
|
+
const overview = this.#viewModel?.contentOverviews[pluginId];
|
|
2785
|
+
return overview ? cloneFrozen(overview) : undefined;
|
|
2786
|
+
}
|
|
2787
|
+
getPluginContentState(pluginId) {
|
|
2788
|
+
if (this.#viewModel?.contentOverviews[pluginId])
|
|
2789
|
+
return 'ready';
|
|
2790
|
+
return this.#pluginContentInflight.has(pluginId) ? 'loading' : 'idle';
|
|
2791
|
+
}
|
|
2792
|
+
loadPluginContent(pluginId) {
|
|
2793
|
+
if (this.#viewModel?.contentOverviews[pluginId])
|
|
2794
|
+
return Promise.resolve();
|
|
2795
|
+
const current = this.#pluginContentInflight.get(pluginId);
|
|
2796
|
+
if (current)
|
|
2797
|
+
return current;
|
|
2798
|
+
const loader = this.dependencies.loadPluginContent;
|
|
2799
|
+
if (!loader)
|
|
2800
|
+
return Promise.resolve();
|
|
2801
|
+
const generation = this.#generation;
|
|
2802
|
+
const contentEpoch = this.#pluginContentEpoch;
|
|
2803
|
+
const promise = this.#trackRead(loader(pluginId, this.#abort.signal))
|
|
2804
|
+
.then((overview) => {
|
|
2805
|
+
if (this.#disposed || generation !== this.#generation
|
|
2806
|
+
|| contentEpoch !== this.#pluginContentEpoch)
|
|
2807
|
+
return;
|
|
2808
|
+
this.#pluginContent.set(pluginId, structuredClone(overview));
|
|
2809
|
+
this.#project();
|
|
2810
|
+
})
|
|
2811
|
+
.catch(() => {
|
|
2812
|
+
if (this.#disposed || generation !== this.#generation
|
|
2813
|
+
|| contentEpoch !== this.#pluginContentEpoch)
|
|
2814
|
+
return;
|
|
2815
|
+
this.#pluginContent.set(pluginId, {
|
|
2816
|
+
pluginId,
|
|
2817
|
+
pluginVersion: '待确认',
|
|
2818
|
+
catalogVersion: '待确认',
|
|
2819
|
+
evidence: 'unavailable',
|
|
2820
|
+
coverage: 'unavailable',
|
|
2821
|
+
coverageIssue: {
|
|
2822
|
+
code: 'unreadable', message: '当前无法安全读取这个插件的内容。',
|
|
2823
|
+
},
|
|
2824
|
+
items: [],
|
|
2825
|
+
notices: ['当前无法安全读取这个插件的内容。'],
|
|
2826
|
+
});
|
|
2827
|
+
this.#project();
|
|
2828
|
+
})
|
|
2829
|
+
.finally(() => {
|
|
2830
|
+
if (this.#pluginContentInflight.get(pluginId) !== promise)
|
|
2831
|
+
return;
|
|
2832
|
+
this.#pluginContentInflight.delete(pluginId);
|
|
2833
|
+
this.#publish();
|
|
2834
|
+
});
|
|
2835
|
+
this.#pluginContentInflight.set(pluginId, promise);
|
|
2836
|
+
this.#publish();
|
|
2837
|
+
return promise;
|
|
2838
|
+
}
|
|
2839
|
+
getPluginSourceIdentity(pluginId) {
|
|
2840
|
+
return flattenStatusTargets(this.#status?.payload.targets ?? []).find((target) => target.pluginId === pluginId)?.sourceIdentity;
|
|
2841
|
+
}
|
|
2842
|
+
listCurrentProjectIntentRoots() {
|
|
2843
|
+
return cloneFrozen([...new Set(flattenStatusTargets(this.#status?.payload.targets ?? []).flatMap((target) => {
|
|
2844
|
+
const intent = statusTargetIntent(target);
|
|
2845
|
+
return intent.relation === 'root' && intent.scopes.includes('project')
|
|
2846
|
+
? [target.pluginId] : [];
|
|
2847
|
+
}))].sort((left, right) => left.localeCompare(right, 'en')));
|
|
2848
|
+
}
|
|
2849
|
+
listPluginWriteBatchTargets(action, pluginIds) {
|
|
2850
|
+
const targets = pluginWriteBatchTargets(action, pluginIds, flattenStatusTargets(this.#status?.payload.targets ?? []));
|
|
2851
|
+
if (action === 'cleanup') {
|
|
2852
|
+
for (const plugin of this.#viewModel?.plugins ?? []) {
|
|
2853
|
+
if (!pluginIds.includes(plugin.pluginId) || !plugin.configOnly
|
|
2854
|
+
|| targets.some((target) => target.pluginId === plugin.pluginId))
|
|
2855
|
+
continue;
|
|
2856
|
+
targets.push({
|
|
2857
|
+
pluginId: plugin.pluginId,
|
|
2858
|
+
platform: 'codex',
|
|
2859
|
+
scope: plugin.savedConfigScopes[0] ?? 'user',
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return cloneFrozen(targets);
|
|
2864
|
+
}
|
|
2865
|
+
listPluginInstallBatchTargets(pluginIds, platform, scope) {
|
|
2866
|
+
const platforms = platform === 'both' ? ['codex', 'claude'] : [platform];
|
|
2867
|
+
return cloneFrozen([...new Set(pluginIds)].flatMap((pluginId) => {
|
|
2868
|
+
const plugin = this.#viewModel?.plugins.find((entry) => entry.pluginId === pluginId);
|
|
2869
|
+
return platforms.map((targetPlatform) => {
|
|
2870
|
+
const target = { pluginId, platform: targetPlatform, scope };
|
|
2871
|
+
const statusTargets = flattenStatusTargets(this.#status?.payload.targets ?? []).filter((entry) => entry.pluginId === pluginId && entry.platform === targetPlatform);
|
|
2872
|
+
const exactTarget = statusTargets.find((entry) => entry.scope === scope);
|
|
2873
|
+
const alreadyConfigured = statusTargets.some((entry) => {
|
|
2874
|
+
const activation = statusTargetActivation(entry);
|
|
2875
|
+
return statusTargetIntent(entry).scopes.includes(scope)
|
|
2876
|
+
|| (targetPlatform === 'codex'
|
|
2877
|
+
&& activation?.evidence === 'observed'
|
|
2878
|
+
&& activation[scope] === true);
|
|
2879
|
+
});
|
|
2880
|
+
const exactOwnership = exactTarget ? statusTargetOwnershipState(exactTarget) : 'absent';
|
|
2881
|
+
const existingOutput = targetPlatform === 'codex'
|
|
2882
|
+
? exactTarget !== undefined && hasScopedExtensionOwnership(exactTarget)
|
|
2883
|
+
: exactOwnership === 'present' || exactOwnership === 'partial';
|
|
2884
|
+
if (plugin?.catalogEntryMissing) {
|
|
2885
|
+
return { ...target, state: 'blocked', reason: '来源中没有可信插件定义' };
|
|
2886
|
+
}
|
|
2887
|
+
if (alreadyConfigured || existingOutput) {
|
|
2888
|
+
return { ...target, state: 'existing' };
|
|
2889
|
+
}
|
|
2890
|
+
if (!plugin)
|
|
2891
|
+
return { ...target, state: 'blocked', reason: '插件已不在当前状态中' };
|
|
2892
|
+
if (plugin.sourceUnavailable) {
|
|
2893
|
+
return { ...target, state: 'blocked', reason: '插件来源不可用' };
|
|
2894
|
+
}
|
|
2895
|
+
if (plugin.capabilityUnsupported) {
|
|
2896
|
+
return { ...target, state: 'blocked', reason: '当前 AW CLI 不支持插件所需功能' };
|
|
2897
|
+
}
|
|
2898
|
+
const option = this.listInstallTargets(pluginId, scope)
|
|
2899
|
+
.find((entry) => entry.platform === targetPlatform);
|
|
2900
|
+
if (!option?.compatible) {
|
|
2901
|
+
return { ...target, state: 'blocked', reason: option?.disabled ?? '插件不支持所选工具或位置' };
|
|
2902
|
+
}
|
|
2903
|
+
const representativeTarget = exactTarget
|
|
2904
|
+
?? (targetPlatform === 'codex' ? statusTargets[0] : undefined);
|
|
2905
|
+
const uncertainObservation = (representativeTarget
|
|
2906
|
+
&& statusTargetActivation(representativeTarget)?.evidence === 'unobserved')
|
|
2907
|
+
|| statusTargets.some((entry) => statusTargetSharedNative(entry)?.state === 'unobserved');
|
|
2908
|
+
if (uncertainObservation) {
|
|
2909
|
+
return { ...target, state: 'blocked', reason: '无法确认所选位置是否缺失' };
|
|
2910
|
+
}
|
|
2911
|
+
if (!representativeTarget || representativeTarget.state === 'blocked') {
|
|
2912
|
+
return {
|
|
2913
|
+
...target,
|
|
2914
|
+
state: 'blocked',
|
|
2915
|
+
reason: representativeTarget?.reasons.find((reason) => reason.severity === 'blocking')?.message
|
|
2916
|
+
?? '无法确认所选位置是否缺失',
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
if (targetPlatform === 'codex') {
|
|
2920
|
+
const intent = statusTargetIntent(representativeTarget);
|
|
2921
|
+
const activation = statusTargetActivation(representativeTarget);
|
|
2922
|
+
const confirmedMissing = activation?.evidence === 'observed' && activation[scope] === false
|
|
2923
|
+
|| intent.enabled && !intent.scopes.includes(scope)
|
|
2924
|
+
|| representativeTarget.state === 'absent'
|
|
2925
|
+
&& !hasScopedExtensionOwnership(representativeTarget)
|
|
2926
|
+
&& !intent.enabled;
|
|
2927
|
+
if (!confirmedMissing) {
|
|
2928
|
+
return { ...target, state: 'blocked', reason: '无法确认所选位置是否缺失' };
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
else if (representativeTarget.state !== 'absent') {
|
|
2932
|
+
return { ...target, state: 'blocked', reason: '无法确认所选位置是否缺失' };
|
|
2933
|
+
}
|
|
2934
|
+
return { ...target, state: 'add' };
|
|
2935
|
+
});
|
|
2936
|
+
}).sort((left, right) => [left.pluginId, left.platform, left.scope].join('\0')
|
|
2937
|
+
.localeCompare([right.pluginId, right.platform, right.scope].join('\0'), 'en')));
|
|
2938
|
+
}
|
|
2939
|
+
pluginHasInstallableTarget(pluginId) {
|
|
2940
|
+
return ['project', 'user'].some((scope) => this.listPluginInstallBatchTargets([pluginId], 'both', scope)
|
|
2941
|
+
.some((target) => target.state === 'add'));
|
|
2942
|
+
}
|
|
936
2943
|
getPluginDependencyOverview(pluginId) {
|
|
937
2944
|
const overview = this.#viewModel?.dependencyOverviews.find((entry) => entry.pluginId === pluginId);
|
|
938
2945
|
return overview ? cloneFrozen(overview) : undefined;
|
|
939
2946
|
}
|
|
2947
|
+
listPluginDependencyOverviews() {
|
|
2948
|
+
return cloneFrozen(this.#viewModel?.dependencyOverviews ?? []);
|
|
2949
|
+
}
|
|
940
2950
|
getBlockingDependents(pluginId, platform, scope) {
|
|
2951
|
+
const statusTargets = flattenStatusTargets(this.#status?.payload.targets ?? []);
|
|
941
2952
|
const dependents = this.#viewModel?.dependencyOverviews.find((entry) => entry.pluginId === pluginId)?.dependents ?? [];
|
|
942
2953
|
return cloneFrozen(dependents.flatMap((dependent) => {
|
|
943
2954
|
const references = (dependent.placementReferences ?? []).filter((reference) => reference.dependency.pluginId === pluginId
|
|
@@ -945,7 +2956,7 @@ export class TuiController {
|
|
|
945
2956
|
&& reference.dependency.scope === scope
|
|
946
2957
|
&& (scope === 'user' || reference.dependency.project === 'current')
|
|
947
2958
|
&& (reference.consumer.project === 'other'
|
|
948
|
-
||
|
|
2959
|
+
|| statusTargets.find((target) => target.pluginId === reference.consumer.pluginId
|
|
949
2960
|
&& target.platform === reference.consumer.platform
|
|
950
2961
|
&& target.scope === reference.consumer.scope)?.state !== 'absent'));
|
|
951
2962
|
return references.length > 0 ? [{ ...dependent, placementReferences: references }] : [];
|
|
@@ -958,6 +2969,11 @@ export class TuiController {
|
|
|
958
2969
|
const plugin = this.#viewModel?.plugins.find((entry) => entry.pluginId === pluginId);
|
|
959
2970
|
if (!plugin)
|
|
960
2971
|
return [];
|
|
2972
|
+
if (plugin.catalogEntryMissing) {
|
|
2973
|
+
return plugin.supportedPlatforms.map((platform) => ({
|
|
2974
|
+
platform, compatible: false, disabled: '来源中没有可信插件定义',
|
|
2975
|
+
}));
|
|
2976
|
+
}
|
|
961
2977
|
if (plugin.aggregateStatus === 'unavailable') {
|
|
962
2978
|
return plugin.supportedPlatforms.map((platform) => ({
|
|
963
2979
|
platform,
|
|
@@ -966,7 +2982,8 @@ export class TuiController {
|
|
|
966
2982
|
}));
|
|
967
2983
|
}
|
|
968
2984
|
return plugin.supportedPlatforms.map((platform) => {
|
|
969
|
-
const
|
|
2985
|
+
const allStatusTargets = flattenStatusTargets(this.#status?.payload.targets ?? []);
|
|
2986
|
+
const platformTargets = allStatusTargets.filter((target) => target.pluginId === pluginId && target.platform === platform) ?? [];
|
|
970
2987
|
const rootSummary = this.#status?.pluginSummaries.find((summary) => summary.pluginId === pluginId);
|
|
971
2988
|
const rootSupportedScopes = rootSummary?.supportedTargets?.[platform]
|
|
972
2989
|
?? platformTargets.filter((target) => !target.reasons.some((error) => error.code === 'unsupportedTarget')).map((target) => target.scope);
|
|
@@ -982,7 +2999,7 @@ export class TuiController {
|
|
|
982
2999
|
for (const dependency of overview?.dependencies ?? []) {
|
|
983
3000
|
const dependencySummary = this.#status?.pluginSummaries.find((summary) => summary.pluginId === dependency.pluginId);
|
|
984
3001
|
const allowedScopes = dependencySummary?.supportedTargets?.[platform]
|
|
985
|
-
?? (
|
|
3002
|
+
?? (allStatusTargets.filter((target) => target.pluginId === dependency.pluginId
|
|
986
3003
|
&& target.platform === platform
|
|
987
3004
|
&& !target.reasons.some((error) => error.code === 'unsupportedTarget'))
|
|
988
3005
|
.map((target) => target.scope) ?? []);
|
|
@@ -995,7 +3012,7 @@ export class TuiController {
|
|
|
995
3012
|
};
|
|
996
3013
|
}
|
|
997
3014
|
const collisionAtEveryViableScope = viableScopes.every((candidateScope) => {
|
|
998
|
-
const target =
|
|
3015
|
+
const target = allStatusTargets.find((entry) => entry.pluginId === dependency.pluginId
|
|
999
3016
|
&& entry.platform === platform
|
|
1000
3017
|
&& entry.scope === candidateScope);
|
|
1001
3018
|
return Boolean(target && targetHasArtifactCollision(target));
|
|
@@ -1012,7 +3029,7 @@ export class TuiController {
|
|
|
1012
3029
|
});
|
|
1013
3030
|
}
|
|
1014
3031
|
getTargetState(pluginId, platform, scope) {
|
|
1015
|
-
return this.#status?.payload.targets.find((target) => target.pluginId === pluginId
|
|
3032
|
+
return flattenStatusTargets(this.#status?.payload.targets ?? []).find((target) => target.pluginId === pluginId
|
|
1016
3033
|
&& target.platform === platform
|
|
1017
3034
|
&& target.scope === scope)?.state;
|
|
1018
3035
|
}
|
|
@@ -1026,6 +3043,10 @@ export class TuiController {
|
|
|
1026
3043
|
health: this.#health.get(sourceId),
|
|
1027
3044
|
});
|
|
1028
3045
|
}
|
|
3046
|
+
getConfiguredSource(sourceId) {
|
|
3047
|
+
const source = this.#status?.configuredSources?.find((candidate) => candidate.id === sourceId);
|
|
3048
|
+
return source ? cloneFrozen(source) : undefined;
|
|
3049
|
+
}
|
|
1029
3050
|
getCatalogGeneration(sourceId) {
|
|
1030
3051
|
const source = this.#catalogGenerations.get(sourceId);
|
|
1031
3052
|
return source ? cloneFrozen(source) : undefined;
|
|
@@ -1035,17 +3056,141 @@ export class TuiController {
|
|
|
1035
3056
|
return freshness ? cloneFrozen(freshness) : undefined;
|
|
1036
3057
|
}
|
|
1037
3058
|
recheckCatalogSource(sourceId) {
|
|
1038
|
-
|
|
3059
|
+
this.#assertAcceptingActions();
|
|
3060
|
+
return this.#catalogSourcesSession.refresh(sourceId, this.#sourceCheckNeedsFullValidation(sourceId));
|
|
3061
|
+
}
|
|
3062
|
+
#sourceCheckNeedsFullValidation(sourceId) {
|
|
3063
|
+
const generation = this.#catalogGenerations.get(sourceId);
|
|
3064
|
+
const freshness = this.#catalogFreshness.get(sourceId);
|
|
3065
|
+
const activeReady = generation?.state === 'ready';
|
|
3066
|
+
return !activeReady
|
|
3067
|
+
|| freshness?.state === 'incompatible'
|
|
3068
|
+
|| freshness?.state === 'versionConflict'
|
|
3069
|
+
|| freshness?.state === 'rollbackDetected';
|
|
3070
|
+
}
|
|
3071
|
+
async recheckAllCatalogSources() {
|
|
3072
|
+
this.#assertAcceptingActions();
|
|
3073
|
+
const sourceIds = [...this.listSources()]
|
|
3074
|
+
.sort((left, right) => Number(Boolean(right.primary)) - Number(Boolean(left.primary)))
|
|
3075
|
+
.map((source) => source.id);
|
|
3076
|
+
let next = 0;
|
|
3077
|
+
const worker = async () => {
|
|
3078
|
+
while (next < sourceIds.length) {
|
|
3079
|
+
const sourceId = sourceIds[next++];
|
|
3080
|
+
if (sourceId) {
|
|
3081
|
+
await this.#catalogSourcesSession.refresh(sourceId, this.#sourceCheckNeedsFullValidation(sourceId));
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
};
|
|
3085
|
+
await Promise.all(Array.from({ length: Math.min(2, sourceIds.length) }, () => worker()));
|
|
1039
3086
|
}
|
|
1040
3087
|
fullValidateCatalogSource(sourceId) {
|
|
3088
|
+
this.#assertAcceptingActions();
|
|
1041
3089
|
return this.#catalogSourcesSession.fullValidate(sourceId);
|
|
1042
3090
|
}
|
|
1043
|
-
setExternalDraftState(
|
|
1044
|
-
|
|
3091
|
+
setExternalDraftState(states = []) {
|
|
3092
|
+
const priority = { sourceDraft: 0, batchDraft: 1, configDraft: 2 };
|
|
3093
|
+
this.#externalDrafts = structuredClone(states).sort((left, right) => priority[left.kind] - priority[right.kind] || left.owner.localeCompare(right.owner, 'en'));
|
|
3094
|
+
this.#publish();
|
|
3095
|
+
}
|
|
3096
|
+
beginPluginWriteBatch() {
|
|
3097
|
+
this.#assertAcceptingActions();
|
|
3098
|
+
this.#router.beginBatchFlow();
|
|
3099
|
+
this.#router.replace({ name: 'batchSelection' }, this.#router.snapshot.current.context);
|
|
3100
|
+
this.#publish();
|
|
3101
|
+
}
|
|
3102
|
+
startPluginWriteBatchReview(intent) {
|
|
3103
|
+
return this.startReviewPreparation(intent, intent.action === 'install'
|
|
3104
|
+
? { name: 'batchInstallScope' }
|
|
3105
|
+
: { name: 'batchPlacement' });
|
|
3106
|
+
}
|
|
3107
|
+
startPluginWriteTaskReview(intent, returnRoute) {
|
|
3108
|
+
return this.startReviewPreparation(intent, returnRoute);
|
|
3109
|
+
}
|
|
3110
|
+
beginNestedPluginWriteTask(route) {
|
|
3111
|
+
this.#assertAcceptingActions();
|
|
3112
|
+
const current = this.#router.snapshot.current.route;
|
|
3113
|
+
if (current.name !== 'pluginWriteTask') {
|
|
3114
|
+
throw new TuiOperationBlockedError('taskOriginUnavailable', '嵌套任务缺少父任务。');
|
|
3115
|
+
}
|
|
3116
|
+
this.#router.beginFlow('pluginWriteTask', current);
|
|
3117
|
+
this.#router.push(route);
|
|
3118
|
+
this.#publish();
|
|
3119
|
+
}
|
|
3120
|
+
pluginWriteTaskReturnRoute(route) {
|
|
3121
|
+
const active = this.#router.activeFlow();
|
|
3122
|
+
return structuredClone(active?.kind === 'pluginWriteTask'
|
|
3123
|
+
&& active.returnTarget.name === 'pluginWriteTask'
|
|
3124
|
+
? active.returnTarget
|
|
3125
|
+
: route);
|
|
3126
|
+
}
|
|
3127
|
+
returnToPluginWriteTaskBatchSelection(flowId) {
|
|
3128
|
+
this.#assertAcceptingActions();
|
|
3129
|
+
const route = this.#router.snapshot.current.route;
|
|
3130
|
+
if (route.name !== 'review'
|
|
3131
|
+
|| this.#activeReview?.operationId !== route.operationId
|
|
3132
|
+
|| this.#activeReview.operationKind !== 'pluginWriteTask')
|
|
3133
|
+
return false;
|
|
3134
|
+
const reviewToken = this.#activeReview.reviewToken;
|
|
3135
|
+
const returned = this.#router.returnToBatchSelection(flowId);
|
|
3136
|
+
if (!returned)
|
|
3137
|
+
return false;
|
|
3138
|
+
this.#cancelReviewPreparation();
|
|
3139
|
+
this.#tickets.delete(reviewToken);
|
|
3140
|
+
this.#activeReview = undefined;
|
|
3141
|
+
this.#publish();
|
|
3142
|
+
return true;
|
|
3143
|
+
}
|
|
3144
|
+
retryFailedPluginWriteBatch() {
|
|
3145
|
+
if (!this.#batchRetryIntent)
|
|
3146
|
+
return undefined;
|
|
3147
|
+
const intent = structuredClone(this.#batchRetryIntent);
|
|
3148
|
+
this.#batchRetryIntent = undefined;
|
|
3149
|
+
return this.startReviewPreparation(intent, { name: 'pluginList', mode: 'installed' });
|
|
3150
|
+
}
|
|
3151
|
+
retryFailedPluginWriteTask() {
|
|
3152
|
+
if (!this.#taskRetryIntent)
|
|
3153
|
+
return undefined;
|
|
3154
|
+
const intent = structuredClone(this.#taskRetryIntent);
|
|
3155
|
+
this.#taskRetryIntent = undefined;
|
|
3156
|
+
return this.startReviewPreparation(intent, { name: 'pluginList', mode: 'installed' });
|
|
1045
3157
|
}
|
|
1046
3158
|
catalogActivationBlockReason() {
|
|
1047
|
-
if (this.#
|
|
1048
|
-
return this.#
|
|
3159
|
+
if (this.#externalDrafts[0])
|
|
3160
|
+
return this.#externalDrafts[0].kind;
|
|
3161
|
+
if (this.#portableDraft)
|
|
3162
|
+
return 'portableDraft';
|
|
3163
|
+
if (this.#reviewPreparation)
|
|
3164
|
+
return 'reviewPreparation';
|
|
3165
|
+
if (this.#activeReview)
|
|
3166
|
+
return 'activeReview';
|
|
3167
|
+
if (this.#router.snapshot.current.route.name === 'progress'
|
|
3168
|
+
|| this.#inflightOperations.size > 0)
|
|
3169
|
+
return 'writeProgress';
|
|
3170
|
+
return undefined;
|
|
3171
|
+
}
|
|
3172
|
+
catalogSourceRecoveryBlockReason(intent) {
|
|
3173
|
+
const activeFlow = this.#router.activeFlow();
|
|
3174
|
+
const route = this.#router.snapshot.current.route;
|
|
3175
|
+
const ownedFrozenBatchTask = intent !== undefined
|
|
3176
|
+
&& route.name === 'pluginWriteTask'
|
|
3177
|
+
&& route.targetKeys !== undefined
|
|
3178
|
+
&& route.targetKeys.length > 0
|
|
3179
|
+
&& route.batchOrigin !== undefined
|
|
3180
|
+
&& (activeFlow?.id === route.batchOrigin.flowId
|
|
3181
|
+
|| activeFlow?.parentFlowId === route.batchOrigin.flowId)
|
|
3182
|
+
&& this.listPluginWriteTaskCandidates(route.goal).some((candidate) => candidate.sourceId === intent.sourceId
|
|
3183
|
+
&& candidate.blockReason === 'catalogActivationRequired'
|
|
3184
|
+
&& route.targetKeys.includes(pluginWriteTaskTargetKey(candidate.target)));
|
|
3185
|
+
const blockingExternalDraft = this.#externalDrafts.find((draft) => !(draft.kind === 'configDraft'
|
|
3186
|
+
&& activeFlow?.kind === 'sourceRecovery'
|
|
3187
|
+
&& activeFlow.parentFlowId !== undefined)
|
|
3188
|
+
&& !(ownedFrozenBatchTask
|
|
3189
|
+
&& draft.kind === 'batchDraft'
|
|
3190
|
+
&& draft.owner === route.batchOrigin?.owner
|
|
3191
|
+
&& draft.flowId === route.batchOrigin.flowId));
|
|
3192
|
+
if (blockingExternalDraft)
|
|
3193
|
+
return blockingExternalDraft.kind;
|
|
1049
3194
|
if (this.#portableDraft)
|
|
1050
3195
|
return 'portableDraft';
|
|
1051
3196
|
if (this.#reviewPreparation)
|
|
@@ -1061,14 +3206,17 @@ export class TuiController {
|
|
|
1061
3206
|
return this.#status?.payload.catalog.sources.find((source) => source.id === sourceId)?.catalogVersion;
|
|
1062
3207
|
}
|
|
1063
3208
|
async reloadCatalog(options) {
|
|
3209
|
+
this.#assertAcceptingActions();
|
|
1064
3210
|
if (this.catalogActivationBlockReason())
|
|
1065
3211
|
return false;
|
|
1066
|
-
this
|
|
3212
|
+
this.#beginCatalogSession();
|
|
1067
3213
|
const generation = ++this.#generation;
|
|
1068
3214
|
this.#phase = 'loading';
|
|
1069
3215
|
this.#publish();
|
|
3216
|
+
if (!this.#operationIsCurrent(generation))
|
|
3217
|
+
return false;
|
|
1070
3218
|
try {
|
|
1071
|
-
const status = await this.dependencies.loadStatus(this.#abort.signal);
|
|
3219
|
+
const status = await this.#trackRead(this.dependencies.loadStatus(this.#abort.signal));
|
|
1072
3220
|
if (this.#disposed || generation !== this.#generation)
|
|
1073
3221
|
return false;
|
|
1074
3222
|
this.#applyStatus(status);
|
|
@@ -1083,6 +3231,8 @@ export class TuiController {
|
|
|
1083
3231
|
return false;
|
|
1084
3232
|
const code = issueCode(error);
|
|
1085
3233
|
await this.#logErrorSafe(error, code);
|
|
3234
|
+
if (!this.#operationIsCurrent(generation))
|
|
3235
|
+
return false;
|
|
1086
3236
|
this.#phase = 'error';
|
|
1087
3237
|
this.#loadError = { code, message: '无法安全重新加载 Catalog。请检查诊断后重试。' };
|
|
1088
3238
|
this.#publish();
|
|
@@ -1090,58 +3240,202 @@ export class TuiController {
|
|
|
1090
3240
|
}
|
|
1091
3241
|
}
|
|
1092
3242
|
async inspectSourceRemoval(sourceId) {
|
|
3243
|
+
this.#assertAcceptingActions();
|
|
1093
3244
|
if (!this.dependencies.inspectSourceRemoval) {
|
|
1094
3245
|
throw new TuiOperationBlockedError('stateInventoryFailed', '来源引用清单不可用。');
|
|
1095
3246
|
}
|
|
1096
|
-
return cloneFrozen(await this.dependencies.inspectSourceRemoval(sourceId, this.#abort.signal));
|
|
3247
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.inspectSourceRemoval(sourceId, this.#abort.signal)));
|
|
3248
|
+
}
|
|
3249
|
+
async inspectCatalogStore() {
|
|
3250
|
+
this.#assertAcceptingActions();
|
|
3251
|
+
if (!this.dependencies.inspectCatalogStore) {
|
|
3252
|
+
throw new TuiOperationBlockedError('catalogStoreUnavailable', 'Catalog 本地存储检查不可用。');
|
|
3253
|
+
}
|
|
3254
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.inspectCatalogStore(this.#abort.signal)));
|
|
1097
3255
|
}
|
|
1098
|
-
async getConfigGroups(pluginId,
|
|
3256
|
+
async getConfigGroups(pluginId, options) {
|
|
3257
|
+
this.#assertAcceptingActions();
|
|
1099
3258
|
if (!this.dependencies.getConfigGroups) {
|
|
1100
3259
|
throw new TuiOperationBlockedError('configUnavailable', '设置读取入口不可用。');
|
|
1101
3260
|
}
|
|
1102
|
-
return cloneFrozen(await this.dependencies.getConfigGroups(pluginId, structuredClone(
|
|
3261
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.getConfigGroups(pluginId, structuredClone(options), this.#abort.signal)));
|
|
1103
3262
|
}
|
|
1104
|
-
async getConfigPage(pluginId,
|
|
3263
|
+
async getConfigPage(pluginId, options, signal) {
|
|
3264
|
+
this.#assertAcceptingActions();
|
|
1105
3265
|
if (!this.dependencies.getConfigPage) {
|
|
1106
3266
|
throw new TuiOperationBlockedError('configUnavailable', '设置读取入口不可用。');
|
|
1107
3267
|
}
|
|
1108
3268
|
const combined = signal
|
|
1109
3269
|
? AbortSignal.any([this.#abort.signal, signal])
|
|
1110
3270
|
: this.#abort.signal;
|
|
1111
|
-
return cloneFrozen(await this.dependencies.getConfigPage(pluginId, structuredClone(
|
|
3271
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.getConfigPage(pluginId, structuredClone(options), combined)));
|
|
3272
|
+
}
|
|
3273
|
+
async getConfigReferenceContext(pluginId, options, draft, signal) {
|
|
3274
|
+
this.#assertAcceptingActions();
|
|
3275
|
+
if (!this.dependencies.getConfigReferenceContext)
|
|
3276
|
+
return { selections: {} };
|
|
3277
|
+
const combined = signal ? AbortSignal.any([this.#abort.signal, signal]) : this.#abort.signal;
|
|
3278
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.getConfigReferenceContext(pluginId, structuredClone(options), structuredClone(draft), combined)));
|
|
3279
|
+
}
|
|
3280
|
+
async getConfigSuggestions(lookup, refresh, signal) {
|
|
3281
|
+
this.#assertAcceptingActions();
|
|
3282
|
+
if (!this.dependencies.getConfigSuggestions)
|
|
3283
|
+
return { schemaVersion: 2, status: 'unavailable', items: [] };
|
|
3284
|
+
const combined = AbortSignal.any([this.#abort.signal, signal]);
|
|
3285
|
+
const frameId = this.#router.snapshot.currentFrameId;
|
|
3286
|
+
const epoch = this.#sessionEpoch;
|
|
3287
|
+
const generation = this.#generation;
|
|
3288
|
+
const verifyRequest = () => {
|
|
3289
|
+
combined.throwIfAborted();
|
|
3290
|
+
if (generation !== this.#generation || epoch !== this.#sessionEpoch || frameId !== this.#router.snapshot.currentFrameId) {
|
|
3291
|
+
throw new DOMException('Config field changed', 'AbortError');
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
return this.#trackRead(this.dependencies.getConfigSuggestions(structuredClone(lookup), async (prepared) => {
|
|
3295
|
+
verifyRequest();
|
|
3296
|
+
const { kind, hint, sharedCacheKey, hintCacheKey } = prepared;
|
|
3297
|
+
const keys = kind === 'object' ? [sharedCacheKey, hintCacheKey] : [hint === undefined ? sharedCacheKey : hintCacheKey];
|
|
3298
|
+
if (refresh) {
|
|
3299
|
+
this.#configSuggestions.delete(sharedCacheKey);
|
|
3300
|
+
this.#configSuggestions.delete(hintCacheKey);
|
|
3301
|
+
}
|
|
3302
|
+
else {
|
|
3303
|
+
for (const key of keys) {
|
|
3304
|
+
const cached = this.#configSuggestions.get(key);
|
|
3305
|
+
if (!cached)
|
|
3306
|
+
continue;
|
|
3307
|
+
// Once a value is recognized as sensitive, keep it out of this shared cache entry.
|
|
3308
|
+
const redacted = cloneFrozen(prepared.project(cached, 'cache'));
|
|
3309
|
+
this.#configSuggestions.set(key, redacted);
|
|
3310
|
+
if (kind === 'object' && key === sharedCacheKey && !hasRecommendedHints(redacted))
|
|
3311
|
+
continue;
|
|
3312
|
+
return cloneFrozen(prepared.project(redacted));
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
const response = cloneFrozen(prepared.project(await prepared.run(combined), 'cache'));
|
|
3316
|
+
verifyRequest();
|
|
3317
|
+
if (response.status === 'ok') {
|
|
3318
|
+
const shared = kind === 'object' ? hasRecommendedHints(response) : hint === undefined;
|
|
3319
|
+
this.#configSuggestions.set(shared ? sharedCacheKey : hintCacheKey, response);
|
|
3320
|
+
}
|
|
3321
|
+
return cloneFrozen(prepared.project(response));
|
|
3322
|
+
}, combined));
|
|
3323
|
+
}
|
|
3324
|
+
async saveConfigDraft(request, signal) {
|
|
3325
|
+
this.#assertAcceptingActions();
|
|
3326
|
+
if (this.hasActiveWrite)
|
|
3327
|
+
throw new TuiOperationBlockedError('writeInProgress', '另一个写操作仍在执行。');
|
|
3328
|
+
if (request.apply || request.kind === 'configSave' && request.retryApply) {
|
|
3329
|
+
throw new TuiOperationBlockedError('configSaveOnlyRequired', '此入口只保存配置。请单独准备插件更新。');
|
|
3330
|
+
}
|
|
3331
|
+
const intent = normalizeOperationIntent(structuredClone(request));
|
|
3332
|
+
const combined = signal ? AbortSignal.any([this.#abort.signal, signal]) : this.#abort.signal;
|
|
3333
|
+
const promise = (async () => {
|
|
3334
|
+
try {
|
|
3335
|
+
this.#validateReviewIntent(intent);
|
|
3336
|
+
const evidence = await this.#prepareReviewEvidence(intent, combined);
|
|
3337
|
+
combined.throwIfAborted();
|
|
3338
|
+
const execution = await this.dependencies.executeIntent(intent, evidence, combined);
|
|
3339
|
+
if (intent.kind === 'configSaveBatch') {
|
|
3340
|
+
const batch = execution;
|
|
3341
|
+
const sensitiveValues = collectOperationSensitiveValues(intent);
|
|
3342
|
+
return {
|
|
3343
|
+
status: batch.status,
|
|
3344
|
+
savedProfiles: batch.groups.filter((group) => group.configSaved).map((group) => group.platform ?? 'common'),
|
|
3345
|
+
failedProfiles: batch.groups.filter((group) => !group.configSaved).map((group) => ({
|
|
3346
|
+
profile: group.platform ?? 'common',
|
|
3347
|
+
...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
|
|
3348
|
+
...(group.failureDetail ? { errorMessage: configSaveFailureMessage(group.failureDetail, sensitiveValues) } : {}),
|
|
3349
|
+
})),
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
const saved = typeof execution === 'object' && execution !== null
|
|
3353
|
+
&& execution.configWrite === 'succeeded';
|
|
3354
|
+
return { status: saved ? 'succeeded' : 'failed', savedProfiles: saved ? [intent.platform ?? 'common'] : [],
|
|
3355
|
+
failedProfiles: saved ? [] : [{ profile: intent.platform ?? 'common', errorCode: 'configWriteUnconfirmed' }] };
|
|
3356
|
+
}
|
|
3357
|
+
catch (error) {
|
|
3358
|
+
const code = safeDiagnosticCode(explicitIssueCode(error)
|
|
3359
|
+
?? (error && typeof error === 'object' && 'code' in error ? error.code : undefined), 'operationBlocked');
|
|
3360
|
+
await this.#logOperationError(error, code, intent);
|
|
3361
|
+
const detail = configSaveFailureDetail(error);
|
|
3362
|
+
throw new TuiOperationBlockedError(code, detail
|
|
3363
|
+
? configSaveFailureMessage(detail, collectOperationSensitiveValues(intent)) || code
|
|
3364
|
+
: code);
|
|
3365
|
+
}
|
|
3366
|
+
})();
|
|
3367
|
+
this.#configSaveInflight = promise;
|
|
3368
|
+
this.#publish();
|
|
3369
|
+
try {
|
|
3370
|
+
return cloneFrozen(await promise);
|
|
3371
|
+
}
|
|
3372
|
+
finally {
|
|
3373
|
+
if (this.#configSaveInflight === promise)
|
|
3374
|
+
this.#configSaveInflight = undefined;
|
|
3375
|
+
this.#publish();
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
async previewConfigSaveImpact(intent, signal) {
|
|
3379
|
+
this.#assertAcceptingActions();
|
|
3380
|
+
const normalized = normalizeOperationIntent(intent);
|
|
3381
|
+
this.#validateReviewIntent(normalized);
|
|
3382
|
+
const combined = signal
|
|
3383
|
+
? AbortSignal.any([this.#abort.signal, signal])
|
|
3384
|
+
: this.#abort.signal;
|
|
3385
|
+
const evidence = await this.#trackRead(this.#prepareReviewEvidence(normalized, combined));
|
|
3386
|
+
if (!evidence.config) {
|
|
3387
|
+
throw new TuiOperationBlockedError('configImpactUnavailable', '无法确定设置修改的应用影响。');
|
|
3388
|
+
}
|
|
3389
|
+
return cloneFrozen(evidence.config);
|
|
1112
3390
|
}
|
|
1113
|
-
async getConfigResetAvailability(pluginId,
|
|
3391
|
+
async getConfigResetAvailability(pluginId, options) {
|
|
3392
|
+
this.#assertAcceptingActions();
|
|
1114
3393
|
if (!this.dependencies.getConfigResetAvailability) {
|
|
1115
3394
|
throw new TuiOperationBlockedError('configResetVerificationUnavailable', '设置层可信读取入口不可用。');
|
|
1116
3395
|
}
|
|
1117
|
-
return cloneFrozen(await this.dependencies.getConfigResetAvailability(pluginId, structuredClone(
|
|
3396
|
+
return cloneFrozen(await this.#trackRead(this.dependencies.getConfigResetAvailability(pluginId, structuredClone(options), this.#abort.signal)));
|
|
1118
3397
|
}
|
|
1119
3398
|
listUserIssues() {
|
|
1120
3399
|
return cloneFrozen(this.#viewModel?.issues ?? []);
|
|
1121
3400
|
}
|
|
3401
|
+
listPluginWriteTaskCandidates(goal) {
|
|
3402
|
+
return cloneFrozen(this.#viewModel
|
|
3403
|
+
? buildPluginWriteTaskCandidates(this.#viewModel, goal)
|
|
3404
|
+
: []);
|
|
3405
|
+
}
|
|
1122
3406
|
async buildOperationReview(intent, returnRoute) {
|
|
3407
|
+
this.#assertAcceptingActions();
|
|
3408
|
+
intent = normalizeOperationIntent(intent);
|
|
1123
3409
|
try {
|
|
1124
3410
|
this.#validateReviewIntent(intent);
|
|
1125
|
-
const evidence = await this.#prepareReviewEvidence(intent, this.#abort.signal);
|
|
3411
|
+
const evidence = await this.#trackRead(this.#prepareReviewEvidence(intent, this.#abort.signal));
|
|
1126
3412
|
return this.#storeOperationReview(intent, evidence, 'push', returnRoute);
|
|
1127
3413
|
}
|
|
1128
3414
|
catch (error) {
|
|
1129
3415
|
const code = issueCode(error);
|
|
1130
3416
|
await this.#logOperationError(error, code, intent);
|
|
3417
|
+
if (error instanceof TuiOperationBlockedError && error.diagnostics?.length)
|
|
3418
|
+
throw error;
|
|
1131
3419
|
throw new TuiOperationBlockedError(code, code === 'catalogGenerationUnavailable'
|
|
1132
3420
|
? '本次加载时 Catalog 来源不可用。请刷新来源并重新加载后重试。'
|
|
1133
3421
|
: '操作未建立。请检查当前设置后重试。');
|
|
1134
3422
|
}
|
|
1135
3423
|
}
|
|
1136
3424
|
startReviewPreparation(intent, returnRoute) {
|
|
3425
|
+
this.#assertAcceptingActions();
|
|
3426
|
+
this.#completionNotice = undefined;
|
|
3427
|
+
intent = normalizeOperationIntent(intent);
|
|
1137
3428
|
if (intent.kind === 'catalogGeneration' && !intent.sourceMutation) {
|
|
1138
|
-
const blockReason = this.
|
|
3429
|
+
const blockReason = this.catalogSourceRecoveryBlockReason(intent);
|
|
1139
3430
|
if (blockReason) {
|
|
1140
3431
|
throw new TuiOperationBlockedError('catalogActivationBlocked', `Catalog Active 切换已阻止:${blockReason}。请先完成或放弃当前草稿或操作。`);
|
|
1141
3432
|
}
|
|
1142
3433
|
}
|
|
3434
|
+
this.#ensureOperationFlow(intent);
|
|
1143
3435
|
const inheritedReturnRoute = this.#reviewPreparation?.returnRoute;
|
|
1144
3436
|
const current = this.#router.snapshot.current.route;
|
|
3437
|
+
if (current.name === 'result')
|
|
3438
|
+
this.#invalidatePortableResultRecheck();
|
|
1145
3439
|
const navigation = current.name === 'result' || current.name === 'reviewPreparing'
|
|
1146
3440
|
? 'replace' : 'push';
|
|
1147
3441
|
const resolvedReturnRoute = returnRoute
|
|
@@ -1151,7 +3445,9 @@ export class TuiController {
|
|
|
1151
3445
|
? this.#result.returnRoute
|
|
1152
3446
|
: current);
|
|
1153
3447
|
const normalizedReturnRoute = this.#normalizeRoute(resolvedReturnRoute);
|
|
1154
|
-
const key =
|
|
3448
|
+
const key = crypto.createHash('sha256')
|
|
3449
|
+
.update(JSON.stringify(stableValue({ intent, returnRoute: normalizedReturnRoute })))
|
|
3450
|
+
.digest('hex');
|
|
1155
3451
|
if (this.#reviewPreparation?.snapshot.state === 'running'
|
|
1156
3452
|
&& this.#reviewPreparation.key === key) {
|
|
1157
3453
|
return cloneFrozen(this.#reviewPreparation.snapshot);
|
|
@@ -1162,14 +3458,16 @@ export class TuiController {
|
|
|
1162
3458
|
const token = ++this.#reviewPreparationToken;
|
|
1163
3459
|
const snapshot = {
|
|
1164
3460
|
id,
|
|
1165
|
-
|
|
3461
|
+
operationKind: intent.kind,
|
|
3462
|
+
subject: this.#reviewPreparationLabel(intent),
|
|
1166
3463
|
state: 'running',
|
|
1167
3464
|
stages: this.dependencies.prepareReviewEvidence ? [] : [
|
|
1168
3465
|
{ id: 'validate', label: '验证当前状态', state: 'running' },
|
|
1169
3466
|
{ id: 'evidence', label: '准备确认信息', state: 'pending' },
|
|
1170
3467
|
],
|
|
1171
|
-
|
|
3468
|
+
...(this.dependencies.prepareReviewEvidence ? {} : { currentStage: 'validate' }),
|
|
1172
3469
|
};
|
|
3470
|
+
this.#reviewPreparationIntents.set(id, structuredClone(intent));
|
|
1173
3471
|
this.#reviewPreparation = {
|
|
1174
3472
|
snapshot,
|
|
1175
3473
|
key,
|
|
@@ -1187,9 +3485,35 @@ export class TuiController {
|
|
|
1187
3485
|
const preparation = this.#reviewPreparation;
|
|
1188
3486
|
if (!preparation || preparation.snapshot.state !== 'failed')
|
|
1189
3487
|
return undefined;
|
|
1190
|
-
|
|
3488
|
+
const intent = this.#reviewPreparationIntents.get(preparation.snapshot.id);
|
|
3489
|
+
if (!intent)
|
|
3490
|
+
return undefined;
|
|
3491
|
+
return this.startReviewPreparation(structuredClone(intent), preparation.returnRoute);
|
|
1191
3492
|
}
|
|
1192
3493
|
#validateReviewIntent(intent) {
|
|
3494
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
3495
|
+
if (intent.targets.length === 0
|
|
3496
|
+
|| JSON.stringify(intent.targets) !== JSON.stringify(canonicalPluginWriteTaskTargets(intent.targets))) {
|
|
3497
|
+
throw new TuiOperationBlockedError('taskSelectionInvalid', '任务目标必须是非空精确目标集合。');
|
|
3498
|
+
}
|
|
3499
|
+
for (const target of intent.targets) {
|
|
3500
|
+
sourceIdFromPluginId(target.pluginId);
|
|
3501
|
+
if ((target.platform !== 'codex' && target.platform !== 'claude')
|
|
3502
|
+
|| (target.scope !== 'user' && target.scope !== 'project')
|
|
3503
|
+
|| (intent.goal === 'update') !== Boolean(target.expectedUpdate)) {
|
|
3504
|
+
throw new TuiOperationBlockedError('taskSelectionInvalid', '任务目标或版本证据无效。');
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
if (intent.kind === 'pluginWriteBatch') {
|
|
3509
|
+
if (intent.selection.kind === 'selected') {
|
|
3510
|
+
const canonical = canonicalPluginIds(intent.selection.pluginIds);
|
|
3511
|
+
if (canonical.length === 0) {
|
|
3512
|
+
throw new TuiOperationBlockedError('batchSelectionInvalid', '批量插件选择无效。');
|
|
3513
|
+
}
|
|
3514
|
+
canonical.forEach(sourceIdFromPluginId);
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
1193
3517
|
const primaryGeneration = intent.kind === 'sourceMutation' && intent.action === 'setPrimary'
|
|
1194
3518
|
? this.#catalogGenerations.get(intent.sourceId) : undefined;
|
|
1195
3519
|
if (primaryGeneration && !primaryGeneration.active && primaryGeneration.state !== 'ready') {
|
|
@@ -1199,6 +3523,15 @@ export class TuiController {
|
|
|
1199
3523
|
#reviewPreparationLabel(intent) {
|
|
1200
3524
|
if (intent.kind === 'catalogSourcesRecovery')
|
|
1201
3525
|
return 'Catalog 来源配置';
|
|
3526
|
+
if (intent.kind === 'catalogStorePrune')
|
|
3527
|
+
return 'Catalog 本地存储';
|
|
3528
|
+
if (intent.kind === 'pluginWriteTask')
|
|
3529
|
+
return `${intent.targets.length} 个安装位置`;
|
|
3530
|
+
if (intent.kind === 'pluginWriteBatch') {
|
|
3531
|
+
return intent.selection.kind === 'selected'
|
|
3532
|
+
? `${intent.selection.pluginIds.length} 个插件`
|
|
3533
|
+
: `${intent.selection.targets.length} 个目标`;
|
|
3534
|
+
}
|
|
1202
3535
|
if ('pluginId' in intent) {
|
|
1203
3536
|
return this.#viewModel?.plugins.find((plugin) => plugin.pluginId === intent.pluginId)?.displayName
|
|
1204
3537
|
?? pluginNameFromId(intent.pluginId);
|
|
@@ -1217,13 +3550,17 @@ export class TuiController {
|
|
|
1217
3550
|
const preparation = this.#reviewPreparation;
|
|
1218
3551
|
if (!preparation || preparation.token !== token)
|
|
1219
3552
|
return;
|
|
1220
|
-
const
|
|
3553
|
+
const storedIntent = this.#reviewPreparationIntents.get(preparation.snapshot.id);
|
|
3554
|
+
if (!storedIntent)
|
|
3555
|
+
return;
|
|
3556
|
+
const intent = structuredClone(storedIntent);
|
|
1221
3557
|
const signal = AbortSignal.any([this.#abort.signal, preparation.abort.signal]);
|
|
1222
3558
|
try {
|
|
1223
3559
|
this.#validateReviewIntent(intent);
|
|
1224
|
-
const evidence = await this.#prepareReviewEvidence(intent, signal, (stage) => {
|
|
3560
|
+
const evidence = await this.#trackRead(this.#prepareReviewEvidence(intent, signal, (stage) => {
|
|
1225
3561
|
if (!this.#reviewPreparationIsCurrent(token))
|
|
1226
3562
|
return;
|
|
3563
|
+
preparation.snapshot.currentStage = stage;
|
|
1227
3564
|
const existing = preparation.snapshot.stages.find((entry) => entry.id === stage);
|
|
1228
3565
|
preparation.snapshot.stages = preparation.snapshot.stages.map((entry) => entry.state === 'running' ? { ...entry, state: 'completed' } : entry);
|
|
1229
3566
|
if (existing) {
|
|
@@ -1237,14 +3574,16 @@ export class TuiController {
|
|
|
1237
3574
|
});
|
|
1238
3575
|
}
|
|
1239
3576
|
this.#publish();
|
|
1240
|
-
});
|
|
3577
|
+
}));
|
|
1241
3578
|
if (!this.#reviewPreparationIsCurrent(token))
|
|
1242
3579
|
return;
|
|
1243
3580
|
preparation.snapshot.stages = preparation.snapshot.stages.map((stage) => stage.state === 'running' ? { ...stage, state: 'completed' } : stage);
|
|
1244
3581
|
this.#publish();
|
|
1245
3582
|
const returnRoute = structuredClone(preparation.returnRoute);
|
|
1246
|
-
this.#reviewPreparation = undefined;
|
|
1247
3583
|
this.#storeOperationReview(intent, evidence, 'replace', returnRoute);
|
|
3584
|
+
this.#reviewPreparationIntents.delete(preparation.snapshot.id);
|
|
3585
|
+
this.#reviewPreparation = undefined;
|
|
3586
|
+
this.#publish();
|
|
1248
3587
|
}
|
|
1249
3588
|
catch (error) {
|
|
1250
3589
|
if (!this.#reviewPreparationIsCurrent(token))
|
|
@@ -1269,7 +3608,10 @@ export class TuiController {
|
|
|
1269
3608
|
: code === 'catalogGenerationActiveComparisonUnavailable'
|
|
1270
3609
|
? '损坏的当前 Active 无法提供可信版本,不能安全比较候选。当前 Active 保持不变。请明确编辑来源,或移除后重新添加。'
|
|
1271
3610
|
: code === 'catalogReplaceDamagedRequired'
|
|
1272
|
-
?
|
|
3611
|
+
? intent.kind === 'catalogGeneration'
|
|
3612
|
+
&& this.#catalogFreshness.get(intent.sourceId)?.state === 'incompatible'
|
|
3613
|
+
? '无法重新取得或精确匹配旧 Active,且当前候选与此 AW 不兼容。当前 Active 保持不变。请升级 AW 或修改来源。'
|
|
3614
|
+
: '无法重新取得或精确匹配旧 Active。当前 Active 保持不变。请返回并选择“使用当前候选替换损坏的 Active”。'
|
|
1273
3615
|
: code === 'catalogVersionConflict'
|
|
1274
3616
|
? '候选 Catalog 与当前 Active 版本相同,但内容摘要不同。普通更新已阻止。'
|
|
1275
3617
|
: code === 'catalogRollbackDetected'
|
|
@@ -1277,6 +3619,57 @@ export class TuiController {
|
|
|
1277
3619
|
: code === 'catalogGenerationUnavailable'
|
|
1278
3620
|
? '本次加载时 Catalog 来源不可用。请刷新来源并重新加载后重试。'
|
|
1279
3621
|
: '无法准备确认信息。请返回检查选择,或重试。';
|
|
3622
|
+
const preparationRecordId = `${this.#sessionEpoch}:${active.snapshot.id}`;
|
|
3623
|
+
active.snapshot.operationRecordId = preparationRecordId;
|
|
3624
|
+
const carriedDiagnostics = error instanceof TuiOperationBlockedError
|
|
3625
|
+
? error.diagnostics : undefined;
|
|
3626
|
+
if (carriedDiagnostics?.length) {
|
|
3627
|
+
active.snapshot.message = `无法准备确认信息:${carriedDiagnostics.slice(0, 3)
|
|
3628
|
+
.map((diagnostic) => sanitizeDiagnosticText(`${diagnostic.target?.pluginId ? `${diagnostic.target.pluginId}:` : ''}${diagnostic.safeMessage}(${safeDiagnosticCode(diagnostic.code, 'operationBlocked')})`, [], collectOperationSensitiveValues(intent))).join(';')}`;
|
|
3629
|
+
}
|
|
3630
|
+
const preparationDiagnostics = carriedDiagnostics?.length
|
|
3631
|
+
? carriedDiagnostics.map((diagnostic, index) => ({
|
|
3632
|
+
...structuredClone(diagnostic),
|
|
3633
|
+
id: `${preparationRecordId}:failure:${index}`,
|
|
3634
|
+
}))
|
|
3635
|
+
: [projectThrownOperationDiagnostic({
|
|
3636
|
+
error,
|
|
3637
|
+
id: `${preparationRecordId}:failure`,
|
|
3638
|
+
stage: active.snapshot.currentStage ?? 'reviewPreparation',
|
|
3639
|
+
fallbackCode: code,
|
|
3640
|
+
sensitiveValues: collectOperationSensitiveValues(intent),
|
|
3641
|
+
})];
|
|
3642
|
+
this.#operationHistory.record({
|
|
3643
|
+
summary: {
|
|
3644
|
+
recordId: preparationRecordId,
|
|
3645
|
+
epoch: this.#sessionEpoch,
|
|
3646
|
+
operationId: active.snapshot.id,
|
|
3647
|
+
createdAtMs: this.dependencies.now?.() ?? Date.now(),
|
|
3648
|
+
state: 'blocked',
|
|
3649
|
+
code: preparationDiagnostics[0].code,
|
|
3650
|
+
message: active.snapshot.message,
|
|
3651
|
+
operationKind: intent.kind,
|
|
3652
|
+
...('pluginId' in intent ? { pluginId: intent.pluginId } : {}),
|
|
3653
|
+
diagnosticCount: preparationDiagnostics.length,
|
|
3654
|
+
effects: {
|
|
3655
|
+
configCommit: 'notApplicable', awWrite: 'notStarted',
|
|
3656
|
+
preApplyExternalEffect: 'notApplicable', finalVerification: 'notStarted',
|
|
3657
|
+
},
|
|
3658
|
+
},
|
|
3659
|
+
diagnostics: preparationDiagnostics,
|
|
3660
|
+
targets: [...new Map(preparationDiagnostics.flatMap((diagnostic) => diagnostic.target ? [[
|
|
3661
|
+
[diagnostic.target.pluginId ?? '', diagnostic.target.platform, diagnostic.target.scope].join('\0'),
|
|
3662
|
+
{
|
|
3663
|
+
...diagnostic.target,
|
|
3664
|
+
state: 'skipped',
|
|
3665
|
+
errorCode: diagnostic.code,
|
|
3666
|
+
diagnosticIds: preparationDiagnostics.filter((candidate) => candidate.target
|
|
3667
|
+
&& candidate.target.pluginId === diagnostic.target.pluginId
|
|
3668
|
+
&& candidate.target.platform === diagnostic.target.platform
|
|
3669
|
+
&& candidate.target.scope === diagnostic.target.scope).map((candidate) => candidate.id),
|
|
3670
|
+
},
|
|
3671
|
+
]] : [])).values()],
|
|
3672
|
+
}, { sensitiveValues: collectOperationSensitiveValues(intent) });
|
|
1280
3673
|
this.#publish();
|
|
1281
3674
|
await this.#logOperationError(error, code, intent);
|
|
1282
3675
|
}
|
|
@@ -1300,11 +3693,13 @@ export class TuiController {
|
|
|
1300
3693
|
return;
|
|
1301
3694
|
this.#reviewPreparationToken += 1;
|
|
1302
3695
|
this.#reviewPreparation.abort.abort();
|
|
3696
|
+
this.#reviewPreparationIntents.delete(this.#reviewPreparation.snapshot.id);
|
|
1303
3697
|
this.#reviewPreparation = undefined;
|
|
1304
3698
|
}
|
|
1305
3699
|
async #logOperationError(error, code, intent) {
|
|
1306
3700
|
await this.#logErrorSafe(error, code, {
|
|
1307
|
-
privateConfigOperation: intent.kind === 'configSave' || intent.kind === '
|
|
3701
|
+
privateConfigOperation: intent.kind === 'configSave' || intent.kind === 'configSaveBatch'
|
|
3702
|
+
|| intent.kind === 'configReset'
|
|
1308
3703
|
|| intent.kind === 'sourceMutation',
|
|
1309
3704
|
});
|
|
1310
3705
|
}
|
|
@@ -1322,8 +3717,29 @@ export class TuiController {
|
|
|
1322
3717
|
}
|
|
1323
3718
|
}
|
|
1324
3719
|
#storeOperationReview(intent, evidence, navigation = 'push', returnRoute = this.#router.snapshot.current.route) {
|
|
3720
|
+
this.#ensureOperationFlow(intent);
|
|
3721
|
+
if (intent.kind === 'pluginWriteBatch')
|
|
3722
|
+
assertPluginWriteBatchEvidence(evidence);
|
|
3723
|
+
if (intent.kind === 'pluginWriteTask')
|
|
3724
|
+
assertPluginWriteTaskEvidence(intent, evidence);
|
|
1325
3725
|
if (this.#router.snapshot.current.route.name === 'result')
|
|
1326
3726
|
navigation = 'replace';
|
|
3727
|
+
const configEvidence = intent.kind === 'configSave'
|
|
3728
|
+
? evidence.config ? [evidence.config] : undefined
|
|
3729
|
+
: intent.kind === 'configSaveBatch'
|
|
3730
|
+
? evidence.configBatch?.groups.map((group) => group.config)
|
|
3731
|
+
: undefined;
|
|
3732
|
+
if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch')
|
|
3733
|
+
&& (!configEvidence || configEvidence.length !== (intent.kind === 'configSave' ? 1 : intent.groups.length))) {
|
|
3734
|
+
throw new TuiOperationBlockedError('configImpactUnavailable', '设置确认缺少完整的应用影响证据。');
|
|
3735
|
+
}
|
|
3736
|
+
const configImpact = configEvidence ? {
|
|
3737
|
+
state: configEvidence.some((group) => group.impactState !== 'known') ? 'unknown' : 'known',
|
|
3738
|
+
affectedTargetCount: new Set(configEvidence.flatMap((group) => group.affectedTargets
|
|
3739
|
+
.map((target) => `${target.pluginName ?? ''}\0${target.platform}\0${target.scope}`))).size
|
|
3740
|
+
+ new Set(configEvidence.flatMap((group) => (group.commandPackages ?? [])
|
|
3741
|
+
.map((target) => target.packageId))).size,
|
|
3742
|
+
} : undefined;
|
|
1327
3743
|
const projection = buildOperationReviewProjection({
|
|
1328
3744
|
intent,
|
|
1329
3745
|
evidence,
|
|
@@ -1338,13 +3754,49 @@ export class TuiController {
|
|
|
1338
3754
|
const expiresAt = now
|
|
1339
3755
|
+ (this.dependencies.reviewTtlMs ?? 2 * 60_000);
|
|
1340
3756
|
const pluginId = 'pluginId' in intent ? intent.pluginId
|
|
1341
|
-
: 'sourceId' in intent ? intent.sourceId
|
|
3757
|
+
: 'sourceId' in intent ? intent.sourceId ?? 'Catalog 管理'
|
|
3758
|
+
: intent.kind === 'pluginWriteBatch'
|
|
3759
|
+
? `${evidence.requestedPluginIds.length} 个插件`
|
|
3760
|
+
: intent.kind === 'pluginWriteTask'
|
|
3761
|
+
? `${evidence.taskPlan.requestedTargets.length} 个安装位置`
|
|
3762
|
+
: intent.kind === 'catalogStorePrune' ? 'Catalog 本地存储'
|
|
3763
|
+
: 'Catalog 来源配置';
|
|
1342
3764
|
if ('pluginId' in intent)
|
|
1343
3765
|
sourceIdFromPluginId(intent.pluginId);
|
|
1344
3766
|
const pluginVersion = 'pluginId' in intent
|
|
1345
3767
|
? evidence.source?.pluginVersion
|
|
1346
3768
|
?? this.#viewModel?.plugins.find((plugin) => plugin.pluginId === intent.pluginId)?.version
|
|
1347
3769
|
: undefined;
|
|
3770
|
+
const rootSummary = intent.kind === 'pluginWriteTask'
|
|
3771
|
+
? [...new Set(evidence.taskPlan.requestedTargets
|
|
3772
|
+
.map((target) => target.pluginId))].map((rootPluginId) => {
|
|
3773
|
+
const targets = evidence.taskPlan.requestedTargets
|
|
3774
|
+
.filter((target) => target.pluginId === rootPluginId);
|
|
3775
|
+
const versions = [...new Set(targets.flatMap((target) => target.expectedUpdate?.activeVersion ? [target.expectedUpdate.activeVersion] : []))];
|
|
3776
|
+
return {
|
|
3777
|
+
pluginId: rootPluginId,
|
|
3778
|
+
...(versions.length === 1 ? { version: versions[0] } : {}),
|
|
3779
|
+
targets: targets.map(({ platform, scope }) => ({ platform, scope })),
|
|
3780
|
+
};
|
|
3781
|
+
})
|
|
3782
|
+
: intent.kind === 'pluginWriteBatch'
|
|
3783
|
+
? evidence.requestedPluginIds.map((rootPluginId) => {
|
|
3784
|
+
const batchEvidence = evidence;
|
|
3785
|
+
const targetVersions = batchEvidence.targetVersions?.filter((target) => target.pluginId === rootPluginId) ?? [];
|
|
3786
|
+
const versions = [...new Set(targetVersions.flatMap((target) => {
|
|
3787
|
+
const version = intent.action === 'uninstall'
|
|
3788
|
+
? target.installedVersion
|
|
3789
|
+
: target.availableVersion ?? target.installedVersion;
|
|
3790
|
+
return version ? [version] : [];
|
|
3791
|
+
}))];
|
|
3792
|
+
return {
|
|
3793
|
+
pluginId: rootPluginId,
|
|
3794
|
+
...(versions.length === 1 ? { version: versions[0] } : {}),
|
|
3795
|
+
targets: batchEvidence.groups.filter((group) => group.requestedPluginIds.includes(rootPluginId))
|
|
3796
|
+
.map(({ platform, scope }) => ({ platform, scope })),
|
|
3797
|
+
};
|
|
3798
|
+
})
|
|
3799
|
+
: undefined;
|
|
1348
3800
|
const review = {
|
|
1349
3801
|
operationId,
|
|
1350
3802
|
reviewToken,
|
|
@@ -1354,10 +3806,13 @@ export class TuiController {
|
|
|
1354
3806
|
: intent.kind === 'catalogGeneration' && intent.sourceMutation
|
|
1355
3807
|
? { sourceAction: intent.sourceMutation.action } : {}),
|
|
1356
3808
|
...(intent.kind === 'pluginWrite' ? { pluginAction: intent.action } : {}),
|
|
3809
|
+
...(intent.kind === 'pluginWriteBatch' ? { pluginAction: intent.action } : {}),
|
|
3810
|
+
...(intent.kind === 'pluginWriteTask' ? { taskGoal: intent.goal } : {}),
|
|
1357
3811
|
...(intent.kind === 'pluginWrite' && intent.originIssue
|
|
1358
3812
|
? { originIssue: intent.originIssue }
|
|
1359
3813
|
: {}),
|
|
1360
3814
|
...projection,
|
|
3815
|
+
...(configImpact ? { configImpact } : {}),
|
|
1361
3816
|
subject: {
|
|
1362
3817
|
name: 'pluginId' in intent
|
|
1363
3818
|
? this.#viewModel?.plugins.find((plugin) => plugin.pluginId === intent.pluginId)?.displayName
|
|
@@ -1366,6 +3821,24 @@ export class TuiController {
|
|
|
1366
3821
|
...('pluginId' in intent ? { sourceLabel: sourceIdFromPluginId(intent.pluginId) } : {}),
|
|
1367
3822
|
...(pluginVersion ? { version: pluginVersion } : {}),
|
|
1368
3823
|
},
|
|
3824
|
+
...(intent.kind === 'pluginWriteBatch' ? {
|
|
3825
|
+
batch: {
|
|
3826
|
+
requestedPluginIds: [...evidence.requestedPluginIds],
|
|
3827
|
+
groupCount: evidence.groups.length,
|
|
3828
|
+
executableGroupCount: evidence.groups
|
|
3829
|
+
.filter((group) => group.executable).length,
|
|
3830
|
+
},
|
|
3831
|
+
} : {}),
|
|
3832
|
+
...(intent.kind === 'pluginWriteTask' ? {
|
|
3833
|
+
task: {
|
|
3834
|
+
goal: intent.goal,
|
|
3835
|
+
requestedTargetCount: evidence.taskPlan.requestedTargets.length,
|
|
3836
|
+
executableTargetCount: evidence.taskPlan.executableTargets.length,
|
|
3837
|
+
blockedTargetCount: evidence.taskPlan.blockedTargets.length,
|
|
3838
|
+
causeCount: evidence.taskPlan.causes.length,
|
|
3839
|
+
},
|
|
3840
|
+
} : {}),
|
|
3841
|
+
...(rootSummary && rootSummary.length > 0 ? { rootSummary } : {}),
|
|
1369
3842
|
...(evidence.source && 'catalogVersion' in evidence.source
|
|
1370
3843
|
&& typeof evidence.source.catalogVersion === 'string'
|
|
1371
3844
|
&& evidence.source.snapshotDigest
|
|
@@ -1389,6 +3862,14 @@ export class TuiController {
|
|
|
1389
3862
|
return cloneFrozen(review);
|
|
1390
3863
|
}
|
|
1391
3864
|
executeOperation(reviewToken) {
|
|
3865
|
+
if (this.#retiring || this.#disposed) {
|
|
3866
|
+
return Promise.resolve(cloneFrozen({
|
|
3867
|
+
state: 'blocked',
|
|
3868
|
+
operationId: this.#tickets.get(reviewToken)?.review.operationId ?? 'unknown',
|
|
3869
|
+
code: 'sessionRetiring',
|
|
3870
|
+
message: '会话正在结束,未启动新操作。',
|
|
3871
|
+
}));
|
|
3872
|
+
}
|
|
1392
3873
|
const inflight = this.#inflightOperations.get(reviewToken);
|
|
1393
3874
|
if (inflight)
|
|
1394
3875
|
return inflight.promise;
|
|
@@ -1409,6 +3890,7 @@ export class TuiController {
|
|
|
1409
3890
|
const promise = this.#executeOperationTicket(ticket, operationId).finally(() => {
|
|
1410
3891
|
if (this.#inflightOperations.get(reviewToken)?.promise === promise) {
|
|
1411
3892
|
this.#inflightOperations.delete(reviewToken);
|
|
3893
|
+
this.#publish();
|
|
1412
3894
|
}
|
|
1413
3895
|
});
|
|
1414
3896
|
this.#inflightOperations.set(reviewToken, { operationId, promise });
|
|
@@ -1418,8 +3900,12 @@ export class TuiController {
|
|
|
1418
3900
|
let generation = this.#generation;
|
|
1419
3901
|
const startedAtMs = this.dependencies.now?.() ?? Date.now();
|
|
1420
3902
|
this.#progressFeed?.clearCurrent?.();
|
|
1421
|
-
const
|
|
1422
|
-
|
|
3903
|
+
const dependencyTargets = ticket.intent.kind === 'pluginWriteBatch'
|
|
3904
|
+
? ticket.evidence.groups.flatMap((group) => group.preview.dependencyPlan?.targets ?? [])
|
|
3905
|
+
: ticket.intent.kind === 'pluginWriteTask'
|
|
3906
|
+
? ticket.evidence.taskPlan.sources.flatMap((source) => source.preview.dependencyPlan?.targets ?? [])
|
|
3907
|
+
: ticket.evidence.dependencyPlan?.targets ?? [];
|
|
3908
|
+
this.#progressTargets = dependencyTargets.map((target) => ({
|
|
1423
3909
|
pluginId: target.pluginId,
|
|
1424
3910
|
platform: target.platform,
|
|
1425
3911
|
scope: target.resolvedScope,
|
|
@@ -1428,21 +3914,27 @@ export class TuiController {
|
|
|
1428
3914
|
: target.depth === 1 ? 'direct' : 'transitive',
|
|
1429
3915
|
requiredBy: target.requiredBy,
|
|
1430
3916
|
state: target.action === 'keep' ? 'kept' : 'pending',
|
|
1431
|
-
}))
|
|
3917
|
+
}));
|
|
1432
3918
|
this.#progress = {
|
|
1433
3919
|
messages: [],
|
|
1434
3920
|
startedAtMs,
|
|
1435
3921
|
elapsedMs: 0,
|
|
1436
3922
|
current: {
|
|
1437
|
-
target:
|
|
1438
|
-
|
|
3923
|
+
target: ticket.intent.kind === 'pluginWriteBatch'
|
|
3924
|
+
? `${ticket.evidence.requestedPluginIds.length} 个插件`
|
|
3925
|
+
: ticket.intent.kind === 'pluginWriteTask'
|
|
3926
|
+
? `${ticket.evidence.taskPlan.executableTargets.length} 个安装位置`
|
|
3927
|
+
: 'pluginId' in ticket.intent ? ticket.intent.pluginId
|
|
3928
|
+
: 'sourceId' in ticket.intent ? ticket.intent.sourceId ?? 'Catalog 管理'
|
|
3929
|
+
: ticket.intent.kind === 'catalogStorePrune' ? 'Catalog 本地存储' : 'Catalog 来源配置',
|
|
1439
3930
|
phase: '验证当前状态',
|
|
1440
3931
|
},
|
|
1441
3932
|
};
|
|
1442
3933
|
this.#router.replace({ name: 'progress', operationId });
|
|
1443
3934
|
this.#publish();
|
|
1444
3935
|
try {
|
|
1445
|
-
if (ticket.intent.kind !== 'pluginWrite'
|
|
3936
|
+
if (ticket.intent.kind !== 'pluginWrite' && ticket.intent.kind !== 'pluginWriteBatch'
|
|
3937
|
+
&& ticket.intent.kind !== 'pluginWriteTask') {
|
|
1446
3938
|
await this.dependencies.validateIntent?.(structuredClone(ticket.intent), this.#abort.signal);
|
|
1447
3939
|
}
|
|
1448
3940
|
}
|
|
@@ -1473,7 +3965,9 @@ export class TuiController {
|
|
|
1473
3965
|
}
|
|
1474
3966
|
if (!this.#operationIsCurrent(generation))
|
|
1475
3967
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1476
|
-
if (ticket.intent.kind !== 'pluginWrite' && ticket.intent.kind !== '
|
|
3968
|
+
if (ticket.intent.kind !== 'pluginWrite' && ticket.intent.kind !== 'pluginWriteBatch'
|
|
3969
|
+
&& ticket.intent.kind !== 'pluginWriteTask'
|
|
3970
|
+
&& ticket.intent.kind !== 'catalogGeneration') {
|
|
1477
3971
|
let current;
|
|
1478
3972
|
try {
|
|
1479
3973
|
current = await this.dependencies.captureEvidence(structuredClone(ticket.intent), this.#abort.signal);
|
|
@@ -1501,6 +3995,15 @@ export class TuiController {
|
|
|
1501
3995
|
const execution = ticket.intent.kind === 'catalogGeneration'
|
|
1502
3996
|
? await this.dependencies.executeIntent(structuredClone(ticket.intent), structuredClone(ticket.evidence), this.#abort.signal)
|
|
1503
3997
|
: await this.dependencies.executeIntent(structuredClone(ticket.intent), structuredClone(ticket.evidence));
|
|
3998
|
+
if (ticket.intent.kind === 'portableInstall' && isPortableInstallReceipt(execution)) {
|
|
3999
|
+
this.#portableResultReceipt = structuredClone(execution);
|
|
4000
|
+
this.#portableResultIntent = structuredClone(ticket.intent);
|
|
4001
|
+
}
|
|
4002
|
+
const executionProjection = projectExecutionDiagnostics(execution, `${this.#sessionEpoch}:${operationId}`, collectOperationSensitiveValues(ticket.intent), ticket.intent.kind);
|
|
4003
|
+
this.#operationDiagnostics.set(operationId, {
|
|
4004
|
+
...executionProjection,
|
|
4005
|
+
sensitiveValues: collectOperationSensitiveValues(ticket.intent),
|
|
4006
|
+
});
|
|
1504
4007
|
if (ticket.intent.kind === 'sourceMutation' && ticket.intent.action === 'update') {
|
|
1505
4008
|
const confirmedAutoCheck = catalogSourceAutoCheckOnlyValue(ticket.intent.update);
|
|
1506
4009
|
if (confirmedAutoCheck !== undefined) {
|
|
@@ -1518,7 +4021,7 @@ export class TuiController {
|
|
|
1518
4021
|
generation = ++this.#generation;
|
|
1519
4022
|
if (ticket.intent.kind === 'sourceMutation' || ticket.intent.kind === 'catalogGeneration'
|
|
1520
4023
|
|| ticket.intent.kind === 'catalogSourcesRecovery') {
|
|
1521
|
-
this
|
|
4024
|
+
this.#beginCatalogSession(ticket.intent.kind === 'sourceMutation' ? {
|
|
1522
4025
|
reuseValidatedGenerations: true,
|
|
1523
4026
|
} : undefined);
|
|
1524
4027
|
try {
|
|
@@ -1541,8 +4044,54 @@ export class TuiController {
|
|
|
1541
4044
|
await this.#logErrorSafe(error, verificationCode, {
|
|
1542
4045
|
privateConfigOperation: true,
|
|
1543
4046
|
});
|
|
4047
|
+
const existingProjection = this.#operationDiagnostics.get(operationId);
|
|
4048
|
+
existingProjection.diagnostics.push(projectThrownOperationDiagnostic({
|
|
4049
|
+
error,
|
|
4050
|
+
id: `${this.#sessionEpoch}:${operationId}:status-reload`,
|
|
4051
|
+
stage: 'statusReload',
|
|
4052
|
+
fallbackCode: verificationCode,
|
|
4053
|
+
}));
|
|
4054
|
+
existingProjection.effects.finalVerification = 'failed';
|
|
1544
4055
|
if (!this.#operationIsCurrent(generation))
|
|
1545
4056
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
4057
|
+
const configCommitted = typeof execution === 'object'
|
|
4058
|
+
&& execution !== null
|
|
4059
|
+
&& (execution.configWrite === 'succeeded'
|
|
4060
|
+
|| Array.isArray(execution.groups)
|
|
4061
|
+
&& (execution.groups
|
|
4062
|
+
.some((group) => group.configSaved)));
|
|
4063
|
+
const configRetryReportedDelivery = ticket.intent.kind === 'configSave' && ticket.intent.retryApply
|
|
4064
|
+
&& configApplyHasCompletedWork(configApplyResult(execution));
|
|
4065
|
+
if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configSaveBatch'
|
|
4066
|
+
|| ticket.intent.kind === 'configReset') && (configCommitted || configRetryReportedDelivery)) {
|
|
4067
|
+
const baseSummary = operationResultSummary(ticket.intent, execution);
|
|
4068
|
+
const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
|
|
4069
|
+
const summary = {
|
|
4070
|
+
...baseSummary,
|
|
4071
|
+
code: 'operationPartial',
|
|
4072
|
+
message: configCommitted ? '设置已保存,但最终状态无法刷新。' : '部分插件内容已就绪,但最终状态无法刷新。',
|
|
4073
|
+
elapsedMs,
|
|
4074
|
+
messages: [
|
|
4075
|
+
...this.#progress.messages,
|
|
4076
|
+
...(baseSummary.messages ?? []),
|
|
4077
|
+
configCommitted ? '状态刷新失败。配置写入已经提交;请稍后刷新状态。' : '请稍后刷新状态。',
|
|
4078
|
+
].slice(-8).map((message) => sanitizeDiagnosticText(message, [], collectOperationSensitiveValues(ticket.intent))),
|
|
4079
|
+
};
|
|
4080
|
+
this.#progress = { ...this.#progress, elapsedMs };
|
|
4081
|
+
const result = {
|
|
4082
|
+
state: 'partial',
|
|
4083
|
+
operationId,
|
|
4084
|
+
summary,
|
|
4085
|
+
operationKind: ticket.intent.kind,
|
|
4086
|
+
pluginId: ticket.intent.pluginId,
|
|
4087
|
+
returnRoute: structuredClone(this.#normalizeRoute(ticket.returnRoute)),
|
|
4088
|
+
};
|
|
4089
|
+
this.#result = structuredClone(result);
|
|
4090
|
+
this.#activeReview = undefined;
|
|
4091
|
+
this.#showResult(result, ticket.intent);
|
|
4092
|
+
this.#publish();
|
|
4093
|
+
return cloneFrozen(result);
|
|
4094
|
+
}
|
|
1546
4095
|
return this.#setBlocked(operationId, verificationCode, {
|
|
1547
4096
|
intent: ticket.intent,
|
|
1548
4097
|
navigation: 'result',
|
|
@@ -1555,11 +4104,28 @@ export class TuiController {
|
|
|
1555
4104
|
if (!this.#operationIsCurrent(generation))
|
|
1556
4105
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1557
4106
|
this.#applyStatus(refreshed);
|
|
4107
|
+
if (ticket.intent.kind === 'catalogGeneration') {
|
|
4108
|
+
const completed = typeof execution === 'object' && execution !== null
|
|
4109
|
+
? execution.generation
|
|
4110
|
+
: undefined;
|
|
4111
|
+
const active = this.#catalogGenerations.get(ticket.intent.sourceId)?.active;
|
|
4112
|
+
if (completed && active
|
|
4113
|
+
&& active.catalogVersion === completed.resolution.catalogVersion
|
|
4114
|
+
&& active.resolvedCommit === completed.resolution.resolvedCommit) {
|
|
4115
|
+
this.#catalogSourcesSession.recordVerifiedGeneration(ticket.intent.sourceId, active);
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
const verifiedProjection = this.#operationDiagnostics.get(operationId);
|
|
4119
|
+
if (verifiedProjection && verifiedProjection.effects.finalVerification !== 'failed') {
|
|
4120
|
+
verifiedProjection.effects.finalVerification = 'completed';
|
|
4121
|
+
}
|
|
1558
4122
|
if (ticket.intent.kind === 'catalogSourcesRecovery') {
|
|
1559
4123
|
this.#phase = 'ready';
|
|
1560
4124
|
this.#loadError = undefined;
|
|
1561
4125
|
}
|
|
1562
4126
|
const pluginSummary = ticket.intent.kind === 'pluginWrite'
|
|
4127
|
+
|| ticket.intent.kind === 'pluginWriteBatch'
|
|
4128
|
+
|| ticket.intent.kind === 'pluginWriteTask'
|
|
1563
4129
|
? operationResultSummary(ticket.intent, execution)
|
|
1564
4130
|
: undefined;
|
|
1565
4131
|
const hasFailedDependencyTarget = pluginSummary?.targets?.some((target) => target.relation !== undefined && target.relation !== 'requested'
|
|
@@ -1570,10 +4136,21 @@ export class TuiController {
|
|
|
1570
4136
|
const dependencyFailure = pluginSummary?.code === 'operationFailed'
|
|
1571
4137
|
&& Boolean(hasFailedDependencyTarget);
|
|
1572
4138
|
if (pluginSummary?.code === 'operationFailed') {
|
|
4139
|
+
const projected = this.#operationDiagnostics.get(operationId);
|
|
4140
|
+
if (projected) {
|
|
4141
|
+
projected.targets = (pluginSummary.targets ?? []).map((target) => ({
|
|
4142
|
+
...target,
|
|
4143
|
+
diagnosticIds: projected.diagnostics.filter((diagnostic) => diagnostic.target
|
|
4144
|
+
&& diagnostic.target.platform === target.platform
|
|
4145
|
+
&& diagnostic.target.scope === target.scope
|
|
4146
|
+
&& (diagnostic.target.pluginId === undefined || diagnostic.target.pluginId === target.pluginId))
|
|
4147
|
+
.map((diagnostic) => diagnostic.id),
|
|
4148
|
+
effects: projected.targetEffects?.get(`${target.pluginId ?? ''}\0${target.platform}\0${target.scope}`),
|
|
4149
|
+
}));
|
|
4150
|
+
}
|
|
1573
4151
|
const unsuccessfulTargets = pluginSummary.targets?.filter((target) => target.state === 'failed' || target.state === 'skipped') ?? [];
|
|
1574
4152
|
const managerFailureCode = unsuccessfulTargets.map((target) => target.errorCode).find((code) => code === 'codexSystemCliUnsupported'
|
|
1575
|
-
|| code === '
|
|
1576
|
-
|| code === 'managedCodexUnavailable');
|
|
4153
|
+
|| code === 'codexCliNotFound');
|
|
1577
4154
|
if (managerFailureCode) {
|
|
1578
4155
|
return this.#setBlocked(operationId, managerFailureCode, {
|
|
1579
4156
|
intent: ticket.intent,
|
|
@@ -1582,19 +4159,40 @@ export class TuiController {
|
|
|
1582
4159
|
summary: pluginSummary,
|
|
1583
4160
|
});
|
|
1584
4161
|
}
|
|
4162
|
+
const concurrentScopeConflict = ticket.intent.kind === 'pluginWrite'
|
|
4163
|
+
&& ticket.intent.action === 'install'
|
|
4164
|
+
&& unsuccessfulTargets.length === pluginSummary.targets?.length
|
|
4165
|
+
&& unsuccessfulTargets.every((target) => target.errorCode === 'codexExtensionScopeConflict');
|
|
4166
|
+
if (concurrentScopeConflict) {
|
|
4167
|
+
return this.#setBlocked(operationId, 'codexExtensionScopeConflict', {
|
|
4168
|
+
intent: ticket.intent,
|
|
4169
|
+
navigation: 'result',
|
|
4170
|
+
returnRoute: ticket.returnRoute,
|
|
4171
|
+
summary: pluginSummary,
|
|
4172
|
+
writeMayHaveCompleted: false,
|
|
4173
|
+
});
|
|
4174
|
+
}
|
|
1585
4175
|
const dependencyStillRequired = unsuccessfulTargets.length > 0
|
|
1586
4176
|
&& unsuccessfulTargets.every((target) => target.errorCode === 'dependencyStillRequired');
|
|
1587
4177
|
return this.#setBlocked(operationId, dependencyStillRequired ? 'dependencyStillRequired' : 'operationFailed', {
|
|
1588
4178
|
intent: ticket.intent,
|
|
1589
4179
|
navigation: 'result',
|
|
1590
4180
|
returnRoute: ticket.returnRoute,
|
|
1591
|
-
...(
|
|
1592
|
-
|
|
4181
|
+
...(ticket.intent.kind === 'pluginWriteBatch' || ticket.intent.kind === 'pluginWriteTask'
|
|
4182
|
+
|| ticket.intent.kind === 'pluginWrite' && ticket.intent.action === 'uninstall'
|
|
4183
|
+
|| dependencyFailure || dependencyStillRequired
|
|
4184
|
+
? { summary: pluginSummary } : {}),
|
|
4185
|
+
...(ticket.intent.kind !== 'pluginWriteBatch' && ticket.intent.kind !== 'pluginWriteTask'
|
|
4186
|
+
&& !dependencyFailure && !dependencyStillRequired && ['started', 'partial', 'completed', 'failed', 'unknown'].includes(this.#operationDiagnostics.get(operationId)?.effects.awWrite ?? 'unknown') ? { writeMayHaveCompleted: true } : {}),
|
|
1593
4187
|
});
|
|
1594
4188
|
}
|
|
1595
4189
|
const originIssue = ticket.intent.kind === 'pluginWrite' ? ticket.intent.originIssue : undefined;
|
|
4190
|
+
const projectRemovalKeepsDemand = ticket.intent.kind === 'pluginWrite'
|
|
4191
|
+
&& ticket.intent.action === 'uninstall' && ticket.intent.scope === 'project'
|
|
4192
|
+
&& pluginSummary?.code === 'operationSucceeded';
|
|
1596
4193
|
if (originIssue && !dependencyPartial
|
|
1597
|
-
&&
|
|
4194
|
+
&& !projectRemovalKeepsDemand
|
|
4195
|
+
&& this.#viewModel?.issues.some((issue) => originIssueRemains(issue, originIssue))) {
|
|
1598
4196
|
return this.#setBlocked(operationId, 'issueStillPresent', {
|
|
1599
4197
|
intent: ticket.intent,
|
|
1600
4198
|
navigation: 'result',
|
|
@@ -1603,7 +4201,7 @@ export class TuiController {
|
|
|
1603
4201
|
verification: 'issueStillPresent',
|
|
1604
4202
|
});
|
|
1605
4203
|
}
|
|
1606
|
-
if (ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configReset') {
|
|
4204
|
+
if ((ticket.intent.kind === 'configSave' && !ticket.intent.retryApply) || ticket.intent.kind === 'configReset') {
|
|
1607
4205
|
const configWrite = typeof execution === 'object' && execution !== null
|
|
1608
4206
|
? execution.configWrite
|
|
1609
4207
|
: undefined;
|
|
@@ -1620,7 +4218,8 @@ export class TuiController {
|
|
|
1620
4218
|
const summary = {
|
|
1621
4219
|
...baseSummary,
|
|
1622
4220
|
elapsedMs: Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs),
|
|
1623
|
-
messages: [...this.#progress.messages, ...(baseSummary.messages ?? [])].slice(-8)
|
|
4221
|
+
messages: [...this.#progress.messages, ...(baseSummary.messages ?? [])].slice(-8)
|
|
4222
|
+
.map((message) => sanitizeDiagnosticText(message, [], collectOperationSensitiveValues(ticket.intent))),
|
|
1624
4223
|
};
|
|
1625
4224
|
this.#progress = { ...this.#progress, elapsedMs: summary.elapsedMs };
|
|
1626
4225
|
if (summary.code === 'operationFailed') {
|
|
@@ -1635,10 +4234,19 @@ export class TuiController {
|
|
|
1635
4234
|
};
|
|
1636
4235
|
this.#result = structuredClone(result);
|
|
1637
4236
|
this.#activeReview = undefined;
|
|
1638
|
-
this.#
|
|
4237
|
+
this.#showResult(result, ticket.intent);
|
|
1639
4238
|
this.#publish();
|
|
1640
4239
|
return cloneFrozen(result);
|
|
1641
4240
|
}
|
|
4241
|
+
if (ticket.intent.kind === 'configSaveBatch') {
|
|
4242
|
+
return this.#setBlocked(operationId, 'operationFailed', {
|
|
4243
|
+
intent: ticket.intent,
|
|
4244
|
+
navigation: 'result',
|
|
4245
|
+
returnRoute: ticket.returnRoute,
|
|
4246
|
+
summary,
|
|
4247
|
+
writeMayHaveCompleted: false,
|
|
4248
|
+
});
|
|
4249
|
+
}
|
|
1642
4250
|
return this.#setBlocked(operationId, 'operationFailed', {
|
|
1643
4251
|
intent: ticket.intent,
|
|
1644
4252
|
navigation: 'result',
|
|
@@ -1661,11 +4269,19 @@ export class TuiController {
|
|
|
1661
4269
|
: ticket.intent.kind === 'sourceMutation' && ticket.intent.action === 'update'
|
|
1662
4270
|
? { name: 'sourceDetail', sourceId: ticket.intent.sourceId }
|
|
1663
4271
|
: ticket.intent.kind === 'catalogGeneration'
|
|
1664
|
-
?
|
|
4272
|
+
? ticket.returnRoute.name === 'pluginWriteTask'
|
|
4273
|
+
? ticket.returnRoute
|
|
4274
|
+
: { name: 'sourceDetail', sourceId: ticket.intent.sourceId }
|
|
1665
4275
|
: ticket.returnRoute)),
|
|
1666
4276
|
};
|
|
1667
|
-
|
|
1668
|
-
|
|
4277
|
+
const configResultNeedsAttention = result.state === 'succeeded' && (result.summary.messages?.some((message) => message.startsWith('警告:')
|
|
4278
|
+
|| message === '提示:其它项目没有被扫描,可能需要在对应项目目录中运行 aw plugin sync --context project。') ?? false);
|
|
4279
|
+
if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configSaveBatch'
|
|
4280
|
+
|| ticket.intent.kind === 'configReset')
|
|
4281
|
+
&& this.#portableRepreparePluginId === ticket.intent.pluginId
|
|
4282
|
+
&& result.state === 'succeeded'
|
|
4283
|
+
&& !configResultNeedsAttention) {
|
|
4284
|
+
this.#operationDiagnostics.delete(operationId);
|
|
1669
4285
|
this.#portableRepreparePluginId = undefined;
|
|
1670
4286
|
this.#activeReview = undefined;
|
|
1671
4287
|
this.#result = undefined;
|
|
@@ -1674,14 +4290,40 @@ export class TuiController {
|
|
|
1674
4290
|
}
|
|
1675
4291
|
this.#result = result;
|
|
1676
4292
|
this.#activeReview = undefined;
|
|
1677
|
-
this.#
|
|
4293
|
+
this.#showResult(result, ticket.intent);
|
|
1678
4294
|
this.#publish();
|
|
1679
4295
|
return cloneFrozen(result);
|
|
1680
4296
|
}
|
|
1681
4297
|
catch (error) {
|
|
1682
4298
|
if (!this.#operationIsCurrent(generation))
|
|
1683
4299
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1684
|
-
const
|
|
4300
|
+
const interruptedApply = error instanceof ConfigApplyInterruptedError ? error : undefined;
|
|
4301
|
+
const code = interruptedApply?.code ?? issueCode(error);
|
|
4302
|
+
const metadata = readSafeOperationError(error);
|
|
4303
|
+
const preApply = metadata?.stage === 'preApply';
|
|
4304
|
+
const applyCompletedWork = configApplyHasCompletedWork(interruptedApply?.apply);
|
|
4305
|
+
const configWrite = error && typeof error === 'object' && 'configWrite' in error
|
|
4306
|
+
? error.configWrite : undefined;
|
|
4307
|
+
this.#captureThrownProjection(operationId, error, code, 'execute', ticket.intent, {
|
|
4308
|
+
configCommit: ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configReset'
|
|
4309
|
+
? configWrite === 'succeeded' ? 'completed'
|
|
4310
|
+
: configWrite === 'failed' ? 'failed' : 'notStarted' : 'notApplicable',
|
|
4311
|
+
awWrite: preApply ? 'notStarted' : 'unknown',
|
|
4312
|
+
preApplyExternalEffect: preApply ? 'possible' : 'notApplicable',
|
|
4313
|
+
finalVerification: 'notStarted',
|
|
4314
|
+
});
|
|
4315
|
+
if (interruptedApply) {
|
|
4316
|
+
const projected = this.#operationDiagnostics.get(operationId);
|
|
4317
|
+
const applyProjection = projectExecutionDiagnostics(interruptedApply, `${this.#sessionEpoch}:${operationId}:interrupted-apply`, projected.sensitiveValues, ticket.intent.kind);
|
|
4318
|
+
projected.diagnostics.push(...applyProjection.diagnostics);
|
|
4319
|
+
projected.effects = {
|
|
4320
|
+
...applyProjection.effects,
|
|
4321
|
+
awWrite: applyCompletedWork ? 'partial' : projected.effects.awWrite,
|
|
4322
|
+
preApplyExternalEffect: preApply ? 'possible' : applyProjection.effects.preApplyExternalEffect,
|
|
4323
|
+
finalVerification: 'notStarted',
|
|
4324
|
+
};
|
|
4325
|
+
projected.targetEffects = applyProjection.targetEffects;
|
|
4326
|
+
}
|
|
1685
4327
|
await this.#logOperationError(error, code, ticket.intent);
|
|
1686
4328
|
if (!this.#operationIsCurrent(generation))
|
|
1687
4329
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
@@ -1689,42 +4331,117 @@ export class TuiController {
|
|
|
1689
4331
|
return this.#rebuildStaleReview(ticket, operationId, undefined, generation);
|
|
1690
4332
|
}
|
|
1691
4333
|
generation = ++this.#generation;
|
|
4334
|
+
let finalVerification = 'completed';
|
|
1692
4335
|
try {
|
|
1693
4336
|
const refreshed = await this.dependencies.loadStatus(this.#abort.signal);
|
|
1694
4337
|
if (!this.#operationIsCurrent(generation))
|
|
1695
4338
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1696
4339
|
this.#applyStatus(refreshed);
|
|
4340
|
+
const projection = this.#operationDiagnostics.get(operationId);
|
|
4341
|
+
if (projection)
|
|
4342
|
+
projection.effects.finalVerification = 'completed';
|
|
1697
4343
|
if (ticket.intent.kind === 'catalogSourcesRecovery'
|
|
1698
4344
|
&& code === 'catalogSourcesConfigRecoveryStale') {
|
|
1699
4345
|
this.#phase = 'ready';
|
|
1700
4346
|
this.#loadError = undefined;
|
|
1701
|
-
this.#
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
state: 'blocked',
|
|
1707
|
-
operationId,
|
|
1708
|
-
code,
|
|
1709
|
-
message: '来源配置已变化,已重新加载当前状态。',
|
|
1710
|
-
operationKind: ticket.intent.kind,
|
|
4347
|
+
return this.#setBlocked(operationId, code, {
|
|
4348
|
+
intent: ticket.intent,
|
|
4349
|
+
navigation: 'result',
|
|
4350
|
+
returnRoute: ticket.returnRoute,
|
|
4351
|
+
writeMayHaveCompleted: false,
|
|
1711
4352
|
});
|
|
1712
4353
|
}
|
|
1713
4354
|
}
|
|
1714
4355
|
catch (reloadError) {
|
|
1715
4356
|
if (!this.#operationIsCurrent(generation))
|
|
1716
4357
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
4358
|
+
finalVerification = 'failed';
|
|
4359
|
+
const projection = this.#operationDiagnostics.get(operationId);
|
|
4360
|
+
if (projection)
|
|
4361
|
+
projection.effects.finalVerification = 'failed';
|
|
1717
4362
|
await this.#logErrorSafe(reloadError, 'tuiStateReloadFailed', {
|
|
1718
4363
|
privateConfigOperation: true,
|
|
1719
4364
|
});
|
|
4365
|
+
if (ticket.intent.kind === 'catalogSourcesRecovery'
|
|
4366
|
+
&& code === 'catalogSourcesConfigRecoveryStale') {
|
|
4367
|
+
this.#phase = 'error';
|
|
4368
|
+
this.#loadError = {
|
|
4369
|
+
code: issueCode(reloadError),
|
|
4370
|
+
message: '无法安全读取插件状态。请检查诊断后重试或退出。',
|
|
4371
|
+
};
|
|
4372
|
+
}
|
|
1720
4373
|
}
|
|
1721
4374
|
if (!this.#operationIsCurrent(generation))
|
|
1722
4375
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
4376
|
+
const applySummary = interruptedApply ? operationResultSummary(ticket.intent, interruptedApply) : undefined;
|
|
4377
|
+
const configMadeProgress = configWrite === 'succeeded' || applyCompletedWork;
|
|
4378
|
+
const retryTargets = configMadeProgress ? configApplyUnfinishedPlatforms(interruptedApply?.apply, ticket.intent.kind === 'configSave' ? ticket.intent.targets : undefined) : [];
|
|
4379
|
+
const interruptionMessage = interruptedApply
|
|
4380
|
+
? configApplyInterruptionMessage(interruptedApply.code, retryTargets) : undefined;
|
|
4381
|
+
if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configReset')
|
|
4382
|
+
&& configMadeProgress) {
|
|
4383
|
+
const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
|
|
4384
|
+
const summary = {
|
|
4385
|
+
...applySummary,
|
|
4386
|
+
code: 'operationPartial',
|
|
4387
|
+
message: ticket.intent.kind === 'configReset'
|
|
4388
|
+
? '设置层重置已提交,但后续步骤未完成。'
|
|
4389
|
+
: applyCompletedWork
|
|
4390
|
+
? configWrite === 'succeeded' ? '设置已保存,部分插件内容已就绪。' : '部分插件内容已就绪。'
|
|
4391
|
+
: finalVerification === 'failed'
|
|
4392
|
+
? ticket.intent.apply
|
|
4393
|
+
? '设置已保存,但后续应用或状态复核失败。'
|
|
4394
|
+
: '设置已保存,但状态复核失败。'
|
|
4395
|
+
: ticket.intent.apply
|
|
4396
|
+
? '设置已保存,但后续应用失败。'
|
|
4397
|
+
: '设置已保存,但后续步骤未完成。',
|
|
4398
|
+
pluginId: ticket.intent.pluginId,
|
|
4399
|
+
configScope: 'user', configPlatform: ticket.intent.platform, configContext: ticket.intent.context ?? 'user',
|
|
4400
|
+
...(interruptedApply ? { configApplied: applyCompletedWork } : {}),
|
|
4401
|
+
...(ticket.intent.kind === 'configSave' && ticket.intent.apply
|
|
4402
|
+
? { configApplyRetryAvailable: !interruptedApply || retryTargets.length > 0 } : {}),
|
|
4403
|
+
...(interruptedApply ? { configApplyRetryTargets: retryTargets } : {}),
|
|
4404
|
+
elapsedMs,
|
|
4405
|
+
messages: [
|
|
4406
|
+
...(applySummary?.messages ?? []),
|
|
4407
|
+
...(configWrite === 'succeeded' ? [ticket.intent.kind === 'configReset'
|
|
4408
|
+
? '设置层重置已经提交;失败的后续步骤没有恢复旧设置。'
|
|
4409
|
+
: '配置写入已经提交;失败的后续步骤没有回滚设置。'] : []),
|
|
4410
|
+
...(interruptionMessage ? [interruptionMessage] : []),
|
|
4411
|
+
...(finalVerification === 'failed' && interruptedApply
|
|
4412
|
+
? ['最终状态无法刷新。请稍后重新检查状态。'] : []),
|
|
4413
|
+
],
|
|
4414
|
+
};
|
|
4415
|
+
this.#progress = { ...this.#progress, elapsedMs };
|
|
4416
|
+
const result = {
|
|
4417
|
+
state: 'partial',
|
|
4418
|
+
operationId,
|
|
4419
|
+
summary,
|
|
4420
|
+
operationKind: ticket.intent.kind,
|
|
4421
|
+
pluginId: ticket.intent.pluginId,
|
|
4422
|
+
returnRoute: structuredClone(this.#normalizeRoute(ticket.returnRoute)),
|
|
4423
|
+
};
|
|
4424
|
+
this.#result = structuredClone(result);
|
|
4425
|
+
this.#activeReview = undefined;
|
|
4426
|
+
this.#showResult(result, ticket.intent);
|
|
4427
|
+
this.#publish();
|
|
4428
|
+
return cloneFrozen(result);
|
|
4429
|
+
}
|
|
1723
4430
|
return this.#setBlocked(operationId, code, {
|
|
1724
4431
|
intent: ticket.intent,
|
|
1725
4432
|
navigation: 'result',
|
|
1726
4433
|
returnRoute: ticket.returnRoute,
|
|
1727
4434
|
writeMayHaveCompleted: ticket.intent.kind === 'catalogSourcesRecovery' ? false : true,
|
|
4435
|
+
...(applySummary && interruptionMessage ? {
|
|
4436
|
+
message: interruptionMessage,
|
|
4437
|
+
summary: {
|
|
4438
|
+
...applySummary,
|
|
4439
|
+
code: 'operationFailed',
|
|
4440
|
+
message: interruptionMessage,
|
|
4441
|
+
configApplyRetryAvailable: false,
|
|
4442
|
+
configApplyRetryTargets: [],
|
|
4443
|
+
},
|
|
4444
|
+
} : {}),
|
|
1728
4445
|
});
|
|
1729
4446
|
}
|
|
1730
4447
|
}
|
|
@@ -1732,6 +4449,7 @@ export class TuiController {
|
|
|
1732
4449
|
return !this.#disposed && !this.#abort.signal.aborted && generation === this.#generation;
|
|
1733
4450
|
}
|
|
1734
4451
|
#detachedBlocked(operationId, intent) {
|
|
4452
|
+
this.#operationDiagnostics.delete(operationId);
|
|
1735
4453
|
return cloneFrozen({
|
|
1736
4454
|
state: 'blocked',
|
|
1737
4455
|
operationId,
|
|
@@ -1741,7 +4459,7 @@ export class TuiController {
|
|
|
1741
4459
|
});
|
|
1742
4460
|
}
|
|
1743
4461
|
async #rebuildStaleReview(ticket, operationId, currentEvidence, generation = this.#generation) {
|
|
1744
|
-
this
|
|
4462
|
+
this.#beginCatalogSession();
|
|
1745
4463
|
generation = ++this.#generation;
|
|
1746
4464
|
try {
|
|
1747
4465
|
const refreshed = await this.dependencies.loadStatus(this.#abort.signal);
|
|
@@ -1752,6 +4470,7 @@ export class TuiController {
|
|
|
1752
4470
|
catch (error) {
|
|
1753
4471
|
if (!this.#operationIsCurrent(generation))
|
|
1754
4472
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
4473
|
+
this.#appendThrownProjection(operationId, error, 'tuiStateReloadFailed', 'statusReload', ticket.intent);
|
|
1755
4474
|
await this.#logErrorSafe(error, 'tuiStateReloadFailed', { privateConfigOperation: true });
|
|
1756
4475
|
return this.#setBlocked(operationId, 'tuiStateReloadFailed', {
|
|
1757
4476
|
intent: ticket.intent,
|
|
@@ -1767,6 +4486,7 @@ export class TuiController {
|
|
|
1767
4486
|
if (!this.#operationIsCurrent(generation))
|
|
1768
4487
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1769
4488
|
const code = issueCode(error);
|
|
4489
|
+
this.#appendThrownProjection(operationId, error, code, 'validate', intent);
|
|
1770
4490
|
await this.#logOperationError(error, code, intent);
|
|
1771
4491
|
if (!this.#operationIsCurrent(generation))
|
|
1772
4492
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
@@ -1780,7 +4500,7 @@ export class TuiController {
|
|
|
1780
4500
|
};
|
|
1781
4501
|
this.#result = structuredClone(result);
|
|
1782
4502
|
this.#activeReview = undefined;
|
|
1783
|
-
this.#
|
|
4503
|
+
this.#showResult(result, ticket.intent);
|
|
1784
4504
|
this.#publish();
|
|
1785
4505
|
return cloneFrozen(result);
|
|
1786
4506
|
}
|
|
@@ -1795,6 +4515,7 @@ export class TuiController {
|
|
|
1795
4515
|
if (!this.#operationIsCurrent(generation))
|
|
1796
4516
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1797
4517
|
const code = issueCode(error);
|
|
4518
|
+
this.#appendThrownProjection(operationId, error, code, 'reviewPreparation', intent);
|
|
1798
4519
|
await this.#logOperationError(error, code, intent);
|
|
1799
4520
|
if (!this.#operationIsCurrent(generation))
|
|
1800
4521
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
@@ -1819,26 +4540,28 @@ export class TuiController {
|
|
|
1819
4540
|
return this.#detachedBlocked(operationId, ticket.intent);
|
|
1820
4541
|
const review = this.#storeOperationReview(intent, evidence, 'replace', ticket.returnRoute);
|
|
1821
4542
|
const result = { state: 'stale', operationId, review, ...this.#operationIdentity(intent) };
|
|
4543
|
+
this.#recordStaleAttempt(operationId, intent);
|
|
1822
4544
|
this.#result = result;
|
|
1823
4545
|
this.#publish();
|
|
1824
4546
|
return cloneFrozen(result);
|
|
1825
4547
|
}
|
|
1826
4548
|
#setBlocked(operationId, code, options) {
|
|
1827
|
-
|
|
1828
|
-
|
|
4549
|
+
if (!this.#operationDiagnostics.has(operationId)) {
|
|
4550
|
+
this.#captureThrownProjection(operationId, undefined, code, 'execute', options?.intent);
|
|
4551
|
+
}
|
|
4552
|
+
const message = options?.message ?? (code === 'codexCliNotFound'
|
|
4553
|
+
? '操作在插件写入前停止。未找到本机 Codex CLI。请检查 PATH,或安装 Codex CLI 或 Codex App 后重试。'
|
|
1829
4554
|
: code === 'codexSystemCliUnsupported'
|
|
1830
|
-
? '
|
|
1831
|
-
: code === '
|
|
1832
|
-
? '
|
|
1833
|
-
:
|
|
1834
|
-
? '
|
|
1835
|
-
:
|
|
1836
|
-
? '
|
|
1837
|
-
: code === '
|
|
1838
|
-
? '
|
|
1839
|
-
:
|
|
1840
|
-
? '写入已完成,但重新检查后原问题仍然存在。'
|
|
1841
|
-
: '操作未完成。请重新检查后重试。';
|
|
4555
|
+
? '操作在插件写入前停止。本机 Codex CLI 版本不受支持或无法确认。请升级或修复本机 Codex CLI 或 Codex App 后重试。'
|
|
4556
|
+
: code === 'portableSkillsCliInstallFailed'
|
|
4557
|
+
? 'Skills CLI 安装失败。请修改 Agent 或重试。'
|
|
4558
|
+
: options?.writeMayHaveCompleted
|
|
4559
|
+
? '写入可能已完成,当前无法确认。请查看刷新后的平台或问题状态。'
|
|
4560
|
+
: code === 'configResetStillPresent'
|
|
4561
|
+
? '重置执行后设置层仍然存在。请重新检查设置问题。'
|
|
4562
|
+
: code === 'issueStillPresent'
|
|
4563
|
+
? '写入已完成,但重新检查后原问题仍然存在。'
|
|
4564
|
+
: '操作未完成。请重新检查后重试。');
|
|
1842
4565
|
const result = {
|
|
1843
4566
|
state: 'blocked',
|
|
1844
4567
|
operationId,
|
|
@@ -1856,6 +4579,8 @@ export class TuiController {
|
|
|
1856
4579
|
this.#router.back();
|
|
1857
4580
|
this.#normalizeCurrentRoute();
|
|
1858
4581
|
}
|
|
4582
|
+
else if (options?.intent)
|
|
4583
|
+
this.#showResult(result, options.intent);
|
|
1859
4584
|
else
|
|
1860
4585
|
this.#router.replace({ name: 'result', operationId });
|
|
1861
4586
|
this.#publish();
|
|
@@ -1866,6 +4591,12 @@ export class TuiController {
|
|
|
1866
4591
|
operationKind: intent.kind,
|
|
1867
4592
|
...(intent.kind === 'sourceMutation' ? { sourceAction: intent.action } : {}),
|
|
1868
4593
|
...('pluginId' in intent ? { pluginId: intent.pluginId } : {}),
|
|
4594
|
+
...(intent.kind === 'portableInstall' ? {
|
|
4595
|
+
portableIntent: {
|
|
4596
|
+
scope: intent.scope,
|
|
4597
|
+
agentMode: intent.requestedAgents === undefined ? 'automatic' : 'explicit',
|
|
4598
|
+
},
|
|
4599
|
+
} : {}),
|
|
1869
4600
|
...(intent.kind === 'pluginWrite' && intent.originIssue
|
|
1870
4601
|
? { originIssue: intent.originIssue }
|
|
1871
4602
|
: {}),
|
|
@@ -1875,18 +4606,94 @@ export class TuiController {
|
|
|
1875
4606
|
if (this.#disposed)
|
|
1876
4607
|
return;
|
|
1877
4608
|
this.#disposed = true;
|
|
4609
|
+
this.#scopedPreparationAbort?.abort();
|
|
4610
|
+
this.#invalidatePortableResultRecheck();
|
|
1878
4611
|
this.#cancelReviewPreparation();
|
|
1879
4612
|
this.#cancelPortableRequest();
|
|
1880
4613
|
this.#cancelInstallPlacementRequest();
|
|
1881
4614
|
this.#catalogSourcesSession.dispose();
|
|
1882
4615
|
this.#abort.abort();
|
|
4616
|
+
this.#configSuggestions.clear();
|
|
1883
4617
|
this.#progressUnsubscribe?.();
|
|
1884
4618
|
this.#tickets.clear();
|
|
1885
4619
|
this.#phase = 'disposed';
|
|
1886
4620
|
this.#listeners.clear();
|
|
1887
4621
|
}
|
|
1888
4622
|
}
|
|
1889
|
-
function
|
|
4623
|
+
function configApplyResult(execution) {
|
|
4624
|
+
if (!execution || typeof execution !== 'object')
|
|
4625
|
+
return undefined;
|
|
4626
|
+
return execution.apply;
|
|
4627
|
+
}
|
|
4628
|
+
export function configApplyHasCompletedWork(apply) {
|
|
4629
|
+
return apply?.targetResults?.some((target) => target.partialDelivery || target.state === 'completed' && target.action !== 'skipped') === true
|
|
4630
|
+
|| apply?.commandResults?.some((result) => result.state === 'completed') === true;
|
|
4631
|
+
}
|
|
4632
|
+
function configApplyUnfinishedPlatforms(apply, reviewedPlatforms) {
|
|
4633
|
+
if (!apply || apply.commandResults?.length)
|
|
4634
|
+
return [];
|
|
4635
|
+
const completed = new Set(apply.targetResults.filter((result) => result.state === 'completed' || result.partialDelivery)
|
|
4636
|
+
.map((result) => result.target.platform));
|
|
4637
|
+
return [...new Set(apply.targetResults.filter((result) => (result.state === 'failed' || result.state === 'skipped' && result.errorCode)
|
|
4638
|
+
&& !completed.has(result.target.platform)
|
|
4639
|
+
&& (!reviewedPlatforms || reviewedPlatforms.includes(result.target.platform)))
|
|
4640
|
+
.map((result) => result.target.platform))];
|
|
4641
|
+
}
|
|
4642
|
+
function configApplyInterruptionMessage(code, retryTargets) {
|
|
4643
|
+
const nextStep = retryTargets.length > 0
|
|
4644
|
+
? '可为未完成平台重新准备确认。' : CONFIG_APPLY_MANUAL_RECOVERY;
|
|
4645
|
+
return code === 'processCleanupUnconfirmed'
|
|
4646
|
+
? `无法确认进程已清理。请先检查相关平台进程。${nextStep}`
|
|
4647
|
+
: `应用已中断。${nextStep}`;
|
|
4648
|
+
}
|
|
4649
|
+
const CONFIG_APPLY_MANUAL_RECOVERY = '请检查未完成位置后,从设置重新准备应用。';
|
|
4650
|
+
function configApplyTargets(apply) {
|
|
4651
|
+
return (apply?.targetResults ?? []).flatMap((entry) => {
|
|
4652
|
+
const target = entry.target;
|
|
4653
|
+
if (!target || !isPlatformTarget(target.platform)
|
|
4654
|
+
|| (target.scope !== 'user' && target.scope !== 'project')
|
|
4655
|
+
|| (entry.state !== 'completed' && entry.state !== 'failed' && entry.state !== 'skipped'))
|
|
4656
|
+
return [];
|
|
4657
|
+
let pluginId;
|
|
4658
|
+
if (typeof target.pluginId === 'string') {
|
|
4659
|
+
try {
|
|
4660
|
+
parsePluginId(target.pluginId);
|
|
4661
|
+
pluginId = target.pluginId;
|
|
4662
|
+
}
|
|
4663
|
+
catch {
|
|
4664
|
+
// Target identity can be unavailable in older receipts.
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
return [{
|
|
4668
|
+
...(pluginId ? { pluginId } : {}),
|
|
4669
|
+
platform: target.platform,
|
|
4670
|
+
scope: target.scope,
|
|
4671
|
+
state: entry.state === 'skipped' || entry.action === 'skipped' ? 'skipped'
|
|
4672
|
+
: entry.state === 'failed' ? 'failed'
|
|
4673
|
+
: entry.action === 'keep' ? 'kept' : 'completed',
|
|
4674
|
+
...(entry.partialDelivery ? { partialDelivery: true } : {}),
|
|
4675
|
+
...projectComponentDelivery(entry),
|
|
4676
|
+
...(typeof entry.errorCode === 'string'
|
|
4677
|
+
? { errorCode: safeDiagnosticCode(entry.errorCode, 'configApplyFailed') }
|
|
4678
|
+
: {}),
|
|
4679
|
+
}];
|
|
4680
|
+
});
|
|
4681
|
+
}
|
|
4682
|
+
function operationResultSummaryUnsafe(intent, execution) {
|
|
4683
|
+
if (intent.kind === 'catalogStorePrune') {
|
|
4684
|
+
const result = execution;
|
|
4685
|
+
return {
|
|
4686
|
+
code: result.overallState === 'succeeded' ? 'operationSucceeded' : 'operationPartial',
|
|
4687
|
+
message: result.overallState === 'succeeded'
|
|
4688
|
+
? `Catalog 本地存储清理完成;删除 ${result.deleted.length} 项。`
|
|
4689
|
+
: `Catalog 本地存储部分清理完成;删除 ${result.deleted.length} 项。`,
|
|
4690
|
+
messages: [
|
|
4691
|
+
result.deletedBytes === null ? '已删除大小未知。' : `已删除 ${result.deletedBytes} bytes。`,
|
|
4692
|
+
`保留 ${result.retained.length} 项。`,
|
|
4693
|
+
...(result.errors.length > 0 ? [`${result.errors.length} 项未能安全删除。`] : []),
|
|
4694
|
+
],
|
|
4695
|
+
};
|
|
4696
|
+
}
|
|
1890
4697
|
if (intent.kind === 'catalogSourcesRecovery') {
|
|
1891
4698
|
const result = execution;
|
|
1892
4699
|
return {
|
|
@@ -1918,14 +4725,14 @@ function operationResultSummary(intent, execution) {
|
|
|
1918
4725
|
: '来源配置已保存,但 Catalog 尚未启用。可在 TUI 中立即重试。'
|
|
1919
4726
|
: intent.action === 'repair' ? 'Catalog 已重新下载并修复。'
|
|
1920
4727
|
: intent.action === 'replaceDamaged' ? '损坏的 Active Catalog 已由当前候选替换。'
|
|
1921
|
-
: intent.action === 'recoverState' ? '
|
|
4728
|
+
: intent.action === 'recoverState' ? '目录版本状态已恢复,目标来源已启用。'
|
|
1922
4729
|
: updateActivated ? `Catalog 已更新到 ${generation.resolution.catalogVersion}。`
|
|
1923
4730
|
: intent.action === 'update' ? 'Catalog 已验证,Active 未变化。'
|
|
1924
4731
|
: 'Catalog 已验证并启用。',
|
|
1925
4732
|
messages: result.status === 'partial'
|
|
1926
4733
|
? [result.partialReason === 'primary'
|
|
1927
|
-
?
|
|
1928
|
-
:
|
|
4734
|
+
? `新的已启用版本可用;主来源保持不变。错误:${result.errorCode ?? 'catalogSourcePrimaryFailed'}`
|
|
4735
|
+
: `旧的已启用版本保持不变。错误:${result.errorCode ?? 'catalogGenerationRefreshFailed'}`]
|
|
1929
4736
|
: updateActivated
|
|
1930
4737
|
? ['已安装插件不会自动升级。', '已重新计算可用的插件升级。']
|
|
1931
4738
|
: intent.action === 'update'
|
|
@@ -1935,9 +4742,10 @@ function operationResultSummary(intent, execution) {
|
|
|
1935
4742
|
}
|
|
1936
4743
|
if (intent.kind === 'portableInstall') {
|
|
1937
4744
|
const receipt = execution;
|
|
1938
|
-
const verificationUnknown = receipt.
|
|
1939
|
-
|
|
1940
|
-
|
|
4745
|
+
const verificationUnknown = (receipt.verification.unknown?.length ?? 0) > 0
|
|
4746
|
+
|| receipt.failures.some((failure) => failure.code === 'portableSkillsCliVerificationFailed'
|
|
4747
|
+
&& receipt.verification.records.length === 0
|
|
4748
|
+
&& receipt.verification.missing.length === 0);
|
|
1941
4749
|
return {
|
|
1942
4750
|
code: receipt.status === 'succeeded' ? 'operationSucceeded'
|
|
1943
4751
|
: receipt.status === 'partial' ? 'operationPartial' : 'operationFailed',
|
|
@@ -1953,21 +4761,160 @@ function operationResultSummary(intent, execution) {
|
|
|
1953
4761
|
selectedSkills: receipt.selectedSkills.map((skill) => skill.name),
|
|
1954
4762
|
agentMode: receipt.agentMode,
|
|
1955
4763
|
requestedAgents: receipt.requestedAgents,
|
|
4764
|
+
...(receipt.attemptedTargets
|
|
4765
|
+
? { attemptedTargets: structuredClone(receipt.attemptedTargets) }
|
|
4766
|
+
: {}),
|
|
1956
4767
|
scope: receipt.scope,
|
|
1957
4768
|
materializationDigest: receipt.materializationDigest,
|
|
1958
4769
|
skillsCliVersion: receipt.skillsCliVersion,
|
|
4770
|
+
verified: receipt.verification.records,
|
|
1959
4771
|
missing: receipt.verification.missing,
|
|
4772
|
+
unknown: receipt.verification.unknown ?? [],
|
|
1960
4773
|
verificationUnknown,
|
|
1961
4774
|
...(receipt.failures[0]?.recovery ? { recovery: receipt.failures[0].recovery } : {}),
|
|
1962
4775
|
...(receipt.failures[0]?.code ? { failureCode: receipt.failures[0].code } : {}),
|
|
1963
4776
|
},
|
|
1964
4777
|
};
|
|
1965
4778
|
}
|
|
1966
|
-
if (intent.kind === '
|
|
4779
|
+
if (intent.kind === 'pluginWriteTask') {
|
|
4780
|
+
const taskExecution = execution;
|
|
4781
|
+
const failedTargets = pluginWriteTaskFailedRequestedTargets(taskExecution);
|
|
4782
|
+
const failedKeys = new Set(failedTargets.map(pluginWriteTaskTargetKey));
|
|
4783
|
+
const technicalTargets = taskExecution.targetResults.map((entry) => {
|
|
4784
|
+
const placement = taskExecution.dependencyPlan?.targets.find((target) => target.pluginId === entry.target.pluginId && target.platform === entry.target.platform
|
|
4785
|
+
&& (target.requestedScope ?? target.resolvedScope) === entry.target.scope);
|
|
4786
|
+
return {
|
|
4787
|
+
pluginId: entry.target.pluginId,
|
|
4788
|
+
platform: entry.target.platform,
|
|
4789
|
+
scope: entry.target.scope,
|
|
4790
|
+
state: entry.action === 'skipped' ? 'skipped'
|
|
4791
|
+
: entry.state === 'failed' ? 'failed'
|
|
4792
|
+
: entry.action === 'keep' ? 'kept' : 'completed',
|
|
4793
|
+
relation: entry.relation === 'requested' ? 'requested'
|
|
4794
|
+
: placement?.depth === 1 ? 'direct' : 'transitive',
|
|
4795
|
+
requiredBy: entry.requiredBy,
|
|
4796
|
+
...(entry.errorCode ? { errorCode: safeDiagnosticCode(entry.errorCode, 'writeFailed') } : {}),
|
|
4797
|
+
};
|
|
4798
|
+
});
|
|
4799
|
+
const blocked = new Map(taskExecution.taskPlan.blockedTargets.map((entry) => [
|
|
4800
|
+
pluginWriteTaskTargetKey(entry.target), entry,
|
|
4801
|
+
]));
|
|
4802
|
+
const relatedResults = (target) => {
|
|
4803
|
+
const key = pluginWriteTaskTargetKey(target);
|
|
4804
|
+
const source = taskExecution.sourceResults.find((candidate) => candidate.requestedTargets.some((requested) => pluginWriteTaskTargetKey(requested) === key));
|
|
4805
|
+
const related = source?.result.targetResults.filter((entry) => {
|
|
4806
|
+
const pluginId = entry.target.pluginId;
|
|
4807
|
+
if (!pluginId)
|
|
4808
|
+
return false;
|
|
4809
|
+
const executionKey = pluginWriteTaskTargetKey({
|
|
4810
|
+
pluginId,
|
|
4811
|
+
platform: entry.target.platform,
|
|
4812
|
+
scope: entry.target.scope,
|
|
4813
|
+
});
|
|
4814
|
+
if (executionKey === key)
|
|
4815
|
+
return true;
|
|
4816
|
+
if (taskExecution.taskPlan.causes.some((cause) => pluginWriteTaskTargetKey(cause.repairTarget) === executionKey
|
|
4817
|
+
&& cause.consumers.some((consumer) => pluginWriteTaskTargetKey(consumer) === key)))
|
|
4818
|
+
return true;
|
|
4819
|
+
const placement = source.result.dependencyPlan?.targets.find((candidate) => candidate.pluginId === pluginId && candidate.platform === entry.target.platform
|
|
4820
|
+
&& (candidate.requestedScope ?? candidate.resolvedScope) === entry.target.scope);
|
|
4821
|
+
return placement?.requiredByTargets?.some((consumer) => pluginWriteTaskTargetKey(consumer) === key) ?? false;
|
|
4822
|
+
}) ?? [];
|
|
4823
|
+
const targetResults = related.map((entry) => {
|
|
4824
|
+
const placement = source?.result.dependencyPlan?.targets.find((candidate) => candidate.pluginId === entry.target.pluginId
|
|
4825
|
+
&& candidate.platform === entry.target.platform
|
|
4826
|
+
&& (candidate.requestedScope ?? candidate.resolvedScope) === entry.target.scope);
|
|
4827
|
+
return {
|
|
4828
|
+
pluginId: entry.target.pluginId,
|
|
4829
|
+
platform: entry.target.platform,
|
|
4830
|
+
scope: entry.target.scope,
|
|
4831
|
+
state: entry.action === 'skipped' ? 'skipped'
|
|
4832
|
+
: entry.state === 'failed' ? 'failed'
|
|
4833
|
+
: entry.action === 'keep' ? 'kept' : 'completed',
|
|
4834
|
+
relation: entry.relation === 'requested' ? 'requested'
|
|
4835
|
+
: placement?.depth === 1 ? 'direct' : 'transitive',
|
|
4836
|
+
...(entry.errorCode ? { errorCode: safeDiagnosticCode(entry.errorCode, 'writeFailed') } : {}),
|
|
4837
|
+
};
|
|
4838
|
+
});
|
|
4839
|
+
if (blocked.has(key) && !targetResults.some((entry) => entry.pluginId === target.pluginId && entry.platform === target.platform
|
|
4840
|
+
&& entry.scope === target.scope)) {
|
|
4841
|
+
targetResults.unshift({
|
|
4842
|
+
pluginId: target.pluginId,
|
|
4843
|
+
platform: target.platform,
|
|
4844
|
+
scope: target.scope,
|
|
4845
|
+
state: 'skipped',
|
|
4846
|
+
relation: 'requested',
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4849
|
+
const hasFailed = targetResults.some((entry) => entry.state === 'failed' || entry.state === 'skipped');
|
|
4850
|
+
const hasCompleted = targetResults.some((entry) => entry.state === 'completed' || entry.state === 'kept');
|
|
4851
|
+
const state = blocked.has(key) ? 'blocked'
|
|
4852
|
+
: !source ? 'notStarted'
|
|
4853
|
+
: hasFailed && hasCompleted ? 'partial'
|
|
4854
|
+
: hasFailed || failedKeys.has(key) ? 'failed'
|
|
4855
|
+
: targetResults.length > 0 && targetResults.every((entry) => entry.state === 'kept')
|
|
4856
|
+
? 'kept' : targetResults.length > 0 ? 'completed' : 'notStarted';
|
|
4857
|
+
return { state, targets: targetResults };
|
|
4858
|
+
};
|
|
4859
|
+
const roots = [...new Set(taskExecution.taskPlan.requestedTargets
|
|
4860
|
+
.map((target) => target.pluginId))].map((pluginId) => {
|
|
4861
|
+
const requestedTargets = taskExecution.taskPlan.requestedTargets.filter((target) => target.pluginId === pluginId);
|
|
4862
|
+
const positions = requestedTargets.map((target) => relatedResults(target));
|
|
4863
|
+
const successfulPositions = positions.filter((position) => position.state === 'completed' || position.state === 'kept');
|
|
4864
|
+
const state = successfulPositions.length > 0
|
|
4865
|
+
? successfulPositions.length === positions.length
|
|
4866
|
+
? positions.every((position) => position.state === 'kept') ? 'kept' : 'completed'
|
|
4867
|
+
: 'partial'
|
|
4868
|
+
: positions.some((position) => position.state === 'failed' || position.state === 'partial')
|
|
4869
|
+
? 'failed'
|
|
4870
|
+
: positions.some((position) => position.state === 'notStarted') ? 'notStarted' : 'blocked';
|
|
4871
|
+
const targets = [...new Map(positions.flatMap((position) => position.targets).map((target) => [[
|
|
4872
|
+
target.pluginId ?? '', target.platform, target.scope,
|
|
4873
|
+
].join('\0'), target])).values()];
|
|
4874
|
+
const causeKeys = [...new Set(taskExecution.taskPlan.causes.filter((cause) => cause.consumers.some((consumer) => consumer.pluginId === pluginId))
|
|
4875
|
+
.map((cause) => cause.causeKey))];
|
|
4876
|
+
return { pluginId, state, causeKeys, targets };
|
|
4877
|
+
});
|
|
4878
|
+
const retryTargets = canonicalPluginWriteTaskTargets(roots.flatMap((root) => root.state === 'failed' || root.state === 'partial' || root.state === 'notStarted'
|
|
4879
|
+
? failedTargets.filter((target) => target.pluginId === root.pluginId) : []));
|
|
4880
|
+
const completedCount = roots.filter((root) => root.state === 'completed'
|
|
4881
|
+
|| root.state === 'kept' || root.state === 'partial').length;
|
|
4882
|
+
const failedCount = roots.filter((root) => root.state === 'failed' || root.state === 'partial'
|
|
4883
|
+
|| root.state === 'notStarted' || root.state === 'blocked').length;
|
|
4884
|
+
const commandFailed = taskExecution.commandResults?.some((result) => result.state !== 'completed') === true;
|
|
4885
|
+
const code = failedCount === 0 && !commandFailed ? 'operationSucceeded'
|
|
4886
|
+
: completedCount > 0 ? 'operationPartial' : 'operationFailed';
|
|
4887
|
+
return {
|
|
4888
|
+
code,
|
|
4889
|
+
message: code === 'operationSucceeded' ? '任务已完成。'
|
|
4890
|
+
: code === 'operationPartial' ? '任务只完成了一部分。' : '任务没有完成。',
|
|
4891
|
+
warnings: taskExecution.warnings,
|
|
4892
|
+
recoveryActions: [...new Set([
|
|
4893
|
+
...taskExecution.targetResults.flatMap((entry) => entry.recoveryActions ?? []),
|
|
4894
|
+
...(taskExecution.commandResults ?? []).flatMap((result) => result.recoveryActions),
|
|
4895
|
+
])],
|
|
4896
|
+
...(taskExecution.commandResults ? { commandResults: taskExecution.commandResults } : {}),
|
|
4897
|
+
...(taskExecution.operationPlan?.planFingerprint
|
|
4898
|
+
? { planFingerprint: taskExecution.operationPlan.planFingerprint } : {}),
|
|
4899
|
+
task: {
|
|
4900
|
+
goal: intent.goal,
|
|
4901
|
+
requestedTargets: taskExecution.taskPlan.requestedTargets,
|
|
4902
|
+
rootResults: roots,
|
|
4903
|
+
...(retryTargets.length > 0 ? { retryTargets } : {}),
|
|
4904
|
+
blockedTargets: taskExecution.taskPlan.blockedTargets,
|
|
4905
|
+
},
|
|
4906
|
+
targets: technicalTargets,
|
|
4907
|
+
};
|
|
4908
|
+
}
|
|
4909
|
+
if (intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch') {
|
|
1967
4910
|
const command = intent.action === 'refreshAndSync' ? 'sync' : intent.action;
|
|
1968
4911
|
const rawExecution = typeof execution === 'object' && execution !== null
|
|
1969
4912
|
? execution
|
|
1970
4913
|
: {};
|
|
4914
|
+
const requestedPluginIds = intent.kind === 'pluginWriteBatch'
|
|
4915
|
+
? canonicalPluginIds(execution.requestedPluginIds ?? [])
|
|
4916
|
+
: [intent.pluginId];
|
|
4917
|
+
const fallbackPluginId = requestedPluginIds[0] ?? 'unknown/plugin';
|
|
1971
4918
|
const normalizedTargetResults = Array.isArray(rawExecution.targetResults)
|
|
1972
4919
|
? rawExecution.targetResults.map((candidate) => {
|
|
1973
4920
|
if (typeof candidate !== 'object' || candidate === null)
|
|
@@ -1984,7 +4931,7 @@ function operationResultSummary(intent, execution) {
|
|
|
1984
4931
|
...rawTarget,
|
|
1985
4932
|
...(pluginId ? { pluginId } : {}),
|
|
1986
4933
|
pluginName: typeof rawTarget.pluginName === 'string'
|
|
1987
|
-
? rawTarget.pluginName : pluginNameFromId(pluginId ??
|
|
4934
|
+
? rawTarget.pluginName : pluginNameFromId(pluginId ?? fallbackPluginId),
|
|
1988
4935
|
},
|
|
1989
4936
|
action: typeof entry.action === 'string'
|
|
1990
4937
|
? entry.action : requestedIntentAction(command),
|
|
@@ -1995,17 +4942,67 @@ function operationResultSummary(intent, execution) {
|
|
|
1995
4942
|
...rawExecution,
|
|
1996
4943
|
...(normalizedTargetResults ? { targetResults: normalizedTargetResults } : {}),
|
|
1997
4944
|
platforms: Array.isArray(rawExecution.platforms) ? rawExecution.platforms : [],
|
|
1998
|
-
plugins: Array.isArray(rawExecution.plugins) ? rawExecution.plugins :
|
|
4945
|
+
plugins: Array.isArray(rawExecution.plugins) ? rawExecution.plugins : requestedPluginIds,
|
|
1999
4946
|
warnings: Array.isArray(rawExecution.warnings) ? rawExecution.warnings : [],
|
|
2000
4947
|
});
|
|
2001
4948
|
const result = buildOperationResultModel(receipt);
|
|
2002
|
-
const requestedIds = new Set(receipt.requestedPluginIds ??
|
|
4949
|
+
const requestedIds = new Set(receipt.requestedPluginIds ?? requestedPluginIds);
|
|
4950
|
+
const retryTargets = intent.kind === 'pluginWriteBatch'
|
|
4951
|
+
? pluginWriteBatchFailedRequestedTargets(execution)
|
|
4952
|
+
: [];
|
|
4953
|
+
const failedRequestedPluginIds = canonicalPluginIds(retryTargets.map((target) => target.pluginId));
|
|
4954
|
+
const requestedTargetKeys = intent.kind === 'pluginWriteBatch'
|
|
4955
|
+
? new Set(execution.groupResults.flatMap((group) => {
|
|
4956
|
+
const roots = new Set(group.requestedPluginIds);
|
|
4957
|
+
return group.result.targetResults.flatMap((entry) => entry.target.pluginId
|
|
4958
|
+
&& roots.has(entry.target.pluginId)
|
|
4959
|
+
&& entry.target.scope === group.scope
|
|
4960
|
+
&& (group.platform === 'both' || entry.target.platform === group.platform)
|
|
4961
|
+
? [[entry.target.pluginId, entry.target.platform, entry.target.scope].join('\0')]
|
|
4962
|
+
: []);
|
|
4963
|
+
}))
|
|
4964
|
+
: new Set();
|
|
4965
|
+
const rootResults = intent.kind === 'pluginWriteBatch'
|
|
4966
|
+
? requestedPluginIds.map((pluginId) => {
|
|
4967
|
+
const observed = (result.targetResults ?? []).flatMap((entry) => entry.target.pluginId === pluginId
|
|
4968
|
+
&& requestedTargetKeys.has([
|
|
4969
|
+
pluginId, entry.target.platform, entry.target.scope,
|
|
4970
|
+
].join('\0')) ? [{
|
|
4971
|
+
pluginId,
|
|
4972
|
+
platform: entry.target.platform,
|
|
4973
|
+
scope: entry.target.scope,
|
|
4974
|
+
state: entry.action === 'skipped' ? 'skipped'
|
|
4975
|
+
: entry.state === 'failed' ? 'failed'
|
|
4976
|
+
: entry.action === 'keep' ? 'kept' : 'completed',
|
|
4977
|
+
relation: 'requested',
|
|
4978
|
+
...(entry.errorCode
|
|
4979
|
+
? { errorCode: safeDiagnosticCode(entry.errorCode, 'writeFailed') }
|
|
4980
|
+
: {}),
|
|
4981
|
+
}] : []);
|
|
4982
|
+
const targets = [...new Map([
|
|
4983
|
+
...retryTargets.filter((target) => target.pluginId === pluginId).map((target) => ({
|
|
4984
|
+
...target,
|
|
4985
|
+
state: 'skipped',
|
|
4986
|
+
relation: 'requested',
|
|
4987
|
+
})),
|
|
4988
|
+
...observed,
|
|
4989
|
+
].map((target) => [[target.pluginId, target.platform, target.scope].join('\0'), target]))
|
|
4990
|
+
.values()];
|
|
4991
|
+
const completed = targets.filter((target) => target.state === 'completed' || target.state === 'kept').length;
|
|
4992
|
+
const failed = targets.length - completed;
|
|
4993
|
+
const state = completed > 0
|
|
4994
|
+
? failed > 0 ? 'partial'
|
|
4995
|
+
: targets.every((target) => target.state === 'kept') ? 'kept' : 'completed'
|
|
4996
|
+
: failed > 0 ? 'failed' : 'notStarted';
|
|
4997
|
+
return { pluginId, state, targets };
|
|
4998
|
+
})
|
|
4999
|
+
: [];
|
|
2003
5000
|
return {
|
|
2004
5001
|
code: result.state === 'succeeded' ? 'operationSucceeded'
|
|
2005
5002
|
: result.state === 'partial' ? 'operationPartial' : 'operationFailed',
|
|
2006
5003
|
message: result.state === 'succeeded' ? '操作已完成。'
|
|
2007
5004
|
: result.state === 'partial' ? '操作只完成了一部分。' : '操作结果无法确认。',
|
|
2008
|
-
pluginId: intent.pluginId,
|
|
5005
|
+
...(intent.kind === 'pluginWrite' ? { pluginId: intent.pluginId } : {}),
|
|
2009
5006
|
action: intent.action,
|
|
2010
5007
|
changes: result.changes,
|
|
2011
5008
|
warnings: result.warnings,
|
|
@@ -2014,10 +5011,19 @@ function operationResultSummary(intent, execution) {
|
|
|
2014
5011
|
messages: [
|
|
2015
5012
|
...result.warnings.map((warning) => `警告:${warning}`),
|
|
2016
5013
|
...result.recoveryActions.map((action) => `恢复:${action}`),
|
|
2017
|
-
...(intent.recoveryDescription
|
|
5014
|
+
...(intent.kind === 'pluginWrite' && intent.recoveryDescription
|
|
2018
5015
|
? [intent.recoveryDescription, `后续:${intent.scope === 'user' ? '当前项目' : '所有项目'} sync`]
|
|
2019
5016
|
: []),
|
|
2020
5017
|
],
|
|
5018
|
+
...(intent.kind === 'pluginWriteBatch' ? {
|
|
5019
|
+
batch: {
|
|
5020
|
+
requestedPluginIds,
|
|
5021
|
+
failedRequestedPluginIds,
|
|
5022
|
+
rootResults,
|
|
5023
|
+
retryTargets,
|
|
5024
|
+
groupCount: execution.groupResults.length,
|
|
5025
|
+
},
|
|
5026
|
+
} : {}),
|
|
2021
5027
|
targets: result.targetResults.map((entry) => ({
|
|
2022
5028
|
pluginId: entry.target.pluginId,
|
|
2023
5029
|
platform: entry.target.platform,
|
|
@@ -2029,68 +5035,155 @@ function operationResultSummary(intent, execution) {
|
|
|
2029
5035
|
relation: entry.relation === 'requested' ? 'requested'
|
|
2030
5036
|
: entry.requiredBy.some((pluginId) => requestedIds.has(pluginId)) ? 'direct' : 'transitive',
|
|
2031
5037
|
requiredBy: entry.requiredBy,
|
|
2032
|
-
...(entry.errorCode
|
|
2033
|
-
|| entry.errorCode === 'codexSystemCliUnsupported'
|
|
2034
|
-
|| entry.errorCode === 'managedCodexAuthorizationRequired'
|
|
2035
|
-
|| entry.errorCode === 'managedCodexUnavailable'
|
|
2036
|
-
? { errorCode: entry.errorCode }
|
|
2037
|
-
: {}),
|
|
5038
|
+
...(entry.errorCode ? { errorCode: safeDiagnosticCode(entry.errorCode, 'writeFailed') } : {}),
|
|
2038
5039
|
})),
|
|
5040
|
+
...(result.commandResults ? { commandResults: result.commandResults } : {}),
|
|
5041
|
+
};
|
|
5042
|
+
}
|
|
5043
|
+
if (intent.kind === 'configSaveBatch') {
|
|
5044
|
+
const batch = execution;
|
|
5045
|
+
const applies = batch.groups.map((group) => configApplyResult(group.execution));
|
|
5046
|
+
const configDiagnostics = applies.flatMap((apply) => apply?.diagnostics ?? []);
|
|
5047
|
+
const commandResults = applies.flatMap((apply) => apply?.commandResults ?? []);
|
|
5048
|
+
const targets = [...new Map(applies.flatMap(configApplyTargets)
|
|
5049
|
+
.map((target) => [[target.pluginId ?? '', target.platform, target.scope].join('\0'), target])).values()];
|
|
5050
|
+
const savedCount = batch.groups.filter((group) => group.configSaved).length;
|
|
5051
|
+
const targetsUpdated = applies.some(configApplyHasCompletedWork);
|
|
5052
|
+
const configGroups = batch.groups.map((group, index) => ({
|
|
5053
|
+
scope: group.scope,
|
|
5054
|
+
platform: group.platform,
|
|
5055
|
+
configSaved: group.configSaved,
|
|
5056
|
+
applyRequested: group.applyRequested,
|
|
5057
|
+
applyStatus: group.applyStatus,
|
|
5058
|
+
...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
|
|
5059
|
+
...(group.status === 'notStarted' ? { notStarted: true } : {}),
|
|
5060
|
+
...(group.applyStatus === 'partial'
|
|
5061
|
+
|| group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
|
|
5062
|
+
? { retryTargets: configApplyUnfinishedPlatforms(applies[index]) } : {}),
|
|
5063
|
+
}));
|
|
5064
|
+
const retryScopes = configGroups.filter((group) => group.configSaved && (group.applyStatus === 'failed' || group.applyStatus === 'partial')
|
|
5065
|
+
&& group.errorCode !== 'invalidConfig' && group.retryTargets?.length !== 0);
|
|
5066
|
+
const invalidConfig = savedCount === batch.groups.length
|
|
5067
|
+
&& batch.groups.some((group) => group.configSaved && group.errorCode === 'invalidConfig')
|
|
5068
|
+
&& retryScopes.length === 0;
|
|
5069
|
+
const publicWarnings = [...new Set(batch.groups.flatMap((group) => {
|
|
5070
|
+
if (!group.execution || typeof group.execution !== 'object'
|
|
5071
|
+
|| !Array.isArray(group.execution.warnings))
|
|
5072
|
+
return [];
|
|
5073
|
+
return group.execution.warnings.filter((warning) => typeof warning === 'string' && warning.startsWith('projectConfigShareabilityUnverified:'));
|
|
5074
|
+
}))];
|
|
5075
|
+
const otherProjectsMayRequireSync = batch.groups.some((group) => group.scope === 'user' && group.execution && typeof group.execution === 'object'
|
|
5076
|
+
&& group.execution.otherProjectsMayRequireSync === true);
|
|
5077
|
+
return {
|
|
5078
|
+
code: batch.status === 'succeeded' ? 'operationSucceeded'
|
|
5079
|
+
: batch.status === 'partial' || targetsUpdated ? 'operationPartial' : 'operationFailed',
|
|
5080
|
+
message: invalidConfig
|
|
5081
|
+
? '设置已保存,但没有应用。当前配置仍无效。'
|
|
5082
|
+
: batch.status !== 'succeeded'
|
|
5083
|
+
? savedCount > 0
|
|
5084
|
+
? `已保存 ${savedCount} 个设置层;${targetsUpdated ? '部分插件目标已更新。' : '部分步骤未完成。'}`
|
|
5085
|
+
: '设置没有保存。'
|
|
5086
|
+
: '设置已保存。',
|
|
5087
|
+
pluginId: intent.pluginId,
|
|
5088
|
+
configContext: intent.context ?? 'user',
|
|
5089
|
+
configApplyRetryAvailable: retryScopes.length > 0,
|
|
5090
|
+
...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
|
|
5091
|
+
configApplied: intent.apply
|
|
5092
|
+
? targetsUpdated || batch.groups.some((group) => group.applyStatus === 'succeeded')
|
|
5093
|
+
: false,
|
|
5094
|
+
configGroups,
|
|
5095
|
+
...(targets.length > 0 ? { configTargets: targets } : {}),
|
|
5096
|
+
...(configDiagnostics.length ? { configDiagnostics } : {}),
|
|
5097
|
+
commandResults,
|
|
5098
|
+
...(commandResults.length ? { recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
|
|
5099
|
+
messages: [
|
|
5100
|
+
...configGroups.map((group) => {
|
|
5101
|
+
const label = group.platform ? `${group.platform} 平台配置` : '公共配置';
|
|
5102
|
+
if (group.notStarted)
|
|
5103
|
+
return `${label}尚未保存。`;
|
|
5104
|
+
return group.configSaved
|
|
5105
|
+
? `${label}已保存${group.errorCode === 'invalidConfig'
|
|
5106
|
+
? ',但当前配置无效,未应用'
|
|
5107
|
+
: group.applyStatus === 'partial' ? ',部分插件目标已更新'
|
|
5108
|
+
: group.applyStatus === 'failed' ? ',但应用失败' : ''}。`
|
|
5109
|
+
: `${label}保存失败。`;
|
|
5110
|
+
}),
|
|
5111
|
+
...configGroups.flatMap((group) => group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
|
|
5112
|
+
? [configApplyInterruptionMessage(group.errorCode, group.retryTargets ?? [])]
|
|
5113
|
+
: group.retryTargets?.length === 0 ? [CONFIG_APPLY_MANUAL_RECOVERY] : []),
|
|
5114
|
+
...publicWarnings.map((warning) => `警告:${warning}`),
|
|
5115
|
+
...(otherProjectsMayRequireSync
|
|
5116
|
+
? ['提示:其它项目没有被扫描,可能需要在对应项目目录中运行 aw plugin sync --context project。']
|
|
5117
|
+
: []),
|
|
5118
|
+
],
|
|
2039
5119
|
};
|
|
2040
5120
|
}
|
|
2041
5121
|
if (intent.kind === 'configSave' || intent.kind === 'configReset') {
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
const targets = rawTargets.flatMap((entry) => {
|
|
2047
|
-
const target = typeof entry.target === 'object' && entry.target !== null
|
|
2048
|
-
? entry.target
|
|
2049
|
-
: entry;
|
|
2050
|
-
if ((target.platform !== 'codex' && target.platform !== 'claude')
|
|
2051
|
-
|| (target.scope !== 'user' && target.scope !== 'project')
|
|
2052
|
-
|| (entry.state !== 'completed' && entry.state !== 'failed'))
|
|
2053
|
-
return [];
|
|
2054
|
-
return [{
|
|
2055
|
-
...(typeof target.pluginId === 'string' ? { pluginId: target.pluginId } : {}),
|
|
2056
|
-
platform: target.platform,
|
|
2057
|
-
scope: target.scope,
|
|
2058
|
-
state: entry.action === 'skipped' ? 'skipped'
|
|
2059
|
-
: entry.state === 'failed' ? 'failed'
|
|
2060
|
-
: entry.action === 'keep' ? 'kept'
|
|
2061
|
-
: entry.state,
|
|
2062
|
-
}];
|
|
2063
|
-
});
|
|
5122
|
+
const apply = configApplyResult(execution);
|
|
5123
|
+
const configDiagnostics = apply?.diagnostics ?? [];
|
|
5124
|
+
const commandResults = apply?.commandResults ?? [];
|
|
5125
|
+
const targets = configApplyTargets(apply);
|
|
2064
5126
|
const overallState = typeof execution === 'object' && execution !== null
|
|
2065
5127
|
? execution.overallState
|
|
2066
5128
|
: undefined;
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
: undefined;
|
|
2070
|
-
const invalidConfig = applySkippedReason === 'invalidConfig';
|
|
5129
|
+
const applyState = apply?.state;
|
|
5130
|
+
const invalidConfig = apply?.state === 'unavailable' && apply.reason === 'invalidConfig';
|
|
2071
5131
|
const resetDisposition = typeof execution === 'object' && execution !== null
|
|
2072
5132
|
? execution.resetDisposition
|
|
2073
5133
|
: undefined;
|
|
2074
5134
|
const quarantineBasename = typeof execution === 'object' && execution !== null
|
|
2075
5135
|
? execution.quarantineBasename
|
|
2076
5136
|
: undefined;
|
|
5137
|
+
const publicWarnings = typeof execution === 'object' && execution !== null
|
|
5138
|
+
&& Array.isArray(execution.warnings)
|
|
5139
|
+
? execution.warnings.filter((warning) => typeof warning === 'string'
|
|
5140
|
+
&& warning.startsWith('projectConfigShareabilityUnverified:'))
|
|
5141
|
+
: [];
|
|
5142
|
+
const otherProjectsMayRequireSync = typeof execution === 'object' && execution !== null
|
|
5143
|
+
&& execution.otherProjectsMayRequireSync === true;
|
|
5144
|
+
const publicMessages = [
|
|
5145
|
+
...publicWarnings.map((warning) => `警告:${warning}`),
|
|
5146
|
+
...(otherProjectsMayRequireSync
|
|
5147
|
+
? ['提示:其它项目没有被扫描,可能需要在对应项目目录中运行 aw plugin sync --context project。']
|
|
5148
|
+
: []),
|
|
5149
|
+
];
|
|
2077
5150
|
const partial = overallState === 'partial'
|
|
5151
|
+
|| applyState === 'partial'
|
|
5152
|
+
|| applyState === 'unavailable'
|
|
2078
5153
|
|| invalidConfig
|
|
2079
5154
|
|| targets.some((target) => target.state === 'failed' || target.state === 'skipped')
|
|
2080
5155
|
&& targets.some((target) => target.state === 'completed' || target.state === 'kept');
|
|
2081
5156
|
const failed = overallState === 'failed'
|
|
2082
5157
|
|| (targets.length > 0
|
|
2083
5158
|
&& targets.every((target) => target.state === 'failed' || target.state === 'skipped'));
|
|
5159
|
+
const retryApply = intent.kind === 'configSave' && intent.retryApply === true;
|
|
5160
|
+
const applied = applyState === 'succeeded' || configApplyHasCompletedWork(apply);
|
|
5161
|
+
const retryable = intent.kind === 'configSave'
|
|
5162
|
+
&& intent.apply && !invalidConfig && (applyState === 'partial' || applyState === 'unavailable');
|
|
5163
|
+
const retryTargets = retryable && intent.kind === 'configSave'
|
|
5164
|
+
? applied || commandResults.some((result) => result.state === 'partial')
|
|
5165
|
+
? configApplyUnfinishedPlatforms(apply, intent.targets)
|
|
5166
|
+
: intent.targets
|
|
5167
|
+
: undefined;
|
|
5168
|
+
if (retryable && retryTargets?.length === 0 && !(execution instanceof ConfigApplyInterruptedError)) {
|
|
5169
|
+
publicMessages.push(CONFIG_APPLY_MANUAL_RECOVERY);
|
|
5170
|
+
}
|
|
2084
5171
|
return {
|
|
2085
5172
|
code: failed || partial ? 'operationPartial' : 'operationSucceeded',
|
|
2086
|
-
message:
|
|
2087
|
-
|
|
5173
|
+
message: retryApply
|
|
5174
|
+
? invalidConfig ? '当前配置仍无效。请返回设置修复。'
|
|
5175
|
+
: failed || partial ? applied ? '部分插件内容已就绪。' : '插件设置应用未完成。'
|
|
5176
|
+
: applied ? '已应用已保存的设置。' : '应用检查完成。'
|
|
5177
|
+
: invalidConfig ? '设置已保存,但没有应用。当前配置仍无效。'
|
|
5178
|
+
: failed || partial ? '设置已保存,但插件内容重新应用失败或部分失败。' : '操作已完成。',
|
|
2088
5179
|
pluginId: intent.pluginId,
|
|
2089
|
-
configScope: intent.
|
|
2090
|
-
configApplyRetryAvailable:
|
|
2091
|
-
|
|
5180
|
+
configScope: 'user', configPlatform: intent.platform, configContext: intent.context ?? 'user',
|
|
5181
|
+
configApplyRetryAvailable: retryable && retryTargets?.length !== 0,
|
|
5182
|
+
...(retryTargets ? { configApplyRetryTargets: retryTargets } : {}),
|
|
5183
|
+
...(retryApply ? { configRetryApply: true } : {}),
|
|
5184
|
+
...(publicMessages.length > 0 ? { messages: publicMessages } : {}),
|
|
2092
5185
|
...(intent.kind === 'configSave'
|
|
2093
|
-
? { configApplied:
|
|
5186
|
+
? { configApplied: applied }
|
|
2094
5187
|
: invalidConfig ? { configApplied: false } : {}),
|
|
2095
5188
|
...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
|
|
2096
5189
|
...(intent.kind === 'configReset'
|
|
@@ -2104,7 +5197,10 @@ function operationResultSummary(intent, execution) {
|
|
|
2104
5197
|
? { quarantineBasename } : {}),
|
|
2105
5198
|
}
|
|
2106
5199
|
: {}),
|
|
2107
|
-
...(targets.length > 0 ? { targets } : {}),
|
|
5200
|
+
...(targets.length > 0 ? { configTargets: targets } : {}),
|
|
5201
|
+
...(configDiagnostics.length ? { configDiagnostics } : {}),
|
|
5202
|
+
...(commandResults.length > 0 ? { commandResults,
|
|
5203
|
+
recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
|
|
2108
5204
|
};
|
|
2109
5205
|
}
|
|
2110
5206
|
const sourceWarnings = intent.kind === 'sourceMutation'
|
|
@@ -2117,4 +5213,7 @@ function operationResultSummary(intent, execution) {
|
|
|
2117
5213
|
...(sourceWarnings.length > 0 ? { messages: sourceWarnings } : {}),
|
|
2118
5214
|
};
|
|
2119
5215
|
}
|
|
5216
|
+
function operationResultSummary(intent, execution) {
|
|
5217
|
+
return sanitizeOperationSummary(operationResultSummaryUnsafe(intent, execution), collectOperationSensitiveValues(intent));
|
|
5218
|
+
}
|
|
2120
5219
|
//# sourceMappingURL=controller.js.map
|