@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,40 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { renderCodexArgs } from "../pi/cliEngineSpawn.js";
|
|
3
|
+
import { codexSandboxProtectedPaths, codexSandboxReadablePaths } from "./engineDispatcher.js";
|
|
4
|
+
import { engineHomeName, prepareEngineExecutable } from "./engineReadiness.js";
|
|
5
|
+
import { parseOrganizationRuntimeConfig } from "./organizationRuntime.js";
|
|
6
|
+
import { prepareOrganizationRuntimePaths } from "./physicalReadiness.js";
|
|
7
|
+
export const CODEX_SANDBOX_PROJECTION_VERSION = "noopolis.daimon.codex-sandbox-projection.v1";
|
|
8
|
+
/** Resolves the production command policy without importing auth or accepting a wake. */
|
|
9
|
+
export async function resolveOrganizationCodexSandboxProjection(config, agentId, options) {
|
|
10
|
+
const parsed = parseOrganizationRuntimeConfig(config);
|
|
11
|
+
const selected = parsed.agents.find(agent => agent.id === agentId);
|
|
12
|
+
if (!selected || selected.engine.kind !== "codex" || selected.engine.codexSandbox === undefined) {
|
|
13
|
+
throw new Error("Sandbox projection requires a known strict Codex agent");
|
|
14
|
+
}
|
|
15
|
+
if (!path.isAbsolute(options.acceptanceStorePath))
|
|
16
|
+
throw new Error("Sandbox projection requires an absolute acceptance store path");
|
|
17
|
+
const authority = await prepareOrganizationRuntimePaths(parsed.agents);
|
|
18
|
+
try {
|
|
19
|
+
const paths = authority.forAgent(selected);
|
|
20
|
+
await paths.verify();
|
|
21
|
+
const agent = { ...selected, workspacePath: paths.workspacePath, runtimeHomePath: paths.runtimeHomePath };
|
|
22
|
+
const engineHomePath = path.join(agent.runtimeHomePath, engineHomeName("codex"));
|
|
23
|
+
const executable = await prepareEngineExecutable(agent.id, "codex");
|
|
24
|
+
// These are the same collectors, canonical roots and renderer used by
|
|
25
|
+
// startOrganizationRuntimeEngine and its strict production invocation.
|
|
26
|
+
const args = renderCodexArgs({ codexSandbox: agent.engine.codexSandbox,
|
|
27
|
+
codexSandboxProtectedPaths: codexSandboxProtectedPaths(agent.id, agent, engineHomePath, parsed.agents, [options.acceptanceStorePath]),
|
|
28
|
+
codexSandboxReadablePaths: codexSandboxReadablePaths(agent) }, agent.workspacePath, undefined);
|
|
29
|
+
const permissionConfig = args.find(arg => arg.startsWith("permissions="));
|
|
30
|
+
const profileName = JSON.parse(args.find(arg => arg.startsWith("default_permissions=")).slice("default_permissions=".length));
|
|
31
|
+
await paths.verify();
|
|
32
|
+
await executable.verify();
|
|
33
|
+
return { version: CODEX_SANDBOX_PROJECTION_VERSION, agentId, workspacePath: agent.workspacePath,
|
|
34
|
+
runtimeHomePath: agent.runtimeHomePath, engineHomePath, executablePath: executable.executablePath, profileName, permissionConfig,
|
|
35
|
+
sandboxArgs: ["sandbox", "-P", profileName, "-C", agent.workspacePath, "-c", permissionConfig] };
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await authority.close();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"activityResponseSchema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"id":{"format":"uuid","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","type":"string"},"kind":{"enum":["wake_started","wake_completed","wake_rejected","wake_aborted","agent_stopped"]},"occurredAt":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["id","agentId","kind","occurredAt"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"maxLength":16,"minLength":1,"pattern":"^(0|[1-9][0-9]{0,15})$","type":"string"},"version":{"const":"noopolis.daimon.organization-runtime-activity.v1"}},"required":["version","items"],"type":"object"},"activityV2ResponseSchema":{"additionalProperties":false,"properties":{"executions":{"items":{"additionalProperties":false,"properties":{"agent_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"delivery_ids":{"items":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"maxItems":32,"type":"array"},"execution_id":{"type":"string"},"state":{"const":"running"}},"required":["agent_id","execution_id","state","delivery_ids"],"type":"object"},"maxItems":32,"type":"array"},"items":{"items":{"additionalProperties":false,"properties":{"acceptance_id":{"type":"string"},"accepted_at":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"active":{"type":"boolean"},"agent_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["engine_failed","host_stopped","host_stopping","queued_wake_stopped","active_wake_aborted","queue_full","unknown_agent"]},"deferred":{"type":"boolean"},"delivery_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"execution_id":{"type":"string"},"queue_position":{"minimum":1,"type":"integer"},"request_digest":{"type":"string"},"state":{"enum":["accepted","running","completed","failed","stopped"]},"text":{"maxLength":16384,"type":"string"},"updated_at":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"version":{"const":"noopolis.daimon.wake-receipt-status.v2"}},"required":["version","acceptance_id","agent_id","delivery_id","request_digest","state","accepted_at","updated_at","active"],"type":"object"},"maxItems":2112,"type":"array"},"state":{"enum":["running","stopped"]},"version":{"const":"noopolis.daimon.organization-runtime-activity.v2"}},"required":["version","items"],"type":"object"},"agySubscriptionRealm":{"directoryMode":448,"durableMountPath":"/var/lib/spawnfile/daimon/agy-subscription-realm","fileMode":384,"maxUnlockBytes":4096,"unlockMountPath":"/var/lib/spawnfile/daimon/agy-unlock-secret","unlockSourceSlot":"agy-unlock-secret"},"attention":{"accounting":"execution-start-reservations","busyDispatch":"bounded-pending-message-batch","completion":"explicit-per-delivery","defaultMaxBatchBytes":12000,"defaultMaxBatchMessages":8,"enabledBy":"agents[].attention","idleDispatch":"immediate","unhandled":"deferred-until-new-input"},"consumedConfigFields":["version","host.bindHost","host.port","host.controlTokenEnv","agents[].id","agents[].name","agents[].instructions","agents[].workspacePath","agents[].runtimeHomePath","agents[].engine.kind","agents[].engine.model","agents[].engine.reasoningEffort","agents[].engine.codexSandbox","agents[].schedule.kind","agents[].schedule.interval_ms","agents[].schedule.cron","agents[].schedule.timezone","agents[].schedule.prompt","agents[].schedule.jitter_seconds","agents[].mcp","agents[].moltnet","agents[].memory","agents[].attention","agents[].recording"],"deliverySemantics":{"activeDeliveryIdempotency":"unbounded-until-terminal","concurrentSameAgentTurns":false,"externalEffectsExactlyOnce":false,"recovery":"at-least-once-with-stable-wake-id","terminalReceiptHorizon":2048},"engineCredentialMaterial":{"codex":{"destinationRelativePath":".codex/auth.json","directoryMode":448,"fileMode":384,"sourceRelativePath":".daimon-inbound/codex-auth","sourceSlot":"codex-auth"}},"grokEngineBroker":{"artifacts":{"arm64Sha256":"d0dc1c03197c3e90f09b66ad7c89b4f7b448d06dc84c03b247dce976d6018d6e","sourceSha256":"15836d7ad69f12ef581a6e5b8635c9db43b2177dac609160c0749d3d1fefbaa8","x64Sha256":"95aa9c272225e74ff9f45f54dde4bc30aee324e9ba24d8a876db9151c81b454d"},"backendSocketPath":"/run/daimon-engine-broker/backend.sock","bounds":{"capabilityBundleBytes":8196,"capabilityBytes":4096,"outputBytes":262144,"promptBytes":65536},"controlProtocolVersion":"noopolis.daimon.engine-broker.v4","controlSocketPath":"/run/daimon-engine-broker/control.sock","credentialHomePath":"/var/lib/spawnfile/daimon/grok-subscription-realm","grokCliArtifacts":{"arm64":{"bytes":136090504,"sha256":"39ab87666877d64ef3a40aa60fbe0c3b6a6acd7001b78fe60e2c76bb6cfc4a94","url":"https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-aarch64"},"x64":{"bytes":163035648,"sha256":"be5905e107d2b8b5f3c142d21ecfe4c8fd32a913d2fd551b788707930c4dc80d","url":"https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-x86_64"}},"grokCliBuild":"3736acbc8658","grokCliVersion":"1.0.34","grokExecutablePath":"/usr/local/bin/grok","identities":{"brokerUid":2100,"firstWorkerUid":2200,"organizationUid":2000},"inferenceGrants":{"bodyMembers":["messages","model","reasoning_effort","response_format","stream","stream_options"],"client":{"configSha256":{"grok-4.5":{"high":"ffbc33728b821e9854fbc7c93601e599225da421ecfd6ebf10d314afcc28d6f2","low":"a07f7436f1268bb399ec233c65d3b3d8fb99a11a1f175f8da1ca133c9367bc74","medium":"1f4c0d4dad1f3b09419b5739db6423a09e0049abc091594c64123a75dd53dfb9"},"grok-4.6":{"high":"5652656effa82f0c4f09cf8226b16e6140332a5a358b571194bb5563312367ac","low":"79314d039f787e4ebfec7dacf57adc969086b948f564dec008f0ed6367e6062f","medium":"6f538de0547c0c4e6a3f04ae08595ceadadabb06b75f6b6ee4c428744bb95cd8"},"grok-build":{"high":"98d16f2b7d12f4eb540d625c853e51d227933e204923e43e8b9b4176f10aca2c","low":"ca15c6a562a008227d39c51d3a3a83715663089b3784e8b46debb1fb67b3c4a1","medium":"01783fb6beadcf6f8486fff0836820ad43fab5662b812a907fe9cfdb83e9804d"}},"envKey":"DAIMON_INFERENCE_GRANT","modelId":"daimon-inference-grok"},"failureCodes":["auth_stale","grant_limit","invalid_request","unavailable"],"ledgerDedupeKey":["grant","request"],"ledgerVersion":"noopolis.daimon.inference-usage.v1","limits":{"maxRequests":64,"maxTokens":2000000},"maxInFlightRequestsPerGrant":1,"maxLiveGrants":8,"messageRoles":["system","user","assistant"],"purposes":["judge","optimizer"],"requestKinds":["request_inference_grant","release_inference_grant"],"tokenPrefix":"inference_","ttlMs":600000},"launcherSocketPath":"/run/daimon-engine-broker/launcher.sock","mcpFacade":{"host":"127.0.0.1","path":"/mcp","port":43124},"nativeAbiVersion":2,"nativeExecutablePath":"/opt/daimon/bin/daimon-engine-broker","projectionVersion":"noopolis.daimon.grok-broker-projection.v3","providerProxy":{"host":"127.0.0.1","port":43123},"registrationPath":"/etc/daimon-engine-broker/registrations.bin","runRequestBudget":{"countsCredentialRetries":true,"fileName":"run-requests.json","includesInferenceGrants":true,"maximumField":"maxRunRequests","storeField":"runRequestStore"},"serviceConfigPath":"/etc/daimon-engine-broker/service.json","serviceConfigVersions":["noopolis.daimon.engine-broker-service.v1","noopolis.daimon.engine-broker-service.v2","noopolis.daimon.engine-broker-service.v3"],"slotPreflightVersion":"noopolis.daimon.grok-slot-preflight.v2","slotRouting":{"controlCaller":"organization","key":"slot","repeatedAgentIds":true,"resetRequest":"reset_slot","resetResponse":"slot_reset","slotEnvironment":"DAIMON_ENGINE_BROKER_SLOT","turnStoreDirectory":"slot-{slot}","workersMayControl":false},"turnLimits":{"bounds":{"maxRequests":[1,48],"maxTokens":[1,10000000],"timeoutMs":[1000,3600000]},"keys":["maxRequests","maxTokens","timeoutMs"],"limitReasons":["tokens","requests","timeout","none"],"maxInFlightRequests":1,"missingUsageEstimate":{"inputBytesPerToken":2,"outputTokens":4096},"requestUsageMaxTokens":500000,"tokenCeilingOvershoot":"at-most-one-request","v1Defaults":{"maxRequests":32,"maxTokens":300000,"timeoutMs":240000},"wakeMayOnlyLower":true},"turnRecordVersions":["noopolis.daimon.engine-broker-turn.v1","noopolis.daimon.engine-broker-turn.v2"],"turnStorePath":"/var/lib/spawnfile/daimon/grok-subscription-realm/turns","wakeLimitEnvironment":{"maxTokens":"DAIMON_ENGINE_WAKE_TOKEN_CEILING","timeoutMs":"DAIMON_ENGINE_WAKE_TIMEOUT_MS"},"worker":{"clockedConfigSha256":{"grok-4.5":{"high":"907d8967960c342b442d6d256b2585f3c85bd846a78578f596f0b605403d6d34","low":"3c4f3515b21c1bffb3fb770e2ecb4b918b6c43d5e77c1fd47e1e6698d1fedee7","medium":"9117e12b2f3f6fa045799592969cbaae1c2f3b1ea79330badac8655b9b41dd7a"},"grok-4.6":{"high":"203744f6f0dfc0bc80cfb896880497edfd9b3de4dcf33060e8ef4d2ef5f220a7","low":"751f1dcd04983e5e5883df5a8fefa04f201e187e5ef1f344d3bf83f950830432","medium":"f1406f93a8091eb0c09e07321254a9c783a89b0bbf5548d9613d53a8d087a517"},"grok-build":{"high":"6efddadc82c38020d3351829e54bb09fa456cd6d76ea1247902794d82a4a3ffa","low":"a8c63ba910623a0686930c27db0733f4a2588c7fca9dd7da25c3f18027720ab5","medium":"6afcd2b90c0d19794f8c0d22147a0f011946a92e613f89dae98b0ca729313101"}},"configSha256":{"grok-4.5":{"high":"c63c3387ce92d94ec3f690abfe98942afcd7c9e17ff84816bbe751f340ab251f","low":"8247127c3625ff7c5d8d527a53596b89ec6557a821ac46cfd00bd122b90daff6","medium":"59288cee61297bb8c002097061a48f77b09d310754187a253ee089f7172a9155"},"grok-4.6":{"high":"65b0212564fb74042b1503d293fb8d3620276033264c0efade2a539ca09218e3","low":"ab58499ac32678097c146479896f2b8a8e2b0e39aea22dc0a60b6227e370538e","medium":"df1a5cc84346e7f6bf6090492fbd19faaefb42953e3bb2e8c6cbc0572242403f"},"grok-build":{"high":"a23724e00d670caee185ba7690d2daa868173e53905cf446f5329666f01ab4e3","low":"fb343f2809903f26d21681470943235031f946e99085542fd89555eb7782cbb5","medium":"8a587ef75c90eab70d19b24583e60051d6fba9d90c558839fdbb15588b4cc656"}},"defaultModel":"grok-4.6","defaultReasoningEffort":"low","home":{"directory":{"group":"worker","mode":1017,"uid":0},"organizationRuntimeHome":{"group":"worker","mode":456,"owner":"organization"},"privateTmp":{"mode":448,"owner":"worker","relativeToWorkerHome":"tmp"},"readOnlyFiles":{"gid":0,"mode":292,"names":["config.toml","managed_config.toml","requirements.toml","sandbox.toml","trusted_folders.toml"],"uid":0},"sandboxEvents":{"group":"broker","mode":416,"owner":"worker","relativePath":"sessions/sandbox-events.jsonl"},"sessionsDirectory":{"group":"worker","mode":1017,"relativePath":"sessions","uid":0},"sharedTmp":{"maxGroupExclusive":2200,"mode":1020,"otherMode":4,"paths":["/tmp","/var/tmp"],"uid":0},"spillDirectory":{"fileMode":416,"group":"worker","mode":1512,"owner":"organization","relativeToRuntimeHome":"tool-output"}},"maxTurns":48,"modelId":"daimon-broker-grok","models":["grok-4.6","grok-4.5","grok-build"],"reasoningEfforts":["low","medium","high"],"systemPromptSha256":"2c31c0085a54a4efbf9c0cf0b8124c56e47f38691b7f0c7fa233a74abaa8ddf8","taskClock":{"directoryMode":493,"directoryPath":"/run/daimon-engine-broker/task-clock/slot-0","fileMode":420,"ownerUid":2100,"preloadPath":"/usr/local/lib/daimon/libfaketime.so.1","rootDirectoryPath":"/run/daimon-engine-broker/task-clock","slotDirectoryPattern":"/run/daimon-engine-broker/task-clock/slot-{slot}","slotFilePattern":"/run/daimon-engine-broker/task-clock/slot-{slot}/faketime","timestampFilePath":"/run/daimon-engine-broker/task-clock/slot-0/faketime","version":"noopolis.daimon.grok-broker-task-clock.v2","workerView":"own-directory-visible-sibling-directories-denied"},"toolIds":["run_terminal_cmd","read_file","grep","list_dir","search_tool","use_tool"],"visibleTools":["grep","list_dir","read_file","run_terminal_command","search_tool","use_tool"]}},"grokSubscriptionRealm":{"agentCredentialRelativePath":".grok/auth.json","bootstrapMountPath":"/var/lib/spawnfile/daimon/grok-bootstrap-auth","bootstrapSourceSlot":"grok-auth","directoryMode":448,"durableMountPath":"/var/lib/spawnfile/daimon/grok-subscription-realm","fileMode":384,"maxCredentialBytes":65536},"healthResponseSchema":{"additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"state":{"enum":["starting","running","stopping","stopped","idle","failed"]}},"required":["agentId","state"],"type":"object"},"maxItems":32,"type":"array"},"state":{"enum":["starting","running","stopping","stopped"]},"version":{"const":"noopolis.daimon.organization-runtime-health.v1"}},"required":["version","state","agents"],"type":"object"},"operatorDrain":{"authorization":"control-bearer","blockedReason":"operator_stop","drainRoute":"POST /v2/drain","queuedWakes":"retained","response":"workAvailabilityResponseSchema","resumeClearsOperatorStop":false,"resumeRoute":"POST /v2/resume","runningTurns":"finish","scope":"process"},"organizationRuntimeConfigSchema":{"$id":"noopolis.daimon.organization-runtime.v1","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"attention":{"additionalProperties":false,"properties":{"maxBatchBytes":{"maximum":12000,"minimum":1024,"type":"integer"},"maxBatchMessages":{"maximum":32,"minimum":1,"type":"integer"},"maxExecutions":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"maxTokens":{"maximum":9007199254740991,"minimum":1,"type":"integer"}},"type":"object"},"engine":{"additionalProperties":false,"allOf":[{"if":{"properties":{"kind":{"const":"grok"}}},"then":{"dependentRequired":{"model":["reasoningEffort"],"reasoningEffort":["model"]},"properties":{"codexSandbox":false,"model":{"enum":["grok-4.6","grok-4.5","grok-build"]},"reasoningEffort":{"enum":["low","medium","high"]}}}},{"if":{"properties":{"kind":{"const":"agy"}}},"then":{"properties":{"codexSandbox":false,"model":false,"reasoningEffort":false}}}],"properties":{"codexSandbox":{"additionalProperties":false,"properties":{"mode":{"const":"workspace-write"},"networkAccess":{"const":false},"webSearch":{"const":"disabled"}},"required":["mode","networkAccess","webSearch"],"type":"object"},"kind":{"enum":["codex","grok","agy"]},"model":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"reasoningEffort":{"enum":["none","minimal","low","medium","high","xhigh","max","ultra","persistent"]}},"required":["kind"],"type":"object"},"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"instructions":{"maxLength":16384,"minLength":1,"pattern":"\\S","type":"string"},"mcp":{"items":{"additionalProperties":false,"properties":{"args":{"items":{"maxLength":4096,"type":"string"},"maxItems":32,"type":"array"},"authSecretEnv":{"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"command":{"pattern":"^/","type":"string"},"env":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"maxLength":4096,"minLength":1,"type":"string"},"tools":{"items":{"maxLength":4096,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"transport":{"enum":["stdio","sse","streamable_http"]},"url":{"type":"string"}},"required":["name","transport","args","env","tools"],"type":"object"},"maxItems":8,"type":"array"},"memory":{"additionalProperties":false,"properties":{"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"source":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"tokenBudget":{"maximum":1000000,"minimum":1,"type":"integer"}},"required":["runtimeHomePath"],"type":"object"},"moltnet":{"additionalProperties":false,"properties":{"cliPath":{"pattern":"^/","type":"string"},"configPath":{"pattern":"^/","type":"string"},"networks":{"items":{"additionalProperties":false,"properties":{"dms":{"type":"boolean"},"id":{"minLength":1,"type":"string"},"rooms":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true}},"required":["id","rooms","dms"],"type":"object"},"maxItems":16,"type":"array"}},"required":["cliPath","configPath","networks"],"type":"object"},"name":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"recording":{"additionalProperties":false,"properties":{"directory":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"},"keepMs":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"snapshots":{"items":{"additionalProperties":false,"properties":{"id":{"pattern":"^[A-Za-z0-9._-]{1,128}$","type":"string"},"path":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"}},"required":["id","path"],"type":"object"},"maxItems":16,"type":"array","uniqueItems":true}},"required":["directory","keepMs","snapshots"],"type":"object"},"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"workspacePath":{"maxLength":4096,"pattern":"^/","type":"string"}},"required":["id","name","instructions","workspacePath","runtimeHomePath","engine"],"type":"object"},"maxItems":32,"minItems":1,"type":"array"},"host":{"additionalProperties":false,"properties":{"bindHost":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"controlTokenEnv":{"maxLength":4096,"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"port":{"maximum":65535,"minimum":1,"type":"integer"}},"required":["bindHost","port","controlTokenEnv"],"type":"object"},"version":{"const":"noopolis.daimon.organization-runtime.v1"}},"required":["version","host","agents"],"type":"object"},"organizationRuntimeConfigV2Schema":{"$id":"noopolis.daimon.organization-runtime.v2","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"attention":{"additionalProperties":false,"properties":{"maxBatchBytes":{"maximum":12000,"minimum":1024,"type":"integer"},"maxBatchMessages":{"maximum":32,"minimum":1,"type":"integer"},"maxExecutions":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"maxTokens":{"maximum":9007199254740991,"minimum":1,"type":"integer"}},"type":"object"},"engine":{"additionalProperties":false,"allOf":[{"if":{"properties":{"kind":{"const":"grok"}}},"then":{"dependentRequired":{"model":["reasoningEffort"],"reasoningEffort":["model"]},"properties":{"codexSandbox":false,"model":{"enum":["grok-4.6","grok-4.5","grok-build"]},"reasoningEffort":{"enum":["low","medium","high"]}}}},{"if":{"properties":{"kind":{"const":"agy"}}},"then":{"properties":{"codexSandbox":false,"model":false,"reasoningEffort":false}}}],"properties":{"codexSandbox":{"additionalProperties":false,"properties":{"mode":{"const":"workspace-write"},"networkAccess":{"const":false},"webSearch":{"const":"disabled"}},"required":["mode","networkAccess","webSearch"],"type":"object"},"kind":{"enum":["codex","grok","agy"]},"model":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"reasoningEffort":{"enum":["none","minimal","low","medium","high","xhigh","max","ultra","persistent"]}},"required":["kind"],"type":"object"},"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"instructions":{"maxLength":16384,"minLength":1,"pattern":"\\S","type":"string"},"mcp":{"items":{"additionalProperties":false,"properties":{"args":{"items":{"maxLength":4096,"type":"string"},"maxItems":32,"type":"array"},"authSecretEnv":{"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"command":{"pattern":"^/","type":"string"},"env":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"maxLength":4096,"minLength":1,"type":"string"},"tools":{"items":{"maxLength":4096,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"transport":{"enum":["stdio","sse","streamable_http"]},"url":{"type":"string"}},"required":["name","transport","args","env","tools"],"type":"object"},"maxItems":8,"type":"array"},"memory":{"additionalProperties":false,"properties":{"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"source":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"tokenBudget":{"maximum":1000000,"minimum":1,"type":"integer"}},"required":["runtimeHomePath"],"type":"object"},"moltnet":{"additionalProperties":false,"properties":{"cliPath":{"pattern":"^/","type":"string"},"configPath":{"pattern":"^/","type":"string"},"networks":{"items":{"additionalProperties":false,"properties":{"dms":{"type":"boolean"},"id":{"minLength":1,"type":"string"},"rooms":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true}},"required":["id","rooms","dms"],"type":"object"},"maxItems":16,"type":"array"}},"required":["cliPath","configPath","networks"],"type":"object"},"name":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"recording":{"additionalProperties":false,"properties":{"directory":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"},"keepMs":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"snapshots":{"items":{"additionalProperties":false,"properties":{"id":{"pattern":"^[A-Za-z0-9._-]{1,128}$","type":"string"},"path":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"}},"required":["id","path"],"type":"object"},"maxItems":16,"type":"array","uniqueItems":true}},"required":["directory","keepMs","snapshots"],"type":"object"},"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"schedule":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"disabled"}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"interval_ms":{"maximum":31536000000,"minimum":1,"type":"integer"},"jitter_seconds":{"maximum":3600,"minimum":0,"type":"integer"},"kind":{"const":"every"},"prompt":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["kind","interval_ms","prompt"],"type":"object"},{"additionalProperties":false,"properties":{"cron":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"jitter_seconds":{"maximum":3600,"minimum":0,"type":"integer"},"kind":{"const":"cron"},"prompt":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"timezone":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["kind","cron","timezone","prompt"],"type":"object"}]},"workspacePath":{"maxLength":4096,"pattern":"^/","type":"string"}},"required":["id","name","instructions","workspacePath","runtimeHomePath","engine","schedule"],"type":"object"},"maxItems":32,"minItems":1,"type":"array"},"host":{"additionalProperties":false,"properties":{"bindHost":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"controlTokenEnv":{"maxLength":4096,"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"port":{"maximum":65535,"minimum":1,"type":"integer"}},"required":["bindHost","port","controlTokenEnv"],"type":"object"},"version":{"const":"noopolis.daimon.organization-runtime.v2"}},"required":["version","host","agents"],"type":"object"},"supportedEngineKinds":["agy","codex","grok"],"version":"noopolis.daimon.runtime-contract-manifest.v5","wakeAcceptanceTypes":["manual","message","schedule","external"],"wakeMoments":{"captureDeadlineMs":60000,"completionSuffix":".complete","configField":"agents[].recording","finalizationDeadlineMs":1000,"maxManifestBytes":134217728,"maxRowBytes":4194304,"maxSnapshotEntries":200000,"maxSnapshotRoots":16,"rowsFile":"wake-moments.jsonl","snapshotsDirectory":"snapshots","version":"noopolis.daimon.wake-moment.v1"},"wakeRequestSchema":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"event":{"additionalProperties":false,"properties":{"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"kind":{"enum":["manual","message","schedule","external"]},"occurredAt":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"text":{"maxLength":4096,"type":"string"},"version":{"const":"noopolis.daimon.wake.v1"}},"required":["version","id","kind","text","occurredAt"],"type":"object"}},"required":["agentId","event"],"type":"object"},"wakeResultSchema":{"oneOf":[{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"durationMs":{"minimum":0,"type":"integer"},"status":{"const":"completed"},"text":{"maxLength":4096,"type":"string"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","text","durationMs"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["unauthorized","unknown_agent","queue_full","durable_inbox_required"]},"status":{"const":"rejected"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"type":"string"},"code":{"const":"invalid_request"},"status":{"const":"rejected"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["host_stopping","host_stopped","queued_wake_stopped","active_wake_aborted"]},"status":{"const":"stopped"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"const":"engine_failed"},"status":{"const":"failed"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"}]},"workAvailabilityResponseSchema":{"additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"agent_id":{"type":"string"},"budget":{"additionalProperties":false,"properties":{"agent_executions_remaining":{"minimum":0,"type":"integer"},"agent_executions_used":{"minimum":0,"type":"integer"},"agent_tokens_remaining":{"minimum":0,"type":"integer"},"agent_tokens_used":{"minimum":0,"type":"integer"},"armed":{"type":"boolean"},"epoch":{"type":"string"},"executions_remaining":{"minimum":0,"type":"integer"},"executions_used":{"minimum":0,"type":"integer"},"reason":{"type":"string"},"state":{"enum":["available","paused","stopped"]},"tokens_remaining":{"minimum":0,"type":"integer"},"tokens_used":{"minimum":0,"type":"integer"}},"required":["armed","epoch","state","executions_used","executions_remaining","tokens_used","tokens_remaining","agent_executions_used","agent_tokens_used"],"type":"object"},"deferred":{"minimum":0,"type":"integer"},"error":{"type":"string"},"pending":{"minimum":0,"type":"integer"},"running":{"type":"boolean"}},"required":["agent_id","pending","running","deferred","budget"],"type":"object"},"maxItems":32,"type":"array"},"drain":{"additionalProperties":false,"properties":{"since":{"type":"string"},"state":{"enum":["draining","drained"]}},"required":["state","since"],"type":"object"},"state":{"enum":["running","paused","stopped"]},"version":{"const":"noopolis.daimon.work-availability.v1"}},"required":["version","state","agents"],"type":"object"},"workBlockedSchema":{"additionalProperties":false,"properties":{"reason":{"enum":["operator_stop","ledger_unavailable","host_stopping","host_stopped","queue_full"]},"retry_after_ms":{"maximum":300000,"minimum":1000,"type":"integer"},"version":{"const":"noopolis.daimon.work-blocked.v1"}},"required":["version","reason","retry_after_ms"],"type":"object"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sha256:e39551277c6727c8807b1247e759f57addcee3f17f1405ebc927179647d64de6
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { canonicalJson } from "../contracts/canonicalJson.js";
|
|
2
|
+
import { AGY_SUBSCRIPTION_REALM, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION } from "../contracts/runtimeContractManifest.js";
|
|
3
|
+
export { AGY_SUBSCRIPTION_REALM, canonicalJson, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION };
|
|
4
|
+
export type RuntimeContractManifest = typeof RUNTIME_CONTRACT_MANIFEST;
|
|
5
|
+
export type EngineCredentialKind = keyof typeof ENGINE_CREDENTIAL_MATERIAL;
|
|
6
|
+
export type EngineCredentialSlot = (typeof ENGINE_CREDENTIAL_MATERIAL)[EngineCredentialKind]["sourceSlot"];
|
|
7
|
+
export declare const canonicalRuntimeContractManifest: () => string;
|
|
8
|
+
//# sourceMappingURL=contractManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractManifest.d.ts","sourceRoot":"","sources":["../../src/runtime/contractManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,wCAAwC,EACxC,yBAAyB,EACzB,iCAAiC,EAClC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,wCAAwC,EACxC,yBAAyB,EACzB,iCAAiC,EAClC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,OAAO,yBAAyB,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,0BAA0B,CAAC;AAC3E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC;AAE3G,eAAO,MAAM,gCAAgC,QAAO,MAAkD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { canonicalJson } from "../contracts/canonicalJson.js";
|
|
2
|
+
import { AGY_SUBSCRIPTION_REALM, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION } from "../contracts/runtimeContractManifest.js";
|
|
3
|
+
export { AGY_SUBSCRIPTION_REALM, canonicalJson, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION };
|
|
4
|
+
export const canonicalRuntimeContractManifest = () => canonicalJson(RUNTIME_CONTRACT_MANIFEST);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long a turn's capabilities outlive the turn's own wall-clock limit.
|
|
3
|
+
*
|
|
4
|
+
* A capability that expires before its turn does strands the worker mid-turn:
|
|
5
|
+
* on 2026-10-05 a 30-minute turn kept a fixed 15-minute grant, lost every tool
|
|
6
|
+
* at minute 16 (MCP 403, mcp_refused=expired) and then timed out unfiled. The
|
|
7
|
+
* turn timer is what ends a turn; the grant only has to not end it first.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS = 60000;
|
|
10
|
+
export declare const engineBrokerCapabilityTtlMs: (turnTimeoutMs: number) => number;
|
|
11
|
+
export declare class EngineBrokerCapabilities {
|
|
12
|
+
private readonly grants;
|
|
13
|
+
issue(agentId: string, turnId: string, ttlMs?: number, maxRequests?: number): string;
|
|
14
|
+
authorize(agentId: string, turnId: string, token: string): boolean;
|
|
15
|
+
authorizeToken(token: string): Readonly<{
|
|
16
|
+
agentId: string;
|
|
17
|
+
turnId: string;
|
|
18
|
+
}> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Which grant a token names and why it would be refused, *without* spending
|
|
21
|
+
* it.
|
|
22
|
+
*
|
|
23
|
+
* The facade needs this on its refusal path alone. A 403 it cannot attribute
|
|
24
|
+
* to a turn is a 403 that seals as nothing at all, and a turn whose every
|
|
25
|
+
* request was refused then reads exactly like a healthy one — the silence
|
|
26
|
+
* `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
|
|
27
|
+
* no turn and stays unattributed; nothing here returns the token, the grant
|
|
28
|
+
* or the agent's capability, only the turn id and a closed reason.
|
|
29
|
+
*/
|
|
30
|
+
classifyToken(token: string): Readonly<{
|
|
31
|
+
turnId: string;
|
|
32
|
+
state: "live" | "expired" | "exhausted";
|
|
33
|
+
}> | undefined;
|
|
34
|
+
inspectToken(token: string): Readonly<{
|
|
35
|
+
agentId: string;
|
|
36
|
+
turnId: string;
|
|
37
|
+
}> | undefined;
|
|
38
|
+
revoke(turnId: string): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=engineBrokerCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerCapabilities.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerCapabilities.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,QAAS,CAAC;AAC7D,eAAO,MAAM,2BAA2B,GAAI,eAAe,MAAM,KAAG,MAAgE,CAAC;AAIrI,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;IAC1E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAc,EAAE,WAAW,SAAK,GAAG,MAAM;IAMrF,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAKlE,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS;IAQxF;;;;;;;;;;OAUG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAA;KAAE,CAAC,GAAG,SAAS;IAW/G,YAAY,CAAC,KAAK,EAAC,MAAM,GAAE,QAAQ,CAAC;QAAC,OAAO,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAA;KAAC,CAAC,GAAC,SAAS;IAC7E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAC7B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* How long a turn's capabilities outlive the turn's own wall-clock limit.
|
|
4
|
+
*
|
|
5
|
+
* A capability that expires before its turn does strands the worker mid-turn:
|
|
6
|
+
* on 2026-10-05 a 30-minute turn kept a fixed 15-minute grant, lost every tool
|
|
7
|
+
* at minute 16 (MCP 403, mcp_refused=expired) and then timed out unfiled. The
|
|
8
|
+
* turn timer is what ends a turn; the grant only has to not end it first.
|
|
9
|
+
*/
|
|
10
|
+
export const ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS = 60_000;
|
|
11
|
+
export const engineBrokerCapabilityTtlMs = (turnTimeoutMs) => turnTimeoutMs + ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS;
|
|
12
|
+
export class EngineBrokerCapabilities {
|
|
13
|
+
grants = new Map();
|
|
14
|
+
issue(agentId, turnId, ttlMs = 15 * 60_000, maxRequests = 64) {
|
|
15
|
+
if (ttlMs < 1 || maxRequests < 1)
|
|
16
|
+
throw new TypeError("invalid broker capability policy");
|
|
17
|
+
const token = randomBytes(32).toString("base64url");
|
|
18
|
+
this.grants.set(turnId, { agentId, turnId, digest: hash(token), expiresAt: Date.now() + ttlMs, maxRequests, requests: 0 });
|
|
19
|
+
return token;
|
|
20
|
+
}
|
|
21
|
+
authorize(agentId, turnId, token) {
|
|
22
|
+
const grant = this.grants.get(turnId);
|
|
23
|
+
const candidate = hash(token);
|
|
24
|
+
if (grant === undefined || grant.agentId !== agentId || grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
|
|
25
|
+
return false;
|
|
26
|
+
grant.requests += 1;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
authorizeToken(token) {
|
|
30
|
+
const candidate = hash(token);
|
|
31
|
+
for (const grant of this.grants.values()) {
|
|
32
|
+
if (grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
|
|
33
|
+
continue;
|
|
34
|
+
grant.requests += 1;
|
|
35
|
+
return { agentId: grant.agentId, turnId: grant.turnId };
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Which grant a token names and why it would be refused, *without* spending
|
|
41
|
+
* it.
|
|
42
|
+
*
|
|
43
|
+
* The facade needs this on its refusal path alone. A 403 it cannot attribute
|
|
44
|
+
* to a turn is a 403 that seals as nothing at all, and a turn whose every
|
|
45
|
+
* request was refused then reads exactly like a healthy one — the silence
|
|
46
|
+
* `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
|
|
47
|
+
* no turn and stays unattributed; nothing here returns the token, the grant
|
|
48
|
+
* or the agent's capability, only the turn id and a closed reason.
|
|
49
|
+
*/
|
|
50
|
+
classifyToken(token) {
|
|
51
|
+
const candidate = hash(token);
|
|
52
|
+
for (const grant of this.grants.values()) {
|
|
53
|
+
if (!timingSafeEqual(grant.digest, candidate))
|
|
54
|
+
continue;
|
|
55
|
+
// Budget before expiry: the TTL outlives every declared turn limit, so an
|
|
56
|
+
// exhausted grant is the reachable refusal and the actionable answer.
|
|
57
|
+
if (grant.requests >= grant.maxRequests)
|
|
58
|
+
return { turnId: grant.turnId, state: "exhausted" };
|
|
59
|
+
return { turnId: grant.turnId, state: grant.expiresAt <= Date.now() ? "expired" : "live" };
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
inspectToken(token) { const candidate = hash(token); for (const grant of this.grants.values()) {
|
|
64
|
+
if (grant.expiresAt > Date.now() && grant.requests < grant.maxRequests && timingSafeEqual(grant.digest, candidate))
|
|
65
|
+
return { agentId: grant.agentId, turnId: grant.turnId };
|
|
66
|
+
} return undefined; }
|
|
67
|
+
revoke(turnId) { const grant = this.grants.get(turnId); grant?.digest.fill(0); this.grants.delete(turnId); }
|
|
68
|
+
}
|
|
69
|
+
const hash = (value) => createHash("sha256").update(value).digest();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Socket } from "node:net";
|
|
2
|
+
import type { EngineBrokerInferenceFailureCode, EngineBrokerInferenceResponse } from "./engineBrokerInferenceProtocol.js";
|
|
3
|
+
import type { EngineBrokerTurnLimitOverrides } from "./engineBrokerTurnAccounting.js";
|
|
4
|
+
import type { GrokBrokerModel, GrokBrokerReasoningEffort } from "./grokBrokerModelPolicy.js";
|
|
5
|
+
import type { GrokInferencePurpose } from "./inferenceUsageLedger.js";
|
|
6
|
+
import type { GrokBrokerProviderClockObservation } from "./grokBrokerProviderClock.js";
|
|
7
|
+
export type EngineBrokerInferenceGrant = Omit<Extract<EngineBrokerInferenceResponse, {
|
|
8
|
+
kind: "inference_grant";
|
|
9
|
+
}>, "version" | "kind" | "requestId">;
|
|
10
|
+
/** A refused grant request; `code` is closed (`auth_stale` is the stale shared realm, `grant_limit` the live-grant cap). */
|
|
11
|
+
export declare class EngineBrokerInferenceGrantRefused extends Error {
|
|
12
|
+
readonly code: EngineBrokerInferenceFailureCode;
|
|
13
|
+
constructor(code: EngineBrokerInferenceFailureCode);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What the organization runtime asks of a brokered turn beyond the prompt:
|
|
17
|
+
* `limits` may only lower the registration's declared limits, and `model`,
|
|
18
|
+
* when the agent declared one, must equal the model the broker sealed.
|
|
19
|
+
*/
|
|
20
|
+
export type EngineBrokerTurnOptions = Readonly<{
|
|
21
|
+
limits?: EngineBrokerTurnLimitOverrides;
|
|
22
|
+
model?: string;
|
|
23
|
+
processClock?: string;
|
|
24
|
+
slot?: number;
|
|
25
|
+
/** Sealed observation on completion, failure and replay; sink errors never change the turn. */
|
|
26
|
+
onProviderClock?: (observation: GrokBrokerProviderClockObservation) => void;
|
|
27
|
+
}>;
|
|
28
|
+
export interface EngineBrokerTurnClient {
|
|
29
|
+
turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
export declare class EngineBrokerControlClient implements EngineBrokerTurnClient {
|
|
32
|
+
private readonly socketPath;
|
|
33
|
+
/** Internal transport seam; the production client always opens the Unix socket. */
|
|
34
|
+
private readonly connect;
|
|
35
|
+
constructor(socketPath?: string,
|
|
36
|
+
/** Internal transport seam; the production client always opens the Unix socket. */
|
|
37
|
+
connect?: (path: string) => Socket);
|
|
38
|
+
ready(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Evaluator side (organization uid only; the native relay enforces it):
|
|
41
|
+
* borrow the broker credential for one sequential lane of judge or optimizer
|
|
42
|
+
* requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
|
|
43
|
+
* a broker that cannot answer rejects with `engine broker unavailable`.
|
|
44
|
+
*/
|
|
45
|
+
requestInferenceGrant(request: Readonly<{
|
|
46
|
+
model: GrokBrokerModel;
|
|
47
|
+
reasoningEffort: GrokBrokerReasoningEffort;
|
|
48
|
+
purpose: GrokInferencePurpose;
|
|
49
|
+
}>): Promise<EngineBrokerInferenceGrant>;
|
|
50
|
+
releaseInferenceGrant(grantId: string): Promise<boolean>;
|
|
51
|
+
resetSlot(slot: number): Promise<void>;
|
|
52
|
+
private exchange;
|
|
53
|
+
turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=engineBrokerControlClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerControlClient.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerControlClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEzD,OAAO,KAAK,EAAE,gCAAgC,EAAgC,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAExJ,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAevF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC;AACrJ,4HAA4H;AAC5H,qBAAa,iCAAkC,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,gCAAgC;gBAAtC,IAAI,EAAE,gCAAgC;CAC5D;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,MAAM,CAAC,EAAE,8BAA8B,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9F,+FAA+F;IAC/F,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,kCAAkC,KAAK,IAAI,CAAC;CAC7E,CAAC,CAAC;AACH,MAAM,WAAW,sBAAsB;IAAG,IAAI,CAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,WAAW,EAAC,MAAM,EAAC,MAAM,CAAC,EAAC,WAAW,EAAC,OAAO,CAAC,EAAC,uBAAuB,GAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAAE;AACrL,qBAAa,yBAA0B,YAAW,sBAAsB;IAEpE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,mFAAmF;IACnF,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,UAAU,SAA2C;IACtE,mFAAmF;IAClE,OAAO,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAA6C;IAErF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B5B;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAC,QAAQ,CAAC;QAAC,KAAK,EAAC,eAAe,CAAC;QAAA,eAAe,EAAC,yBAAyB,CAAC;QAAA,OAAO,EAAC,oBAAoB,CAAA;KAAC,CAAC,GAAE,OAAO,CAAC,0BAA0B,CAAC;IAM3K,qBAAqB,CAAC,OAAO,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC;IAMtD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,OAAO,CAAC,QAAQ;IA6BV,IAAI,CACR,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EACpE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,GAAE,uBAA4B,GAC1D,OAAO,CAAC,MAAM,CAAC;CA+EnB"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { createConnection } from "node:net";
|
|
3
|
+
import { ENGINE_BROKER_VERSION, EngineBrokerProtocolMismatch, encodeEngineBrokerFrame, EngineBrokerFrameDecoder, parseEngineBrokerResponse, parseEngineBrokerSlot } from "./engineBrokerProtocol.js";
|
|
4
|
+
import { ENGINE_BROKER_MCP_REFUSAL_REASONS } from "./engineBrokerMcpCallLog.js";
|
|
5
|
+
/**
|
|
6
|
+
* What the broker saw of the worker's MCP tool calls on a failed turn
|
|
7
|
+
* (`engineBrokerMcpCallLog.ts`). Absent for a turn with no observation at all;
|
|
8
|
+
* `outstanding` names every call that started and was never answered, with how
|
|
9
|
+
* long it had been waiting — the one thing a completion-only tool receipt can
|
|
10
|
+
* never say.
|
|
11
|
+
*/
|
|
12
|
+
const renderMcpCalls = (calls) => calls === undefined ? "" : `; mcp=${calls.answered}/${calls.started} answered${calls.undecoded === 0 ? "" : `; mcp_undecoded=${calls.undecoded}`}${calls.outstanding.length === 0 ? "" : `; mcp_outstanding=${calls.outstanding.map((call) => `${call.name}@${call.outstandingMs}ms`).join(",")}`}${renderMcpRefusals(calls.refusals)}${renderMcpTunnels(calls.tunnels)}`;
|
|
13
|
+
/** The refusals the facade never relayed, by reason class, and only the classes that happened: a turn refused 403 must not read as a turn that was served. */
|
|
14
|
+
const renderMcpRefusals = (refusals) => { if (refusals === undefined)
|
|
15
|
+
return ""; const named = ENGINE_BROKER_MCP_REFUSAL_REASONS.filter((reason) => refusals[reason] > 0); return named.length === 0 ? "" : `; mcp_refused=${named.map((reason) => `${reason}:${refusals[reason]}`).join(",")}`; };
|
|
16
|
+
/** The session's GET SSE tunnels: how many closed of how many opened, and each one still open with its age and whether the mount ever pushed through it. */
|
|
17
|
+
const renderMcpTunnels = (tunnels) => tunnels === undefined ? "" : `; mcp_get=${tunnels.closed}/${tunnels.opened} closed, ${tunnels.delivered} delivered${tunnels.open.length === 0 ? "" : `; mcp_get_open=${tunnels.open.map((tunnel) => `${tunnel.openMs}ms/${tunnel.delivered ? "delivered" : "silent"}`).join(",")}`}`;
|
|
18
|
+
/** A refused grant request; `code` is closed (`auth_stale` is the stale shared realm, `grant_limit` the live-grant cap). */
|
|
19
|
+
export class EngineBrokerInferenceGrantRefused extends Error {
|
|
20
|
+
code;
|
|
21
|
+
constructor(code) {
|
|
22
|
+
super(`engine broker inference grant refused (${code})`);
|
|
23
|
+
this.code = code;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class EngineBrokerControlClient {
|
|
27
|
+
socketPath;
|
|
28
|
+
connect;
|
|
29
|
+
constructor(socketPath = "/run/daimon-engine-broker/control.sock",
|
|
30
|
+
/** Internal transport seam; the production client always opens the Unix socket. */
|
|
31
|
+
connect = (path) => createConnection({ path })) {
|
|
32
|
+
this.socketPath = socketPath;
|
|
33
|
+
this.connect = connect;
|
|
34
|
+
}
|
|
35
|
+
async ready() {
|
|
36
|
+
const requestId = randomUUID();
|
|
37
|
+
const socket = this.connect(this.socketPath);
|
|
38
|
+
const decoder = new EngineBrokerFrameDecoder();
|
|
39
|
+
await new Promise((resolve, reject) => {
|
|
40
|
+
let settled = false;
|
|
41
|
+
const fail = (error) => {
|
|
42
|
+
if (settled)
|
|
43
|
+
return;
|
|
44
|
+
settled = true;
|
|
45
|
+
socket.destroy();
|
|
46
|
+
reject(controlFailure(error));
|
|
47
|
+
};
|
|
48
|
+
socket.once("error", fail);
|
|
49
|
+
socket.once("close", fail);
|
|
50
|
+
socket.once("connect", () => socket.write(encodeEngineBrokerFrame({
|
|
51
|
+
version: ENGINE_BROKER_VERSION, kind: "health", requestId
|
|
52
|
+
})));
|
|
53
|
+
socket.on("data", (chunk) => {
|
|
54
|
+
try {
|
|
55
|
+
for (const value of decoder.push(chunk)) {
|
|
56
|
+
const response = parseEngineBrokerResponse(value);
|
|
57
|
+
if (response.kind !== "ready" || response.requestId !== requestId || settled)
|
|
58
|
+
throw new Error();
|
|
59
|
+
settled = true;
|
|
60
|
+
socket.destroy();
|
|
61
|
+
resolve();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
fail(error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Evaluator side (organization uid only; the native relay enforces it):
|
|
72
|
+
* borrow the broker credential for one sequential lane of judge or optimizer
|
|
73
|
+
* requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
|
|
74
|
+
* a broker that cannot answer rejects with `engine broker unavailable`.
|
|
75
|
+
*/
|
|
76
|
+
async requestInferenceGrant(request) {
|
|
77
|
+
const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "request_inference_grant", requestId: randomUUID(), model: request.model, reasoningEffort: request.reasoningEffort, purpose: request.purpose });
|
|
78
|
+
if (response.kind === "inference_grant_refused")
|
|
79
|
+
throw new EngineBrokerInferenceGrantRefused(response.code);
|
|
80
|
+
if (response.kind !== "inference_grant" || response.model !== request.model || response.reasoningEffort !== request.reasoningEffort || response.purpose !== request.purpose)
|
|
81
|
+
throw new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
|
|
82
|
+
const { version: _version, kind: _kind, requestId: _requestId, ...grant } = response;
|
|
83
|
+
return grant;
|
|
84
|
+
}
|
|
85
|
+
async releaseInferenceGrant(grantId) {
|
|
86
|
+
const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "release_inference_grant", requestId: randomUUID(), grantId });
|
|
87
|
+
if (response.kind === "inference_grant_refused")
|
|
88
|
+
throw new EngineBrokerInferenceGrantRefused(response.code);
|
|
89
|
+
if (response.kind !== "inference_grant_released" || response.grantId !== grantId)
|
|
90
|
+
throw new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
|
|
91
|
+
return response.released;
|
|
92
|
+
}
|
|
93
|
+
async resetSlot(slot) {
|
|
94
|
+
const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "reset_slot", requestId: randomUUID(), slot: parseEngineBrokerSlot(slot) });
|
|
95
|
+
if (response.kind !== "slot_reset" || response.slot !== slot)
|
|
96
|
+
throw new Error("engine broker reset unavailable");
|
|
97
|
+
}
|
|
98
|
+
exchange(request) {
|
|
99
|
+
const socket = this.connect(this.socketPath);
|
|
100
|
+
const decoder = new EngineBrokerFrameDecoder();
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
let settled = false;
|
|
103
|
+
const fail = (error) => {
|
|
104
|
+
if (settled)
|
|
105
|
+
return;
|
|
106
|
+
settled = true;
|
|
107
|
+
socket.destroy();
|
|
108
|
+
reject(controlFailure(error));
|
|
109
|
+
};
|
|
110
|
+
socket.once("error", fail);
|
|
111
|
+
socket.once("close", fail);
|
|
112
|
+
socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request)));
|
|
113
|
+
socket.on("data", (chunk) => {
|
|
114
|
+
try {
|
|
115
|
+
for (const value of decoder.push(chunk)) {
|
|
116
|
+
const response = parseEngineBrokerResponse(value);
|
|
117
|
+
if (settled || response.requestId !== request.requestId ||
|
|
118
|
+
(response.kind !== "inference_grant" && response.kind !== "inference_grant_released" &&
|
|
119
|
+
response.kind !== "inference_grant_refused" && response.kind !== "slot_reset"))
|
|
120
|
+
throw new Error();
|
|
121
|
+
settled = true;
|
|
122
|
+
socket.destroy();
|
|
123
|
+
resolve(response);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
fail(error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async turn(agentId, wakeId, prompt, mcpEndpoint, signal, options = {}) {
|
|
133
|
+
const configured = process.env.DAIMON_ENGINE_BROKER_SLOT;
|
|
134
|
+
const slot = options.slot ?? (configured === undefined ? undefined : parseEngineBrokerSlot(/^(0|[1-9][0-9]*)$/u.test(configured) ? Number(configured) : NaN));
|
|
135
|
+
if (slot !== undefined)
|
|
136
|
+
parseEngineBrokerSlot(slot);
|
|
137
|
+
const turnId = createHash("sha256").update(`${slot === undefined ? "" : `${slot}\0`}${agentId}\0${wakeId}`).digest("hex");
|
|
138
|
+
const requestId = randomUUID();
|
|
139
|
+
const request = {
|
|
140
|
+
version: ENGINE_BROKER_VERSION, kind: "start_turn", requestId, turnId, agentId, wakeId, prompt, mcpEndpoint,
|
|
141
|
+
...(slot === undefined ? {} : { slot }),
|
|
142
|
+
...(options.limits === undefined ? {} : { limits: options.limits }),
|
|
143
|
+
...(options.processClock === undefined ? {} : { processClock: options.processClock })
|
|
144
|
+
};
|
|
145
|
+
const socket = this.connect(this.socketPath);
|
|
146
|
+
const decoder = new EngineBrokerFrameDecoder();
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
let accepted = false;
|
|
149
|
+
let settled = false;
|
|
150
|
+
const fail = (error) => {
|
|
151
|
+
if (settled)
|
|
152
|
+
return;
|
|
153
|
+
settled = true;
|
|
154
|
+
cleanup();
|
|
155
|
+
reject(controlFailure(error));
|
|
156
|
+
};
|
|
157
|
+
const cleanup = () => {
|
|
158
|
+
signal?.removeEventListener("abort", abort);
|
|
159
|
+
socket.destroy();
|
|
160
|
+
};
|
|
161
|
+
const abort = () => fail();
|
|
162
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
163
|
+
if (signal?.aborted)
|
|
164
|
+
return abort();
|
|
165
|
+
socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request)));
|
|
166
|
+
socket.on("data", (chunk) => {
|
|
167
|
+
try {
|
|
168
|
+
for (const value of decoder.push(chunk)) {
|
|
169
|
+
const response = parseEngineBrokerResponse(value);
|
|
170
|
+
if ((response.kind !== "accepted" && response.kind !== "completed" && response.kind !== "failed") ||
|
|
171
|
+
response.requestId !== requestId || response.turnId !== turnId)
|
|
172
|
+
throw new Error();
|
|
173
|
+
if (response.kind === "accepted") {
|
|
174
|
+
if (accepted)
|
|
175
|
+
throw new Error();
|
|
176
|
+
accepted = true;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!accepted || settled)
|
|
180
|
+
throw new Error();
|
|
181
|
+
settled = true;
|
|
182
|
+
cleanup();
|
|
183
|
+
if (response.providerClock !== undefined) {
|
|
184
|
+
try {
|
|
185
|
+
options.onProviderClock?.(response.providerClock);
|
|
186
|
+
}
|
|
187
|
+
catch { /* Observation cannot discard a terminal result. */ }
|
|
188
|
+
}
|
|
189
|
+
if (options.model !== undefined && response.model !== options.model) {
|
|
190
|
+
reject(new Error(`engine broker turn used model ${response.model}, not the declared ${options.model}`));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (response.kind === "completed") {
|
|
194
|
+
if (response.cleanupDiagnostic !== undefined) {
|
|
195
|
+
try {
|
|
196
|
+
console.warn(`daimon: engine broker ${response.cleanupDiagnostic}`);
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// An operational warning must not discard completed work.
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
resolve(response.text);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const limit = response.limitReason === "none" ? "" : `; limit=${response.limitReason}`;
|
|
206
|
+
const detail = response.diagnostic;
|
|
207
|
+
const reason = detail?.reason === undefined ? "" : `; reason=${detail.reason}`;
|
|
208
|
+
const diagnostic = detail === undefined ? "" :
|
|
209
|
+
`; ${detail.stage}/${detail.failureClass}; exit=${detail.exitCode}; signal=${detail.termSignal}${reason}`;
|
|
210
|
+
const cleanupDiagnostic = response.cleanupDiagnostic === undefined ? "" : `; ${response.cleanupDiagnostic}`;
|
|
211
|
+
reject(new Error(`engine broker turn failed (${response.code}${limit}${diagnostic}${renderMcpCalls(response.mcpCalls)}${cleanupDiagnostic})`));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
fail(error);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
socket.once("error", fail);
|
|
220
|
+
socket.once("close", () => { if (!settled)
|
|
221
|
+
fail(); });
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function controlFailure(error) {
|
|
226
|
+
return error instanceof EngineBrokerProtocolMismatch ? error :
|
|
227
|
+
new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
|
|
228
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type BrokerCredentialJournal = Readonly<{
|
|
2
|
+
version: "noopolis.daimon.broker-credential-journal.v1";
|
|
3
|
+
state: "refreshing" | "promoted" | "stale";
|
|
4
|
+
generation: number;
|
|
5
|
+
sourceDigest: string;
|
|
6
|
+
promotedDigest?: string;
|
|
7
|
+
ancestorDigests?: readonly string[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare const BROKER_CREDENTIAL_MAX_ANCESTORS = 900;
|
|
10
|
+
export declare function parseBrokerCredentialJournal(value: unknown): BrokerCredentialJournal;
|
|
11
|
+
export declare function recoverBrokerCredentialJournal(journal: BrokerCredentialJournal, authorityDigest: string): "ready" | "stale";
|
|
12
|
+
//# sourceMappingURL=engineBrokerCredentialJournal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerCredentialJournal.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerCredentialJournal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,8CAA8C,CAAC;IAAC,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AAEhQ,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAGnD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAWpF;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAI3H"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// At most 61 KiB including the rest of the record; all readers allow 64 KiB.
|
|
2
|
+
export const BROKER_CREDENTIAL_MAX_ANCESTORS = 900;
|
|
3
|
+
const DIGEST = /^[a-f0-9]{64}$/u;
|
|
4
|
+
export function parseBrokerCredentialJournal(value) {
|
|
5
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
6
|
+
throw new TypeError("invalid credential journal");
|
|
7
|
+
const input = value;
|
|
8
|
+
const fields = input.state === "refreshing" ? ["version", "state", "generation", "sourceDigest"] : ["version", "state", "generation", "sourceDigest", "promotedDigest"];
|
|
9
|
+
if (Object.hasOwn(input, "ancestorDigests")) {
|
|
10
|
+
fields.push("ancestorDigests");
|
|
11
|
+
if (!Array.isArray(input.ancestorDigests) || input.ancestorDigests.length > BROKER_CREDENTIAL_MAX_ANCESTORS ||
|
|
12
|
+
input.ancestorDigests.some((entry) => typeof entry !== "string" || !DIGEST.test(entry)) ||
|
|
13
|
+
new Set(input.ancestorDigests).size !== input.ancestorDigests.length)
|
|
14
|
+
throw new TypeError("invalid credential journal");
|
|
15
|
+
}
|
|
16
|
+
if (Object.keys(input).length !== fields.length || fields.some((key) => !Object.hasOwn(input, key)) || input.version !== "noopolis.daimon.broker-credential-journal.v1" || !["refreshing", "promoted", "stale"].includes(String(input.state)) || !Number.isSafeInteger(input.generation) || input.generation < 0 || !DIGEST.test(String(input.sourceDigest)) || (input.state !== "refreshing" && !DIGEST.test(String(input.promotedDigest))))
|
|
17
|
+
throw new TypeError("invalid credential journal");
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
export function recoverBrokerCredentialJournal(journal, authorityDigest) {
|
|
21
|
+
if (journal.state === "stale")
|
|
22
|
+
return "stale";
|
|
23
|
+
if (journal.state === "refreshing")
|
|
24
|
+
return authorityDigest === journal.sourceDigest ? "ready" : "stale";
|
|
25
|
+
return authorityDigest === journal.promotedDigest ? "ready" : "stale";
|
|
26
|
+
}
|