@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,365 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { taskClockAttentionMessages } from "./attention.js";
|
|
3
|
+
import { engineFailureDetail } from "./organizationRuntimeHost.js";
|
|
4
|
+
import { WakeExecutionClaimLostError } from "./wakeAcceptanceStore.js";
|
|
5
|
+
import { sanitizeExecutionError } from "./wakeAcceptanceRecord.js";
|
|
6
|
+
import { STALE_QUEUED_DELIVERY_MS } from "./wakeAcceptanceRetention.js";
|
|
7
|
+
import { ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS, ORGANIZATION_RUNTIME_MAX_WAKE_TEXT_BYTES } from "../contracts/organizationRuntimeContract.js";
|
|
8
|
+
import { grokDaimonToolName } from "../contracts/grokWorkerContract.js";
|
|
9
|
+
import { verifyHostRecordingStore, wakeFromDurableInbox } from "./organizationRuntimeAdmission.js";
|
|
10
|
+
import { recordWakeMoment } from "./wakeMomentRecorder.js";
|
|
11
|
+
/** Durable deliveries wait here; only a selected execution reserves a budget slot. */
|
|
12
|
+
export class AttentionDispatcher {
|
|
13
|
+
options;
|
|
14
|
+
owner = randomUUID();
|
|
15
|
+
work = new Map();
|
|
16
|
+
observed = new Map();
|
|
17
|
+
generations = new Map();
|
|
18
|
+
waiters = new Set();
|
|
19
|
+
active = new Map();
|
|
20
|
+
errors = new Map();
|
|
21
|
+
stopping = false;
|
|
22
|
+
/** Reversible drain: no new execution starts; durable deliveries stay queued. */
|
|
23
|
+
paused = false;
|
|
24
|
+
/** Agents whose inbox loop gave up its turn to a drain; resume owes each one a pass. */
|
|
25
|
+
pausedOut = new Set();
|
|
26
|
+
fatal;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
notify(agentId, fresh = false) {
|
|
31
|
+
if (fresh)
|
|
32
|
+
this.generations.set(agentId, (this.generations.get(agentId) ?? 0) + 1);
|
|
33
|
+
if (this.stopping)
|
|
34
|
+
return;
|
|
35
|
+
// Every pass a drain withholds is owed back on resume.
|
|
36
|
+
if (this.paused) {
|
|
37
|
+
this.pausedOut.add(agentId);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (this.work.has(agentId))
|
|
41
|
+
return;
|
|
42
|
+
// An owed pass is not new input: it starts from the generation already seen, so
|
|
43
|
+
// deferred deliveries stay deferred unless something really arrived meanwhile.
|
|
44
|
+
const baseline = this.pausedOut.delete(agentId) ? this.observed.get(agentId) ?? 0 : 0;
|
|
45
|
+
const task = this.drain(agentId, baseline).catch((error) => { this.observed.set(agentId, this.generations.get(agentId) ?? 0); this.errors.set(agentId, engineFailureDetail(error) ?? "inbox_storage_unavailable"); }).finally(() => {
|
|
46
|
+
this.work.delete(agentId);
|
|
47
|
+
// A resume that landed while this loop was still unwinding its paused exit found it busy; run the owed pass now.
|
|
48
|
+
if (!this.stopping && ((this.generations.get(agentId) ?? 0) > (this.observed.get(agentId) ?? 0) || this.pausedOut.has(agentId)))
|
|
49
|
+
this.notify(agentId);
|
|
50
|
+
this.options.onIdle(agentId);
|
|
51
|
+
});
|
|
52
|
+
this.work.set(agentId, task);
|
|
53
|
+
}
|
|
54
|
+
fatalReason() { return this.fatal; }
|
|
55
|
+
busy(agentId) { return this.work.has(agentId); }
|
|
56
|
+
activeExecutions() { return [...this.active].map(([agent_id, value]) => ({ agent_id, ...value, state: "running" })); }
|
|
57
|
+
failure(agentId) { return this.errors.get(agentId); }
|
|
58
|
+
async stop() {
|
|
59
|
+
this.stopping = true;
|
|
60
|
+
for (const finish of this.waiters)
|
|
61
|
+
finish();
|
|
62
|
+
await Promise.allSettled(this.work.values());
|
|
63
|
+
await this.options.store.releaseClaims(this.owner);
|
|
64
|
+
}
|
|
65
|
+
halt() { this.stopping = true; for (const finish of this.waiters)
|
|
66
|
+
finish(); }
|
|
67
|
+
/** Stops admitting executions; a running turn finishes and its records settle as usual. */
|
|
68
|
+
pause() { this.paused = true; for (const finish of this.waiters)
|
|
69
|
+
finish(); }
|
|
70
|
+
/** Admits again and revisits every agent whose inbox moved while paused. */
|
|
71
|
+
resume(queued = []) {
|
|
72
|
+
this.paused = false;
|
|
73
|
+
// Agents with queued work get an owed pass too: a delivery parked before the
|
|
74
|
+
// drain (a budget pause, say) has no generation of its own to wake it.
|
|
75
|
+
for (const agentId of queued)
|
|
76
|
+
this.pausedOut.add(agentId);
|
|
77
|
+
for (const agent of this.options.agents)
|
|
78
|
+
if ((this.generations.get(agent.id) ?? 0) > (this.observed.get(agent.id) ?? 0) || this.pausedOut.has(agent.id))
|
|
79
|
+
this.notify(agent.id);
|
|
80
|
+
}
|
|
81
|
+
/** True once no inbox loop is alive: nothing runs, and nothing can start until resume. */
|
|
82
|
+
quiescent() { return this.work.size === 0; }
|
|
83
|
+
async drain(agentId, baseline = 0) {
|
|
84
|
+
const agent = this.options.agents.find((value) => value.id === agentId);
|
|
85
|
+
let observedGeneration = baseline;
|
|
86
|
+
while (!this.stopping) {
|
|
87
|
+
if (this.paused) {
|
|
88
|
+
this.pausedOut.add(agentId);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const generation = this.generations.get(agentId) ?? 0;
|
|
92
|
+
const stale = [];
|
|
93
|
+
const records = (await this.options.store.recoverable(new Set(this.options.agents.map((value) => value.id)), (record) => { if (record.agent_id === agentId)
|
|
94
|
+
stale.push(record); })).filter((record) => record.agent_id === agentId);
|
|
95
|
+
for (const record of stale)
|
|
96
|
+
await expireStaleDelivery(this.options.store, record);
|
|
97
|
+
const selected = selectBatch(records, agent, generation > observedGeneration);
|
|
98
|
+
observedGeneration = generation;
|
|
99
|
+
this.observed.set(agentId, generation);
|
|
100
|
+
this.errors.delete(agentId);
|
|
101
|
+
if (!selected.length)
|
|
102
|
+
return;
|
|
103
|
+
const budget = await this.options.fuse.snapshot(agentId, agent.attention);
|
|
104
|
+
if (budget.state !== "available")
|
|
105
|
+
return;
|
|
106
|
+
if (this.paused) {
|
|
107
|
+
this.pausedOut.add(agentId);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const executionId = selected[0].execution_id ?? randomUUID();
|
|
111
|
+
const acquired = await this.options.store.acquireClaim(selected[0].acceptance_id, this.owner, selected.map((record) => record.acceptance_id), executionId);
|
|
112
|
+
if (acquired.state === "held") {
|
|
113
|
+
await this.waitUntil(acquired.retry_at);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (acquired.state === "terminal")
|
|
117
|
+
continue;
|
|
118
|
+
const claimed = selected.map((record) => ({ record, claim: acquired.claim, done: false }));
|
|
119
|
+
for (const item of claimed)
|
|
120
|
+
item.record = await this.options.store.transitionClaimed(item.record.acceptance_id, item.claim, "running", undefined, undefined, agent.attention === undefined ? undefined : { execution_id: executionId, deferred: false });
|
|
121
|
+
// A member ended between selection and claim (another host's expiry or stop
|
|
122
|
+
// reached it first): never wake cognition on a batch that includes it.
|
|
123
|
+
if (claimed.some((item) => item.record.state !== "running")) {
|
|
124
|
+
for (const item of claimed.filter((value) => value.record.state === "running"))
|
|
125
|
+
await this.options.store.transitionClaimed(item.record.acceptance_id, item.claim, "accepted");
|
|
126
|
+
await this.options.store.releaseClaim(claimed[0].claim);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
// A drain that arrived after the claim releases it before any budget is spent.
|
|
130
|
+
// Admission is the drain's linearization point: a turn the fuse admitted before
|
|
131
|
+
// the loop saw the drain is a running turn, and keeps the host "draining".
|
|
132
|
+
const pausedBeforeAdmit = this.paused;
|
|
133
|
+
const verdict = pausedBeforeAdmit ? undefined : await this.options.fuse.admit(agentId, randomUUID(), agent.attention);
|
|
134
|
+
if (verdict?.state !== "admitted" || this.stopping) {
|
|
135
|
+
if (pausedBeforeAdmit)
|
|
136
|
+
this.pausedOut.add(agentId);
|
|
137
|
+
for (const item of claimed)
|
|
138
|
+
await this.options.store.transitionClaimed(item.record.acceptance_id, item.claim, "accepted");
|
|
139
|
+
await this.options.store.releaseClaim(claimed[0].claim);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
await this.execute(agent, claimed, executionId);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async execute(agent, claimed, executionId) {
|
|
146
|
+
const { store, registry, host, token, fuse } = this.options;
|
|
147
|
+
// Serialize tool disposition and lease renewal against the same current claim.
|
|
148
|
+
let mutation = Promise.resolve();
|
|
149
|
+
const serialize = (operation) => {
|
|
150
|
+
const result = mutation.then(operation);
|
|
151
|
+
mutation = result.then(() => undefined, () => undefined);
|
|
152
|
+
void result.catch((error) => { if (error instanceof WakeExecutionClaimLostError)
|
|
153
|
+
this.failClosed(agent.id, error); });
|
|
154
|
+
return result;
|
|
155
|
+
};
|
|
156
|
+
const heartbeat = setInterval(() => {
|
|
157
|
+
void serialize(async () => {
|
|
158
|
+
const renewed = await store.renewClaim(claimed[0].claim.acceptance_id, claimed[0].claim);
|
|
159
|
+
for (const item of claimed)
|
|
160
|
+
item.claim = renewed;
|
|
161
|
+
for (const item of claimed.filter((value) => !value.done))
|
|
162
|
+
await store.transitionClaimed(item.record.acceptance_id, item.claim, "running");
|
|
163
|
+
}).catch((error) => this.failClosed(agent.id, error));
|
|
164
|
+
}, store.claimHeartbeatIntervalMs());
|
|
165
|
+
this.active.set(agent.id, { execution_id: agent.attention === undefined ? claimed[0].record.delivery_id : executionId, delivery_ids: claimed.map((item) => item.record.delivery_id) });
|
|
166
|
+
let result;
|
|
167
|
+
try {
|
|
168
|
+
const messages = taskClockAttentionMessages(claimed.map(({ record }) => record));
|
|
169
|
+
if (agent.attention !== undefined)
|
|
170
|
+
registry.set(agent.id, {
|
|
171
|
+
executionId, messages, budget: () => fuse.snapshot(agent.id, agent.attention),
|
|
172
|
+
disposition: (deliveryId, disposition) => serialize(async () => {
|
|
173
|
+
const item = claimed.find((value) => value.record.delivery_id === deliveryId);
|
|
174
|
+
if (!item)
|
|
175
|
+
throw new Error("Delivery is outside this agent's selected inbox turn");
|
|
176
|
+
if (item.done && item.record.state === "completed") {
|
|
177
|
+
if (disposition !== "complete")
|
|
178
|
+
throw new Error("A completed delivery cannot be deferred");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (item.done && disposition === "defer")
|
|
182
|
+
return;
|
|
183
|
+
item.record = await store.transitionClaimed(item.record.acceptance_id, item.claim, disposition === "complete" ? "completed" : "accepted", undefined, disposition === "complete" ? "" : undefined, disposition === "defer" ? { deferred: true, clear_execution: true, execution_error: null } : { execution_id: executionId, deferred: false, execution_error: null });
|
|
184
|
+
item.done = true;
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
const first = claimed[0].record;
|
|
188
|
+
if (agent.recording) {
|
|
189
|
+
await recordWakeMoment(agent, agent.attention === undefined ? first.delivery_id : executionId, claimed.map(({ record }) => record), { ...this.options.recordingOptionsForTest, verifyStore: () => verifyHostRecordingStore(host, agent.id) });
|
|
190
|
+
}
|
|
191
|
+
result = await wakeFromDurableInbox(host, { token, agentId: agent.id, event: {
|
|
192
|
+
version: "noopolis.daimon.wake.v1", id: agent.attention === undefined ? first.delivery_id : executionId, kind: first.event.kind,
|
|
193
|
+
occurredAt: messages[0].occurred_at,
|
|
194
|
+
text: agent.attention === undefined ? first.event.text : inboxPrompt(messages, agent.engine.kind, agent.attention.maxBatchBytes)
|
|
195
|
+
} });
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
result = { version: "noopolis.daimon.wake-result.v1", status: "failed", agentId: agent.id, wakeId: executionId, code: "engine_failed", detail: engineFailureDetail(error) };
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
clearInterval(heartbeat);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
await mutation;
|
|
205
|
+
const executionError = result.status === "rejected" ? `wake rejected: ${result.code}`
|
|
206
|
+
: result.status === "failed" ? `engine_failed: ${result.detail ?? "engine execution failed"}` : null;
|
|
207
|
+
for (const item of claimed.filter((value) => !value.done)) {
|
|
208
|
+
// Returned to the inbox for restart, and recording WHY. Only a WAKE OUTCOME
|
|
209
|
+
// decides this: `stopped` — which an aborted in-flight wake also carries, with
|
|
210
|
+
// its own code — is the runtime reclaiming work nobody read. The dispatcher's
|
|
211
|
+
// own halt is not an outcome and must not stand in for one; it guards the
|
|
212
|
+
// pre-wake path, where it belongs. Keying on it here discarded a completed
|
|
213
|
+
// wake's evidence because the host happened to be halting, leaving a record
|
|
214
|
+
// byte-identical to "never ran". Production tolerated it because a restart
|
|
215
|
+
// re-delivers; a one-shot isolated trial has no restart and simply lost it.
|
|
216
|
+
if (result.status === "stopped") {
|
|
217
|
+
await store.transitionClaimed(item.record.acceptance_id, item.claim, "accepted", result.code);
|
|
218
|
+
}
|
|
219
|
+
else if (agent.attention !== undefined) {
|
|
220
|
+
// Successful reading is not completion: an undisposed delivery of a
|
|
221
|
+
// completed execution waits, deferred, for new input.
|
|
222
|
+
//
|
|
223
|
+
// A failed execution is retried ONCE, at once, under a fresh execution
|
|
224
|
+
// id. Keeping its id made every retry the same broker turn — a sealed
|
|
225
|
+
// failure replays forever and a changed prompt is a turn conflict — and
|
|
226
|
+
// deferring it left work a turn died on (a token ceiling after a
|
|
227
|
+
// validated revision) waiting for mail that might never come. The
|
|
228
|
+
// record's `execution_error` is the bound: it is set by the failure and
|
|
229
|
+
// cleared only by a disposition or a completed execution, so a delivery
|
|
230
|
+
// that fails again is deferred like any other.
|
|
231
|
+
const retry = result.status === "failed" && item.record.execution_error === undefined;
|
|
232
|
+
await store.transitionClaimed(item.record.acceptance_id, item.claim, "accepted", undefined, undefined, { deferred: !retry, clear_execution: result.status !== "rejected", execution_error: executionError });
|
|
233
|
+
if (retry)
|
|
234
|
+
console.error(`daimon: wake requeued once agent=${agent.id} delivery=${item.record.delivery_id} after ${sanitizeExecutionError(executionError ?? "engine_failed")}`);
|
|
235
|
+
}
|
|
236
|
+
else if (result.status === "completed")
|
|
237
|
+
await store.transitionClaimed(item.record.acceptance_id, item.claim, "completed", undefined, result.text);
|
|
238
|
+
else
|
|
239
|
+
await store.transitionClaimed(item.record.acceptance_id, item.claim, "failed", "engine_failed", result.status === "failed" ? result.detail : undefined);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
this.active.delete(agent.id);
|
|
244
|
+
registry.delete(agent.id);
|
|
245
|
+
await store.releaseClaim(claimed[0].claim);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
failClosed(agentId, error) {
|
|
249
|
+
this.errors.set(agentId, engineFailureDetail(error) ?? "execution_claim_lost");
|
|
250
|
+
this.fatal = "ledger_unavailable";
|
|
251
|
+
this.options.registry.clear();
|
|
252
|
+
this.active.clear();
|
|
253
|
+
this.halt();
|
|
254
|
+
// Losing a fence revokes runtime/tool authority before stopping cognition.
|
|
255
|
+
// This host has no per-agent abort lifecycle, so fail closed.
|
|
256
|
+
void this.options.host.stop().catch(() => undefined);
|
|
257
|
+
}
|
|
258
|
+
async waitUntil(timestamp) {
|
|
259
|
+
if (this.stopping || this.paused)
|
|
260
|
+
return;
|
|
261
|
+
await new Promise((resolve) => {
|
|
262
|
+
const finish = () => { clearTimeout(timer); this.waiters.delete(finish); resolve(); };
|
|
263
|
+
const timer = setTimeout(finish, Math.max(1, Date.parse(timestamp) - Date.now()));
|
|
264
|
+
this.waiters.add(finish);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A delivery past `STALE_QUEUED_DELIVERY_MS` is stopped `queued_wake_stopped`
|
|
270
|
+
* where the dispatcher meets it, and the stop is logged: an expiry nobody can
|
|
271
|
+
* see reads, in every artifact, like work that was never sent. Stopping goes
|
|
272
|
+
* through the store's accepted-only seam, so a delivery claimed in the meantime
|
|
273
|
+
* is left alone; a failure to stop is logged and retried on the next drain.
|
|
274
|
+
*/
|
|
275
|
+
async function expireStaleDelivery(store, record) {
|
|
276
|
+
try {
|
|
277
|
+
const stopped = await store.transitionAcceptedToStopped(record.acceptance_id, "queued_wake_stopped");
|
|
278
|
+
if (stopped.state === "stopped")
|
|
279
|
+
console.error(`daimon: wake expired agent=${record.agent_id} delivery=${record.delivery_id} accepted_at=${record.accepted_at} unhandled past ${STALE_QUEUED_DELIVERY_MS / 3_600_000}h; stopped queued_wake_stopped${record.execution_error === undefined ? "" : ` (last failure: ${record.execution_error})`}`);
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
console.error(`daimon: wake expiry failed agent=${record.agent_id} delivery=${record.delivery_id}: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
export function selectBatch(records, agent, revisitDeferred) {
|
|
286
|
+
const eligible = records.filter((record) => !record.deferred || revisitDeferred);
|
|
287
|
+
const first = eligible[0];
|
|
288
|
+
if (!first)
|
|
289
|
+
return [];
|
|
290
|
+
// A durable execution identity survives a crash and partially completed batch.
|
|
291
|
+
if (first.execution_id !== undefined)
|
|
292
|
+
return records.filter((record) => record.execution_id === first.execution_id);
|
|
293
|
+
if (agent.attention === undefined || first.event.kind !== "message")
|
|
294
|
+
return [first];
|
|
295
|
+
const selected = [];
|
|
296
|
+
const count = agent.attention.maxBatchMessages ?? 8;
|
|
297
|
+
const bytes = agent.attention.maxBatchBytes ?? 12000;
|
|
298
|
+
for (const record of eligible) {
|
|
299
|
+
if (record.event.kind !== "message" || record.execution_id !== undefined || selected.length >= count)
|
|
300
|
+
break;
|
|
301
|
+
const next = [...selected, record];
|
|
302
|
+
if (Buffer.byteLength(JSON.stringify(next.map((value) => ({ acceptance_id: value.acceptance_id, delivery_id: value.delivery_id, ...value.event })))) > bytes)
|
|
303
|
+
break;
|
|
304
|
+
selected.push(record);
|
|
305
|
+
}
|
|
306
|
+
// Oversized individual payloads remain intact in daimon_inbox, not a silently
|
|
307
|
+
// truncated synthetic wake. The prompt references its durable delivery id.
|
|
308
|
+
return selected.length ? selected : [first];
|
|
309
|
+
}
|
|
310
|
+
/** One claimed delivery, rendered as the task it is. */
|
|
311
|
+
function deliveryBlock(message, index) {
|
|
312
|
+
if (message === null || typeof message !== "object")
|
|
313
|
+
return undefined;
|
|
314
|
+
const row = message;
|
|
315
|
+
const text = typeof row.text === "string" ? row.text : undefined;
|
|
316
|
+
if (text === undefined)
|
|
317
|
+
return undefined;
|
|
318
|
+
const from = typeof row.from === "string" ? row.from : undefined;
|
|
319
|
+
const kind = typeof row.kind === "string" ? row.kind : "delivery";
|
|
320
|
+
const id = typeof row.delivery_id === "string" ? row.delivery_id : `#${index + 1}`;
|
|
321
|
+
return [`<delivery id="${id}" kind="${kind}"${from === undefined ? "" : ` from="${from}"`}>`, text, "</delivery>"].join("\n");
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The inbox turn, task first.
|
|
325
|
+
*
|
|
326
|
+
* A delivery's own text *is* the work. Leading with bookkeeping and handing the
|
|
327
|
+
* model `JSON.stringify(messages)` buried the task: an agent read the JSON, did
|
|
328
|
+
* the accounting and deferred without doing the job (observed on Grok: nine
|
|
329
|
+
* model requests, no tool calls, nothing filed). The deliveries are therefore
|
|
330
|
+
* rendered as labelled blocks and the `daimon_inbox` accounting follows them as
|
|
331
|
+
* what to do *after* the work, with the machine-readable payload kept as a
|
|
332
|
+
* trailing appendix while it fits the same budget.
|
|
333
|
+
*
|
|
334
|
+
* Both tools are named the way the agent's own engine can call them. On Grok a
|
|
335
|
+
* Daimon tool is an MCP tool of server `daimon` and its bare name reaches
|
|
336
|
+
* nothing (`grokDaimonToolName`, the same contract module the worker's system
|
|
337
|
+
* prompt and identity envelope render from), so an agent handed the bare name
|
|
338
|
+
* cannot mark its work complete — and an unmarked, finished wake is recorded as
|
|
339
|
+
* deferred.
|
|
340
|
+
*/
|
|
341
|
+
export function inboxPrompt(messages, engine, maxBytes = 12000) {
|
|
342
|
+
const body = JSON.stringify(messages);
|
|
343
|
+
const blocks = messages.map(deliveryBlock).filter((block) => block !== undefined);
|
|
344
|
+
const tool = (name) => engine === "grok" ? grokDaimonToolName(name) : name;
|
|
345
|
+
const accounting = `\nWhen the work above is done, record each delivery with ${tool("daimon_inbox_disposition")} (complete), or defer the ones you could not finish; use ${tool("daimon_inbox")} for deliveries and remaining allowances. Reading or ending this turn never completes a delivery, and deferred work waits for a later external wake.\n`;
|
|
346
|
+
const header = blocks.length === 1 ? "Carry out this delivery.\n" : `Carry out these ${blocks.length} deliveries.\n`;
|
|
347
|
+
const fits = (value) => Buffer.byteLength(value) <= ORGANIZATION_RUNTIME_MAX_WAKE_TEXT_BYTES
|
|
348
|
+
&& [...value].length <= ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS;
|
|
349
|
+
if (blocks.length > 0 && Buffer.byteLength(blocks.join("\n\n")) <= maxBytes) {
|
|
350
|
+
const task = header + blocks.join("\n\n") + accounting;
|
|
351
|
+
const withPayload = `${task}\nMachine-readable payload: ${body}`;
|
|
352
|
+
// The inbox budget bounds selection; the v1 execution boundary independently
|
|
353
|
+
// bounds the complete prompt, including metadata, escaping, and instructions.
|
|
354
|
+
if (Buffer.byteLength(body) <= maxBytes && fits(withPayload))
|
|
355
|
+
return withPayload;
|
|
356
|
+
if (fits(task))
|
|
357
|
+
return task;
|
|
358
|
+
}
|
|
359
|
+
const prefix = `Handle this inbox turn. Use ${tool("daimon_inbox")} for deliveries and remaining allowances. Explicitly call ${tool("daimon_inbox_disposition")} for each handled delivery (complete) or unfinished delivery (defer). Reading or ending this turn never completes a delivery. Deferred work waits for a later external wake.\n`;
|
|
360
|
+
const prompt = prefix + body;
|
|
361
|
+
if (Buffer.byteLength(body) > maxBytes || !fits(prompt)) {
|
|
362
|
+
return prefix + `The selected payload exceeds the prompt budget; read it with ${tool("daimon_inbox")}.`;
|
|
363
|
+
}
|
|
364
|
+
return prompt;
|
|
365
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare function runOrganizationRuntimeCli(arguments_: readonly string[], environment?: NodeJS.ProcessEnv): Promise<void>;
|
|
3
|
+
export declare function parseOrganizationRuntimeCliArguments(arguments_: readonly string[]): Readonly<{
|
|
4
|
+
configPath: string;
|
|
5
|
+
kind: "agy-login" | "run";
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/runtime/cli.ts"],"names":[],"mappings":";AAkBA,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,oBAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDvH;AASD,wBAAgB,oCAAoC,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,CAAC;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,GAAG,KAAK,CAAC;CAC3B,CAAC,CASD"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, open, readFile, realpath, rename, stat } from "node:fs/promises";
|
|
3
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
4
|
+
import { createServer } from "node:http";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { createOrganizationRuntimeHost } from "./organizationRuntimeHost.js";
|
|
8
|
+
import { createOrganizationRuntimeControlHost } from "./organizationRuntimeControl.js";
|
|
9
|
+
import { runAgySubscriptionBootstrap } from "./agySubscriptionBootstrap.js";
|
|
10
|
+
import { parseOrganizationRuntimeConfig, parseOrganizationRuntimeWakeRequest } from "./organizationRuntime.js";
|
|
11
|
+
import { runEngineBrokerServiceCli } from "./engineBrokerServiceCli.js";
|
|
12
|
+
const MAX_BODY_BYTES = 1_048_576;
|
|
13
|
+
const MAX_CONFIG_BYTES = 1_048_576;
|
|
14
|
+
const ACCEPTANCE_STORE_ENV = "DAIMON_RUNTIME_ACCEPTANCE_STORE";
|
|
15
|
+
const READINESS_RECEIPT_ENV = "DAIMON_RUNTIME_READINESS_RECEIPT";
|
|
16
|
+
export async function runOrganizationRuntimeCli(arguments_, environment = process.env) {
|
|
17
|
+
if (arguments_.length === 2 && arguments_[0] === "engine-broker" && arguments_[1] === "serve") {
|
|
18
|
+
await runEngineBrokerServiceCli();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const command = parseArguments(arguments_);
|
|
22
|
+
const config = parseOrganizationRuntimeConfig(JSON.parse(await readBoundedFile(command.configPath)));
|
|
23
|
+
if (command.kind === "agy-login") {
|
|
24
|
+
await runAgySubscriptionBootstrap(config);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const storePath = environment[ACCEPTANCE_STORE_ENV];
|
|
28
|
+
const control = storePath === undefined || !storePath.trim()
|
|
29
|
+
? undefined
|
|
30
|
+
: createOrganizationRuntimeControlHost(config, { acceptanceStorePath: storePath, controlToken: environment[config.host.controlTokenEnv] });
|
|
31
|
+
const host = control ?? createOrganizationRuntimeHost(config);
|
|
32
|
+
await host.start();
|
|
33
|
+
const server = createServer((request, response) => {
|
|
34
|
+
void handleRequest(request, response, host, control, environment[config.host.controlTokenEnv]);
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
if (environment[READINESS_RECEIPT_ENV])
|
|
38
|
+
await writeReadinessReceipt(environment[READINESS_RECEIPT_ENV], config);
|
|
39
|
+
await listen(server, config.host.bindHost, config.host.port);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
await host.stop();
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
const sockets = new Set();
|
|
46
|
+
server.on("connection", (socket) => { sockets.add(socket); socket.once("close", () => sockets.delete(socket)); });
|
|
47
|
+
// Signals can arrive together (Docker stop commonly sends TERM then KILL).
|
|
48
|
+
// Every path shares one shutdown outcome and only the first initiates it.
|
|
49
|
+
let shutdown;
|
|
50
|
+
let serverClosed = false;
|
|
51
|
+
const stop = () => {
|
|
52
|
+
if (shutdown !== undefined)
|
|
53
|
+
return shutdown;
|
|
54
|
+
const attempt = (async () => {
|
|
55
|
+
if (!serverClosed) {
|
|
56
|
+
await closeServer(server, sockets);
|
|
57
|
+
serverClosed = true;
|
|
58
|
+
}
|
|
59
|
+
await host.stop();
|
|
60
|
+
process.removeListener("SIGINT", onSignal);
|
|
61
|
+
process.removeListener("SIGTERM", onSignal);
|
|
62
|
+
})();
|
|
63
|
+
shutdown = attempt;
|
|
64
|
+
void attempt.catch(() => { if (shutdown === attempt)
|
|
65
|
+
shutdown = undefined; });
|
|
66
|
+
return attempt;
|
|
67
|
+
};
|
|
68
|
+
const onSignal = () => { void stop().catch((error) => { process.stderr.write(`${error instanceof Error ? error.message : "runtime shutdown failed"}\n`); process.exitCode = 1; }); };
|
|
69
|
+
process.once("SIGINT", onSignal);
|
|
70
|
+
process.once("SIGTERM", onSignal);
|
|
71
|
+
}
|
|
72
|
+
async function writeReadinessReceipt(file, config) {
|
|
73
|
+
const value = `${JSON.stringify({ version: "noopolis.daimon.readiness-receipt.v1", agents: config.agents.map((agent) => ({ agent_id: agent.id, engine: agent.engine.kind })).sort((left, right) => left.agent_id.localeCompare(right.agent_id)) })}\n`;
|
|
74
|
+
await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
75
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
76
|
+
const handle = await open(temporary, "wx", 0o600);
|
|
77
|
+
try {
|
|
78
|
+
await handle.writeFile(value);
|
|
79
|
+
await handle.sync();
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
await handle.close();
|
|
83
|
+
}
|
|
84
|
+
await rename(temporary, file);
|
|
85
|
+
const directory = await open(path.dirname(file), "r");
|
|
86
|
+
try {
|
|
87
|
+
await directory.sync();
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await directory.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function parseOrganizationRuntimeCliArguments(arguments_) {
|
|
94
|
+
if (arguments_.length === 3 && arguments_[0] === "run" && arguments_[1] === "--config" && arguments_[2]) {
|
|
95
|
+
return { configPath: arguments_[2], kind: "run" };
|
|
96
|
+
}
|
|
97
|
+
if (arguments_.length === 5 && arguments_[0] === "auth" && arguments_[1] === "agy" && arguments_[2] === "login"
|
|
98
|
+
&& arguments_[3] === "--config" && arguments_[4]) {
|
|
99
|
+
return { configPath: arguments_[4], kind: "agy-login" };
|
|
100
|
+
}
|
|
101
|
+
throw new Error("usage: daimon-runtime run --config <path> | daimon-runtime auth agy login --config <path>");
|
|
102
|
+
}
|
|
103
|
+
const parseArguments = parseOrganizationRuntimeCliArguments;
|
|
104
|
+
async function handleRequest(request, response, host, control, expectedToken) {
|
|
105
|
+
try {
|
|
106
|
+
const url = new URL(request.url ?? "/", "http://runtime.invalid");
|
|
107
|
+
if (request.method === "GET" && url.pathname === "/healthz" && url.search === "") {
|
|
108
|
+
return respond(response, 200, { status: "ok" });
|
|
109
|
+
}
|
|
110
|
+
if (!authorized(request, expectedToken))
|
|
111
|
+
return respond(response, 401, { error: "unauthorized" });
|
|
112
|
+
if (request.method === "POST" && url.pathname === "/v1/wake") {
|
|
113
|
+
if (request.headers["content-type"] !== "application/json")
|
|
114
|
+
throw new TypeError("content-type must be application/json");
|
|
115
|
+
const result = await host.wake(parseOrganizationRuntimeWakeRequest({ ...bodyRecord(await readJson(request)), token: expectedToken }));
|
|
116
|
+
return respond(response, result.status === "completed" ? 200 : result.status === "failed" ? 502 : 409, result);
|
|
117
|
+
}
|
|
118
|
+
if (request.method === "GET" && url.pathname === "/v1/health") {
|
|
119
|
+
return respond(response, 200, await host.health(parseHealthQuery(url)));
|
|
120
|
+
}
|
|
121
|
+
if (request.method === "GET" && url.pathname === "/v1/activity") {
|
|
122
|
+
return respond(response, 200, await host.activity(parseActivityQuery(url)));
|
|
123
|
+
}
|
|
124
|
+
if (control !== undefined && request.method === "POST" && url.pathname === "/v2/wakes") {
|
|
125
|
+
if (request.headers["content-type"] !== "application/json")
|
|
126
|
+
throw new TypeError("content-type must be application/json");
|
|
127
|
+
const result = await control.accept({ ...bodyRecord(await readJson(request)), token: expectedToken });
|
|
128
|
+
const status = result.state === "accepted" ? 202 : result.state === "stopped" ? 409 : result.code === "invalid_request" ? 400 : result.code === "unauthorized" ? 401 : 409;
|
|
129
|
+
return respond(response, status, result);
|
|
130
|
+
}
|
|
131
|
+
if (control !== undefined && request.method === "GET" && /^\/v2\/wake-receipts\/[0-9a-f-]+$/iu.test(url.pathname)) {
|
|
132
|
+
assertQuery(url, []);
|
|
133
|
+
const acceptanceId = url.pathname.slice("/v2/wake-receipts/".length);
|
|
134
|
+
const receipt = await control.wakeReceipt(expectedToken, acceptanceId);
|
|
135
|
+
return receipt === undefined ? respond(response, 404, { error: "not_found" }) : respond(response, 200, receipt);
|
|
136
|
+
}
|
|
137
|
+
if (control !== undefined && request.method === "GET" && url.pathname === "/v2/availability") {
|
|
138
|
+
assertQuery(url, []);
|
|
139
|
+
const availability = await control.availability(expectedToken);
|
|
140
|
+
return availability === undefined ? respond(response, 404, { error: "not_found" }) : respond(response, 200, availability);
|
|
141
|
+
}
|
|
142
|
+
if (control !== undefined && request.method === "POST" && (url.pathname === "/v2/drain" || url.pathname === "/v2/resume")) {
|
|
143
|
+
assertQuery(url, []);
|
|
144
|
+
const availability = url.pathname === "/v2/drain" ? await control.drain(expectedToken) : await control.resume(expectedToken);
|
|
145
|
+
return availability === undefined ? respond(response, 404, { error: "not_found" }) : respond(response, 200, availability);
|
|
146
|
+
}
|
|
147
|
+
if (control !== undefined && request.method === "GET" && url.pathname === "/v2/activity") {
|
|
148
|
+
assertQuery(url, []);
|
|
149
|
+
const activity = await control.activityV2(expectedToken);
|
|
150
|
+
return activity === undefined ? respond(response, 404, { error: "not_found" }) : respond(response, 200, activity);
|
|
151
|
+
}
|
|
152
|
+
return respond(response, 404, { error: "not_found" });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
return respond(response, 400, { error: error instanceof Error ? error.message : "invalid_request" });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function authorized(request, token) {
|
|
159
|
+
if (token === undefined || !token.trim())
|
|
160
|
+
return false;
|
|
161
|
+
const actual = request.headers.authorization;
|
|
162
|
+
if (actual === undefined)
|
|
163
|
+
return false;
|
|
164
|
+
const digest = (value) => createHash("sha256").update(value).digest();
|
|
165
|
+
return timingSafeEqual(digest(`Bearer ${token}`), digest(actual));
|
|
166
|
+
}
|
|
167
|
+
async function readJson(request) {
|
|
168
|
+
const chunks = [];
|
|
169
|
+
let size = 0;
|
|
170
|
+
for await (const chunk of request) {
|
|
171
|
+
const value = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
172
|
+
size += value.length;
|
|
173
|
+
if (size > MAX_BODY_BYTES)
|
|
174
|
+
throw new TypeError("request body is too large");
|
|
175
|
+
chunks.push(value);
|
|
176
|
+
}
|
|
177
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
178
|
+
}
|
|
179
|
+
function bodyRecord(value) {
|
|
180
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
181
|
+
throw new TypeError("request body must be an object");
|
|
182
|
+
const prototype = Object.getPrototypeOf(value);
|
|
183
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
184
|
+
throw new TypeError("request body must be a plain own-properties object");
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
function parseHealthQuery(url) {
|
|
188
|
+
assertQuery(url, ["agentId"]);
|
|
189
|
+
return url.searchParams.has("agentId") ? nonBlank(url.searchParams.get("agentId"), "agentId") : undefined;
|
|
190
|
+
}
|
|
191
|
+
function parseActivityQuery(url) {
|
|
192
|
+
assertQuery(url, ["agentId", "cursor", "limit"]);
|
|
193
|
+
const rawLimit = url.searchParams.get("limit");
|
|
194
|
+
const limit = rawLimit === null ? 50 : Number(rawLimit);
|
|
195
|
+
if (!Number.isInteger(limit))
|
|
196
|
+
throw new TypeError("limit must be an integer");
|
|
197
|
+
return {
|
|
198
|
+
...(url.searchParams.has("agentId") ? { agentId: nonBlank(url.searchParams.get("agentId"), "agentId") } : {}),
|
|
199
|
+
...(url.searchParams.has("cursor") ? { cursor: nonBlank(url.searchParams.get("cursor"), "cursor") } : {}),
|
|
200
|
+
limit
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function assertQuery(url, allowed) {
|
|
204
|
+
const seen = new Set();
|
|
205
|
+
for (const [key] of url.searchParams) {
|
|
206
|
+
if (!allowed.includes(key) || seen.has(key))
|
|
207
|
+
throw new TypeError("query contains an unsupported or duplicate parameter");
|
|
208
|
+
seen.add(key);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function nonBlank(value, label) {
|
|
212
|
+
if (typeof value !== "string")
|
|
213
|
+
throw new TypeError(`${label} must be a string`);
|
|
214
|
+
const result = value;
|
|
215
|
+
if (!result.trim())
|
|
216
|
+
throw new TypeError(`${label} must not be blank`);
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
async function readBoundedFile(filePath) {
|
|
220
|
+
if ((await stat(filePath)).size > MAX_CONFIG_BYTES)
|
|
221
|
+
throw new TypeError("runtime config is too large");
|
|
222
|
+
const bytes = await readFile(filePath);
|
|
223
|
+
if (bytes.length > MAX_CONFIG_BYTES)
|
|
224
|
+
throw new TypeError("runtime config is too large");
|
|
225
|
+
return bytes.toString("utf8");
|
|
226
|
+
}
|
|
227
|
+
function respond(response, status, value) {
|
|
228
|
+
response.writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
|
229
|
+
response.end(`${JSON.stringify(value)}\n`);
|
|
230
|
+
}
|
|
231
|
+
function listen(server, host, port) {
|
|
232
|
+
return new Promise((resolve, reject) => {
|
|
233
|
+
server.once("error", reject);
|
|
234
|
+
server.listen(port, host, () => resolve());
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
async function closeServer(server, sockets) {
|
|
238
|
+
const closed = new Promise((resolve, reject) => server.close((error) => error === undefined ? resolve() : reject(error)));
|
|
239
|
+
const timeout = setTimeout(() => { for (const socket of sockets)
|
|
240
|
+
socket.destroy(); }, 10_000);
|
|
241
|
+
try {
|
|
242
|
+
await closed;
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
clearTimeout(timeout);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const invokedPath = process.argv[1] === undefined
|
|
249
|
+
? undefined
|
|
250
|
+
: await realpath(process.argv[1]).catch(() => process.argv[1]);
|
|
251
|
+
if (invokedPath !== undefined && import.meta.url === pathToFileURL(invokedPath).href) {
|
|
252
|
+
void runOrganizationRuntimeCli(process.argv.slice(2)).catch((error) => {
|
|
253
|
+
process.stderr.write(`${error instanceof Error ? error.message : "daimon-runtime failed"}\n`);
|
|
254
|
+
process.exitCode = 1;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const CODEX_SANDBOX_PROJECTION_VERSION = "noopolis.daimon.codex-sandbox-projection.v1";
|
|
2
|
+
export type OrganizationCodexSandboxProjection = Readonly<{
|
|
3
|
+
version: typeof CODEX_SANDBOX_PROJECTION_VERSION;
|
|
4
|
+
agentId: string;
|
|
5
|
+
workspacePath: string;
|
|
6
|
+
runtimeHomePath: string;
|
|
7
|
+
engineHomePath: string;
|
|
8
|
+
executablePath: string;
|
|
9
|
+
profileName: string;
|
|
10
|
+
permissionConfig: string;
|
|
11
|
+
sandboxArgs: readonly string[];
|
|
12
|
+
}>;
|
|
13
|
+
/** Resolves the production command policy without importing auth or accepting a wake. */
|
|
14
|
+
export declare function resolveOrganizationCodexSandboxProjection(config: unknown, agentId: string, options: Readonly<{
|
|
15
|
+
acceptanceStorePath: string;
|
|
16
|
+
}>): Promise<OrganizationCodexSandboxProjection>;
|
|
17
|
+
//# sourceMappingURL=codexSandboxProjection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codexSandboxProjection.d.ts","sourceRoot":"","sources":["../../src/runtime/codexSandboxProjection.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gCAAgC,gDAAgD,CAAC;AAC9F,MAAM,MAAM,kCAAkC,GAAG,QAAQ,CAAC;IACxD,OAAO,EAAE,OAAO,gCAAgC,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC,CAAC,CAAC;AAEH,yFAAyF;AACzF,wBAAsB,yCAAyC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC9F,OAAO,EAAE,QAAQ,CAAC;IAAE,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,kCAAkC,CAAC,CA2BjG"}
|