@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,158 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { mkdir, open, readFile, rename, unlink } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { parseEngineBrokerResponse, parseEngineBrokerV1TerminalResponse } from "./engineBrokerProtocol.js";
|
|
6
|
+
import { EMPTY_BROKER_TURN_LEDGER, parseBrokerTurnLedgerLines } from "./grokEngineBrokerLedger.js";
|
|
7
|
+
export const ENGINE_BROKER_TURN_RECORD_V1 = "noopolis.daimon.engine-broker-turn.v1";
|
|
8
|
+
export const ENGINE_BROKER_TURN_RECORD_V2 = "noopolis.daimon.engine-broker-turn.v2";
|
|
9
|
+
// The digest deliberately excludes `limits` and the protocol version, so a v1
|
|
10
|
+
// record written before the upgrade still identifies the same turn.
|
|
11
|
+
const digest = (request) => createHash("sha256").update(JSON.stringify([request.turnId, request.agentId, request.wakeId, request.prompt, request.mcpEndpoint])).digest("hex");
|
|
12
|
+
const safe = (turnId) => `${createHash("sha256").update(turnId).digest("hex")}.json`;
|
|
13
|
+
/**
|
|
14
|
+
* Durable per-turn state. Record v2 stores the terminal response *with* its
|
|
15
|
+
* sealed accounting (usage, outcome, model, requests, limitReason), so a replay
|
|
16
|
+
* returns exactly what was metered and never meters again: metering happens
|
|
17
|
+
* only on the path that returned `"start"`.
|
|
18
|
+
*/
|
|
19
|
+
export class EngineBrokerTurnRegistry {
|
|
20
|
+
root;
|
|
21
|
+
bootId;
|
|
22
|
+
syncDirectoryOf;
|
|
23
|
+
/** `syncDirectoryOf` is injectable only so the post-publish failure path can be exercised under test. */
|
|
24
|
+
constructor(root, bootId = randomUUID(), syncDirectoryOf = syncDirectory) {
|
|
25
|
+
this.root = root;
|
|
26
|
+
this.bootId = bootId;
|
|
27
|
+
this.syncDirectoryOf = syncDirectoryOf;
|
|
28
|
+
}
|
|
29
|
+
/** `model` is the registration's declared model, used only to upgrade a v1 record on replay. */
|
|
30
|
+
async begin(request, model) {
|
|
31
|
+
await mkdir(this.root, { recursive: true, mode: 0o700 });
|
|
32
|
+
const file = path.join(this.root, safe(request.turnId));
|
|
33
|
+
const expected = digest(request);
|
|
34
|
+
try {
|
|
35
|
+
const handle = await open(file, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600);
|
|
36
|
+
try {
|
|
37
|
+
await handle.writeFile(`${JSON.stringify({ version: ENGINE_BROKER_TURN_RECORD_V2, digest: expected, state: "active", bootId: this.bootId })}\n`);
|
|
38
|
+
await handle.sync();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await handle.close();
|
|
42
|
+
}
|
|
43
|
+
await this.syncDirectoryOf(this.root);
|
|
44
|
+
return "start";
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.code !== "EEXIST")
|
|
48
|
+
throw new Error("broker turn registry unavailable");
|
|
49
|
+
}
|
|
50
|
+
const observed = parseEngineBrokerTurnRecord(await readFile(file, "utf8"), model);
|
|
51
|
+
if (observed.digest !== expected)
|
|
52
|
+
throw new Error("broker turn conflict");
|
|
53
|
+
if (observed.state === "terminal" && observed.response !== undefined)
|
|
54
|
+
return { replay: observed.response, ledger: observed.ledger ?? EMPTY_BROKER_TURN_LEDGER };
|
|
55
|
+
if (observed.state === "active" && observed.bootId !== this.bootId) {
|
|
56
|
+
const response = { version: request.version, kind: "failed", requestId: request.requestId, turnId: request.turnId, code: "engine_failed", outcome: "failed", usage: null, model, requests: 0, limitReason: "none" };
|
|
57
|
+
await this.finish(request, response);
|
|
58
|
+
return { replay: response, ledger: EMPTY_BROKER_TURN_LEDGER };
|
|
59
|
+
}
|
|
60
|
+
throw new Error("broker turn already active");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `ledger` is the exact ledger bytes this turn owes, sealed with it so a replay can finish an interrupted append.
|
|
64
|
+
*
|
|
65
|
+
* The rename is the publish point. A failure before it rejects (nothing was
|
|
66
|
+
* published); a failure after it — the directory fsync — must not, because
|
|
67
|
+
* the terminal record is already the visible truth and a caller that saw a
|
|
68
|
+
* rejection would believe the turn unsealed and write a contradicting
|
|
69
|
+
* record over it. That durability gap is reported as `directorySynced: false`
|
|
70
|
+
* instead: the record is published but may not survive a power loss.
|
|
71
|
+
*/
|
|
72
|
+
async finish(request, response, ledger = EMPTY_BROKER_TURN_LEDGER) {
|
|
73
|
+
const file = path.join(this.root, safe(request.turnId));
|
|
74
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
75
|
+
const handle = await open(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600);
|
|
76
|
+
try {
|
|
77
|
+
await handle.writeFile(`${JSON.stringify({ version: ENGINE_BROKER_TURN_RECORD_V2, digest: digest(request), state: "terminal", bootId: this.bootId, response, ledger })}\n`);
|
|
78
|
+
await handle.sync();
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
await handle.close();
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
await rename(temporary, file);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
await unlink(temporary).catch(() => undefined);
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
await this.syncDirectoryOf(this.root);
|
|
91
|
+
return { directorySynced: true };
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return { directorySynced: false };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Strict record parser. v2 accepts exactly `{version,digest,state,bootId}`
|
|
100
|
+
* plus `response` and its sealed `ledger` bytes when terminal, and the response must be a v2 terminal frame.
|
|
101
|
+
* v1 records keep their historical looser shape and are upgraded on read: no
|
|
102
|
+
* usage (`null`), zero requests, `limitReason: "none"`, the declared model.
|
|
103
|
+
*/
|
|
104
|
+
export function parseEngineBrokerTurnRecord(text, model) {
|
|
105
|
+
let value;
|
|
106
|
+
try {
|
|
107
|
+
value = JSON.parse(text);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
throw new Error("broker turn registry unavailable");
|
|
111
|
+
}
|
|
112
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
113
|
+
throw new Error("broker turn registry unavailable");
|
|
114
|
+
const input = value;
|
|
115
|
+
if (typeof input.digest !== "string" || !/^[a-f0-9]{64}$/u.test(input.digest) || typeof input.bootId !== "string" || (input.state !== "active" && input.state !== "terminal"))
|
|
116
|
+
throw new Error("broker turn registry unavailable");
|
|
117
|
+
const base = { digest: input.digest, state: input.state, bootId: input.bootId };
|
|
118
|
+
if (input.version === ENGINE_BROKER_TURN_RECORD_V1) {
|
|
119
|
+
if (input.state !== "terminal" || input.response === undefined)
|
|
120
|
+
return { version: ENGINE_BROKER_TURN_RECORD_V1, ...base };
|
|
121
|
+
let legacy;
|
|
122
|
+
try {
|
|
123
|
+
legacy = parseEngineBrokerV1TerminalResponse(input.response);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
throw new Error("broker turn registry unavailable");
|
|
127
|
+
}
|
|
128
|
+
const accounting = { outcome: legacy.kind, usage: null, model, requests: 0, limitReason: "none" };
|
|
129
|
+
const response = { ...legacy, ...accounting, version: "noopolis.daimon.engine-broker.v2" };
|
|
130
|
+
return { version: ENGINE_BROKER_TURN_RECORD_V1, ...base, response };
|
|
131
|
+
}
|
|
132
|
+
if (input.version !== ENGINE_BROKER_TURN_RECORD_V2)
|
|
133
|
+
throw new Error("broker turn conflict");
|
|
134
|
+
const fields = input.state === "terminal" ? ["version", "digest", "state", "bootId", "response", "ledger"] : ["version", "digest", "state", "bootId"];
|
|
135
|
+
if (Object.keys(input).length !== fields.length || fields.some((field) => !Object.hasOwn(input, field)))
|
|
136
|
+
throw new Error("broker turn registry unavailable");
|
|
137
|
+
if (input.state === "active")
|
|
138
|
+
return { version: ENGINE_BROKER_TURN_RECORD_V2, ...base };
|
|
139
|
+
let response;
|
|
140
|
+
try {
|
|
141
|
+
response = parseEngineBrokerResponse(input.response);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
throw new Error("broker turn registry unavailable");
|
|
145
|
+
}
|
|
146
|
+
if (response.kind !== "completed" && response.kind !== "failed")
|
|
147
|
+
throw new Error("broker turn registry unavailable");
|
|
148
|
+
const ledger = parseBrokerTurnLedgerLines(input.ledger, response.turnId);
|
|
149
|
+
if ((response.usage === null) !== (ledger.usage === null))
|
|
150
|
+
throw new Error("broker turn registry unavailable");
|
|
151
|
+
return { version: ENGINE_BROKER_TURN_RECORD_V2, ...base, response, ledger };
|
|
152
|
+
}
|
|
153
|
+
async function syncDirectory(directory) { const handle = await open(directory, constants.O_RDONLY); try {
|
|
154
|
+
await handle.sync();
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
await handle.close();
|
|
158
|
+
} }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AttentionRegistry } from "./attention.js";
|
|
2
|
+
import type { AgentHandle } from "../core/types.js";
|
|
3
|
+
import type { OrganizationRuntimeAgentConfig } from "./organizationRuntime.js";
|
|
4
|
+
import type { OrganizationRuntimePathAuthority } from "./physicalReadiness.js";
|
|
5
|
+
import type { EngineBrokerTurnClient } from "./engineBrokerControlClient.js";
|
|
6
|
+
/**
|
|
7
|
+
* The production-only bridge from a closed runtime engine intent to Daimon's
|
|
8
|
+
* existing one-agent harness. Configuration never carries a command or env.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startOrganizationRuntimeEngine(agent: OrganizationRuntimeAgentConfig, controlTokenEnv: string, paths?: ReturnType<OrganizationRuntimePathAuthority["forAgent"]>, agyBusAddress?: string, grokBroker?: EngineBrokerTurnClient, organizationAgents?: readonly OrganizationRuntimeAgentConfig[], sharedProtectedPaths?: readonly string[], attention?: AttentionRegistry): Promise<AgentHandle>;
|
|
11
|
+
export declare function grokSandboxProtectedPaths(currentAgentId: string, organizationAgents: readonly OrganizationRuntimeAgentConfig[], sharedProtectedPaths?: readonly string[]): readonly string[];
|
|
12
|
+
export declare function codexSandboxProtectedPaths(currentAgentId: string, currentAgent: OrganizationRuntimeAgentConfig, currentEngineHomePath: string, organizationAgents: readonly OrganizationRuntimeAgentConfig[], sharedProtectedPaths?: readonly string[]): readonly string[];
|
|
13
|
+
export declare function codexSandboxReadablePaths(currentAgent: OrganizationRuntimeAgentConfig): readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* CLI engines do not consume Pi's resource loader. Frame the same immutable
|
|
16
|
+
* identity in JSON so arbitrary names/instructions cannot change its shape.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The caller-owned prompt preamble.
|
|
20
|
+
*
|
|
21
|
+
* It names the mounted tools explicitly, because a CLI engine reaches Daimon's
|
|
22
|
+
* tools over MCP and an agent whose instructions name another engine's tool
|
|
23
|
+
* spelling can finish a turn having called nothing. The declared names are the
|
|
24
|
+
* caller's own configuration, not engine-supplied text.
|
|
25
|
+
*
|
|
26
|
+
* On Grok the bare names are not the callable ones: every Daimon tool is a
|
|
27
|
+
* deferred MCP tool of server `daimon`, and Grok 1.0.34 refuses an unqualified
|
|
28
|
+
* name before any HTTP ("Tool names must be qualified as `server__tool`"). This
|
|
29
|
+
* envelope used to instruct exactly that refused form. The correct rule is not
|
|
30
|
+
* restated here — it is rendered by `grokMountedToolNamingRule` in the same
|
|
31
|
+
* contract module that renders the worker's pinned system prompt, so the two
|
|
32
|
+
* texts cannot contradict each other again. Every other engine's sentence is
|
|
33
|
+
* unchanged, byte for byte.
|
|
34
|
+
*/
|
|
35
|
+
export declare function identityEnvelope(agent: OrganizationRuntimeAgentConfig, mountedToolNames?: readonly string[]): string;
|
|
36
|
+
//# sourceMappingURL=engineDispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineDispatcher.d.ts","sourceRoot":"","sources":["../../src/runtime/engineDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAM7E;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,8BAA8B,EACrC,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,UAAU,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC,EAChE,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,sBAAsB,EACnC,kBAAkB,CAAC,EAAE,SAAS,8BAA8B,EAAE,EAC9D,oBAAoB,GAAE,SAAS,MAAM,EAAO,EAC5C,SAAS,CAAC,EAAE,iBAAiB,GAC5B,OAAO,CAAC,WAAW,CAAC,CA8CtB;AAED,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,SAAS,8BAA8B,EAAE,EAC7D,oBAAoB,GAAE,SAAS,MAAM,EAAO,GAC3C,SAAS,MAAM,EAAE,CAYnB;AAED,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,8BAA8B,EAC5C,qBAAqB,EAAE,MAAM,EAC7B,kBAAkB,EAAE,SAAS,8BAA8B,EAAE,EAC7D,oBAAoB,GAAE,SAAS,MAAM,EAAO,GAC3C,SAAS,MAAM,EAAE,CAQnB;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,8BAA8B,GAC3C,SAAS,MAAM,EAAE,CAEnB;AAwDD;;;GAGG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,8BAA8B,EAAE,gBAAgB,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAkBxH"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { attentionTools } from "./attention.js";
|
|
2
|
+
import { grokDaimonToolName, grokMountedToolNamingRule } from "../contracts/grokWorkerContract.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { AGY_MAX_TOOL_TURNS, createCliSessionFactory, resolveCodexWakeTimeoutMs, resolveCodexWakeTokenCeiling, resolveEngineWakeLimitOverrides } from "../pi/cliSession.js";
|
|
5
|
+
import { GROK_DAIMON_SANDBOX_PROFILE, prepareAndVerifyGrokSandbox } from "../pi/grokSandbox.js";
|
|
6
|
+
import { PiHarnessAdapter } from "../pi/piHarness.js";
|
|
7
|
+
import { engineAuthFile, engineHomeName, prepareEngineExecutable, prepareEngineReadiness, readPortableEngineCredentialSecrets } from "./engineReadiness.js";
|
|
8
|
+
import { createProductionAgentTools } from "./productionAgentTools.js";
|
|
9
|
+
import { AGY_SUBSCRIPTION_REALM, GROK_SUBSCRIPTION_REALM } from "./contractManifest.js";
|
|
10
|
+
import { recordTurnUsage, resolveTurnUsageLedgerPath } from "./turnUsageLedger.js";
|
|
11
|
+
import { recordCodexTurnRequests } from "./turnRequestLedger.js";
|
|
12
|
+
/**
|
|
13
|
+
* The production-only bridge from a closed runtime engine intent to Daimon's
|
|
14
|
+
* existing one-agent harness. Configuration never carries a command or env.
|
|
15
|
+
*/
|
|
16
|
+
export async function startOrganizationRuntimeEngine(agent, controlTokenEnv, paths, agyBusAddress, grokBroker, organizationAgents, sharedProtectedPaths = [], attention) {
|
|
17
|
+
// A declared Grok model is enforced by the broker proxy and worker config;
|
|
18
|
+
// the direct path has neither, so it refuses rather than silently ignoring it.
|
|
19
|
+
if (agent.engine.kind === "grok" && agent.engine.model !== undefined && grokBroker === undefined)
|
|
20
|
+
throw new Error(`Agent ${agent.id} declares a Grok model, which requires the engine broker`);
|
|
21
|
+
await paths?.verify();
|
|
22
|
+
const canonicalAgent = paths === undefined ? agent : { ...agent, workspacePath: paths.workspacePath, runtimeHomePath: paths.runtimeHomePath };
|
|
23
|
+
const readiness = canonicalAgent.engine.kind === "grok" && grokBroker !== undefined
|
|
24
|
+
? { ...(await prepareEngineExecutable(canonicalAgent.id, "grok")), engineHomePath: path.join(canonicalAgent.runtimeHomePath, engineHomeName("grok")) }
|
|
25
|
+
: await prepareEngineReadiness(canonicalAgent, canonicalAgent.runtimeHomePath, agyBusAddress);
|
|
26
|
+
const wakeContext = {};
|
|
27
|
+
const grokSandbox = canonicalAgent.engine.kind === "grok" && paths !== undefined && organizationAgents !== undefined
|
|
28
|
+
? () => prepareAndVerifyGrokSandbox({
|
|
29
|
+
command: readiness.executablePath,
|
|
30
|
+
cwd: canonicalAgent.workspacePath,
|
|
31
|
+
engineHomePath: readiness.engineHomePath,
|
|
32
|
+
protectedPaths: grokSandboxProtectedPaths(canonicalAgent.id, organizationAgents, sharedProtectedPaths),
|
|
33
|
+
runtimeHomePath: canonicalAgent.runtimeHomePath
|
|
34
|
+
})
|
|
35
|
+
: undefined;
|
|
36
|
+
const codexSandboxPaths = canonicalAgent.engine.kind === "codex" && canonicalAgent.engine.codexSandbox !== undefined
|
|
37
|
+
? {
|
|
38
|
+
protectedPaths: codexSandboxProtectedPaths(canonicalAgent.id, canonicalAgent, readiness.engineHomePath, organizationAgents ?? [canonicalAgent], sharedProtectedPaths),
|
|
39
|
+
readablePaths: codexSandboxReadablePaths(canonicalAgent)
|
|
40
|
+
}
|
|
41
|
+
: undefined;
|
|
42
|
+
const mountedTools = [...await createProductionAgentTools(canonicalAgent, wakeContext), ...(agent.attention !== undefined && attention !== undefined ? attentionTools(agent.id, attention) : [])];
|
|
43
|
+
const adapter = adapterFor(canonicalAgent, controlTokenEnv, readiness.verify, readiness.executablePath, readiness.engineHomePath, paths?.verify, agyBusAddress, mountedTools, wakeContext, grokSandbox, grokBroker, codexSandboxPaths, mountedTools.map((tool) => tool.name));
|
|
44
|
+
const handle = await adapter.startAgent({
|
|
45
|
+
id: canonicalAgent.id,
|
|
46
|
+
name: canonicalAgent.name,
|
|
47
|
+
instructions: canonicalAgent.instructions,
|
|
48
|
+
runtimeHomePath: canonicalAgent.runtimeHomePath,
|
|
49
|
+
workspacePath: canonicalAgent.workspacePath
|
|
50
|
+
});
|
|
51
|
+
await paths?.verify();
|
|
52
|
+
const result = {
|
|
53
|
+
...handle,
|
|
54
|
+
async wake(event) {
|
|
55
|
+
await paths?.verify();
|
|
56
|
+
await readiness.verify();
|
|
57
|
+
try {
|
|
58
|
+
return await handle.wake(event);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
await paths?.verify();
|
|
62
|
+
await readiness.verify();
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async stop() { await handle.stop(); },
|
|
66
|
+
status: () => handle.status()
|
|
67
|
+
};
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
export function grokSandboxProtectedPaths(currentAgentId, organizationAgents, sharedProtectedPaths = []) {
|
|
71
|
+
return [
|
|
72
|
+
GROK_SUBSCRIPTION_REALM.bootstrapMountPath,
|
|
73
|
+
GROK_SUBSCRIPTION_REALM.durableMountPath,
|
|
74
|
+
...(organizationAgents.some((peer) => peer.engine.kind === "agy") ? [
|
|
75
|
+
AGY_SUBSCRIPTION_REALM.unlockMountPath,
|
|
76
|
+
AGY_SUBSCRIPTION_REALM.durableMountPath
|
|
77
|
+
] : []),
|
|
78
|
+
...sharedProtectedPaths,
|
|
79
|
+
...organizationAgents.filter((peer) => peer.id !== currentAgentId)
|
|
80
|
+
.flatMap((peer) => [peer.runtimeHomePath, peer.workspacePath])
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
export function codexSandboxProtectedPaths(currentAgentId, currentAgent, currentEngineHomePath, organizationAgents, sharedProtectedPaths = []) {
|
|
84
|
+
return [...new Set([
|
|
85
|
+
engineAuthFile("codex", currentEngineHomePath),
|
|
86
|
+
path.join(currentAgent.runtimeHomePath, ".daimon-inbound"),
|
|
87
|
+
"/proc",
|
|
88
|
+
"/run",
|
|
89
|
+
...grokSandboxProtectedPaths(currentAgentId, organizationAgents, sharedProtectedPaths)
|
|
90
|
+
])];
|
|
91
|
+
}
|
|
92
|
+
export function codexSandboxReadablePaths(currentAgent) {
|
|
93
|
+
return [path.join(currentAgent.runtimeHomePath, "tool-output")];
|
|
94
|
+
}
|
|
95
|
+
function adapterFor(agent, controlTokenEnv, verifyExecutable, executablePath, engineHomePath, verifyRuntimePaths, agyBusAddress, productionTools = [], wakeEnvironmentContext = {}, verifyGrokSandbox, grokBroker, codexSandboxPaths, mountedToolNames = []) {
|
|
96
|
+
const engine = agent.engine.kind;
|
|
97
|
+
const sessionFactory = createCliSessionFactory(engine === "agy"
|
|
98
|
+
? { engine, maxToolTurns: AGY_MAX_TOOL_TURNS, timeoutMs: 180_000, dbusSessionBusAddress: agyBusAddress, redactedEnvironmentNames: [controlTokenEnv], identityPrompt: identityEnvelope(agent, mountedToolNames), command: executablePath, engineHomePath, verifyExecutable, verifyRuntimePaths,
|
|
99
|
+
// AGY has no broker to meter it, so the session hands its decoded
|
|
100
|
+
// terminal-frame usage straight to the same ledger the Grok broker
|
|
101
|
+
// appends to. `recordTurnUsage` is advisory and never rejects.
|
|
102
|
+
onTurnUsage: (usage, outcome) => recordTurnUsage(resolveTurnUsageLedgerPath(), { agent: agent.id, wake: wakeEnvironmentContext.current ?? "wake", engine: "agy", usage, outcome }) }
|
|
103
|
+
: { engine, redactedEnvironmentNames: [controlTokenEnv], identityPrompt: identityEnvelope(agent, mountedToolNames), command: executablePath, engineHomePath, verifyExecutable, verifyRuntimePaths,
|
|
104
|
+
...(engine === "codex" ? {
|
|
105
|
+
// Codex has no broker to meter it, so publish terminal-frame usage
|
|
106
|
+
// to the shared advisory ledger — on the wake that published and on
|
|
107
|
+
// the wake that failed after Codex had already reported its spend.
|
|
108
|
+
onTurnUsage: (usage, outcome) => recordTurnUsage(resolveTurnUsageLedgerPath(), { agent: agent.id, wake: wakeEnvironmentContext.current ?? "wake", engine: "codex", usage, outcome }),
|
|
109
|
+
// Per-model-request accounting, written to its own stream beside the
|
|
110
|
+
// ledger. `engineHomePath` is the agent's `CODEX_HOME`
|
|
111
|
+
// (`../pi/cliEnvironment.ts`), so the rollout Codex just wrote for
|
|
112
|
+
// this thread is under it. Advisory throughout: it never fails a wake.
|
|
113
|
+
onCodexTurnRequests: (threadId) => recordCodexTurnRequests({ agent: agent.id, wake: wakeEnvironmentContext.current ?? "wake", codexHome: engineHomePath, threadId }).then(() => undefined),
|
|
114
|
+
// `maxToolTurns` mediates only daimon-MCP tool calls; Codex's own
|
|
115
|
+
// shell is never routed through it, so it gets its own wall-clock
|
|
116
|
+
// and per-wake token bounds instead (`cliSession.ts`).
|
|
117
|
+
timeoutMs: resolveCodexWakeTimeoutMs(),
|
|
118
|
+
codexTokenCeiling: resolveCodexWakeTokenCeiling(),
|
|
119
|
+
// Present only when the parsed config declared them; absent keeps
|
|
120
|
+
// today's unpinned Codex CLI default and today's exact argv.
|
|
121
|
+
...(agent.engine.model === undefined ? {} : { model: agent.engine.model }),
|
|
122
|
+
...(agent.engine.reasoningEffort === undefined ? {} : { reasoningEffort: agent.engine.reasoningEffort }),
|
|
123
|
+
...(agent.engine.codexSandbox === undefined ? {} : { codexSandbox: agent.engine.codexSandbox }),
|
|
124
|
+
...(codexSandboxPaths === undefined ? {} : {
|
|
125
|
+
codexSandboxProtectedPaths: codexSandboxPaths.protectedPaths,
|
|
126
|
+
codexSandboxReadablePaths: codexSandboxPaths.readablePaths
|
|
127
|
+
})
|
|
128
|
+
} : {}),
|
|
129
|
+
...(engine === "grok" && grokBroker !== undefined ? {} : { credentialSecretValues: () => readPortableEngineCredentialSecrets(agent.id, engine, engineHomePath) }),
|
|
130
|
+
// The broker seals usage and enforces its registration's limits; the
|
|
131
|
+
// wake may only lower them (DAIMON_ENGINE_WAKE_*), and a declared model
|
|
132
|
+
// must be the one the broker reports it ran.
|
|
133
|
+
...(engine === "grok" && grokBroker !== undefined ? { grokBrokerTurn: grokBrokerTurnFor(agent, grokBroker, wakeEnvironmentContext) } : {}),
|
|
134
|
+
...(engine === "grok" && verifyGrokSandbox ? {
|
|
135
|
+
grokSandboxProfile: GROK_DAIMON_SANDBOX_PROFILE,
|
|
136
|
+
verifyGrokSandbox
|
|
137
|
+
} : {}) });
|
|
138
|
+
return cliHarness(agent, sessionFactory, [controlTokenEnv], productionTools, wakeEnvironmentContext);
|
|
139
|
+
}
|
|
140
|
+
function grokBrokerTurnFor(agent, grokBroker, wakeEnvironmentContext) {
|
|
141
|
+
const limits = resolveEngineWakeLimitOverrides();
|
|
142
|
+
const options = { ...(limits === undefined ? {} : { limits }), ...(agent.engine.model === undefined ? {} : { model: agent.engine.model }) };
|
|
143
|
+
return (prompt, endpoint, signal) => grokBroker.turn(agent.id, wakeEnvironmentContext.current ?? "wake", prompt, endpoint, signal, options);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* CLI engines do not consume Pi's resource loader. Frame the same immutable
|
|
147
|
+
* identity in JSON so arbitrary names/instructions cannot change its shape.
|
|
148
|
+
*/
|
|
149
|
+
/**
|
|
150
|
+
* The caller-owned prompt preamble.
|
|
151
|
+
*
|
|
152
|
+
* It names the mounted tools explicitly, because a CLI engine reaches Daimon's
|
|
153
|
+
* tools over MCP and an agent whose instructions name another engine's tool
|
|
154
|
+
* spelling can finish a turn having called nothing. The declared names are the
|
|
155
|
+
* caller's own configuration, not engine-supplied text.
|
|
156
|
+
*
|
|
157
|
+
* On Grok the bare names are not the callable ones: every Daimon tool is a
|
|
158
|
+
* deferred MCP tool of server `daimon`, and Grok 1.0.34 refuses an unqualified
|
|
159
|
+
* name before any HTTP ("Tool names must be qualified as `server__tool`"). This
|
|
160
|
+
* envelope used to instruct exactly that refused form. The correct rule is not
|
|
161
|
+
* restated here — it is rendered by `grokMountedToolNamingRule` in the same
|
|
162
|
+
* contract module that renders the worker's pinned system prompt, so the two
|
|
163
|
+
* texts cannot contradict each other again. Every other engine's sentence is
|
|
164
|
+
* unchanged, byte for byte.
|
|
165
|
+
*/
|
|
166
|
+
export function identityEnvelope(agent, mountedToolNames = []) {
|
|
167
|
+
return [
|
|
168
|
+
"<daimon-agent-identity>",
|
|
169
|
+
JSON.stringify({ id: agent.id, name: agent.name, instructions: agent.instructions }),
|
|
170
|
+
"</daimon-agent-identity>",
|
|
171
|
+
...(mountedToolNames.length === 0 ? [] : [
|
|
172
|
+
(agent.engine.kind === "grok"
|
|
173
|
+
? grokMountedToolNamingRule(mountedToolNames)
|
|
174
|
+
: `Your mounted tools are exactly: ${mountedToolNames.join(", ")}. Call them by these names; `
|
|
175
|
+
+ "your instructions may spell them differently.")
|
|
176
|
+
+ " No other tool reaches the newsroom."
|
|
177
|
+
]),
|
|
178
|
+
// The one tool that reaches colleagues is named the way this engine can
|
|
179
|
+
// call it. Meaning and prohibition are unchanged; only the spelling is.
|
|
180
|
+
`Colleagues only hear you when you call ${engineToolName(agent, "moltnet_send")}; your terminal response is a private note to the runtime, not a message to anyone — keep it to one line or leave it empty. `
|
|
181
|
+
+ "Do not seek transport credentials or invoke a transport CLI unless the caller explicitly mounted an authenticated transport tool.",
|
|
182
|
+
"The following is the current wake event."
|
|
183
|
+
].join("\n") + "\n";
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* One Daimon tool name, spelled the way this agent's engine accepts it.
|
|
187
|
+
*
|
|
188
|
+
* On Grok the bare form is refused as an invalid MCP tool name, so any
|
|
189
|
+
* engine-facing sentence that *names* a tool renders it through the contract's
|
|
190
|
+
* `grokDaimonToolName`; every other engine keeps the bare name byte for byte.
|
|
191
|
+
* Grok's own native tools (`read_file`, `search_tool`, `use_tool`) are not
|
|
192
|
+
* Daimon tools and never take the prefix.
|
|
193
|
+
*/
|
|
194
|
+
const engineToolName = (agent, tool) => agent.engine.kind === "grok" ? grokDaimonToolName(tool) : tool;
|
|
195
|
+
function cliHarness(agent, sessionFactory, protectedEnvironmentNames, productionTools, wakeEnvironmentContext) {
|
|
196
|
+
return new PiHarnessAdapter({
|
|
197
|
+
authPath: path.join(agent.runtimeHomePath, "auth.json"),
|
|
198
|
+
// Pi owns the harness envelope while the session factory owns this CLI.
|
|
199
|
+
model: {
|
|
200
|
+
auth: { method: "none" },
|
|
201
|
+
endpoint: { baseUrl: "http://127.0.0.1/daimon-cli", compatibility: "openai" },
|
|
202
|
+
name: "daimon-cli",
|
|
203
|
+
provider: "daimon-cli"
|
|
204
|
+
},
|
|
205
|
+
sessionFactory,
|
|
206
|
+
protectedEnvironmentNames,
|
|
207
|
+
productionTools,
|
|
208
|
+
...(agent.engine.kind === "codex" && agent.engine.codexSandbox !== undefined ? { toolNames: [] } : {}),
|
|
209
|
+
wakeEnvironmentContext,
|
|
210
|
+
...(agent.memory === undefined ? {} : { memory: {
|
|
211
|
+
runtimeHomePath: agent.memory.runtimeHomePath,
|
|
212
|
+
...(agent.memory.source === undefined ? {} : { source: agent.memory.source }),
|
|
213
|
+
...(agent.memory.tokenBudget === undefined ? {} : { tokenBudget: agent.memory.tokenBudget })
|
|
214
|
+
} })
|
|
215
|
+
});
|
|
216
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OrganizationRuntimeAgentConfig } from "./organizationRuntime.js";
|
|
2
|
+
export type EngineReadiness = Readonly<{
|
|
3
|
+
executablePath: string;
|
|
4
|
+
engineHomePath: string;
|
|
5
|
+
verify(): Promise<void>;
|
|
6
|
+
}>;
|
|
7
|
+
export type EngineExecutableReadiness = Readonly<{
|
|
8
|
+
executablePath: string;
|
|
9
|
+
verify(): Promise<void>;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves and pins the small, local authority needed by one CLI engine. This
|
|
13
|
+
* deliberately does not start an agent, contact a provider, or read a secret
|
|
14
|
+
* beyond the bounded structural authentication check.
|
|
15
|
+
*/
|
|
16
|
+
export declare function prepareEngineReadiness(agent: OrganizationRuntimeAgentConfig, runtimeHomePath: string, agyBusAddress?: string): Promise<EngineReadiness>;
|
|
17
|
+
export declare function prepareEngineExecutable(agentId: string, engine: "codex" | "grok" | "agy"): Promise<EngineExecutableReadiness>;
|
|
18
|
+
export declare function engineHomeName(engine: "codex" | "grok"): string;
|
|
19
|
+
export declare function engineAuthFile(_engine: "codex" | "grok", engineHomePath: string): string;
|
|
20
|
+
/** Securely rereads the currently staged provider credential for exact output redaction. */
|
|
21
|
+
export declare function readPortableEngineCredentialSecrets(agentId: string, engine: "codex" | "grok", engineHomePath: string): Promise<readonly string[]>;
|
|
22
|
+
export declare function verifyAgySubscriptionEnrollment(agentId: string, executablePath: string, runtimeHomePath: string, busAddress: string | undefined): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=engineReadiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineReadiness.d.ts","sourceRoot":"","sources":["../../src/runtime/engineReadiness.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAM/E,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC,CAAC;AAIH;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,8BAA8B,EACrC,eAAe,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CAa1B;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAC/B,OAAO,CAAC,yBAAyB,CAAC,CAqBpC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAExF;AAqFD,4FAA4F;AAC5F,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,MAAM,EACxB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAqB5B;AAUD,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|