@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,367 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { open, readFile, readdir, rename, stat, unlink } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
+
import { resolveTurnUsageLedgerPath, TURN_USAGE_LEDGER, TURN_USAGE_MAX_IDENTIFIER_CHARS, TURN_USAGE_ROTATE_BYTES } from "./turnUsageLedger.js";
|
|
6
|
+
export const WAKE_FUSE_VERSION = "noopolis.daimon.wake-fuse.v1";
|
|
7
|
+
export const WAKE_FUSE_DIRECTORY_ENV = "DAIMON_WAKE_FUSE_DIRECTORY";
|
|
8
|
+
export const DEFAULT_WAKE_FUSE_MAX_WAKES = 100;
|
|
9
|
+
export const DEFAULT_WAKE_FUSE_MAX_TOKENS = 5_000_000;
|
|
10
|
+
const TRIP_MARKER = "fuse.trip.json";
|
|
11
|
+
let warnedDisarmed = false;
|
|
12
|
+
/**
|
|
13
|
+
* Durable catastrophic-wake admission fuse for one organization/container.
|
|
14
|
+
*
|
|
15
|
+
* Operator trip: `docker exec <container> touch /var/lib/spawnfile/daimon/usage/fuse.stop`.
|
|
16
|
+
* Unlike `recordTurnUsage` ("advisory: never rejects"), every storage or
|
|
17
|
+
* evaluation failure here rejects admission: this safety boundary fails closed.
|
|
18
|
+
*/
|
|
19
|
+
export class WakeFuse {
|
|
20
|
+
armed;
|
|
21
|
+
directory;
|
|
22
|
+
epoch;
|
|
23
|
+
epochStartedAt;
|
|
24
|
+
maxWakes;
|
|
25
|
+
maxTokens;
|
|
26
|
+
admissions;
|
|
27
|
+
usageLedgerPath;
|
|
28
|
+
now;
|
|
29
|
+
serial = Promise.resolve();
|
|
30
|
+
reason;
|
|
31
|
+
tripMarkerMissing = false;
|
|
32
|
+
constructor(armed, directory, epoch, epochStartedAt, maxWakes, maxTokens, admissions, usageLedgerPath, now) {
|
|
33
|
+
this.armed = armed;
|
|
34
|
+
this.directory = directory;
|
|
35
|
+
this.epoch = epoch;
|
|
36
|
+
this.epochStartedAt = epochStartedAt;
|
|
37
|
+
this.maxWakes = maxWakes;
|
|
38
|
+
this.maxTokens = maxTokens;
|
|
39
|
+
this.admissions = admissions;
|
|
40
|
+
this.usageLedgerPath = usageLedgerPath;
|
|
41
|
+
this.now = now;
|
|
42
|
+
}
|
|
43
|
+
static async open(options) {
|
|
44
|
+
const environment = options.environment ?? process.env;
|
|
45
|
+
const setting = environment.DAIMON_WAKE_FUSE;
|
|
46
|
+
if (setting !== undefined && setting !== "off")
|
|
47
|
+
throw new Error("DAIMON_WAKE_FUSE must be exactly 'off' when set");
|
|
48
|
+
if (environment.DAIMON_WAKE_FUSE_EPOCH !== undefined && nonBlank(environment.DAIMON_WAKE_FUSE_EPOCH) === undefined)
|
|
49
|
+
throw new Error("DAIMON_WAKE_FUSE_EPOCH must be non-blank");
|
|
50
|
+
const epoch = nonBlank(environment.DAIMON_WAKE_FUSE_EPOCH)
|
|
51
|
+
// Agent ids are the stable organization identity available to Daimon.
|
|
52
|
+
?? `organization-${createHash("sha256").update(options.organizationKey).digest("hex")}`;
|
|
53
|
+
const maxWakes = ceiling(environment.DAIMON_WAKE_FUSE_MAX_WAKES, DEFAULT_WAKE_FUSE_MAX_WAKES, "DAIMON_WAKE_FUSE_MAX_WAKES");
|
|
54
|
+
const maxTokens = ceiling(environment.DAIMON_WAKE_FUSE_MAX_TOKENS, DEFAULT_WAKE_FUSE_MAX_TOKENS, "DAIMON_WAKE_FUSE_MAX_TOKENS");
|
|
55
|
+
const directory = resolveWakeFuseDirectory(environment);
|
|
56
|
+
const now = options.now ?? (() => new Date());
|
|
57
|
+
const usageLedgerPath = resolveTurnUsageLedgerPath(environment);
|
|
58
|
+
if (setting === "off") {
|
|
59
|
+
if (!warnedDisarmed) {
|
|
60
|
+
warnedDisarmed = true;
|
|
61
|
+
console.error("DAIMON WAKE FUSE IS OFF: wake admission is unbounded");
|
|
62
|
+
}
|
|
63
|
+
return new WakeFuse(false, directory, epoch, now().toISOString(), maxWakes, maxTokens, new Set(), usageLedgerPath, now);
|
|
64
|
+
}
|
|
65
|
+
// Unbounded defaults would reproduce exactly the failure this module prevents.
|
|
66
|
+
await readdir(directory);
|
|
67
|
+
await ensureUsageLedgerUsable(usageLedgerPath);
|
|
68
|
+
const records = await readFuseRecords(directory);
|
|
69
|
+
const existingStart = records.filter((record) => record.kind === "epoch_start" && record.epoch === epoch).at(-1);
|
|
70
|
+
const epochStartedAt = existingStart?.at ?? now().toISOString();
|
|
71
|
+
if (existingStart === undefined)
|
|
72
|
+
await append(directory, { v: WAKE_FUSE_VERSION, kind: "epoch_start", epoch, at: epochStartedAt });
|
|
73
|
+
const admissions = new Set(records
|
|
74
|
+
.filter((record) => record.kind === "admission" && record.epoch === epoch)
|
|
75
|
+
.map((record) => key(record.agent, record.delivery)));
|
|
76
|
+
const fuse = new WakeFuse(true, directory, epoch, epochStartedAt, maxWakes, maxTokens, admissions, usageLedgerPath, now);
|
|
77
|
+
if (await exists(path.join(directory, "fuse.stop")))
|
|
78
|
+
fuse.reason = "operator_stop";
|
|
79
|
+
else
|
|
80
|
+
fuse.reason = await readTripMarker(directory, epoch);
|
|
81
|
+
return fuse;
|
|
82
|
+
}
|
|
83
|
+
admit(agentId, deliveryId, limits = {}) {
|
|
84
|
+
if (!this.armed)
|
|
85
|
+
return Promise.resolve({ state: "admitted" });
|
|
86
|
+
// One organization is one container/control-host process. This promise
|
|
87
|
+
// chain is organization-wide in-process serialization, not cross-process locking.
|
|
88
|
+
const result = this.serial.catch(() => undefined).then(async () => await this.admitNow(agentId, deliveryId, limits));
|
|
89
|
+
this.serial = result.then(() => undefined, () => undefined);
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
async snapshot(agentId, limits = {}) {
|
|
93
|
+
const used = this.admissions.size;
|
|
94
|
+
const agentUsed = [...this.admissions].filter((entry) => entry.startsWith(`${bounded(agentId)}\u0000`)).length;
|
|
95
|
+
const tokens = this.armed ? await sumTokens(this.usageLedgerPath, this.epochStartedAt) : 0;
|
|
96
|
+
const agentTokens = this.armed ? await sumTokens(this.usageLedgerPath, this.epochStartedAt, agentId) : 0;
|
|
97
|
+
const reason = this.reason ?? (this.armed ? used >= this.maxWakes ? "wake_ceiling" : tokens >= this.maxTokens ? "token_ceiling" : limits.maxExecutions !== undefined && agentUsed >= limits.maxExecutions ? "agent_execution_ceiling" : limits.maxTokens !== undefined && agentTokens >= limits.maxTokens ? "agent_token_ceiling" : undefined : undefined);
|
|
98
|
+
return { armed: this.armed, epoch: this.epoch, state: reason === undefined ? "available" : reason === "operator_stop" || reason === "ledger_unavailable" ? "stopped" : "paused", ...(reason === undefined ? {} : { reason }), executions_used: used, executions_remaining: Math.max(0, this.maxWakes - used), tokens_used: tokens, tokens_remaining: Math.max(0, this.maxTokens - tokens), agent_executions_used: agentUsed, agent_tokens_used: agentTokens, ...(limits.maxExecutions === undefined ? {} : { agent_executions_remaining: Math.max(0, limits.maxExecutions - agentUsed) }), ...(limits.maxTokens === undefined ? {} : { agent_tokens_remaining: Math.max(0, limits.maxTokens - agentTokens) }) };
|
|
99
|
+
}
|
|
100
|
+
async pollOperatorStop() {
|
|
101
|
+
if (!this.armed || this.reason === "operator_stop" || this.reason === "ledger_unavailable")
|
|
102
|
+
return this.reason;
|
|
103
|
+
try {
|
|
104
|
+
if (await exists(path.join(this.directory, "fuse.stop")))
|
|
105
|
+
await this.trip("operator_stop");
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
await this.trip("ledger_unavailable");
|
|
109
|
+
}
|
|
110
|
+
return this.reason;
|
|
111
|
+
}
|
|
112
|
+
tripped() { return this.reason; }
|
|
113
|
+
async close() { await this.serial; }
|
|
114
|
+
async admitNow(agentId, deliveryId, limits) {
|
|
115
|
+
if (this.reason !== undefined)
|
|
116
|
+
return await this.trip(this.reason);
|
|
117
|
+
try {
|
|
118
|
+
if (await exists(path.join(this.directory, "fuse.stop")))
|
|
119
|
+
return await this.trip("operator_stop");
|
|
120
|
+
const admissionKey = key(bounded(agentId), bounded(deliveryId));
|
|
121
|
+
if (this.admissions.has(admissionKey))
|
|
122
|
+
return { state: "admitted" };
|
|
123
|
+
const budget = await this.snapshot(agentId, limits);
|
|
124
|
+
if (budget.agent_executions_remaining === 0)
|
|
125
|
+
return { state: "paused", reason: "agent_execution_ceiling" };
|
|
126
|
+
if (budget.agent_tokens_remaining === 0)
|
|
127
|
+
return { state: "paused", reason: "agent_token_ceiling" };
|
|
128
|
+
if (this.admissions.size >= this.maxWakes)
|
|
129
|
+
return await this.trip("wake_ceiling");
|
|
130
|
+
// Lagging indicator: usage is written after turn completion, so in-flight
|
|
131
|
+
// spend can overshoot by one concurrent round. The wake ceiling bounds it;
|
|
132
|
+
// design §5.2 owns the later pre-spawn reservation.
|
|
133
|
+
if (await sumTokens(this.usageLedgerPath, this.epochStartedAt) >= this.maxTokens)
|
|
134
|
+
return await this.trip("token_ceiling");
|
|
135
|
+
const record = { v: WAKE_FUSE_VERSION, kind: "admission", epoch: this.epoch, at: this.now().toISOString(), agent: bounded(agentId), delivery: bounded(deliveryId) };
|
|
136
|
+
await append(this.directory, record);
|
|
137
|
+
this.admissions.add(admissionKey);
|
|
138
|
+
return { state: "admitted" };
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return await this.trip("ledger_unavailable");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async trip(reason) {
|
|
145
|
+
if (this.reason === undefined || (reason === "operator_stop" || reason === "ledger_unavailable") && this.reason !== "operator_stop" && this.reason !== "ledger_unavailable") {
|
|
146
|
+
this.reason = reason;
|
|
147
|
+
this.tripMarkerMissing = true;
|
|
148
|
+
}
|
|
149
|
+
if (this.tripMarkerMissing) {
|
|
150
|
+
try {
|
|
151
|
+
await writeTripMarker(this.directory, { v: WAKE_FUSE_VERSION, kind: "trip", epoch: this.epoch, at: this.now().toISOString(), reason: this.reason });
|
|
152
|
+
this.tripMarkerMissing = false;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// Keep the in-memory fuse closed and retry durability on every later
|
|
156
|
+
// admit/trip. Marker I/O must never turn a tripped verdict into an
|
|
157
|
+
// unhandled rejection at the HTTP boundary.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { state: "tripped", reason: this.reason };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function resolveWakeFuseDirectory(environment = process.env) {
|
|
164
|
+
const override = environment[WAKE_FUSE_DIRECTORY_ENV]?.trim();
|
|
165
|
+
return override !== undefined && override.startsWith("/") ? override : TURN_USAGE_LEDGER.directoryPath;
|
|
166
|
+
}
|
|
167
|
+
function ceiling(value, fallback, name) {
|
|
168
|
+
if (value === undefined)
|
|
169
|
+
return fallback;
|
|
170
|
+
const parsed = Number(value);
|
|
171
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0)
|
|
172
|
+
throw new Error(`${name} must be a positive integer`);
|
|
173
|
+
return parsed;
|
|
174
|
+
}
|
|
175
|
+
function nonBlank(value) { const trimmed = value?.trim(); return trimmed ? trimmed : undefined; }
|
|
176
|
+
function bounded(value) { return [...value].slice(0, TURN_USAGE_MAX_IDENTIFIER_CHARS).join(""); }
|
|
177
|
+
function key(agent, delivery) { return `${agent}\u0000${delivery}`; }
|
|
178
|
+
function admissionsPath(directory) { return path.join(directory, "admissions.jsonl"); }
|
|
179
|
+
async function append(directory, record) {
|
|
180
|
+
const file = admissionsPath(directory);
|
|
181
|
+
try {
|
|
182
|
+
if ((await stat(file)).size >= TURN_USAGE_ROTATE_BYTES)
|
|
183
|
+
await rename(file, `${file}.1`);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
if (error.code !== "ENOENT")
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
const bytes = Buffer.from(`${JSON.stringify(record)}\n`, "utf8");
|
|
190
|
+
const handle = await open(file, constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | constants.O_NOFOLLOW, TURN_USAGE_LEDGER.fileMode);
|
|
191
|
+
try {
|
|
192
|
+
const result = await handle.write(bytes, 0, bytes.length);
|
|
193
|
+
if (result.bytesWritten !== bytes.length)
|
|
194
|
+
throw new Error("wake fuse admission append was torn");
|
|
195
|
+
await handle.sync();
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
await handle.close();
|
|
199
|
+
}
|
|
200
|
+
await syncDirectory(directory);
|
|
201
|
+
}
|
|
202
|
+
async function syncDirectory(directory) { const handle = await open(directory, constants.O_RDONLY); try {
|
|
203
|
+
await handle.sync();
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
await handle.close();
|
|
207
|
+
} }
|
|
208
|
+
async function readFuseRecords(directory) {
|
|
209
|
+
const records = [];
|
|
210
|
+
for (const file of [`${admissionsPath(directory)}.1`, admissionsPath(directory)]) {
|
|
211
|
+
for (const line of await lines(file)) {
|
|
212
|
+
try {
|
|
213
|
+
const value = JSON.parse(line);
|
|
214
|
+
if (value.v !== WAKE_FUSE_VERSION || typeof value.epoch !== "string" || typeof value.at !== "string" || Number.isNaN(Date.parse(value.at)))
|
|
215
|
+
continue;
|
|
216
|
+
if (value.kind === "epoch_start")
|
|
217
|
+
records.push(value);
|
|
218
|
+
else if (value.kind === "admission" && typeof value.agent === "string" && typeof value.delivery === "string")
|
|
219
|
+
records.push(value);
|
|
220
|
+
}
|
|
221
|
+
catch { /* malformed historical fuse lines do not count */ }
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return records;
|
|
225
|
+
}
|
|
226
|
+
async function sumTokens(ledgerPath, since, agentId) {
|
|
227
|
+
let total = 0;
|
|
228
|
+
// Rows carrying a `turn` idempotency key count once per turn, whichever file holds them.
|
|
229
|
+
const turns = new Set();
|
|
230
|
+
for (const file of [`${ledgerPath}.1`, ledgerPath]) {
|
|
231
|
+
for (const line of await lines(file)) {
|
|
232
|
+
try {
|
|
233
|
+
const value = JSON.parse(line);
|
|
234
|
+
// Evaluator inference rows belong to their own ledger; one here (a misconfigured path) is never subject spend.
|
|
235
|
+
if (value.kind === "inference")
|
|
236
|
+
continue;
|
|
237
|
+
if (typeof value.turn === "string") {
|
|
238
|
+
if (turns.has(value.turn))
|
|
239
|
+
continue;
|
|
240
|
+
turns.add(value.turn);
|
|
241
|
+
}
|
|
242
|
+
if ((agentId === undefined || value.agent === agentId) && typeof value.at === "string" && !Number.isNaN(Date.parse(value.at)) && value.at >= since && typeof value.total === "number" && Number.isFinite(value.total) && value.total >= 0)
|
|
243
|
+
total += value.total;
|
|
244
|
+
}
|
|
245
|
+
catch { /* usage accounting is advisory input; malformed lines are skipped */ }
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return total;
|
|
249
|
+
}
|
|
250
|
+
async function writeTripMarker(directory, marker) {
|
|
251
|
+
const target = path.join(directory, TRIP_MARKER);
|
|
252
|
+
const temporary = path.join(directory, `.${TRIP_MARKER}.${process.pid}.${randomUUID()}`);
|
|
253
|
+
const bytes = Buffer.from(`${JSON.stringify(marker)}\n`, "utf8");
|
|
254
|
+
try {
|
|
255
|
+
const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, TURN_USAGE_LEDGER.fileMode);
|
|
256
|
+
try {
|
|
257
|
+
const result = await handle.write(bytes, 0, bytes.length);
|
|
258
|
+
if (result.bytesWritten !== bytes.length)
|
|
259
|
+
throw new Error("wake fuse trip marker write was torn");
|
|
260
|
+
await handle.sync();
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
await handle.close();
|
|
264
|
+
}
|
|
265
|
+
await rename(temporary, target);
|
|
266
|
+
await syncDirectory(directory);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
await unlink(temporary).catch(() => undefined);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function readTripMarker(directory, epoch) {
|
|
273
|
+
try {
|
|
274
|
+
const value = JSON.parse(await readFile(path.join(directory, TRIP_MARKER), "utf8"));
|
|
275
|
+
if (value.v !== WAKE_FUSE_VERSION || value.kind !== "trip" || typeof value.epoch !== "string" || typeof value.at !== "string" || Number.isNaN(Date.parse(value.at)) || !isTripReason(value.reason))
|
|
276
|
+
return "ledger_unavailable";
|
|
277
|
+
// A valid marker belongs to one explicit counting window. Selecting a new
|
|
278
|
+
// epoch deliberately clears it; a corrupt marker cannot prove that and fails closed.
|
|
279
|
+
return value.epoch === epoch ? value.reason : undefined;
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
if (error.code === "ENOENT")
|
|
283
|
+
return undefined;
|
|
284
|
+
return "ledger_unavailable";
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function isTripReason(value) { return value === "wake_ceiling" || value === "token_ceiling" || value === "operator_stop" || value === "ledger_unavailable"; }
|
|
288
|
+
async function lines(file) { try {
|
|
289
|
+
return (await readFile(file, "utf8")).split("\n").filter(Boolean);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (error.code === "ENOENT")
|
|
293
|
+
return [];
|
|
294
|
+
throw error;
|
|
295
|
+
} }
|
|
296
|
+
/**
|
|
297
|
+
* An unenforceable usage ledger at arm time must never degrade to a silent
|
|
298
|
+
* zero. `sumTokens` (used on every later `admit`) deliberately treats a
|
|
299
|
+
* missing ledger as an empty one — if the ledger is deleted mid-epoch, the
|
|
300
|
+
* fuse still needs to keep functioning rather than wedge the organization —
|
|
301
|
+
* but that same tolerance is exactly how a 17.6M-token run passed a 5M
|
|
302
|
+
* ceiling untouched: the ledger was never created at all, so every sum read
|
|
303
|
+
* zero and the ceiling never had anything to compare against.
|
|
304
|
+
*
|
|
305
|
+
* Four states, distinguished by what actually makes the ceiling
|
|
306
|
+
* unenforceable versus merely unwritten yet:
|
|
307
|
+
* - The ledger directory is missing, or present but not writable by this
|
|
308
|
+
* uid: the ceiling is genuinely unenforceable. Fails loudly, the same
|
|
309
|
+
* treatment `readdir(directory)` above already gives a missing
|
|
310
|
+
* admissions directory.
|
|
311
|
+
* - The directory is present and writable but the ledger file itself is
|
|
312
|
+
* absent: Spawnfile's entrypoint provisions and chows the directory as a
|
|
313
|
+
* persistent volume before the first turn ever writes usage
|
|
314
|
+
* (`renderDaimonUsageLedgerProvisioning`), so a brand-new organization
|
|
315
|
+
* legitimately has zero recorded spend. That is a true zero, not an
|
|
316
|
+
* unknown one — but only once this durably creates the (empty) ledger
|
|
317
|
+
* itself and verifies the result is readable, rather than assuming a
|
|
318
|
+
* missing file means zero.
|
|
319
|
+
* - The ledger file exists and is readable: arm normally; `sumTokens` sums
|
|
320
|
+
* whatever is in it.
|
|
321
|
+
* - The ledger file exists but is unreadable (EACCES, EISDIR, ...): fails
|
|
322
|
+
* loudly, exactly as before.
|
|
323
|
+
*/
|
|
324
|
+
async function ensureUsageLedgerUsable(ledgerPath) {
|
|
325
|
+
try {
|
|
326
|
+
await readFile(ledgerPath, "utf8");
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
const code = error.code;
|
|
331
|
+
if (code !== "ENOENT") {
|
|
332
|
+
throw new Error(`DAIMON_WAKE_FUSE cannot start: usage ledger at ${ledgerPath} is missing or unreadable (${code ?? String(error)}); refusing to admit wakes against an unenforceable token ceiling`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// Ledger file absent. Create it empty, matching the mode the broker itself
|
|
336
|
+
// writes usage records with, so a fresh organization can start.
|
|
337
|
+
try {
|
|
338
|
+
const handle = await open(ledgerPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, TURN_USAGE_LEDGER.fileMode);
|
|
339
|
+
await handle.close();
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
const code = error.code;
|
|
343
|
+
// EEXIST means a concurrent writer created it first (e.g. a racing turn
|
|
344
|
+
// append); that is not a creation failure, so fall through to verify.
|
|
345
|
+
if (code !== "EEXIST") {
|
|
346
|
+
throw new Error(`DAIMON_WAKE_FUSE cannot start: usage ledger at ${ledgerPath} is missing and could not be created (${code ?? String(error)}); refusing to admit wakes against an unenforceable token ceiling`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Never assume the create succeeded: read the file back before treating
|
|
350
|
+
// the ceiling as enforceable.
|
|
351
|
+
try {
|
|
352
|
+
await readFile(ledgerPath, "utf8");
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
const code = error.code ?? String(error);
|
|
356
|
+
throw new Error(`DAIMON_WAKE_FUSE cannot start: usage ledger at ${ledgerPath} is missing or unreadable (${code}); refusing to admit wakes against an unenforceable token ceiling`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async function exists(file) { try {
|
|
360
|
+
await stat(file);
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
if (error.code === "ENOENT")
|
|
365
|
+
return false;
|
|
366
|
+
throw error;
|
|
367
|
+
} }
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noopolis/daimon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Noopolis native per-agent runtime harness built on Pi.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"daimon-runtime": "dist/runtime/cli.js"
|
|
11
|
+
},
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
14
|
"types": "./dist/index.d.ts",
|
|
@@ -18,6 +21,10 @@
|
|
|
18
21
|
"./observability": {
|
|
19
22
|
"types": "./dist/observability/index.d.ts",
|
|
20
23
|
"import": "./dist/observability/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./runtime": {
|
|
26
|
+
"types": "./dist/runtime/index.d.ts",
|
|
27
|
+
"import": "./dist/runtime/index.js"
|
|
21
28
|
}
|
|
22
29
|
},
|
|
23
30
|
"files": [
|
|
@@ -32,36 +39,37 @@
|
|
|
32
39
|
"access": "public"
|
|
33
40
|
},
|
|
34
41
|
"scripts": {
|
|
35
|
-
"build": "rm -rf dist && tsc --project tsconfig.build.json",
|
|
42
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json && node --import tsx scripts/emitRuntimeContractManifest.ts && node --experimental-strip-types src/runtime/native/copyArtifact.ts",
|
|
43
|
+
"build:test-runtime": "rm -rf dist-test-runtime && tsc --project tsconfig.test-runtime.json",
|
|
36
44
|
"clean": "rm -rf dist",
|
|
37
45
|
"prepack": "npm run build",
|
|
38
46
|
"prepublishOnly": "npm run typecheck && npm test",
|
|
39
|
-
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
40
|
-
"
|
|
47
|
+
"typecheck": "tsc --project tsconfig.json --noEmit && tsc --project scripts/tsconfig.json --noEmit",
|
|
48
|
+
"verify:contract-manifest": "node --import tsx scripts/emitRuntimeContractManifest.ts --check",
|
|
49
|
+
"verify:native": "node --experimental-strip-types src/runtime/native/verifyArtifacts.ts",
|
|
50
|
+
"verify:production-closure": "node --experimental-strip-types scripts/verifyProductionClosure.ts",
|
|
51
|
+
"test": "node --import tsx --test \"src/**/*.test.ts\" scripts/scriptSourcePolicy.test.ts",
|
|
52
|
+
"emit-causal-fixture": "tsx src/observability/emitCausalFixture.ts",
|
|
53
|
+
"emit-causal-fixture:spoof": "tsx src/observability/emitCausalFixture.ts --spoof",
|
|
54
|
+
"live:codex-session": "node --import tsx scripts/liveCodexSession.ts",
|
|
55
|
+
"live:grok-broker": "node --import tsx scripts/liveGrokBrokerSession.ts",
|
|
41
56
|
"e2e:pi-agent": "tsx src/examples/pi-agent.ts",
|
|
42
57
|
"e2e:pi-memory-org": "tsx src/examples/pi-memory-org.ts",
|
|
43
|
-
"e2e:mixed-engine-org": "tsx src/examples/mixed-engine-org.ts",
|
|
44
58
|
"e2e:jungian-play-org": "tsx src/examples/jungian-play-org.ts",
|
|
45
|
-
"e2e:jungian-triad-org": "tsx src/examples/jungian-triad-org.ts"
|
|
46
|
-
"image:runtime:local": "docker build -f Dockerfile.runtime -t noopolis/spawnfile-runtime-daimon:0.1.1-local --build-arg DAIMON_VERSION=0.1.1 --build-arg MNEME_VERSION=0.1.0 --build-arg PI_VERSION=0.79.10 ."
|
|
59
|
+
"e2e:jungian-triad-org": "tsx src/examples/jungian-triad-org.ts"
|
|
47
60
|
},
|
|
48
61
|
"engines": {
|
|
49
62
|
"node": ">=22.19.0"
|
|
50
63
|
},
|
|
51
64
|
"dependencies": {
|
|
52
65
|
"@earendil-works/pi-ai": "^0.79.10",
|
|
53
|
-
"@earendil-works/pi-coding-agent": "^0.79.10"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
"peerDependenciesMeta": {
|
|
59
|
-
"@noopolis/mneme": {
|
|
60
|
-
"optional": true
|
|
61
|
-
}
|
|
66
|
+
"@earendil-works/pi-coding-agent": "^0.79.10",
|
|
67
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
68
|
+
"@noopolis/mneme": "^0.1.1",
|
|
69
|
+
"ajv": "^8.17.1",
|
|
70
|
+
"zod": "^4.4.3"
|
|
62
71
|
},
|
|
63
72
|
"devDependencies": {
|
|
64
|
-
"@noopolis/mneme": "^0.1.0",
|
|
65
73
|
"@types/node": "^24.12.4",
|
|
66
74
|
"tsx": "^4.21.0",
|
|
67
75
|
"typescript": "^5.9.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixed-engine-org.d.ts","sourceRoot":"","sources":["../../src/examples/mixed-engine-org.ts"],"names":[],"mappings":""}
|