spawnfile 0.1.13 → 0.1.14
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 +50 -11
- package/dist/audit/auditCli.d.ts +19 -0
- package/dist/audit/auditCli.js +63 -0
- package/dist/audit/checks.d.ts +100 -0
- package/dist/audit/checks.js +279 -0
- package/dist/audit/checksShared.d.ts +74 -0
- package/dist/audit/checksShared.js +37 -0
- package/dist/audit/generateAudit.d.ts +19 -0
- package/dist/audit/generateAudit.js +122 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.js +4 -0
- package/dist/audit/readAudit.d.ts +50 -0
- package/dist/audit/readAudit.js +59 -0
- package/dist/audit/types.d.ts +40 -0
- package/dist/audit/types.js +8 -0
- package/dist/auth/credentialEnvFile.d.ts +11 -0
- package/dist/auth/credentialEnvFile.js +60 -0
- package/dist/auth/credentialProvisioning.d.ts +15 -0
- package/dist/auth/credentialProvisioning.js +75 -0
- package/dist/auth/credentialProvisioningReceipt.d.ts +28 -0
- package/dist/auth/credentialProvisioningReceipt.js +70 -0
- package/dist/auth/credentialProvisioningRequest.d.ts +51 -0
- package/dist/auth/credentialProvisioningRequest.js +169 -0
- package/dist/auth/credentialWorldBindings.d.ts +21 -0
- package/dist/auth/credentialWorldBindings.js +104 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/paths.d.ts +11 -0
- package/dist/auth/paths.js +21 -0
- package/dist/auth/targetSecretSourceAuthor.d.ts +18 -0
- package/dist/auth/targetSecretSourceAuthor.js +52 -0
- package/dist/auth/targetSecretSourceFsPublish.d.ts +15 -0
- package/dist/auth/targetSecretSourceFsPublish.js +49 -0
- package/dist/auth/targetSecretSourceFsPublishImmutable.d.ts +16 -0
- package/dist/auth/targetSecretSourceFsPublishImmutable.js +435 -0
- package/dist/auth/targetSecretSourceFsRead.d.ts +14 -0
- package/dist/auth/targetSecretSourceFsRead.js +198 -0
- package/dist/auth/targetSecretSourceGrant.d.ts +16 -0
- package/dist/auth/targetSecretSourceGrant.js +99 -0
- package/dist/auth/targetSecretSourceGrantRecords.d.ts +84 -0
- package/dist/auth/targetSecretSourceGrantRecords.js +214 -0
- package/dist/auth/targetSecretSourceLifecycle.d.ts +30 -0
- package/dist/auth/targetSecretSourceLifecycle.js +52 -0
- package/dist/auth/targetSecretSourceOwnerEntropy.d.ts +6 -0
- package/dist/auth/targetSecretSourceOwnerEntropy.js +28 -0
- package/dist/auth/targetSecretSourceRecordCommon.d.ts +14 -0
- package/dist/auth/targetSecretSourceRecordCommon.js +100 -0
- package/dist/auth/targetSecretSourceRecordPublish.d.ts +10 -0
- package/dist/auth/targetSecretSourceRecordPublish.js +104 -0
- package/dist/auth/targetSecretSourceResolver.d.ts +10 -0
- package/dist/auth/targetSecretSourceResolver.js +137 -0
- package/dist/auth/targetSecretSourceRevoke.d.ts +20 -0
- package/dist/auth/targetSecretSourceRevoke.js +92 -0
- package/dist/auth/targetSecretSourceRotate.d.ts +19 -0
- package/dist/auth/targetSecretSourceRotate.js +121 -0
- package/dist/auth/targetSecretSourceVersionRecords.d.ts +49 -0
- package/dist/auth/targetSecretSourceVersionRecords.js +166 -0
- package/dist/cli/artifactsCommands.d.ts +27 -0
- package/dist/cli/artifactsCommands.js +132 -0
- package/dist/cli/authCommands.d.ts +5 -0
- package/dist/cli/authCommands.js +221 -0
- package/dist/cli/compileBuildCommands.d.ts +3 -0
- package/dist/cli/compileBuildCommands.js +35 -0
- package/dist/cli/containerBundleCommand.d.ts +6 -0
- package/dist/cli/containerBundleCommand.js +116 -0
- package/dist/cli/downCommand.d.ts +25 -0
- package/dist/cli/downCommand.js +134 -0
- package/dist/cli/index.js +6 -3
- package/dist/cli/lifecycleCommands.d.ts +1 -1
- package/dist/cli/lifecycleCommands.js +11 -181
- package/dist/cli/lifecycleMachine.d.ts +19 -0
- package/dist/cli/lifecycleMachine.js +78 -0
- package/dist/cli/lifecyclePlan.d.ts +35 -0
- package/dist/cli/lifecyclePlan.js +240 -0
- package/dist/cli/lifecyclePlanningCommands.d.ts +3 -0
- package/dist/cli/lifecyclePlanningCommands.js +30 -0
- package/dist/cli/runCli.d.ts +9 -2
- package/dist/cli/runCli.js +27 -71
- package/dist/cli/runPublishCommands.d.ts +3 -0
- package/dist/cli/runPublishCommands.js +70 -0
- package/dist/cli/statusCommand.d.ts +3 -33
- package/dist/cli/statusCommand.js +19 -249
- package/dist/cli/statusCommandLive.d.ts +20 -0
- package/dist/cli/statusCommandLive.js +188 -0
- package/dist/cli/statusCommandOptions.d.ts +40 -0
- package/dist/cli/statusCommandOptions.js +42 -0
- package/dist/cli/targetCliRoute.d.ts +2 -0
- package/dist/cli/targetCliRoute.js +30 -0
- package/dist/cli/targetCommands.d.ts +33 -0
- package/dist/cli/targetCommands.js +257 -0
- package/dist/cli/targetComposedPreparationCommand.d.ts +6 -0
- package/dist/cli/targetComposedPreparationCommand.js +39 -0
- package/dist/cli/targetDefaultArtifactAuthority.d.ts +5 -0
- package/dist/cli/targetDefaultArtifactAuthority.js +28 -0
- package/dist/cli/targetDefaultAuthorities.d.ts +53 -0
- package/dist/cli/targetDefaultAuthorities.js +210 -0
- package/dist/cli/targetDefaultConfig.d.ts +68 -0
- package/dist/cli/targetDefaultConfig.js +317 -0
- package/dist/cli/targetDefaultConfigStdin.d.ts +13 -0
- package/dist/cli/targetDefaultConfigStdin.js +215 -0
- package/dist/cli/targetDefaultEnvelope.d.ts +1 -0
- package/dist/cli/targetDefaultEnvelope.js +13 -0
- package/dist/cli/targetDefaultHandlerFactory.d.ts +28 -0
- package/dist/cli/targetDefaultHandlerFactory.js +247 -0
- package/dist/cli/targetDefaultHandlers.d.ts +21 -0
- package/dist/cli/targetDefaultHandlers.js +72 -0
- package/dist/cli/targetDefaultJournalAuthority.d.ts +35 -0
- package/dist/cli/targetDefaultJournalAuthority.js +135 -0
- package/dist/cli/targetDefaultWorldClock.d.ts +4 -0
- package/dist/cli/targetDefaultWorldClock.js +14 -0
- package/dist/cli/targetDefaultWorldQueries.d.ts +5 -0
- package/dist/cli/targetDefaultWorldQueries.js +11 -0
- package/dist/cli/targetDefaultWorldReadiness.d.ts +4 -0
- package/dist/cli/targetDefaultWorldReadiness.js +17 -0
- package/dist/cli/targetEvidenceHelperResolution.d.ts +14 -0
- package/dist/cli/targetEvidenceHelperResolution.js +23 -0
- package/dist/cli/targetLookupCli.d.ts +3 -0
- package/dist/cli/targetLookupCli.js +31 -0
- package/dist/cli/targetLookupCommands.d.ts +12 -0
- package/dist/cli/targetLookupCommands.js +69 -0
- package/dist/cli/targetOperationDispatch.d.ts +58 -0
- package/dist/cli/targetOperationDispatch.js +21 -0
- package/dist/cli/targetReceiptOutput.d.ts +14 -0
- package/dist/cli/targetReceiptOutput.js +21 -0
- package/dist/cli/targetRequestFile.d.ts +14 -0
- package/dist/cli/targetRequestFile.js +63 -0
- package/dist/cli/targetSecretSourceInput.d.ts +28 -0
- package/dist/cli/targetSecretSourceInput.js +121 -0
- package/dist/cli/targetWorldClockCommand.d.ts +10 -0
- package/dist/cli/targetWorldClockCommand.js +42 -0
- package/dist/cli/targetWorldClockCrossProcess.test-helper.d.ts +13 -0
- package/dist/cli/targetWorldClockCrossProcess.test-helper.js +109 -0
- package/dist/cli/targetWorldReadinessCommand.d.ts +10 -0
- package/dist/cli/targetWorldReadinessCommand.js +43 -0
- package/dist/cli/upCommand.d.ts +3 -0
- package/dist/cli/upCommand.js +133 -0
- package/dist/cli/upImageCommand.d.ts +11 -0
- package/dist/cli/upImageCommand.js +41 -0
- package/dist/cli/upLifecycleInvocation.d.ts +41 -0
- package/dist/cli/upLifecycleInvocation.js +48 -0
- package/dist/cli/upLifecycleRecovery.d.ts +4 -0
- package/dist/cli/upLifecycleRecovery.js +53 -0
- package/dist/compiler/agentNodeMerge.d.ts +2 -0
- package/dist/compiler/agentNodeMerge.js +79 -0
- package/dist/compiler/agentSurfaces.js +11 -1
- package/dist/compiler/buildCompilePlan.js +17 -0
- package/dist/compiler/buildCompilePlanAgent.d.ts +11 -0
- package/dist/compiler/buildCompilePlanAgent.js +56 -0
- package/dist/compiler/buildCompilePlanTeams.d.ts +1 -0
- package/dist/compiler/buildCompilePlanTeams.js +4 -1
- package/dist/compiler/buildCompilePlanTraversal.js +75 -82
- package/dist/compiler/buildProject.d.ts +11 -0
- package/dist/compiler/buildProject.js +77 -2
- package/dist/compiler/compilePlanHelpers.js +2 -0
- package/dist/compiler/compileProject.d.ts +13 -0
- package/dist/compiler/compileProject.js +26 -74
- package/dist/compiler/compileProjectPolicy.d.ts +5 -0
- package/dist/compiler/compileProjectPolicy.js +21 -0
- package/dist/compiler/compileProjectReports.d.ts +9 -0
- package/dist/compiler/compileProjectReports.js +52 -0
- package/dist/compiler/containerArtifactSummaries.d.ts +7 -0
- package/dist/compiler/containerArtifactSummaries.js +138 -0
- package/dist/compiler/containerArtifacts.d.ts +10 -0
- package/dist/compiler/containerArtifacts.js +126 -125
- package/dist/compiler/containerArtifactsPlans.d.ts +5 -3
- package/dist/compiler/containerArtifactsPlans.js +31 -118
- package/dist/compiler/containerArtifactsRender.d.ts +3 -1
- package/dist/compiler/containerArtifactsRender.js +15 -12
- package/dist/compiler/containerArtifactsTypes.d.ts +12 -0
- package/dist/compiler/containerConfigEnvRender.d.ts +3 -0
- package/dist/compiler/containerConfigEnvRender.js +54 -0
- package/dist/compiler/containerEntrypointRender.d.ts +1 -0
- package/dist/compiler/containerEntrypointRender.js +56 -52
- package/dist/compiler/containerEntrypointShell.d.ts +5 -0
- package/dist/compiler/containerEntrypointShell.js +29 -0
- package/dist/compiler/containerPackageOverrides.d.ts +27 -0
- package/dist/compiler/containerPackageOverrides.js +63 -0
- package/dist/compiler/containerTargetPlanResolution.d.ts +20 -0
- package/dist/compiler/containerTargetPlanResolution.js +97 -0
- package/dist/compiler/daimonTelemetryArtifacts.d.ts +22 -0
- package/dist/compiler/daimonTelemetryArtifacts.js +61 -0
- package/dist/compiler/dockerBuildContext.d.ts +16 -0
- package/dist/compiler/dockerBuildContext.js +159 -0
- package/dist/compiler/dockerBuildSkip.d.ts +30 -0
- package/dist/compiler/dockerBuildSkip.js +81 -0
- package/dist/compiler/index.d.ts +4 -0
- package/dist/compiler/index.js +4 -0
- package/dist/compiler/memoryArtifacts.d.ts +26 -0
- package/dist/compiler/memoryArtifacts.js +134 -0
- package/dist/compiler/memoryResolution.d.ts +4 -0
- package/dist/compiler/memoryResolution.js +147 -0
- package/dist/compiler/modelEnv.d.ts +2 -0
- package/dist/compiler/modelEnv.js +6 -0
- package/dist/compiler/moltnetAllowedWakeSendersValidation.d.ts +2 -0
- package/dist/compiler/moltnetAllowedWakeSendersValidation.js +42 -0
- package/dist/compiler/moltnetArtifactPaths.d.ts +26 -0
- package/dist/compiler/moltnetArtifactPaths.js +49 -0
- package/dist/compiler/moltnetArtifactTypes.d.ts +46 -0
- package/dist/compiler/moltnetArtifactTypes.js +1 -0
- package/dist/compiler/moltnetArtifacts.d.ts +2 -40
- package/dist/compiler/moltnetArtifacts.js +43 -97
- package/dist/compiler/moltnetBinaries.d.ts +21 -4
- package/dist/compiler/moltnetBinaries.js +134 -27
- package/dist/compiler/moltnetClientConfig.js +7 -2
- package/dist/compiler/moltnetConfigLowering.d.ts +16 -1
- package/dist/compiler/moltnetConfigLowering.js +67 -5
- package/dist/compiler/moltnetExternalParticipantArtifact.d.ts +38 -0
- package/dist/compiler/moltnetExternalParticipantArtifact.js +188 -0
- package/dist/compiler/moltnetNodeConfig.js +7 -2
- package/dist/compiler/moltnetReleaseAuthority.d.ts +17 -0
- package/dist/compiler/moltnetReleaseAuthority.js +73 -0
- package/dist/compiler/moltnetReleaseDownload.d.ts +12 -0
- package/dist/compiler/moltnetReleaseDownload.js +85 -0
- package/dist/compiler/moltnetRepresentativeResolution.d.ts +1 -0
- package/dist/compiler/moltnetRepresentativeResolution.js +16 -2
- package/dist/compiler/moltnetResolution.js +72 -20
- package/dist/compiler/moltnetRoomMemberships.js +37 -9
- package/dist/compiler/moltnetServerPlans.d.ts +9 -0
- package/dist/compiler/moltnetServerPlans.js +132 -0
- package/dist/compiler/organizationIdentity.d.ts +27 -0
- package/dist/compiler/organizationIdentity.js +297 -0
- package/dist/compiler/organizationReadyEvidence.d.ts +49 -0
- package/dist/compiler/organizationReadyEvidence.js +261 -0
- package/dist/compiler/projectManifestGraph.d.ts +4 -0
- package/dist/compiler/projectManifestGraph.js +24 -0
- package/dist/compiler/runProject.d.ts +4 -0
- package/dist/compiler/runProject.js +30 -21
- package/dist/compiler/runProjectAuth.d.ts +7 -1
- package/dist/compiler/runProjectAuth.js +87 -9
- package/dist/compiler/runProjectDocker.d.ts +7 -0
- package/dist/compiler/runProjectDocker.js +31 -8
- package/dist/compiler/runProjectLifecycle.d.ts +7 -0
- package/dist/compiler/runProjectLifecycle.js +40 -0
- package/dist/compiler/syncProjectAuth.js +4 -1
- package/dist/compiler/teamContextActiveEnvironments.d.ts +13 -0
- package/dist/compiler/teamContextActiveEnvironments.js +255 -0
- package/dist/compiler/teamContextSupport.js +32 -40
- package/dist/compiler/teamContextTypes.d.ts +2 -0
- package/dist/compiler/types.d.ts +82 -1
- package/dist/compiler/upProject.d.ts +5 -0
- package/dist/compiler/upProject.js +256 -20
- package/dist/compiler/upReceipt.d.ts +36 -0
- package/dist/compiler/upReceipt.js +82 -0
- package/dist/compiler/updateProjectModels.js +42 -60
- package/dist/compiler/updateProjectRuntime.js +22 -35
- package/dist/compiler/updateProjectSurfaces.js +53 -47
- package/dist/compiler/worldBindings.d.ts +39 -0
- package/dist/compiler/worldBindings.js +247 -0
- package/dist/compiler/worldBindingsFile.d.ts +5 -0
- package/dist/compiler/worldBindingsFile.js +162 -0
- package/dist/deployment/artifactsExport.d.ts +49 -0
- package/dist/deployment/artifactsExport.js +217 -0
- package/dist/deployment/artifactsExportDocker.d.ts +48 -0
- package/dist/deployment/artifactsExportDocker.js +91 -0
- package/dist/deployment/artifactsExportPlan.d.ts +24 -0
- package/dist/deployment/artifactsExportPlan.js +135 -0
- package/dist/deployment/artifactsExportTypes.d.ts +50 -0
- package/dist/deployment/artifactsExportTypes.js +52 -0
- package/dist/deployment/buildImageCacheStore.d.ts +23 -0
- package/dist/deployment/buildImageCacheStore.js +54 -0
- package/dist/deployment/deploymentLifecycleCorrelation.d.ts +11 -0
- package/dist/deployment/deploymentLifecycleCorrelation.js +33 -0
- package/dist/deployment/dockerInspect.d.ts +9 -0
- package/dist/deployment/dockerInspect.js +24 -1
- package/dist/deployment/dockerLabels.d.ts +2 -0
- package/dist/deployment/dockerLabels.js +2 -0
- package/dist/deployment/dockerLogs.js +2 -10
- package/dist/deployment/dockerManager.d.ts +51 -0
- package/dist/deployment/dockerManager.js +118 -1
- package/dist/deployment/dockerProbeGateway.js +64 -5
- package/dist/deployment/dockerRecover.js +9 -1
- package/dist/deployment/dockerTeardown.d.ts +32 -0
- package/dist/deployment/dockerTeardown.js +61 -0
- package/dist/deployment/downDeployment.d.ts +34 -0
- package/dist/deployment/downDeployment.js +147 -0
- package/dist/deployment/downReceiptTypes.d.ts +21 -0
- package/dist/deployment/downReceiptTypes.js +30 -0
- package/dist/deployment/index.d.ts +16 -0
- package/dist/deployment/index.js +17 -0
- package/dist/deployment/lifecycleCompletion.d.ts +37 -0
- package/dist/deployment/lifecycleCompletion.js +236 -0
- package/dist/deployment/lifecycleCompletionContracts.d.ts +158 -0
- package/dist/deployment/lifecycleCompletionContracts.js +106 -0
- package/dist/deployment/lifecycleCompletionHeartbeat.d.ts +2 -0
- package/dist/deployment/lifecycleCompletionHeartbeat.js +50 -0
- package/dist/deployment/lifecycleCompletionLookup.d.ts +18 -0
- package/dist/deployment/lifecycleCompletionLookup.js +88 -0
- package/dist/deployment/lifecycleCompletionOwner.d.ts +8 -0
- package/dist/deployment/lifecycleCompletionOwner.js +31 -0
- package/dist/deployment/lifecycleCompletionParsing.d.ts +12 -0
- package/dist/deployment/lifecycleCompletionParsing.js +108 -0
- package/dist/deployment/lifecycleCompletionPaths.d.ts +9 -0
- package/dist/deployment/lifecycleCompletionPaths.js +16 -0
- package/dist/deployment/lifecycleCompletionPublication.d.ts +5 -0
- package/dist/deployment/lifecycleCompletionPublication.js +35 -0
- package/dist/deployment/lifecycleCompletionRecovery.d.ts +21 -0
- package/dist/deployment/lifecycleCompletionRecovery.js +56 -0
- package/dist/deployment/lifecycleCompletionRoot.d.ts +21 -0
- package/dist/deployment/lifecycleCompletionRoot.js +243 -0
- package/dist/deployment/lifecycleCompletionStore.d.ts +6 -0
- package/dist/deployment/lifecycleCompletionStore.js +151 -0
- package/dist/deployment/organizationHandoffAuthorityFsClient.d.ts +17 -0
- package/dist/deployment/organizationHandoffAuthorityFsClient.js +132 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorker.d.ts +1 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorker.js +285 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorkerParent.fixture.d.ts +1 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorkerParent.fixture.js +26 -0
- package/dist/deployment/organizationHandoffAuthorityStore.d.ts +41 -0
- package/dist/deployment/organizationHandoffAuthorityStore.js +348 -0
- package/dist/deployment/organizationHandoffAuthorityTypes.d.ts +76 -0
- package/dist/deployment/organizationHandoffAuthorityTypes.js +148 -0
- package/dist/deployment/organizationHandoffTypes.d.ts +29 -0
- package/dist/deployment/organizationHandoffTypes.js +80 -0
- package/dist/deployment/organizationReady.d.ts +52 -0
- package/dist/deployment/organizationReady.js +200 -0
- package/dist/deployment/privateArtifactsExport.d.ts +18 -0
- package/dist/deployment/privateArtifactsExport.js +80 -0
- package/dist/deployment/providerRuntimeBoundaryScanner.test-helper.d.ts +8 -0
- package/dist/deployment/providerRuntimeBoundaryScanner.test-helper.js +60 -0
- package/dist/deployment/record.d.ts +26 -1
- package/dist/deployment/record.js +49 -4
- package/dist/deployment/simfileFixtureBoundary.test-helper.d.ts +8 -0
- package/dist/deployment/simfileFixtureBoundary.test-helper.js +103 -0
- package/dist/deployment/target.d.ts +1 -35
- package/dist/deployment/target.js +1 -96
- package/dist/deployment/upReceiptTypes.d.ts +111 -0
- package/dist/deployment/upReceiptTypes.js +164 -0
- package/dist/dev/project.js +15 -9
- package/dist/distribution/buildDistributionReport.d.ts +2 -1
- package/dist/distribution/buildDistributionReport.js +2 -1
- package/dist/distribution/distributionReportSchema.d.ts +5 -0
- package/dist/distribution/distributionReportSchema.js +7 -2
- package/dist/distribution/index.d.ts +2 -2
- package/dist/distribution/index.js +1 -1
- package/dist/distribution/types.d.ts +7 -0
- package/dist/distribution/types.js +1 -0
- package/dist/filesystem/paths.js +10 -1
- package/dist/ledger/causalConformanceCli.d.ts +1 -0
- package/dist/ledger/causalConformanceCli.js +41 -0
- package/dist/ledger/causeNamespace.d.ts +8 -0
- package/dist/ledger/causeNamespace.js +24 -0
- package/dist/ledger/conformance.d.ts +83 -0
- package/dist/ledger/conformance.js +259 -0
- package/dist/ledger/emitters.d.ts +76 -0
- package/dist/ledger/emitters.js +188 -0
- package/dist/ledger/index.d.ts +4 -0
- package/dist/ledger/index.js +4 -0
- package/dist/ledger/principal.d.ts +96 -0
- package/dist/ledger/principal.js +121 -0
- package/dist/manifest/externalParticipantSchemas.d.ts +18 -0
- package/dist/manifest/externalParticipantSchemas.js +17 -0
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +1 -0
- package/dist/manifest/inlineAgentMember.d.ts +2 -0
- package/dist/manifest/inlineAgentMember.js +9 -0
- package/dist/manifest/loadManifest.js +14 -8
- package/dist/manifest/mcpSchemas.d.ts +17 -0
- package/dist/manifest/mcpSchemas.js +41 -0
- package/dist/manifest/memorySchemas.d.ts +245 -0
- package/dist/manifest/memorySchemas.js +148 -0
- package/dist/manifest/renderSpawnfile.js +22 -131
- package/dist/manifest/renderSpawnfileNetworks.js +9 -2
- package/dist/manifest/renderSpawnfileSurfaces.d.ts +2 -0
- package/dist/manifest/renderSpawnfileSurfaces.js +134 -0
- package/dist/manifest/schemas.d.ts +1868 -99
- package/dist/manifest/schemas.js +78 -32
- package/dist/manifest/surfaceSchemas.d.ts +17 -0
- package/dist/manifest/surfaceSchemas.js +24 -1
- package/dist/manifest/teamNetworkAccessSchemas.d.ts +1 -1
- package/dist/manifest/teamNetworkAuthSchemas.d.ts +48 -0
- package/dist/manifest/teamNetworkAuthSchemas.js +103 -0
- package/dist/manifest/teamNetworkSchemas.d.ts +8 -187
- package/dist/manifest/teamNetworkSchemas.js +3 -317
- package/dist/manifest/teamNetworkServerSchemas.d.ts +150 -0
- package/dist/manifest/teamNetworkServerSchemas.js +199 -0
- package/dist/ownership/siblingBuildFreshness.d.ts +20 -0
- package/dist/ownership/siblingBuildFreshness.js +20 -0
- package/dist/ownership/simfileRunOperatorInputs.d.ts +103 -0
- package/dist/ownership/simfileRunOperatorInputs.js +139 -0
- package/dist/report/types.d.ts +142 -0
- package/dist/runtime/common.d.ts +35 -0
- package/dist/runtime/common.js +55 -0
- package/dist/runtime/container.d.ts +28 -1
- package/dist/runtime/container.js +38 -5
- package/dist/runtime/containerPackageOverrides.d.ts +37 -0
- package/dist/runtime/containerPackageOverrides.js +33 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/mnemeMcp.d.ts +15 -0
- package/dist/runtime/mnemeMcp.js +109 -0
- package/dist/runtime/openclaw/adapter.js +15 -4
- package/dist/runtime/openclaw/mcp.d.ts +10 -0
- package/dist/runtime/openclaw/mcp.js +69 -0
- package/dist/runtime/openclaw/runAuth.js +2 -2
- package/dist/runtime/openclaw/scaffold.js +1 -1
- package/dist/runtime/openclaw/schedules.d.ts +38 -0
- package/dist/runtime/openclaw/schedules.js +74 -0
- package/dist/runtime/pi/adapter.d.ts +1 -1
- package/dist/runtime/pi/adapter.js +86 -53
- package/dist/runtime/pi/appActivitySource.js +114 -2
- package/dist/runtime/pi/appAgentConfig.d.ts +11 -0
- package/dist/runtime/pi/appAgentConfig.js +264 -0
- package/dist/runtime/pi/appCliEnginesSource.d.ts +1 -0
- package/dist/runtime/pi/appCliEnginesSource.js +183 -0
- package/dist/runtime/pi/appCliSource.d.ts +1 -0
- package/dist/runtime/pi/appCliSource.js +353 -0
- package/dist/runtime/pi/appControlSource.d.ts +1 -0
- package/dist/runtime/pi/appControlSource.js +390 -0
- package/dist/runtime/pi/appControlWakeIdentitySource.d.ts +1 -0
- package/dist/runtime/pi/appControlWakeIdentitySource.js +19 -0
- package/dist/runtime/pi/appCoreSource.d.ts +4 -1
- package/dist/runtime/pi/appCoreSource.js +104 -214
- package/dist/runtime/pi/appPreludeSource.js +140 -52
- package/dist/runtime/pi/appScheduleSource.d.ts +1 -0
- package/dist/runtime/pi/appScheduleSource.js +80 -0
- package/dist/runtime/pi/appScriptedEngine.d.ts +31 -0
- package/dist/runtime/pi/appScriptedEngine.js +42 -0
- package/dist/runtime/pi/appSource.d.ts +4 -1
- package/dist/runtime/pi/appSource.js +6 -2
- package/dist/runtime/pi/appTemplate.d.ts +8 -22
- package/dist/runtime/pi/appTemplate.js +9 -126
- package/dist/runtime/pi/appTemplateTypes.d.ts +64 -0
- package/dist/runtime/pi/appTemplateTypes.js +18 -0
- package/dist/runtime/pi/appWakeContextSource.d.ts +1 -0
- package/dist/runtime/pi/appWakeContextSource.js +398 -0
- package/dist/runtime/pi/containerTargets.d.ts +4 -0
- package/dist/runtime/pi/containerTargets.js +57 -0
- package/dist/runtime/pi/runAuth.js +126 -9
- package/dist/runtime/pi/testHelpers.d.ts +2 -0
- package/dist/runtime/pi/testHelpers.js +40 -0
- package/dist/runtime/picoclaw/adapter.js +23 -27
- package/dist/runtime/picoclaw/mcp.d.ts +4 -0
- package/dist/runtime/picoclaw/mcp.js +43 -0
- package/dist/runtime/picoclaw/memory.d.ts +7 -0
- package/dist/runtime/picoclaw/memory.js +17 -0
- package/dist/runtime/picoclaw/runAuth.js +1 -1
- package/dist/runtime/picoclaw/scaffold.js +1 -1
- package/dist/runtime/picoclaw/schedules.d.ts +26 -0
- package/dist/runtime/picoclaw/schedules.js +62 -3
- package/dist/runtime/scheduleUtils.d.ts +2 -0
- package/dist/runtime/scheduleUtils.js +15 -0
- package/dist/runtime/types.d.ts +25 -2
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +2 -2
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/redaction.d.ts +2 -0
- package/dist/shared/redaction.js +10 -0
- package/dist/status/buildStatus.d.ts +1 -0
- package/dist/status/buildStatus.js +2 -0
- package/dist/status/compileReport.d.ts +22 -0
- package/dist/status/compileReport.js +16 -2
- package/dist/status/compiledProbeCollection.d.ts +21 -0
- package/dist/status/compiledProbeCollection.js +27 -0
- package/dist/status/imageStatusReport.js +6 -0
- package/dist/status/index.d.ts +3 -0
- package/dist/status/index.js +3 -0
- package/dist/status/lifecycleProbes.d.ts +19 -0
- package/dist/status/lifecycleProbes.js +174 -0
- package/dist/status/moltnetProbes.d.ts +7 -8
- package/dist/status/moltnetProbes.js +27 -198
- package/dist/status/moltnetWiringProbes.d.ts +19 -0
- package/dist/status/moltnetWiringProbes.js +178 -0
- package/dist/target/cleanupRun.d.ts +41 -0
- package/dist/target/cleanupRun.js +139 -0
- package/dist/target/cleanupRunDocker.d.ts +16 -0
- package/dist/target/cleanupRunDocker.js +66 -0
- package/dist/target/cleanupRunDocker.test-helper.d.ts +67 -0
- package/dist/target/cleanupRunDocker.test-helper.js +238 -0
- package/dist/target/cleanupRunDockerPreflight.d.ts +17 -0
- package/dist/target/cleanupRunDockerPreflight.js +224 -0
- package/dist/target/composedPreparation.d.ts +205 -0
- package/dist/target/composedPreparation.js +223 -0
- package/dist/target/containerBundle.d.ts +82 -0
- package/dist/target/containerBundle.js +243 -0
- package/dist/target/containerBundleArchive.d.ts +31 -0
- package/dist/target/containerBundleArchive.js +140 -0
- package/dist/target/containerBundleAuthority.d.ts +25 -0
- package/dist/target/containerBundleAuthority.js +65 -0
- package/dist/target/containerBundleContracts.d.ts +114 -0
- package/dist/target/containerBundleContracts.js +173 -0
- package/dist/target/containerBundleFilesystemStore.d.ts +3 -0
- package/dist/target/containerBundleFilesystemStore.js +247 -0
- package/dist/target/containerBundlePolicy.d.ts +33 -0
- package/dist/target/containerBundlePolicy.js +64 -0
- package/dist/target/containerBundleStore.d.ts +127 -0
- package/dist/target/containerBundleStore.js +284 -0
- package/dist/target/contracts.d.ts +538 -0
- package/dist/target/contracts.js +373 -0
- package/dist/target/dockerArtifactIdentityTypes.d.ts +56 -0
- package/dist/target/dockerArtifactIdentityTypes.js +1 -0
- package/dist/target/dockerArtifactInspection.d.ts +40 -0
- package/dist/target/dockerArtifactInspection.js +125 -0
- package/dist/target/dockerArtifacts.d.ts +21 -0
- package/dist/target/dockerArtifacts.js +110 -0
- package/dist/target/dockerArtifactsProvider.d.ts +41 -0
- package/dist/target/dockerArtifactsProvider.js +449 -0
- package/dist/target/dockerCommandExecutor.d.ts +27 -0
- package/dist/target/dockerCommandExecutor.js +200 -0
- package/dist/target/dockerCommandExecutorCore.d.ts +34 -0
- package/dist/target/dockerCommandExecutorCore.js +273 -0
- package/dist/target/dockerContainerBundleBuilder.d.ts +8 -0
- package/dist/target/dockerContainerBundleBuilder.js +256 -0
- package/dist/target/dockerContextSnapshot.d.ts +21 -0
- package/dist/target/dockerContextSnapshot.js +158 -0
- package/dist/target/dockerEndpointFingerprint.d.ts +1 -0
- package/dist/target/dockerEndpointFingerprint.js +9 -0
- package/dist/target/dockerPreparedArtifact.d.ts +48 -0
- package/dist/target/dockerPreparedArtifact.js +131 -0
- package/dist/target/dockerProjectionJson.d.ts +1 -0
- package/dist/target/dockerProjectionJson.js +80 -0
- package/dist/target/dockerPublicArtifactSnapshot.d.ts +17 -0
- package/dist/target/dockerPublicArtifactSnapshot.js +99 -0
- package/dist/target/dockerResources.d.ts +26 -0
- package/dist/target/dockerResources.js +162 -0
- package/dist/target/dockerResourcesProvider.d.ts +44 -0
- package/dist/target/dockerResourcesProvider.js +207 -0
- package/dist/target/dockerSecrets.d.ts +39 -0
- package/dist/target/dockerSecrets.js +249 -0
- package/dist/target/dockerSecretsAuthority.d.ts +26 -0
- package/dist/target/dockerSecretsAuthority.js +216 -0
- package/dist/target/dockerSecretsLifecycle.d.ts +25 -0
- package/dist/target/dockerSecretsLifecycle.js +133 -0
- package/dist/target/dockerSecretsProvider.d.ts +68 -0
- package/dist/target/dockerSecretsProvider.js +329 -0
- package/dist/target/dockerTarget.d.ts +52 -0
- package/dist/target/dockerTarget.js +48 -0
- package/dist/target/dockerTargetBinding.d.ts +14 -0
- package/dist/target/dockerTargetBinding.js +96 -0
- package/dist/target/dockerWorldClock.d.ts +17 -0
- package/dist/target/dockerWorldClock.js +111 -0
- package/dist/target/dockerWorldReadiness.d.ts +17 -0
- package/dist/target/dockerWorldReadiness.js +119 -0
- package/dist/target/dockerWorldService.d.ts +23 -0
- package/dist/target/dockerWorldService.js +216 -0
- package/dist/target/dockerWorldServiceAuthority.d.ts +80 -0
- package/dist/target/dockerWorldServiceAuthority.js +182 -0
- package/dist/target/dockerWorldServiceLifecycle.d.ts +41 -0
- package/dist/target/dockerWorldServiceLifecycle.js +275 -0
- package/dist/target/dockerWorldServiceProvider.d.ts +60 -0
- package/dist/target/dockerWorldServiceProvider.js +318 -0
- package/dist/target/dockerWorldServiceStore.d.ts +73 -0
- package/dist/target/dockerWorldServiceStore.js +367 -0
- package/dist/target/evidenceExport.d.ts +55 -0
- package/dist/target/evidenceExport.js +518 -0
- package/dist/target/evidenceExportArchive.d.ts +10 -0
- package/dist/target/evidenceExportArchive.js +302 -0
- package/dist/target/evidenceExportContract.d.ts +27 -0
- package/dist/target/evidenceExportContract.js +40 -0
- package/dist/target/evidenceExportOperationsTestKit.d.ts +87 -0
- package/dist/target/evidenceExportOperationsTestKit.js +312 -0
- package/dist/target/evidenceExportProvider.d.ts +85 -0
- package/dist/target/evidenceExportProvider.js +187 -0
- package/dist/target/evidenceExportPublicationTypes.d.ts +16 -0
- package/dist/target/evidenceExportPublicationTypes.js +1 -0
- package/dist/target/evidenceExportStore.d.ts +70 -0
- package/dist/target/evidenceExportStore.js +498 -0
- package/dist/target/evidenceExportStorePublication.d.ts +7 -0
- package/dist/target/evidenceExportStorePublication.js +395 -0
- package/dist/target/handles.d.ts +20 -0
- package/dist/target/handles.js +56 -0
- package/dist/target/index.d.ts +12 -0
- package/dist/target/index.js +11 -0
- package/dist/target/journal.d.ts +59 -0
- package/dist/target/journal.js +529 -0
- package/dist/target/journalFilesystem.d.ts +3 -0
- package/dist/target/journalFilesystem.js +111 -0
- package/dist/target/journalRoot.d.ts +4 -0
- package/dist/target/journalRoot.js +6 -0
- package/dist/target/organizationAttachment.d.ts +23 -0
- package/dist/target/organizationAttachment.js +263 -0
- package/dist/target/organizationAttachmentAuthority.d.ts +65 -0
- package/dist/target/organizationAttachmentAuthority.js +161 -0
- package/dist/target/organizationAttachmentLifecycle.d.ts +17 -0
- package/dist/target/organizationAttachmentLifecycle.js +101 -0
- package/dist/target/organizationAttachmentProvider.d.ts +76 -0
- package/dist/target/organizationAttachmentProvider.js +289 -0
- package/dist/target/organizationAttachmentStore.d.ts +51 -0
- package/dist/target/organizationAttachmentStore.js +316 -0
- package/dist/target/publicArtifactSnapshot.d.ts +41 -0
- package/dist/target/publicArtifactSnapshot.js +150 -0
- package/dist/target/topologyActivation.d.ts +51 -0
- package/dist/target/topologyActivation.js +149 -0
- package/dist/target/topologyAttestation.d.ts +37 -0
- package/dist/target/topologyAttestation.js +300 -0
- package/dist/target/topologyAttestationErrors.d.ts +1 -0
- package/dist/target/topologyAttestationErrors.js +1 -0
- package/dist/target/worldClock.d.ts +60 -0
- package/dist/target/worldClock.js +129 -0
- package/dist/target/worldReadiness.d.ts +103 -0
- package/dist/target/worldReadiness.js +153 -0
- package/moltnet-releases.json +20 -0
- package/package.json +27 -11
- package/runtimes.yaml +8 -23
- package/dist/runtime/openclaw/scaffold-assets/CLAUDE.md +0 -5
- package/dist/runtime/picoclaw/scaffold-assets/CLAUDE.md +0 -5
- /package/dist/runtime/openclaw/scaffold-assets/{AGENTS.md → WORKSPACE_AGENTS.md} +0 -0
- /package/dist/runtime/picoclaw/scaffold-assets/{AGENTS.md → WORKSPACE_AGENTS.md} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { SpawnfileError } from "../shared/index.js";
|
|
5
|
+
import { SELECTED_TARGET_VERSION, parseOpaqueTargetHandle, parseSelectedTargetReceipt } from "./contracts.js";
|
|
6
|
+
import { createEndpointFingerprint } from "./dockerEndpointFingerprint.js";
|
|
7
|
+
export const defaultDockerTargetExecFile = promisify(execFileCallback);
|
|
8
|
+
const TARGET_SELECTION_ERROR = "Target selection failed";
|
|
9
|
+
const DOCKER_CONTEXT_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/u;
|
|
10
|
+
const MAX_RAW_EXECUTOR_STDOUT_BYTES = 4_096;
|
|
11
|
+
const parseDockerEndpoint = (stdout) => {
|
|
12
|
+
if (Buffer.byteLength(stdout, "utf8") > MAX_RAW_EXECUTOR_STDOUT_BYTES) {
|
|
13
|
+
throw new SpawnfileError("runtime_error", TARGET_SELECTION_ERROR);
|
|
14
|
+
}
|
|
15
|
+
const trimmed = stdout.trim();
|
|
16
|
+
if (trimmed.length === 0) {
|
|
17
|
+
throw new SpawnfileError("runtime_error", "Docker context endpoint was empty");
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(trimmed);
|
|
21
|
+
if (typeof parsed === "string" && parsed.trim().length > 0)
|
|
22
|
+
return parsed.trim();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Docker/podman variants may return a plain string instead of JSON.
|
|
26
|
+
}
|
|
27
|
+
return trimmed;
|
|
28
|
+
};
|
|
29
|
+
export const resolveDockerContextEndpoint = async (context, options) => {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await options.execFile(options.dockerCommand, ["context", "inspect", context, "--format", "{{json .Endpoints.docker.Host}}"], { signal: options.signal, timeout: options.timeoutMs });
|
|
32
|
+
return parseDockerEndpoint(stdout);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
36
|
+
throw new SpawnfileError("runtime_error", `Unable to resolve Docker context "${context}": ${reason}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const selectionFailure = (code) => {
|
|
40
|
+
throw new SpawnfileError(code, TARGET_SELECTION_ERROR);
|
|
41
|
+
};
|
|
42
|
+
const selectTargetContext = (input) => {
|
|
43
|
+
if (input.DOCKER_HOST != null || input.dockerHost != null || input.endpoint != null || input.host != null) {
|
|
44
|
+
return selectionFailure("validation_error");
|
|
45
|
+
}
|
|
46
|
+
if (typeof input.context !== "string" || !DOCKER_CONTEXT_PATTERN.test(input.context)) {
|
|
47
|
+
return selectionFailure("validation_error");
|
|
48
|
+
}
|
|
49
|
+
return input.context;
|
|
50
|
+
};
|
|
51
|
+
const isDockerContextEndpoint = (endpoint) => endpoint.length <= 4_096
|
|
52
|
+
&& /^(?:npipe|ssh|tcp|unix|fd|http|https):\/\/[^\s]+$/u.test(endpoint);
|
|
53
|
+
const selectTargetOptions = (input) => {
|
|
54
|
+
if (input.dockerCommand !== undefined && (typeof input.dockerCommand !== "string" || input.dockerCommand.length === 0 || input.dockerCommand.length > 128)) {
|
|
55
|
+
return selectionFailure("validation_error");
|
|
56
|
+
}
|
|
57
|
+
if (input.timeoutMs !== undefined && (typeof input.timeoutMs !== "number" || !Number.isSafeInteger(input.timeoutMs) || input.timeoutMs < 1 || input.timeoutMs > 120_000)) {
|
|
58
|
+
return selectionFailure("validation_error");
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
dockerCommand: input.dockerCommand ?? "docker",
|
|
62
|
+
execFile: input.execFile ?? defaultDockerTargetExecFile,
|
|
63
|
+
signal: input.signal,
|
|
64
|
+
timeoutMs: input.timeoutMs ?? 10_000
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const createSelectedTargetHandle = (context, fingerprint) => parseOpaqueTargetHandle(`opaque_${createHash("sha256")
|
|
68
|
+
.update("spawnfile.target-resource.selected-target.v1\0", "utf8")
|
|
69
|
+
.update(context, "utf8")
|
|
70
|
+
.update("\0", "utf8")
|
|
71
|
+
.update(fingerprint, "utf8")
|
|
72
|
+
.digest("hex")}`);
|
|
73
|
+
export const selectedTargetForContextEndpoint = (context, endpoint) => {
|
|
74
|
+
if (!DOCKER_CONTEXT_PATTERN.test(context) || !isDockerContextEndpoint(endpoint)) {
|
|
75
|
+
return selectionFailure("runtime_error");
|
|
76
|
+
}
|
|
77
|
+
const fingerprint = createEndpointFingerprint(endpoint);
|
|
78
|
+
return parseSelectedTargetReceipt({
|
|
79
|
+
fingerprint,
|
|
80
|
+
handle: createSelectedTargetHandle(context, fingerprint),
|
|
81
|
+
version: SELECTED_TARGET_VERSION
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
export const resolveSelectedTargetBinding = async (input = {}) => {
|
|
85
|
+
try {
|
|
86
|
+
const context = selectTargetContext(input);
|
|
87
|
+
const endpoint = await resolveDockerContextEndpoint(context, selectTargetOptions(input));
|
|
88
|
+
const selected = selectedTargetForContextEndpoint(context, endpoint);
|
|
89
|
+
return Object.freeze({ endpoint, selected });
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return selectionFailure("runtime_error");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/** Resolves one explicit named Docker context without exposing private selector data. */
|
|
96
|
+
export const selectTarget = async (input = {}) => (await resolveSelectedTargetBinding(input)).selected;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DockerTargetExecutors } from "./dockerCommandExecutor.js";
|
|
2
|
+
import type { DockerWorldServiceExecutor } from "./dockerWorldServiceProvider.js";
|
|
3
|
+
import type { WorldServiceAuthorityReader } from "./dockerWorldServiceStore.js";
|
|
4
|
+
import { type TargetWorldClockReceipt } from "./worldClock.js";
|
|
5
|
+
export declare const TARGET_WORLD_CLOCK_ERROR = "Target world clock query failed";
|
|
6
|
+
export interface DockerWorldClockOptions {
|
|
7
|
+
readonly authorityStore: WorldServiceAuthorityReader;
|
|
8
|
+
readonly context: string;
|
|
9
|
+
readonly contentExecutor: DockerTargetExecutors["publicArtifact"];
|
|
10
|
+
readonly executor: DockerWorldServiceExecutor;
|
|
11
|
+
readonly signal?: AbortSignal;
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
}
|
|
14
|
+
export interface WorldClockReader {
|
|
15
|
+
query(raw: unknown): Promise<TargetWorldClockReceipt>;
|
|
16
|
+
}
|
|
17
|
+
export declare const createDockerWorldClockReader: (input: DockerWorldClockOptions) => WorldClockReader;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { SpawnfileError } from "../shared/index.js";
|
|
2
|
+
import { inspectDockerWorldService, sameWorldServiceValue, worldServiceSpecForBinding, } from "./dockerWorldServiceLifecycle.js";
|
|
3
|
+
import { createCanonicalWorldServiceActivationBytes, createTargetTopologyActivationReceiptDigest, createWorldServiceActivationDigest, parseWorldServiceActivation, } from "./topologyActivation.js";
|
|
4
|
+
import { createTargetWorldClockReceipt, MAX_TARGET_WORLD_CLOCK_BYTES, parseTargetWorldClockRequest, } from "./worldClock.js";
|
|
5
|
+
export const TARGET_WORLD_CLOCK_ERROR = "Target world clock query failed";
|
|
6
|
+
const CONTEXT = /^[a-z][a-z0-9_-]{0,63}$/u;
|
|
7
|
+
const fail = () => { throw new SpawnfileError("runtime_error", TARGET_WORLD_CLOCK_ERROR); };
|
|
8
|
+
const options = (raw) => {
|
|
9
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)
|
|
10
|
+
|| typeof raw.context !== "string" || !CONTEXT.test(raw.context)
|
|
11
|
+
|| typeof raw.contentExecutor !== "function" || typeof raw.executor !== "function"
|
|
12
|
+
|| !raw.authorityStore || typeof raw.authorityStore.loadService !== "function"
|
|
13
|
+
|| !Number.isSafeInteger(raw.timeoutMs) || raw.timeoutMs < 1 || raw.timeoutMs > 120_000
|
|
14
|
+
|| raw.signal !== undefined && !(raw.signal instanceof AbortSignal))
|
|
15
|
+
return fail();
|
|
16
|
+
return raw;
|
|
17
|
+
};
|
|
18
|
+
const queryScript = [
|
|
19
|
+
"import http from \"node:http\";",
|
|
20
|
+
"const [rawPort,pathname]=process.argv.slice(1);const port=Number(rawPort);",
|
|
21
|
+
"const fail=()=>{process.exitCode=1;};",
|
|
22
|
+
"if(!Number.isSafeInteger(port)||port<1||port>65535||pathname!==\"/v1/world/clock\")fail();",
|
|
23
|
+
"else http.get({headers:{accept:\"application/json\"},host:\"127.0.0.1\",path:pathname,port},response=>{",
|
|
24
|
+
"const media=response.headers[\"content-type\"];if(response.statusCode!==200||typeof media!==\"string\"||!media.toLowerCase().startsWith(\"application/json\")){response.resume();fail();return;}",
|
|
25
|
+
`const chunks=[];let size=0;response.on("data",chunk=>{size+=chunk.length;if(size>${MAX_TARGET_WORLD_CLOCK_BYTES}){response.destroy();fail();}else chunks.push(chunk);});`,
|
|
26
|
+
"response.on(\"end\",()=>{if(process.exitCode!==1)process.stdout.write(Buffer.concat(chunks));});response.on(\"error\",fail);",
|
|
27
|
+
"}).on(\"error\",fail);",
|
|
28
|
+
].join("\n");
|
|
29
|
+
const bytes = async (optionsValue, args) => {
|
|
30
|
+
const result = await optionsValue.contentExecutor("docker", [
|
|
31
|
+
"--context", optionsValue.context, "container", "exec", ...args,
|
|
32
|
+
], { signal: optionsValue.signal, timeout: optionsValue.timeoutMs }).catch(fail);
|
|
33
|
+
if (!result || !(result.bytes instanceof Uint8Array)
|
|
34
|
+
|| result.bytes.byteLength < 2 || result.bytes.byteLength > MAX_TARGET_WORLD_CLOCK_BYTES)
|
|
35
|
+
return fail();
|
|
36
|
+
return result.bytes;
|
|
37
|
+
};
|
|
38
|
+
const json = (raw) => {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(raw));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return fail();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
class DockerWorldClockReader {
|
|
47
|
+
#options;
|
|
48
|
+
constructor(input) { this.#options = options(input); }
|
|
49
|
+
async query(raw) {
|
|
50
|
+
let request;
|
|
51
|
+
try {
|
|
52
|
+
request = parseTargetWorldClockRequest(raw);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return fail();
|
|
56
|
+
}
|
|
57
|
+
const binding = await this.#options.authorityStore
|
|
58
|
+
.loadService(request.world_service_handle).catch(fail);
|
|
59
|
+
const authorization = binding.resolution.authorization;
|
|
60
|
+
if (binding.world_service_handle !== request.world_service_handle
|
|
61
|
+
|| authorization.run_id !== request.run_id
|
|
62
|
+
|| authorization.descriptor_digest !== request.descriptor_digest
|
|
63
|
+
|| !sameWorldServiceValue(authorization.selected_target, request.selected_target))
|
|
64
|
+
return fail();
|
|
65
|
+
const spec = worldServiceSpecForBinding(binding);
|
|
66
|
+
const before = await inspectDockerWorldService(binding.container_id, spec, this.#options).catch(fail);
|
|
67
|
+
if (!before || before.containerId !== binding.container_id || before.status !== "running")
|
|
68
|
+
return fail();
|
|
69
|
+
const markerBytes = await bytes(this.#options, [
|
|
70
|
+
binding.container_id, "/bin/cat",
|
|
71
|
+
`${spec.evidenceMountPath}/.spawnfile/world-service-activated.v1`,
|
|
72
|
+
]);
|
|
73
|
+
let marker;
|
|
74
|
+
try {
|
|
75
|
+
marker = parseWorldServiceActivation(json(markerBytes));
|
|
76
|
+
if (new TextDecoder().decode(markerBytes) !== createCanonicalWorldServiceActivationBytes(marker)
|
|
77
|
+
|| marker.run_id !== request.run_id
|
|
78
|
+
|| marker.topology_receipt_digest !== request.topology_receipt_digest
|
|
79
|
+
|| marker.topology_request_digest !== request.topology_request_digest
|
|
80
|
+
|| createWorldServiceActivationDigest(marker) !== request.activation_digest)
|
|
81
|
+
return fail();
|
|
82
|
+
const activationBody = {
|
|
83
|
+
activation_digest: request.activation_digest, bundle_digest: marker.bundle_digest,
|
|
84
|
+
receipt_digest: `sha256:${"0".repeat(64)}`, run_id: marker.run_id,
|
|
85
|
+
state: "activated", topology_receipt_digest: marker.topology_receipt_digest,
|
|
86
|
+
topology_request_digest: marker.topology_request_digest,
|
|
87
|
+
version: "spawnfile.target-topology-activation-receipt.v1",
|
|
88
|
+
};
|
|
89
|
+
if (createTargetTopologyActivationReceiptDigest(activationBody)
|
|
90
|
+
!== request.activation_receipt_digest)
|
|
91
|
+
return fail();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return fail();
|
|
95
|
+
}
|
|
96
|
+
const observed = json(await bytes(this.#options, [
|
|
97
|
+
binding.container_id, "/usr/local/bin/node", "--input-type=module", "-e",
|
|
98
|
+
queryScript, String(request.endpoint.internal_port), request.endpoint.path,
|
|
99
|
+
]));
|
|
100
|
+
const after = await inspectDockerWorldService(binding.container_id, spec, this.#options).catch(fail);
|
|
101
|
+
if (!after || after.containerId !== before.containerId || after.status !== "running")
|
|
102
|
+
return fail();
|
|
103
|
+
try {
|
|
104
|
+
return createTargetWorldClockReceipt({ observation: observed, request });
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return fail();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export const createDockerWorldClockReader = (input) => new DockerWorldClockReader(input);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DockerTargetExecutors } from "./dockerCommandExecutor.js";
|
|
2
|
+
import { type DockerWorldServiceExecutor } from "./dockerWorldServiceProvider.js";
|
|
3
|
+
import type { WorldServiceAuthorityReader } from "./dockerWorldServiceStore.js";
|
|
4
|
+
import { type TargetWorldReadinessReceipt } from "./worldReadiness.js";
|
|
5
|
+
export declare const TARGET_WORLD_READINESS_ERROR = "Target world readiness query failed";
|
|
6
|
+
export interface DockerWorldReadinessOptions {
|
|
7
|
+
readonly authorityStore: WorldServiceAuthorityReader;
|
|
8
|
+
readonly context: string;
|
|
9
|
+
readonly contentExecutor: DockerTargetExecutors["publicArtifact"];
|
|
10
|
+
readonly executor: DockerWorldServiceExecutor;
|
|
11
|
+
readonly signal?: AbortSignal;
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
}
|
|
14
|
+
export interface WorldReadinessReader {
|
|
15
|
+
query(raw: unknown): Promise<TargetWorldReadinessReceipt>;
|
|
16
|
+
}
|
|
17
|
+
export declare const createDockerWorldReadinessReader: (options: DockerWorldReadinessOptions) => WorldReadinessReader;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SpawnfileError } from "../shared/index.js";
|
|
2
|
+
import { types as nodeTypes } from "node:util";
|
|
3
|
+
import { inspectDockerWorldService, sameWorldServiceValue, worldServiceSpecForBinding } from "./dockerWorldServiceLifecycle.js";
|
|
4
|
+
import { createTargetWorldReadinessReceipt, MAX_TARGET_WORLD_READINESS_BYTES, parseTargetWorldReadinessRequest } from "./worldReadiness.js";
|
|
5
|
+
export const TARGET_WORLD_READINESS_ERROR = "Target world readiness query failed";
|
|
6
|
+
const CONTEXT_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/u;
|
|
7
|
+
const fail = () => {
|
|
8
|
+
throw new SpawnfileError("runtime_error", TARGET_WORLD_READINESS_ERROR);
|
|
9
|
+
};
|
|
10
|
+
const validOptions = (raw) => {
|
|
11
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw) || nodeTypes.isProxy(raw)
|
|
12
|
+
|| Object.getPrototypeOf(raw) !== Object.prototype)
|
|
13
|
+
return fail();
|
|
14
|
+
const descriptors = Object.getOwnPropertyDescriptors(raw);
|
|
15
|
+
const required = [
|
|
16
|
+
"authorityStore", "context", "contentExecutor", "executor", "timeoutMs"
|
|
17
|
+
];
|
|
18
|
+
const expected = Object.hasOwn(descriptors, "signal") ? [...required, "signal"] : required;
|
|
19
|
+
const keys = Reflect.ownKeys(raw);
|
|
20
|
+
if (keys.length !== expected.length
|
|
21
|
+
|| keys.some((key) => typeof key !== "string" || !expected.includes(key))
|
|
22
|
+
|| Object.values(descriptors).some((descriptor) => !descriptor.enumerable || !("value" in descriptor)))
|
|
23
|
+
return fail();
|
|
24
|
+
const values = Object.fromEntries(expected.map((key) => [key, descriptors[key].value]));
|
|
25
|
+
if (typeof values.context !== "string" || !CONTEXT_PATTERN.test(values.context)
|
|
26
|
+
|| typeof values.contentExecutor !== "function"
|
|
27
|
+
|| typeof values.executor !== "function"
|
|
28
|
+
|| !values.authorityStore || typeof values.authorityStore.loadService !== "function"
|
|
29
|
+
|| !Number.isSafeInteger(values.timeoutMs) || values.timeoutMs < 1
|
|
30
|
+
|| values.timeoutMs > 120_000
|
|
31
|
+
|| values.signal !== undefined && !(values.signal instanceof AbortSignal))
|
|
32
|
+
return fail();
|
|
33
|
+
return Object.freeze(values);
|
|
34
|
+
};
|
|
35
|
+
const exactBinding = async (request, options) => {
|
|
36
|
+
const binding = await options.authorityStore.loadService(request.world_service_handle);
|
|
37
|
+
const authorization = binding.resolution.authorization;
|
|
38
|
+
if (binding.world_service_handle !== request.world_service_handle
|
|
39
|
+
|| authorization.run_id !== request.run_id
|
|
40
|
+
|| authorization.descriptor_digest !== request.descriptor_digest
|
|
41
|
+
|| !sameWorldServiceValue(authorization.selected_target, request.selected_target))
|
|
42
|
+
return fail();
|
|
43
|
+
return binding;
|
|
44
|
+
};
|
|
45
|
+
const queryScript = [
|
|
46
|
+
"import http from \"node:http\";",
|
|
47
|
+
"const [rawPort, pathname] = process.argv.slice(1);",
|
|
48
|
+
"const port = Number(rawPort);",
|
|
49
|
+
"const fail = () => { process.exitCode = 1; };",
|
|
50
|
+
"if (!Number.isSafeInteger(port) || port < 1 || port > 65535 || pathname !== \"/v1/world/readiness\") fail();",
|
|
51
|
+
"else http.get({headers:{accept:\"application/json\"},host:\"127.0.0.1\",path:pathname,port}, response => {",
|
|
52
|
+
"const mediaType = response.headers[\"content-type\"];",
|
|
53
|
+
"if (response.statusCode !== 200 || typeof mediaType !== \"string\" || !mediaType.toLowerCase().startsWith(\"application/json\")) { response.resume(); fail(); return; }",
|
|
54
|
+
"const chunks = []; let size = 0;",
|
|
55
|
+
`response.on("data", chunk => { size += chunk.length; if (size > ${MAX_TARGET_WORLD_READINESS_BYTES}) { response.destroy(); fail(); } else chunks.push(chunk); });`,
|
|
56
|
+
"response.on(\"end\", () => { if (process.exitCode !== 1) process.stdout.write(Buffer.concat(chunks)); });",
|
|
57
|
+
"response.on(\"error\", fail);",
|
|
58
|
+
"}).on(\"error\", fail);"
|
|
59
|
+
].join("\n");
|
|
60
|
+
const queryWorld = async (containerId, request, options) => {
|
|
61
|
+
try {
|
|
62
|
+
const result = await options.contentExecutor("docker", [
|
|
63
|
+
"--context", options.context,
|
|
64
|
+
"container", "exec",
|
|
65
|
+
containerId,
|
|
66
|
+
"/usr/local/bin/node",
|
|
67
|
+
"--input-type=module",
|
|
68
|
+
"-e",
|
|
69
|
+
queryScript,
|
|
70
|
+
String(request.endpoint.internal_port),
|
|
71
|
+
request.endpoint.path
|
|
72
|
+
], {
|
|
73
|
+
signal: options.signal,
|
|
74
|
+
timeout: options.timeoutMs
|
|
75
|
+
});
|
|
76
|
+
if (!result || !(result.bytes instanceof Uint8Array)
|
|
77
|
+
|| result.bytes.byteLength < 2
|
|
78
|
+
|| result.bytes.byteLength > MAX_TARGET_WORLD_READINESS_BYTES)
|
|
79
|
+
return fail();
|
|
80
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(result.bytes);
|
|
81
|
+
return JSON.parse(text);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return fail();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
class DockerWorldReadinessReader {
|
|
88
|
+
#options;
|
|
89
|
+
constructor(options) {
|
|
90
|
+
this.#options = validOptions(options);
|
|
91
|
+
}
|
|
92
|
+
async query(raw) {
|
|
93
|
+
let request;
|
|
94
|
+
try {
|
|
95
|
+
request = parseTargetWorldReadinessRequest(raw);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return fail();
|
|
99
|
+
}
|
|
100
|
+
const binding = await exactBinding(request, this.#options).catch(fail);
|
|
101
|
+
const spec = worldServiceSpecForBinding(binding);
|
|
102
|
+
const before = await inspectDockerWorldService(binding.container_id, spec, this.#options).catch(fail);
|
|
103
|
+
if (!before || before.containerId !== binding.container_id
|
|
104
|
+
|| before.status !== "running")
|
|
105
|
+
return fail();
|
|
106
|
+
const document = await queryWorld(binding.container_id, request, this.#options);
|
|
107
|
+
const after = await inspectDockerWorldService(binding.container_id, spec, this.#options).catch(fail);
|
|
108
|
+
if (!after || after.containerId !== before.containerId
|
|
109
|
+
|| after.status !== "running")
|
|
110
|
+
return fail();
|
|
111
|
+
try {
|
|
112
|
+
return createTargetWorldReadinessReceipt({ document, request });
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return fail();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export const createDockerWorldReadinessReader = (options) => new DockerWorldReadinessReader(options);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type TargetResourceReceipt } from "./contracts.js";
|
|
2
|
+
import { type TargetJournalStore } from "./journal.js";
|
|
3
|
+
import { type WorldServiceResolver } from "./dockerWorldServiceAuthority.js";
|
|
4
|
+
import { type DockerWorldServiceExecutor } from "./dockerWorldServiceProvider.js";
|
|
5
|
+
import { type WorldServiceAuthorityStore } from "./dockerWorldServiceStore.js";
|
|
6
|
+
type OperationResult = {
|
|
7
|
+
readonly receipt: TargetResourceReceipt;
|
|
8
|
+
readonly receiptBytes: string;
|
|
9
|
+
};
|
|
10
|
+
export interface DockerWorldServiceOperationsOptions {
|
|
11
|
+
readonly authorityStore: WorldServiceAuthorityStore;
|
|
12
|
+
readonly context: unknown;
|
|
13
|
+
readonly executor: DockerWorldServiceExecutor;
|
|
14
|
+
readonly journal: TargetJournalStore;
|
|
15
|
+
readonly resolver: WorldServiceResolver;
|
|
16
|
+
readonly signal?: AbortSignal;
|
|
17
|
+
readonly timeoutMs?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface DockerWorldServiceOperations {
|
|
20
|
+
execute(raw: unknown): Promise<OperationResult>;
|
|
21
|
+
}
|
|
22
|
+
export declare const createDockerWorldServiceOperations: (options: DockerWorldServiceOperationsOptions) => DockerWorldServiceOperations;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { SpawnfileError } from "../shared/index.js";
|
|
2
|
+
import { parseTargetResourceRequest } from "./contracts.js";
|
|
3
|
+
import { WORLD_SERVICE_ERROR } from "./dockerWorldServiceAuthority.js";
|
|
4
|
+
import { DockerWorldServiceProviderError } from "./dockerWorldServiceProvider.js";
|
|
5
|
+
import { createWorldServiceReceipt, inspectDockerWorldService, mutateDockerWorldService, resolveWorldServiceCreate, sameWorldServiceValue, selectedWorldServiceContextMatches, verifyWorldServiceResources, worldServiceSpecForBinding } from "./dockerWorldServiceLifecycle.js";
|
|
6
|
+
import { createWorldServiceBinding, createWorldServiceMutationAdmission } from "./dockerWorldServiceStore.js";
|
|
7
|
+
const CONTEXT_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/u;
|
|
8
|
+
const CONTAINER_ID_PATTERN = /^[a-f0-9]{64}$/u;
|
|
9
|
+
const exactMutationAck = (stdout, containerId) => stdout === "" || stdout === `${containerId}\n`;
|
|
10
|
+
const fail = () => {
|
|
11
|
+
throw new SpawnfileError("runtime_error", WORLD_SERVICE_ERROR);
|
|
12
|
+
};
|
|
13
|
+
const validOptions = (raw) => {
|
|
14
|
+
if (typeof raw.context !== "string" || !CONTEXT_PATTERN.test(raw.context)
|
|
15
|
+
|| typeof raw.executor !== "function"
|
|
16
|
+
|| !raw.journal || typeof raw.journal.reserve !== "function"
|
|
17
|
+
|| !raw.resolver || typeof raw.resolver.resolve !== "function"
|
|
18
|
+
|| !raw.authorityStore || typeof raw.authorityStore.bindResolution !== "function"
|
|
19
|
+
|| typeof raw.timeoutMs !== "undefined"
|
|
20
|
+
&& (typeof raw.timeoutMs !== "number" || !Number.isSafeInteger(raw.timeoutMs)
|
|
21
|
+
|| raw.timeoutMs < 1 || raw.timeoutMs > 120_000))
|
|
22
|
+
return fail();
|
|
23
|
+
return {
|
|
24
|
+
authorityStore: raw.authorityStore,
|
|
25
|
+
context: raw.context,
|
|
26
|
+
executor: raw.executor,
|
|
27
|
+
journal: raw.journal,
|
|
28
|
+
resolver: raw.resolver,
|
|
29
|
+
signal: raw.signal,
|
|
30
|
+
timeoutMs: raw.timeoutMs ?? 10_000
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const parseRequest = (raw) => {
|
|
34
|
+
const request = parseTargetResourceRequest(raw);
|
|
35
|
+
if (request.operation !== "create_world_service"
|
|
36
|
+
&& request.operation !== "start_world_service"
|
|
37
|
+
&& request.operation !== "stop_world_service")
|
|
38
|
+
return fail();
|
|
39
|
+
return request;
|
|
40
|
+
};
|
|
41
|
+
class DockerWorldServiceOperationsImpl {
|
|
42
|
+
#live = new Map();
|
|
43
|
+
#options;
|
|
44
|
+
constructor(options) { this.#options = options; }
|
|
45
|
+
execute(raw) {
|
|
46
|
+
let request;
|
|
47
|
+
try {
|
|
48
|
+
request = parseRequest(raw);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return Promise.reject(new SpawnfileError("runtime_error", WORLD_SERVICE_ERROR));
|
|
52
|
+
}
|
|
53
|
+
const active = this.#live.get(request.idempotency_key);
|
|
54
|
+
if (active)
|
|
55
|
+
return sameWorldServiceValue(active.request, request) ? active.promise
|
|
56
|
+
: Promise.reject(new SpawnfileError("runtime_error", WORLD_SERVICE_ERROR));
|
|
57
|
+
const promise = this.executeOwner(request).finally(() => {
|
|
58
|
+
if (this.#live.get(request.idempotency_key)?.promise === promise) {
|
|
59
|
+
this.#live.delete(request.idempotency_key);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.#live.set(request.idempotency_key, { promise, request });
|
|
63
|
+
return promise;
|
|
64
|
+
}
|
|
65
|
+
async executeOwner(request) {
|
|
66
|
+
try {
|
|
67
|
+
const reservation = await this.#options.journal.reserve(request);
|
|
68
|
+
if (reservation.kind === "replay") {
|
|
69
|
+
return { receipt: reservation.receipt, receiptBytes: reservation.receiptBytes };
|
|
70
|
+
}
|
|
71
|
+
return request.operation === "create_world_service"
|
|
72
|
+
? await this.create(request, reservation.claim, reservation.kind)
|
|
73
|
+
: await this.change(request, reservation.claim, reservation.kind);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return fail();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async create(request, claim, reservation) {
|
|
80
|
+
const resolved = await resolveWorldServiceCreate(request, claim, this.#options);
|
|
81
|
+
await selectedWorldServiceContextMatches(request, this.#options);
|
|
82
|
+
await verifyWorldServiceResources(resolved, this.#options);
|
|
83
|
+
const spec = worldServiceSpecForBinding(resolved);
|
|
84
|
+
const admission = createWorldServiceMutationAdmission({
|
|
85
|
+
containerId: null,
|
|
86
|
+
containerName: spec.containerName,
|
|
87
|
+
operation: request.operation,
|
|
88
|
+
operationHandle: claim.operationHandle,
|
|
89
|
+
requestDigest: claim.requestDigest,
|
|
90
|
+
worldServiceHandle: spec.resultHandle
|
|
91
|
+
});
|
|
92
|
+
let current;
|
|
93
|
+
if (reservation === "owner") {
|
|
94
|
+
current = await inspectDockerWorldService(spec.containerName, spec, this.#options);
|
|
95
|
+
if (current !== null)
|
|
96
|
+
return fail();
|
|
97
|
+
await this.#options.authorityStore.bindMutationAdmission(admission);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await this.#options.authorityStore.requireMutationAdmission(admission);
|
|
101
|
+
current = await inspectDockerWorldService(spec.containerName, spec, this.#options);
|
|
102
|
+
}
|
|
103
|
+
let createdId = null;
|
|
104
|
+
if (current === null) {
|
|
105
|
+
try {
|
|
106
|
+
const stdout = await mutateDockerWorldService([...spec.createArgs], this.#options);
|
|
107
|
+
const candidate = stdout.endsWith("\n") ? stdout.slice(0, -1) : stdout;
|
|
108
|
+
if (!CONTAINER_ID_PATTERN.test(candidate))
|
|
109
|
+
return fail();
|
|
110
|
+
createdId = candidate;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (!(error instanceof DockerWorldServiceProviderError)
|
|
114
|
+
|| error.kind !== "collision")
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
current = await inspectDockerWorldService(spec.containerName, spec, this.#options);
|
|
118
|
+
}
|
|
119
|
+
if (!current || current.status !== "created"
|
|
120
|
+
|| createdId !== null && current.containerId !== createdId)
|
|
121
|
+
return fail();
|
|
122
|
+
const binding = createWorldServiceBinding({
|
|
123
|
+
containerId: current.containerId,
|
|
124
|
+
dataNetwork: resolved.resources.data_network,
|
|
125
|
+
evidenceVolume: resolved.resources.evidence_volume,
|
|
126
|
+
resolution: resolved.resolution,
|
|
127
|
+
secretBindings: resolved.resources.secret_bindings,
|
|
128
|
+
spec
|
|
129
|
+
});
|
|
130
|
+
await this.#options.authorityStore.bindService(binding);
|
|
131
|
+
const receipt = await createWorldServiceReceipt({ claim, journal: this.#options.journal,
|
|
132
|
+
labels: spec.receiptLabels, request, resultHandle: spec.resultHandle });
|
|
133
|
+
return this.#options.journal.complete(claim, receipt);
|
|
134
|
+
}
|
|
135
|
+
async change(request, claim, reservation) {
|
|
136
|
+
const binding = await this.#options.authorityStore.loadService(request.world_service_handle);
|
|
137
|
+
if (binding.world_service_handle !== request.world_service_handle
|
|
138
|
+
|| binding.resolution.authorization.run_id !== request.run_id
|
|
139
|
+
|| binding.resolution.authorization.descriptor_digest !== request.descriptor_digest
|
|
140
|
+
|| !sameWorldServiceValue(binding.resolution.authorization.selected_target, request.selected_target))
|
|
141
|
+
return fail();
|
|
142
|
+
const spec = worldServiceSpecForBinding(binding);
|
|
143
|
+
if (spec.resultHandle !== request.world_service_handle)
|
|
144
|
+
return fail();
|
|
145
|
+
await selectedWorldServiceContextMatches(request, this.#options);
|
|
146
|
+
await verifyWorldServiceResources(binding, this.#options);
|
|
147
|
+
const admission = createWorldServiceMutationAdmission({
|
|
148
|
+
containerId: binding.container_id,
|
|
149
|
+
containerName: spec.containerName,
|
|
150
|
+
operation: request.operation,
|
|
151
|
+
operationHandle: claim.operationHandle,
|
|
152
|
+
requestDigest: claim.requestDigest,
|
|
153
|
+
worldServiceHandle: binding.world_service_handle
|
|
154
|
+
});
|
|
155
|
+
let current;
|
|
156
|
+
if (reservation === "owner") {
|
|
157
|
+
current = await inspectDockerWorldService(binding.container_id, spec, this.#options);
|
|
158
|
+
if (!current || current.containerId !== binding.container_id)
|
|
159
|
+
return fail();
|
|
160
|
+
if (request.operation === "start_world_service"
|
|
161
|
+
&& current.status !== "created" && current.status !== "exited")
|
|
162
|
+
return fail();
|
|
163
|
+
if (request.operation === "stop_world_service" && current.status === "removing")
|
|
164
|
+
return fail();
|
|
165
|
+
await this.#options.authorityStore.bindMutationAdmission(admission);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
await this.#options.authorityStore.requireMutationAdmission(admission);
|
|
169
|
+
current = await inspectDockerWorldService(binding.container_id, spec, this.#options);
|
|
170
|
+
}
|
|
171
|
+
if (request.operation === "start_world_service") {
|
|
172
|
+
if (!current)
|
|
173
|
+
return fail();
|
|
174
|
+
if (current.status !== "running") {
|
|
175
|
+
if (current.status !== "created" && current.status !== "exited")
|
|
176
|
+
return fail();
|
|
177
|
+
if (!exactMutationAck(await mutateDockerWorldService(["container", "start", binding.container_id], this.#options), binding.container_id))
|
|
178
|
+
return fail();
|
|
179
|
+
current = await inspectDockerWorldService(binding.container_id, spec, this.#options);
|
|
180
|
+
}
|
|
181
|
+
if (!current || current.containerId !== binding.container_id
|
|
182
|
+
|| current.status !== "running")
|
|
183
|
+
return fail();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
if (current?.status === "running" || current?.status === "paused"
|
|
187
|
+
|| current?.status === "restarting") {
|
|
188
|
+
if (!exactMutationAck(await mutateDockerWorldService(["container", "stop", "--timeout", "10", binding.container_id], this.#options), binding.container_id))
|
|
189
|
+
return fail();
|
|
190
|
+
current = await inspectDockerWorldService(binding.container_id, spec, this.#options);
|
|
191
|
+
}
|
|
192
|
+
if (current?.status === "running" || current?.status === "paused"
|
|
193
|
+
|| current?.status === "restarting" || current?.status === "removing")
|
|
194
|
+
return fail();
|
|
195
|
+
if (current) {
|
|
196
|
+
try {
|
|
197
|
+
if (!exactMutationAck(await mutateDockerWorldService(["container", "rm", binding.container_id], this.#options), binding.container_id))
|
|
198
|
+
return fail();
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
if (!(error instanceof DockerWorldServiceProviderError)
|
|
202
|
+
|| error.kind !== "not_found")
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (await inspectDockerWorldService(binding.container_id, spec, this.#options) !== null)
|
|
207
|
+
return fail();
|
|
208
|
+
}
|
|
209
|
+
const resultHandle = request.operation === "start_world_service"
|
|
210
|
+
? binding.world_service_handle : null;
|
|
211
|
+
const receipt = await createWorldServiceReceipt({ claim, journal: this.#options.journal,
|
|
212
|
+
labels: spec.receiptLabels, request, resultHandle });
|
|
213
|
+
return this.#options.journal.complete(claim, receipt);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export const createDockerWorldServiceOperations = (options) => new DockerWorldServiceOperationsImpl(validOptions(options));
|