@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,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-flight MCP tool calls of one brokered turn.
|
|
3
|
+
*
|
|
4
|
+
* Daimon writes a tool receipt only when a call *completes*, so a call that
|
|
5
|
+
* started and never returned is byte-identical, in every artifact, to a call
|
|
6
|
+
* that was never made. A live Grok turn stopped acting after its eighth
|
|
7
|
+
* provider response and was killed by the trial deadline seven minutes later
|
|
8
|
+
* with the proxy's per-request ledger reporting `open: 0` — every provider
|
|
9
|
+
* request closed — which leaves exactly one unlit path: a tool call the worker
|
|
10
|
+
* issued and the facade never answered.
|
|
11
|
+
*
|
|
12
|
+
* This is that light, and it follows the per-request ledger's rules rather
|
|
13
|
+
* than inventing its own:
|
|
14
|
+
*
|
|
15
|
+
* - **names and timings only.** The tool name off the JSON-RPC envelope and
|
|
16
|
+
* two clocks. Never arguments, never a result, never a session id, never a
|
|
17
|
+
* capability or bearer. A name that is not a plain short identifier is
|
|
18
|
+
* recorded as {@link ENGINE_BROKER_MCP_CALL_INVALID} rather than passed
|
|
19
|
+
* through, and the list is bounded at
|
|
20
|
+
* {@link ENGINE_BROKER_MCP_OUTSTANDING_MAX} with
|
|
21
|
+
* {@link ENGINE_BROKER_MCP_CALL_TRUNCATED} as its last entry.
|
|
22
|
+
* - **absence stays absence.** A turn the log never opened observes as
|
|
23
|
+
* `undefined`; a turn that made no call observes `started: 0`, which is not
|
|
24
|
+
* the same statement as an answered call. A POST whose body the facade could
|
|
25
|
+
* not read counts in `undecoded` and never as a call with a name, because a
|
|
26
|
+
* fabricated name is byte-identical to a measured one — and because "zero
|
|
27
|
+
* calls started" is exactly the reading this instrument exists to make
|
|
28
|
+
* trustworthy.
|
|
29
|
+
* - **it cannot fail a turn.** Every operation here is arithmetic over a map,
|
|
30
|
+
* the one parse is wrapped, and the facade treats a missing handle as a
|
|
31
|
+
* no-op.
|
|
32
|
+
*
|
|
33
|
+
* The same map carries the facade's *other* channel, and for the same reason.
|
|
34
|
+
* A `tools/call` is a POST that answers; the standalone `GET` SSE tunnel the
|
|
35
|
+
* Streamable HTTP transport opens once per session is the route a server
|
|
36
|
+
* notification or progress frame takes, and it stays open for the whole
|
|
37
|
+
* session by design. A worker parked reading that tunnel is, in every artifact
|
|
38
|
+
* the broker writes, indistinguishable from a worker doing nothing at all:
|
|
39
|
+
* every provider request closed, every tool call answered, and the turn idle
|
|
40
|
+
* until its deadline. {@link EngineBrokerMcpCallLog.openTunnel} records the
|
|
41
|
+
* lifecycle — how many the facade relayed, how many ended, and for the ones
|
|
42
|
+
* still open at seal time how long each has been open and whether the mount
|
|
43
|
+
* ever pushed a single byte through it. A tunnel held open having delivered
|
|
44
|
+
* nothing is a different fact from one actively carrying frames, and it is the
|
|
45
|
+
* difference that decides whether the tunnel is the blocker.
|
|
46
|
+
*
|
|
47
|
+
* Observing is all it does. The facade's behaviour is unchanged: nothing here
|
|
48
|
+
* closes, times out or refuses a tunnel, because an instrument that tore down
|
|
49
|
+
* the stream would destroy the evidence it exists to gather.
|
|
50
|
+
*
|
|
51
|
+
* "Answered" means the facade wrote a complete response back to the worker —
|
|
52
|
+
* the relay reached its own `end()`. A relay that was torn down (the worker
|
|
53
|
+
* died, the tunnel broke, the turn aborted) did *not* answer, so its calls stay
|
|
54
|
+
* outstanding with the elapsed time they had reached. That is the whole point:
|
|
55
|
+
* the turn's death must not retroactively mark the call it was blocked on as
|
|
56
|
+
* finished.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* The same map carries the facade's *refusals*, for the sharpest form of the
|
|
60
|
+
* same problem. A refused request never reaches the relay at all, so a turn
|
|
61
|
+
* every one of whose requests was 403'd sealed as `answered == started,
|
|
62
|
+
* outstanding: []` — byte-identical to a healthy turn, which is precisely the
|
|
63
|
+
* reading this instrument exists to make trustworthy. The reason class is what
|
|
64
|
+
* makes it actionable: an exhausted per-turn capability budget — the facade's
|
|
65
|
+
* `ENGINE_BROKER_MCP_CAPABILITY_REQUESTS`, derived from the compiled turn
|
|
66
|
+
* bound times what a round may spend — is a different fault from a mount that
|
|
67
|
+
* was never registered, and both differ from a worker asking for a route the
|
|
68
|
+
* facade does not serve. Counts only, keyed by a closed vocabulary:
|
|
69
|
+
* never the token, the capability, the URL or the body. A refusal the facade
|
|
70
|
+
* cannot attribute to a turn — a bearer no live grant matches — is recorded
|
|
71
|
+
* nowhere, because attributing it to a turn would be inventing the fact.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ENGINE_BROKER_MCP_OUTSTANDING_MAX = 16;
|
|
74
|
+
export declare const ENGINE_BROKER_MCP_CALL_INVALID = "<invalid>";
|
|
75
|
+
export declare const ENGINE_BROKER_MCP_CALL_TRUNCATED = "<truncated>";
|
|
76
|
+
/** A plain short identifier, or one of the two sentinels above. */
|
|
77
|
+
export declare const ENGINE_BROKER_MCP_CALL_NAME: RegExp;
|
|
78
|
+
/** Open GET tunnels reported: a session opens one, so more than a handful is already the anomaly. */
|
|
79
|
+
export declare const ENGINE_BROKER_MCP_TUNNEL_MAX = 8;
|
|
80
|
+
/**
|
|
81
|
+
* Why the facade refused one relayed request, as a closed vocabulary:
|
|
82
|
+
* - `route`: a path or method the facade does not serve.
|
|
83
|
+
* - `expired`: the turn capability's TTL had passed.
|
|
84
|
+
* - `exhausted`: the turn capability's request budget was spent.
|
|
85
|
+
* - `unrouted`: a live capability whose turn has no registered mount.
|
|
86
|
+
* - `oversized`: a POST body past the facade's own request bound.
|
|
87
|
+
*/
|
|
88
|
+
export declare const ENGINE_BROKER_MCP_REFUSAL_REASONS: readonly ["route", "expired", "exhausted", "unrouted", "oversized"];
|
|
89
|
+
export type EngineBrokerMcpRefusalReason = (typeof ENGINE_BROKER_MCP_REFUSAL_REASONS)[number];
|
|
90
|
+
/** How many requests of this turn the facade refused, by reason class. Every member is a measurement; the whole member is absent only where it was never measured. */
|
|
91
|
+
export type EngineBrokerMcpRefusalObservation = Readonly<Record<EngineBrokerMcpRefusalReason, number>>;
|
|
92
|
+
export type EngineBrokerOutstandingMcpCall = Readonly<{
|
|
93
|
+
name: string;
|
|
94
|
+
outstandingMs: number;
|
|
95
|
+
}>;
|
|
96
|
+
/** One GET SSE tunnel still open at observation: how long it has been open, and whether the mount ever pushed through it. */
|
|
97
|
+
export type EngineBrokerOpenMcpTunnel = Readonly<{
|
|
98
|
+
openMs: number;
|
|
99
|
+
delivered: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* What the facade saw of one turn's standalone GET SSE tunnels: how many it
|
|
103
|
+
* relayed, how many ended, how many ever carried a byte from the mount, and
|
|
104
|
+
* the ones still open with the age of each.
|
|
105
|
+
*/
|
|
106
|
+
export type EngineBrokerMcpTunnelObservation = Readonly<{
|
|
107
|
+
opened: number;
|
|
108
|
+
closed: number;
|
|
109
|
+
delivered: number;
|
|
110
|
+
open: readonly EngineBrokerOpenMcpTunnel[];
|
|
111
|
+
}>;
|
|
112
|
+
/**
|
|
113
|
+
* What the facade saw of one turn's tool calls: how many started, how many the
|
|
114
|
+
* facade answered, how many POST bodies it could not read, and the ones still
|
|
115
|
+
* unanswered with the time each has been outstanding.
|
|
116
|
+
*/
|
|
117
|
+
export type EngineBrokerMcpCallObservation = Readonly<{
|
|
118
|
+
started: number;
|
|
119
|
+
answered: number;
|
|
120
|
+
undecoded: number;
|
|
121
|
+
outstanding: readonly EngineBrokerOutstandingMcpCall[];
|
|
122
|
+
tunnels?: EngineBrokerMcpTunnelObservation;
|
|
123
|
+
refusals?: EngineBrokerMcpRefusalObservation;
|
|
124
|
+
}>;
|
|
125
|
+
/** One relayed POST's calls. `answer` marks a complete relay; `close` ends it unanswered. Both are idempotent. */
|
|
126
|
+
export interface EngineBrokerMcpCallHandle {
|
|
127
|
+
answer(): void;
|
|
128
|
+
close(): void;
|
|
129
|
+
}
|
|
130
|
+
/** One relayed GET tunnel. `deliver` marks the first byte the mount pushed; `close` ends it. Both are idempotent. */
|
|
131
|
+
export interface EngineBrokerMcpTunnelHandle {
|
|
132
|
+
deliver(): void;
|
|
133
|
+
close(): void;
|
|
134
|
+
}
|
|
135
|
+
export declare class EngineBrokerMcpCallLog {
|
|
136
|
+
private readonly now;
|
|
137
|
+
private readonly turns;
|
|
138
|
+
constructor(now?: () => number);
|
|
139
|
+
/** A turn the facade registered. Re-opening an id resets it: a turn id is unique per turn. */
|
|
140
|
+
open(turnId: string): void;
|
|
141
|
+
close(turnId: string): void;
|
|
142
|
+
/** A POST body the facade is about to relay. Anything that is not a `tools/call` records nothing. */
|
|
143
|
+
begin(turnId: string, body: Uint8Array | undefined): EngineBrokerMcpCallHandle;
|
|
144
|
+
/**
|
|
145
|
+
* A GET SSE tunnel the facade is about to relay. Counted when it opens, not
|
|
146
|
+
* when it succeeds: a tunnel the mount refused still ends, so `opened` and
|
|
147
|
+
* `closed` stay a pair and an open one is exactly `opened - closed`.
|
|
148
|
+
*/
|
|
149
|
+
openTunnel(turnId: string): EngineBrokerMcpTunnelHandle;
|
|
150
|
+
/**
|
|
151
|
+
* A request the facade refused before it could ever be relayed. A refusal it
|
|
152
|
+
* cannot attribute to a turn is never recorded against one, so an unknown
|
|
153
|
+
* turn is a no-op here exactly as every other operation is.
|
|
154
|
+
*/
|
|
155
|
+
refuse(turnId: string, reason: EngineBrokerMcpRefusalReason): void;
|
|
156
|
+
/** A POST whose body the facade refused to read (over its own bound), which is a call it cannot name. */
|
|
157
|
+
undecodable(turnId: string): void;
|
|
158
|
+
observe(turnId: string): EngineBrokerMcpCallObservation | undefined;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=engineBrokerMcpCallLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerMcpCallLog.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerMcpCallLog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,KAAK,CAAC;AACpD,eAAO,MAAM,8BAA8B,cAAc,CAAC;AAC1D,eAAO,MAAM,gCAAgC,gBAAgB,CAAC;AAC9D,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,QAAsD,CAAC;AAG/F,qGAAqG;AACrG,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,qEAAsE,CAAC;AACrH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9F,sKAAsK;AACtK,MAAM,MAAM,iCAAiC,GAAG,QAAQ,CAAC,MAAM,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvG,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC/F,6HAA6H;AAC7H,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AACzF;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,yBAAyB,EAAE,CAAA;CAAE,CAAC,CAAC;AAC3J;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,SAAS,8BAA8B,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,gCAAgC,CAAC;IAAC,QAAQ,CAAC,EAAE,iCAAiC,CAAA;CAAE,CAAC,CAAC;AAElQ,kHAAkH;AAClH,MAAM,WAAW,yBAAyB;IAAG,MAAM,IAAI,IAAI,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE;AAE5E,qHAAqH;AACrH,MAAM,WAAW,2BAA2B;IAAG,OAAO,IAAI,IAAI,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE;AAY/E,qBAAa,sBAAsB;IAErB,OAAO,CAAC,QAAQ,CAAC,GAAG;IADhC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;gBACvB,GAAG,GAAE,MAAM,MAAiB;IAEzD,8FAA8F;IAC9F,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAC1B,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAE3B,qGAAqG;IACrG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,yBAAyB;IA8B9E;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,2BAA2B;IAavD;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,4BAA4B,GAAG,IAAI;IAElE,yGAAyG;IACzG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAEjC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,8BAA8B,GAAG,SAAS;CAmBpE"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-flight MCP tool calls of one brokered turn.
|
|
3
|
+
*
|
|
4
|
+
* Daimon writes a tool receipt only when a call *completes*, so a call that
|
|
5
|
+
* started and never returned is byte-identical, in every artifact, to a call
|
|
6
|
+
* that was never made. A live Grok turn stopped acting after its eighth
|
|
7
|
+
* provider response and was killed by the trial deadline seven minutes later
|
|
8
|
+
* with the proxy's per-request ledger reporting `open: 0` — every provider
|
|
9
|
+
* request closed — which leaves exactly one unlit path: a tool call the worker
|
|
10
|
+
* issued and the facade never answered.
|
|
11
|
+
*
|
|
12
|
+
* This is that light, and it follows the per-request ledger's rules rather
|
|
13
|
+
* than inventing its own:
|
|
14
|
+
*
|
|
15
|
+
* - **names and timings only.** The tool name off the JSON-RPC envelope and
|
|
16
|
+
* two clocks. Never arguments, never a result, never a session id, never a
|
|
17
|
+
* capability or bearer. A name that is not a plain short identifier is
|
|
18
|
+
* recorded as {@link ENGINE_BROKER_MCP_CALL_INVALID} rather than passed
|
|
19
|
+
* through, and the list is bounded at
|
|
20
|
+
* {@link ENGINE_BROKER_MCP_OUTSTANDING_MAX} with
|
|
21
|
+
* {@link ENGINE_BROKER_MCP_CALL_TRUNCATED} as its last entry.
|
|
22
|
+
* - **absence stays absence.** A turn the log never opened observes as
|
|
23
|
+
* `undefined`; a turn that made no call observes `started: 0`, which is not
|
|
24
|
+
* the same statement as an answered call. A POST whose body the facade could
|
|
25
|
+
* not read counts in `undecoded` and never as a call with a name, because a
|
|
26
|
+
* fabricated name is byte-identical to a measured one — and because "zero
|
|
27
|
+
* calls started" is exactly the reading this instrument exists to make
|
|
28
|
+
* trustworthy.
|
|
29
|
+
* - **it cannot fail a turn.** Every operation here is arithmetic over a map,
|
|
30
|
+
* the one parse is wrapped, and the facade treats a missing handle as a
|
|
31
|
+
* no-op.
|
|
32
|
+
*
|
|
33
|
+
* The same map carries the facade's *other* channel, and for the same reason.
|
|
34
|
+
* A `tools/call` is a POST that answers; the standalone `GET` SSE tunnel the
|
|
35
|
+
* Streamable HTTP transport opens once per session is the route a server
|
|
36
|
+
* notification or progress frame takes, and it stays open for the whole
|
|
37
|
+
* session by design. A worker parked reading that tunnel is, in every artifact
|
|
38
|
+
* the broker writes, indistinguishable from a worker doing nothing at all:
|
|
39
|
+
* every provider request closed, every tool call answered, and the turn idle
|
|
40
|
+
* until its deadline. {@link EngineBrokerMcpCallLog.openTunnel} records the
|
|
41
|
+
* lifecycle — how many the facade relayed, how many ended, and for the ones
|
|
42
|
+
* still open at seal time how long each has been open and whether the mount
|
|
43
|
+
* ever pushed a single byte through it. A tunnel held open having delivered
|
|
44
|
+
* nothing is a different fact from one actively carrying frames, and it is the
|
|
45
|
+
* difference that decides whether the tunnel is the blocker.
|
|
46
|
+
*
|
|
47
|
+
* Observing is all it does. The facade's behaviour is unchanged: nothing here
|
|
48
|
+
* closes, times out or refuses a tunnel, because an instrument that tore down
|
|
49
|
+
* the stream would destroy the evidence it exists to gather.
|
|
50
|
+
*
|
|
51
|
+
* "Answered" means the facade wrote a complete response back to the worker —
|
|
52
|
+
* the relay reached its own `end()`. A relay that was torn down (the worker
|
|
53
|
+
* died, the tunnel broke, the turn aborted) did *not* answer, so its calls stay
|
|
54
|
+
* outstanding with the elapsed time they had reached. That is the whole point:
|
|
55
|
+
* the turn's death must not retroactively mark the call it was blocked on as
|
|
56
|
+
* finished.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* The same map carries the facade's *refusals*, for the sharpest form of the
|
|
60
|
+
* same problem. A refused request never reaches the relay at all, so a turn
|
|
61
|
+
* every one of whose requests was 403'd sealed as `answered == started,
|
|
62
|
+
* outstanding: []` — byte-identical to a healthy turn, which is precisely the
|
|
63
|
+
* reading this instrument exists to make trustworthy. The reason class is what
|
|
64
|
+
* makes it actionable: an exhausted per-turn capability budget — the facade's
|
|
65
|
+
* `ENGINE_BROKER_MCP_CAPABILITY_REQUESTS`, derived from the compiled turn
|
|
66
|
+
* bound times what a round may spend — is a different fault from a mount that
|
|
67
|
+
* was never registered, and both differ from a worker asking for a route the
|
|
68
|
+
* facade does not serve. Counts only, keyed by a closed vocabulary:
|
|
69
|
+
* never the token, the capability, the URL or the body. A refusal the facade
|
|
70
|
+
* cannot attribute to a turn — a bearer no live grant matches — is recorded
|
|
71
|
+
* nowhere, because attributing it to a turn would be inventing the fact.
|
|
72
|
+
*/
|
|
73
|
+
export const ENGINE_BROKER_MCP_OUTSTANDING_MAX = 16;
|
|
74
|
+
export const ENGINE_BROKER_MCP_CALL_INVALID = "<invalid>";
|
|
75
|
+
export const ENGINE_BROKER_MCP_CALL_TRUNCATED = "<truncated>";
|
|
76
|
+
/** A plain short identifier, or one of the two sentinels above. */
|
|
77
|
+
export const ENGINE_BROKER_MCP_CALL_NAME = /^(?:<invalid>|<truncated>|[A-Za-z0-9_.-]{1,64})$/u;
|
|
78
|
+
const TOOL_NAME = /^[A-Za-z0-9_.-]{1,64}$/u;
|
|
79
|
+
/** Open GET tunnels reported: a session opens one, so more than a handful is already the anomaly. */
|
|
80
|
+
export const ENGINE_BROKER_MCP_TUNNEL_MAX = 8;
|
|
81
|
+
/**
|
|
82
|
+
* Why the facade refused one relayed request, as a closed vocabulary:
|
|
83
|
+
* - `route`: a path or method the facade does not serve.
|
|
84
|
+
* - `expired`: the turn capability's TTL had passed.
|
|
85
|
+
* - `exhausted`: the turn capability's request budget was spent.
|
|
86
|
+
* - `unrouted`: a live capability whose turn has no registered mount.
|
|
87
|
+
* - `oversized`: a POST body past the facade's own request bound.
|
|
88
|
+
*/
|
|
89
|
+
export const ENGINE_BROKER_MCP_REFUSAL_REASONS = ["route", "expired", "exhausted", "unrouted", "oversized"];
|
|
90
|
+
const INERT = { answer: () => undefined, close: () => undefined };
|
|
91
|
+
const INERT_TUNNEL = { deliver: () => undefined, close: () => undefined };
|
|
92
|
+
const noRefusals = () => ({ route: 0, expired: 0, exhausted: 0, unrouted: 0, oversized: 0 });
|
|
93
|
+
export class EngineBrokerMcpCallLog {
|
|
94
|
+
now;
|
|
95
|
+
turns = new Map();
|
|
96
|
+
constructor(now = Date.now) {
|
|
97
|
+
this.now = now;
|
|
98
|
+
}
|
|
99
|
+
/** A turn the facade registered. Re-opening an id resets it: a turn id is unique per turn. */
|
|
100
|
+
open(turnId) { this.turns.set(turnId, { started: 0, answered: 0, undecoded: 0, live: new Set(), ended: [], tunnelsOpened: 0, tunnelsClosed: 0, tunnelsDelivered: 0, openTunnels: new Set(), refusals: noRefusals() }); }
|
|
101
|
+
close(turnId) { this.turns.delete(turnId); }
|
|
102
|
+
/** A POST body the facade is about to relay. Anything that is not a `tools/call` records nothing. */
|
|
103
|
+
begin(turnId, body) {
|
|
104
|
+
const log = this.turns.get(turnId);
|
|
105
|
+
if (log === undefined || body === undefined || body.byteLength === 0)
|
|
106
|
+
return INERT;
|
|
107
|
+
const names = toolCallNames(body);
|
|
108
|
+
if (names === undefined) {
|
|
109
|
+
log.undecoded += 1;
|
|
110
|
+
return INERT;
|
|
111
|
+
}
|
|
112
|
+
if (names.length === 0)
|
|
113
|
+
return INERT;
|
|
114
|
+
const startedAt = this.now();
|
|
115
|
+
const records = names.map((name) => ({ name, startedAt }));
|
|
116
|
+
log.started += records.length;
|
|
117
|
+
for (const record of records)
|
|
118
|
+
log.live.add(record);
|
|
119
|
+
let settled = false;
|
|
120
|
+
return {
|
|
121
|
+
answer: () => {
|
|
122
|
+
if (settled)
|
|
123
|
+
return;
|
|
124
|
+
settled = true;
|
|
125
|
+
log.answered += records.length;
|
|
126
|
+
for (const record of records)
|
|
127
|
+
log.live.delete(record);
|
|
128
|
+
},
|
|
129
|
+
close: () => {
|
|
130
|
+
if (settled)
|
|
131
|
+
return;
|
|
132
|
+
settled = true;
|
|
133
|
+
const endedAt = this.now();
|
|
134
|
+
for (const record of records) {
|
|
135
|
+
log.live.delete(record);
|
|
136
|
+
record.endedAt = endedAt;
|
|
137
|
+
// Retain only as many as can be reported; the earliest are the ones
|
|
138
|
+
// a hang is about, so a later flood cannot displace them.
|
|
139
|
+
if (log.ended.length < ENGINE_BROKER_MCP_OUTSTANDING_MAX)
|
|
140
|
+
log.ended.push(record);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A GET SSE tunnel the facade is about to relay. Counted when it opens, not
|
|
147
|
+
* when it succeeds: a tunnel the mount refused still ends, so `opened` and
|
|
148
|
+
* `closed` stay a pair and an open one is exactly `opened - closed`.
|
|
149
|
+
*/
|
|
150
|
+
openTunnel(turnId) {
|
|
151
|
+
const log = this.turns.get(turnId);
|
|
152
|
+
if (log === undefined)
|
|
153
|
+
return INERT_TUNNEL;
|
|
154
|
+
const record = { openedAt: this.now(), delivered: false };
|
|
155
|
+
log.tunnelsOpened += 1;
|
|
156
|
+
log.openTunnels.add(record);
|
|
157
|
+
let ended = false;
|
|
158
|
+
return {
|
|
159
|
+
deliver: () => { if (record.delivered)
|
|
160
|
+
return; record.delivered = true; log.tunnelsDelivered += 1; },
|
|
161
|
+
close: () => { if (ended)
|
|
162
|
+
return; ended = true; log.tunnelsClosed += 1; log.openTunnels.delete(record); }
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A request the facade refused before it could ever be relayed. A refusal it
|
|
167
|
+
* cannot attribute to a turn is never recorded against one, so an unknown
|
|
168
|
+
* turn is a no-op here exactly as every other operation is.
|
|
169
|
+
*/
|
|
170
|
+
refuse(turnId, reason) { const log = this.turns.get(turnId); if (log !== undefined)
|
|
171
|
+
log.refusals[reason] += 1; }
|
|
172
|
+
/** A POST whose body the facade refused to read (over its own bound), which is a call it cannot name. */
|
|
173
|
+
undecodable(turnId) { const log = this.turns.get(turnId); if (log !== undefined)
|
|
174
|
+
log.undecoded += 1; }
|
|
175
|
+
observe(turnId) {
|
|
176
|
+
const log = this.turns.get(turnId);
|
|
177
|
+
if (log === undefined)
|
|
178
|
+
return undefined;
|
|
179
|
+
const at = this.now();
|
|
180
|
+
const pending = [...log.live, ...log.ended].sort((left, right) => left.startedAt - right.startedAt);
|
|
181
|
+
const outstanding = pending.map((record) => ({ name: record.name, outstandingMs: Math.max(0, (record.endedAt ?? at) - record.startedAt) }));
|
|
182
|
+
const open = [...log.openTunnels]
|
|
183
|
+
.sort((left, right) => left.openedAt - right.openedAt)
|
|
184
|
+
.slice(0, ENGINE_BROKER_MCP_TUNNEL_MAX)
|
|
185
|
+
.map((record) => ({ openMs: Math.max(0, at - record.openedAt), delivered: record.delivered }));
|
|
186
|
+
return {
|
|
187
|
+
started: log.started, answered: log.answered, undecoded: log.undecoded,
|
|
188
|
+
refusals: { ...log.refusals },
|
|
189
|
+
tunnels: { opened: log.tunnelsOpened, closed: log.tunnelsClosed, delivered: log.tunnelsDelivered, open },
|
|
190
|
+
outstanding: outstanding.length > ENGINE_BROKER_MCP_OUTSTANDING_MAX
|
|
191
|
+
? [...outstanding.slice(0, ENGINE_BROKER_MCP_OUTSTANDING_MAX - 1), { name: ENGINE_BROKER_MCP_CALL_TRUNCATED, outstandingMs: 0 }]
|
|
192
|
+
: outstanding
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The tool names one JSON-RPC POST asks for: `undefined` when the body did not
|
|
198
|
+
* decode at all (which is a fact of its own, not zero calls), `[]` when it
|
|
199
|
+
* decoded and asked for no tool. A batch names each of its calls.
|
|
200
|
+
*/
|
|
201
|
+
function toolCallNames(body) {
|
|
202
|
+
let parsed;
|
|
203
|
+
try {
|
|
204
|
+
parsed = JSON.parse(Buffer.from(body.buffer, body.byteOffset, body.byteLength).toString("utf8"));
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
const entries = Array.isArray(parsed) ? parsed : [parsed];
|
|
210
|
+
const names = [];
|
|
211
|
+
for (const entry of entries) {
|
|
212
|
+
if (!isRecord(entry) || entry.method !== "tools/call")
|
|
213
|
+
continue;
|
|
214
|
+
const name = isRecord(entry.params) ? entry.params.name : undefined;
|
|
215
|
+
names.push(typeof name === "string" && TOOL_NAME.test(name) ? name : ENGINE_BROKER_MCP_CALL_INVALID);
|
|
216
|
+
}
|
|
217
|
+
return names;
|
|
218
|
+
}
|
|
219
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ServerResponse } from "node:http";
|
|
2
|
+
import { type EngineBrokerMcpCallObservation } from "./engineBrokerMcpCallLog.js";
|
|
3
|
+
export declare const ENGINE_BROKER_MCP_FACADE_PORT = 43124;
|
|
4
|
+
/** Requests one worker round may legitimately make: its `search_tool`, its `use_tool`, and one spare for a retry or a second discovery. */
|
|
5
|
+
export declare const ENGINE_BROKER_MCP_ROUND_REQUESTS = 3;
|
|
6
|
+
/** The session's fixed cost, once per turn: `initialize`, `notifications/initialized`, `tools/list`, the standalone GET tunnel, the closing DELETE. */
|
|
7
|
+
export declare const ENGINE_BROKER_MCP_SESSION_REQUESTS = 5;
|
|
8
|
+
/**
|
|
9
|
+
* Requests one turn capability may spend, across all three methods — *derived*
|
|
10
|
+
* from the compiled turn bound rather than chosen.
|
|
11
|
+
*
|
|
12
|
+
* It was 128, and a legitimate 48-round wake needs ~101 of them: a worker's
|
|
13
|
+
* round is a `search_tool` and a `use_tool`, so the first round that also
|
|
14
|
+
* retries, or looks something up twice, eats the margin. A bound that can be
|
|
15
|
+
* predicted to bite mid-turn is not a bound, it is a 403 storm waiting for a
|
|
16
|
+
* real wake — and a number raised until it feels comfortable is not one
|
|
17
|
+
* either, because the budget exists to cap a *compromised* worker.
|
|
18
|
+
*
|
|
19
|
+
* So the two numbers that must agree are kept in one place: the launcher's
|
|
20
|
+
* `--max-turns` backstop ({@link GROK_WORKER_MAX_TURNS}) times what a round
|
|
21
|
+
* may legitimately spend, plus the session's fixed cost. Raising the turn
|
|
22
|
+
* bound raises this with it, and a compromised worker still gets exactly three
|
|
23
|
+
* MCP calls per round it was compiled to take and not one more. The arithmetic
|
|
24
|
+
* is spelled out rather than folded into a literal so it can be audited: the
|
|
25
|
+
* two multiplicands above each say what they are.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ENGINE_BROKER_MCP_CAPABILITY_REQUESTS: number;
|
|
28
|
+
export declare const ENGINE_BROKER_MCP_CAPABILITY_TTL_MS: number;
|
|
29
|
+
export declare function startEngineBrokerMcpFacade(): Promise<{
|
|
30
|
+
register(agentId: string, turnId: string, endpoint: string): string;
|
|
31
|
+
revoke(turnId: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* What the facade saw of this turn's tool calls, GET tunnels and refusals,
|
|
34
|
+
* or `undefined` for a turn
|
|
35
|
+
* it never registered. Read on the failure path, before `revoke`.
|
|
36
|
+
*/
|
|
37
|
+
observe: (turnId: string) => EngineBrokerMcpCallObservation | undefined;
|
|
38
|
+
close: () => Promise<void>;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Waits for a backpressured tunnel to drain, or for the tunnel to end —
|
|
42
|
+
* whichever happens first, but always one of them.
|
|
43
|
+
*
|
|
44
|
+
* A bare `once("drain")` never settles for a client that hung up mid-write:
|
|
45
|
+
* `drain` cannot fire on a socket nobody is reading, and neither the
|
|
46
|
+
* response's own `close` nor the turn's abort woke that await. The GET SSE
|
|
47
|
+
* tunnel stays open for a whole session, so the handler — and the upstream
|
|
48
|
+
* call it was relaying — leaked for the life of the broker process, with no
|
|
49
|
+
* refusal, no status and no line anywhere to read. Every outcome settles this
|
|
50
|
+
* now, and every outcome but an actual drain *rejects*, so the caller tears
|
|
51
|
+
* the tunnel down instead of writing into a socket that is gone.
|
|
52
|
+
*
|
|
53
|
+
* Exported for its own test: a hang is only observable from inside.
|
|
54
|
+
*/
|
|
55
|
+
export declare function awaitMcpTunnelDrain(response: ServerResponse, signal: AbortSignal): Promise<void>;
|
|
56
|
+
//# sourceMappingURL=engineBrokerMcpFacade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineBrokerMcpFacade.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerMcpFacade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAIpF,OAAO,EAA0B,KAAK,8BAA8B,EAAuE,MAAM,6BAA6B,CAAC;AA4C/K,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAEpD,2IAA2I;AAC3I,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,uJAAuJ;AACvJ,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qCAAqC,QAAgG,CAAC;AACnJ,eAAO,MAAM,mCAAmC,QAAc,CAAC;AAI/D,wBAAsB,0BAA0B;sBA0G1B,MAAM,UAAU,MAAM,YAAY,MAAM,GAAG,MAAM;mBAQpD,MAAM,GAAG,IAAI;IAM5B;;;;OAIG;sBACe,MAAM,KAAG,8BAA8B,GAAG,SAAS;iBACpD,OAAO,CAAC,IAAI,CAAC;GAUjC;AAoED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAehG"}
|