@noopolis/daimon 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +275 -51
- package/dist/contracts/attentionContract.d.ts +142 -0
- package/dist/contracts/attentionContract.d.ts.map +1 -0
- package/dist/contracts/attentionContract.js +21 -0
- package/dist/contracts/canonicalJson.d.ts +3 -0
- package/dist/contracts/canonicalJson.d.ts.map +1 -0
- package/dist/contracts/canonicalJson.js +54 -0
- package/dist/contracts/grokBrokerTaskClock.d.ts +18 -0
- package/dist/contracts/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/contracts/grokBrokerTaskClock.js +16 -0
- package/dist/contracts/grokWorkerContract.d.ts +74 -0
- package/dist/contracts/grokWorkerContract.d.ts.map +1 -0
- package/dist/contracts/grokWorkerContract.js +88 -0
- package/dist/contracts/organizationRuntimeContract.d.ts +841 -0
- package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
- package/dist/contracts/organizationRuntimeContract.js +123 -0
- package/dist/contracts/runtimeContractManifest.d.ts +1822 -0
- package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
- package/dist/contracts/runtimeContractManifest.js +206 -0
- package/dist/contracts/shellEnvironmentPolicy.d.ts +3 -0
- package/dist/contracts/shellEnvironmentPolicy.d.ts.map +1 -0
- package/dist/contracts/shellEnvironmentPolicy.js +5 -0
- package/dist/contracts/wakeMomentContract.d.ts +61 -0
- package/dist/contracts/wakeMomentContract.d.ts.map +1 -0
- package/dist/contracts/wakeMomentContract.js +27 -0
- package/dist/core/credentialRedaction.d.ts +4 -0
- package/dist/core/credentialRedaction.d.ts.map +1 -0
- package/dist/core/credentialRedaction.js +28 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.d.ts +1 -0
- package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.js +6 -2
- package/dist/mcp/toolServer.d.ts +19 -2
- package/dist/mcp/toolServer.d.ts.map +1 -1
- package/dist/mcp/toolServer.js +57 -17
- package/dist/observability/causalEvents.d.ts +6 -6
- package/dist/observability/causalEvents.d.ts.map +1 -1
- package/dist/observability/causalEvents.js +107 -19
- package/dist/observability/orgObserver.d.ts.map +1 -1
- package/dist/observability/orgObserver.js +3 -3
- package/dist/pi/agyHeadlessResult.d.ts +60 -0
- package/dist/pi/agyHeadlessResult.d.ts.map +1 -0
- package/dist/pi/agyHeadlessResult.js +95 -0
- package/dist/pi/cliChildOutput.d.ts +67 -0
- package/dist/pi/cliChildOutput.d.ts.map +1 -0
- package/dist/pi/cliChildOutput.js +269 -0
- package/dist/pi/cliEngineRun.d.ts +16 -0
- package/dist/pi/cliEngineRun.d.ts.map +1 -0
- package/dist/pi/cliEngineRun.js +27 -0
- package/dist/pi/cliEngineSpawn.d.ts +55 -0
- package/dist/pi/cliEngineSpawn.d.ts.map +1 -0
- package/dist/pi/cliEngineSpawn.js +169 -0
- package/dist/pi/cliEnvironment.d.ts +12 -0
- package/dist/pi/cliEnvironment.d.ts.map +1 -0
- package/dist/pi/cliEnvironment.js +34 -0
- package/dist/pi/cliMcpRegistration.d.ts +61 -0
- package/dist/pi/cliMcpRegistration.d.ts.map +1 -0
- package/dist/pi/cliMcpRegistration.js +75 -0
- package/dist/pi/cliProcess.d.ts +7 -0
- package/dist/pi/cliProcess.d.ts.map +1 -0
- package/dist/pi/cliProcess.js +132 -0
- package/dist/pi/cliSession.d.ts +86 -24
- package/dist/pi/cliSession.d.ts.map +1 -1
- package/dist/pi/cliSession.js +251 -173
- package/dist/pi/cliSessionMcp.d.ts +9 -0
- package/dist/pi/cliSessionMcp.d.ts.map +1 -0
- package/dist/pi/cliSessionMcp.js +80 -0
- package/dist/pi/cliTurnMetering.d.ts +60 -0
- package/dist/pi/cliTurnMetering.d.ts.map +1 -0
- package/dist/pi/cliTurnMetering.js +60 -0
- package/dist/pi/codexFilesystemRules.d.ts +3 -0
- package/dist/pi/codexFilesystemRules.d.ts.map +1 -0
- package/dist/pi/codexFilesystemRules.js +28 -0
- package/dist/pi/codexHeadlessResult.d.ts +68 -0
- package/dist/pi/codexHeadlessResult.d.ts.map +1 -0
- package/dist/pi/codexHeadlessResult.js +122 -0
- package/dist/pi/codexRolloutUsage.d.ts +95 -0
- package/dist/pi/codexRolloutUsage.d.ts.map +1 -0
- package/dist/pi/codexRolloutUsage.js +221 -0
- package/dist/pi/engineTaskClock.d.ts +9 -0
- package/dist/pi/engineTaskClock.d.ts.map +1 -0
- package/dist/pi/engineTaskClock.js +28 -0
- package/dist/pi/engineWakeLimits.d.ts +39 -0
- package/dist/pi/engineWakeLimits.d.ts.map +1 -0
- package/dist/pi/engineWakeLimits.js +55 -0
- package/dist/pi/grokHeadlessResult.d.ts +36 -0
- package/dist/pi/grokHeadlessResult.d.ts.map +1 -0
- package/dist/pi/grokHeadlessResult.js +118 -0
- package/dist/pi/grokHomeMcpRegistration.d.ts +21 -0
- package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -0
- package/dist/pi/grokHomeMcpRegistration.js +58 -0
- package/dist/pi/grokSandbox.d.ts +11 -0
- package/dist/pi/grokSandbox.d.ts.map +1 -0
- package/dist/pi/grokSandbox.js +216 -0
- package/dist/pi/grokStreamUsage.d.ts +31 -0
- package/dist/pi/grokStreamUsage.d.ts.map +1 -0
- package/dist/pi/grokStreamUsage.js +51 -0
- package/dist/pi/memoryClock.d.ts +25 -0
- package/dist/pi/memoryClock.d.ts.map +1 -0
- package/dist/pi/memoryClock.js +18 -0
- package/dist/pi/piAgentHandle.d.ts +6 -3
- package/dist/pi/piAgentHandle.d.ts.map +1 -1
- package/dist/pi/piAgentHandle.js +42 -12
- package/dist/pi/piAgentWakeSupport.d.ts +35 -0
- package/dist/pi/piAgentWakeSupport.d.ts.map +1 -1
- package/dist/pi/piAgentWakeSupport.js +4 -0
- package/dist/pi/piHarness.d.ts +18 -3
- package/dist/pi/piHarness.d.ts.map +1 -1
- package/dist/pi/piHarness.js +83 -14
- package/dist/pi/prompts.d.ts +1 -0
- package/dist/pi/prompts.d.ts.map +1 -1
- package/dist/pi/prompts.js +24 -0
- package/dist/pi/taskClockProcess.d.ts +6 -0
- package/dist/pi/taskClockProcess.d.ts.map +1 -0
- package/dist/pi/taskClockProcess.js +8 -0
- package/dist/pi/turnCausal.d.ts +4 -2
- package/dist/pi/turnCausal.d.ts.map +1 -1
- package/dist/pi/turnCausal.js +4 -4
- package/dist/pi/turnTrace.d.ts.map +1 -1
- package/dist/pi/turnTrace.js +5 -8
- package/dist/pi/wakeAcceptance.d.ts +1 -1
- package/dist/pi/wakeAcceptance.d.ts.map +1 -1
- package/dist/pi/wakeAcceptance.js +2 -2
- package/dist/pi/worldTrajectory.d.ts +1 -1
- package/dist/pi/worldTrajectory.d.ts.map +1 -1
- package/dist/pi/worldTrajectory.js +3 -3
- package/dist/runtime/agySubscriptionBootstrap.d.ts +16 -0
- package/dist/runtime/agySubscriptionBootstrap.d.ts.map +1 -0
- package/dist/runtime/agySubscriptionBootstrap.js +80 -0
- package/dist/runtime/agySubscriptionRealm.d.ts +38 -0
- package/dist/runtime/agySubscriptionRealm.d.ts.map +1 -0
- package/dist/runtime/agySubscriptionRealm.js +242 -0
- package/dist/runtime/attention.d.ts +26 -0
- package/dist/runtime/attention.d.ts.map +1 -0
- package/dist/runtime/attention.js +49 -0
- package/dist/runtime/attentionDispatcher.d.ts +78 -0
- package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
- package/dist/runtime/attentionDispatcher.js +365 -0
- package/dist/runtime/cli.d.ts +7 -0
- package/dist/runtime/cli.d.ts.map +1 -0
- package/dist/runtime/cli.js +256 -0
- package/dist/runtime/codexSandboxProjection.d.ts +17 -0
- package/dist/runtime/codexSandboxProjection.d.ts.map +1 -0
- package/dist/runtime/codexSandboxProjection.js +40 -0
- package/dist/runtime/contract-manifest.json +1 -0
- package/dist/runtime/contract-manifest.sha256 +1 -0
- package/dist/runtime/contractManifest.d.ts +8 -0
- package/dist/runtime/contractManifest.d.ts.map +1 -0
- package/dist/runtime/contractManifest.js +4 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts +40 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCapabilities.js +69 -0
- package/dist/runtime/engineBrokerControlClient.d.ts +55 -0
- package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
- package/dist/runtime/engineBrokerControlClient.js +228 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts +12 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCredentialJournal.js +26 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts +53 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts +171 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpCallLog.js +231 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts +59 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpFacade.js +346 -0
- package/dist/runtime/engineBrokerNativeClient.d.ts +52 -0
- package/dist/runtime/engineBrokerNativeClient.d.ts.map +1 -0
- package/dist/runtime/engineBrokerNativeClient.js +151 -0
- package/dist/runtime/engineBrokerProtocol.d.ts +167 -0
- package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerProtocol.js +357 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
- package/dist/runtime/engineBrokerSealLedger.js +132 -0
- package/dist/runtime/engineBrokerService.d.ts +43 -0
- package/dist/runtime/engineBrokerService.d.ts.map +1 -0
- package/dist/runtime/engineBrokerService.js +196 -0
- package/dist/runtime/engineBrokerServiceCli.d.ts +5 -0
- package/dist/runtime/engineBrokerServiceCli.d.ts.map +1 -0
- package/dist/runtime/engineBrokerServiceCli.js +32 -0
- package/dist/runtime/engineBrokerServiceConfig.d.ts +55 -0
- package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
- package/dist/runtime/engineBrokerServiceConfig.js +130 -0
- package/dist/runtime/engineBrokerSingleflight.d.ts +13 -0
- package/dist/runtime/engineBrokerSingleflight.d.ts.map +1 -0
- package/dist/runtime/engineBrokerSingleflight.js +24 -0
- package/dist/runtime/engineBrokerTurnAccounting.d.ts +76 -0
- package/dist/runtime/engineBrokerTurnAccounting.d.ts.map +1 -0
- package/dist/runtime/engineBrokerTurnAccounting.js +108 -0
- package/dist/runtime/engineBrokerTurnRegistry.d.ts +57 -0
- package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -0
- package/dist/runtime/engineBrokerTurnRegistry.js +159 -0
- package/dist/runtime/engineDispatcher.d.ts +38 -0
- package/dist/runtime/engineDispatcher.d.ts.map +1 -0
- package/dist/runtime/engineDispatcher.js +228 -0
- package/dist/runtime/engineReadiness.d.ts +23 -0
- package/dist/runtime/engineReadiness.d.ts.map +1 -0
- package/dist/runtime/engineReadiness.js +222 -0
- package/dist/runtime/grokAuthenticationError.d.ts +8 -0
- package/dist/runtime/grokAuthenticationError.d.ts.map +1 -0
- package/dist/runtime/grokAuthenticationError.js +20 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts +23 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialAuthority.js +150 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts +6 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialReader.js +38 -0
- package/dist/runtime/grokBrokerModelPolicy.d.ts +23 -0
- package/dist/runtime/grokBrokerModelPolicy.d.ts.map +1 -0
- package/dist/runtime/grokBrokerModelPolicy.js +28 -0
- package/dist/runtime/grokBrokerProjection.d.ts +114 -0
- package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProjection.js +101 -0
- package/dist/runtime/grokBrokerProviderClock.d.ts +26 -0
- package/dist/runtime/grokBrokerProviderClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProviderClock.js +133 -0
- package/dist/runtime/grokBrokerProxy.d.ts +69 -0
- package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxy.js +326 -0
- package/dist/runtime/grokBrokerProxyJson.d.ts +10 -0
- package/dist/runtime/grokBrokerProxyJson.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyJson.js +31 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyRequest.js +85 -0
- package/dist/runtime/grokBrokerRealmLease.d.ts +4 -0
- package/dist/runtime/grokBrokerRealmLease.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRealmLease.js +33 -0
- package/dist/runtime/grokBrokerRefresh.d.ts +2 -0
- package/dist/runtime/grokBrokerRefresh.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRefresh.js +15 -0
- package/dist/runtime/grokBrokerRunBudget.d.ts +20 -0
- package/dist/runtime/grokBrokerRunBudget.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRunBudget.js +85 -0
- package/dist/runtime/grokBrokerSlot.d.ts +6 -0
- package/dist/runtime/grokBrokerSlot.d.ts.map +1 -0
- package/dist/runtime/grokBrokerSlot.js +21 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts +32 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTaskClock.js +120 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts +180 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTurnMeter.js +337 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts +89 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
- package/dist/runtime/grokBrokerWorkerConfig.js +154 -0
- package/dist/runtime/grokEngineBroker.d.ts +88 -0
- package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
- package/dist/runtime/grokEngineBroker.js +202 -0
- package/dist/runtime/grokEngineBrokerLedger.d.ts +52 -0
- package/dist/runtime/grokEngineBrokerLedger.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerLedger.js +114 -0
- package/dist/runtime/grokEngineBrokerMetering.d.ts +51 -0
- package/dist/runtime/grokEngineBrokerMetering.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerMetering.js +34 -0
- package/dist/runtime/grokEngineBrokerTurn.d.ts +82 -0
- package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurn.js +348 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts +88 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.js +148 -0
- package/dist/runtime/grokInferenceClientConfig.d.ts +41 -0
- package/dist/runtime/grokInferenceClientConfig.d.ts.map +1 -0
- package/dist/runtime/grokInferenceClientConfig.js +62 -0
- package/dist/runtime/grokInferenceGrants.d.ts +77 -0
- package/dist/runtime/grokInferenceGrants.d.ts.map +1 -0
- package/dist/runtime/grokInferenceGrants.js +116 -0
- package/dist/runtime/grokInferenceProxy.d.ts +29 -0
- package/dist/runtime/grokInferenceProxy.d.ts.map +1 -0
- package/dist/runtime/grokInferenceProxy.js +85 -0
- package/dist/runtime/grokInferenceProxyRequest.d.ts +23 -0
- package/dist/runtime/grokInferenceProxyRequest.d.ts.map +1 -0
- package/dist/runtime/grokInferenceProxyRequest.js +63 -0
- package/dist/runtime/grokSlotPreflightReceipt.d.ts +70 -0
- package/dist/runtime/grokSlotPreflightReceipt.d.ts.map +1 -0
- package/dist/runtime/grokSlotPreflightReceipt.js +101 -0
- package/dist/runtime/grokSubscriptionRealm.d.ts +4 -0
- package/dist/runtime/grokSubscriptionRealm.d.ts.map +1 -0
- package/dist/runtime/grokSubscriptionRealm.js +435 -0
- package/dist/runtime/grokSubscriptionRealmTypes.d.ts +26 -0
- package/dist/runtime/grokSubscriptionRealmTypes.d.ts.map +1 -0
- package/dist/runtime/grokSubscriptionRealmTypes.js +1 -0
- package/dist/runtime/grokWorkerAttestation.d.ts +175 -0
- package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerAttestation.js +266 -0
- package/dist/runtime/grokWorkerDenyPlacement.d.ts +80 -0
- package/dist/runtime/grokWorkerDenyPlacement.d.ts.map +1 -0
- package/dist/runtime/grokWorkerDenyPlacement.js +128 -0
- package/dist/runtime/grokWorkerHomeAttestation.d.ts +32 -0
- package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerHomeAttestation.js +75 -0
- package/dist/runtime/grokWorkerSandboxProfile.d.ts +27 -0
- package/dist/runtime/grokWorkerSandboxProfile.d.ts.map +1 -0
- package/dist/runtime/grokWorkerSandboxProfile.js +44 -0
- package/dist/runtime/grokWorkerTmpAttestation.d.ts +55 -0
- package/dist/runtime/grokWorkerTmpAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerTmpAttestation.js +63 -0
- package/dist/runtime/index.d.ts +31 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/inferenceUsageLedger.d.ts +38 -0
- package/dist/runtime/inferenceUsageLedger.d.ts.map +1 -0
- package/dist/runtime/inferenceUsageLedger.js +53 -0
- package/dist/runtime/mcpToolResult.d.ts +127 -0
- package/dist/runtime/mcpToolResult.d.ts.map +1 -0
- package/dist/runtime/mcpToolResult.js +214 -0
- package/dist/runtime/moltnetMachineRead.d.ts +97 -0
- package/dist/runtime/moltnetMachineRead.d.ts.map +1 -0
- package/dist/runtime/moltnetMachineRead.js +183 -0
- package/dist/runtime/native/daimon-engine-broker +0 -0
- package/dist/runtime/organizationRuntime.d.ts +168 -0
- package/dist/runtime/organizationRuntime.d.ts.map +1 -0
- package/dist/runtime/organizationRuntime.js +3 -0
- package/dist/runtime/organizationRuntimeAdmission.d.ts +6 -0
- package/dist/runtime/organizationRuntimeAdmission.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeAdmission.js +22 -0
- package/dist/runtime/organizationRuntimeControl.d.ts +51 -0
- package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeControl.js +283 -0
- package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
- package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeHost.js +368 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeParsing.js +373 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeReadiness.js +67 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts +7 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeRecording.js +58 -0
- package/dist/runtime/physicalReadiness.d.ts +59 -0
- package/dist/runtime/physicalReadiness.d.ts.map +1 -0
- package/dist/runtime/physicalReadiness.js +176 -0
- package/dist/runtime/portableCredentialAuth.d.ts +6 -0
- package/dist/runtime/portableCredentialAuth.d.ts.map +1 -0
- package/dist/runtime/portableCredentialAuth.js +70 -0
- package/dist/runtime/portableCredentialMaterial.d.ts +8 -0
- package/dist/runtime/portableCredentialMaterial.d.ts.map +1 -0
- package/dist/runtime/portableCredentialMaterial.js +169 -0
- package/dist/runtime/productionAgentTools.d.ts +5 -0
- package/dist/runtime/productionAgentTools.d.ts.map +1 -0
- package/dist/runtime/productionAgentTools.js +336 -0
- package/dist/runtime/relocateRuntimeConfig.d.ts +14 -0
- package/dist/runtime/relocateRuntimeConfig.d.ts.map +1 -0
- package/dist/runtime/relocateRuntimeConfig.js +38 -0
- package/dist/runtime/runtimeHomeLayout.d.ts +48 -0
- package/dist/runtime/runtimeHomeLayout.d.ts.map +1 -0
- package/dist/runtime/runtimeHomeLayout.js +84 -0
- package/dist/runtime/schedule.d.ts +40 -0
- package/dist/runtime/schedule.d.ts.map +1 -0
- package/dist/runtime/schedule.js +376 -0
- package/dist/runtime/storeCoordination.d.ts +33 -0
- package/dist/runtime/storeCoordination.d.ts.map +1 -0
- package/dist/runtime/storeCoordination.js +117 -0
- package/dist/runtime/taskClock.d.ts +42 -0
- package/dist/runtime/taskClock.d.ts.map +1 -0
- package/dist/runtime/taskClock.js +102 -0
- package/dist/runtime/taskClockProcess.d.ts +17 -0
- package/dist/runtime/taskClockProcess.d.ts.map +1 -0
- package/dist/runtime/taskClockProcess.js +58 -0
- package/dist/runtime/toolResultSpill.d.ts +152 -0
- package/dist/runtime/toolResultSpill.d.ts.map +1 -0
- package/dist/runtime/toolResultSpill.js +351 -0
- package/dist/runtime/turnRequestLedger.d.ts +155 -0
- package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
- package/dist/runtime/turnRequestLedger.js +251 -0
- package/dist/runtime/turnUsageLedger.d.ts +143 -0
- package/dist/runtime/turnUsageLedger.d.ts.map +1 -0
- package/dist/runtime/turnUsageLedger.js +203 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts +34 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.js +79 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts +55 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceIndex.js +158 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +25 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.js +54 -0
- package/dist/runtime/wakeAcceptanceReconciliation.d.ts +211 -0
- package/dist/runtime/wakeAcceptanceReconciliation.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceReconciliation.js +289 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts +25 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRecord.js +58 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts +36 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRetention.js +38 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceStore.js +561 -0
- package/dist/runtime/wakeAcceptanceTypes.d.ts +179 -0
- package/dist/runtime/wakeAcceptanceTypes.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceTypes.js +95 -0
- package/dist/runtime/wakeFuse.d.ts +124 -0
- package/dist/runtime/wakeFuse.d.ts.map +1 -0
- package/dist/runtime/wakeFuse.js +466 -0
- package/dist/runtime/wakeMomentFs.d.ts +27 -0
- package/dist/runtime/wakeMomentFs.d.ts.map +1 -0
- package/dist/runtime/wakeMomentFs.js +223 -0
- package/dist/runtime/wakeMomentHistory.d.ts +26 -0
- package/dist/runtime/wakeMomentHistory.d.ts.map +1 -0
- package/dist/runtime/wakeMomentHistory.js +109 -0
- package/dist/runtime/wakeMomentIo.d.ts +22 -0
- package/dist/runtime/wakeMomentIo.d.ts.map +1 -0
- package/dist/runtime/wakeMomentIo.js +114 -0
- package/dist/runtime/wakeMomentRecorder.d.ts +33 -0
- package/dist/runtime/wakeMomentRecorder.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRecorder.js +81 -0
- package/dist/runtime/wakeMomentRetention.d.ts +7 -0
- package/dist/runtime/wakeMomentRetention.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRetention.js +143 -0
- package/dist/runtime/wakeMomentRows.d.ts +8 -0
- package/dist/runtime/wakeMomentRows.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRows.js +66 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts +56 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts.map +1 -0
- package/dist/runtime/wakeMomentSnapshot.js +248 -0
- package/package.json +22 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizationRuntime.d.ts","sourceRoot":"","sources":["../../src/runtime/organizationRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EACL,4CAA4C,EAC5C,sDAAsD,EACtD,kCAAkC,EAClC,qCAAqC,EACrC,+BAA+B,EAC/B,qCAAqC,EACrC,gDAAgD,EAChD,qCAAqC,EACrC,0CAA0C,EAC1C,wCAAwC,EACxC,6CAA6C,EAC7C,gDAAgD,EAChD,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACL,4CAA4C,EAC5C,sDAAsD,EACtD,kCAAkC,EAClC,qCAAqC,EACrC,+BAA+B,EAC/B,qCAAqC,EACrC,gDAAgD,EAChD,qCAAqC,EACrC,0CAA0C,EAC1C,wCAAwC,EACxC,6CAA6C,EAC7C,gDAAgD,EAChD,+BAA+B,EAC/B,4BAA4B,EAC7B,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AACrE;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAA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AA;CAAE,CAAC,CAAC;AAC5L,MAAM,MAAM,qCAAqC,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,8CAA8C,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE5I,sEAAsE;AACtE,MAAM,WAAW,uBAAuB;IACtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;IACtF,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7D,QAAQ,CAAC,OAAO,EAAE,kCAAkC,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAChG,IAAI,IAAI,OAAO,CAAC,qCAAqC,CAAC,CAAC;CACxD;AAED,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,iCAAiC,EAClC,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ORGANIZATION_RUNTIME_CODEX_REASONING_EFFORTS, ORGANIZATION_RUNTIME_CODEX_WORKSPACE_NO_NETWORK_POLICY, ORGANIZATION_RUNTIME_CONFIG_SCHEMA, ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA, ORGANIZATION_RUNTIME_MAX_AGENTS, ORGANIZATION_RUNTIME_MAX_CONFIG_BYTES, ORGANIZATION_RUNTIME_MAX_INSTRUCTIONS_CODEPOINTS, ORGANIZATION_RUNTIME_MAX_STRING_BYTES, ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS, ORGANIZATION_RUNTIME_MAX_WAKE_TEXT_BYTES, ORGANIZATION_RUNTIME_MAX_SCHEDULE_INTERVAL_MS, ORGANIZATION_RUNTIME_MAX_SCHEDULE_JITTER_SECONDS, ORGANIZATION_RUNTIME_V2_VERSION, ORGANIZATION_RUNTIME_VERSION } from "../contracts/organizationRuntimeContract.js";
|
|
2
|
+
export { ORGANIZATION_RUNTIME_CODEX_REASONING_EFFORTS, ORGANIZATION_RUNTIME_CODEX_WORKSPACE_NO_NETWORK_POLICY, ORGANIZATION_RUNTIME_CONFIG_SCHEMA, ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA, ORGANIZATION_RUNTIME_MAX_AGENTS, ORGANIZATION_RUNTIME_MAX_CONFIG_BYTES, ORGANIZATION_RUNTIME_MAX_INSTRUCTIONS_CODEPOINTS, ORGANIZATION_RUNTIME_MAX_STRING_BYTES, ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS, ORGANIZATION_RUNTIME_MAX_WAKE_TEXT_BYTES, ORGANIZATION_RUNTIME_MAX_SCHEDULE_INTERVAL_MS, ORGANIZATION_RUNTIME_MAX_SCHEDULE_JITTER_SECONDS, ORGANIZATION_RUNTIME_V2_VERSION, ORGANIZATION_RUNTIME_VERSION };
|
|
3
|
+
export { isOrganizationRuntimeConfig, parseOrganizationRuntimeConfig, parseOrganizationRuntimeWakeRequest, validateOrganizationRuntimeConfig } from "./organizationRuntimeParsing.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OrganizationRuntimeHost, OrganizationRuntimeWakeRequest, OrganizationRuntimeWakeResult } from "./organizationRuntime.js";
|
|
2
|
+
export declare function wakeFromDurableInbox(host: OrganizationRuntimeHost, request: OrganizationRuntimeWakeRequest): Promise<OrganizationRuntimeWakeResult>;
|
|
3
|
+
export declare function consumeDurableAdmission(request: OrganizationRuntimeWakeRequest): boolean;
|
|
4
|
+
export declare function registerRecordingVerifier(host: OrganizationRuntimeHost, verify: (agentId: string) => Promise<void>): OrganizationRuntimeHost;
|
|
5
|
+
export declare function verifyHostRecordingStore(host: OrganizationRuntimeHost, agentId: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=organizationRuntimeAdmission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizationRuntimeAdmission.d.ts","sourceRoot":"","sources":["../../src/runtime/organizationRuntimeAdmission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAMvI,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAIzJ;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAExF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAG5I;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5G"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Internal capabilities are object identities, never caller-provided wire fields.
|
|
2
|
+
const durableRequests = new WeakSet();
|
|
3
|
+
const recordingVerifiers = new WeakMap();
|
|
4
|
+
export async function wakeFromDurableInbox(host, request) {
|
|
5
|
+
durableRequests.add(request);
|
|
6
|
+
try {
|
|
7
|
+
return await host.wake(request);
|
|
8
|
+
}
|
|
9
|
+
finally {
|
|
10
|
+
durableRequests.delete(request);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function consumeDurableAdmission(request) {
|
|
14
|
+
return durableRequests.delete(request);
|
|
15
|
+
}
|
|
16
|
+
export function registerRecordingVerifier(host, verify) {
|
|
17
|
+
recordingVerifiers.set(host, verify);
|
|
18
|
+
return host;
|
|
19
|
+
}
|
|
20
|
+
export async function verifyHostRecordingStore(host, agentId) {
|
|
21
|
+
await recordingVerifiers.get(host)?.(agentId);
|
|
22
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type OrganizationRuntimeHost } from "./organizationRuntime.js";
|
|
2
|
+
import { type WakeBudgetSnapshot } from "./wakeFuse.js";
|
|
3
|
+
import type { AttentionRegistry } from "./attention.js";
|
|
4
|
+
import { type ScheduleControllerOptions } from "./schedule.js";
|
|
5
|
+
import { type WakeAcceptanceStoreTestOptions } from "./wakeAcceptanceStore.js";
|
|
6
|
+
import { type OrganizationRuntimeActivityV2, type OrganizationRuntimeWakeAcceptanceResult, type OrganizationRuntimeWakeReceiptStatus } from "./wakeAcceptanceTypes.js";
|
|
7
|
+
export type WorkDrain = Readonly<{
|
|
8
|
+
state: "draining" | "drained";
|
|
9
|
+
since: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type WorkAvailability = Readonly<{
|
|
12
|
+
version: "noopolis.daimon.work-availability.v1";
|
|
13
|
+
state: "running" | "paused" | "stopped";
|
|
14
|
+
agents: readonly Readonly<{
|
|
15
|
+
agent_id: string;
|
|
16
|
+
pending: number;
|
|
17
|
+
running: boolean;
|
|
18
|
+
deferred: number;
|
|
19
|
+
budget: WakeBudgetSnapshot;
|
|
20
|
+
error?: string;
|
|
21
|
+
}>[];
|
|
22
|
+
drain?: WorkDrain;
|
|
23
|
+
}>;
|
|
24
|
+
export type OrganizationRuntimeControlHost = OrganizationRuntimeHost & Readonly<{
|
|
25
|
+
accept(request: unknown): Promise<OrganizationRuntimeWakeAcceptanceResult>;
|
|
26
|
+
wakeReceipt(token: string | undefined, acceptanceId: string): Promise<OrganizationRuntimeWakeReceiptStatus | undefined>;
|
|
27
|
+
activityV2(token: string | undefined): Promise<OrganizationRuntimeActivityV2 | undefined>;
|
|
28
|
+
availability(token: string | undefined): Promise<WorkAvailability | undefined>;
|
|
29
|
+
/** Reversible operator drain: new wakes answer work-blocked, queued ones stay durable, running turns finish. */
|
|
30
|
+
drain(token: string | undefined): Promise<WorkAvailability | undefined>;
|
|
31
|
+
/** Ends a drain and dispatches the queue. Never clears the latched `fuse.stop`. */
|
|
32
|
+
resume(token: string | undefined): Promise<WorkAvailability | undefined>;
|
|
33
|
+
}>;
|
|
34
|
+
export type OrganizationRuntimeControlOptions = Readonly<{
|
|
35
|
+
acceptanceStorePath: string;
|
|
36
|
+
controlToken?: string;
|
|
37
|
+
}>;
|
|
38
|
+
type TestControlOptions = OrganizationRuntimeControlOptions & Readonly<{
|
|
39
|
+
scheduleOptions?: Pick<ScheduleControllerOptions, "clearTimer" | "now" | "setTimer">;
|
|
40
|
+
storeOptions?: WakeAcceptanceStoreTestOptions;
|
|
41
|
+
fuseEnvironment?: NodeJS.ProcessEnv;
|
|
42
|
+
fusePollIntervalMsForTest?: number;
|
|
43
|
+
attentionRegistryForTest?: AttentionRegistry;
|
|
44
|
+
}>;
|
|
45
|
+
/** Durable acceptance owns inbox delivery; only dispatch owns execution admission. */
|
|
46
|
+
export declare function createOrganizationRuntimeControlHost(config: unknown, options: OrganizationRuntimeControlOptions): OrganizationRuntimeControlHost;
|
|
47
|
+
/** @internal Test seam; intentionally absent from the public runtime barrel. */
|
|
48
|
+
export declare function createOrganizationRuntimeControlHostWithCoreForTest(config: unknown, host: OrganizationRuntimeHost, options: TestControlOptions): OrganizationRuntimeControlHost;
|
|
49
|
+
export declare const WAKE_FUSE_OPERATOR_POLL_MS = 1000;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=organizationRuntimeControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizationRuntimeControl.d.ts","sourceRoot":"","sources":["../../src/runtime/organizationRuntimeControl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuG,KAAK,uBAAuB,EAA8C,MAAM,0BAA0B,CAAC;AAEzN,OAAO,EAAY,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAqD,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAA0F,KAAK,8BAA8B,EAAE,MAAM,0BAA0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B,GAAG,SAAS,CAAC,CAAC;IACxE,mFAAmF;IACnF,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;CAC1E,CAAC,CAAC;AACH,MAAM,MAAM,iCAAiC,GAAG,QAAQ,CAAC;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACjH,KAAK,kBAAkB,GAAG,iCAAiC,GAAG,QAAQ,CAAC;IACrE,eAAe,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC,CAAC;IACrF,YAAY,CAAC,EAAE,8BAA8B,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACpC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,iBAAiB,CAAC;CAC9C,CAAC,CAAC;AAEH,sFAAsF;AACtF,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iCAAiC,GAAG,8BAA8B,CAIhJ;AACD,gFAAgF;AAChF,wBAAgB,mDAAmD,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,kBAAkB,GAAG,8BAA8B,CAE/K;AAoMD,eAAO,MAAM,0BAA0B,OAAO,CAAC"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { readTaskClock } from "./taskClock.js";
|
|
3
|
+
import { parseOrganizationRuntimeConfig, parseOrganizationRuntimeWakeRequest } from "./organizationRuntime.js";
|
|
4
|
+
import { createOrganizationRuntimeHostWithAttention } from "./organizationRuntimeHost.js";
|
|
5
|
+
import { WakeFuse } from "./wakeFuse.js";
|
|
6
|
+
import { AttentionDispatcher } from "./attentionDispatcher.js";
|
|
7
|
+
import { createScheduleController } from "./schedule.js";
|
|
8
|
+
import { WakeAcceptanceConflictError, WakeAcceptanceStore, WakeInboxFullError, publicAcceptance } from "./wakeAcceptanceStore.js";
|
|
9
|
+
import { parseWakeAcceptanceRequest, ACTIVITY_V2_VERSION } from "./wakeAcceptanceTypes.js";
|
|
10
|
+
/** Durable acceptance owns inbox delivery; only dispatch owns execution admission. */
|
|
11
|
+
export function createOrganizationRuntimeControlHost(config, options) {
|
|
12
|
+
const parsed = parseOrganizationRuntimeConfig(config);
|
|
13
|
+
const registry = new Map();
|
|
14
|
+
return createControl(parsed, createOrganizationRuntimeHostWithAttention(parsed, { sharedProtectedPaths: [options.acceptanceStorePath] }, registry), options, registry);
|
|
15
|
+
}
|
|
16
|
+
/** @internal Test seam; intentionally absent from the public runtime barrel. */
|
|
17
|
+
export function createOrganizationRuntimeControlHostWithCoreForTest(config, host, options) {
|
|
18
|
+
return createControl(parseOrganizationRuntimeConfig(config), host, { ...options, fuseEnvironment: options.fuseEnvironment ?? { DAIMON_WAKE_FUSE: "off" } }, options.attentionRegistryForTest ?? new Map());
|
|
19
|
+
}
|
|
20
|
+
function createControl(config, host, options, registry) {
|
|
21
|
+
const expectedToken = options.controlToken ?? process.env[config.host.controlTokenEnv];
|
|
22
|
+
const knownAgents = new Set(config.agents.map((agent) => agent.id));
|
|
23
|
+
const persistence = new Set();
|
|
24
|
+
let store;
|
|
25
|
+
let schedules;
|
|
26
|
+
let fuse;
|
|
27
|
+
let dispatcher;
|
|
28
|
+
let fusePoll;
|
|
29
|
+
let started = false;
|
|
30
|
+
let stopping = false;
|
|
31
|
+
let sealedActivity;
|
|
32
|
+
/** In-process only: a restarted host admits, so a drained release ends drained-free. */
|
|
33
|
+
let drainedSince;
|
|
34
|
+
/** Synchronous v1 turns bypass the dispatcher; a drain is not drained while one is admitted or running. */
|
|
35
|
+
let v1Turns = 0;
|
|
36
|
+
/**
|
|
37
|
+
* One projection, read the same way live and at shutdown. `active` is decided by
|
|
38
|
+
* the dispatcher's own execution authority rather than the record's flag alone,
|
|
39
|
+
* so a stopped host — whose dispatcher has already awaited every in-flight turn
|
|
40
|
+
* — reports exactly the executions that were still admitted when it stopped.
|
|
41
|
+
*/
|
|
42
|
+
const projectActivity = async (current, state) => {
|
|
43
|
+
const executions = dispatcher?.activeExecutions() ?? [];
|
|
44
|
+
const items = (await current.activity()).map((item) => ({ ...item, active: item.active && executions.some((execution) => execution.agent_id === item.agent_id && execution.delivery_ids.includes(item.delivery_id)) }));
|
|
45
|
+
return { version: ACTIVITY_V2_VERSION, state, items, executions };
|
|
46
|
+
};
|
|
47
|
+
const hardReason = () => {
|
|
48
|
+
if (!started || stopping)
|
|
49
|
+
return stopping ? "host_stopping" : "host_stopped";
|
|
50
|
+
if (dispatcher?.fatalReason())
|
|
51
|
+
return dispatcher.fatalReason();
|
|
52
|
+
const reason = fuse?.tripped();
|
|
53
|
+
return reason === "operator_stop" || reason === "ledger_unavailable" ? reason : undefined;
|
|
54
|
+
};
|
|
55
|
+
const accept = async (value, nativeSchedule = false) => {
|
|
56
|
+
let request;
|
|
57
|
+
try {
|
|
58
|
+
request = parseWakeAcceptanceRequest(value);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return rejected("invalid_request");
|
|
62
|
+
}
|
|
63
|
+
if (!tokensEqual(expectedToken, request.token))
|
|
64
|
+
return rejected("unauthorized");
|
|
65
|
+
if (!knownAgents.has(request.agent_id))
|
|
66
|
+
return rejected("unknown_agent");
|
|
67
|
+
// Check the operator latch before taking ownership, even between polls.
|
|
68
|
+
await fuse?.pollOperatorStop();
|
|
69
|
+
const reason = hardReason();
|
|
70
|
+
if (reason)
|
|
71
|
+
return blocked(reason);
|
|
72
|
+
// A drain is an operator stop that can be undone; bridges already defer on this reason.
|
|
73
|
+
if (drainedSince !== undefined)
|
|
74
|
+
return blocked("operator_stop");
|
|
75
|
+
const operation = (async () => {
|
|
76
|
+
try {
|
|
77
|
+
const accepted = await store.accept(request, nativeSchedule);
|
|
78
|
+
// A stop racing this fsync cannot revoke already durable ownership.
|
|
79
|
+
// It remains accepted for restart instead of being terminalized.
|
|
80
|
+
dispatcher?.notify(request.agent_id, accepted.created);
|
|
81
|
+
return publicAcceptance(accepted.record);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof WakeAcceptanceConflictError)
|
|
85
|
+
return rejected("delivery_conflict");
|
|
86
|
+
if (error instanceof WakeInboxFullError)
|
|
87
|
+
return blocked("queue_full");
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
persistence.add(operation);
|
|
92
|
+
try {
|
|
93
|
+
return await operation;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
persistence.delete(operation);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const availability = async (token) => {
|
|
100
|
+
if (!tokensEqual(expectedToken, token) || !store || !fuse)
|
|
101
|
+
return undefined;
|
|
102
|
+
await fuse.pollOperatorStop();
|
|
103
|
+
const items = await store.activityWithExecutionErrors();
|
|
104
|
+
const executionErrors = new Map(items.filter((record) => (record.state === "accepted" || record.state === "running")
|
|
105
|
+
&& record.execution_error !== undefined).map((record) => [record.agent_id, record.execution_error]));
|
|
106
|
+
const agents = await Promise.all(config.agents.map(async (agent) => ({
|
|
107
|
+
agent_id: agent.id, pending: items.filter((item) => item.agent_id === agent.id && (item.state === "accepted" || item.state === "running" && !dispatcher?.activeExecutions().some((execution) => execution.agent_id === agent.id))).length,
|
|
108
|
+
running: dispatcher?.activeExecutions().some((execution) => execution.agent_id === agent.id) ?? false,
|
|
109
|
+
deferred: items.filter((item) => item.agent_id === agent.id && item.state === "accepted" && item.deferred).length,
|
|
110
|
+
budget: await fuse.snapshot(agent.id, agent.attention),
|
|
111
|
+
...((dispatcher?.failure(agent.id) ?? executionErrors.get(agent.id))
|
|
112
|
+
? { error: dispatcher?.failure(agent.id) ?? executionErrors.get(agent.id) } : {})
|
|
113
|
+
})));
|
|
114
|
+
// "drained" only once no inbox loop is alive: nothing runs and nothing can start until resume.
|
|
115
|
+
const drain = drainedSince === undefined ? undefined : { state: dispatcher?.quiescent() === false || v1Turns > 0 ? "draining" : "drained", since: drainedSince };
|
|
116
|
+
return { version: "noopolis.daimon.work-availability.v1", state: hardReason() ? "stopped" : drain !== undefined || agents.some((agent) => agent.budget.state !== "available" || agent.error) ? "paused" : "running", agents, ...(drain === undefined ? {} : { drain }) };
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
wake: async (request) => {
|
|
120
|
+
try {
|
|
121
|
+
request = parseOrganizationRuntimeWakeRequest(request);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: "", wakeId: "", code: "invalid_request" };
|
|
125
|
+
}
|
|
126
|
+
// Attention and recording require durable ownership and dispatcher admission.
|
|
127
|
+
if (!tokensEqual(expectedToken, request.token))
|
|
128
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: request.agentId, wakeId: request.event.id, code: "unauthorized" };
|
|
129
|
+
if (!knownAgents.has(request.agentId))
|
|
130
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: request.agentId, wakeId: request.event.id, code: "unknown_agent" };
|
|
131
|
+
const agent = config.agents.find((candidate) => candidate.id === request.agentId);
|
|
132
|
+
if (agent.attention !== undefined || agent.recording !== undefined)
|
|
133
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: request.agentId, wakeId: request.event.id, code: "durable_inbox_required" };
|
|
134
|
+
// v1 has no `blocked` member on its wire; a drain answers it exactly as the latched stop does.
|
|
135
|
+
if (hardReason() || drainedSince !== undefined)
|
|
136
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "stopped", agentId: request.agentId, wakeId: request.event.id, code: "host_stopping" };
|
|
137
|
+
v1Turns += 1;
|
|
138
|
+
try {
|
|
139
|
+
if ((await fuse.admit(request.agentId, request.event.id, config.agents.find((agent) => agent.id === request.agentId)?.attention)).state !== "admitted")
|
|
140
|
+
return { version: "noopolis.daimon.wake-result.v1", status: "stopped", agentId: request.agentId, wakeId: request.event.id, code: "host_stopping" };
|
|
141
|
+
return await host.wake(request);
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
v1Turns -= 1;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
health: async (agentId) => await host.health(agentId),
|
|
148
|
+
activity: async (request) => await host.activity(request),
|
|
149
|
+
async start() {
|
|
150
|
+
if (started)
|
|
151
|
+
return;
|
|
152
|
+
const clock = readTaskClock();
|
|
153
|
+
if (stopping)
|
|
154
|
+
throw new Error("organization runtime control host has been stopped");
|
|
155
|
+
if (!expectedToken?.trim())
|
|
156
|
+
throw new Error("required control token is missing or blank");
|
|
157
|
+
const opened = await WakeAcceptanceStore.open(options.acceptanceStorePath, options.storeOptions);
|
|
158
|
+
let openedFuse;
|
|
159
|
+
try {
|
|
160
|
+
openedFuse = await WakeFuse.open({ organizationKey: [...knownAgents].sort().join("\u0000"), environment: options.fuseEnvironment });
|
|
161
|
+
await host.start();
|
|
162
|
+
store = opened;
|
|
163
|
+
fuse = openedFuse;
|
|
164
|
+
started = true;
|
|
165
|
+
dispatcher = new AttentionDispatcher({ store, host, fuse, agents: config.agents, registry, token: expectedToken, onIdle: (agentId) => { void schedules?.drain(agentId).catch(() => undefined); } });
|
|
166
|
+
if (!hardReason())
|
|
167
|
+
for (const agentId of new Set((await opened.recoverable(knownAgents)).filter((record) => !record.deferred).map((record) => record.agent_id)))
|
|
168
|
+
dispatcher.notify(agentId);
|
|
169
|
+
fusePoll = setInterval(() => {
|
|
170
|
+
void fuse?.pollOperatorStop().then((reason) => {
|
|
171
|
+
if (reason === "operator_stop" || reason === "ledger_unavailable")
|
|
172
|
+
dispatcher?.halt();
|
|
173
|
+
}).catch(() => undefined);
|
|
174
|
+
}, options.fusePollIntervalMsForTest ?? WAKE_FUSE_OPERATOR_POLL_MS);
|
|
175
|
+
fusePoll.unref();
|
|
176
|
+
if (config.version === "noopolis.daimon.organization-runtime.v2") {
|
|
177
|
+
schedules = createScheduleController({ acceptanceStorePath: options.acceptanceStorePath, agents: config.agents, ...options.scheduleOptions,
|
|
178
|
+
// Calendar selection/state use task instants; due - taskNow remains a real delay.
|
|
179
|
+
now: () => { const realNow = (options.scheduleOptions?.now ?? Date.now)(); return clock?.at(realNow) ?? realNow; },
|
|
180
|
+
accept: async (occurrence) => {
|
|
181
|
+
if (dispatcher?.busy(occurrence.agentId) || hardReason() || drainedSince !== undefined)
|
|
182
|
+
return false;
|
|
183
|
+
const result = await accept({ token: expectedToken, agent_id: occurrence.agentId, delivery_id: occurrence.deliveryId, event: { version: "noopolis.daimon.wake.v2", kind: "schedule", text: occurrence.prompt, occurred_at: occurrence.occurredAt } }, true);
|
|
184
|
+
return result.state === "accepted";
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
await schedules.start();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
dispatcher?.halt();
|
|
192
|
+
await host.stop().catch(() => undefined);
|
|
193
|
+
await dispatcher?.stop().catch(() => undefined);
|
|
194
|
+
await openedFuse?.close().catch(() => undefined);
|
|
195
|
+
await opened.close().catch(() => undefined);
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
// Do not expose the private provenance argument, even to JavaScript callers.
|
|
200
|
+
accept: (value) => accept(value),
|
|
201
|
+
async wakeReceipt(token, acceptanceId) {
|
|
202
|
+
if (!tokensEqual(expectedToken, token) || store === undefined)
|
|
203
|
+
return undefined;
|
|
204
|
+
return await store.status(acceptanceId);
|
|
205
|
+
},
|
|
206
|
+
async activityV2(token) {
|
|
207
|
+
if (!tokensEqual(expectedToken, token))
|
|
208
|
+
return undefined;
|
|
209
|
+
// A stopped host is not an unanswerable one. Its sealed projection is a
|
|
210
|
+
// *stronger* statement about quiescence than a live poll, because nothing
|
|
211
|
+
// can be admitted after it, and a caller proving that an execution closed
|
|
212
|
+
// has no other authority to read. A host that never started, or one whose
|
|
213
|
+
// seal could not be taken, still answers nothing: absence stays absence
|
|
214
|
+
// rather than becoming a fabricated idle runtime.
|
|
215
|
+
if (store === undefined)
|
|
216
|
+
return sealedActivity;
|
|
217
|
+
return await projectActivity(store, "running");
|
|
218
|
+
},
|
|
219
|
+
availability,
|
|
220
|
+
async drain(token) {
|
|
221
|
+
if (!tokensEqual(expectedToken, token) || !store || !fuse)
|
|
222
|
+
return undefined;
|
|
223
|
+
drainedSince ??= new Date().toISOString();
|
|
224
|
+
dispatcher?.pause();
|
|
225
|
+
return await availability(token);
|
|
226
|
+
},
|
|
227
|
+
async resume(token) {
|
|
228
|
+
if (!tokensEqual(expectedToken, token) || !store || !fuse)
|
|
229
|
+
return undefined;
|
|
230
|
+
if (drainedSince !== undefined) {
|
|
231
|
+
drainedSince = undefined;
|
|
232
|
+
// A latched operator stop or fatal fault outlives the drain: resume never reopens it.
|
|
233
|
+
if (!hardReason()) {
|
|
234
|
+
// An owed pass for every agent the drain withheld or that holds queued work;
|
|
235
|
+
// owed passes never count as new input, so deferred deliveries stay deferred.
|
|
236
|
+
const queued = new Set((await store.recoverable(knownAgents).catch(() => [])).filter((record) => !record.deferred).map((record) => record.agent_id));
|
|
237
|
+
if (drainedSince === undefined && !hardReason())
|
|
238
|
+
dispatcher?.resume(queued);
|
|
239
|
+
void schedules?.drain().catch(() => undefined);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return await availability(token);
|
|
243
|
+
},
|
|
244
|
+
async stop() {
|
|
245
|
+
if (!started && stopping)
|
|
246
|
+
return { version: "noopolis.daimon.organization-runtime-stop.v1", state: "stopped" };
|
|
247
|
+
stopping = true;
|
|
248
|
+
dispatcher?.halt();
|
|
249
|
+
if (fusePoll !== undefined)
|
|
250
|
+
clearInterval(fusePoll);
|
|
251
|
+
await schedules?.stop();
|
|
252
|
+
await Promise.allSettled(persistence);
|
|
253
|
+
const result = await host.stop();
|
|
254
|
+
await dispatcher?.stop();
|
|
255
|
+
// The last moment the store can be read, and the only one at which the
|
|
256
|
+
// dispatcher has finished every admitted turn. Seal the projection here so
|
|
257
|
+
// the closure query keeps an accurate answer once the store is closed; a
|
|
258
|
+
// fault leaves it absent instead of inventing one.
|
|
259
|
+
if (store) {
|
|
260
|
+
try {
|
|
261
|
+
sealedActivity = await projectActivity(store, "stopped");
|
|
262
|
+
}
|
|
263
|
+
catch { /* an unreadable final state stays absent */ }
|
|
264
|
+
}
|
|
265
|
+
await store?.close();
|
|
266
|
+
await fuse?.close();
|
|
267
|
+
store = undefined;
|
|
268
|
+
fuse = undefined;
|
|
269
|
+
schedules = undefined;
|
|
270
|
+
started = false;
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
export const WAKE_FUSE_OPERATOR_POLL_MS = 1000;
|
|
276
|
+
function rejected(code) { return { version: "noopolis.daimon.wake-acceptance.v2", state: "rejected", code }; }
|
|
277
|
+
function blocked(reason) { return { version: "noopolis.daimon.wake-acceptance.v2", state: "stopped", code: reason === "host_stopped" ? "host_stopped" : "host_stopping", blocked: { version: "noopolis.daimon.work-blocked.v1", reason, retry_after_ms: 30000 } }; }
|
|
278
|
+
function tokensEqual(expected, actual) {
|
|
279
|
+
if (!expected?.trim())
|
|
280
|
+
return false;
|
|
281
|
+
const digest = (value) => createHash("sha256").update(value).digest();
|
|
282
|
+
return timingSafeEqual(digest(expected), digest(actual ?? ""));
|
|
283
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AttentionRegistry } from "./attention.js";
|
|
2
|
+
import type { AgentHandle } from "../core/types.js";
|
|
3
|
+
import type { OrganizationRuntimePathAuthority } from "./physicalReadiness.js";
|
|
4
|
+
import { type OrganizationRuntimeAgentConfig, type OrganizationRuntimeHost } from "./organizationRuntime.js";
|
|
5
|
+
type OrganizationRuntimeEngineFactory = (agent: OrganizationRuntimeAgentConfig, paths?: ReturnType<OrganizationRuntimePathAuthority["forAgent"]>) => Promise<AgentHandle>;
|
|
6
|
+
type ProductionHostOptions = Readonly<{
|
|
7
|
+
sharedProtectedPaths?: readonly string[];
|
|
8
|
+
}>;
|
|
9
|
+
/** Creates the public host with Daimon's closed production engine dispatcher. */
|
|
10
|
+
export declare function createOrganizationRuntimeHost(config: unknown, options?: ProductionHostOptions): OrganizationRuntimeHost;
|
|
11
|
+
/** @internal Control-owned attention registry, never a caller-supplied config hook. */
|
|
12
|
+
export declare function createOrganizationRuntimeHostWithAttention(config: unknown, options: ProductionHostOptions, attention: AttentionRegistry): OrganizationRuntimeHost;
|
|
13
|
+
/** @internal Test-only construction seam; it is intentionally not package-exported. */
|
|
14
|
+
export declare function createOrganizationRuntimeHostForTest(config: unknown, factory: OrganizationRuntimeEngineFactory, preflight?: () => Promise<OrganizationRuntimePathAuthority>): OrganizationRuntimeHost;
|
|
15
|
+
/** Engine failures are undiagnosable without the cause, so carry a bounded excerpt. */
|
|
16
|
+
export declare const ENGINE_FAILURE_DETAIL_MAX_BYTES = 2048;
|
|
17
|
+
export declare function engineFailureDetail(error: unknown): string | undefined;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=organizationRuntimeHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizationRuntimeHost.d.ts","sourceRoot":"","sources":["../../src/runtime/organizationRuntimeHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,kBAAkB,CAAC;AAG5E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAK/E,OAAO,EAML,KAAK,8BAA8B,EAInC,KAAK,uBAAuB,EAK7B,MAAM,0BAA0B,CAAC;AAClC,KAAK,gCAAgC,GAAG,CACtC,KAAK,EAAE,8BAA8B,EACrC,KAAK,CAAC,EAAE,UAAU,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC,KAC7D,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B,KAAK,qBAAqB,GAAG,QAAQ,CAAC;IAAE,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AAgBpF,iFAAiF;AACjF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,qBAA0B,GAAG,uBAAuB,CAI3H;AACD,uFAAuF;AACvF,wBAAgB,0CAA0C,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,iBAAiB,GAAG,uBAAuB,CAmBjK;AAED,uFAAuF;AACvF,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,gCAAgC,EACzC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,gCAAgC,CAAC,GAC1D,uBAAuB,CAKzB;AA8RD,uFAAuF;AACvF,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AAOrD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMtE"}
|