@moorline/core 0.0.1
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/app/bootstrap/apiAdapterPackageLoader.d.ts +21 -0
- package/dist/app/bootstrap/apiAdapterPackageLoader.js +143 -0
- package/dist/app/bootstrap/apiAdapterPackageLoader.js.map +1 -0
- package/dist/app/bootstrap/officialCatalog.d.ts +1 -0
- package/dist/app/bootstrap/officialCatalog.js +2 -0
- package/dist/app/bootstrap/officialCatalog.js.map +1 -0
- package/dist/app/bootstrap/operatorPackageService.d.ts +79 -0
- package/dist/app/bootstrap/operatorPackageService.js +1025 -0
- package/dist/app/bootstrap/operatorPackageService.js.map +1 -0
- package/dist/app/bootstrap/providerPackageLoader.d.ts +12 -0
- package/dist/app/bootstrap/providerPackageLoader.js +139 -0
- package/dist/app/bootstrap/providerPackageLoader.js.map +1 -0
- package/dist/app/bootstrap/runtimeBootstrap.d.ts +12 -0
- package/dist/app/bootstrap/runtimeBootstrap.js +46 -0
- package/dist/app/bootstrap/runtimeBootstrap.js.map +1 -0
- package/dist/app/bootstrap/transportPackageLoader.d.ts +23 -0
- package/dist/app/bootstrap/transportPackageLoader.js +149 -0
- package/dist/app/bootstrap/transportPackageLoader.js.map +1 -0
- package/dist/app/control-api/services/actions.d.ts +140 -0
- package/dist/app/control-api/services/actions.js +312 -0
- package/dist/app/control-api/services/actions.js.map +1 -0
- package/dist/app/control-api/services/controlPlane.d.ts +245 -0
- package/dist/app/control-api/services/controlPlane.js +301 -0
- package/dist/app/control-api/services/controlPlane.js.map +1 -0
- package/dist/app/control-api/services/runtimeHost.d.ts +61 -0
- package/dist/app/control-api/services/runtimeHost.js +117 -0
- package/dist/app/control-api/services/runtimeHost.js.map +1 -0
- package/dist/app/control-api/services/state.d.ts +19 -0
- package/dist/app/control-api/services/state.js +177 -0
- package/dist/app/control-api/services/state.js.map +1 -0
- package/dist/core/domain/memory/operatorMemoryService.d.ts +36 -0
- package/dist/core/domain/memory/operatorMemoryService.js +81 -0
- package/dist/core/domain/memory/operatorMemoryService.js.map +1 -0
- package/dist/core/domain/memory/pathSafety.d.ts +2 -0
- package/dist/core/domain/memory/pathSafety.js +36 -0
- package/dist/core/domain/memory/pathSafety.js.map +1 -0
- package/dist/core/domain/memory/retrieval/fileWalker.d.ts +1 -0
- package/dist/core/domain/memory/retrieval/fileWalker.js +31 -0
- package/dist/core/domain/memory/retrieval/fileWalker.js.map +1 -0
- package/dist/core/domain/memory/retrieval/indexTargets.d.ts +3 -0
- package/dist/core/domain/memory/retrieval/indexTargets.js +43 -0
- package/dist/core/domain/memory/retrieval/indexTargets.js.map +1 -0
- package/dist/core/domain/memory/retrieval/markdownChunker.d.ts +3 -0
- package/dist/core/domain/memory/retrieval/markdownChunker.js +77 -0
- package/dist/core/domain/memory/retrieval/markdownChunker.js.map +1 -0
- package/dist/core/domain/memory/retrieval/parse.d.ts +2 -0
- package/dist/core/domain/memory/retrieval/parse.js +28 -0
- package/dist/core/domain/memory/retrieval/parse.js.map +1 -0
- package/dist/core/domain/memory/retrieval/ranking.d.ts +11 -0
- package/dist/core/domain/memory/retrieval/ranking.js +63 -0
- package/dist/core/domain/memory/retrieval/ranking.js.map +1 -0
- package/dist/core/domain/memory/retrieval/schema.d.ts +2 -0
- package/dist/core/domain/memory/retrieval/schema.js +105 -0
- package/dist/core/domain/memory/retrieval/schema.js.map +1 -0
- package/dist/core/domain/memory/retrieval/scope.d.ts +20 -0
- package/dist/core/domain/memory/retrieval/scope.js +38 -0
- package/dist/core/domain/memory/retrieval/scope.js.map +1 -0
- package/dist/core/domain/memory/retrieval/tokenEmbedding.d.ts +4 -0
- package/dist/core/domain/memory/retrieval/tokenEmbedding.js +44 -0
- package/dist/core/domain/memory/retrieval/tokenEmbedding.js.map +1 -0
- package/dist/core/domain/memory/retrieval/types.d.ts +88 -0
- package/dist/core/domain/memory/retrieval/types.js +7 -0
- package/dist/core/domain/memory/retrieval/types.js.map +1 -0
- package/dist/core/domain/memory/retrieval.d.ts +4 -0
- package/dist/core/domain/memory/retrieval.js +398 -0
- package/dist/core/domain/memory/retrieval.js.map +1 -0
- package/dist/core/domain/memory/store.d.ts +28 -0
- package/dist/core/domain/memory/store.js +52 -0
- package/dist/core/domain/memory/store.js.map +1 -0
- package/dist/core/domain/missions/missionDraftSetup.d.ts +12 -0
- package/dist/core/domain/missions/missionDraftSetup.js +92 -0
- package/dist/core/domain/missions/missionDraftSetup.js.map +1 -0
- package/dist/core/domain/missions/missionHookService.d.ts +41 -0
- package/dist/core/domain/missions/missionHookService.js +161 -0
- package/dist/core/domain/missions/missionHookService.js.map +1 -0
- package/dist/core/domain/missions/missionHookValidation.d.ts +8 -0
- package/dist/core/domain/missions/missionHookValidation.js +59 -0
- package/dist/core/domain/missions/missionHookValidation.js.map +1 -0
- package/dist/core/domain/missions/missionRegistry.d.ts +55 -0
- package/dist/core/domain/missions/missionRegistry.js +204 -0
- package/dist/core/domain/missions/missionRegistry.js.map +1 -0
- package/dist/core/domain/missions/missionSchedule.d.ts +24 -0
- package/dist/core/domain/missions/missionSchedule.js +441 -0
- package/dist/core/domain/missions/missionSchedule.js.map +1 -0
- package/dist/core/domain/sessions/lifecycleOrchestration.d.ts +23 -0
- package/dist/core/domain/sessions/lifecycleOrchestration.js +18 -0
- package/dist/core/domain/sessions/lifecycleOrchestration.js.map +1 -0
- package/dist/core/domain/sessions/managedWorkerSessions.d.ts +3 -0
- package/dist/core/domain/sessions/managedWorkerSessions.js +4 -0
- package/dist/core/domain/sessions/managedWorkerSessions.js.map +1 -0
- package/dist/core/domain/sessions/runtimeWorkManagementService.d.ts +129 -0
- package/dist/core/domain/sessions/runtimeWorkManagementService.js +627 -0
- package/dist/core/domain/sessions/runtimeWorkManagementService.js.map +1 -0
- package/dist/core/domain/sessions/sessionLifecycleService.d.ts +21 -0
- package/dist/core/domain/sessions/sessionLifecycleService.js +76 -0
- package/dist/core/domain/sessions/sessionLifecycleService.js.map +1 -0
- package/dist/core/domain/sessions/sessionState.d.ts +34 -0
- package/dist/core/domain/sessions/sessionState.js +154 -0
- package/dist/core/domain/sessions/sessionState.js.map +1 -0
- package/dist/core/domain/sessions/workManagement/managedSessionLimit.d.ts +3 -0
- package/dist/core/domain/sessions/workManagement/managedSessionLimit.js +15 -0
- package/dist/core/domain/sessions/workManagement/managedSessionLimit.js.map +1 -0
- package/dist/core/domain/sessions/workManagement/spaceNames.d.ts +2 -0
- package/dist/core/domain/sessions/workManagement/spaceNames.js +15 -0
- package/dist/core/domain/sessions/workManagement/spaceNames.js.map +1 -0
- package/dist/core/extension/capabilities/capabilities.d.ts +8 -0
- package/dist/core/extension/capabilities/capabilities.js +40 -0
- package/dist/core/extension/capabilities/capabilities.js.map +1 -0
- package/dist/core/extension/packages/archiveExtraction.d.ts +1 -0
- package/dist/core/extension/packages/archiveExtraction.js +194 -0
- package/dist/core/extension/packages/archiveExtraction.js.map +1 -0
- package/dist/core/extension/packages/npmRegistryClient.d.ts +24 -0
- package/dist/core/extension/packages/npmRegistryClient.js +261 -0
- package/dist/core/extension/packages/npmRegistryClient.js.map +1 -0
- package/dist/core/extension/packages/officialArchiveResolver.d.ts +2 -0
- package/dist/core/extension/packages/officialArchiveResolver.js +51 -0
- package/dist/core/extension/packages/officialArchiveResolver.js.map +1 -0
- package/dist/core/extension/packages/officialCatalog.d.ts +9 -0
- package/dist/core/extension/packages/officialCatalog.js +198 -0
- package/dist/core/extension/packages/officialCatalog.js.map +1 -0
- package/dist/core/extension/packages/packageActivation.d.ts +21 -0
- package/dist/core/extension/packages/packageActivation.js +81 -0
- package/dist/core/extension/packages/packageActivation.js.map +1 -0
- package/dist/core/extension/packages/packageApplyPlanner.d.ts +4 -0
- package/dist/core/extension/packages/packageApplyPlanner.js +79 -0
- package/dist/core/extension/packages/packageApplyPlanner.js.map +1 -0
- package/dist/core/extension/packages/packageBundleRoot.d.ts +1 -0
- package/dist/core/extension/packages/packageBundleRoot.js +34 -0
- package/dist/core/extension/packages/packageBundleRoot.js.map +1 -0
- package/dist/core/extension/packages/packageConfigSchema.d.ts +7 -0
- package/dist/core/extension/packages/packageConfigSchema.js +86 -0
- package/dist/core/extension/packages/packageConfigSchema.js.map +1 -0
- package/dist/core/extension/packages/packageDependencyResolver.d.ts +13 -0
- package/dist/core/extension/packages/packageDependencyResolver.js +128 -0
- package/dist/core/extension/packages/packageDependencyResolver.js.map +1 -0
- package/dist/core/extension/packages/packageDistroMetadata.d.ts +14 -0
- package/dist/core/extension/packages/packageDistroMetadata.js +153 -0
- package/dist/core/extension/packages/packageDistroMetadata.js.map +1 -0
- package/dist/core/extension/packages/packageInstaller.d.ts +27 -0
- package/dist/core/extension/packages/packageInstaller.js +269 -0
- package/dist/core/extension/packages/packageInstaller.js.map +1 -0
- package/dist/core/extension/packages/packageInventoryStore.d.ts +25 -0
- package/dist/core/extension/packages/packageInventoryStore.js +398 -0
- package/dist/core/extension/packages/packageInventoryStore.js.map +1 -0
- package/dist/core/extension/packages/packageManifest.d.ts +15 -0
- package/dist/core/extension/packages/packageManifest.js +65 -0
- package/dist/core/extension/packages/packageManifest.js.map +1 -0
- package/dist/core/extension/packages/packageRegistryBlocklist.d.ts +10 -0
- package/dist/core/extension/packages/packageRegistryBlocklist.js +13 -0
- package/dist/core/extension/packages/packageRegistryBlocklist.js.map +1 -0
- package/dist/core/extension/packages/packageRegistryService.d.ts +22 -0
- package/dist/core/extension/packages/packageRegistryService.js +123 -0
- package/dist/core/extension/packages/packageRegistryService.js.map +1 -0
- package/dist/core/extension/packages/packageRegistryTypes.d.ts +33 -0
- package/dist/core/extension/packages/packageRegistryTypes.js +2 -0
- package/dist/core/extension/packages/packageRegistryTypes.js.map +1 -0
- package/dist/core/extension/packages/packageSource.d.ts +8 -0
- package/dist/core/extension/packages/packageSource.js +116 -0
- package/dist/core/extension/packages/packageSource.js.map +1 -0
- package/dist/core/extension/packages/packageSourceLimits.d.ts +5 -0
- package/dist/core/extension/packages/packageSourceLimits.js +6 -0
- package/dist/core/extension/packages/packageSourceLimits.js.map +1 -0
- package/dist/core/extension/packages/packageValidation.d.ts +2 -0
- package/dist/core/extension/packages/packageValidation.js +67 -0
- package/dist/core/extension/packages/packageValidation.js.map +1 -0
- package/dist/core/extension/packages/packageVersionResolver.d.ts +28 -0
- package/dist/core/extension/packages/packageVersionResolver.js +78 -0
- package/dist/core/extension/packages/packageVersionResolver.js.map +1 -0
- package/dist/core/extension/packages/remoteArchiveDownloader.d.ts +10 -0
- package/dist/core/extension/packages/remoteArchiveDownloader.js +156 -0
- package/dist/core/extension/packages/remoteArchiveDownloader.js.map +1 -0
- package/dist/core/extension/packages/runtimeStartability.d.ts +16 -0
- package/dist/core/extension/packages/runtimeStartability.js +237 -0
- package/dist/core/extension/packages/runtimeStartability.js.map +1 -0
- package/dist/core/extension/plugins/pluginHost.d.ts +50 -0
- package/dist/core/extension/plugins/pluginHost.js +303 -0
- package/dist/core/extension/plugins/pluginHost.js.map +1 -0
- package/dist/core/extension/plugins/pluginId.d.ts +2 -0
- package/dist/core/extension/plugins/pluginId.js +8 -0
- package/dist/core/extension/plugins/pluginId.js.map +1 -0
- package/dist/core/extension/plugins/pluginManifest.d.ts +3 -0
- package/dist/core/extension/plugins/pluginManifest.js +17 -0
- package/dist/core/extension/plugins/pluginManifest.js.map +1 -0
- package/dist/core/extension/plugins/runtimePluginLoader.d.ts +7 -0
- package/dist/core/extension/plugins/runtimePluginLoader.js +160 -0
- package/dist/core/extension/plugins/runtimePluginLoader.js.map +1 -0
- package/dist/core/extension/skills/skillRegistry.d.ts +21 -0
- package/dist/core/extension/skills/skillRegistry.js +233 -0
- package/dist/core/extension/skills/skillRegistry.js.map +1 -0
- package/dist/core/extension/skills/skillWriter.d.ts +20 -0
- package/dist/core/extension/skills/skillWriter.js +150 -0
- package/dist/core/extension/skills/skillWriter.js.map +1 -0
- package/dist/core/runtime/execution/commandReactor.d.ts +31 -0
- package/dist/core/runtime/execution/commandReactor.js +38 -0
- package/dist/core/runtime/execution/commandReactor.js.map +1 -0
- package/dist/core/runtime/execution/defaultModelSelection.d.ts +4 -0
- package/dist/core/runtime/execution/defaultModelSelection.js +17 -0
- package/dist/core/runtime/execution/defaultModelSelection.js.map +1 -0
- package/dist/core/runtime/execution/drainableWorker.d.ts +27 -0
- package/dist/core/runtime/execution/drainableWorker.js +79 -0
- package/dist/core/runtime/execution/drainableWorker.js.map +1 -0
- package/dist/core/runtime/execution/orchestrationEngine.d.ts +16 -0
- package/dist/core/runtime/execution/orchestrationEngine.js +181 -0
- package/dist/core/runtime/execution/orchestrationEngine.js.map +1 -0
- package/dist/core/runtime/execution/orchestrationHealth.d.ts +45 -0
- package/dist/core/runtime/execution/orchestrationHealth.js +95 -0
- package/dist/core/runtime/execution/orchestrationHealth.js.map +1 -0
- package/dist/core/runtime/execution/pluginContext/defaultSessionOwner.d.ts +2 -0
- package/dist/core/runtime/execution/pluginContext/defaultSessionOwner.js +10 -0
- package/dist/core/runtime/execution/pluginContext/defaultSessionOwner.js.map +1 -0
- package/dist/core/runtime/execution/pluginContext/pluginCapabilities.d.ts +40 -0
- package/dist/core/runtime/execution/pluginContext/pluginCapabilities.js +73 -0
- package/dist/core/runtime/execution/pluginContext/pluginCapabilities.js.map +1 -0
- package/dist/core/runtime/execution/pluginContext/pluginContextFactory.d.ts +20 -0
- package/dist/core/runtime/execution/pluginContext/pluginContextFactory.js +18 -0
- package/dist/core/runtime/execution/pluginContext/pluginContextFactory.js.map +1 -0
- package/dist/core/runtime/execution/pluginContext/transportAuthor.d.ts +7 -0
- package/dist/core/runtime/execution/pluginContext/transportAuthor.js +15 -0
- package/dist/core/runtime/execution/pluginContext/transportAuthor.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerCompactionCoordinator.d.ts +7 -0
- package/dist/core/runtime/execution/providerCoordination/providerCompactionCoordinator.js +25 -0
- package/dist/core/runtime/execution/providerCoordination/providerCompactionCoordinator.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerPolicyTarget.d.ts +2 -0
- package/dist/core/runtime/execution/providerCoordination/providerPolicyTarget.js +5 -0
- package/dist/core/runtime/execution/providerCoordination/providerPolicyTarget.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerRecoveryService.d.ts +7 -0
- package/dist/core/runtime/execution/providerCoordination/providerRecoveryService.js +6 -0
- package/dist/core/runtime/execution/providerCoordination/providerRecoveryService.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerRequestAttributionService.d.ts +10 -0
- package/dist/core/runtime/execution/providerCoordination/providerRequestAttributionService.js +33 -0
- package/dist/core/runtime/execution/providerCoordination/providerRequestAttributionService.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerSessionCoordinator.d.ts +5 -0
- package/dist/core/runtime/execution/providerCoordination/providerSessionCoordinator.js +9 -0
- package/dist/core/runtime/execution/providerCoordination/providerSessionCoordinator.js.map +1 -0
- package/dist/core/runtime/execution/providerCoordination/providerTurnCoordinator.d.ts +3 -0
- package/dist/core/runtime/execution/providerCoordination/providerTurnCoordinator.js +6 -0
- package/dist/core/runtime/execution/providerCoordination/providerTurnCoordinator.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/ports.d.ts +47 -0
- package/dist/core/runtime/execution/providerOrchestration/ports.js +2 -0
- package/dist/core/runtime/execution/providerOrchestration/ports.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerAttachmentResolver.d.ts +13 -0
- package/dist/core/runtime/execution/providerOrchestration/providerAttachmentResolver.js +57 -0
- package/dist/core/runtime/execution/providerOrchestration/providerAttachmentResolver.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerCompactionPolicy.d.ts +19 -0
- package/dist/core/runtime/execution/providerOrchestration/providerCompactionPolicy.js +129 -0
- package/dist/core/runtime/execution/providerOrchestration/providerCompactionPolicy.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerEventPipeline.d.ts +32 -0
- package/dist/core/runtime/execution/providerOrchestration/providerEventPipeline.js +67 -0
- package/dist/core/runtime/execution/providerOrchestration/providerEventPipeline.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerMissionEventProjector.d.ts +12 -0
- package/dist/core/runtime/execution/providerOrchestration/providerMissionEventProjector.js +71 -0
- package/dist/core/runtime/execution/providerOrchestration/providerMissionEventProjector.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerOrchestrator.d.ts +37 -0
- package/dist/core/runtime/execution/providerOrchestration/providerOrchestrator.js +53 -0
- package/dist/core/runtime/execution/providerOrchestration/providerOrchestrator.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerRequestProjector.d.ts +15 -0
- package/dist/core/runtime/execution/providerOrchestration/providerRequestProjector.js +93 -0
- package/dist/core/runtime/execution/providerOrchestration/providerRequestProjector.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerSessionOrchestrator.d.ts +37 -0
- package/dist/core/runtime/execution/providerOrchestration/providerSessionOrchestrator.js +104 -0
- package/dist/core/runtime/execution/providerOrchestration/providerSessionOrchestrator.js.map +1 -0
- package/dist/core/runtime/execution/providerOrchestration/providerTurnBroker.d.ts +62 -0
- package/dist/core/runtime/execution/providerOrchestration/providerTurnBroker.js +349 -0
- package/dist/core/runtime/execution/providerOrchestration/providerTurnBroker.js.map +1 -0
- package/dist/core/runtime/execution/providerProjectionTypes.d.ts +25 -0
- package/dist/core/runtime/execution/providerProjectionTypes.js +18 -0
- package/dist/core/runtime/execution/providerProjectionTypes.js.map +1 -0
- package/dist/core/runtime/execution/providerSessionDirectory.d.ts +12 -0
- package/dist/core/runtime/execution/providerSessionDirectory.js +94 -0
- package/dist/core/runtime/execution/providerSessionDirectory.js.map +1 -0
- package/dist/core/runtime/execution/runtimeDomain.d.ts +116 -0
- package/dist/core/runtime/execution/runtimeDomain.js +262 -0
- package/dist/core/runtime/execution/runtimeDomain.js.map +1 -0
- package/dist/core/runtime/execution/runtimeIngestion.d.ts +17 -0
- package/dist/core/runtime/execution/runtimeIngestion.js +254 -0
- package/dist/core/runtime/execution/runtimeIngestion.js.map +1 -0
- package/dist/core/runtime/execution/runtimeInteractionService.d.ts +66 -0
- package/dist/core/runtime/execution/runtimeInteractionService.js +230 -0
- package/dist/core/runtime/execution/runtimeInteractionService.js.map +1 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequestService.d.ts +64 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequestService.js +366 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequestService.js.map +1 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequests.d.ts +111 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequests.js +464 -0
- package/dist/core/runtime/execution/runtimeOrchestrationRequests.js.map +1 -0
- package/dist/core/runtime/execution/runtimeOrchestrationResult.d.ts +4 -0
- package/dist/core/runtime/execution/runtimeOrchestrationResult.js +7 -0
- package/dist/core/runtime/execution/runtimeOrchestrationResult.js.map +1 -0
- package/dist/core/runtime/execution/runtimePendingRequestService.d.ts +69 -0
- package/dist/core/runtime/execution/runtimePendingRequestService.js +360 -0
- package/dist/core/runtime/execution/runtimePendingRequestService.js.map +1 -0
- package/dist/core/runtime/execution/runtimePluginContextService.d.ts +100 -0
- package/dist/core/runtime/execution/runtimePluginContextService.js +576 -0
- package/dist/core/runtime/execution/runtimePluginContextService.js.map +1 -0
- package/dist/core/runtime/execution/runtimeReceiptBus.d.ts +17 -0
- package/dist/core/runtime/execution/runtimeReceiptBus.js +50 -0
- package/dist/core/runtime/execution/runtimeReceiptBus.js.map +1 -0
- package/dist/core/runtime/execution/runtimeWorkerQueues.d.ts +33 -0
- package/dist/core/runtime/execution/runtimeWorkerQueues.js +55 -0
- package/dist/core/runtime/execution/runtimeWorkerQueues.js.map +1 -0
- package/dist/core/runtime/graph/runtimePaths.d.ts +2 -0
- package/dist/core/runtime/graph/runtimePaths.js +22 -0
- package/dist/core/runtime/graph/runtimePaths.js.map +1 -0
- package/dist/core/runtime/hosting/managedSpaceMetadata.d.ts +7 -0
- package/dist/core/runtime/hosting/managedSpaceMetadata.js +14 -0
- package/dist/core/runtime/hosting/managedSpaceMetadata.js.map +1 -0
- package/dist/core/runtime/hosting/runtimeHostingService.d.ts +32 -0
- package/dist/core/runtime/hosting/runtimeHostingService.js +123 -0
- package/dist/core/runtime/hosting/runtimeHostingService.js.map +1 -0
- package/dist/core/runtime/hosting/runtimeLayout.d.ts +5 -0
- package/dist/core/runtime/hosting/runtimeLayout.js +133 -0
- package/dist/core/runtime/hosting/runtimeLayout.js.map +1 -0
- package/dist/core/runtime/hosting/runtimeManagementPort.d.ts +60 -0
- package/dist/core/runtime/hosting/runtimeManagementPort.js +28 -0
- package/dist/core/runtime/hosting/runtimeManagementPort.js.map +1 -0
- package/dist/core/runtime/hosting/runtimeTransportSurfaceService.d.ts +20 -0
- package/dist/core/runtime/hosting/runtimeTransportSurfaceService.js +82 -0
- package/dist/core/runtime/hosting/runtimeTransportSurfaceService.js.map +1 -0
- package/dist/core/runtime/hosting/systemEmbeds.d.ts +22 -0
- package/dist/core/runtime/hosting/systemEmbeds.js +25 -0
- package/dist/core/runtime/hosting/systemEmbeds.js.map +1 -0
- package/dist/core/runtime/lifecycle/managedChannelLifecycleService.d.ts +37 -0
- package/dist/core/runtime/lifecycle/managedChannelLifecycleService.js +256 -0
- package/dist/core/runtime/lifecycle/managedChannelLifecycleService.js.map +1 -0
- package/dist/core/runtime/lifecycle/runtimeLifecycleService.d.ts +43 -0
- package/dist/core/runtime/lifecycle/runtimeLifecycleService.js +322 -0
- package/dist/core/runtime/lifecycle/runtimeLifecycleService.js.map +1 -0
- package/dist/core/runtime/moorlineRuntime.d.ts +100 -0
- package/dist/core/runtime/moorlineRuntime.js +573 -0
- package/dist/core/runtime/moorlineRuntime.js.map +1 -0
- package/dist/core/runtime/moorlineRuntimeBuilder.d.ts +180 -0
- package/dist/core/runtime/moorlineRuntimeBuilder.js +681 -0
- package/dist/core/runtime/moorlineRuntimeBuilder.js.map +1 -0
- package/dist/core/runtime/runtimeAudit.d.ts +7 -0
- package/dist/core/runtime/runtimeAudit.js +32 -0
- package/dist/core/runtime/runtimeAudit.js.map +1 -0
- package/dist/core/runtime/runtimeBootstrapRegistry.d.ts +5 -0
- package/dist/core/runtime/runtimeBootstrapRegistry.js +15 -0
- package/dist/core/runtime/runtimeBootstrapRegistry.js.map +1 -0
- package/dist/core/runtime/runtimeStatus.d.ts +14 -0
- package/dist/core/runtime/runtimeStatus.js +16 -0
- package/dist/core/runtime/runtimeStatus.js.map +1 -0
- package/dist/core/runtime/supervision/managedSidecar.d.ts +71 -0
- package/dist/core/runtime/supervision/managedSidecar.js +13 -0
- package/dist/core/runtime/supervision/managedSidecar.js.map +1 -0
- package/dist/core/runtime/supervision/runtimeControl.d.ts +45 -0
- package/dist/core/runtime/supervision/runtimeControl.js +2 -0
- package/dist/core/runtime/supervision/runtimeControl.js.map +1 -0
- package/dist/core/runtime/supervision/runtimeControlService.d.ts +56 -0
- package/dist/core/runtime/supervision/runtimeControlService.js +315 -0
- package/dist/core/runtime/supervision/runtimeControlService.js.map +1 -0
- package/dist/core/runtime/supervision/runtimeSupervisor.d.ts +106 -0
- package/dist/core/runtime/supervision/runtimeSupervisor.js +425 -0
- package/dist/core/runtime/supervision/runtimeSupervisor.js.map +1 -0
- package/dist/core/runtime/supervision/sidecarLaunchDefinition.d.ts +3 -0
- package/dist/core/runtime/supervision/sidecarLaunchDefinition.js +24 -0
- package/dist/core/runtime/supervision/sidecarLaunchDefinition.js.map +1 -0
- package/dist/core/runtime/supervision/sidecarManager.d.ts +40 -0
- package/dist/core/runtime/supervision/sidecarManager.js +409 -0
- package/dist/core/runtime/supervision/sidecarManager.js.map +1 -0
- package/dist/core/shared/fs/atomicWrite.d.ts +6 -0
- package/dist/core/shared/fs/atomicWrite.js +48 -0
- package/dist/core/shared/fs/atomicWrite.js.map +1 -0
- package/dist/core/shared/fs/canonicalPathContainment.d.ts +8 -0
- package/dist/core/shared/fs/canonicalPathContainment.js +31 -0
- package/dist/core/shared/fs/canonicalPathContainment.js.map +1 -0
- package/dist/core/shared/fs/runtimeOwnedPath.d.ts +6 -0
- package/dist/core/shared/fs/runtimeOwnedPath.js +23 -0
- package/dist/core/shared/fs/runtimeOwnedPath.js.map +1 -0
- package/dist/core/shared/utils/childProcessEnv.d.ts +4 -0
- package/dist/core/shared/utils/childProcessEnv.js +66 -0
- package/dist/core/shared/utils/childProcessEnv.js.map +1 -0
- package/dist/core/shared/utils/commandRunner.d.ts +18 -0
- package/dist/core/shared/utils/commandRunner.js +51 -0
- package/dist/core/shared/utils/commandRunner.js.map +1 -0
- package/dist/core/shared/utils/payloadRedaction.d.ts +13 -0
- package/dist/core/shared/utils/payloadRedaction.js +91 -0
- package/dist/core/shared/utils/payloadRedaction.js.map +1 -0
- package/dist/core/shared/utils/remoteNetworkPolicy.d.ts +11 -0
- package/dist/core/shared/utils/remoteNetworkPolicy.js +137 -0
- package/dist/core/shared/utils/remoteNetworkPolicy.js.map +1 -0
- package/dist/core/shared/utils/runtimeMessageUtils.d.ts +27 -0
- package/dist/core/shared/utils/runtimeMessageUtils.js +383 -0
- package/dist/core/shared/utils/runtimeMessageUtils.js.map +1 -0
- package/dist/core/system/audit/auditLogger.d.ts +15 -0
- package/dist/core/system/audit/auditLogger.js +22 -0
- package/dist/core/system/audit/auditLogger.js.map +1 -0
- package/dist/core/system/backup/runtimeBackupService.d.ts +28 -0
- package/dist/core/system/backup/runtimeBackupService.js +284 -0
- package/dist/core/system/backup/runtimeBackupService.js.map +1 -0
- package/dist/core/system/config/configStore.d.ts +38 -0
- package/dist/core/system/config/configStore.js +672 -0
- package/dist/core/system/config/configStore.js.map +1 -0
- package/dist/core/system/policy/actorRulePolicy.d.ts +13 -0
- package/dist/core/system/policy/actorRulePolicy.js +87 -0
- package/dist/core/system/policy/actorRulePolicy.js.map +1 -0
- package/dist/core/system/policy/networkPolicy.d.ts +6 -0
- package/dist/core/system/policy/networkPolicy.js +71 -0
- package/dist/core/system/policy/networkPolicy.js.map +1 -0
- package/dist/core/system/policy/policyEngine.d.ts +22 -0
- package/dist/core/system/policy/policyEngine.js +41 -0
- package/dist/core/system/policy/policyEngine.js.map +1 -0
- package/dist/core/system/policy/policyProfile.d.ts +16 -0
- package/dist/core/system/policy/policyProfile.js +78 -0
- package/dist/core/system/policy/policyProfile.js.map +1 -0
- package/dist/core/system/policy/runtimeActionGuard.d.ts +24 -0
- package/dist/core/system/policy/runtimeActionGuard.js +64 -0
- package/dist/core/system/policy/runtimeActionGuard.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/auditEvents.d.ts +9 -0
- package/dist/core/system/projection/managementReadModel/auditEvents.js +61 -0
- package/dist/core/system/projection/managementReadModel/auditEvents.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/deps.d.ts +35 -0
- package/dist/core/system/projection/managementReadModel/deps.js +2 -0
- package/dist/core/system/projection/managementReadModel/deps.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/objects/serviceObjects.d.ts +3 -0
- package/dist/core/system/projection/managementReadModel/objects/serviceObjects.js +129 -0
- package/dist/core/system/projection/managementReadModel/objects/serviceObjects.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/pluginDiskRecords.d.ts +10 -0
- package/dist/core/system/projection/managementReadModel/pluginDiskRecords.js +55 -0
- package/dist/core/system/projection/managementReadModel/pluginDiskRecords.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/providerAlignment.d.ts +7 -0
- package/dist/core/system/projection/managementReadModel/providerAlignment.js +48 -0
- package/dist/core/system/projection/managementReadModel/providerAlignment.js.map +1 -0
- package/dist/core/system/projection/managementReadModel/text.d.ts +1 -0
- package/dist/core/system/projection/managementReadModel/text.js +8 -0
- package/dist/core/system/projection/managementReadModel/text.js.map +1 -0
- package/dist/core/system/projection/managementReadModelService.d.ts +18 -0
- package/dist/core/system/projection/managementReadModelService.js +768 -0
- package/dist/core/system/projection/managementReadModelService.js.map +1 -0
- package/dist/core/system/projection/pendingRequestProjectionStore.d.ts +12 -0
- package/dist/core/system/projection/pendingRequestProjectionStore.js +113 -0
- package/dist/core/system/projection/pendingRequestProjectionStore.js.map +1 -0
- package/dist/core/system/projection/pendingRequestQuestions.d.ts +2 -0
- package/dist/core/system/projection/pendingRequestQuestions.js +51 -0
- package/dist/core/system/projection/pendingRequestQuestions.js.map +1 -0
- package/dist/core/system/projection/projectionStateStore.d.ts +17 -0
- package/dist/core/system/projection/projectionStateStore.js +60 -0
- package/dist/core/system/projection/projectionStateStore.js.map +1 -0
- package/dist/core/system/projection/runtimeActivityStore.d.ts +24 -0
- package/dist/core/system/projection/runtimeActivityStore.js +150 -0
- package/dist/core/system/projection/runtimeActivityStore.js.map +1 -0
- package/dist/core/system/projection/runtimeProjectionService.d.ts +41 -0
- package/dist/core/system/projection/runtimeProjectionService.js +209 -0
- package/dist/core/system/projection/runtimeProjectionService.js.map +1 -0
- package/dist/core/system/projection/runtimeReceiptStore.d.ts +11 -0
- package/dist/core/system/projection/runtimeReceiptStore.js +77 -0
- package/dist/core/system/projection/runtimeReceiptStore.js.map +1 -0
- package/dist/core/system/projection/runtimeReconciler.d.ts +25 -0
- package/dist/core/system/projection/runtimeReconciler.js +83 -0
- package/dist/core/system/projection/runtimeReconciler.js.map +1 -0
- package/dist/core/system/projection/runtimeSnapshotQuery.d.ts +46 -0
- package/dist/core/system/projection/runtimeSnapshotQuery.js +135 -0
- package/dist/core/system/projection/runtimeSnapshotQuery.js.map +1 -0
- package/dist/core/system/release/releaseArtifacts.d.ts +7 -0
- package/dist/core/system/release/releaseArtifacts.js +88 -0
- package/dist/core/system/release/releaseArtifacts.js.map +1 -0
- package/dist/core/system/release/runtimePackageLoadReport.d.ts +10 -0
- package/dist/core/system/release/runtimePackageLoadReport.js +31 -0
- package/dist/core/system/release/runtimePackageLoadReport.js.map +1 -0
- package/dist/core/system/state/canonicalEventLogStore.d.ts +16 -0
- package/dist/core/system/state/canonicalEventLogStore.js +156 -0
- package/dist/core/system/state/canonicalEventLogStore.js.map +1 -0
- package/dist/core/system/state/migrationRunner.d.ts +5 -0
- package/dist/core/system/state/migrationRunner.js +58 -0
- package/dist/core/system/state/migrationRunner.js.map +1 -0
- package/dist/core/system/state/safeJson.d.ts +8 -0
- package/dist/core/system/state/safeJson.js +36 -0
- package/dist/core/system/state/safeJson.js.map +1 -0
- package/dist/core/system/state/sqlite/connection.d.ts +2 -0
- package/dist/core/system/state/sqlite/connection.js +8 -0
- package/dist/core/system/state/sqlite/connection.js.map +1 -0
- package/dist/core/system/state/sqlite/domainEventLogRepository.d.ts +10 -0
- package/dist/core/system/state/sqlite/domainEventLogRepository.js +69 -0
- package/dist/core/system/state/sqlite/domainEventLogRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/eventIntegrity.d.ts +6 -0
- package/dist/core/system/state/sqlite/eventIntegrity.js +7 -0
- package/dist/core/system/state/sqlite/eventIntegrity.js.map +1 -0
- package/dist/core/system/state/sqlite/managedSidecarRepository.d.ts +10 -0
- package/dist/core/system/state/sqlite/managedSidecarRepository.js +62 -0
- package/dist/core/system/state/sqlite/managedSidecarRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/missionRepository.d.ts +24 -0
- package/dist/core/system/state/sqlite/missionRepository.js +252 -0
- package/dist/core/system/state/sqlite/missionRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/orchestrationRepository.d.ts +20 -0
- package/dist/core/system/state/sqlite/orchestrationRepository.js +158 -0
- package/dist/core/system/state/sqlite/orchestrationRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/pendingRequestRepository.d.ts +13 -0
- package/dist/core/system/state/sqlite/pendingRequestRepository.js +76 -0
- package/dist/core/system/state/sqlite/pendingRequestRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/providerBindingRepository.d.ts +10 -0
- package/dist/core/system/state/sqlite/providerBindingRepository.js +58 -0
- package/dist/core/system/state/sqlite/providerBindingRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/providerEventLogRepository.d.ts +10 -0
- package/dist/core/system/state/sqlite/providerEventLogRepository.js +77 -0
- package/dist/core/system/state/sqlite/providerEventLogRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/rowMappers.d.ts +2 -0
- package/dist/core/system/state/sqlite/rowMappers.js +7 -0
- package/dist/core/system/state/sqlite/rowMappers.js.map +1 -0
- package/dist/core/system/state/sqlite/runtimeHistoryPruningRepository.d.ts +23 -0
- package/dist/core/system/state/sqlite/runtimeHistoryPruningRepository.js +82 -0
- package/dist/core/system/state/sqlite/runtimeHistoryPruningRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/runtimeReceiptRepository.d.ts +9 -0
- package/dist/core/system/state/sqlite/runtimeReceiptRepository.js +47 -0
- package/dist/core/system/state/sqlite/runtimeReceiptRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/sessionMetadataRepository.d.ts +7 -0
- package/dist/core/system/state/sqlite/sessionMetadataRepository.js +25 -0
- package/dist/core/system/state/sqlite/sessionMetadataRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/sessionRepository.d.ts +12 -0
- package/dist/core/system/state/sqlite/sessionRepository.js +72 -0
- package/dist/core/system/state/sqlite/sessionRepository.js.map +1 -0
- package/dist/core/system/state/sqlite/types.d.ts +140 -0
- package/dist/core/system/state/sqlite/types.js +113 -0
- package/dist/core/system/state/sqlite/types.js.map +1 -0
- package/dist/core/system/state/sqliteSessionStore.d.ts +86 -0
- package/dist/core/system/state/sqliteSessionStore.js +210 -0
- package/dist/core/system/state/sqliteSessionStore.js.map +1 -0
- package/dist/core/system/state/sqliteSupport.d.ts +4 -0
- package/dist/core/system/state/sqliteSupport.js +32 -0
- package/dist/core/system/state/sqliteSupport.js.map +1 -0
- package/dist/core/system/vcs/gitCheckpointService.d.ts +11 -0
- package/dist/core/system/vcs/gitCheckpointService.js +32 -0
- package/dist/core/system/vcs/gitCheckpointService.js.map +1 -0
- package/dist/core/system/vcs/gitCommitParser.d.ts +3 -0
- package/dist/core/system/vcs/gitCommitParser.js +55 -0
- package/dist/core/system/vcs/gitCommitParser.js.map +1 -0
- package/dist/core/system/vcs/gitDiffFormatter.d.ts +1 -0
- package/dist/core/system/vcs/gitDiffFormatter.js +4 -0
- package/dist/core/system/vcs/gitDiffFormatter.js.map +1 -0
- package/dist/core/system/vcs/gitHistoryService.d.ts +46 -0
- package/dist/core/system/vcs/gitHistoryService.js +277 -0
- package/dist/core/system/vcs/gitHistoryService.js.map +1 -0
- package/dist/core/system/vcs/gitIgnoreTemplate.d.ts +1 -0
- package/dist/core/system/vcs/gitIgnoreTemplate.js +12 -0
- package/dist/core/system/vcs/gitIgnoreTemplate.js.map +1 -0
- package/dist/core/system/vcs/gitRepoStore.d.ts +12 -0
- package/dist/core/system/vcs/gitRepoStore.js +46 -0
- package/dist/core/system/vcs/gitRepoStore.js.map +1 -0
- package/dist/core/system/vcs/gitTrackedPaths.d.ts +6 -0
- package/dist/core/system/vcs/gitTrackedPaths.js +80 -0
- package/dist/core/system/vcs/gitTrackedPaths.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/app.d.ts +444 -0
- package/dist/types/app.js +2 -0
- package/dist/types/app.js.map +1 -0
- package/dist/types/config.d.ts +188 -0
- package/dist/types/config.js +422 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/distro.d.ts +1 -0
- package/dist/types/distro.js +2 -0
- package/dist/types/distro.js.map +1 -0
- package/dist/types/history.d.ts +43 -0
- package/dist/types/history.js +2 -0
- package/dist/types/history.js.map +1 -0
- package/dist/types/package.d.ts +61 -0
- package/dist/types/package.js +2 -0
- package/dist/types/package.js.map +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/plugin.js +2 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/provider.d.ts +2 -0
- package/dist/types/provider.js +2 -0
- package/dist/types/provider.js.map +1 -0
- package/dist/types/release.d.ts +24 -0
- package/dist/types/release.js +2 -0
- package/dist/types/release.js.map +1 -0
- package/dist/types/runtime.d.ts +2 -0
- package/dist/types/runtime.js +2 -0
- package/dist/types/runtime.js.map +1 -0
- package/dist/types/skill.d.ts +1 -0
- package/dist/types/skill.js +2 -0
- package/dist/types/skill.js.map +1 -0
- package/dist/types/transport.d.ts +2 -0
- package/dist/types/transport.js +2 -0
- package/dist/types/transport.js.map +1 -0
- package/package.json +62 -0
- package/resources/migrations/001_sessions.sql +59 -0
- package/resources/migrations/002_pending_request_metadata.sql +2 -0
- package/resources/migrations/003_provider_projections.sql +38 -0
- package/resources/migrations/004_runtime_projection_state.sql +22 -0
- package/resources/migrations/005_runtime_robustness.sql +3 -0
- package/resources/migrations/006_provider_autostart.sql +1 -0
- package/resources/migrations/007_missions.sql +41 -0
- package/resources/migrations/008_mission_schedule_anchor.sql +5 -0
- package/resources/migrations/009_session_orchestration.sql +26 -0
- package/resources/migrations/010_mission_archival.sql +1 -0
- package/resources/migrations/011_managed_sidecars.sql +29 -0
- package/resources/migrations/012_scope_space_terminology.sql +19 -0
- package/resources/migrations/013_orchestration_dedupe.sql +5 -0
- package/resources/migrations/014_orchestration_execution_claims.sql +13 -0
- package/resources/migrations/015_mission_schedule_meta.sql +9 -0
- package/resources/migrations/016_mission_hook_bindings.sql +16 -0
- package/resources/migrations/017_domain_event_provenance.sql +1 -0
- package/resources/migrations/018_provider_event_processing.sql +8 -0
- package/resources/official-catalog.json +444 -0
- package/resources/policies/default-secure.json +160 -0
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { defaultHttpApiAdapterConfig, homeRootForRuntime } from '../../types/config.js';
|
|
4
|
+
import { createPackageApplyPlan } from '../../core/extension/packages/packageApplyPlanner.js';
|
|
5
|
+
import { findDependentRecords, findDependents } from '../../core/extension/packages/packageDependencyResolver.js';
|
|
6
|
+
import { resolvePackageConfigSchema } from '../../core/extension/packages/packageConfigSchema.js';
|
|
7
|
+
import { PackageInventoryStore } from '../../core/extension/packages/packageInventoryStore.js';
|
|
8
|
+
import { PackageInstaller } from '../../core/extension/packages/packageInstaller.js';
|
|
9
|
+
import { coerceSurfaceConfigInput, evaluateRuntimeStartability } from '../../core/extension/packages/runtimeStartability.js';
|
|
10
|
+
import { appliedPackageRefs, desiredPackageRefsFromConfig, isBuiltInActivatedPackage, packageActivationUniqueKey } from '../../core/extension/packages/packageActivation.js';
|
|
11
|
+
import { buildRequiredAppliedSurfaceConfigs, buildShareableMoorlineConfig, runtimePaths, saveMoorlineConfig } from '../../core/system/config/configStore.js';
|
|
12
|
+
import { recordHistoryCheckpoint } from '../../core/system/vcs/gitCheckpointService.js';
|
|
13
|
+
import { GitHistoryService } from '../../core/system/vcs/gitHistoryService.js';
|
|
14
|
+
import { loadTransportPackageById } from './transportPackageLoader.js';
|
|
15
|
+
import { assertOfficialCatalogChecksums, getOfficialCatalog } from './officialCatalog.js';
|
|
16
|
+
import { packageVersionSatisfiesRange, resolveBundleMembers } from '../../core/extension/packages/packageVersionResolver.js';
|
|
17
|
+
import { PackageRegistryService } from '../../core/extension/packages/packageRegistryService.js';
|
|
18
|
+
import { loadInstallablePackageManifest } from '../../core/extension/packages/packageManifest.js';
|
|
19
|
+
function packageInstallDirName(surface) {
|
|
20
|
+
return surface === 'api-adapter'
|
|
21
|
+
? 'api-adapters'
|
|
22
|
+
: surface === 'bundle'
|
|
23
|
+
? 'bundles'
|
|
24
|
+
: `${surface}s`;
|
|
25
|
+
}
|
|
26
|
+
function packageConfigRoot(config, surface, packageId) {
|
|
27
|
+
if (surface === 'api-adapter') {
|
|
28
|
+
config.surfaces.apiAdapter.configByPackageId ??= {};
|
|
29
|
+
config.surfaces.apiAdapter.configByPackageId[packageId] ??= {};
|
|
30
|
+
return config.surfaces.apiAdapter.configByPackageId[packageId];
|
|
31
|
+
}
|
|
32
|
+
if (surface === 'transport') {
|
|
33
|
+
config.surfaces.transport.configByPackageId ??= {};
|
|
34
|
+
config.surfaces.transport.configByPackageId[packageId] ??= {};
|
|
35
|
+
return config.surfaces.transport.configByPackageId[packageId];
|
|
36
|
+
}
|
|
37
|
+
if (surface === 'provider') {
|
|
38
|
+
config.surfaces.provider.configByPackageId ??= {};
|
|
39
|
+
config.surfaces.provider.configByPackageId[packageId] ??= {};
|
|
40
|
+
return config.surfaces.provider.configByPackageId[packageId];
|
|
41
|
+
}
|
|
42
|
+
if (surface === 'plugin') {
|
|
43
|
+
config.surfaces.plugins.configByPackageId[packageId] ??= {};
|
|
44
|
+
return config.surfaces.plugins.configByPackageId[packageId];
|
|
45
|
+
}
|
|
46
|
+
config.surfaces.skills.configByPackageId[packageId] ??= {};
|
|
47
|
+
return config.surfaces.skills.configByPackageId[packageId];
|
|
48
|
+
}
|
|
49
|
+
function packageConfigRootIfPresent(config, surface, packageId) {
|
|
50
|
+
if (surface === 'api-adapter') {
|
|
51
|
+
return {
|
|
52
|
+
...(config.surfaces.apiAdapter.activePackageId === packageId ? config.surfaces.apiAdapter.config : {}),
|
|
53
|
+
...(config.surfaces.apiAdapter.configByPackageId?.[packageId] ?? {})
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (surface === 'transport') {
|
|
57
|
+
return {
|
|
58
|
+
...(config.surfaces.transport.activePackageId === packageId ? config.surfaces.transport.config : {}),
|
|
59
|
+
...(config.surfaces.transport.configByPackageId?.[packageId] ?? {})
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (surface === 'provider') {
|
|
63
|
+
return {
|
|
64
|
+
...(config.surfaces.provider.activePackageId === packageId ? config.surfaces.provider.config : {}),
|
|
65
|
+
...(config.surfaces.provider.configByPackageId?.[packageId] ?? {})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (surface === 'plugin') {
|
|
69
|
+
return config.surfaces.plugins.configByPackageId[packageId] ?? {};
|
|
70
|
+
}
|
|
71
|
+
return config.surfaces.skills.configByPackageId[packageId] ?? {};
|
|
72
|
+
}
|
|
73
|
+
function coercePackageConfigValue(input) {
|
|
74
|
+
if (input.surface === 'transport' || input.surface === 'provider') {
|
|
75
|
+
return coerceSurfaceConfigInput({
|
|
76
|
+
surface: input.surface,
|
|
77
|
+
packageId: input.packageId,
|
|
78
|
+
schema: input.schema,
|
|
79
|
+
key: input.key,
|
|
80
|
+
rawValue: input.rawValue
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!input.schema?.properties) {
|
|
84
|
+
return input.rawValue;
|
|
85
|
+
}
|
|
86
|
+
const property = input.schema.properties[input.key];
|
|
87
|
+
if (!property) {
|
|
88
|
+
throw new Error(`Unknown ${input.surface} config key ${input.key} for ${input.packageId}.`);
|
|
89
|
+
}
|
|
90
|
+
const required = new Set(input.schema.required ?? []);
|
|
91
|
+
const trimmed = input.rawValue.trim();
|
|
92
|
+
if (required.has(input.key) && trimmed.length === 0) {
|
|
93
|
+
throw new Error(`${input.surface} config key ${input.key} is required.`);
|
|
94
|
+
}
|
|
95
|
+
let value = input.rawValue;
|
|
96
|
+
if (property.type === 'boolean') {
|
|
97
|
+
if (trimmed === 'true') {
|
|
98
|
+
value = true;
|
|
99
|
+
}
|
|
100
|
+
else if (trimmed === 'false') {
|
|
101
|
+
value = false;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error(`${input.surface} config key ${input.key} must be "true" or "false".`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (property.type === 'number') {
|
|
108
|
+
const parsed = Number(trimmed);
|
|
109
|
+
if (!Number.isFinite(parsed)) {
|
|
110
|
+
throw new Error(`${input.surface} config key ${input.key} must be a finite number.`);
|
|
111
|
+
}
|
|
112
|
+
value = parsed;
|
|
113
|
+
}
|
|
114
|
+
if (property.enum && !property.enum.some((entry) => entry === value)) {
|
|
115
|
+
throw new Error(`${input.surface} config key ${input.key} must be one of: ${property.enum.map((entry) => String(entry)).join(', ')}.`);
|
|
116
|
+
}
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
function isBuiltInPackage(surface, packageId) {
|
|
120
|
+
return surface === 'api-adapter' && packageId === 'official/http';
|
|
121
|
+
}
|
|
122
|
+
export class OperatorPackageService {
|
|
123
|
+
config;
|
|
124
|
+
configPath;
|
|
125
|
+
now;
|
|
126
|
+
inventory;
|
|
127
|
+
installer;
|
|
128
|
+
packageRegistry = new PackageRegistryService();
|
|
129
|
+
history = new GitHistoryService();
|
|
130
|
+
homeRoot;
|
|
131
|
+
constructor(config, configPath, now = () => new Date().toISOString(), homeRoot = homeRootForRuntime(config.runtimeRoot)) {
|
|
132
|
+
this.config = config;
|
|
133
|
+
this.configPath = configPath;
|
|
134
|
+
this.now = now;
|
|
135
|
+
this.inventory = new PackageInventoryStore(config.runtimeRoot);
|
|
136
|
+
this.installer = new PackageInstaller(config.runtimeRoot, now);
|
|
137
|
+
this.homeRoot = homeRoot;
|
|
138
|
+
}
|
|
139
|
+
ensureInitialized() {
|
|
140
|
+
this.history.ensureInitializedSync(this.homeRoot);
|
|
141
|
+
this.inventory.ensureInitialized();
|
|
142
|
+
this.recoverInterruptedPackageOperation();
|
|
143
|
+
const pendingRemovalRecovery = this.installer.recoverPendingRemovals();
|
|
144
|
+
if (pendingRemovalRecovery.restored > 0 || pendingRemovalRecovery.cleaned > 0) {
|
|
145
|
+
this.repairInventoryAgainstDisk();
|
|
146
|
+
this.reconcileDesiredAndAppliedState();
|
|
147
|
+
}
|
|
148
|
+
const paths = runtimePaths(this.config.runtimeRoot);
|
|
149
|
+
if (!existsSync(paths.runtimeRoot)) {
|
|
150
|
+
throw new Error(`Runtime root does not exist: ${paths.runtimeRoot}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
operationJournalPath() {
|
|
154
|
+
return join(runtimePaths(this.config.runtimeRoot).stateDir, 'package-operation-journal.json');
|
|
155
|
+
}
|
|
156
|
+
writeOperationJournal(operation) {
|
|
157
|
+
const payload = {
|
|
158
|
+
version: 1,
|
|
159
|
+
operation,
|
|
160
|
+
startedAt: this.now()
|
|
161
|
+
};
|
|
162
|
+
writeFileSync(this.operationJournalPath(), `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
|
|
163
|
+
}
|
|
164
|
+
clearOperationJournal() {
|
|
165
|
+
rmSync(this.operationJournalPath(), { force: true });
|
|
166
|
+
}
|
|
167
|
+
withOperationJournal(operation, work) {
|
|
168
|
+
this.writeOperationJournal(operation);
|
|
169
|
+
try {
|
|
170
|
+
const result = work();
|
|
171
|
+
this.clearOperationJournal();
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
this.recoverInterruptedPackageOperation();
|
|
176
|
+
this.clearOperationJournal();
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async withAsyncOperationJournal(operation, work) {
|
|
181
|
+
this.writeOperationJournal(operation);
|
|
182
|
+
try {
|
|
183
|
+
const result = await work();
|
|
184
|
+
this.clearOperationJournal();
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
this.recoverInterruptedPackageOperation();
|
|
189
|
+
this.clearOperationJournal();
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
repairInventoryAgainstDisk() {
|
|
194
|
+
const state = this.inventory.load();
|
|
195
|
+
const filtered = state.installed.filter((entry) => existsSync(entry.installPath));
|
|
196
|
+
if (filtered.length === state.installed.length) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
state.installed = filtered;
|
|
200
|
+
this.inventory.save(state);
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
backupCorruptOperationJournal(journalPath, error) {
|
|
204
|
+
const backupPath = `${journalPath}.corrupt-${Date.now()}`;
|
|
205
|
+
try {
|
|
206
|
+
copyFileSync(journalPath, backupPath);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Best effort backup; recovery still continues.
|
|
210
|
+
}
|
|
211
|
+
globalThis.console.warn(`[moorline:packages] Corrupt package operation journal recovered at ${journalPath}; backup written to ${backupPath}.`, error);
|
|
212
|
+
}
|
|
213
|
+
recoverInterruptedPackageOperation() {
|
|
214
|
+
const journalPath = this.operationJournalPath();
|
|
215
|
+
if (!existsSync(journalPath)) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
let parsed = null;
|
|
219
|
+
try {
|
|
220
|
+
const decoded = JSON.parse(readFileSync(journalPath, 'utf8'));
|
|
221
|
+
if (!decoded || typeof decoded !== 'object' || Array.isArray(decoded)) {
|
|
222
|
+
throw new Error('operation journal payload must be a JSON object.');
|
|
223
|
+
}
|
|
224
|
+
parsed = decoded;
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
this.backupCorruptOperationJournal(journalPath, error);
|
|
228
|
+
this.clearOperationJournal();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (parsed.operation !== 'remove' && parsed.operation !== 'apply') {
|
|
232
|
+
this.clearOperationJournal();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.repairInventoryAgainstDisk();
|
|
236
|
+
this.reconcileDesiredAndAppliedState();
|
|
237
|
+
this.clearOperationJournal();
|
|
238
|
+
}
|
|
239
|
+
checkpoint(input) {
|
|
240
|
+
recordHistoryCheckpoint({
|
|
241
|
+
homeRoot: this.homeRoot,
|
|
242
|
+
actor: input.actor,
|
|
243
|
+
reason: input.reason,
|
|
244
|
+
operation: input.operation,
|
|
245
|
+
...(input.absoluteTargets ? { absoluteTargets: input.absoluteTargets } : {}),
|
|
246
|
+
...(input.includeConfig ? { configPath: this.configPath } : {})
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
listCatalog() {
|
|
250
|
+
return this.packageRegistry.listCachedCatalog();
|
|
251
|
+
}
|
|
252
|
+
async searchCatalog(input) {
|
|
253
|
+
return await this.packageRegistry.search(input);
|
|
254
|
+
}
|
|
255
|
+
async getCatalogPackage(input) {
|
|
256
|
+
return await this.packageRegistry.getPackage(input);
|
|
257
|
+
}
|
|
258
|
+
exportShareBundle(productVersion = process.env.npm_package_version ?? '0.0.1') {
|
|
259
|
+
const inventory = this.inventory.load();
|
|
260
|
+
const notes = [
|
|
261
|
+
'Secrets are excluded from this bundle.',
|
|
262
|
+
'This export captures configuration and package selections only, not runtime state.'
|
|
263
|
+
];
|
|
264
|
+
const installed = inventory.installed.map((entry) => {
|
|
265
|
+
if (entry.source.kind === 'local_dir' || entry.source.kind === 'local_archive') {
|
|
266
|
+
notes.push(`Package ${entry.packageId} was installed from a local path and must be reinstalled manually by the recipient.`);
|
|
267
|
+
return {
|
|
268
|
+
kind: entry.kind,
|
|
269
|
+
surface: entry.surface,
|
|
270
|
+
packageId: entry.packageId,
|
|
271
|
+
source: null,
|
|
272
|
+
shareState: 'local_only'
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
kind: entry.kind,
|
|
277
|
+
surface: entry.surface,
|
|
278
|
+
packageId: entry.packageId,
|
|
279
|
+
source: entry.source,
|
|
280
|
+
shareState: 'portable'
|
|
281
|
+
};
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
version: 1,
|
|
285
|
+
exportedAt: this.now(),
|
|
286
|
+
productVersion,
|
|
287
|
+
config: buildShareableMoorlineConfig(this.config),
|
|
288
|
+
packages: {
|
|
289
|
+
selectedApiAdapterPackageId: this.config.surfaces.apiAdapter.activePackageId,
|
|
290
|
+
selectedTransportPackageId: this.config.surfaces.transport.activePackageId,
|
|
291
|
+
selectedProviderPackageId: this.config.surfaces.provider.activePackageId,
|
|
292
|
+
enabledPluginPackageIds: [...this.config.surfaces.plugins.enabledPackageIds].sort(),
|
|
293
|
+
enabledSkillPackageIds: [...this.config.surfaces.skills.enabledPackageIds].sort(),
|
|
294
|
+
installed
|
|
295
|
+
},
|
|
296
|
+
notes: [...new Set(notes)]
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
listInstalled(surface) {
|
|
300
|
+
return this.inventory.list(surface);
|
|
301
|
+
}
|
|
302
|
+
getInventory() {
|
|
303
|
+
return this.inventory.load();
|
|
304
|
+
}
|
|
305
|
+
getApplyPlan() {
|
|
306
|
+
return createPackageApplyPlan(this.config, this.inventory.load());
|
|
307
|
+
}
|
|
308
|
+
expectedPackageForEntry(entry) {
|
|
309
|
+
return {
|
|
310
|
+
kind: entry.kind,
|
|
311
|
+
packageId: entry.packageId,
|
|
312
|
+
version: entry.version
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
embeddedBundleMemberEntries(input) {
|
|
316
|
+
const entries = [];
|
|
317
|
+
for (const member of input.members) {
|
|
318
|
+
const packageDir = join(input.bundleInstallPath, 'packages', packageInstallDirName(member.kind), ...member.packageId.split('/'));
|
|
319
|
+
if (!existsSync(join(packageDir, 'manifest.json'))) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const loaded = loadInstallablePackageManifest(member.kind, packageDir);
|
|
323
|
+
entries.push({
|
|
324
|
+
kind: member.kind,
|
|
325
|
+
surface: member.kind,
|
|
326
|
+
packageId: loaded.manifest.id,
|
|
327
|
+
name: loaded.manifest.name,
|
|
328
|
+
description: loaded.manifest.description ?? loaded.manifest.id,
|
|
329
|
+
version: loaded.manifest.version,
|
|
330
|
+
recommendedForSetup: false,
|
|
331
|
+
tags: ['embedded'],
|
|
332
|
+
source: {
|
|
333
|
+
kind: 'local_dir',
|
|
334
|
+
path: packageDir
|
|
335
|
+
},
|
|
336
|
+
requires: ('dependencies' in loaded.manifest ? loaded.manifest.dependencies ?? [] : []).map((dependency) => dependency.packageId)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
return entries;
|
|
340
|
+
}
|
|
341
|
+
async installPackage(input) {
|
|
342
|
+
const kind = input.kind ?? input.surface;
|
|
343
|
+
if (!kind) {
|
|
344
|
+
throw new Error('Package install requires a kind.');
|
|
345
|
+
}
|
|
346
|
+
if (input.packageId) {
|
|
347
|
+
assertOfficialCatalogChecksums({
|
|
348
|
+
kind,
|
|
349
|
+
packageId: input.packageId
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
const registryEntry = input.source || !input.packageId
|
|
353
|
+
? null
|
|
354
|
+
: await this.packageRegistry.resolveInstallEntry({ kind, packageId: input.packageId });
|
|
355
|
+
const source = input.source ?? registryEntry?.source ?? null;
|
|
356
|
+
if (!source) {
|
|
357
|
+
throw new Error('Package install requires a source descriptor or a catalog package id');
|
|
358
|
+
}
|
|
359
|
+
if (kind === 'bundle') {
|
|
360
|
+
return await this.installBundle({ packageId: input.packageId, source, registryEntry: registryEntry ?? undefined });
|
|
361
|
+
}
|
|
362
|
+
const record = await this.installer.install({
|
|
363
|
+
surface: kind,
|
|
364
|
+
source,
|
|
365
|
+
...(registryEntry ? { expectedPackage: this.expectedPackageForEntry(registryEntry) } : {})
|
|
366
|
+
});
|
|
367
|
+
this.checkpoint({
|
|
368
|
+
actor: 'system:package-manager',
|
|
369
|
+
reason: `Installed ${record.surface} package ${record.packageId}.`,
|
|
370
|
+
operation: `install ${record.packageId}`,
|
|
371
|
+
absoluteTargets: [record.installPath]
|
|
372
|
+
});
|
|
373
|
+
this.reconcileDesiredAndAppliedState({ pruneDesiredSelections: false });
|
|
374
|
+
return record;
|
|
375
|
+
}
|
|
376
|
+
addBundleOwner(input) {
|
|
377
|
+
const state = this.inventory.load();
|
|
378
|
+
const record = state.installed.find((entry) => entry.kind === input.kind && entry.packageId === input.packageId);
|
|
379
|
+
if (!record?.installedByPackageIds || record.installedByPackageIds.length === 0) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
record.installedByPackageIds = [...new Set([...record.installedByPackageIds, input.bundlePackageId])].sort();
|
|
383
|
+
this.inventory.save(state);
|
|
384
|
+
}
|
|
385
|
+
removeBundleOwner(input) {
|
|
386
|
+
const state = this.inventory.load();
|
|
387
|
+
const record = state.installed.find((entry) => entry.kind === input.kind && entry.packageId === input.packageId);
|
|
388
|
+
if (!record?.installedByPackageIds?.includes(input.bundlePackageId)) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const nextOwners = record.installedByPackageIds.filter((owner) => owner !== input.bundlePackageId);
|
|
392
|
+
if (nextOwners.length > 0) {
|
|
393
|
+
record.installedByPackageIds = nextOwners;
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
delete record.installedByPackageIds;
|
|
397
|
+
}
|
|
398
|
+
this.inventory.save(state);
|
|
399
|
+
}
|
|
400
|
+
bundleMemberDependents(input) {
|
|
401
|
+
return findDependentRecords(this.inventory.load().installed, input.kind, input.packageId)
|
|
402
|
+
.map((entry) => `${entry.surface}:${entry.packageId}`)
|
|
403
|
+
.sort();
|
|
404
|
+
}
|
|
405
|
+
assertReplacementSatisfiesExistingBundleOwners(input) {
|
|
406
|
+
const state = this.inventory.load();
|
|
407
|
+
const conflicts = [];
|
|
408
|
+
for (const ownerPackageId of input.ownerPackageIds) {
|
|
409
|
+
const ownerBundle = state.installed.find((entry) => entry.kind === 'bundle' && entry.packageId === ownerPackageId);
|
|
410
|
+
if (!ownerBundle) {
|
|
411
|
+
conflicts.push(`${ownerPackageId} has no installed bundle record`);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const ownerMember = (ownerBundle.members ?? []).find((member) => member.kind === input.kind && member.packageId === input.packageId);
|
|
415
|
+
if (!ownerMember) {
|
|
416
|
+
conflicts.push(`${ownerPackageId} no longer declares ${input.kind}:${input.packageId}`);
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
if (!packageVersionSatisfiesRange({
|
|
421
|
+
packageId: input.packageId,
|
|
422
|
+
version: input.replacementVersion,
|
|
423
|
+
range: ownerMember.version
|
|
424
|
+
})) {
|
|
425
|
+
conflicts.push(`${ownerPackageId} requires ${ownerMember.version}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
430
|
+
conflicts.push(`${ownerPackageId} has invalid member constraint ${ownerMember.version}: ${detail}`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (conflicts.length > 0) {
|
|
434
|
+
throw new Error(`Cannot replace ${input.kind} package ${input.packageId} with version ${input.replacementVersion ?? '<missing>'}; ` +
|
|
435
|
+
`existing bundle owner constraints would be violated: ${conflicts.join('; ')}.`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
async installBundle(input) {
|
|
439
|
+
const record = await this.installer.install({
|
|
440
|
+
surface: 'bundle',
|
|
441
|
+
source: input.source,
|
|
442
|
+
...(input.registryEntry ? { expectedPackage: this.expectedPackageForEntry(input.registryEntry) } : {})
|
|
443
|
+
});
|
|
444
|
+
const bundle = input.registryEntry
|
|
445
|
+
? {
|
|
446
|
+
...input.registryEntry,
|
|
447
|
+
members: input.registryEntry.members && input.registryEntry.members.length > 0 ? input.registryEntry.members : record.members ?? []
|
|
448
|
+
}
|
|
449
|
+
: {
|
|
450
|
+
kind: 'bundle',
|
|
451
|
+
surface: 'bundle',
|
|
452
|
+
packageId: record.packageId,
|
|
453
|
+
name: record.name,
|
|
454
|
+
description: record.description ?? record.packageId,
|
|
455
|
+
version: record.version,
|
|
456
|
+
recommendedForSetup: false,
|
|
457
|
+
tags: [],
|
|
458
|
+
source: input.source,
|
|
459
|
+
requires: [],
|
|
460
|
+
members: record.members ?? []
|
|
461
|
+
};
|
|
462
|
+
let members;
|
|
463
|
+
try {
|
|
464
|
+
const requestedMembers = record.members ?? bundle.members ?? [];
|
|
465
|
+
const embeddedMemberEntries = this.embeddedBundleMemberEntries({
|
|
466
|
+
bundleInstallPath: record.installPath,
|
|
467
|
+
members: requestedMembers
|
|
468
|
+
});
|
|
469
|
+
const embeddedKeys = new Set(embeddedMemberEntries.map((entry) => `${entry.kind}:${entry.packageId}`));
|
|
470
|
+
const externalMembers = requestedMembers.filter((member) => !embeddedKeys.has(`${member.kind}:${member.packageId}`));
|
|
471
|
+
const memberEntries = externalMembers.length > 0
|
|
472
|
+
? await this.packageRegistry.resolveBundleMemberEntries({ members: externalMembers })
|
|
473
|
+
: [];
|
|
474
|
+
members = resolveBundleMembers({
|
|
475
|
+
catalog: [
|
|
476
|
+
...embeddedMemberEntries,
|
|
477
|
+
...getOfficialCatalog(),
|
|
478
|
+
...memberEntries
|
|
479
|
+
],
|
|
480
|
+
bundle
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
try {
|
|
485
|
+
this.installer.remove({ surface: 'bundle', packageId: record.packageId, cascade: true });
|
|
486
|
+
}
|
|
487
|
+
catch {
|
|
488
|
+
// Best effort rollback; the resolution error below is the actionable failure.
|
|
489
|
+
}
|
|
490
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
491
|
+
throw new Error(`Bundle ${record.packageId} can only reference packages that are present in catalog metadata in this version. ${detail}`);
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
for (const resolved of members) {
|
|
495
|
+
const existing = this.inventory.get(resolved.catalogEntry.kind, resolved.catalogEntry.packageId);
|
|
496
|
+
if (!existing) {
|
|
497
|
+
await this.installer.install({
|
|
498
|
+
surface: resolved.catalogEntry.kind,
|
|
499
|
+
source: resolved.catalogEntry.source,
|
|
500
|
+
installedByPackageId: record.packageId,
|
|
501
|
+
expectedPackage: this.expectedPackageForEntry(resolved.catalogEntry)
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
const satisfiesBundleRange = packageVersionSatisfiesRange({
|
|
506
|
+
packageId: resolved.catalogEntry.packageId,
|
|
507
|
+
version: existing.version,
|
|
508
|
+
range: resolved.member.version
|
|
509
|
+
});
|
|
510
|
+
if (!satisfiesBundleRange) {
|
|
511
|
+
if (!existing.installedByPackageIds || existing.installedByPackageIds.length === 0) {
|
|
512
|
+
throw new Error(`Installed ${resolved.catalogEntry.kind} package ${existing.packageId}@${existing.version} does not satisfy bundle ` +
|
|
513
|
+
`${record.packageId} requirement ${resolved.member.version}. Remove or update it before installing the bundle.`);
|
|
514
|
+
}
|
|
515
|
+
this.assertReplacementSatisfiesExistingBundleOwners({
|
|
516
|
+
kind: resolved.catalogEntry.kind,
|
|
517
|
+
packageId: resolved.catalogEntry.packageId,
|
|
518
|
+
replacementVersion: resolved.catalogEntry.version,
|
|
519
|
+
ownerPackageIds: existing.installedByPackageIds
|
|
520
|
+
});
|
|
521
|
+
await this.installer.install({
|
|
522
|
+
surface: resolved.catalogEntry.kind,
|
|
523
|
+
source: resolved.catalogEntry.source,
|
|
524
|
+
installedByPackageId: record.packageId,
|
|
525
|
+
expectedPackage: this.expectedPackageForEntry(resolved.catalogEntry)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
else if (existing.installedByPackageIds && existing.installedByPackageIds.length > 0) {
|
|
529
|
+
this.addBundleOwner({
|
|
530
|
+
kind: resolved.catalogEntry.kind,
|
|
531
|
+
packageId: resolved.catalogEntry.packageId,
|
|
532
|
+
bundlePackageId: record.packageId
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (resolved.member.activation === 'select') {
|
|
537
|
+
this.setSelectedPackage(resolved.member.kind, resolved.catalogEntry.packageId);
|
|
538
|
+
}
|
|
539
|
+
else if (resolved.member.activation === 'enable') {
|
|
540
|
+
this.enablePackage(resolved.member.kind, resolved.catalogEntry.packageId);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
catch (error) {
|
|
545
|
+
try {
|
|
546
|
+
this.removeBundle({ packageId: record.packageId, cascade: true });
|
|
547
|
+
}
|
|
548
|
+
catch {
|
|
549
|
+
// Best effort rollback. The member install error is the actionable failure.
|
|
550
|
+
}
|
|
551
|
+
throw error;
|
|
552
|
+
}
|
|
553
|
+
this.checkpoint({
|
|
554
|
+
actor: 'system:package-manager',
|
|
555
|
+
reason: `Installed bundle package ${record.packageId}.`,
|
|
556
|
+
operation: `install ${record.packageId}`,
|
|
557
|
+
absoluteTargets: [record.installPath]
|
|
558
|
+
});
|
|
559
|
+
this.reconcileDesiredAndAppliedState({ pruneDesiredSelections: false });
|
|
560
|
+
return record;
|
|
561
|
+
}
|
|
562
|
+
removePackage(input) {
|
|
563
|
+
const kind = input.kind ?? input.surface;
|
|
564
|
+
if (!kind) {
|
|
565
|
+
throw new Error('Package remove requires a kind.');
|
|
566
|
+
}
|
|
567
|
+
if (kind === 'bundle') {
|
|
568
|
+
this.removeBundle({ packageId: input.packageId, cascade: input.cascade });
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
this.withOperationJournal('remove', () => {
|
|
572
|
+
const existing = this.inventory.get(kind, input.packageId);
|
|
573
|
+
this.installer.remove({ surface: kind, packageId: input.packageId, cascade: input.cascade });
|
|
574
|
+
if (existing) {
|
|
575
|
+
this.checkpoint({
|
|
576
|
+
actor: 'system:package-manager',
|
|
577
|
+
reason: `Removed ${kind} package ${input.packageId}.`,
|
|
578
|
+
operation: `remove ${input.packageId}`,
|
|
579
|
+
absoluteTargets: [existing.installPath]
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
this.reconcileDesiredAndAppliedState();
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
removeBundle(input) {
|
|
586
|
+
this.withOperationJournal('remove', () => {
|
|
587
|
+
const state = this.inventory.load();
|
|
588
|
+
const bundle = state.installed.find((entry) => entry.kind === 'bundle' && entry.packageId === input.packageId);
|
|
589
|
+
if (!bundle) {
|
|
590
|
+
this.installer.remove({ surface: 'bundle', packageId: input.packageId, cascade: input.cascade });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const keptMembers = [];
|
|
594
|
+
for (const member of [...(bundle.members ?? [])].reverse()) {
|
|
595
|
+
const installed = this.inventory.get(member.kind, member.packageId);
|
|
596
|
+
if (!installed) {
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const owners = installed.installedByPackageIds ?? [];
|
|
600
|
+
if (!owners.includes(input.packageId)) {
|
|
601
|
+
keptMembers.push(`${member.kind}:${member.packageId} is manually installed`);
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (owners.length > 1) {
|
|
605
|
+
this.removeBundleOwner({ kind: member.kind, packageId: member.packageId, bundlePackageId: input.packageId });
|
|
606
|
+
keptMembers.push(`${member.kind}:${member.packageId} is also owned by ${owners.filter((owner) => owner !== input.packageId).join(', ')}`);
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
const dependents = this.bundleMemberDependents({ kind: member.kind, packageId: member.packageId });
|
|
610
|
+
if (dependents.length > 0 && input.cascade !== true) {
|
|
611
|
+
this.removeBundleOwner({ kind: member.kind, packageId: member.packageId, bundlePackageId: input.packageId });
|
|
612
|
+
keptMembers.push(`${member.kind}:${member.packageId} is required by ${dependents.join(', ')}`);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
this.installer.remove({ surface: member.kind, packageId: member.packageId, cascade: input.cascade });
|
|
616
|
+
}
|
|
617
|
+
this.installer.remove({ surface: 'bundle', packageId: input.packageId, cascade: input.cascade });
|
|
618
|
+
if (keptMembers.length > 0) {
|
|
619
|
+
globalThis.console.warn(`[moorline:packages] Removed bundle ${input.packageId} but kept member package(s): ${keptMembers.join('; ')}.`);
|
|
620
|
+
}
|
|
621
|
+
this.checkpoint({
|
|
622
|
+
actor: 'system:package-manager',
|
|
623
|
+
reason: keptMembers.length > 0
|
|
624
|
+
? `Removed bundle package ${input.packageId}. Kept members: ${keptMembers.join('; ')}.`
|
|
625
|
+
: `Removed bundle package ${input.packageId}.`,
|
|
626
|
+
operation: `remove ${input.packageId}`,
|
|
627
|
+
absoluteTargets: [bundle.installPath]
|
|
628
|
+
});
|
|
629
|
+
this.reconcileDesiredAndAppliedState();
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
dependents(surface, packageId) {
|
|
633
|
+
return findDependents(this.inventory.load().installed, surface, packageId);
|
|
634
|
+
}
|
|
635
|
+
installedLookup(state) {
|
|
636
|
+
return {
|
|
637
|
+
'api-adapter': new Set(state.installed.filter((entry) => entry.kind === 'api-adapter').map((entry) => entry.packageId)),
|
|
638
|
+
transport: new Set(state.installed.filter((entry) => entry.kind === 'transport').map((entry) => entry.packageId)),
|
|
639
|
+
provider: new Set(state.installed.filter((entry) => entry.kind === 'provider').map((entry) => entry.packageId)),
|
|
640
|
+
plugin: new Set(state.installed.filter((entry) => entry.kind === 'plugin').map((entry) => entry.packageId)),
|
|
641
|
+
skill: new Set(state.installed.filter((entry) => entry.kind === 'skill').map((entry) => entry.packageId))
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
requireInstalledPackage(state, surface, packageId, operation) {
|
|
645
|
+
if (isBuiltInPackage(surface, packageId)) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (!state.installed.some((entry) => entry.kind === surface && entry.packageId === packageId)) {
|
|
649
|
+
throw new Error(`Cannot ${operation} ${surface} package ${packageId}; it is not installed.`);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
deactivateDesiredPackagesWithActivationKey(state, uniqueKey, except) {
|
|
653
|
+
for (const entry of state.installed) {
|
|
654
|
+
if (entry.kind === 'bundle') {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
const surface = entry.surface;
|
|
658
|
+
if (except && entry.surface === except.surface && entry.packageId === except.packageId) {
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
if (packageActivationUniqueKey(surface, entry) !== uniqueKey) {
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
if (entry.surface === 'transport' && this.config.surfaces.transport.activePackageId === entry.packageId) {
|
|
665
|
+
this.config.surfaces.transport.activePackageId = null;
|
|
666
|
+
}
|
|
667
|
+
if (entry.surface === 'api-adapter' && this.config.surfaces.apiAdapter.activePackageId === entry.packageId) {
|
|
668
|
+
this.config.surfaces.apiAdapter.activePackageId = null;
|
|
669
|
+
}
|
|
670
|
+
if (entry.surface === 'provider' && this.config.surfaces.provider.activePackageId === entry.packageId) {
|
|
671
|
+
this.config.surfaces.provider.activePackageId = null;
|
|
672
|
+
}
|
|
673
|
+
if (entry.surface === 'plugin') {
|
|
674
|
+
this.config.surfaces.plugins.enabledPackageIds = this.config.surfaces.plugins.enabledPackageIds.filter((packageId) => packageId !== entry.packageId);
|
|
675
|
+
}
|
|
676
|
+
if (entry.surface === 'skill') {
|
|
677
|
+
this.config.surfaces.skills.enabledPackageIds = this.config.surfaces.skills.enabledPackageIds.filter((packageId) => packageId !== entry.packageId);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
reconcileDesiredAndAppliedState(options = {}) {
|
|
682
|
+
const state = this.inventory.load();
|
|
683
|
+
const installed = this.installedLookup(state);
|
|
684
|
+
const pruneDesiredSelections = options.pruneDesiredSelections !== false;
|
|
685
|
+
let configChanged = false;
|
|
686
|
+
let inventoryChanged = false;
|
|
687
|
+
if (pruneDesiredSelections) {
|
|
688
|
+
if (this.config.surfaces.apiAdapter.activePackageId &&
|
|
689
|
+
this.config.surfaces.apiAdapter.activePackageId !== 'official/http' &&
|
|
690
|
+
!installed['api-adapter'].has(this.config.surfaces.apiAdapter.activePackageId)) {
|
|
691
|
+
this.config.surfaces.apiAdapter.activePackageId = null;
|
|
692
|
+
this.config.surfaces.apiAdapter.config = {};
|
|
693
|
+
configChanged = true;
|
|
694
|
+
}
|
|
695
|
+
if (this.config.surfaces.transport.activePackageId && !installed.transport.has(this.config.surfaces.transport.activePackageId)) {
|
|
696
|
+
this.config.surfaces.transport.activePackageId = null;
|
|
697
|
+
this.config.surfaces.transport.config = {};
|
|
698
|
+
configChanged = true;
|
|
699
|
+
}
|
|
700
|
+
if (this.config.surfaces.provider.activePackageId && !installed.provider.has(this.config.surfaces.provider.activePackageId)) {
|
|
701
|
+
this.config.surfaces.provider.activePackageId = null;
|
|
702
|
+
this.config.surfaces.provider.config = {};
|
|
703
|
+
configChanged = true;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
for (const packageId of Object.keys(this.config.surfaces.apiAdapter.configByPackageId ?? {})) {
|
|
707
|
+
if (packageId !== 'official/http' && !installed['api-adapter'].has(packageId)) {
|
|
708
|
+
delete this.config.surfaces.apiAdapter.configByPackageId?.[packageId];
|
|
709
|
+
configChanged = true;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
for (const packageId of Object.keys(this.config.surfaces.transport.configByPackageId ?? {})) {
|
|
713
|
+
if (!installed.transport.has(packageId)) {
|
|
714
|
+
delete this.config.surfaces.transport.configByPackageId?.[packageId];
|
|
715
|
+
configChanged = true;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
for (const packageId of Object.keys(this.config.surfaces.provider.configByPackageId ?? {})) {
|
|
719
|
+
if (!installed.provider.has(packageId)) {
|
|
720
|
+
delete this.config.surfaces.provider.configByPackageId?.[packageId];
|
|
721
|
+
configChanged = true;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const normalizedEnabledPlugins = [...new Set(this.config.surfaces.plugins.enabledPackageIds.filter((entry) => installed.plugin.has(entry)))].sort();
|
|
725
|
+
if (JSON.stringify(normalizedEnabledPlugins) !== JSON.stringify(this.config.surfaces.plugins.enabledPackageIds)) {
|
|
726
|
+
this.config.surfaces.plugins.enabledPackageIds = normalizedEnabledPlugins;
|
|
727
|
+
configChanged = true;
|
|
728
|
+
}
|
|
729
|
+
const normalizedEnabledSkills = [...new Set(this.config.surfaces.skills.enabledPackageIds.filter((entry) => installed.skill.has(entry)))].sort();
|
|
730
|
+
if (JSON.stringify(normalizedEnabledSkills) !== JSON.stringify(this.config.surfaces.skills.enabledPackageIds)) {
|
|
731
|
+
this.config.surfaces.skills.enabledPackageIds = normalizedEnabledSkills;
|
|
732
|
+
configChanged = true;
|
|
733
|
+
}
|
|
734
|
+
for (const packageId of Object.keys(this.config.surfaces.plugins.configByPackageId)) {
|
|
735
|
+
if (!installed.plugin.has(packageId)) {
|
|
736
|
+
delete this.config.surfaces.plugins.configByPackageId[packageId];
|
|
737
|
+
configChanged = true;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
for (const packageId of Object.keys(this.config.surfaces.skills.configByPackageId)) {
|
|
741
|
+
if (!installed.skill.has(packageId)) {
|
|
742
|
+
delete this.config.surfaces.skills.configByPackageId[packageId];
|
|
743
|
+
configChanged = true;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const normalizedApplied = appliedPackageRefs(state.applied).filter((entry) => isBuiltInActivatedPackage(entry) || installed[entry.surface].has(entry.packageId));
|
|
747
|
+
if (JSON.stringify(normalizedApplied) !== JSON.stringify(state.applied.activated)) {
|
|
748
|
+
state.applied.activated = normalizedApplied;
|
|
749
|
+
inventoryChanged = true;
|
|
750
|
+
}
|
|
751
|
+
const startability = evaluateRuntimeStartability(this.config, state);
|
|
752
|
+
const nextSetup = startability.startable
|
|
753
|
+
? {
|
|
754
|
+
completed: true,
|
|
755
|
+
completedAt: this.config.setup.completedAt ?? this.now()
|
|
756
|
+
}
|
|
757
|
+
: {
|
|
758
|
+
completed: false
|
|
759
|
+
};
|
|
760
|
+
if (JSON.stringify(nextSetup) !== JSON.stringify(this.config.setup)) {
|
|
761
|
+
this.config.setup = nextSetup;
|
|
762
|
+
configChanged = true;
|
|
763
|
+
}
|
|
764
|
+
if (configChanged) {
|
|
765
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
766
|
+
}
|
|
767
|
+
if (inventoryChanged) {
|
|
768
|
+
this.inventory.save(state);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
setSelectedPackage(surface, packageId) {
|
|
772
|
+
const state = this.inventory.load();
|
|
773
|
+
if (packageId) {
|
|
774
|
+
this.requireInstalledPackage(state, surface, packageId, 'select');
|
|
775
|
+
const record = state.installed.find((entry) => entry.surface === surface && entry.packageId === packageId);
|
|
776
|
+
const uniqueKey = packageActivationUniqueKey(surface, record);
|
|
777
|
+
if (uniqueKey) {
|
|
778
|
+
this.deactivateDesiredPackagesWithActivationKey(state, uniqueKey, { surface, packageId });
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (surface === 'api-adapter') {
|
|
782
|
+
this.config.surfaces.apiAdapter.activePackageId = packageId;
|
|
783
|
+
if (packageId === null) {
|
|
784
|
+
this.config.surfaces.apiAdapter.config = {};
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
const savedConfig = this.config.surfaces.apiAdapter.configByPackageId?.[packageId];
|
|
788
|
+
const legacyDefaultConfig = packageId === 'official/http' ? defaultHttpApiAdapterConfig() : {};
|
|
789
|
+
this.config.surfaces.apiAdapter.config = {
|
|
790
|
+
...(savedConfig ?? legacyDefaultConfig)
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
else if (surface === 'transport') {
|
|
795
|
+
this.config.surfaces.transport.activePackageId = packageId;
|
|
796
|
+
if (packageId === null) {
|
|
797
|
+
this.config.surfaces.transport.config = {};
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
this.config.surfaces.transport.config = {
|
|
801
|
+
...(this.config.surfaces.transport.configByPackageId?.[packageId] ?? this.config.surfaces.transport.config)
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
this.config.surfaces.provider.activePackageId = packageId;
|
|
807
|
+
if (packageId === null) {
|
|
808
|
+
this.config.surfaces.provider.config = {};
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
this.config.surfaces.provider.config = {
|
|
812
|
+
...(this.config.surfaces.provider.configByPackageId?.[packageId] ?? this.config.surfaces.provider.config)
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
817
|
+
this.reconcileDesiredAndAppliedState();
|
|
818
|
+
this.checkpoint({
|
|
819
|
+
actor: 'system:package-manager',
|
|
820
|
+
reason: `Selected ${surface} package ${packageId ?? 'none'}.`,
|
|
821
|
+
operation: `select ${surface}`,
|
|
822
|
+
includeConfig: true
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
activatePackage(surface, packageId) {
|
|
826
|
+
const state = this.inventory.load();
|
|
827
|
+
this.requireInstalledPackage(state, surface, packageId, 'activate');
|
|
828
|
+
if (surface === 'api-adapter' || surface === 'transport' || surface === 'provider') {
|
|
829
|
+
this.setSelectedPackage(surface, packageId);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
if (surface === 'plugin' || surface === 'skill') {
|
|
833
|
+
this.enablePackage(surface, packageId);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
deactivatePackage(surface, packageId) {
|
|
837
|
+
const state = this.inventory.load();
|
|
838
|
+
this.requireInstalledPackage(state, surface, packageId, 'deactivate');
|
|
839
|
+
if (surface === 'api-adapter' && this.config.surfaces.apiAdapter.activePackageId === packageId) {
|
|
840
|
+
this.setSelectedPackage(surface, null);
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (surface === 'transport' && this.config.surfaces.transport.activePackageId === packageId) {
|
|
844
|
+
this.setSelectedPackage(surface, null);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (surface === 'provider' && this.config.surfaces.provider.activePackageId === packageId) {
|
|
848
|
+
this.setSelectedPackage(surface, null);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
if (surface === 'plugin' || surface === 'skill') {
|
|
852
|
+
this.disablePackage(surface, packageId);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
setPackageConfigValues(input) {
|
|
856
|
+
const state = this.inventory.load();
|
|
857
|
+
this.requireInstalledPackage(state, input.surface, input.packageId, 'configure');
|
|
858
|
+
const schema = resolvePackageConfigSchema({
|
|
859
|
+
runtimeRoot: this.config.runtimeRoot,
|
|
860
|
+
surface: input.surface,
|
|
861
|
+
packageId: input.packageId
|
|
862
|
+
});
|
|
863
|
+
const currentRoot = packageConfigRootIfPresent(this.config, input.surface, input.packageId);
|
|
864
|
+
const nextRoot = { ...currentRoot };
|
|
865
|
+
if (input.surface === 'api-adapter') {
|
|
866
|
+
delete nextRoot[input.packageId];
|
|
867
|
+
}
|
|
868
|
+
const replacements = input.secretReplacements ?? [];
|
|
869
|
+
for (const [key, rawValue] of Object.entries(input.values)) {
|
|
870
|
+
nextRoot[key] = coercePackageConfigValue({
|
|
871
|
+
surface: input.surface,
|
|
872
|
+
packageId: input.packageId,
|
|
873
|
+
schema,
|
|
874
|
+
key,
|
|
875
|
+
rawValue
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
for (const replacement of replacements) {
|
|
879
|
+
if (replacement.value.trim().length === 0) {
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
const property = schema?.properties?.[replacement.key];
|
|
883
|
+
if (!property || property.secret !== true) {
|
|
884
|
+
throw new Error(`${input.surface} config key ${replacement.key} is not a secret field for ${input.packageId}.`);
|
|
885
|
+
}
|
|
886
|
+
nextRoot[replacement.key] = coercePackageConfigValue({
|
|
887
|
+
surface: input.surface,
|
|
888
|
+
packageId: input.packageId,
|
|
889
|
+
schema,
|
|
890
|
+
key: replacement.key,
|
|
891
|
+
rawValue: replacement.value
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
const targetRoot = packageConfigRoot(this.config, input.surface, input.packageId);
|
|
895
|
+
for (const key of Object.keys(targetRoot)) {
|
|
896
|
+
delete targetRoot[key];
|
|
897
|
+
}
|
|
898
|
+
Object.assign(targetRoot, nextRoot);
|
|
899
|
+
if (input.surface === 'api-adapter') {
|
|
900
|
+
delete targetRoot[input.packageId];
|
|
901
|
+
}
|
|
902
|
+
if (input.surface === 'api-adapter' && this.config.surfaces.apiAdapter.activePackageId === input.packageId) {
|
|
903
|
+
this.config.surfaces.apiAdapter.config = { ...targetRoot };
|
|
904
|
+
}
|
|
905
|
+
if (input.surface === 'transport' && this.config.surfaces.transport.activePackageId === input.packageId) {
|
|
906
|
+
this.config.surfaces.transport.config = { ...targetRoot };
|
|
907
|
+
}
|
|
908
|
+
if (input.surface === 'provider' && this.config.surfaces.provider.activePackageId === input.packageId) {
|
|
909
|
+
this.config.surfaces.provider.config = { ...targetRoot };
|
|
910
|
+
}
|
|
911
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
912
|
+
this.reconcileDesiredAndAppliedState();
|
|
913
|
+
this.checkpoint({
|
|
914
|
+
actor: 'system:package-manager',
|
|
915
|
+
reason: `Updated ${input.surface} package configuration for ${input.packageId}.`,
|
|
916
|
+
operation: `config ${input.surface}`,
|
|
917
|
+
includeConfig: true
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
enablePackage(surface, packageId) {
|
|
921
|
+
const state = this.inventory.load();
|
|
922
|
+
this.requireInstalledPackage(state, surface, packageId, 'enable');
|
|
923
|
+
const record = state.installed.find((entry) => entry.surface === surface && entry.packageId === packageId);
|
|
924
|
+
const uniqueKey = packageActivationUniqueKey(surface, record);
|
|
925
|
+
if (uniqueKey) {
|
|
926
|
+
this.deactivateDesiredPackagesWithActivationKey(state, uniqueKey, { surface, packageId });
|
|
927
|
+
}
|
|
928
|
+
const target = surface === 'plugin' ? this.config.surfaces.plugins.enabledPackageIds : this.config.surfaces.skills.enabledPackageIds;
|
|
929
|
+
if (!target.includes(packageId)) {
|
|
930
|
+
target.push(packageId);
|
|
931
|
+
target.sort();
|
|
932
|
+
}
|
|
933
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
934
|
+
this.reconcileDesiredAndAppliedState();
|
|
935
|
+
this.checkpoint({
|
|
936
|
+
actor: 'system:package-manager',
|
|
937
|
+
reason: `Enabled ${surface} package ${packageId}.`,
|
|
938
|
+
operation: `enable ${packageId}`,
|
|
939
|
+
includeConfig: true
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
disablePackage(surface, packageId) {
|
|
943
|
+
const next = (surface === 'plugin' ? this.config.surfaces.plugins.enabledPackageIds : this.config.surfaces.skills.enabledPackageIds).filter((entry) => entry !== packageId);
|
|
944
|
+
if (surface === 'plugin') {
|
|
945
|
+
this.config.surfaces.plugins.enabledPackageIds = next;
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
this.config.surfaces.skills.enabledPackageIds = next;
|
|
949
|
+
}
|
|
950
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
951
|
+
this.reconcileDesiredAndAppliedState();
|
|
952
|
+
this.checkpoint({
|
|
953
|
+
actor: 'system:package-manager',
|
|
954
|
+
reason: `Disabled ${surface} package ${packageId}.`,
|
|
955
|
+
operation: `disable ${packageId}`,
|
|
956
|
+
includeConfig: true
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
async completeSelectedTransportConfig() {
|
|
960
|
+
const packageId = this.config.surfaces.transport.activePackageId;
|
|
961
|
+
if (!packageId) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
const pkg = await loadTransportPackageById({
|
|
965
|
+
runtimeRoot: this.config.runtimeRoot,
|
|
966
|
+
packageId,
|
|
967
|
+
config: this.config
|
|
968
|
+
});
|
|
969
|
+
if (!pkg.completeConfig) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const currentRoot = packageConfigRootIfPresent(this.config, 'transport', packageId);
|
|
973
|
+
const completed = await pkg.completeConfig({
|
|
974
|
+
config: { ...currentRoot }
|
|
975
|
+
});
|
|
976
|
+
if (!completed || typeof completed !== 'object' || !completed.config || typeof completed.config !== 'object' || Array.isArray(completed.config)) {
|
|
977
|
+
throw new Error(`Transport package ${packageId} returned invalid completed config.`);
|
|
978
|
+
}
|
|
979
|
+
const targetRoot = packageConfigRoot(this.config, 'transport', packageId);
|
|
980
|
+
for (const key of Object.keys(targetRoot)) {
|
|
981
|
+
delete targetRoot[key];
|
|
982
|
+
}
|
|
983
|
+
Object.assign(targetRoot, {
|
|
984
|
+
...currentRoot,
|
|
985
|
+
...completed.config
|
|
986
|
+
});
|
|
987
|
+
this.config.surfaces.transport.config = { ...targetRoot };
|
|
988
|
+
}
|
|
989
|
+
async apply() {
|
|
990
|
+
return await this.withAsyncOperationJournal('apply', async () => {
|
|
991
|
+
this.reconcileDesiredAndAppliedState();
|
|
992
|
+
await this.completeSelectedTransportConfig();
|
|
993
|
+
const state = this.inventory.load();
|
|
994
|
+
const startability = evaluateRuntimeStartability(this.config, state);
|
|
995
|
+
if (!startability.startable) {
|
|
996
|
+
throw new Error(startability.issues.join('\n'));
|
|
997
|
+
}
|
|
998
|
+
const plan = createPackageApplyPlan(this.config, state);
|
|
999
|
+
if (plan.errors.length > 0) {
|
|
1000
|
+
throw new Error(plan.errors.map((entry) => entry.detail).join('\n'));
|
|
1001
|
+
}
|
|
1002
|
+
const applied = buildRequiredAppliedSurfaceConfigs(this.config);
|
|
1003
|
+
this.config.transport = applied.transport;
|
|
1004
|
+
this.config.provider = applied.provider;
|
|
1005
|
+
state.applied = {
|
|
1006
|
+
activated: desiredPackageRefsFromConfig(this.config)
|
|
1007
|
+
};
|
|
1008
|
+
this.config.setup = {
|
|
1009
|
+
completed: true,
|
|
1010
|
+
completedAt: this.config.setup.completedAt ?? this.now()
|
|
1011
|
+
};
|
|
1012
|
+
saveMoorlineConfig(this.config, this.configPath);
|
|
1013
|
+
this.inventory.save(state);
|
|
1014
|
+
this.reconcileDesiredAndAppliedState();
|
|
1015
|
+
this.checkpoint({
|
|
1016
|
+
actor: 'system:package-manager',
|
|
1017
|
+
reason: 'Applied desired package state to the runtime configuration.',
|
|
1018
|
+
operation: 'apply packages',
|
|
1019
|
+
includeConfig: true
|
|
1020
|
+
});
|
|
1021
|
+
return createPackageApplyPlan(this.config, this.inventory.load());
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
//# sourceMappingURL=operatorPackageService.js.map
|