@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,167 @@
|
|
|
1
|
+
import { type BrokerClockObservation } from "./grokBrokerTaskClock.js";
|
|
2
|
+
import { type EngineBrokerInferenceRequest, type EngineBrokerInferenceResponse } from "./engineBrokerInferenceProtocol.js";
|
|
3
|
+
import { type EngineBrokerMcpCallObservation } from "./engineBrokerMcpCallLog.js";
|
|
4
|
+
import { type EngineBrokerTurnAccounting, type EngineBrokerTurnLimitOverrides } from "./engineBrokerTurnAccounting.js";
|
|
5
|
+
/**
|
|
6
|
+
* Control protocol v4 adds slot routing and reset. Both ends ship in the same
|
|
7
|
+
* package; v1/v2/v3 frames are refused on the wire. Durable terminal adapters
|
|
8
|
+
* retain those record formats. A missing slot is allowed only for a unique
|
|
9
|
+
* agent registration (unclocked production compatibility).
|
|
10
|
+
*/
|
|
11
|
+
declare const VERSION: "noopolis.daimon.engine-broker.v4";
|
|
12
|
+
export declare const ENGINE_BROKER_VERSION: "noopolis.daimon.engine-broker.v4";
|
|
13
|
+
declare const V1: "noopolis.daimon.engine-broker.v1";
|
|
14
|
+
export declare const ENGINE_BROKER_MAX_FRAME_BYTES = 1048576;
|
|
15
|
+
/** Version refusal is independent of the incompatible operation's schema. */
|
|
16
|
+
export type EngineBrokerProtocolDiagnostic = Readonly<{
|
|
17
|
+
kind: "protocol_mismatch";
|
|
18
|
+
receivedVersion: string;
|
|
19
|
+
expectedVersion: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare class EngineBrokerProtocolMismatch extends TypeError {
|
|
22
|
+
readonly diagnostic: EngineBrokerProtocolDiagnostic;
|
|
23
|
+
constructor(received: unknown, expected?: unknown);
|
|
24
|
+
}
|
|
25
|
+
export type EngineBrokerRequest = Readonly<{
|
|
26
|
+
version: typeof VERSION;
|
|
27
|
+
kind: "health";
|
|
28
|
+
requestId: string;
|
|
29
|
+
}> | Readonly<{
|
|
30
|
+
version: typeof VERSION;
|
|
31
|
+
kind: "start_turn";
|
|
32
|
+
requestId: string;
|
|
33
|
+
turnId: string;
|
|
34
|
+
slot?: number;
|
|
35
|
+
agentId: string;
|
|
36
|
+
wakeId: string;
|
|
37
|
+
prompt: string;
|
|
38
|
+
mcpEndpoint: string;
|
|
39
|
+
limits?: EngineBrokerTurnLimitOverrides;
|
|
40
|
+
processClock?: string;
|
|
41
|
+
}> | Readonly<{
|
|
42
|
+
version: typeof VERSION;
|
|
43
|
+
kind: "cancel_turn";
|
|
44
|
+
requestId: string;
|
|
45
|
+
turnId: string;
|
|
46
|
+
}> | Readonly<{
|
|
47
|
+
version: typeof VERSION;
|
|
48
|
+
kind: "reset_slot";
|
|
49
|
+
requestId: string;
|
|
50
|
+
slot: number;
|
|
51
|
+
}> | EngineBrokerInferenceRequest;
|
|
52
|
+
/**
|
|
53
|
+
* `reason` is the worker's own last words (`engineBrokerNativeClient.ts`),
|
|
54
|
+
* already redacted and flattened to one bounded line by the broker. It is the
|
|
55
|
+
* only field a failed turn carries that the worker itself wrote, so it is
|
|
56
|
+
* optional, bounded, control-character free, and admitted only for the
|
|
57
|
+
* statuses where a worker actually ran and spoke.
|
|
58
|
+
*/
|
|
59
|
+
export interface EngineBrokerFailureDiagnostic {
|
|
60
|
+
status: string;
|
|
61
|
+
stage: string;
|
|
62
|
+
failureClass: string;
|
|
63
|
+
profileApplied: boolean;
|
|
64
|
+
reason?: string;
|
|
65
|
+
exitCode: number;
|
|
66
|
+
termSignal: number;
|
|
67
|
+
workerPid: number;
|
|
68
|
+
workerUid: number;
|
|
69
|
+
startTicks: string;
|
|
70
|
+
}
|
|
71
|
+
export declare const ENGINE_BROKER_MAX_DIAGNOSTIC_REASON_BYTES = 768;
|
|
72
|
+
/** Operational state after sealing; never raw filesystem errors or worker text. */
|
|
73
|
+
export declare const ENGINE_BROKER_TASK_CLOCK_RESET_FAILED = "task clock reset failed; slot fenced until restart";
|
|
74
|
+
export type EngineBrokerCleanupObservation = Readonly<{
|
|
75
|
+
cleanupDiagnostic?: typeof ENGINE_BROKER_TASK_CLOCK_RESET_FAILED;
|
|
76
|
+
}>;
|
|
77
|
+
export type EngineBrokerResponse = Readonly<{
|
|
78
|
+
version: typeof VERSION;
|
|
79
|
+
kind: "ready";
|
|
80
|
+
requestId: string;
|
|
81
|
+
brokerUid: 2100;
|
|
82
|
+
providerProxyPort: 43123;
|
|
83
|
+
mcpFacadePort: 43124;
|
|
84
|
+
registrations: number;
|
|
85
|
+
credentialStale: false;
|
|
86
|
+
realmLease: true;
|
|
87
|
+
workerIsolation: true;
|
|
88
|
+
}> | Readonly<{
|
|
89
|
+
version: typeof VERSION;
|
|
90
|
+
kind: "accepted";
|
|
91
|
+
requestId: string;
|
|
92
|
+
turnId: string;
|
|
93
|
+
}> | (Readonly<{
|
|
94
|
+
version: typeof VERSION;
|
|
95
|
+
kind: "completed";
|
|
96
|
+
requestId: string;
|
|
97
|
+
turnId: string;
|
|
98
|
+
text: string;
|
|
99
|
+
workerPid: number;
|
|
100
|
+
workerUid: number;
|
|
101
|
+
workerStartTime: string;
|
|
102
|
+
}> & EngineBrokerTurnAccounting & BrokerClockObservation & EngineBrokerCleanupObservation) | (Readonly<{
|
|
103
|
+
version: typeof VERSION;
|
|
104
|
+
kind: "failed";
|
|
105
|
+
requestId: string;
|
|
106
|
+
turnId: string;
|
|
107
|
+
code: EngineBrokerFailureCode;
|
|
108
|
+
diagnostic?: EngineBrokerFailureDiagnostic;
|
|
109
|
+
mcpCalls?: EngineBrokerMcpCallObservation;
|
|
110
|
+
}> & EngineBrokerTurnAccounting & BrokerClockObservation & EngineBrokerCleanupObservation) | Readonly<{
|
|
111
|
+
version: typeof VERSION;
|
|
112
|
+
kind: "slot_reset";
|
|
113
|
+
requestId: string;
|
|
114
|
+
slot: number;
|
|
115
|
+
}> | EngineBrokerInferenceResponse;
|
|
116
|
+
/**
|
|
117
|
+
* The one name for a fenced credential realm. The turn's failure code, the
|
|
118
|
+
* proxy's refusal reason on a worker request, and the grant path's 401 body
|
|
119
|
+
* (`GROK_INFERENCE_AUTH_STALE_BODY`) all say this same word, so an operator
|
|
120
|
+
* greps one string across every surface instead of three spellings of it.
|
|
121
|
+
*/
|
|
122
|
+
export declare const ENGINE_BROKER_AUTH_STALE: "auth_stale";
|
|
123
|
+
export declare const ENGINE_BROKER_FAILURE_CODES: readonly ["auth_stale", "cancelled", "engine_failed", "invalid_request", "limit_exceeded", "turn_conflict", "unavailable"];
|
|
124
|
+
export type EngineBrokerFailureCode = (typeof ENGINE_BROKER_FAILURE_CODES)[number];
|
|
125
|
+
export type EngineBrokerTerminalResponse = Extract<EngineBrokerResponse, {
|
|
126
|
+
kind: "completed" | "failed";
|
|
127
|
+
}>;
|
|
128
|
+
type V1Completed = Readonly<{
|
|
129
|
+
version: typeof V1;
|
|
130
|
+
kind: "completed";
|
|
131
|
+
requestId: string;
|
|
132
|
+
turnId: string;
|
|
133
|
+
text: string;
|
|
134
|
+
workerPid: number;
|
|
135
|
+
workerUid: number;
|
|
136
|
+
workerStartTime: string;
|
|
137
|
+
}>;
|
|
138
|
+
type V1Failed = Readonly<{
|
|
139
|
+
version: typeof V1;
|
|
140
|
+
kind: "failed";
|
|
141
|
+
requestId: string;
|
|
142
|
+
turnId: string;
|
|
143
|
+
code: Exclude<EngineBrokerFailureCode, "limit_exceeded">;
|
|
144
|
+
diagnostic?: EngineBrokerFailureDiagnostic;
|
|
145
|
+
}>;
|
|
146
|
+
export type EngineBrokerV1TerminalResponse = V1Completed | V1Failed;
|
|
147
|
+
export declare function parseEngineBrokerRequest(value: unknown): EngineBrokerRequest;
|
|
148
|
+
export declare function parseEngineBrokerResponse(value: unknown): EngineBrokerResponse;
|
|
149
|
+
/**
|
|
150
|
+
* A terminal response persisted by a pre-v2 broker: the v1 field sets exactly,
|
|
151
|
+
* with no accounting. Accepted only from the durable turn registry, never from
|
|
152
|
+
* the wire.
|
|
153
|
+
*/
|
|
154
|
+
export declare function parseEngineBrokerV1TerminalResponse(value: unknown): EngineBrokerV1TerminalResponse;
|
|
155
|
+
export declare function parseEngineBrokerSlot(value: unknown): number;
|
|
156
|
+
/** v3 survives only in durable records. */
|
|
157
|
+
export declare function parseEngineBrokerV3TerminalResponse(value: unknown): EngineBrokerTerminalResponse;
|
|
158
|
+
/** v2 survives only in durable records. The wire always refuses it. */
|
|
159
|
+
export declare function parseEngineBrokerV2TerminalResponse(value: unknown): EngineBrokerTerminalResponse;
|
|
160
|
+
export declare function encodeEngineBrokerFrame(value: EngineBrokerRequest | EngineBrokerResponse | EngineBrokerProtocolDiagnostic): Buffer;
|
|
161
|
+
export declare class EngineBrokerFrameDecoder {
|
|
162
|
+
private buffered;
|
|
163
|
+
push(chunk: Uint8Array): unknown[];
|
|
164
|
+
finish(): void;
|
|
165
|
+
}
|
|
166
|
+
export {};
|
|
167
|
+
//# sourceMappingURL=engineBrokerProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerProtocol.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEhG,OAAO,EAAkJ,KAAK,4BAA4B,EAAE,KAAK,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAC3Q,OAAO,EAAmI,KAAK,8BAA8B,EAAiF,MAAM,6BAA6B,CAAC;AAClS,OAAO,EAAwE,KAAK,0BAA0B,EAAE,KAAK,8BAA8B,EAAE,MAAM,iCA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G,OAAO,EAAE;IAYlC,MAAM,IAAI,IAAI;CACf"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { parseBrokerProcessClock } from "./grokBrokerTaskClock.js";
|
|
2
|
+
import { parseGrokBrokerProviderClockObservation } from "./grokBrokerProviderClock.js";
|
|
3
|
+
import { isEngineBrokerInferenceRequestKind, isEngineBrokerInferenceResponseKind, parseEngineBrokerInferenceRequest, parseEngineBrokerInferenceResponse } from "./engineBrokerInferenceProtocol.js";
|
|
4
|
+
import { ENGINE_BROKER_MCP_CALL_NAME, ENGINE_BROKER_MCP_OUTSTANDING_MAX, ENGINE_BROKER_MCP_REFUSAL_REASONS, ENGINE_BROKER_MCP_TUNNEL_MAX } from "./engineBrokerMcpCallLog.js";
|
|
5
|
+
import { parseEngineBrokerTurnAccounting, parseEngineBrokerTurnLimitOverrides } from "./engineBrokerTurnAccounting.js";
|
|
6
|
+
/**
|
|
7
|
+
* Control protocol v4 adds slot routing and reset. Both ends ship in the same
|
|
8
|
+
* package; v1/v2/v3 frames are refused on the wire. Durable terminal adapters
|
|
9
|
+
* retain those record formats. A missing slot is allowed only for a unique
|
|
10
|
+
* agent registration (unclocked production compatibility).
|
|
11
|
+
*/
|
|
12
|
+
const VERSION = "noopolis.daimon.engine-broker.v4";
|
|
13
|
+
export const ENGINE_BROKER_VERSION = VERSION;
|
|
14
|
+
const V1 = "noopolis.daimon.engine-broker.v1";
|
|
15
|
+
export const ENGINE_BROKER_MAX_FRAME_BYTES = 1_048_576;
|
|
16
|
+
const PROTOCOL_NAME = /^noopolis\.daimon\.engine-broker\.v[0-9]{1,6}$/u;
|
|
17
|
+
const boundedProtocol = (value) => typeof value === "string" && PROTOCOL_NAME.test(value) ? value : "<invalid>";
|
|
18
|
+
export class EngineBrokerProtocolMismatch extends TypeError {
|
|
19
|
+
diagnostic;
|
|
20
|
+
constructor(received, expected = VERSION) {
|
|
21
|
+
const receivedVersion = boundedProtocol(received);
|
|
22
|
+
const expectedVersion = boundedProtocol(expected);
|
|
23
|
+
super(`invalid broker frame: protocol version mismatch (received ${receivedVersion}; expected ${expectedVersion})`);
|
|
24
|
+
this.diagnostic = { kind: "protocol_mismatch", receivedVersion, expectedVersion };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
28
|
+
export const ENGINE_BROKER_MAX_DIAGNOSTIC_REASON_BYTES = 768;
|
|
29
|
+
/** Operational state after sealing; never raw filesystem errors or worker text. */
|
|
30
|
+
export const ENGINE_BROKER_TASK_CLOCK_RESET_FAILED = "task clock reset failed; slot fenced until restart";
|
|
31
|
+
/**
|
|
32
|
+
* The one name for a fenced credential realm. The turn's failure code, the
|
|
33
|
+
* proxy's refusal reason on a worker request, and the grant path's 401 body
|
|
34
|
+
* (`GROK_INFERENCE_AUTH_STALE_BODY`) all say this same word, so an operator
|
|
35
|
+
* greps one string across every surface instead of three spellings of it.
|
|
36
|
+
*/
|
|
37
|
+
export const ENGINE_BROKER_AUTH_STALE = "auth_stale";
|
|
38
|
+
export const ENGINE_BROKER_FAILURE_CODES = [ENGINE_BROKER_AUTH_STALE, "cancelled", "engine_failed", "invalid_request", "limit_exceeded", "turn_conflict", "unavailable"];
|
|
39
|
+
const ACCOUNTING = ["outcome", "usage", "model", "requests", "limitReason"];
|
|
40
|
+
const record = (value) => {
|
|
41
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null))
|
|
42
|
+
throw new TypeError("invalid broker frame");
|
|
43
|
+
return value;
|
|
44
|
+
};
|
|
45
|
+
const exact = (value, fields) => {
|
|
46
|
+
if (Object.keys(value).length !== fields.length || fields.some((field) => !Object.hasOwn(value, field)))
|
|
47
|
+
throw new TypeError("invalid broker frame");
|
|
48
|
+
};
|
|
49
|
+
const text = (value, maxBytes) => {
|
|
50
|
+
if (typeof value !== "string" || value.length === 0 || Buffer.byteLength(value, "utf8") > maxBytes)
|
|
51
|
+
throw new TypeError("invalid broker frame");
|
|
52
|
+
return value;
|
|
53
|
+
};
|
|
54
|
+
const id = (value) => { const result = text(value, 128); if (!ID.test(result))
|
|
55
|
+
throw new TypeError("invalid broker frame"); return result; };
|
|
56
|
+
const version = (value) => {
|
|
57
|
+
if (value !== VERSION)
|
|
58
|
+
throw new EngineBrokerProtocolMismatch(value);
|
|
59
|
+
return VERSION;
|
|
60
|
+
};
|
|
61
|
+
export function parseEngineBrokerRequest(value) {
|
|
62
|
+
const input = record(value);
|
|
63
|
+
version(input.version);
|
|
64
|
+
if (input.kind === "health") {
|
|
65
|
+
exact(input, ["version", "kind", "requestId"]);
|
|
66
|
+
return { version: VERSION, kind: "health", requestId: id(input.requestId) };
|
|
67
|
+
}
|
|
68
|
+
if (input.kind === "start_turn") {
|
|
69
|
+
const fields = ["version", "kind", "requestId", "turnId", "agentId", "wakeId", "prompt", "mcpEndpoint"];
|
|
70
|
+
exact(input, [...fields, ...(input.slot === undefined ? [] : ["slot"]), ...(input.limits === undefined ? [] : ["limits"]), ...(input.processClock === undefined ? [] : ["processClock"])]);
|
|
71
|
+
let processClock;
|
|
72
|
+
if (input.processClock !== undefined) {
|
|
73
|
+
try {
|
|
74
|
+
processClock = parseBrokerProcessClock(input.processClock);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new TypeError("invalid broker frame");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const mcpEndpoint = text(input.mcpEndpoint, 2048);
|
|
81
|
+
const url = new URL(mcpEndpoint);
|
|
82
|
+
if (url.protocol !== "http:" || url.hostname !== "127.0.0.1" || url.pathname !== "/mcp")
|
|
83
|
+
throw new TypeError("invalid broker frame");
|
|
84
|
+
let limits;
|
|
85
|
+
if (input.limits !== undefined) {
|
|
86
|
+
try {
|
|
87
|
+
limits = parseEngineBrokerTurnLimitOverrides(input.limits);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw new TypeError("invalid broker frame");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { version: VERSION, kind: "start_turn", ...(input.slot === undefined ? {} : { slot: parseEngineBrokerSlot(input.slot) }), requestId: id(input.requestId), turnId: id(input.turnId), agentId: id(input.agentId), wakeId: id(input.wakeId), prompt: text(input.prompt, 65_536), mcpEndpoint, ...(limits === undefined ? {} : { limits }), ...(processClock === undefined ? {} : { processClock }) };
|
|
94
|
+
}
|
|
95
|
+
if (input.kind === "reset_slot") {
|
|
96
|
+
exact(input, ["version", "kind", "requestId", "slot"]);
|
|
97
|
+
return { version: VERSION, kind: "reset_slot", requestId: id(input.requestId), slot: parseEngineBrokerSlot(input.slot) };
|
|
98
|
+
}
|
|
99
|
+
if (input.kind === "cancel_turn") {
|
|
100
|
+
exact(input, ["version", "kind", "requestId", "turnId"]);
|
|
101
|
+
return { version: VERSION, kind: "cancel_turn", requestId: id(input.requestId), turnId: id(input.turnId) };
|
|
102
|
+
}
|
|
103
|
+
if (isEngineBrokerInferenceRequestKind(input.kind))
|
|
104
|
+
return parseEngineBrokerInferenceRequest(input, id(input.requestId), VERSION);
|
|
105
|
+
throw new TypeError("invalid broker frame");
|
|
106
|
+
}
|
|
107
|
+
export function parseEngineBrokerResponse(value) {
|
|
108
|
+
const input = record(value);
|
|
109
|
+
if (input.kind === "protocol_mismatch") {
|
|
110
|
+
exact(input, ["kind", "receivedVersion", "expectedVersion"]);
|
|
111
|
+
for (const field of [input.receivedVersion, input.expectedVersion]) {
|
|
112
|
+
if (field !== "<invalid>" && boundedProtocol(field) !== field)
|
|
113
|
+
throw new TypeError("invalid broker frame");
|
|
114
|
+
}
|
|
115
|
+
throw new EngineBrokerProtocolMismatch(input.receivedVersion, input.expectedVersion);
|
|
116
|
+
}
|
|
117
|
+
version(input.version);
|
|
118
|
+
if (input.kind === "ready") {
|
|
119
|
+
exact(input, ["version", "kind", "requestId", "brokerUid", "providerProxyPort", "mcpFacadePort", "registrations", "credentialStale", "realmLease", "workerIsolation"]);
|
|
120
|
+
if (input.brokerUid !== 2100 || input.providerProxyPort !== 43123 || input.mcpFacadePort !== 43124 || !Number.isSafeInteger(input.registrations) || input.registrations < 1 || input.credentialStale !== false || input.realmLease !== true || input.workerIsolation !== true)
|
|
121
|
+
throw new TypeError("invalid broker frame");
|
|
122
|
+
return { version: VERSION, kind: "ready", requestId: id(input.requestId), brokerUid: 2100, providerProxyPort: 43123, mcpFacadePort: 43124, registrations: input.registrations, credentialStale: false, realmLease: true, workerIsolation: true };
|
|
123
|
+
}
|
|
124
|
+
if (input.kind === "slot_reset") {
|
|
125
|
+
exact(input, ["version", "kind", "requestId", "slot"]);
|
|
126
|
+
return { version: VERSION, kind: "slot_reset", requestId: id(input.requestId), slot: parseEngineBrokerSlot(input.slot) };
|
|
127
|
+
}
|
|
128
|
+
if (input.kind === "accepted") {
|
|
129
|
+
exact(input, ["version", "kind", "requestId", "turnId"]);
|
|
130
|
+
return { version: VERSION, kind: "accepted", requestId: id(input.requestId), turnId: id(input.turnId) };
|
|
131
|
+
}
|
|
132
|
+
if (input.kind === "completed" || input.kind === "failed")
|
|
133
|
+
return parseTerminal(input, VERSION);
|
|
134
|
+
if (isEngineBrokerInferenceResponseKind(input.kind))
|
|
135
|
+
return parseEngineBrokerInferenceResponse(input, id(input.requestId), VERSION);
|
|
136
|
+
throw new TypeError("invalid broker frame");
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A terminal response persisted by a pre-v2 broker: the v1 field sets exactly,
|
|
140
|
+
* with no accounting. Accepted only from the durable turn registry, never from
|
|
141
|
+
* the wire.
|
|
142
|
+
*/
|
|
143
|
+
export function parseEngineBrokerV1TerminalResponse(value) {
|
|
144
|
+
const input = record(value);
|
|
145
|
+
if (input.version !== V1 || (input.kind !== "completed" && input.kind !== "failed"))
|
|
146
|
+
throw new TypeError("invalid broker frame");
|
|
147
|
+
return parseTerminal(input, V1);
|
|
148
|
+
}
|
|
149
|
+
export function parseEngineBrokerSlot(value) {
|
|
150
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
151
|
+
throw new TypeError("invalid broker slot");
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
/** v3 survives only in durable records. */
|
|
155
|
+
export function parseEngineBrokerV3TerminalResponse(value) {
|
|
156
|
+
const input = record(value);
|
|
157
|
+
if (input.version !== "noopolis.daimon.engine-broker.v3" || (input.kind !== "completed" && input.kind !== "failed"))
|
|
158
|
+
throw new TypeError("invalid broker frame");
|
|
159
|
+
return parseTerminal({ ...input, version: VERSION }, VERSION);
|
|
160
|
+
}
|
|
161
|
+
/** v2 survives only in durable records. The wire always refuses it. */
|
|
162
|
+
export function parseEngineBrokerV2TerminalResponse(value) {
|
|
163
|
+
const input = record(value);
|
|
164
|
+
if (input.version !== "noopolis.daimon.engine-broker.v2" ||
|
|
165
|
+
(input.kind !== "completed" && input.kind !== "failed") ||
|
|
166
|
+
Object.hasOwn(input, "shellClock") || Object.hasOwn(input, "providerClock") ||
|
|
167
|
+
Object.hasOwn(input, "cleanupDiagnostic")) {
|
|
168
|
+
throw new TypeError("invalid broker frame");
|
|
169
|
+
}
|
|
170
|
+
return parseTerminal({ ...input, version: VERSION }, VERSION);
|
|
171
|
+
}
|
|
172
|
+
function parseTerminal(input, expected) {
|
|
173
|
+
const accounting = expected === VERSION ? ACCOUNTING : [];
|
|
174
|
+
const shellClock = input.shellClock;
|
|
175
|
+
if (shellClock !== undefined && (expected !== VERSION || !["task", "real", "gap"].includes(shellClock)))
|
|
176
|
+
throw new TypeError("invalid broker frame");
|
|
177
|
+
if (input.providerClock !== undefined && expected !== VERSION)
|
|
178
|
+
throw new TypeError("invalid broker frame");
|
|
179
|
+
const cleanupDiagnostic = input.cleanupDiagnostic;
|
|
180
|
+
if (cleanupDiagnostic !== undefined &&
|
|
181
|
+
(expected !== VERSION || cleanupDiagnostic !== ENGINE_BROKER_TASK_CLOCK_RESET_FAILED)) {
|
|
182
|
+
throw new TypeError("invalid broker frame");
|
|
183
|
+
}
|
|
184
|
+
const observation = {
|
|
185
|
+
...(cleanupDiagnostic === undefined ? {} : { cleanupDiagnostic }),
|
|
186
|
+
...(shellClock === undefined ? {} : { shellClock: shellClock }),
|
|
187
|
+
...(input.providerClock === undefined ? {} : {
|
|
188
|
+
providerClock: parseGrokBrokerProviderClockObservation(input.providerClock)
|
|
189
|
+
})
|
|
190
|
+
};
|
|
191
|
+
const clockFields = Object.keys(observation);
|
|
192
|
+
if (input.kind === "completed") {
|
|
193
|
+
exact(input, ["version", "kind", "requestId", "turnId", "text", "workerPid", "workerUid", "workerStartTime", ...accounting, ...clockFields]);
|
|
194
|
+
if (!Number.isSafeInteger(input.workerPid) || input.workerPid < 1 || !Number.isSafeInteger(input.workerUid) || input.workerUid < 1)
|
|
195
|
+
throw new TypeError("invalid broker frame");
|
|
196
|
+
const base = { kind: "completed", requestId: id(input.requestId), turnId: id(input.turnId), text: text(input.text, 262_144), workerPid: input.workerPid, workerUid: input.workerUid, workerStartTime: id(input.workerStartTime) };
|
|
197
|
+
return expected === VERSION ? { version: VERSION, ...base, ...observation, ...parseEngineBrokerTurnAccounting(input, "completed") } : { version: V1, ...base };
|
|
198
|
+
}
|
|
199
|
+
// `mcpCalls` is the broker's own observation of the worker's tool calls
|
|
200
|
+
// (`engineBrokerMcpCallLog.ts`), additive in v2 and never part of a v1
|
|
201
|
+
// record, which predates the instrument entirely.
|
|
202
|
+
if (expected === V1 && input.mcpCalls !== undefined)
|
|
203
|
+
throw new TypeError("invalid broker frame");
|
|
204
|
+
const fields = ["version", "kind", "requestId", "turnId", "code", ...accounting, ...clockFields, ...(input.diagnostic === undefined ? [] : ["diagnostic"]), ...(input.mcpCalls === undefined ? [] : ["mcpCalls"])];
|
|
205
|
+
exact(input, fields);
|
|
206
|
+
const codes = expected === VERSION ? ENGINE_BROKER_FAILURE_CODES : ENGINE_BROKER_FAILURE_CODES.filter((code) => code !== "limit_exceeded");
|
|
207
|
+
if (!codes.includes(input.code))
|
|
208
|
+
throw new TypeError("invalid broker frame");
|
|
209
|
+
let diagnostic;
|
|
210
|
+
if (input.diagnostic !== undefined) {
|
|
211
|
+
const value = record(input.diagnostic);
|
|
212
|
+
const fields = ["status", "stage", "failureClass", "profileApplied", "exitCode", "termSignal", "workerPid", "workerUid", "startTicks"];
|
|
213
|
+
exact(value, value.reason === undefined ? fields : [...fields, "reason"]);
|
|
214
|
+
if (value.reason !== undefined && (typeof value.reason !== "string" || value.reason.length === 0 || Buffer.byteLength(value.reason, "utf8") > ENGINE_BROKER_MAX_DIAGNOSTIC_REASON_BYTES || /[\u0000-\u001f\u007f]/u.test(value.reason)))
|
|
215
|
+
throw new TypeError("invalid broker frame");
|
|
216
|
+
const status = ["prelaunch_failed", "worker_failed", "output_failed", "cancelled"], stage = ["peer", "request", "registration", "executable", "exec", "wait", "output", "attestation"], failureClass = ["peer", "protocol", "registration", "executable", "exec", "wait", "output_limit", "cancelled", "profile_missing", "profile_invalid"];
|
|
217
|
+
if (!status.includes(value.status) || !stage.includes(value.stage) || !failureClass.includes(value.failureClass) || typeof value.profileApplied !== "boolean" || ![value.exitCode, value.termSignal, value.workerPid, value.workerUid].every(Number.isSafeInteger) || typeof value.startTicks !== "string" || !/^(0|[1-9][0-9]*)$/u.test(value.startTicks) || !closedDiagnostic(value))
|
|
218
|
+
throw new TypeError("invalid broker frame");
|
|
219
|
+
diagnostic = value;
|
|
220
|
+
}
|
|
221
|
+
const base = { kind: "failed", requestId: id(input.requestId), turnId: id(input.turnId), code: input.code, ...(diagnostic ? { diagnostic } : {}) };
|
|
222
|
+
if (expected === V1)
|
|
223
|
+
return { version: V1, ...base };
|
|
224
|
+
const accountingValue = parseEngineBrokerTurnAccounting(input, "failed");
|
|
225
|
+
if ((input.code === "limit_exceeded") !== (accountingValue.limitReason !== "none"))
|
|
226
|
+
throw new TypeError("invalid broker frame");
|
|
227
|
+
const mcpCalls = input.mcpCalls === undefined ? undefined : parseMcpCallObservation(input.mcpCalls);
|
|
228
|
+
return { version: VERSION, ...base, ...observation, ...(mcpCalls === undefined ? {} : { mcpCalls }), ...accountingValue };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Names and timings, bounded, and internally consistent: a report can never
|
|
232
|
+
* claim more answered calls than started ones, nor more outstanding ones than
|
|
233
|
+
* started minus answered. Every count is its own measurement, so a missing
|
|
234
|
+
* field is refused rather than defaulted — a zero the broker did not measure
|
|
235
|
+
* would read exactly like one it did.
|
|
236
|
+
*/
|
|
237
|
+
function parseMcpCallObservation(value) {
|
|
238
|
+
const input = record(value);
|
|
239
|
+
// `tunnels` is optional for one reason only: a turn sealed before the GET
|
|
240
|
+
// tunnel was observed carries no such member, and its record must still
|
|
241
|
+
// replay. Absence there means "the instrument did not exist", never zero.
|
|
242
|
+
exact(input, ["started", "answered", "undecoded", "outstanding", ...(input.tunnels === undefined ? [] : ["tunnels"]), ...(input.refusals === undefined ? [] : ["refusals"])]);
|
|
243
|
+
const started = input.started, answered = input.answered, undecoded = input.undecoded;
|
|
244
|
+
if (![started, answered, undecoded].every((count) => Number.isSafeInteger(count) && count >= 0))
|
|
245
|
+
throw new TypeError("invalid broker frame");
|
|
246
|
+
if (!Array.isArray(input.outstanding) || input.outstanding.length > ENGINE_BROKER_MCP_OUTSTANDING_MAX)
|
|
247
|
+
throw new TypeError("invalid broker frame");
|
|
248
|
+
const outstanding = input.outstanding.map((entry) => {
|
|
249
|
+
const call = record(entry);
|
|
250
|
+
exact(call, ["name", "outstandingMs"]);
|
|
251
|
+
if (typeof call.name !== "string" || !ENGINE_BROKER_MCP_CALL_NAME.test(call.name))
|
|
252
|
+
throw new TypeError("invalid broker frame");
|
|
253
|
+
if (!Number.isSafeInteger(call.outstandingMs) || call.outstandingMs < 0)
|
|
254
|
+
throw new TypeError("invalid broker frame");
|
|
255
|
+
return { name: call.name, outstandingMs: call.outstandingMs };
|
|
256
|
+
});
|
|
257
|
+
if (answered > started || outstanding.length > started - answered)
|
|
258
|
+
throw new TypeError("invalid broker frame");
|
|
259
|
+
const tunnels = input.tunnels === undefined ? undefined : parseMcpTunnelObservation(input.tunnels);
|
|
260
|
+
const refusals = input.refusals === undefined ? undefined : parseMcpRefusalObservation(input.refusals);
|
|
261
|
+
return { started: started, answered: answered, undecoded: undecoded, outstanding, ...(tunnels === undefined ? {} : { tunnels }), ...(refusals === undefined ? {} : { refusals }) };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The refused requests, by reason class: one count per closed reason, all of
|
|
265
|
+
* them required once the member is present. Optional for the same single
|
|
266
|
+
* reason `tunnels` is — a turn sealed before the facade counted its refusals
|
|
267
|
+
* must still replay — so its absence means "not measured" and never zero, and
|
|
268
|
+
* a partial member is refused rather than zero-filled.
|
|
269
|
+
*/
|
|
270
|
+
function parseMcpRefusalObservation(value) {
|
|
271
|
+
const input = record(value);
|
|
272
|
+
exact(input, ENGINE_BROKER_MCP_REFUSAL_REASONS);
|
|
273
|
+
for (const reason of ENGINE_BROKER_MCP_REFUSAL_REASONS) {
|
|
274
|
+
if (!Number.isSafeInteger(input[reason]) || input[reason] < 0)
|
|
275
|
+
throw new TypeError("invalid broker frame");
|
|
276
|
+
}
|
|
277
|
+
return Object.fromEntries(ENGINE_BROKER_MCP_REFUSAL_REASONS.map((reason) => [reason, input[reason]]));
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The GET SSE tunnels, under the call observation's rules: counts and elapsed
|
|
281
|
+
* milliseconds, bounded, and internally consistent. A tunnel cannot close
|
|
282
|
+
* before it opened, cannot deliver without having opened, and no more can be
|
|
283
|
+
* reported open than `opened - closed` — a report claiming otherwise is a
|
|
284
|
+
* frame, not a measurement.
|
|
285
|
+
*/
|
|
286
|
+
function parseMcpTunnelObservation(value) {
|
|
287
|
+
const input = record(value);
|
|
288
|
+
exact(input, ["opened", "closed", "delivered", "open"]);
|
|
289
|
+
const opened = input.opened, closed = input.closed, delivered = input.delivered;
|
|
290
|
+
if (![opened, closed, delivered].every((count) => Number.isSafeInteger(count) && count >= 0))
|
|
291
|
+
throw new TypeError("invalid broker frame");
|
|
292
|
+
if (closed > opened || delivered > opened)
|
|
293
|
+
throw new TypeError("invalid broker frame");
|
|
294
|
+
if (!Array.isArray(input.open) || input.open.length > ENGINE_BROKER_MCP_TUNNEL_MAX || input.open.length > opened - closed)
|
|
295
|
+
throw new TypeError("invalid broker frame");
|
|
296
|
+
const open = input.open.map((entry) => {
|
|
297
|
+
const tunnel = record(entry);
|
|
298
|
+
exact(tunnel, ["openMs", "delivered"]);
|
|
299
|
+
if (!Number.isSafeInteger(tunnel.openMs) || tunnel.openMs < 0 || typeof tunnel.delivered !== "boolean")
|
|
300
|
+
throw new TypeError("invalid broker frame");
|
|
301
|
+
return { openMs: tunnel.openMs, delivered: tunnel.delivered };
|
|
302
|
+
});
|
|
303
|
+
return { opened: opened, closed: closed, delivered: delivered, open };
|
|
304
|
+
}
|
|
305
|
+
function closedDiagnostic(value) {
|
|
306
|
+
if (value.profileApplied !== false || value.workerPid < 0 || value.workerUid < 0)
|
|
307
|
+
return false;
|
|
308
|
+
// Only a worker that ran and wrote something can have said why it failed:
|
|
309
|
+
// no prelaunch failure and no attestation refusal carries worker words.
|
|
310
|
+
if (value.reason !== undefined && !((value.status === "worker_failed" && value.stage === "wait") || value.status === "output_failed" || value.status === "cancelled"))
|
|
311
|
+
return false;
|
|
312
|
+
const noWorker = value.workerPid === 0 && value.workerUid === 0 && value.startTicks === "0";
|
|
313
|
+
const worker = value.workerPid > 0 && value.workerUid >= 2200 && value.startTicks !== "0";
|
|
314
|
+
if (value.status === "prelaunch_failed")
|
|
315
|
+
return noWorker && { peer: "peer", request: "protocol", registration: "registration", executable: "executable", exec: "exec" }[value.stage] === value.failureClass;
|
|
316
|
+
if (value.status === "worker_failed" && value.stage === "attestation")
|
|
317
|
+
return worker && (value.failureClass === "profile_missing" || value.failureClass === "profile_invalid");
|
|
318
|
+
if (value.status === "worker_failed")
|
|
319
|
+
return worker && value.stage === "wait" && (value.failureClass === "exec" || value.failureClass === "wait");
|
|
320
|
+
if (value.status === "output_failed")
|
|
321
|
+
return worker && value.stage === "output" && value.failureClass === "output_limit";
|
|
322
|
+
return value.status === "cancelled" && worker && value.stage === "wait" && value.failureClass === "cancelled";
|
|
323
|
+
}
|
|
324
|
+
export function encodeEngineBrokerFrame(value) {
|
|
325
|
+
const body = Buffer.from(JSON.stringify(value), "utf8");
|
|
326
|
+
if (body.length > ENGINE_BROKER_MAX_FRAME_BYTES)
|
|
327
|
+
throw new TypeError("invalid broker frame");
|
|
328
|
+
const frame = Buffer.allocUnsafe(body.length + 4);
|
|
329
|
+
frame.writeUInt32BE(body.length);
|
|
330
|
+
body.copy(frame, 4);
|
|
331
|
+
return frame;
|
|
332
|
+
}
|
|
333
|
+
export class EngineBrokerFrameDecoder {
|
|
334
|
+
buffered = Buffer.alloc(0);
|
|
335
|
+
push(chunk) {
|
|
336
|
+
this.buffered = Buffer.concat([this.buffered, chunk]);
|
|
337
|
+
const values = [];
|
|
338
|
+
while (this.buffered.length >= 4) {
|
|
339
|
+
const length = this.buffered.readUInt32BE(0);
|
|
340
|
+
if (length === 0 || length > ENGINE_BROKER_MAX_FRAME_BYTES)
|
|
341
|
+
throw new TypeError("invalid broker frame");
|
|
342
|
+
if (this.buffered.length < length + 4)
|
|
343
|
+
break;
|
|
344
|
+
const body = this.buffered.subarray(4, length + 4);
|
|
345
|
+
this.buffered = this.buffered.subarray(length + 4);
|
|
346
|
+
try {
|
|
347
|
+
values.push(JSON.parse(body.toString("utf8")));
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
throw new TypeError("invalid broker frame");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return values;
|
|
354
|
+
}
|
|
355
|
+
finish() { if (this.buffered.length !== 0)
|
|
356
|
+
throw new TypeError("incomplete broker frame"); }
|
|
357
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { EngineBrokerTerminalResponse } from "./engineBrokerProtocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* The operator-visible half of a sealed terminal turn, as a durable row.
|
|
4
|
+
*
|
|
5
|
+
* The seal itself already carries everything an operator needs to read a turn
|
|
6
|
+
* that stopped acting — the failure code, the worker's own redacted last words,
|
|
7
|
+
* and `engineBrokerMcpCallLog.ts`'s observation of the tool call the worker was
|
|
8
|
+
* blocked on. All of it travels in the control-protocol terminal response, and
|
|
9
|
+
* that response is the one artifact a *hung* turn never produces: the client is
|
|
10
|
+
* gone before the broker answers, the turn registry record lives in the
|
|
11
|
+
* broker's own `0700` turn store, and a training slot's control root is tmpfs
|
|
12
|
+
* that dies with the container. Six live runs reproduced the same signature and
|
|
13
|
+
* none of them could read the instrument built for it.
|
|
14
|
+
*
|
|
15
|
+
* What does survive a slot is the broker's ledger directory: Paideia already
|
|
16
|
+
* recovers `usage.jsonl` and `requests.jsonl` from it on the failure path. So
|
|
17
|
+
* this is a third stream beside those two, written by the broker — still the
|
|
18
|
+
* single sealed usage writer — from the sealed response and nothing else, at
|
|
19
|
+
* the moment that response is sealed.
|
|
20
|
+
*
|
|
21
|
+
* Its rules are the two ledgers' rules:
|
|
22
|
+
*
|
|
23
|
+
* - **Numbers, names, timings and closed vocabularies only.** The failure code,
|
|
24
|
+
* the accounting, the diagnostic's closed `status`/`stage`/`failure_class`
|
|
25
|
+
* and its already-redacted, already-bounded, control-character-free `reason`
|
|
26
|
+
* (`engineBrokerNativeClient.ts` produced it; nothing here re-derives it),
|
|
27
|
+
* plus tool-call names, GET-tunnel counts and elapsed milliseconds. Never a
|
|
28
|
+
* prompt, a body, a
|
|
29
|
+
* reply, a bearer, a capability or a session id — none of which the terminal
|
|
30
|
+
* response carries in the first place.
|
|
31
|
+
* - **Absence stays absence.** `mcp` is written only when the facade actually
|
|
32
|
+
* observed the turn, `diagnostic` only when the sealed response carried one,
|
|
33
|
+
* and `code` only for a failure. A turn that called no tool publishes
|
|
34
|
+
* `started: 0`, which is a measurement; a turn the facade never registered
|
|
35
|
+
* publishes no `mcp` member at all, which is not.
|
|
36
|
+
* - **It can never fail a turn.** The row is rendered from an
|
|
37
|
+
* already-validated frame and appended through `recordLedgerLines`, which
|
|
38
|
+
* swallows every I/O fault.
|
|
39
|
+
*
|
|
40
|
+
* A separate stream and a separate `v`, for `turnRequestLedger.ts`'s reason:
|
|
41
|
+
* Spawnfile's reader pins `noopolis.daimon.turn-usage.v1` and drops any other
|
|
42
|
+
* `v` outright, and Paideia's request reader refuses a row it cannot type. A
|
|
43
|
+
* row in a new file is invisible to both.
|
|
44
|
+
*/
|
|
45
|
+
export declare const TURN_SEAL_LEDGER_VERSION: "noopolis.daimon.turn-seal.v1";
|
|
46
|
+
/** Default location: beside `usage.jsonl` and `requests.jsonl`, no new mount. */
|
|
47
|
+
export declare const TURN_SEAL_LEDGER: {
|
|
48
|
+
readonly version: "noopolis.daimon.turn-seal.v1";
|
|
49
|
+
readonly directoryPath: "/var/lib/spawnfile/daimon/usage";
|
|
50
|
+
readonly filePath: "/var/lib/spawnfile/daimon/usage/turns.jsonl";
|
|
51
|
+
readonly rotatedFilePath: "/var/lib/spawnfile/daimon/usage/turns.jsonl.1";
|
|
52
|
+
readonly fileMode: 416;
|
|
53
|
+
};
|
|
54
|
+
/** A rendered seal line is bounded by its own contents: a 768-byte reason, 16 bounded names and 8 tunnel timings. */
|
|
55
|
+
export declare const TURN_SEAL_MAX_LINE_BYTES = 8192;
|
|
56
|
+
export type BrokerTurnSealEntry = Readonly<{
|
|
57
|
+
agent: string;
|
|
58
|
+
wake: string;
|
|
59
|
+
at: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* One newline-terminated row for one sealed terminal turn.
|
|
63
|
+
*
|
|
64
|
+
* Every member is copied from the terminal response the protocol already
|
|
65
|
+
* validated, so this projection cannot widen what the response admits; it is an
|
|
66
|
+
* allow-list rather than a spread, so a future additive member of the response
|
|
67
|
+
* does not silently become a ledger field.
|
|
68
|
+
*/
|
|
69
|
+
export declare const renderBrokerTurnSealLine: (terminal: EngineBrokerTerminalResponse, entry: BrokerTurnSealEntry) => string;
|
|
70
|
+
//# sourceMappingURL=engineBrokerSealLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerSealLedger.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerSealLedger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,wBAAwB,EAAG,8BAAuC,CAAC;AAEhF,iFAAiF;AACjF,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,qHAAqH;AACrH,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAIxF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,UAAU,4BAA4B,EAAE,OAAO,mBAAmB,KAAG,MAkExG,CAAC"}
|