@1mcp/agent 0.39.5 → 0.40.0-beta.0
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/README.md +14 -7
- package/build/admin/assets/{admin-BackendLogsWorkspace-BKavXT9B.js → admin-BackendLogsWorkspace-DnPzXW3E.js} +1 -1
- package/build/admin/assets/{admin-InstructionTemplatesWorkspace-CvG4EPdZ.js → admin-InstructionTemplatesWorkspace-B7beKEgz.js} +1 -1
- package/build/admin/assets/{admin-OAuthServicesWorkspace-BzrCR7Bi.js → admin-OAuthServicesWorkspace-Bu74Bzt5.js} +1 -1
- package/build/admin/assets/{admin-PresetAuthoringWorkspace-BboJVBFl.js → admin-PresetAuthoringWorkspace-053b1zwU.js} +1 -1
- package/build/admin/assets/{admin-console-BpUgmlrR.js → admin-console-DVuqABnE.js} +3 -3
- package/build/admin/assets/admin-icons-wOzB38gm.js +1 -0
- package/build/admin/assets/admin-vendor-BLZ1Mauf.js +3 -0
- package/build/admin/assets/admin-vendor-BdHKHno1.js +1 -0
- package/build/admin/assets/admin-vendor-BqYiU41k.js +51 -0
- package/build/admin/assets/admin-vendor-C291Vs-N.js +3 -0
- package/build/admin/assets/admin-vendor-VzhcFgoy.js +1 -0
- package/build/admin/index.html +7 -5
- package/build/application/backendPreparationAdmission.d.ts +77 -0
- package/build/application/backendPreparationAdmission.d.ts.map +1 -0
- package/build/application/backendPreparationAdmission.js +423 -0
- package/build/application/backendPreparationAdmission.js.map +1 -0
- package/build/application/backendPreparationCoordinator.d.ts +122 -0
- package/build/application/backendPreparationCoordinator.d.ts.map +1 -0
- package/build/application/backendPreparationCoordinator.js +885 -0
- package/build/application/backendPreparationCoordinator.js.map +1 -0
- package/build/application/projectLifecycle.d.ts +49 -0
- package/build/application/projectLifecycle.d.ts.map +1 -0
- package/build/application/projectLifecycle.js +228 -0
- package/build/application/projectLifecycle.js.map +1 -0
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +39 -17
- package/build/cli.js.map +1 -1
- package/build/commands/admin/index.d.ts.map +1 -1
- package/build/commands/admin/index.js +2 -6
- package/build/commands/admin/index.js.map +1 -1
- package/build/commands/app/index.d.ts.map +1 -1
- package/build/commands/app/index.js +5 -17
- package/build/commands/app/index.js.map +1 -1
- package/build/commands/auth/index.d.ts.map +1 -1
- package/build/commands/auth/index.js +2 -7
- package/build/commands/auth/index.js.map +1 -1
- package/build/commands/bootstrap/bootstrap.d.ts +38 -0
- package/build/commands/bootstrap/bootstrap.d.ts.map +1 -0
- package/build/commands/bootstrap/bootstrap.js +265 -0
- package/build/commands/bootstrap/bootstrap.js.map +1 -0
- package/build/commands/bootstrap/bootstrapOwnership.d.ts +13 -0
- package/build/commands/bootstrap/bootstrapOwnership.d.ts.map +1 -0
- package/build/commands/bootstrap/bootstrapOwnership.js +112 -0
- package/build/commands/bootstrap/bootstrapOwnership.js.map +1 -0
- package/build/commands/bootstrap/index.d.ts +3 -0
- package/build/commands/bootstrap/index.d.ts.map +1 -0
- package/build/commands/bootstrap/index.js +22 -0
- package/build/commands/bootstrap/index.js.map +1 -0
- package/build/commands/cliSetup/index.d.ts.map +1 -1
- package/build/commands/cliSetup/index.js +3 -4
- package/build/commands/cliSetup/index.js.map +1 -1
- package/build/commands/cliSetup/installPreparationSkill.d.ts +8 -0
- package/build/commands/cliSetup/installPreparationSkill.d.ts.map +1 -0
- package/build/commands/cliSetup/installPreparationSkill.js +201 -0
- package/build/commands/cliSetup/installPreparationSkill.js.map +1 -0
- package/build/commands/cliSetup/preparationSkill.generated.d.ts +2 -0
- package/build/commands/cliSetup/preparationSkill.generated.d.ts.map +1 -0
- package/build/commands/cliSetup/preparationSkill.generated.js +8 -0
- package/build/commands/cliSetup/preparationSkill.generated.js.map +1 -0
- package/build/commands/cliSetup/setupFiles.d.ts +5 -1
- package/build/commands/cliSetup/setupFiles.d.ts.map +1 -1
- package/build/commands/cliSetup/setupFiles.js +54 -37
- package/build/commands/cliSetup/setupFiles.js.map +1 -1
- package/build/commands/inspect/index.d.ts.map +1 -1
- package/build/commands/inspect/index.js +4 -4
- package/build/commands/inspect/index.js.map +1 -1
- package/build/commands/inspect/inspect.d.ts +2 -1
- package/build/commands/inspect/inspect.d.ts.map +1 -1
- package/build/commands/inspect/inspect.js +10 -5
- package/build/commands/inspect/inspect.js.map +1 -1
- package/build/commands/inspect/inspectUtils.js +3 -0
- package/build/commands/inspect/inspectUtils.js.map +1 -1
- package/build/commands/instructions/index.d.ts.map +1 -1
- package/build/commands/instructions/index.js +8 -3
- package/build/commands/instructions/index.js.map +1 -1
- package/build/commands/instructions/instructions.d.ts +3 -1
- package/build/commands/instructions/instructions.d.ts.map +1 -1
- package/build/commands/instructions/instructions.js +24 -0
- package/build/commands/instructions/instructions.js.map +1 -1
- package/build/commands/instructions/instructionsUtils.d.ts +2 -0
- package/build/commands/instructions/instructionsUtils.d.ts.map +1 -1
- package/build/commands/instructions/instructionsUtils.js +14 -4
- package/build/commands/instructions/instructionsUtils.js.map +1 -1
- package/build/commands/mcp/index.d.ts.map +1 -1
- package/build/commands/mcp/index.js +16 -21
- package/build/commands/mcp/index.js.map +1 -1
- package/build/commands/mcp/installSource.d.ts +3 -1
- package/build/commands/mcp/installSource.d.ts.map +1 -1
- package/build/commands/mcp/installSource.js +2 -2
- package/build/commands/mcp/installSource.js.map +1 -1
- package/build/commands/mcp/knownServerSetup.d.ts +4 -0
- package/build/commands/mcp/knownServerSetup.d.ts.map +1 -0
- package/build/commands/mcp/knownServerSetup.js +102 -0
- package/build/commands/mcp/knownServerSetup.js.map +1 -0
- package/build/commands/mcp/setup.d.ts +28 -0
- package/build/commands/mcp/setup.d.ts.map +1 -0
- package/build/commands/mcp/setup.js +56 -0
- package/build/commands/mcp/setup.js.map +1 -0
- package/build/commands/mcp/tools.d.ts.map +1 -1
- package/build/commands/mcp/tools.js +3 -3
- package/build/commands/mcp/tools.js.map +1 -1
- package/build/commands/preparation/index.d.ts +3 -0
- package/build/commands/preparation/index.d.ts.map +1 -0
- package/build/commands/preparation/index.js +55 -0
- package/build/commands/preparation/index.js.map +1 -0
- package/build/commands/preparation/preparation.d.ts +18 -0
- package/build/commands/preparation/preparation.d.ts.map +1 -0
- package/build/commands/preparation/preparation.js +102 -0
- package/build/commands/preparation/preparation.js.map +1 -0
- package/build/commands/preset/index.d.ts.map +1 -1
- package/build/commands/preset/index.js +4 -51
- package/build/commands/preset/index.js.map +1 -1
- package/build/commands/project/index.d.ts +3 -0
- package/build/commands/project/index.d.ts.map +1 -0
- package/build/commands/project/index.js +40 -0
- package/build/commands/project/index.js.map +1 -0
- package/build/commands/project/project.d.ts +34 -0
- package/build/commands/project/project.d.ts.map +1 -0
- package/build/commands/project/project.js +119 -0
- package/build/commands/project/project.js.map +1 -0
- package/build/commands/proxy/index.d.ts +2 -1
- package/build/commands/proxy/index.d.ts.map +1 -1
- package/build/commands/proxy/index.js +6 -46
- package/build/commands/proxy/index.js.map +1 -1
- package/build/commands/proxy/proxy.d.ts.map +1 -1
- package/build/commands/proxy/proxy.js +7 -1
- package/build/commands/proxy/proxy.js.map +1 -1
- package/build/commands/registry/index.d.ts.map +1 -1
- package/build/commands/registry/index.js +16 -20
- package/build/commands/registry/index.js.map +1 -1
- package/build/commands/run/index.d.ts.map +1 -1
- package/build/commands/run/index.js +9 -3
- package/build/commands/run/index.js.map +1 -1
- package/build/commands/run/run.d.ts +4 -1
- package/build/commands/run/run.d.ts.map +1 -1
- package/build/commands/run/run.js +80 -14
- package/build/commands/run/run.js.map +1 -1
- package/build/commands/serve/cooperativeRuntime.d.ts.map +1 -1
- package/build/commands/serve/cooperativeRuntime.js +2 -1
- package/build/commands/serve/cooperativeRuntime.js.map +1 -1
- package/build/commands/serve/index.d.ts.map +1 -1
- package/build/commands/serve/index.js +57 -39
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serveStatus.d.ts.map +1 -1
- package/build/commands/serve/serveStatus.js +3 -0
- package/build/commands/serve/serveStatus.js.map +1 -1
- package/build/commands/serve/serveStop.d.ts.map +1 -1
- package/build/commands/serve/serveStop.js +38 -6
- package/build/commands/serve/serveStop.js.map +1 -1
- package/build/commands/shared/agentSession.d.ts +5 -0
- package/build/commands/shared/agentSession.d.ts.map +1 -0
- package/build/commands/shared/agentSession.js +75 -0
- package/build/commands/shared/agentSession.js.map +1 -0
- package/build/commands/shared/apiClient.d.ts +2 -0
- package/build/commands/shared/apiClient.d.ts.map +1 -1
- package/build/commands/shared/apiClient.js +10 -6
- package/build/commands/shared/apiClient.js.map +1 -1
- package/build/commands/shared/cliContext.d.ts +2 -1
- package/build/commands/shared/cliContext.d.ts.map +1 -1
- package/build/commands/shared/cliContext.js +2 -1
- package/build/commands/shared/cliContext.js.map +1 -1
- package/build/commands/shared/clientSurfaceAttachment.d.ts +7 -1
- package/build/commands/shared/clientSurfaceAttachment.d.ts.map +1 -1
- package/build/commands/shared/clientSurfaceAttachment.js +221 -140
- package/build/commands/shared/clientSurfaceAttachment.js.map +1 -1
- package/build/commands/shared/inspectApiSchemas.d.ts +4 -4
- package/build/commands/shared/projectOwnerStorage.d.ts +8 -0
- package/build/commands/shared/projectOwnerStorage.d.ts.map +1 -0
- package/build/commands/shared/projectOwnerStorage.js +63 -0
- package/build/commands/shared/projectOwnerStorage.js.map +1 -0
- package/build/commands/shared/projectOwnerStore.d.ts +78 -0
- package/build/commands/shared/projectOwnerStore.d.ts.map +1 -0
- package/build/commands/shared/projectOwnerStore.js +482 -0
- package/build/commands/shared/projectOwnerStore.js.map +1 -0
- package/build/commands/shared/projectSelectionOptions.d.ts +24 -0
- package/build/commands/shared/projectSelectionOptions.d.ts.map +1 -0
- package/build/commands/shared/projectSelectionOptions.js +20 -0
- package/build/commands/shared/projectSelectionOptions.js.map +1 -0
- package/build/commands/shared/serveTargetResolver.d.ts +7 -1
- package/build/commands/shared/serveTargetResolver.d.ts.map +1 -1
- package/build/commands/shared/serveTargetResolver.js +99 -4
- package/build/commands/shared/serveTargetResolver.js.map +1 -1
- package/build/commands/target/index.d.ts.map +1 -1
- package/build/commands/target/index.js +6 -13
- package/build/commands/target/index.js.map +1 -1
- package/build/commands/wait/index.d.ts.map +1 -1
- package/build/commands/wait/index.js +3 -3
- package/build/commands/wait/index.js.map +1 -1
- package/build/commands/wait/wait.d.ts +2 -1
- package/build/commands/wait/wait.d.ts.map +1 -1
- package/build/commands/wait/wait.js.map +1 -1
- package/build/config/configLoader.d.ts.map +1 -1
- package/build/config/configLoader.js +5 -1
- package/build/config/configLoader.js.map +1 -1
- package/build/config/configManager.d.ts.map +1 -1
- package/build/config/configManager.js +5 -1
- package/build/config/configManager.js.map +1 -1
- package/build/config/projectConfigLoader.d.ts +4 -0
- package/build/config/projectConfigLoader.d.ts.map +1 -1
- package/build/config/projectConfigLoader.js +129 -28
- package/build/config/projectConfigLoader.js.map +1 -1
- package/build/config/projectConfigTypes.d.ts +7 -0
- package/build/config/projectConfigTypes.d.ts.map +1 -1
- package/build/config/projectConfigTypes.js +1 -0
- package/build/config/projectConfigTypes.js.map +1 -1
- package/build/constants/cliTimeouts.d.ts +4 -0
- package/build/constants/cliTimeouts.d.ts.map +1 -0
- package/build/constants/cliTimeouts.js +4 -0
- package/build/constants/cliTimeouts.js.map +1 -0
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.d.ts.map +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/constants/mcp.js.map +1 -1
- package/build/core/capabilities/capabilityCatalog.d.ts +7 -0
- package/build/core/capabilities/capabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/capabilityCatalog.js +58 -2
- package/build/core/capabilities/capabilityCatalog.js.map +1 -1
- package/build/core/capabilities/capabilityPagination.d.ts +12 -4
- package/build/core/capabilities/capabilityPagination.d.ts.map +1 -1
- package/build/core/capabilities/capabilityPagination.js +15 -2
- package/build/core/capabilities/capabilityPagination.js.map +1 -1
- package/build/core/capabilities/capabilityVisibility.d.ts +3 -0
- package/build/core/capabilities/capabilityVisibility.d.ts.map +1 -1
- package/build/core/capabilities/capabilityVisibility.js.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts +2 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.js +2 -2
- package/build/core/capabilities/lazyLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/metaToolProvider.d.ts +2 -2
- package/build/core/capabilities/metaToolProvider.d.ts.map +1 -1
- package/build/core/capabilities/metaToolProvider.js +2 -2
- package/build/core/capabilities/metaToolProvider.js.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts +1 -0
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.js +23 -9
- package/build/core/capabilities/runtimeCapabilityCatalog.js.map +1 -1
- package/build/core/context/projectOwner.d.ts +16 -0
- package/build/core/context/projectOwner.d.ts.map +1 -0
- package/build/core/context/projectOwner.js +33 -0
- package/build/core/context/projectOwner.js.map +1 -0
- package/build/core/context/projectPreparationAuthority.d.ts +37 -0
- package/build/core/context/projectPreparationAuthority.d.ts.map +1 -0
- package/build/core/context/projectPreparationAuthority.js +113 -0
- package/build/core/context/projectPreparationAuthority.js.map +1 -0
- package/build/core/instructions/inspectionGuidance.d.ts +2 -0
- package/build/core/instructions/inspectionGuidance.d.ts.map +1 -0
- package/build/core/instructions/inspectionGuidance.js +2 -0
- package/build/core/instructions/inspectionGuidance.js.map +1 -0
- package/build/core/instructions/instructionAggregator.d.ts +1 -0
- package/build/core/instructions/instructionAggregator.d.ts.map +1 -1
- package/build/core/instructions/instructionAggregator.js +2 -2
- package/build/core/instructions/instructionAggregator.js.map +1 -1
- package/build/core/instructions/instructionsDistribution.d.ts +5 -0
- package/build/core/instructions/instructionsDistribution.d.ts.map +1 -1
- package/build/core/instructions/instructionsDistribution.js +72 -15
- package/build/core/instructions/instructionsDistribution.js.map +1 -1
- package/build/core/instructions/preparationGuidance.d.ts +3 -0
- package/build/core/instructions/preparationGuidance.d.ts.map +1 -0
- package/build/core/instructions/preparationGuidance.js +14 -0
- package/build/core/instructions/preparationGuidance.js.map +1 -0
- package/build/core/instructions/sessionGuidance.d.ts +3 -0
- package/build/core/instructions/sessionGuidance.d.ts.map +1 -0
- package/build/core/instructions/sessionGuidance.js +25 -0
- package/build/core/instructions/sessionGuidance.js.map +1 -0
- package/build/core/instructions/templateTypes.d.ts +3 -1
- package/build/core/instructions/templateTypes.d.ts.map +1 -1
- package/build/core/instructions/templateTypes.js +15 -5
- package/build/core/instructions/templateTypes.js.map +1 -1
- package/build/core/protocol/requestHandlerUtils.d.ts.map +1 -1
- package/build/core/protocol/requestHandlerUtils.js +23 -4
- package/build/core/protocol/requestHandlerUtils.js.map +1 -1
- package/build/core/server/connectionResolver.d.ts +5 -0
- package/build/core/server/connectionResolver.d.ts.map +1 -1
- package/build/core/server/connectionResolver.js +11 -0
- package/build/core/server/connectionResolver.js.map +1 -1
- package/build/core/server/pidFileManager.d.ts +20 -5
- package/build/core/server/pidFileManager.d.ts.map +1 -1
- package/build/core/server/pidFileManager.js +34 -15
- package/build/core/server/pidFileManager.js.map +1 -1
- package/build/core/server/processIdentity.d.ts +18 -0
- package/build/core/server/processIdentity.d.ts.map +1 -1
- package/build/core/server/processIdentity.js +13 -2
- package/build/core/server/processIdentity.js.map +1 -1
- package/build/core/server/runtimeLaunchIpc.d.ts +167 -2
- package/build/core/server/runtimeLaunchIpc.d.ts.map +1 -1
- package/build/core/server/runtimeOwnershipIdentityRepair.d.ts +21 -0
- package/build/core/server/runtimeOwnershipIdentityRepair.d.ts.map +1 -0
- package/build/core/server/runtimeOwnershipIdentityRepair.js +158 -0
- package/build/core/server/runtimeOwnershipIdentityRepair.js.map +1 -0
- package/build/core/server/runtimeReplacementConfig.d.ts +167 -2
- package/build/core/server/runtimeReplacementConfig.d.ts.map +1 -1
- package/build/core/server/runtimeScopeOwnership.d.ts +21 -2
- package/build/core/server/runtimeScopeOwnership.d.ts.map +1 -1
- package/build/core/server/runtimeScopeOwnership.js +145 -16
- package/build/core/server/runtimeScopeOwnership.js.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.d.ts +413 -7
- package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +59 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/index.d.ts +1 -1
- package/build/core/tools/internal/schemas/management.d.ts +1 -1
- package/build/core/types/server.d.ts +7 -1
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/transport.d.ts +249 -3
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +27 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/domains/admin/adminInstructionPreviewRuntime.d.ts.map +1 -1
- package/build/domains/admin/adminInstructionPreviewRuntime.js +4 -1
- package/build/domains/admin/adminInstructionPreviewRuntime.js.map +1 -1
- package/build/domains/backend-preparation/adapterRegistry.d.ts +8 -0
- package/build/domains/backend-preparation/adapterRegistry.d.ts.map +1 -0
- package/build/domains/backend-preparation/adapterRegistry.js +15 -0
- package/build/domains/backend-preparation/adapterRegistry.js.map +1 -0
- package/build/domains/backend-preparation/builtInIntegrationDefinitions.d.ts +4 -0
- package/build/domains/backend-preparation/builtInIntegrationDefinitions.d.ts.map +1 -0
- package/build/domains/backend-preparation/builtInIntegrationDefinitions.js +3 -0
- package/build/domains/backend-preparation/builtInIntegrationDefinitions.js.map +1 -0
- package/build/domains/backend-preparation/configuredCommandAdapter.d.ts +88 -0
- package/build/domains/backend-preparation/configuredCommandAdapter.d.ts.map +1 -0
- package/build/domains/backend-preparation/configuredCommandAdapter.js +196 -0
- package/build/domains/backend-preparation/configuredCommandAdapter.js.map +1 -0
- package/build/domains/backend-preparation/configuredCommandProcess.d.ts +27 -0
- package/build/domains/backend-preparation/configuredCommandProcess.d.ts.map +1 -0
- package/build/domains/backend-preparation/configuredCommandProcess.js +183 -0
- package/build/domains/backend-preparation/configuredCommandProcess.js.map +1 -0
- package/build/domains/backend-preparation/contracts.d.ts +131 -0
- package/build/domains/backend-preparation/contracts.d.ts.map +1 -0
- package/build/domains/backend-preparation/contracts.js +2 -0
- package/build/domains/backend-preparation/contracts.js.map +1 -0
- package/build/domains/backend-preparation/integrationDefinitions.d.ts +171 -0
- package/build/domains/backend-preparation/integrationDefinitions.d.ts.map +1 -0
- package/build/domains/backend-preparation/integrationDefinitions.js +246 -0
- package/build/domains/backend-preparation/integrationDefinitions.js.map +1 -0
- package/build/domains/backend-preparation/policy.d.ts +50 -0
- package/build/domains/backend-preparation/policy.d.ts.map +1 -0
- package/build/domains/backend-preparation/policy.js +58 -0
- package/build/domains/backend-preparation/policy.js.map +1 -0
- package/build/domains/backend-preparation/scheduler.d.ts +18 -0
- package/build/domains/backend-preparation/scheduler.d.ts.map +1 -0
- package/build/domains/backend-preparation/scheduler.js +62 -0
- package/build/domains/backend-preparation/scheduler.js.map +1 -0
- package/build/domains/backend-preparation/service.d.ts +67 -0
- package/build/domains/backend-preparation/service.d.ts.map +1 -0
- package/build/domains/backend-preparation/service.js +709 -0
- package/build/domains/backend-preparation/service.js.map +1 -0
- package/build/domains/config-change/configChange.js +5 -5
- package/build/domains/config-change/configChange.js.map +1 -1
- package/build/domains/installation/knownServerCatalog.d.ts +14 -0
- package/build/domains/installation/knownServerCatalog.d.ts.map +1 -0
- package/build/domains/installation/knownServerCatalog.js +56 -0
- package/build/domains/installation/knownServerCatalog.js.map +1 -0
- package/build/domains/installation/knownServerSetup.d.ts +21 -0
- package/build/domains/installation/knownServerSetup.d.ts.map +1 -0
- package/build/domains/installation/knownServerSetup.js +330 -0
- package/build/domains/installation/knownServerSetup.js.map +1 -0
- package/build/domains/installation/knownServerSetupTypes.d.ts +34 -0
- package/build/domains/installation/knownServerSetupTypes.d.ts.map +1 -0
- package/build/domains/installation/knownServerSetupTypes.js +2 -0
- package/build/domains/installation/knownServerSetupTypes.js.map +1 -0
- package/build/domains/project-selection/projectBindingScope.d.ts +7 -0
- package/build/domains/project-selection/projectBindingScope.d.ts.map +1 -0
- package/build/domains/project-selection/projectBindingScope.js +9 -0
- package/build/domains/project-selection/projectBindingScope.js.map +1 -0
- package/build/domains/project-selection/projectPolicy.d.ts +11 -0
- package/build/domains/project-selection/projectPolicy.d.ts.map +1 -0
- package/build/domains/project-selection/projectPolicy.js +104 -0
- package/build/domains/project-selection/projectPolicy.js.map +1 -0
- package/build/domains/project-selection/projectSelection.d.ts +30 -0
- package/build/domains/project-selection/projectSelection.d.ts.map +1 -0
- package/build/domains/project-selection/projectSelection.js +124 -0
- package/build/domains/project-selection/projectSelection.js.map +1 -0
- package/build/globalOptions.d.ts +9 -0
- package/build/globalOptions.d.ts.map +1 -1
- package/build/globalOptions.js +13 -11
- package/build/globalOptions.js.map +1 -1
- package/build/observability/events/registry.d.ts +67 -1
- package/build/observability/events/registry.d.ts.map +1 -1
- package/build/observability/events/registry.js +67 -1
- package/build/observability/events/registry.js.map +1 -1
- package/build/observability/privacy/fields.d.ts +4 -0
- package/build/observability/privacy/fields.d.ts.map +1 -1
- package/build/observability/privacy/fields.js +4 -0
- package/build/observability/privacy/fields.js.map +1 -1
- package/build/sdk/legacy/client/runtime/backendDispatchLifetime.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/backendDispatchLifetime.js +8 -2
- package/build/sdk/legacy/client/runtime/backendDispatchLifetime.js.map +1 -1
- package/build/sdk/legacy/client/runtime/legacyTransport.d.ts +2 -0
- package/build/sdk/legacy/client/runtime/legacyTransport.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/serveClient.d.ts +6 -1
- package/build/sdk/legacy/client/runtime/serveClient.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/serveClient.js +16 -5
- package/build/sdk/legacy/client/runtime/serveClient.js.map +1 -1
- package/build/sdk/legacy/commands/serve.d.ts.map +1 -1
- package/build/sdk/legacy/commands/serve.js +73 -4
- package/build/sdk/legacy/commands/serve.js.map +1 -1
- package/build/sdk/legacy/server/protocol/projectAdmission.d.ts +4 -0
- package/build/sdk/legacy/server/protocol/projectAdmission.d.ts.map +1 -0
- package/build/sdk/legacy/server/protocol/projectAdmission.js +24 -0
- package/build/sdk/legacy/server/protocol/projectAdmission.js.map +1 -0
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js +6 -3
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js +6 -4
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceSubscriptions.d.ts +1 -1
- package/build/sdk/legacy/server/protocol/resourceSubscriptions.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceSubscriptions.js +193 -41
- package/build/sdk/legacy/server/protocol/resourceSubscriptions.js.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js +93 -17
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts +12 -0
- package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/clientInstancePool.js +117 -4
- package/build/sdk/legacy/server/runtime/clientInstancePool.js.map +1 -1
- package/build/sdk/legacy/server/runtime/connectionManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/connectionManager.js +2 -0
- package/build/sdk/legacy/server/runtime/connectionManager.js.map +1 -1
- package/build/sdk/legacy/server/runtime/requestContextPreparation.d.ts +19 -1
- package/build/sdk/legacy/server/runtime/requestContextPreparation.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/requestContextPreparation.js +40 -7
- package/build/sdk/legacy/server/runtime/requestContextPreparation.js.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.d.ts +6 -2
- package/build/sdk/legacy/server/runtime/serverManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.js +85 -17
- package/build/sdk/legacy/server/runtime/serverManager.js.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.d.ts +26 -4
- package/build/sdk/legacy/server/runtime/templateServerManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.js +260 -14
- package/build/sdk/legacy/server/runtime/templateServerManager.js.map +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js.map +1 -1
- package/build/sdk/legacy/transport/http/streamableSessionLifecycle.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/streamableSessionLifecycle.js +14 -3
- package/build/sdk/legacy/transport/http/streamableSessionLifecycle.js.map +1 -1
- package/build/sdk/legacy/transport/stdioProxyTransport.d.ts +1 -0
- package/build/sdk/legacy/transport/stdioProxyTransport.d.ts.map +1 -1
- package/build/sdk/legacy/transport/stdioProxyTransport.js +2 -0
- package/build/sdk/legacy/transport/stdioProxyTransport.js.map +1 -1
- package/build/template/handlebarsTemplateRenderer.d.ts.map +1 -1
- package/build/template/handlebarsTemplateRenderer.js +3 -0
- package/build/template/handlebarsTemplateRenderer.js.map +1 -1
- package/build/transport/http/middlewares/projectAdmission.d.ts +5 -0
- package/build/transport/http/middlewares/projectAdmission.d.ts.map +1 -0
- package/build/transport/http/middlewares/projectAdmission.js +33 -0
- package/build/transport/http/middlewares/projectAdmission.js.map +1 -0
- package/build/transport/http/routes/apiRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/apiRoutes.js +4 -0
- package/build/transport/http/routes/apiRoutes.js.map +1 -1
- package/build/transport/http/routes/inspectHelpers.d.ts +1 -0
- package/build/transport/http/routes/inspectHelpers.d.ts.map +1 -1
- package/build/transport/http/routes/inspectHelpers.js +2 -0
- package/build/transport/http/routes/inspectHelpers.js.map +1 -1
- package/build/transport/http/routes/inspectRequestContext.d.ts +5 -2
- package/build/transport/http/routes/inspectRequestContext.d.ts.map +1 -1
- package/build/transport/http/routes/inspectRequestContext.js +41 -19
- package/build/transport/http/routes/inspectRequestContext.js.map +1 -1
- package/build/transport/http/routes/inspectRoutes.d.ts +11 -2
- package/build/transport/http/routes/inspectRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/inspectRoutes.js +94 -24
- package/build/transport/http/routes/inspectRoutes.js.map +1 -1
- package/build/transport/http/routes/instructionsRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/instructionsRoutes.js +20 -8
- package/build/transport/http/routes/instructionsRoutes.js.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.js +96 -13
- package/build/transport/http/routes/modernHttpRoutes.js.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.d.ts.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.js +3 -9
- package/build/transport/http/routes/modernInteractionBinding.js.map +1 -1
- package/build/transport/http/routes/modernSubscriptions.d.ts.map +1 -1
- package/build/transport/http/routes/modernSubscriptions.js +7 -5
- package/build/transport/http/routes/modernSubscriptions.js.map +1 -1
- package/build/transport/http/routes/modernTemplateContext.d.ts +2 -1
- package/build/transport/http/routes/modernTemplateContext.d.ts.map +1 -1
- package/build/transport/http/routes/modernTemplateContext.js +14 -3
- package/build/transport/http/routes/modernTemplateContext.js.map +1 -1
- package/build/transport/http/routes/modernToolHeaderRegistry.d.ts.map +1 -1
- package/build/transport/http/routes/modernToolHeaderRegistry.js +2 -2
- package/build/transport/http/routes/modernToolHeaderRegistry.js.map +1 -1
- package/build/transport/http/routes/preparationRoutes.d.ts +26 -0
- package/build/transport/http/routes/preparationRoutes.d.ts.map +1 -0
- package/build/transport/http/routes/preparationRoutes.js +132 -0
- package/build/transport/http/routes/preparationRoutes.js.map +1 -0
- package/build/transport/http/routes/projectRoutes.d.ts +18 -0
- package/build/transport/http/routes/projectRoutes.d.ts.map +1 -0
- package/build/transport/http/routes/projectRoutes.js +159 -0
- package/build/transport/http/routes/projectRoutes.js.map +1 -0
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +24 -4
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/routes/toolRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/toolRoutes.js +163 -20
- package/build/transport/http/routes/toolRoutes.js.map +1 -1
- package/build/transport/http/utils/contextExtractor.d.ts +2 -0
- package/build/transport/http/utils/contextExtractor.d.ts.map +1 -1
- package/build/transport/http/utils/contextExtractor.js +11 -0
- package/build/transport/http/utils/contextExtractor.js.map +1 -1
- package/build/transport/http/utils/templateContextAuthority.d.ts +2 -0
- package/build/transport/http/utils/templateContextAuthority.d.ts.map +1 -1
- package/build/transport/http/utils/templateContextAuthority.js +23 -2
- package/build/transport/http/utils/templateContextAuthority.js.map +1 -1
- package/build/types/context.d.ts +13 -0
- package/build/types/context.d.ts.map +1 -1
- package/build/types/context.js.map +1 -1
- package/build/utils/cli/help.d.ts +7 -0
- package/build/utils/cli/help.d.ts.map +1 -0
- package/build/utils/cli/help.js +57 -0
- package/build/utils/cli/help.js.map +1 -0
- package/package.json +20 -22
- package/build/admin/assets/admin-icons-CYGTDZA5.js +0 -1
- package/build/admin/assets/admin-vendor-62eL-qdH.js +0 -1
- package/build/admin/assets/admin-vendor-BbMrl7MK.js +0 -3
- package/build/admin/assets/admin-vendor-DpjVwd81.js +0 -62
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { BackendPolicySchema, BackendReadyReadinessSchema, PreparationFailureSchema, preparationKey, PreparationOptionsSchema, PreparationTargetSchema, } from './policy.js';
|
|
2
|
+
import { PreparationScheduler } from './scheduler.js';
|
|
3
|
+
export class BackendPreparationService {
|
|
4
|
+
registry;
|
|
5
|
+
options;
|
|
6
|
+
scheduler;
|
|
7
|
+
jobs = new Map();
|
|
8
|
+
identities = new Map();
|
|
9
|
+
sequence = 0;
|
|
10
|
+
shuttingDown = false;
|
|
11
|
+
constructor(registry, options = {}) {
|
|
12
|
+
this.registry = registry;
|
|
13
|
+
this.options = PreparationOptionsSchema.parse(options);
|
|
14
|
+
this.scheduler = new PreparationScheduler(this.options.concurrency, this.options.queueCapacity);
|
|
15
|
+
}
|
|
16
|
+
async inspect(target, operation, options = {}) {
|
|
17
|
+
const resolved = PreparationTargetSchema.parse(target);
|
|
18
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
19
|
+
if (!adapter)
|
|
20
|
+
return this.unsupported(resolved.backendName);
|
|
21
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
22
|
+
return this.probe(adapter, resolved, operation, waitMs, options.signal);
|
|
23
|
+
}
|
|
24
|
+
/** Explicit status inspection is read-only and never admits, retries, or changes a job. */
|
|
25
|
+
async inspectProgress(target, operation, options = {}) {
|
|
26
|
+
const resolved = PreparationTargetSchema.parse(target);
|
|
27
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
28
|
+
if (!adapter?.progress)
|
|
29
|
+
return undefined;
|
|
30
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
31
|
+
if (waitMs === 0 || options.signal?.aborted)
|
|
32
|
+
return undefined;
|
|
33
|
+
const controller = new AbortController();
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let settled = false;
|
|
36
|
+
const finish = (progress) => {
|
|
37
|
+
if (settled)
|
|
38
|
+
return;
|
|
39
|
+
settled = true;
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
options.signal?.removeEventListener('abort', stop);
|
|
42
|
+
resolve(progress);
|
|
43
|
+
};
|
|
44
|
+
const stop = () => {
|
|
45
|
+
controller.abort();
|
|
46
|
+
finish();
|
|
47
|
+
};
|
|
48
|
+
const timer = setTimeout(stop, waitMs);
|
|
49
|
+
options.signal?.addEventListener('abort', stop, { once: true });
|
|
50
|
+
try {
|
|
51
|
+
void adapter.progress(resolved, operation, { signal: controller.signal, waitMs }).then(finish, () => finish());
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
finish();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** Recovery only reconciles native evidence. A persisted running flag never starts or kills work. */
|
|
59
|
+
async recover(target, operation, advisory, options = {}) {
|
|
60
|
+
const resolved = PreparationTargetSchema.parse(target);
|
|
61
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
62
|
+
if (!adapter)
|
|
63
|
+
return this.unsupported(resolved.backendName);
|
|
64
|
+
if (!adapter.reconcile)
|
|
65
|
+
return {
|
|
66
|
+
state: 'conflict',
|
|
67
|
+
instructions: 'Native ownership reconciliation is unavailable; inspect prerequisites before explicit preparation.',
|
|
68
|
+
};
|
|
69
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
70
|
+
return this.readReadiness((signal) => adapter.reconcile(resolved, operation, advisory, { signal, waitMs }), (error) => adapter.classifyFailure(error), waitMs, options.signal);
|
|
71
|
+
}
|
|
72
|
+
async prepare(target, operation, policy, action, options = {}) {
|
|
73
|
+
if (this.shuttingDown)
|
|
74
|
+
return this.shutdownResult();
|
|
75
|
+
const resolved = Object.freeze(PreparationTargetSchema.parse(target));
|
|
76
|
+
const authority = BackendPolicySchema.parse(policy);
|
|
77
|
+
const active = this.activeJob(resolved, authority, action, operation);
|
|
78
|
+
if (active)
|
|
79
|
+
return { state: 'job', status: this.snapshot(active) };
|
|
80
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
81
|
+
if (!adapter)
|
|
82
|
+
return this.unsupported(resolved.backendName);
|
|
83
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
84
|
+
const readiness = await this.probe(adapter, resolved, operation, waitMs, options.signal);
|
|
85
|
+
return this.prepareInspected(resolved, operation, authority, adapter, readiness, action, undefined, options.beforeAdmission, options.validateAdmission);
|
|
86
|
+
}
|
|
87
|
+
async prepareInspected(resolved, operation, authority, adapter, readiness, action, replacement, beforeAdmission, validateAdmission) {
|
|
88
|
+
if (this.shuttingDown)
|
|
89
|
+
return this.shutdownResult();
|
|
90
|
+
const active = this.activeJob(resolved, authority, action, operation);
|
|
91
|
+
if (active)
|
|
92
|
+
return { state: 'job', status: this.snapshot(active) };
|
|
93
|
+
if (readiness.state === 'conflict')
|
|
94
|
+
return readiness;
|
|
95
|
+
if (readiness.state === 'unsupported')
|
|
96
|
+
return readiness;
|
|
97
|
+
if (readiness.state === 'unknown')
|
|
98
|
+
return readiness;
|
|
99
|
+
if (readiness.state === 'ready') {
|
|
100
|
+
if (!action) {
|
|
101
|
+
this.clearResolvedFailure(resolved, operation, authority, readiness);
|
|
102
|
+
return { state: 'ready', readiness };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const selected = action ?? (readiness.state === 'required' ? readiness.action : undefined);
|
|
106
|
+
if (!selected)
|
|
107
|
+
return { state: 'forbidden', instructions: 'No permitted preparation action was selected.' };
|
|
108
|
+
if (!authority.allowedActions.includes(selected))
|
|
109
|
+
return { state: 'forbidden', instructions: `Runtime policy does not permit ${selected}.` };
|
|
110
|
+
const key = `${preparationKey(resolved, authority, this.options, operation)}:${selected}`;
|
|
111
|
+
// Another compatible inspection may have admitted a job while this inspection was pending.
|
|
112
|
+
const failed = action ? undefined : this.failedJob(resolved, authority, operation);
|
|
113
|
+
if (failed)
|
|
114
|
+
return { state: 'job', status: this.snapshot(failed) };
|
|
115
|
+
const admitted = this.findJob(key);
|
|
116
|
+
if (admitted && admitted !== replacement && admitted.status.state !== 'ready') {
|
|
117
|
+
if (replacement)
|
|
118
|
+
return {
|
|
119
|
+
state: 'busy',
|
|
120
|
+
instructions: `Retry of ${replacement.status.id} (${replacement.status.action}) did not start: ${admitted.status.id} owns ${selected}. Check or explicitly retry that operation; both records are preserved.`,
|
|
121
|
+
};
|
|
122
|
+
if (admitted.status.action !== selected)
|
|
123
|
+
return {
|
|
124
|
+
state: 'busy',
|
|
125
|
+
instructions: `Preparation ${admitted.status.id} reserves ${selected} while performing ${admitted.status.action}; wait before explicitly selecting ${selected} again.`,
|
|
126
|
+
};
|
|
127
|
+
return { state: 'job', status: this.snapshot(admitted) };
|
|
128
|
+
}
|
|
129
|
+
if (!replacement)
|
|
130
|
+
this.releaseCompletedRecords();
|
|
131
|
+
if (this.jobs.size - (replacement ? 1 : 0) >= this.options.maxRecords)
|
|
132
|
+
return {
|
|
133
|
+
state: 'busy',
|
|
134
|
+
instructions: 'Preparation status capacity reached; use a new runtime after reconciling retained operations.',
|
|
135
|
+
};
|
|
136
|
+
if (validateAdmission) {
|
|
137
|
+
await validateAdmission();
|
|
138
|
+
// Validation may have yielded to another caller, shutdown, or a completed job.
|
|
139
|
+
// Repeat identity/capacity checks, then run the synchronous mutation guard with no further await.
|
|
140
|
+
return this.prepareInspected(resolved, operation, authority, adapter, readiness, action, replacement, beforeAdmission);
|
|
141
|
+
}
|
|
142
|
+
let complete;
|
|
143
|
+
const completion = new Promise((resolve) => {
|
|
144
|
+
complete = resolve;
|
|
145
|
+
});
|
|
146
|
+
const job = {
|
|
147
|
+
status: {
|
|
148
|
+
id: `preparation-${++this.sequence}`,
|
|
149
|
+
target: resolved,
|
|
150
|
+
operation,
|
|
151
|
+
action: selected,
|
|
152
|
+
state: 'queued',
|
|
153
|
+
attempt: 1,
|
|
154
|
+
executionDeadlineMs: authority.executionDeadlineMs ?? this.options.executionDeadlineMs,
|
|
155
|
+
readiness,
|
|
156
|
+
},
|
|
157
|
+
adapter,
|
|
158
|
+
policy: authority,
|
|
159
|
+
controller: new AbortController(),
|
|
160
|
+
listeners: new Set(),
|
|
161
|
+
settling: false,
|
|
162
|
+
createdAt: Date.now(),
|
|
163
|
+
retrying: false,
|
|
164
|
+
completion,
|
|
165
|
+
complete,
|
|
166
|
+
automatic: action === undefined,
|
|
167
|
+
};
|
|
168
|
+
if (!this.scheduler.schedule(job.status.id, async (wasQueued) => {
|
|
169
|
+
try {
|
|
170
|
+
await this.execute(job, wasQueued);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
job.complete();
|
|
174
|
+
}
|
|
175
|
+
}, JSON.stringify([resolved.checkoutRoot, resolved.backendName]), beforeAdmission)) {
|
|
176
|
+
return { state: 'busy', instructions: 'Preparation queue is full; submit a new request later.' };
|
|
177
|
+
}
|
|
178
|
+
if (replacement)
|
|
179
|
+
this.removeRecord(replacement);
|
|
180
|
+
this.jobs.set(job.status.id, job);
|
|
181
|
+
this.identities.set(key, job.status.id);
|
|
182
|
+
return { state: 'job', status: this.snapshot(job) };
|
|
183
|
+
}
|
|
184
|
+
/** Never receives an operation callback, so pending calls cannot be queued or replayed. */
|
|
185
|
+
async admit(target, operation, policy, preferences, options = {}) {
|
|
186
|
+
if (this.shuttingDown)
|
|
187
|
+
return this.shutdownResult();
|
|
188
|
+
const resolved = Object.freeze(PreparationTargetSchema.parse(target));
|
|
189
|
+
const authority = BackendPolicySchema.parse(policy);
|
|
190
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
191
|
+
const expiresAt = Date.now() + waitMs;
|
|
192
|
+
const remaining = () => Math.max(0, expiresAt - Date.now());
|
|
193
|
+
const active = this.activeJob(resolved, authority, undefined, operation);
|
|
194
|
+
let result;
|
|
195
|
+
if (active) {
|
|
196
|
+
result = { state: 'job', status: this.snapshot(active) };
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
200
|
+
if (!adapter)
|
|
201
|
+
return this.unsupported(resolved.backendName);
|
|
202
|
+
const readiness = await this.probe(adapter, resolved, operation, remaining(), options.signal);
|
|
203
|
+
const joined = this.activeJob(resolved, authority, undefined, operation);
|
|
204
|
+
if (joined)
|
|
205
|
+
result = { state: 'job', status: this.snapshot(joined) };
|
|
206
|
+
else {
|
|
207
|
+
if (readiness.state === 'ready') {
|
|
208
|
+
this.clearResolvedFailure(resolved, operation, authority, readiness);
|
|
209
|
+
return { state: 'ready', readiness };
|
|
210
|
+
}
|
|
211
|
+
if (readiness.state === 'unsupported')
|
|
212
|
+
return readiness;
|
|
213
|
+
if (readiness.state === 'conflict')
|
|
214
|
+
return readiness;
|
|
215
|
+
if (readiness.state === 'unknown')
|
|
216
|
+
return readiness;
|
|
217
|
+
if (!preferences[resolved.backendName]?.enabled)
|
|
218
|
+
return { state: 'disabled', instructions: readiness.instructions };
|
|
219
|
+
result = await this.prepareInspected(resolved, operation, authority, adapter, readiness, undefined, undefined, options.beforeAdmission, options.validateAdmission);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (result.state !== 'job')
|
|
223
|
+
return result;
|
|
224
|
+
if (result.status.state === 'failed')
|
|
225
|
+
return result;
|
|
226
|
+
if (result.status.state === 'not_ready')
|
|
227
|
+
return result;
|
|
228
|
+
if (result.status.state === 'cancelled')
|
|
229
|
+
return result;
|
|
230
|
+
return this.pending(result.status, `Preparation ${result.status.id} is ${result.status.state}. Check status or wait, then submit the original operation again.`);
|
|
231
|
+
}
|
|
232
|
+
pending(status, instructions) {
|
|
233
|
+
return {
|
|
234
|
+
state: 'pending',
|
|
235
|
+
status,
|
|
236
|
+
operationExecuted: false,
|
|
237
|
+
operationQueued: false,
|
|
238
|
+
instructions: `${instructions} The original operation has not executed and will not be replayed.`,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/** All admitted jobs, including automatic jobs with no public control handle. */
|
|
242
|
+
activeStatuses() {
|
|
243
|
+
return [...this.jobs.values()]
|
|
244
|
+
.filter((job) => ['queued', 'running', 'cancelling'].includes(job.status.state))
|
|
245
|
+
.map((job) => this.snapshot(job));
|
|
246
|
+
}
|
|
247
|
+
status(id) {
|
|
248
|
+
const job = this.jobs.get(id);
|
|
249
|
+
return job ? this.snapshot(job) : undefined;
|
|
250
|
+
}
|
|
251
|
+
async wait(id, options = {}) {
|
|
252
|
+
const job = this.jobs.get(id);
|
|
253
|
+
if (!job)
|
|
254
|
+
return undefined;
|
|
255
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
256
|
+
if (this.terminal(job))
|
|
257
|
+
return this.snapshot(job);
|
|
258
|
+
if (options.signal?.aborted)
|
|
259
|
+
return this.snapshot(job);
|
|
260
|
+
if (job.listeners.size >= 1024)
|
|
261
|
+
return this.snapshot(job);
|
|
262
|
+
await new Promise((resolve) => {
|
|
263
|
+
const finish = () => {
|
|
264
|
+
clearTimeout(timer);
|
|
265
|
+
job.listeners.delete(changed);
|
|
266
|
+
options.signal?.removeEventListener('abort', finish);
|
|
267
|
+
resolve();
|
|
268
|
+
};
|
|
269
|
+
const changed = () => {
|
|
270
|
+
if (this.terminal(job))
|
|
271
|
+
finish();
|
|
272
|
+
};
|
|
273
|
+
const timer = setTimeout(finish, waitMs);
|
|
274
|
+
job.listeners.add(changed);
|
|
275
|
+
options.signal?.addEventListener('abort', finish, { once: true });
|
|
276
|
+
});
|
|
277
|
+
return this.snapshot(job);
|
|
278
|
+
}
|
|
279
|
+
cancel(id) {
|
|
280
|
+
const job = this.jobs.get(id);
|
|
281
|
+
if (!job)
|
|
282
|
+
return undefined;
|
|
283
|
+
if (this.terminal(job))
|
|
284
|
+
return this.snapshot(job);
|
|
285
|
+
if (this.scheduler.cancelQueued(id)) {
|
|
286
|
+
this.update(job, { state: 'cancelled' });
|
|
287
|
+
job.complete();
|
|
288
|
+
return this.snapshot(job);
|
|
289
|
+
}
|
|
290
|
+
this.update(job, { state: 'cancelling' });
|
|
291
|
+
job.controller.abort();
|
|
292
|
+
return this.snapshot(job);
|
|
293
|
+
}
|
|
294
|
+
/** Explicit retry creates a new compatible identity when the execution budget changes. */
|
|
295
|
+
async retry(id, policy, options = {}) {
|
|
296
|
+
const job = this.jobs.get(id);
|
|
297
|
+
if (!job)
|
|
298
|
+
return { state: 'unsupported', instructions: 'Unknown preparation operation.' };
|
|
299
|
+
if (this.shuttingDown)
|
|
300
|
+
return this.shutdownResult();
|
|
301
|
+
if (job.retrying)
|
|
302
|
+
return { state: 'busy', instructions: 'Explicit retry inspection is already in progress.' };
|
|
303
|
+
if (job.settling)
|
|
304
|
+
return { state: 'busy', instructions: 'Owned preparation work has not stopped yet.' };
|
|
305
|
+
if (!this.terminal(job))
|
|
306
|
+
return { state: 'job', status: this.snapshot(job) };
|
|
307
|
+
const authority = BackendPolicySchema.parse(policy ?? job.policy);
|
|
308
|
+
const deadline = authority.executionDeadlineMs ?? this.options.executionDeadlineMs;
|
|
309
|
+
if (job.status.failure?.code === 'execution_deadline') {
|
|
310
|
+
if (deadline <= job.status.executionDeadlineMs)
|
|
311
|
+
return {
|
|
312
|
+
state: 'forbidden',
|
|
313
|
+
instructions: 'Execution deadline exhausted; explicitly select a larger execution budget before retrying.',
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
job.retrying = true;
|
|
317
|
+
try {
|
|
318
|
+
const waitMs = PreparationOptionsSchema.shape.requestWaitMs.parse(options.waitMs ?? this.options.requestWaitMs);
|
|
319
|
+
const readiness = await this.probe(job.adapter, job.status.target, job.status.operation, waitMs, options.signal);
|
|
320
|
+
if (readiness.state === 'required' && readiness.action !== job.status.action) {
|
|
321
|
+
if (!authority.allowedActions.includes(readiness.action))
|
|
322
|
+
return { state: 'forbidden', instructions: `Runtime policy does not permit ${readiness.action}.` };
|
|
323
|
+
const destination = this.findJob(`${preparationKey(job.status.target, authority, this.options, job.status.operation)}:${readiness.action}`);
|
|
324
|
+
if (destination && destination.status.state !== 'ready')
|
|
325
|
+
return {
|
|
326
|
+
state: 'busy',
|
|
327
|
+
instructions: `Retry of ${job.status.id} did not start: ${destination.status.id} already owns ${readiness.action}. Both records are preserved.`,
|
|
328
|
+
};
|
|
329
|
+
// A further required action is a separate job, explicitly admitted by retry.
|
|
330
|
+
// Preserve the previous action's terminal record rather than rewriting history.
|
|
331
|
+
return await this.prepareInspected(job.status.target, job.status.operation, authority, job.adapter, readiness, readiness.action, undefined, options.beforeAdmission, options.validateAdmission);
|
|
332
|
+
}
|
|
333
|
+
if (!authority.allowedActions.includes(job.status.action))
|
|
334
|
+
return { state: 'forbidden', instructions: `Runtime policy does not permit ${job.status.action}.` };
|
|
335
|
+
return await this.prepareInspected(job.status.target, job.status.operation, authority, job.adapter, readiness, job.status.action, job, options.beforeAdmission, options.validateAdmission);
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
job.retrying = false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/** Stop admission and wait for actual owned work settlement, including expired jobs. */
|
|
342
|
+
async shutdown() {
|
|
343
|
+
this.shuttingDown = true;
|
|
344
|
+
const completions = [];
|
|
345
|
+
for (const job of this.jobs.values()) {
|
|
346
|
+
if (job.settling)
|
|
347
|
+
job.controller.abort();
|
|
348
|
+
if (!this.terminal(job))
|
|
349
|
+
this.cancel(job.status.id);
|
|
350
|
+
completions.push(job.completion);
|
|
351
|
+
}
|
|
352
|
+
await Promise.all(completions);
|
|
353
|
+
}
|
|
354
|
+
/** Only restores a validated stable failure; it confers no process ownership or repair authority. */
|
|
355
|
+
importFailure(target, operation, policy, action, failure, state = 'failed') {
|
|
356
|
+
if (this.shuttingDown)
|
|
357
|
+
return undefined;
|
|
358
|
+
const resolved = Object.freeze(PreparationTargetSchema.parse(target));
|
|
359
|
+
const authority = BackendPolicySchema.parse(policy);
|
|
360
|
+
const diagnostic = PreparationFailureSchema.parse(failure);
|
|
361
|
+
if (!operation)
|
|
362
|
+
throw new Error('Preparation operation is required');
|
|
363
|
+
if (!authority.allowedActions.includes(action))
|
|
364
|
+
return undefined;
|
|
365
|
+
const adapter = this.registry.get(resolved.backendName);
|
|
366
|
+
if (!adapter)
|
|
367
|
+
return undefined;
|
|
368
|
+
const key = `${preparationKey(resolved, authority, this.options, operation)}:${action}`;
|
|
369
|
+
if (this.findJob(key))
|
|
370
|
+
return undefined;
|
|
371
|
+
if (this.activeJob(resolved, authority, undefined, operation))
|
|
372
|
+
return undefined;
|
|
373
|
+
this.releaseCompletedRecords();
|
|
374
|
+
if (this.jobs.size >= this.options.maxRecords)
|
|
375
|
+
return undefined;
|
|
376
|
+
const job = {
|
|
377
|
+
status: {
|
|
378
|
+
id: `preparation-${++this.sequence}`,
|
|
379
|
+
target: resolved,
|
|
380
|
+
operation,
|
|
381
|
+
action,
|
|
382
|
+
state,
|
|
383
|
+
attempt: 1,
|
|
384
|
+
executionDeadlineMs: authority.executionDeadlineMs ?? this.options.executionDeadlineMs,
|
|
385
|
+
failure: diagnostic,
|
|
386
|
+
},
|
|
387
|
+
adapter,
|
|
388
|
+
policy: authority,
|
|
389
|
+
controller: new AbortController(),
|
|
390
|
+
listeners: new Set(),
|
|
391
|
+
settling: false,
|
|
392
|
+
createdAt: Date.now(),
|
|
393
|
+
finishedAt: Date.now(),
|
|
394
|
+
retrying: false,
|
|
395
|
+
completion: Promise.resolve(),
|
|
396
|
+
complete: () => { },
|
|
397
|
+
automatic: false,
|
|
398
|
+
};
|
|
399
|
+
this.jobs.set(job.status.id, job);
|
|
400
|
+
this.identities.set(key, job.status.id);
|
|
401
|
+
return this.snapshot(job);
|
|
402
|
+
}
|
|
403
|
+
/** Caller supplies fresh native evidence; advisory state alone cannot resolve a failure. */
|
|
404
|
+
clearResolvedFailure(target, operation, policy, readiness) {
|
|
405
|
+
const resolved = PreparationTargetSchema.parse(target);
|
|
406
|
+
const authority = BackendPolicySchema.parse(policy);
|
|
407
|
+
BackendReadyReadinessSchema.parse(readiness);
|
|
408
|
+
const base = preparationKey(resolved, authority, this.options, operation);
|
|
409
|
+
let cleared = 0;
|
|
410
|
+
for (const action of authority.allowedActions) {
|
|
411
|
+
const job = this.findJob(`${base}:${action}`);
|
|
412
|
+
if (!job)
|
|
413
|
+
continue;
|
|
414
|
+
if (job.status.state !== 'failed' && job.status.state !== 'not_ready')
|
|
415
|
+
continue;
|
|
416
|
+
if (job.status.operation !== operation)
|
|
417
|
+
continue;
|
|
418
|
+
if (job.settling)
|
|
419
|
+
continue;
|
|
420
|
+
if (job.retrying)
|
|
421
|
+
continue;
|
|
422
|
+
this.removeRecord(job);
|
|
423
|
+
cleared++;
|
|
424
|
+
}
|
|
425
|
+
return cleared;
|
|
426
|
+
}
|
|
427
|
+
removeRecord(job) {
|
|
428
|
+
this.jobs.delete(job.status.id);
|
|
429
|
+
for (const [key, id] of this.identities) {
|
|
430
|
+
if (id === job.status.id)
|
|
431
|
+
this.identities.delete(key);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
shutdownResult() {
|
|
435
|
+
return { state: 'busy', instructions: 'Preparation runtime is shutting down; no new work can start.' };
|
|
436
|
+
}
|
|
437
|
+
async execute(job, wasQueued) {
|
|
438
|
+
if (job.controller.signal.aborted) {
|
|
439
|
+
this.update(job, { state: 'cancelled' });
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
job.settling = true;
|
|
443
|
+
this.update(job, { state: 'running' });
|
|
444
|
+
const expiresAt = Date.now() + job.status.executionDeadlineMs;
|
|
445
|
+
const deadline = setTimeout(() => {
|
|
446
|
+
if (job.status.state === 'cancelling')
|
|
447
|
+
return;
|
|
448
|
+
this.update(job, {
|
|
449
|
+
state: 'failed',
|
|
450
|
+
failure: {
|
|
451
|
+
code: 'execution_deadline',
|
|
452
|
+
message: 'Preparation execution deadline exhausted.',
|
|
453
|
+
retryable: false,
|
|
454
|
+
instructions: 'Wait for owned work to stop, then explicitly retry with a larger execution budget.',
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
job.controller.abort();
|
|
458
|
+
}, job.status.executionDeadlineMs);
|
|
459
|
+
try {
|
|
460
|
+
if (wasQueued) {
|
|
461
|
+
if (job.automatic) {
|
|
462
|
+
if (!(await this.reconcileQueuedReadiness(job, expiresAt)))
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
await this.runAttempts(job);
|
|
467
|
+
if (job.controller.signal.aborted) {
|
|
468
|
+
if (job.status.state !== 'failed')
|
|
469
|
+
this.update(job, { state: 'cancelled' });
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const readiness = await this.probe(job.adapter, job.status.target, job.status.operation, Math.max(0, expiresAt - Date.now()), job.controller.signal);
|
|
473
|
+
if (job.controller.signal.aborted) {
|
|
474
|
+
if (job.status.state !== 'failed')
|
|
475
|
+
this.update(job, { state: 'cancelled' });
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (readiness.state !== 'ready') {
|
|
479
|
+
this.update(job, {
|
|
480
|
+
state: 'not_ready',
|
|
481
|
+
readiness,
|
|
482
|
+
failure: {
|
|
483
|
+
code: readiness.state === 'required' ? 'further_action_required' : 'not_ready',
|
|
484
|
+
message: 'Preparation completed without verified readiness.',
|
|
485
|
+
retryable: false,
|
|
486
|
+
instructions: readiness.instructions,
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
this.update(job, { state: 'ready', readiness });
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
if (job.status.state === 'failed')
|
|
495
|
+
return;
|
|
496
|
+
if (job.controller.signal.aborted) {
|
|
497
|
+
this.update(job, { state: 'cancelled' });
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
this.update(job, { state: 'failed', failure: job.adapter.classifyFailure(error) });
|
|
501
|
+
}
|
|
502
|
+
finally {
|
|
503
|
+
clearTimeout(deadline);
|
|
504
|
+
job.settling = false;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
async reconcileQueuedReadiness(job, expiresAt) {
|
|
508
|
+
const readiness = await this.probe(job.adapter, job.status.target, job.status.operation, Math.max(0, expiresAt - Date.now()), job.controller.signal);
|
|
509
|
+
if (job.controller.signal.aborted) {
|
|
510
|
+
if (job.status.state !== 'failed')
|
|
511
|
+
this.update(job, { state: 'cancelled' });
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
if (readiness.state === 'ready') {
|
|
515
|
+
this.update(job, { state: 'ready', readiness });
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
if (readiness.state !== 'required') {
|
|
519
|
+
this.update(job, {
|
|
520
|
+
state: 'failed',
|
|
521
|
+
readiness,
|
|
522
|
+
failure: {
|
|
523
|
+
code: 'not_ready',
|
|
524
|
+
message: 'Queued preparation could not verify native readiness.',
|
|
525
|
+
retryable: false,
|
|
526
|
+
instructions: readiness.instructions,
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
if (!job.policy.allowedActions.includes(readiness.action)) {
|
|
532
|
+
this.update(job, {
|
|
533
|
+
state: 'failed',
|
|
534
|
+
readiness,
|
|
535
|
+
failure: {
|
|
536
|
+
code: 'action_forbidden',
|
|
537
|
+
message: `Runtime policy does not permit ${readiness.action}.`,
|
|
538
|
+
retryable: false,
|
|
539
|
+
instructions: readiness.instructions,
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
this.moveActionIdentity(job, readiness.action);
|
|
545
|
+
this.update(job, { action: readiness.action, readiness });
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
moveActionIdentity(job, action) {
|
|
549
|
+
const base = preparationKey(job.status.target, job.policy, this.options, job.status.operation);
|
|
550
|
+
const destinationKey = `${base}:${action}`;
|
|
551
|
+
const destination = this.findJob(destinationKey);
|
|
552
|
+
if (destination === job)
|
|
553
|
+
return;
|
|
554
|
+
if (destination) {
|
|
555
|
+
// Keep the inferred job's original reservation when another explicit job owns this action.
|
|
556
|
+
if (destination.status.state !== 'ready')
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const oldKey = `${base}:${job.status.action}`;
|
|
560
|
+
if (this.identities.get(oldKey) === job.status.id)
|
|
561
|
+
this.identities.delete(oldKey);
|
|
562
|
+
this.identities.set(destinationKey, job.status.id);
|
|
563
|
+
}
|
|
564
|
+
async runAttempts(job) {
|
|
565
|
+
const retryLimit = job.policy.transientRetryLimit ?? 0;
|
|
566
|
+
for (let retry = 0;; retry++) {
|
|
567
|
+
try {
|
|
568
|
+
await job.adapter.prepare(job.status.target, job.status.action, {
|
|
569
|
+
signal: job.controller.signal,
|
|
570
|
+
executionDeadlineMs: job.status.executionDeadlineMs,
|
|
571
|
+
operation: job.status.operation,
|
|
572
|
+
});
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
catch (error) {
|
|
576
|
+
if (job.controller.signal.aborted)
|
|
577
|
+
throw error;
|
|
578
|
+
const failure = job.adapter.classifyFailure(error);
|
|
579
|
+
if (!failure.retryable)
|
|
580
|
+
throw error;
|
|
581
|
+
if (retry >= retryLimit)
|
|
582
|
+
throw error;
|
|
583
|
+
this.update(job, { attempt: job.status.attempt + 1 });
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
releaseCompletedRecords() {
|
|
588
|
+
if (this.jobs.size < this.options.maxRecords)
|
|
589
|
+
return;
|
|
590
|
+
for (const [id, job] of this.jobs) {
|
|
591
|
+
if (job.settling)
|
|
592
|
+
continue;
|
|
593
|
+
if (job.retrying)
|
|
594
|
+
continue;
|
|
595
|
+
if (job.status.state !== 'ready' && job.status.state !== 'cancelled')
|
|
596
|
+
continue;
|
|
597
|
+
this.jobs.delete(id);
|
|
598
|
+
for (const [key, mappedId] of this.identities) {
|
|
599
|
+
if (mappedId === id)
|
|
600
|
+
this.identities.delete(key);
|
|
601
|
+
}
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
failedJob(target, policy, operation) {
|
|
606
|
+
const base = preparationKey(target, policy, this.options, operation);
|
|
607
|
+
for (const action of policy.allowedActions) {
|
|
608
|
+
const job = this.findJob(`${base}:${action}`);
|
|
609
|
+
if (job?.status.state === 'failed' || job?.status.state === 'not_ready')
|
|
610
|
+
return job;
|
|
611
|
+
}
|
|
612
|
+
return undefined;
|
|
613
|
+
}
|
|
614
|
+
activeJob(target, policy, action, operation) {
|
|
615
|
+
const base = preparationKey(target, policy, this.options, operation);
|
|
616
|
+
const actions = action ? [action] : policy.allowedActions;
|
|
617
|
+
for (const selected of actions) {
|
|
618
|
+
const job = this.findJob(`${base}:${selected}`);
|
|
619
|
+
if (action) {
|
|
620
|
+
if (job?.status.action !== action)
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (job && !this.terminal(job))
|
|
624
|
+
return job;
|
|
625
|
+
if (job?.settling)
|
|
626
|
+
return job;
|
|
627
|
+
}
|
|
628
|
+
return undefined;
|
|
629
|
+
}
|
|
630
|
+
async probe(adapter, target, operation, waitMs, signal) {
|
|
631
|
+
return this.readReadiness((signal) => adapter.inspect(target, operation, { signal, waitMs }), (error) => adapter.classifyFailure(error), waitMs, signal);
|
|
632
|
+
}
|
|
633
|
+
async readReadiness(inspect, classifyFailure, waitMs, signal) {
|
|
634
|
+
const controller = new AbortController();
|
|
635
|
+
return new Promise((resolve) => {
|
|
636
|
+
let settled = false;
|
|
637
|
+
const finish = (readiness) => {
|
|
638
|
+
if (settled)
|
|
639
|
+
return;
|
|
640
|
+
settled = true;
|
|
641
|
+
clearTimeout(timer);
|
|
642
|
+
signal?.removeEventListener('abort', stop);
|
|
643
|
+
resolve(readiness);
|
|
644
|
+
};
|
|
645
|
+
const stop = () => {
|
|
646
|
+
controller.abort();
|
|
647
|
+
finish({
|
|
648
|
+
state: 'unknown',
|
|
649
|
+
reason: signal?.aborted ? 'caller_disconnected' : 'inspection_timeout',
|
|
650
|
+
instructions: 'Readiness inspection did not complete within the caller budget; no backend operation executed. Inspect again before preparing.',
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
const timer = setTimeout(stop, waitMs);
|
|
654
|
+
if (signal?.aborted) {
|
|
655
|
+
stop();
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (waitMs === 0) {
|
|
659
|
+
stop();
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
663
|
+
const failed = (error) => {
|
|
664
|
+
if (settled)
|
|
665
|
+
return;
|
|
666
|
+
try {
|
|
667
|
+
const failure = classifyFailure(error);
|
|
668
|
+
finish({ state: 'conflict', instructions: failure.instructions });
|
|
669
|
+
}
|
|
670
|
+
catch {
|
|
671
|
+
finish({
|
|
672
|
+
state: 'unsupported',
|
|
673
|
+
instructions: 'The readiness adapter failed and could not classify the failure. Check adapter configuration and native prerequisites; no backend operation executed.',
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
try {
|
|
678
|
+
void inspect(controller.signal).then(finish, failed);
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
failed(error);
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
findJob(key) {
|
|
686
|
+
const id = this.identities.get(key);
|
|
687
|
+
return id ? this.jobs.get(id) : undefined;
|
|
688
|
+
}
|
|
689
|
+
snapshot(job) {
|
|
690
|
+
return structuredClone({ ...job.status, elapsedMs: Math.max(0, (job.finishedAt ?? Date.now()) - job.createdAt) });
|
|
691
|
+
}
|
|
692
|
+
update(job, fields) {
|
|
693
|
+
job.status = { ...job.status, ...fields };
|
|
694
|
+
if (this.terminal(job))
|
|
695
|
+
job.finishedAt ??= Date.now();
|
|
696
|
+
for (const listener of job.listeners)
|
|
697
|
+
listener();
|
|
698
|
+
}
|
|
699
|
+
terminal(job) {
|
|
700
|
+
return ['ready', 'not_ready', 'failed', 'cancelled'].includes(job.status.state);
|
|
701
|
+
}
|
|
702
|
+
unsupported(backendName) {
|
|
703
|
+
return {
|
|
704
|
+
state: 'unsupported',
|
|
705
|
+
instructions: `No preparation adapter is registered for ${backendName}; prepare it using supported native instructions.`,
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//# sourceMappingURL=service.js.map
|