@noopolis/daimon 0.1.1 → 0.2.0
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 +307 -45
- package/dist/contracts/attentionContract.d.ts +117 -0
- package/dist/contracts/attentionContract.d.ts.map +1 -0
- package/dist/contracts/attentionContract.js +14 -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/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 +765 -0
- package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
- package/dist/contracts/organizationRuntimeContract.js +121 -0
- package/dist/contracts/runtimeContractManifest.d.ts +1615 -0
- package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
- package/dist/contracts/runtimeContractManifest.js +181 -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/siblingBuildFreshness.d.ts +21 -0
- package/dist/core/siblingBuildFreshness.d.ts.map +1 -0
- package/dist/core/siblingBuildFreshness.js +25 -0
- package/dist/core/types.d.ts +10 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/examples/exampleCausalId.d.ts +3 -0
- package/dist/examples/exampleCausalId.d.ts.map +1 -0
- package/dist/examples/exampleCausalId.js +8 -0
- package/dist/examples/jungian-play-org.js +3 -2
- package/dist/examples/jungian-triad-org.js +3 -2
- package/dist/examples/jungianPlayAgent.d.ts +1 -1
- package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.js +1 -1
- package/dist/examples/jungianProfiles.d.ts +1 -1
- package/dist/examples/jungianProfiles.d.ts.map +1 -1
- package/dist/examples/jungianTriadProfiles.d.ts +1 -1
- package/dist/examples/jungianTriadProfiles.d.ts.map +1 -1
- package/dist/examples/pi-agent.js +3 -2
- package/dist/examples/pi-memory-org.js +6 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/mcp/toolServer.d.ts +31 -0
- package/dist/mcp/toolServer.d.ts.map +1 -0
- package/dist/mcp/toolServer.js +145 -0
- package/dist/observability/causalEvents.d.ts +118 -0
- package/dist/observability/causalEvents.d.ts.map +1 -0
- package/dist/observability/causalEvents.js +223 -0
- package/dist/observability/controlCausal.d.ts +117 -0
- package/dist/observability/controlCausal.d.ts.map +1 -0
- package/dist/observability/controlCausal.js +107 -0
- package/dist/observability/emitCausalFixture.d.ts +25 -0
- package/dist/observability/emitCausalFixture.d.ts.map +1 -0
- package/dist/observability/emitCausalFixture.js +98 -0
- package/dist/observability/index.d.ts +2 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +2 -0
- 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 +164 -0
- package/dist/pi/cliEnvironment.d.ts +12 -0
- package/dist/pi/cliEnvironment.d.ts.map +1 -0
- package/dist/pi/cliEnvironment.js +32 -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 +106 -0
- package/dist/pi/cliSession.d.ts.map +1 -0
- package/dist/pi/cliSession.js +379 -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/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 +57 -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/index.d.ts +5 -0
- package/dist/pi/index.d.ts.map +1 -1
- package/dist/pi/index.js +5 -0
- package/dist/pi/memoryTools.d.ts +55 -1
- package/dist/pi/memoryTools.d.ts.map +1 -1
- package/dist/pi/memoryTools.js +144 -24
- package/dist/pi/modelRegistry.d.ts +13 -0
- package/dist/pi/modelRegistry.d.ts.map +1 -0
- package/dist/pi/modelRegistry.js +19 -0
- package/dist/pi/piAgentHandle.d.ts +46 -0
- package/dist/pi/piAgentHandle.d.ts.map +1 -0
- package/dist/pi/piAgentHandle.js +351 -0
- package/dist/pi/piAgentWakeSupport.d.ts +103 -0
- package/dist/pi/piAgentWakeSupport.d.ts.map +1 -0
- package/dist/pi/piAgentWakeSupport.js +151 -0
- package/dist/pi/piHarness.d.ts +40 -5
- package/dist/pi/piHarness.d.ts.map +1 -1
- package/dist/pi/piHarness.js +151 -256
- package/dist/pi/prompts.d.ts +10 -0
- package/dist/pi/prompts.d.ts.map +1 -0
- package/dist/pi/prompts.js +63 -0
- package/dist/pi/rawTrainingCapture.d.ts +59 -0
- package/dist/pi/rawTrainingCapture.d.ts.map +1 -0
- package/dist/pi/rawTrainingCapture.js +175 -0
- package/dist/pi/turnCausal.d.ts +73 -0
- package/dist/pi/turnCausal.d.ts.map +1 -0
- package/dist/pi/turnCausal.js +75 -0
- package/dist/pi/turnTrace.d.ts +128 -0
- package/dist/pi/turnTrace.d.ts.map +1 -0
- package/dist/pi/turnTrace.js +138 -0
- package/dist/pi/wakeAcceptance.d.ts +49 -0
- package/dist/pi/wakeAcceptance.d.ts.map +1 -0
- package/dist/pi/wakeAcceptance.js +281 -0
- package/dist/pi/wakeAcceptanceFs.d.ts +44 -0
- package/dist/pi/wakeAcceptanceFs.d.ts.map +1 -0
- package/dist/pi/wakeAcceptanceFs.js +318 -0
- package/dist/pi/wakeAcceptanceSchema.d.ts +75 -0
- package/dist/pi/wakeAcceptanceSchema.d.ts.map +1 -0
- package/dist/pi/wakeAcceptanceSchema.js +265 -0
- package/dist/pi/wakeModes.d.ts +9 -0
- package/dist/pi/wakeModes.d.ts.map +1 -0
- package/dist/pi/wakeModes.js +19 -0
- package/dist/pi/worldNudge.d.ts +22 -0
- package/dist/pi/worldNudge.d.ts.map +1 -0
- package/dist/pi/worldNudge.js +62 -0
- package/dist/pi/worldToolProtocol.d.ts +13 -0
- package/dist/pi/worldToolProtocol.d.ts.map +1 -0
- package/dist/pi/worldToolProtocol.js +49 -0
- package/dist/pi/worldTools.d.ts +32 -0
- package/dist/pi/worldTools.d.ts.map +1 -0
- package/dist/pi/worldTools.js +373 -0
- package/dist/pi/worldTrajectory.d.ts +52 -0
- package/dist/pi/worldTrajectory.d.ts.map +1 -0
- package/dist/pi/worldTrajectory.js +131 -0
- 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 +21 -0
- package/dist/runtime/attention.d.ts.map +1 -0
- package/dist/runtime/attention.js +36 -0
- package/dist/runtime/attentionDispatcher.d.ts +66 -0
- package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
- package/dist/runtime/attentionDispatcher.js +271 -0
- package/dist/runtime/cli.d.ts +7 -0
- package/dist/runtime/cli.d.ts.map +1 -0
- package/dist/runtime/cli.js +251 -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 +30 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCapabilities.js +59 -0
- package/dist/runtime/engineBrokerControlClient.d.ts +44 -0
- package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
- package/dist/runtime/engineBrokerControlClient.js +132 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts +10 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCredentialJournal.js +17 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts +52 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts +160 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpCallLog.js +219 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts +56 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpFacade.js +343 -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 +135 -0
- package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerProtocol.js +274 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
- package/dist/runtime/engineBrokerSealLedger.js +123 -0
- package/dist/runtime/engineBrokerService.d.ts +37 -0
- package/dist/runtime/engineBrokerService.d.ts.map +1 -0
- package/dist/runtime/engineBrokerService.js +138 -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 +50 -0
- package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
- package/dist/runtime/engineBrokerServiceConfig.js +92 -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 +158 -0
- package/dist/runtime/engineDispatcher.d.ts +36 -0
- package/dist/runtime/engineDispatcher.d.ts.map +1 -0
- package/dist/runtime/engineDispatcher.js +216 -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 +22 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialAuthority.js +124 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts +5 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialReader.js +37 -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 +106 -0
- package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProjection.js +94 -0
- package/dist/runtime/grokBrokerProxy.d.ts +55 -0
- package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxy.js +262 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyRequest.js +74 -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/grokBrokerTurnMeter.d.ts +128 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTurnMeter.js +251 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts +86 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
- package/dist/runtime/grokBrokerWorkerConfig.js +135 -0
- package/dist/runtime/grokEngineBroker.d.ts +48 -0
- package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
- package/dist/runtime/grokEngineBroker.js +114 -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 +58 -0
- package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurn.js +165 -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 +82 -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 +170 -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 +30 -0
- package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerHomeAttestation.js +69 -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 +26 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +23 -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 +165 -0
- package/dist/runtime/organizationRuntime.d.ts.map +1 -0
- package/dist/runtime/organizationRuntime.js +3 -0
- package/dist/runtime/organizationRuntimeControl.d.ts +42 -0
- package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeControl.js +235 -0
- package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
- package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeHost.js +359 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeParsing.js +370 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeReadiness.js +59 -0
- package/dist/runtime/physicalReadiness.d.ts +47 -0
- package/dist/runtime/physicalReadiness.d.ts.map +1 -0
- package/dist/runtime/physicalReadiness.js +142 -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 +328 -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 +371 -0
- package/dist/runtime/storeCoordination.d.ts +23 -0
- package/dist/runtime/storeCoordination.d.ts.map +1 -0
- package/dist/runtime/storeCoordination.js +94 -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 +160 -0
- package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
- package/dist/runtime/turnRequestLedger.js +249 -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/wakeAcceptanceProcessIdentity.d.ts +17 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.js +50 -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 +23 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRecord.js +56 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts +12 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRetention.js +12 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceStore.js +558 -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 +69 -0
- package/dist/runtime/wakeFuse.d.ts.map +1 -0
- package/dist/runtime/wakeFuse.js +367 -0
- package/package.json +25 -17
- package/dist/examples/mixed-engine-org.d.ts +0 -2
- package/dist/examples/mixed-engine-org.d.ts.map +0 -1
- package/dist/examples/mixed-engine-org.js +0 -351
- package/dist/examples/mixedEngineCli.d.ts +0 -15
- package/dist/examples/mixedEngineCli.d.ts.map +0 -1
- package/dist/examples/mixedEngineCli.js +0 -174
|
@@ -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"],"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":"c07d22225ff968bc289e5ddf0981cdd5d64040eee6e3ea45da7d03e1439dea98","sourceSha256":"dd39aacfece496cc6528f6acdb4f1066a848a0fb5b0961f5c70b0ba00440dc24","x64Sha256":"67e3624d3198e9c59e1ffafa4eca7c895dfe265d5b8bb0614cb547b68b8b93a7"},"backendSocketPath":"/run/daimon-engine-broker/backend.sock","bounds":{"capabilityBundleBytes":8196,"capabilityBytes":4096,"outputBytes":262144,"promptBytes":65536},"controlProtocolVersion":"noopolis.daimon.engine-broker.v2","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.v1","providerProxy":{"host":"127.0.0.1","port":43123},"registrationPath":"/etc/daimon-engine-broker/registrations.bin","serviceConfigPath":"/etc/daimon-engine-broker/service.json","serviceConfigVersions":["noopolis.daimon.engine-broker-service.v1","noopolis.daimon.engine-broker-service.v2"],"slotPreflightVersion":"noopolis.daimon.grok-slot-preflight.v2","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":{"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","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"},"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"},"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"},"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.v3","wakeAcceptanceTypes":["manual","message","schedule","external"],"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"},"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:c672ed47e4a01a75f1482ea6e4b6ecb28205aab344741a10cad8783f5501b6c4
|
|
@@ -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,30 @@
|
|
|
1
|
+
export declare class EngineBrokerCapabilities {
|
|
2
|
+
private readonly grants;
|
|
3
|
+
issue(agentId: string, turnId: string, ttlMs?: number, maxRequests?: number): string;
|
|
4
|
+
authorize(agentId: string, turnId: string, token: string): boolean;
|
|
5
|
+
authorizeToken(token: string): Readonly<{
|
|
6
|
+
agentId: string;
|
|
7
|
+
turnId: string;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Which grant a token names and why it would be refused, *without* spending
|
|
11
|
+
* it.
|
|
12
|
+
*
|
|
13
|
+
* The facade needs this on its refusal path alone. A 403 it cannot attribute
|
|
14
|
+
* to a turn is a 403 that seals as nothing at all, and a turn whose every
|
|
15
|
+
* request was refused then reads exactly like a healthy one — the silence
|
|
16
|
+
* `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
|
|
17
|
+
* no turn and stays unattributed; nothing here returns the token, the grant
|
|
18
|
+
* or the agent's capability, only the turn id and a closed reason.
|
|
19
|
+
*/
|
|
20
|
+
classifyToken(token: string): Readonly<{
|
|
21
|
+
turnId: string;
|
|
22
|
+
state: "live" | "expired" | "exhausted";
|
|
23
|
+
}> | undefined;
|
|
24
|
+
inspectToken(token: string): Readonly<{
|
|
25
|
+
agentId: string;
|
|
26
|
+
turnId: string;
|
|
27
|
+
}> | undefined;
|
|
28
|
+
revoke(turnId: string): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=engineBrokerCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerCapabilities.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerCapabilities.ts"],"names":[],"mappings":"AAIA,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,59 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
export class EngineBrokerCapabilities {
|
|
3
|
+
grants = new Map();
|
|
4
|
+
issue(agentId, turnId, ttlMs = 15 * 60_000, maxRequests = 64) {
|
|
5
|
+
if (ttlMs < 1 || maxRequests < 1)
|
|
6
|
+
throw new TypeError("invalid broker capability policy");
|
|
7
|
+
const token = randomBytes(32).toString("base64url");
|
|
8
|
+
this.grants.set(turnId, { agentId, turnId, digest: hash(token), expiresAt: Date.now() + ttlMs, maxRequests, requests: 0 });
|
|
9
|
+
return token;
|
|
10
|
+
}
|
|
11
|
+
authorize(agentId, turnId, token) {
|
|
12
|
+
const grant = this.grants.get(turnId);
|
|
13
|
+
const candidate = hash(token);
|
|
14
|
+
if (grant === undefined || grant.agentId !== agentId || grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
|
|
15
|
+
return false;
|
|
16
|
+
grant.requests += 1;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
authorizeToken(token) {
|
|
20
|
+
const candidate = hash(token);
|
|
21
|
+
for (const grant of this.grants.values()) {
|
|
22
|
+
if (grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
|
|
23
|
+
continue;
|
|
24
|
+
grant.requests += 1;
|
|
25
|
+
return { agentId: grant.agentId, turnId: grant.turnId };
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Which grant a token names and why it would be refused, *without* spending
|
|
31
|
+
* it.
|
|
32
|
+
*
|
|
33
|
+
* The facade needs this on its refusal path alone. A 403 it cannot attribute
|
|
34
|
+
* to a turn is a 403 that seals as nothing at all, and a turn whose every
|
|
35
|
+
* request was refused then reads exactly like a healthy one — the silence
|
|
36
|
+
* `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
|
|
37
|
+
* no turn and stays unattributed; nothing here returns the token, the grant
|
|
38
|
+
* or the agent's capability, only the turn id and a closed reason.
|
|
39
|
+
*/
|
|
40
|
+
classifyToken(token) {
|
|
41
|
+
const candidate = hash(token);
|
|
42
|
+
for (const grant of this.grants.values()) {
|
|
43
|
+
if (!timingSafeEqual(grant.digest, candidate))
|
|
44
|
+
continue;
|
|
45
|
+
// Budget before expiry: the TTL outlives every declared turn limit, so an
|
|
46
|
+
// exhausted grant is the reachable refusal and the actionable answer.
|
|
47
|
+
if (grant.requests >= grant.maxRequests)
|
|
48
|
+
return { turnId: grant.turnId, state: "exhausted" };
|
|
49
|
+
return { turnId: grant.turnId, state: grant.expiresAt <= Date.now() ? "expired" : "live" };
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
inspectToken(token) { const candidate = hash(token); for (const grant of this.grants.values()) {
|
|
54
|
+
if (grant.expiresAt > Date.now() && grant.requests < grant.maxRequests && timingSafeEqual(grant.digest, candidate))
|
|
55
|
+
return { agentId: grant.agentId, turnId: grant.turnId };
|
|
56
|
+
} return undefined; }
|
|
57
|
+
revoke(turnId) { const grant = this.grants.get(turnId); grant?.digest.fill(0); this.grants.delete(turnId); }
|
|
58
|
+
}
|
|
59
|
+
const hash = (value) => createHash("sha256").update(value).digest();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { EngineBrokerInferenceFailureCode, EngineBrokerInferenceResponse } from "./engineBrokerInferenceProtocol.js";
|
|
2
|
+
import type { EngineBrokerTurnLimitOverrides } from "./engineBrokerTurnAccounting.js";
|
|
3
|
+
import type { GrokBrokerModel, GrokBrokerReasoningEffort } from "./grokBrokerModelPolicy.js";
|
|
4
|
+
import type { GrokInferencePurpose } from "./inferenceUsageLedger.js";
|
|
5
|
+
export type EngineBrokerInferenceGrant = Omit<Extract<EngineBrokerInferenceResponse, {
|
|
6
|
+
kind: "inference_grant";
|
|
7
|
+
}>, "version" | "kind" | "requestId">;
|
|
8
|
+
/** A refused grant request; `code` is closed (`auth_stale` is the stale shared realm, `grant_limit` the live-grant cap). */
|
|
9
|
+
export declare class EngineBrokerInferenceGrantRefused extends Error {
|
|
10
|
+
readonly code: EngineBrokerInferenceFailureCode;
|
|
11
|
+
constructor(code: EngineBrokerInferenceFailureCode);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What the organization runtime asks of a brokered turn beyond the prompt:
|
|
15
|
+
* `limits` may only lower the registration's declared limits, and `model`,
|
|
16
|
+
* when the agent declared one, must equal the model the broker sealed.
|
|
17
|
+
*/
|
|
18
|
+
export type EngineBrokerTurnOptions = Readonly<{
|
|
19
|
+
limits?: EngineBrokerTurnLimitOverrides;
|
|
20
|
+
model?: string;
|
|
21
|
+
}>;
|
|
22
|
+
export interface EngineBrokerTurnClient {
|
|
23
|
+
turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
export declare class EngineBrokerControlClient implements EngineBrokerTurnClient {
|
|
26
|
+
private readonly socketPath;
|
|
27
|
+
constructor(socketPath?: string);
|
|
28
|
+
ready(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Evaluator side (organization uid only; the native relay enforces it):
|
|
31
|
+
* borrow the broker credential for one sequential lane of judge or optimizer
|
|
32
|
+
* requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
|
|
33
|
+
* a broker that cannot answer rejects with `engine broker unavailable`.
|
|
34
|
+
*/
|
|
35
|
+
requestInferenceGrant(request: Readonly<{
|
|
36
|
+
model: GrokBrokerModel;
|
|
37
|
+
reasoningEffort: GrokBrokerReasoningEffort;
|
|
38
|
+
purpose: GrokInferencePurpose;
|
|
39
|
+
}>): Promise<EngineBrokerInferenceGrant>;
|
|
40
|
+
releaseInferenceGrant(grantId: string): Promise<boolean>;
|
|
41
|
+
private exchange;
|
|
42
|
+
turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=engineBrokerControlClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerControlClient.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerControlClient.ts"],"names":[],"mappings":"AAGA,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;AAetE,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;IAAE,MAAM,CAAC,EAAE,8BAA8B,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC5G,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;IAC1D,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,SAAyC;IAC1E,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAC3B;;;;;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;IAM5D,OAAO,CAAC,QAAQ;IACV,IAAI,CAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,WAAW,EAAC,MAAM,EAAC,MAAM,CAAC,EAAC,WAAW,EAAC,OAAO,GAAC,uBAA0B,GAAE,OAAO,CAAC,MAAM,CAAC;CAMjJ"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { createConnection } from "node:net";
|
|
3
|
+
import { ENGINE_BROKER_VERSION, encodeEngineBrokerFrame, EngineBrokerFrameDecoder, parseEngineBrokerResponse } 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
|
+
constructor(socketPath = "/run/daimon-engine-broker/control.sock") {
|
|
29
|
+
this.socketPath = socketPath;
|
|
30
|
+
}
|
|
31
|
+
async ready() { const requestId = randomUUID(), socket = createConnection({ path: this.socketPath }), decoder = new EngineBrokerFrameDecoder(); await new Promise((resolve, reject) => { let settled = false; const fail = () => { if (settled)
|
|
32
|
+
return; settled = true; socket.destroy(); reject(new Error("engine broker unavailable")); }; socket.once("error", fail); socket.once("close", fail); socket.once("connect", () => socket.write(encodeEngineBrokerFrame({ version: ENGINE_BROKER_VERSION, kind: "health", requestId }))); socket.on("data", (chunk) => { try {
|
|
33
|
+
for (const value of decoder.push(chunk)) {
|
|
34
|
+
const response = parseEngineBrokerResponse(value);
|
|
35
|
+
if (response.kind !== "ready" || response.requestId !== requestId || settled)
|
|
36
|
+
throw new Error();
|
|
37
|
+
settled = true;
|
|
38
|
+
socket.destroy();
|
|
39
|
+
resolve();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
fail();
|
|
44
|
+
} }); }); }
|
|
45
|
+
/**
|
|
46
|
+
* Evaluator side (organization uid only; the native relay enforces it):
|
|
47
|
+
* borrow the broker credential for one sequential lane of judge or optimizer
|
|
48
|
+
* requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
|
|
49
|
+
* a broker that cannot answer rejects with `engine broker unavailable`.
|
|
50
|
+
*/
|
|
51
|
+
async requestInferenceGrant(request) {
|
|
52
|
+
const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "request_inference_grant", requestId: randomUUID(), model: request.model, reasoningEffort: request.reasoningEffort, purpose: request.purpose });
|
|
53
|
+
if (response.kind === "inference_grant_refused")
|
|
54
|
+
throw new EngineBrokerInferenceGrantRefused(response.code);
|
|
55
|
+
if (response.kind !== "inference_grant" || response.model !== request.model || response.reasoningEffort !== request.reasoningEffort || response.purpose !== request.purpose)
|
|
56
|
+
throw new Error("engine broker unavailable");
|
|
57
|
+
const { version: _version, kind: _kind, requestId: _requestId, ...grant } = response;
|
|
58
|
+
return grant;
|
|
59
|
+
}
|
|
60
|
+
async releaseInferenceGrant(grantId) {
|
|
61
|
+
const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "release_inference_grant", requestId: randomUUID(), grantId });
|
|
62
|
+
if (response.kind === "inference_grant_refused")
|
|
63
|
+
throw new EngineBrokerInferenceGrantRefused(response.code);
|
|
64
|
+
if (response.kind !== "inference_grant_released" || response.grantId !== grantId)
|
|
65
|
+
throw new Error("engine broker unavailable");
|
|
66
|
+
return response.released;
|
|
67
|
+
}
|
|
68
|
+
exchange(request) { const socket = createConnection({ path: this.socketPath }), decoder = new EngineBrokerFrameDecoder(); return new Promise((resolve, reject) => { let settled = false; const fail = () => { if (settled)
|
|
69
|
+
return; settled = true; socket.destroy(); reject(new Error("engine broker unavailable")); }; socket.once("error", fail); socket.once("close", fail); socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request))); socket.on("data", (chunk) => { try {
|
|
70
|
+
for (const value of decoder.push(chunk)) {
|
|
71
|
+
const response = parseEngineBrokerResponse(value);
|
|
72
|
+
if (settled || response.requestId !== request.requestId || (response.kind !== "inference_grant" && response.kind !== "inference_grant_released" && response.kind !== "inference_grant_refused"))
|
|
73
|
+
throw new Error();
|
|
74
|
+
settled = true;
|
|
75
|
+
socket.destroy();
|
|
76
|
+
resolve(response);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
fail();
|
|
81
|
+
} }); }); }
|
|
82
|
+
async turn(agentId, wakeId, prompt, mcpEndpoint, signal, options = {}) {
|
|
83
|
+
const turnId = createHash("sha256").update(`${agentId}\0${wakeId}`).digest("hex"), requestId = randomUUID();
|
|
84
|
+
const request = { version: ENGINE_BROKER_VERSION, kind: "start_turn", requestId, turnId, agentId, wakeId, prompt, mcpEndpoint, ...(options.limits === undefined ? {} : { limits: options.limits }) };
|
|
85
|
+
const socket = createConnection({ path: this.socketPath });
|
|
86
|
+
const decoder = new EngineBrokerFrameDecoder();
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
let accepted = false, settled = false;
|
|
89
|
+
const fail = () => { if (settled)
|
|
90
|
+
return; settled = true; cleanup(); reject(new Error("engine broker unavailable")); };
|
|
91
|
+
const cleanup = () => { signal?.removeEventListener("abort", abort); socket.destroy(); };
|
|
92
|
+
const abort = () => fail();
|
|
93
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
94
|
+
if (signal?.aborted)
|
|
95
|
+
return abort();
|
|
96
|
+
socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request)));
|
|
97
|
+
socket.on("data", (chunk) => {
|
|
98
|
+
try {
|
|
99
|
+
for (const value of decoder.push(chunk)) {
|
|
100
|
+
const response = parseEngineBrokerResponse(value);
|
|
101
|
+
if ((response.kind !== "accepted" && response.kind !== "completed" && response.kind !== "failed") || response.requestId !== requestId || response.turnId !== turnId)
|
|
102
|
+
throw new Error();
|
|
103
|
+
if (response.kind === "accepted") {
|
|
104
|
+
if (accepted)
|
|
105
|
+
throw new Error();
|
|
106
|
+
accepted = true;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (!accepted || settled)
|
|
110
|
+
throw new Error();
|
|
111
|
+
settled = true;
|
|
112
|
+
cleanup();
|
|
113
|
+
if (options.model !== undefined && response.model !== options.model) {
|
|
114
|
+
reject(new Error(`engine broker turn used model ${response.model}, not the declared ${options.model}`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (response.kind === "completed")
|
|
118
|
+
resolve(response.text);
|
|
119
|
+
else
|
|
120
|
+
reject(new Error(`engine broker turn failed (${response.code}${response.limitReason === "none" ? "" : `; limit=${response.limitReason}`}${response.diagnostic ? `; ${response.diagnostic.stage}/${response.diagnostic.failureClass}; exit=${response.diagnostic.exitCode}; signal=${response.diagnostic.termSignal}${response.diagnostic.reason === undefined ? "" : `; reason=${response.diagnostic.reason}`}` : ""}${renderMcpCalls(response.mcpCalls)})`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
fail();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
socket.once("error", fail);
|
|
128
|
+
socket.once("close", () => { if (!settled)
|
|
129
|
+
fail(); });
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}>;
|
|
8
|
+
export declare function parseBrokerCredentialJournal(value: unknown): BrokerCredentialJournal;
|
|
9
|
+
export declare function recoverBrokerCredentialJournal(journal: BrokerCredentialJournal, authorityDigest: string): "ready" | "stale";
|
|
10
|
+
//# 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,CAAA;CAAE,CAAC,CAAC;AAG3N,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAKpF;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAI3H"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const DIGEST = /^[a-f0-9]{64}$/u;
|
|
2
|
+
export function parseBrokerCredentialJournal(value) {
|
|
3
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
4
|
+
throw new TypeError("invalid credential journal");
|
|
5
|
+
const input = value;
|
|
6
|
+
const fields = input.state === "refreshing" ? ["version", "state", "generation", "sourceDigest"] : ["version", "state", "generation", "sourceDigest", "promotedDigest"];
|
|
7
|
+
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))))
|
|
8
|
+
throw new TypeError("invalid credential journal");
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
export function recoverBrokerCredentialJournal(journal, authorityDigest) {
|
|
12
|
+
if (journal.state === "stale")
|
|
13
|
+
return "stale";
|
|
14
|
+
if (journal.state === "refreshing")
|
|
15
|
+
return authorityDigest === journal.sourceDigest ? "ready" : "stale";
|
|
16
|
+
return authorityDigest === journal.promotedDigest ? "ready" : "stale";
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EngineBrokerTurnLimits } from "./engineBrokerTurnAccounting.js";
|
|
2
|
+
import type { GrokBrokerModel, GrokBrokerReasoningEffort } from "./grokBrokerModelPolicy.js";
|
|
3
|
+
import type { GrokInferencePurpose } from "./inferenceUsageLedger.js";
|
|
4
|
+
export declare const ENGINE_BROKER_INFERENCE_FAILURE_CODES: readonly ["auth_stale", "grant_limit", "invalid_request", "unavailable"];
|
|
5
|
+
export type EngineBrokerInferenceFailureCode = (typeof ENGINE_BROKER_INFERENCE_FAILURE_CODES)[number];
|
|
6
|
+
export declare const GROK_INFERENCE_PROXY_BASE_URL: "http://127.0.0.1:43123/v1";
|
|
7
|
+
type V = "noopolis.daimon.engine-broker.v2";
|
|
8
|
+
export type EngineBrokerInferenceRequest = Readonly<{
|
|
9
|
+
version: V;
|
|
10
|
+
kind: "request_inference_grant";
|
|
11
|
+
requestId: string;
|
|
12
|
+
model: GrokBrokerModel;
|
|
13
|
+
reasoningEffort: GrokBrokerReasoningEffort;
|
|
14
|
+
purpose: GrokInferencePurpose;
|
|
15
|
+
}> | Readonly<{
|
|
16
|
+
version: V;
|
|
17
|
+
kind: "release_inference_grant";
|
|
18
|
+
requestId: string;
|
|
19
|
+
grantId: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type EngineBrokerInferenceResponse = Readonly<{
|
|
22
|
+
version: V;
|
|
23
|
+
kind: "inference_grant";
|
|
24
|
+
requestId: string;
|
|
25
|
+
grantId: string;
|
|
26
|
+
token: string;
|
|
27
|
+
baseUrl: typeof GROK_INFERENCE_PROXY_BASE_URL;
|
|
28
|
+
model: GrokBrokerModel;
|
|
29
|
+
reasoningEffort: GrokBrokerReasoningEffort;
|
|
30
|
+
purpose: GrokInferencePurpose;
|
|
31
|
+
expiresAt: string;
|
|
32
|
+
limits: EngineBrokerTurnLimits;
|
|
33
|
+
}> | Readonly<{
|
|
34
|
+
version: V;
|
|
35
|
+
kind: "inference_grant_released";
|
|
36
|
+
requestId: string;
|
|
37
|
+
grantId: string;
|
|
38
|
+
released: boolean;
|
|
39
|
+
}> | Readonly<{
|
|
40
|
+
version: V;
|
|
41
|
+
kind: "inference_grant_refused";
|
|
42
|
+
requestId: string;
|
|
43
|
+
code: EngineBrokerInferenceFailureCode;
|
|
44
|
+
}>;
|
|
45
|
+
type JsonRecord = Record<string, unknown>;
|
|
46
|
+
/** `input` has already passed the v2 envelope checks; `requestId` is the parsed id. */
|
|
47
|
+
export declare function parseEngineBrokerInferenceRequest(input: JsonRecord, requestId: string, version: V): EngineBrokerInferenceRequest;
|
|
48
|
+
export declare function parseEngineBrokerInferenceResponse(input: JsonRecord, requestId: string, version: V): EngineBrokerInferenceResponse;
|
|
49
|
+
export declare const isEngineBrokerInferenceRequestKind: (kind: unknown) => boolean;
|
|
50
|
+
export declare const isEngineBrokerInferenceResponseKind: (kind: unknown) => boolean;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=engineBrokerInferenceProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerInferenceProtocol.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerInferenceProtocol.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAgBtE,eAAO,MAAM,qCAAqC,0EAAoB,CAAC;AACvE,MAAM,MAAM,gCAAgC,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC,MAAM,CAAC,CAAC;AACtG,eAAO,MAAM,6BAA6B,6BAAyG,CAAC;AAEpJ,KAAK,CAAC,GAAG,kCAAkC,CAAC;AAC5C,MAAM,MAAM,4BAA4B,GACpC,QAAQ,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,yBAAyB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAC;IAAC,eAAe,EAAE,yBAAyB,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,CAAC,GAC/K,QAAQ,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,yBAAyB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAClG,MAAM,MAAM,6BAA6B,GACrC,QAAQ,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,6BAA6B,CAAC;IAAC,KAAK,EAAE,eAAe,CAAC;IAAC,eAAe,EAAE,yBAAyB,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,CAAC,GACzS,QAAQ,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,0BAA0B,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,GACjH,QAAQ,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,yBAAyB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gCAAgC,CAAA;CAAE,CAAC,CAAC;AAEzH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAO1C,uFAAuF;AACvF,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,4BAA4B,CAUhI;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,6BAA6B,CAoBlI;AAED,eAAO,MAAM,kCAAkC,GAAI,MAAM,OAAO,KAAG,OAAmF,CAAC;AACvJ,eAAO,MAAM,mCAAmC,GAAI,MAAM,OAAO,KAAG,OAAkH,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { GROK_BROKER_MODELS, GROK_BROKER_REASONING_EFFORTS } from "../contracts/grokWorkerContract.js";
|
|
2
|
+
import { GROK_ENGINE_BROKER } from "../contracts/runtimeContractManifest.js";
|
|
3
|
+
/**
|
|
4
|
+
* Evaluator inference grant frames, additive kinds of control protocol v2.
|
|
5
|
+
*
|
|
6
|
+
* Both ends ship in this package (the organization-side client and the broker
|
|
7
|
+
* service), so the kinds join v2 without a version bump; a broker that
|
|
8
|
+
* predates them refuses the unknown kind and closes the connection, which the
|
|
9
|
+
* client reports as `unavailable`. The native relay forwards frames opaquely
|
|
10
|
+
* and admits only the organization uid on `control.sock` (`SO_PEERCRED`), so
|
|
11
|
+
* that check is what limits grants to the evaluator side.
|
|
12
|
+
*
|
|
13
|
+
* The grant `token` is the bearer the evaluator's Grok CLI presents to the
|
|
14
|
+
* provider proxy (`env_key`). It never carries the broker credential.
|
|
15
|
+
*/
|
|
16
|
+
const SPEC = GROK_ENGINE_BROKER.inferenceGrants;
|
|
17
|
+
export const ENGINE_BROKER_INFERENCE_FAILURE_CODES = SPEC.failureCodes;
|
|
18
|
+
export const GROK_INFERENCE_PROXY_BASE_URL = `http://${GROK_ENGINE_BROKER.providerProxy.host}:${GROK_ENGINE_BROKER.providerProxy.port}/v1`;
|
|
19
|
+
const invalid = () => new TypeError("invalid broker frame");
|
|
20
|
+
const exact = (value, fields) => { if (Object.keys(value).length !== fields.length || fields.some((field) => !Object.hasOwn(value, field)))
|
|
21
|
+
throw invalid(); };
|
|
22
|
+
const member = (list, value) => { if (!list.includes(value))
|
|
23
|
+
throw invalid(); return value; };
|
|
24
|
+
const grantId = (value) => { if (typeof value !== "string" || !/^[a-f0-9]{32}$/u.test(value))
|
|
25
|
+
throw invalid(); return value; };
|
|
26
|
+
const TOKEN = new RegExp(`^${SPEC.tokenPrefix}[A-Za-z0-9_-]{43}$`, "u");
|
|
27
|
+
/** `input` has already passed the v2 envelope checks; `requestId` is the parsed id. */
|
|
28
|
+
export function parseEngineBrokerInferenceRequest(input, requestId, version) {
|
|
29
|
+
if (input.kind === "request_inference_grant") {
|
|
30
|
+
exact(input, ["version", "kind", "requestId", "model", "reasoningEffort", "purpose"]);
|
|
31
|
+
return { version, kind: "request_inference_grant", requestId, model: member(GROK_BROKER_MODELS, input.model), reasoningEffort: member(GROK_BROKER_REASONING_EFFORTS, input.reasoningEffort), purpose: member(SPEC.purposes, input.purpose) };
|
|
32
|
+
}
|
|
33
|
+
if (input.kind === "release_inference_grant") {
|
|
34
|
+
exact(input, ["version", "kind", "requestId", "grantId"]);
|
|
35
|
+
return { version, kind: "release_inference_grant", requestId, grantId: grantId(input.grantId) };
|
|
36
|
+
}
|
|
37
|
+
throw invalid();
|
|
38
|
+
}
|
|
39
|
+
export function parseEngineBrokerInferenceResponse(input, requestId, version) {
|
|
40
|
+
if (input.kind === "inference_grant") {
|
|
41
|
+
exact(input, ["version", "kind", "requestId", "grantId", "token", "baseUrl", "model", "reasoningEffort", "purpose", "expiresAt", "limits"]);
|
|
42
|
+
if (typeof input.token !== "string" || !TOKEN.test(input.token) || input.baseUrl !== GROK_INFERENCE_PROXY_BASE_URL || typeof input.expiresAt !== "string" || Number.isNaN(Date.parse(input.expiresAt)) || new Date(input.expiresAt).toISOString() !== input.expiresAt)
|
|
43
|
+
throw invalid();
|
|
44
|
+
const limits = input.limits;
|
|
45
|
+
if (limits === null || typeof limits !== "object" || Array.isArray(limits))
|
|
46
|
+
throw invalid();
|
|
47
|
+
exact(limits, ["maxRequests", "maxTokens", "timeoutMs"]);
|
|
48
|
+
if (!(Number.isSafeInteger(limits.maxRequests) && limits.maxRequests >= 1 && limits.maxRequests <= SPEC.limits.maxRequests && Number.isSafeInteger(limits.maxTokens) && limits.maxTokens >= 1 && limits.maxTokens <= SPEC.limits.maxTokens && Number.isSafeInteger(limits.timeoutMs) && limits.timeoutMs >= 1 && limits.timeoutMs <= SPEC.ttlMs))
|
|
49
|
+
throw invalid();
|
|
50
|
+
return { version, kind: "inference_grant", requestId, grantId: grantId(input.grantId), token: input.token, baseUrl: GROK_INFERENCE_PROXY_BASE_URL, model: member(GROK_BROKER_MODELS, input.model), reasoningEffort: member(GROK_BROKER_REASONING_EFFORTS, input.reasoningEffort), purpose: member(SPEC.purposes, input.purpose), expiresAt: input.expiresAt, limits: { maxRequests: limits.maxRequests, maxTokens: limits.maxTokens, timeoutMs: limits.timeoutMs } };
|
|
51
|
+
}
|
|
52
|
+
if (input.kind === "inference_grant_released") {
|
|
53
|
+
exact(input, ["version", "kind", "requestId", "grantId", "released"]);
|
|
54
|
+
if (typeof input.released !== "boolean")
|
|
55
|
+
throw invalid();
|
|
56
|
+
return { version, kind: "inference_grant_released", requestId, grantId: grantId(input.grantId), released: input.released };
|
|
57
|
+
}
|
|
58
|
+
if (input.kind === "inference_grant_refused") {
|
|
59
|
+
exact(input, ["version", "kind", "requestId", "code"]);
|
|
60
|
+
return { version, kind: "inference_grant_refused", requestId, code: member(ENGINE_BROKER_INFERENCE_FAILURE_CODES, input.code) };
|
|
61
|
+
}
|
|
62
|
+
throw invalid();
|
|
63
|
+
}
|
|
64
|
+
export const isEngineBrokerInferenceRequestKind = (kind) => kind === "request_inference_grant" || kind === "release_inference_grant";
|
|
65
|
+
export const isEngineBrokerInferenceResponseKind = (kind) => kind === "inference_grant" || kind === "inference_grant_released" || kind === "inference_grant_refused";
|