@noopolis/daimon 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +275 -51
- package/dist/contracts/attentionContract.d.ts +142 -0
- package/dist/contracts/attentionContract.d.ts.map +1 -0
- package/dist/contracts/attentionContract.js +21 -0
- package/dist/contracts/canonicalJson.d.ts +3 -0
- package/dist/contracts/canonicalJson.d.ts.map +1 -0
- package/dist/contracts/canonicalJson.js +54 -0
- package/dist/contracts/grokBrokerTaskClock.d.ts +18 -0
- package/dist/contracts/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/contracts/grokBrokerTaskClock.js +16 -0
- package/dist/contracts/grokWorkerContract.d.ts +74 -0
- package/dist/contracts/grokWorkerContract.d.ts.map +1 -0
- package/dist/contracts/grokWorkerContract.js +88 -0
- package/dist/contracts/organizationRuntimeContract.d.ts +841 -0
- package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
- package/dist/contracts/organizationRuntimeContract.js +123 -0
- package/dist/contracts/runtimeContractManifest.d.ts +1822 -0
- package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
- package/dist/contracts/runtimeContractManifest.js +206 -0
- package/dist/contracts/shellEnvironmentPolicy.d.ts +3 -0
- package/dist/contracts/shellEnvironmentPolicy.d.ts.map +1 -0
- package/dist/contracts/shellEnvironmentPolicy.js +5 -0
- package/dist/contracts/wakeMomentContract.d.ts +61 -0
- package/dist/contracts/wakeMomentContract.d.ts.map +1 -0
- package/dist/contracts/wakeMomentContract.js +27 -0
- package/dist/core/credentialRedaction.d.ts +4 -0
- package/dist/core/credentialRedaction.d.ts.map +1 -0
- package/dist/core/credentialRedaction.js +28 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.d.ts +1 -0
- package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.js +6 -2
- package/dist/mcp/toolServer.d.ts +19 -2
- package/dist/mcp/toolServer.d.ts.map +1 -1
- package/dist/mcp/toolServer.js +57 -17
- package/dist/observability/causalEvents.d.ts +6 -6
- package/dist/observability/causalEvents.d.ts.map +1 -1
- package/dist/observability/causalEvents.js +107 -19
- package/dist/observability/orgObserver.d.ts.map +1 -1
- package/dist/observability/orgObserver.js +3 -3
- package/dist/pi/agyHeadlessResult.d.ts +60 -0
- package/dist/pi/agyHeadlessResult.d.ts.map +1 -0
- package/dist/pi/agyHeadlessResult.js +95 -0
- package/dist/pi/cliChildOutput.d.ts +67 -0
- package/dist/pi/cliChildOutput.d.ts.map +1 -0
- package/dist/pi/cliChildOutput.js +269 -0
- package/dist/pi/cliEngineRun.d.ts +16 -0
- package/dist/pi/cliEngineRun.d.ts.map +1 -0
- package/dist/pi/cliEngineRun.js +27 -0
- package/dist/pi/cliEngineSpawn.d.ts +55 -0
- package/dist/pi/cliEngineSpawn.d.ts.map +1 -0
- package/dist/pi/cliEngineSpawn.js +169 -0
- package/dist/pi/cliEnvironment.d.ts +12 -0
- package/dist/pi/cliEnvironment.d.ts.map +1 -0
- package/dist/pi/cliEnvironment.js +34 -0
- package/dist/pi/cliMcpRegistration.d.ts +61 -0
- package/dist/pi/cliMcpRegistration.d.ts.map +1 -0
- package/dist/pi/cliMcpRegistration.js +75 -0
- package/dist/pi/cliProcess.d.ts +7 -0
- package/dist/pi/cliProcess.d.ts.map +1 -0
- package/dist/pi/cliProcess.js +132 -0
- package/dist/pi/cliSession.d.ts +86 -24
- package/dist/pi/cliSession.d.ts.map +1 -1
- package/dist/pi/cliSession.js +251 -173
- package/dist/pi/cliSessionMcp.d.ts +9 -0
- package/dist/pi/cliSessionMcp.d.ts.map +1 -0
- package/dist/pi/cliSessionMcp.js +80 -0
- package/dist/pi/cliTurnMetering.d.ts +60 -0
- package/dist/pi/cliTurnMetering.d.ts.map +1 -0
- package/dist/pi/cliTurnMetering.js +60 -0
- package/dist/pi/codexFilesystemRules.d.ts +3 -0
- package/dist/pi/codexFilesystemRules.d.ts.map +1 -0
- package/dist/pi/codexFilesystemRules.js +28 -0
- package/dist/pi/codexHeadlessResult.d.ts +68 -0
- package/dist/pi/codexHeadlessResult.d.ts.map +1 -0
- package/dist/pi/codexHeadlessResult.js +122 -0
- package/dist/pi/codexRolloutUsage.d.ts +95 -0
- package/dist/pi/codexRolloutUsage.d.ts.map +1 -0
- package/dist/pi/codexRolloutUsage.js +221 -0
- package/dist/pi/engineTaskClock.d.ts +9 -0
- package/dist/pi/engineTaskClock.d.ts.map +1 -0
- package/dist/pi/engineTaskClock.js +28 -0
- package/dist/pi/engineWakeLimits.d.ts +39 -0
- package/dist/pi/engineWakeLimits.d.ts.map +1 -0
- package/dist/pi/engineWakeLimits.js +55 -0
- package/dist/pi/grokHeadlessResult.d.ts +36 -0
- package/dist/pi/grokHeadlessResult.d.ts.map +1 -0
- package/dist/pi/grokHeadlessResult.js +118 -0
- package/dist/pi/grokHomeMcpRegistration.d.ts +21 -0
- package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -0
- package/dist/pi/grokHomeMcpRegistration.js +58 -0
- package/dist/pi/grokSandbox.d.ts +11 -0
- package/dist/pi/grokSandbox.d.ts.map +1 -0
- package/dist/pi/grokSandbox.js +216 -0
- package/dist/pi/grokStreamUsage.d.ts +31 -0
- package/dist/pi/grokStreamUsage.d.ts.map +1 -0
- package/dist/pi/grokStreamUsage.js +51 -0
- package/dist/pi/memoryClock.d.ts +25 -0
- package/dist/pi/memoryClock.d.ts.map +1 -0
- package/dist/pi/memoryClock.js +18 -0
- package/dist/pi/piAgentHandle.d.ts +6 -3
- package/dist/pi/piAgentHandle.d.ts.map +1 -1
- package/dist/pi/piAgentHandle.js +42 -12
- package/dist/pi/piAgentWakeSupport.d.ts +35 -0
- package/dist/pi/piAgentWakeSupport.d.ts.map +1 -1
- package/dist/pi/piAgentWakeSupport.js +4 -0
- package/dist/pi/piHarness.d.ts +18 -3
- package/dist/pi/piHarness.d.ts.map +1 -1
- package/dist/pi/piHarness.js +83 -14
- package/dist/pi/prompts.d.ts +1 -0
- package/dist/pi/prompts.d.ts.map +1 -1
- package/dist/pi/prompts.js +24 -0
- package/dist/pi/taskClockProcess.d.ts +6 -0
- package/dist/pi/taskClockProcess.d.ts.map +1 -0
- package/dist/pi/taskClockProcess.js +8 -0
- package/dist/pi/turnCausal.d.ts +4 -2
- package/dist/pi/turnCausal.d.ts.map +1 -1
- package/dist/pi/turnCausal.js +4 -4
- package/dist/pi/turnTrace.d.ts.map +1 -1
- package/dist/pi/turnTrace.js +5 -8
- package/dist/pi/wakeAcceptance.d.ts +1 -1
- package/dist/pi/wakeAcceptance.d.ts.map +1 -1
- package/dist/pi/wakeAcceptance.js +2 -2
- package/dist/pi/worldTrajectory.d.ts +1 -1
- package/dist/pi/worldTrajectory.d.ts.map +1 -1
- package/dist/pi/worldTrajectory.js +3 -3
- package/dist/runtime/agySubscriptionBootstrap.d.ts +16 -0
- package/dist/runtime/agySubscriptionBootstrap.d.ts.map +1 -0
- package/dist/runtime/agySubscriptionBootstrap.js +80 -0
- package/dist/runtime/agySubscriptionRealm.d.ts +38 -0
- package/dist/runtime/agySubscriptionRealm.d.ts.map +1 -0
- package/dist/runtime/agySubscriptionRealm.js +242 -0
- package/dist/runtime/attention.d.ts +26 -0
- package/dist/runtime/attention.d.ts.map +1 -0
- package/dist/runtime/attention.js +49 -0
- package/dist/runtime/attentionDispatcher.d.ts +78 -0
- package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
- package/dist/runtime/attentionDispatcher.js +365 -0
- package/dist/runtime/cli.d.ts +7 -0
- package/dist/runtime/cli.d.ts.map +1 -0
- package/dist/runtime/cli.js +256 -0
- package/dist/runtime/codexSandboxProjection.d.ts +17 -0
- package/dist/runtime/codexSandboxProjection.d.ts.map +1 -0
- package/dist/runtime/codexSandboxProjection.js +40 -0
- package/dist/runtime/contract-manifest.json +1 -0
- package/dist/runtime/contract-manifest.sha256 +1 -0
- package/dist/runtime/contractManifest.d.ts +8 -0
- package/dist/runtime/contractManifest.d.ts.map +1 -0
- package/dist/runtime/contractManifest.js +4 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts +40 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCapabilities.js +69 -0
- package/dist/runtime/engineBrokerControlClient.d.ts +55 -0
- package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
- package/dist/runtime/engineBrokerControlClient.js +228 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts +12 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
- package/dist/runtime/engineBrokerCredentialJournal.js +26 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts +53 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts +171 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpCallLog.js +231 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts +59 -0
- package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
- package/dist/runtime/engineBrokerMcpFacade.js +346 -0
- package/dist/runtime/engineBrokerNativeClient.d.ts +52 -0
- package/dist/runtime/engineBrokerNativeClient.d.ts.map +1 -0
- package/dist/runtime/engineBrokerNativeClient.js +151 -0
- package/dist/runtime/engineBrokerProtocol.d.ts +167 -0
- package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
- package/dist/runtime/engineBrokerProtocol.js +357 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
- package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
- package/dist/runtime/engineBrokerSealLedger.js +132 -0
- package/dist/runtime/engineBrokerService.d.ts +43 -0
- package/dist/runtime/engineBrokerService.d.ts.map +1 -0
- package/dist/runtime/engineBrokerService.js +196 -0
- package/dist/runtime/engineBrokerServiceCli.d.ts +5 -0
- package/dist/runtime/engineBrokerServiceCli.d.ts.map +1 -0
- package/dist/runtime/engineBrokerServiceCli.js +32 -0
- package/dist/runtime/engineBrokerServiceConfig.d.ts +55 -0
- package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
- package/dist/runtime/engineBrokerServiceConfig.js +130 -0
- package/dist/runtime/engineBrokerSingleflight.d.ts +13 -0
- package/dist/runtime/engineBrokerSingleflight.d.ts.map +1 -0
- package/dist/runtime/engineBrokerSingleflight.js +24 -0
- package/dist/runtime/engineBrokerTurnAccounting.d.ts +76 -0
- package/dist/runtime/engineBrokerTurnAccounting.d.ts.map +1 -0
- package/dist/runtime/engineBrokerTurnAccounting.js +108 -0
- package/dist/runtime/engineBrokerTurnRegistry.d.ts +57 -0
- package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -0
- package/dist/runtime/engineBrokerTurnRegistry.js +159 -0
- package/dist/runtime/engineDispatcher.d.ts +38 -0
- package/dist/runtime/engineDispatcher.d.ts.map +1 -0
- package/dist/runtime/engineDispatcher.js +228 -0
- package/dist/runtime/engineReadiness.d.ts +23 -0
- package/dist/runtime/engineReadiness.d.ts.map +1 -0
- package/dist/runtime/engineReadiness.js +222 -0
- package/dist/runtime/grokAuthenticationError.d.ts +8 -0
- package/dist/runtime/grokAuthenticationError.d.ts.map +1 -0
- package/dist/runtime/grokAuthenticationError.js +20 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts +23 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialAuthority.js +150 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts +6 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
- package/dist/runtime/grokBrokerCredentialReader.js +38 -0
- package/dist/runtime/grokBrokerModelPolicy.d.ts +23 -0
- package/dist/runtime/grokBrokerModelPolicy.d.ts.map +1 -0
- package/dist/runtime/grokBrokerModelPolicy.js +28 -0
- package/dist/runtime/grokBrokerProjection.d.ts +114 -0
- package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProjection.js +101 -0
- package/dist/runtime/grokBrokerProviderClock.d.ts +26 -0
- package/dist/runtime/grokBrokerProviderClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProviderClock.js +133 -0
- package/dist/runtime/grokBrokerProxy.d.ts +69 -0
- package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxy.js +326 -0
- package/dist/runtime/grokBrokerProxyJson.d.ts +10 -0
- package/dist/runtime/grokBrokerProxyJson.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyJson.js +31 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyRequest.js +85 -0
- package/dist/runtime/grokBrokerRealmLease.d.ts +4 -0
- package/dist/runtime/grokBrokerRealmLease.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRealmLease.js +33 -0
- package/dist/runtime/grokBrokerRefresh.d.ts +2 -0
- package/dist/runtime/grokBrokerRefresh.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRefresh.js +15 -0
- package/dist/runtime/grokBrokerRunBudget.d.ts +20 -0
- package/dist/runtime/grokBrokerRunBudget.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRunBudget.js +85 -0
- package/dist/runtime/grokBrokerSlot.d.ts +6 -0
- package/dist/runtime/grokBrokerSlot.d.ts.map +1 -0
- package/dist/runtime/grokBrokerSlot.js +21 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts +32 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTaskClock.js +120 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts +180 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTurnMeter.js +337 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts +89 -0
- package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
- package/dist/runtime/grokBrokerWorkerConfig.js +154 -0
- package/dist/runtime/grokEngineBroker.d.ts +88 -0
- package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
- package/dist/runtime/grokEngineBroker.js +202 -0
- package/dist/runtime/grokEngineBrokerLedger.d.ts +52 -0
- package/dist/runtime/grokEngineBrokerLedger.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerLedger.js +114 -0
- package/dist/runtime/grokEngineBrokerMetering.d.ts +51 -0
- package/dist/runtime/grokEngineBrokerMetering.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerMetering.js +34 -0
- package/dist/runtime/grokEngineBrokerTurn.d.ts +82 -0
- package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurn.js +348 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts +88 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.js +148 -0
- package/dist/runtime/grokInferenceClientConfig.d.ts +41 -0
- package/dist/runtime/grokInferenceClientConfig.d.ts.map +1 -0
- package/dist/runtime/grokInferenceClientConfig.js +62 -0
- package/dist/runtime/grokInferenceGrants.d.ts +77 -0
- package/dist/runtime/grokInferenceGrants.d.ts.map +1 -0
- package/dist/runtime/grokInferenceGrants.js +116 -0
- package/dist/runtime/grokInferenceProxy.d.ts +29 -0
- package/dist/runtime/grokInferenceProxy.d.ts.map +1 -0
- package/dist/runtime/grokInferenceProxy.js +85 -0
- package/dist/runtime/grokInferenceProxyRequest.d.ts +23 -0
- package/dist/runtime/grokInferenceProxyRequest.d.ts.map +1 -0
- package/dist/runtime/grokInferenceProxyRequest.js +63 -0
- package/dist/runtime/grokSlotPreflightReceipt.d.ts +70 -0
- package/dist/runtime/grokSlotPreflightReceipt.d.ts.map +1 -0
- package/dist/runtime/grokSlotPreflightReceipt.js +101 -0
- package/dist/runtime/grokSubscriptionRealm.d.ts +4 -0
- package/dist/runtime/grokSubscriptionRealm.d.ts.map +1 -0
- package/dist/runtime/grokSubscriptionRealm.js +435 -0
- package/dist/runtime/grokSubscriptionRealmTypes.d.ts +26 -0
- package/dist/runtime/grokSubscriptionRealmTypes.d.ts.map +1 -0
- package/dist/runtime/grokSubscriptionRealmTypes.js +1 -0
- package/dist/runtime/grokWorkerAttestation.d.ts +175 -0
- package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerAttestation.js +266 -0
- package/dist/runtime/grokWorkerDenyPlacement.d.ts +80 -0
- package/dist/runtime/grokWorkerDenyPlacement.d.ts.map +1 -0
- package/dist/runtime/grokWorkerDenyPlacement.js +128 -0
- package/dist/runtime/grokWorkerHomeAttestation.d.ts +32 -0
- package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerHomeAttestation.js +75 -0
- package/dist/runtime/grokWorkerSandboxProfile.d.ts +27 -0
- package/dist/runtime/grokWorkerSandboxProfile.d.ts.map +1 -0
- package/dist/runtime/grokWorkerSandboxProfile.js +44 -0
- package/dist/runtime/grokWorkerTmpAttestation.d.ts +55 -0
- package/dist/runtime/grokWorkerTmpAttestation.d.ts.map +1 -0
- package/dist/runtime/grokWorkerTmpAttestation.js +63 -0
- package/dist/runtime/index.d.ts +31 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/inferenceUsageLedger.d.ts +38 -0
- package/dist/runtime/inferenceUsageLedger.d.ts.map +1 -0
- package/dist/runtime/inferenceUsageLedger.js +53 -0
- package/dist/runtime/mcpToolResult.d.ts +127 -0
- package/dist/runtime/mcpToolResult.d.ts.map +1 -0
- package/dist/runtime/mcpToolResult.js +214 -0
- package/dist/runtime/moltnetMachineRead.d.ts +97 -0
- package/dist/runtime/moltnetMachineRead.d.ts.map +1 -0
- package/dist/runtime/moltnetMachineRead.js +183 -0
- package/dist/runtime/native/daimon-engine-broker +0 -0
- package/dist/runtime/organizationRuntime.d.ts +168 -0
- package/dist/runtime/organizationRuntime.d.ts.map +1 -0
- package/dist/runtime/organizationRuntime.js +3 -0
- package/dist/runtime/organizationRuntimeAdmission.d.ts +6 -0
- package/dist/runtime/organizationRuntimeAdmission.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeAdmission.js +22 -0
- package/dist/runtime/organizationRuntimeControl.d.ts +51 -0
- package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeControl.js +283 -0
- package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
- package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeHost.js +368 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
- package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeParsing.js +373 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
- package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeReadiness.js +67 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts +7 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeRecording.js +58 -0
- package/dist/runtime/physicalReadiness.d.ts +59 -0
- package/dist/runtime/physicalReadiness.d.ts.map +1 -0
- package/dist/runtime/physicalReadiness.js +176 -0
- package/dist/runtime/portableCredentialAuth.d.ts +6 -0
- package/dist/runtime/portableCredentialAuth.d.ts.map +1 -0
- package/dist/runtime/portableCredentialAuth.js +70 -0
- package/dist/runtime/portableCredentialMaterial.d.ts +8 -0
- package/dist/runtime/portableCredentialMaterial.d.ts.map +1 -0
- package/dist/runtime/portableCredentialMaterial.js +169 -0
- package/dist/runtime/productionAgentTools.d.ts +5 -0
- package/dist/runtime/productionAgentTools.d.ts.map +1 -0
- package/dist/runtime/productionAgentTools.js +336 -0
- package/dist/runtime/relocateRuntimeConfig.d.ts +14 -0
- package/dist/runtime/relocateRuntimeConfig.d.ts.map +1 -0
- package/dist/runtime/relocateRuntimeConfig.js +38 -0
- package/dist/runtime/runtimeHomeLayout.d.ts +48 -0
- package/dist/runtime/runtimeHomeLayout.d.ts.map +1 -0
- package/dist/runtime/runtimeHomeLayout.js +84 -0
- package/dist/runtime/schedule.d.ts +40 -0
- package/dist/runtime/schedule.d.ts.map +1 -0
- package/dist/runtime/schedule.js +376 -0
- package/dist/runtime/storeCoordination.d.ts +33 -0
- package/dist/runtime/storeCoordination.d.ts.map +1 -0
- package/dist/runtime/storeCoordination.js +117 -0
- package/dist/runtime/taskClock.d.ts +42 -0
- package/dist/runtime/taskClock.d.ts.map +1 -0
- package/dist/runtime/taskClock.js +102 -0
- package/dist/runtime/taskClockProcess.d.ts +17 -0
- package/dist/runtime/taskClockProcess.d.ts.map +1 -0
- package/dist/runtime/taskClockProcess.js +58 -0
- package/dist/runtime/toolResultSpill.d.ts +152 -0
- package/dist/runtime/toolResultSpill.d.ts.map +1 -0
- package/dist/runtime/toolResultSpill.js +351 -0
- package/dist/runtime/turnRequestLedger.d.ts +155 -0
- package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
- package/dist/runtime/turnRequestLedger.js +251 -0
- package/dist/runtime/turnUsageLedger.d.ts +143 -0
- package/dist/runtime/turnUsageLedger.d.ts.map +1 -0
- package/dist/runtime/turnUsageLedger.js +203 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts +34 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.js +79 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts +55 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceIndex.js +158 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +25 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.js +54 -0
- package/dist/runtime/wakeAcceptanceReconciliation.d.ts +211 -0
- package/dist/runtime/wakeAcceptanceReconciliation.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceReconciliation.js +289 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts +25 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRecord.js +58 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts +36 -0
- package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceRetention.js +38 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
- package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceStore.js +561 -0
- package/dist/runtime/wakeAcceptanceTypes.d.ts +179 -0
- package/dist/runtime/wakeAcceptanceTypes.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceTypes.js +95 -0
- package/dist/runtime/wakeFuse.d.ts +124 -0
- package/dist/runtime/wakeFuse.d.ts.map +1 -0
- package/dist/runtime/wakeFuse.js +466 -0
- package/dist/runtime/wakeMomentFs.d.ts +27 -0
- package/dist/runtime/wakeMomentFs.d.ts.map +1 -0
- package/dist/runtime/wakeMomentFs.js +223 -0
- package/dist/runtime/wakeMomentHistory.d.ts +26 -0
- package/dist/runtime/wakeMomentHistory.d.ts.map +1 -0
- package/dist/runtime/wakeMomentHistory.js +109 -0
- package/dist/runtime/wakeMomentIo.d.ts +22 -0
- package/dist/runtime/wakeMomentIo.d.ts.map +1 -0
- package/dist/runtime/wakeMomentIo.js +114 -0
- package/dist/runtime/wakeMomentRecorder.d.ts +33 -0
- package/dist/runtime/wakeMomentRecorder.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRecorder.js +81 -0
- package/dist/runtime/wakeMomentRetention.d.ts +7 -0
- package/dist/runtime/wakeMomentRetention.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRetention.js +143 -0
- package/dist/runtime/wakeMomentRows.d.ts +8 -0
- package/dist/runtime/wakeMomentRows.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRows.js +66 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts +56 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts.map +1 -0
- package/dist/runtime/wakeMomentSnapshot.js +248 -0
- package/package.json +22 -11
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { access, lstat, open, realpath } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { GROK_ENGINE_BROKER } from "../contracts/runtimeContractManifest.js";
|
|
5
|
+
import { pathsOverlap } from "./organizationRuntimeRecording.js";
|
|
6
|
+
/** Only a brokered Grok agent's home is worker-traversable; every other engine keeps 0700. */
|
|
7
|
+
function runtimeHomeShape(agent) {
|
|
8
|
+
return agent.engine.kind === "grok" ? "worker-traversable" : "private";
|
|
9
|
+
}
|
|
10
|
+
export async function prepareOrganizationRuntimePaths(agents) {
|
|
11
|
+
const workspaces = new Map();
|
|
12
|
+
const homes = new Map();
|
|
13
|
+
const recordings = new Map();
|
|
14
|
+
try {
|
|
15
|
+
for (const agent of agents) {
|
|
16
|
+
workspaces.set(agent.id, await verifyDirectory(agent.workspacePath, "workspacePath", "safe"));
|
|
17
|
+
homes.set(agent.id, await verifyDirectory(agent.runtimeHomePath, "runtimeHomePath", runtimeHomeShape(agent)));
|
|
18
|
+
if (agent.recording)
|
|
19
|
+
recordings.set(agent.id, await verifyDirectory(agent.recording.directory, "recording.directory", "private"));
|
|
20
|
+
}
|
|
21
|
+
const roots = [...workspaces.values(), ...homes.values(), ...recordings.values()];
|
|
22
|
+
for (let left = 0; left < roots.length; left += 1)
|
|
23
|
+
for (let right = left + 1; right < roots.length; right += 1) {
|
|
24
|
+
const first = roots[left];
|
|
25
|
+
const second = roots[right];
|
|
26
|
+
if (sameIdentity(first.identity, second.identity) || overlaps(first.real, second.real)) {
|
|
27
|
+
throw new Error(`physical runtime paths overlap: ${first.configured} and ${second.configured}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
for (const agent of agents)
|
|
31
|
+
for (const source of agent.recording?.snapshots ?? []) {
|
|
32
|
+
const real = await readableSnapshotDirectory(source.path);
|
|
33
|
+
if (real !== undefined && [...recordings.values()].some((store) => pathsOverlap(store.real, real)))
|
|
34
|
+
throw new Error("physical recording and snapshot paths overlap");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const closeError = await closeAll([...workspaces.values(), ...homes.values(), ...recordings.values()]);
|
|
39
|
+
if (closeError !== undefined)
|
|
40
|
+
throw new AggregateError([error, closeError], "runtime path validation cleanup failed");
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
let closed = false;
|
|
44
|
+
const verify = async (agent) => {
|
|
45
|
+
if (closed)
|
|
46
|
+
throw new Error("runtime path authority is closed");
|
|
47
|
+
const workspace = workspaces.get(agent.id);
|
|
48
|
+
const home = homes.get(agent.id);
|
|
49
|
+
if (workspace === undefined || home === undefined)
|
|
50
|
+
throw new Error(`no runtime path authority for ${agent.id}`);
|
|
51
|
+
await Promise.all([
|
|
52
|
+
verifyIdentity(workspace, "workspacePath", "safe"),
|
|
53
|
+
verifyIdentity(home, "runtimeHomePath", runtimeHomeShape(agent))
|
|
54
|
+
]);
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
forAgent(agent) {
|
|
58
|
+
const workspace = workspaces.get(agent.id);
|
|
59
|
+
const home = homes.get(agent.id);
|
|
60
|
+
if (workspace === undefined || home === undefined)
|
|
61
|
+
throw new Error(`no runtime path authority for ${agent.id}`);
|
|
62
|
+
return { workspacePath: workspace.real, runtimeHomePath: home.real, verify: () => verify(agent),
|
|
63
|
+
verifyRecording: async () => {
|
|
64
|
+
if (closed)
|
|
65
|
+
throw new Error("runtime path authority is closed");
|
|
66
|
+
const recording = recordings.get(agent.id);
|
|
67
|
+
if (recording)
|
|
68
|
+
await verifyIdentity(recording, "recording.directory", "private");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
async close() {
|
|
73
|
+
if (closed)
|
|
74
|
+
return;
|
|
75
|
+
const failure = await closeAll([...workspaces.values(), ...homes.values(), ...recordings.values()]);
|
|
76
|
+
if (failure !== undefined)
|
|
77
|
+
throw failure;
|
|
78
|
+
closed = true;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async function verifyDirectory(configured, label, shape) {
|
|
83
|
+
await assertNoSymlinkComponents(configured);
|
|
84
|
+
const before = await lstat(configured);
|
|
85
|
+
assertDirectory(before, label, shape);
|
|
86
|
+
const fd = await open(configured, constants.O_RDONLY | directoryFlag() | noFollow());
|
|
87
|
+
try {
|
|
88
|
+
const opened = await fd.stat();
|
|
89
|
+
const real = await realpath(configured);
|
|
90
|
+
const after = await lstat(configured);
|
|
91
|
+
if (!sameIdentity(identity(before), identity(opened)) || !sameIdentity(identity(before), identity(after))) {
|
|
92
|
+
throw new Error(`${label} changed during validation`);
|
|
93
|
+
}
|
|
94
|
+
return { configured, real, fd, identity: identity(before), closed: false };
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
await fd.close().catch(() => undefined);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function verifyIdentity(directory, label, shape) {
|
|
102
|
+
if (directory.closed)
|
|
103
|
+
throw new Error(`${label} authority is closed`);
|
|
104
|
+
await assertNoSymlinkComponents(directory.configured);
|
|
105
|
+
const entry = await lstat(directory.configured);
|
|
106
|
+
const opened = await directory.fd.stat();
|
|
107
|
+
if (!sameIdentity(identity(entry), directory.identity) || !sameIdentity(identity(opened), directory.identity)) {
|
|
108
|
+
throw new Error(`${label} changed after readiness validation`);
|
|
109
|
+
}
|
|
110
|
+
assertDirectory(entry, label, shape);
|
|
111
|
+
if (await realpath(directory.configured) !== directory.real)
|
|
112
|
+
throw new Error(`${label} changed after readiness validation`);
|
|
113
|
+
}
|
|
114
|
+
export async function assertNoSymlinkComponents(target, stat = lstat) {
|
|
115
|
+
const parsed = path.parse(target);
|
|
116
|
+
let current = parsed.root;
|
|
117
|
+
for (const part of path.relative(parsed.root, target).split(path.sep).filter(Boolean)) {
|
|
118
|
+
current = path.join(current, part);
|
|
119
|
+
// macOS exposes /var as a system compatibility symlink to /private/var.
|
|
120
|
+
// It is an OS-root alias, not a caller-controlled component.
|
|
121
|
+
if ((await stat(current)).isSymbolicLink() && current !== "/var")
|
|
122
|
+
throw new Error(`path contains symlink: ${current}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Shared sources have no owner/privacy requirement. Missing sources are empty captures. */
|
|
126
|
+
async function readableSnapshotDirectory(target) {
|
|
127
|
+
try {
|
|
128
|
+
await assertNoSymlinkComponents(target);
|
|
129
|
+
const entry = await lstat(target);
|
|
130
|
+
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
131
|
+
throw new Error("recording snapshot must be a readable real directory");
|
|
132
|
+
await access(target, constants.R_OK | constants.X_OK);
|
|
133
|
+
return await realpath(target);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error.code === "ENOENT")
|
|
137
|
+
return undefined;
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Pure shape check for a caller-prepared runtime root. */
|
|
142
|
+
export function assertRuntimeDirectory(entry, label, shape, runtime) {
|
|
143
|
+
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
144
|
+
throw new Error(`${label} must be an existing real directory`);
|
|
145
|
+
if (entry.uid !== runtime.uid)
|
|
146
|
+
throw new Error(`${label} must be owned by the runtime user`);
|
|
147
|
+
const permissions = Number(entry.mode) & 0o7777;
|
|
148
|
+
if (shape === "private" && permissions !== 0o700)
|
|
149
|
+
throw new Error(`${label} must have mode 0700`);
|
|
150
|
+
if (shape === "worker-traversable") {
|
|
151
|
+
const home = GROK_ENGINE_BROKER.worker.home.organizationRuntimeHome;
|
|
152
|
+
if (permissions !== home.mode)
|
|
153
|
+
throw new Error(`${label} must have mode 0710 for a brokered Grok agent`);
|
|
154
|
+
if (entry.gid < (runtime.firstWorkerUid ?? GROK_ENGINE_BROKER.identities.firstWorkerUid) || entry.gid === runtime.gid) {
|
|
155
|
+
throw new Error(`${label} must be group-owned by the agent's Grok worker group`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (shape === "safe" && (permissions & 0o022) !== 0)
|
|
159
|
+
throw new Error(`${label} must not grant group or other write access`);
|
|
160
|
+
}
|
|
161
|
+
function assertDirectory(entry, label, shape) {
|
|
162
|
+
assertRuntimeDirectory(entry, label, shape, { uid: process.getuid?.() ?? -1, gid: process.getgid?.() ?? -1 });
|
|
163
|
+
}
|
|
164
|
+
export function identity(entry) { return { dev: entry.dev, ino: entry.ino, uid: entry.uid, mode: entry.mode & 0o7777 }; }
|
|
165
|
+
export function sameIdentity(left, right) { return left.dev === right.dev && left.ino === right.ino && left.uid === right.uid && left.mode === right.mode; }
|
|
166
|
+
function overlaps(left, right) { return left === right || left.startsWith(`${right}${path.sep}`) || right.startsWith(`${left}${path.sep}`); }
|
|
167
|
+
function noFollow() { return constants.O_NOFOLLOW ?? 0; }
|
|
168
|
+
function directoryFlag() { return constants.O_DIRECTORY ?? 0; }
|
|
169
|
+
async function closeAll(directories) {
|
|
170
|
+
const results = await Promise.allSettled(directories.filter((directory) => !directory.closed).map(async (directory) => {
|
|
171
|
+
await directory.fd.close();
|
|
172
|
+
directory.closed = true;
|
|
173
|
+
}));
|
|
174
|
+
const failures = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
175
|
+
return failures.length === 0 ? undefined : new AggregateError(failures, "runtime path authority cleanup failed");
|
|
176
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type PortableCredentialKind = "codex" | "grok";
|
|
2
|
+
/** Validates only the bounded provider-native shape needed for refresh. */
|
|
3
|
+
export declare function hasRefreshablePortableCredential(engine: PortableCredentialKind, bytes: Uint8Array): boolean;
|
|
4
|
+
/** Returns only the provider-native bearer values for exact in-process redaction. */
|
|
5
|
+
export declare function portableCredentialSecretValues(engine: PortableCredentialKind, bytes: Uint8Array): readonly string[];
|
|
6
|
+
//# sourceMappingURL=portableCredentialAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portableCredentialAuth.d.ts","sourceRoot":"","sources":["../../src/runtime/portableCredentialAuth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtD,2EAA2E;AAC3E,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,UAAU,GAChB,OAAO,CAYT;AAED,qFAAqF;AACrF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,UAAU,GAChB,SAAS,MAAM,EAAE,CASnB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Validates only the bounded provider-native shape needed for refresh. */
|
|
2
|
+
export function hasRefreshablePortableCredential(engine, bytes) {
|
|
3
|
+
let value;
|
|
4
|
+
try {
|
|
5
|
+
value = JSON.parse(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("utf8"));
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const pair = engine === "grok" ? grokTokenPair(value) : tokenPair(value);
|
|
11
|
+
if (pair.access === undefined || pair.refresh === undefined)
|
|
12
|
+
return false;
|
|
13
|
+
if (engine !== "grok")
|
|
14
|
+
return true;
|
|
15
|
+
const candidate = firstString(grokTokenEntry(value), ["expires_at"]);
|
|
16
|
+
return candidate !== undefined && Number.isFinite(Date.parse(candidate));
|
|
17
|
+
}
|
|
18
|
+
/** Returns only the provider-native bearer values for exact in-process redaction. */
|
|
19
|
+
export function portableCredentialSecretValues(engine, bytes) {
|
|
20
|
+
let value;
|
|
21
|
+
try {
|
|
22
|
+
value = JSON.parse(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("utf8"));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const pair = engine === "grok" ? grokTokenPair(value) : tokenPair(value);
|
|
28
|
+
return [...new Set([pair.access, pair.refresh].filter((entry) => entry !== undefined))];
|
|
29
|
+
}
|
|
30
|
+
function tokenPair(value) {
|
|
31
|
+
const source = object(value);
|
|
32
|
+
const nested = object(source?.tokens) ?? source;
|
|
33
|
+
return {
|
|
34
|
+
access: firstNonBlankString(nested, ["access_token", "accessToken", "token"]),
|
|
35
|
+
refresh: firstNonBlankString(nested, ["refresh_token", "refreshToken"])
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function grokTokenEntry(value) {
|
|
39
|
+
const source = object(value);
|
|
40
|
+
if (source === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
for (const [key, entry] of Object.entries(source)) {
|
|
43
|
+
if (/^https:\/\/auth\.x\.ai::/u.test(key))
|
|
44
|
+
return object(entry);
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
function grokTokenPair(value) {
|
|
49
|
+
const entry = grokTokenEntry(value);
|
|
50
|
+
return {
|
|
51
|
+
access: firstNonBlankString(entry, ["key"]),
|
|
52
|
+
refresh: firstNonBlankString(entry, ["refresh_token"])
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function object(value) {
|
|
56
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
57
|
+
? value
|
|
58
|
+
: undefined;
|
|
59
|
+
}
|
|
60
|
+
function firstString(value, names) {
|
|
61
|
+
for (const name of names) {
|
|
62
|
+
if (typeof value?.[name] === "string" && value[name].length > 0)
|
|
63
|
+
return value[name];
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
function firstNonBlankString(value, names) {
|
|
68
|
+
const candidate = firstString(value, names);
|
|
69
|
+
return candidate !== undefined && candidate.trim().length > 0 ? candidate : undefined;
|
|
70
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OrganizationRuntimeAgentConfig } from "./organizationRuntime.js";
|
|
2
|
+
/**
|
|
3
|
+
* Seeds a runtime-writable CLI credential from Daimon's read-only ingress.
|
|
4
|
+
* A newer runtime copy wins so a CLI refresh survives process/container
|
|
5
|
+
* restarts; a later operator refresh of the ingress is imported on restart.
|
|
6
|
+
*/
|
|
7
|
+
export declare function materializePortableCredential(configuredAgent: OrganizationRuntimeAgentConfig, runtimeHomePath: string): Promise<"created" | "preserved" | "refreshed">;
|
|
8
|
+
//# sourceMappingURL=portableCredentialMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portableCredentialMaterial.d.ts","sourceRoot":"","sources":["../../src/runtime/portableCredentialMaterial.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAc/E;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,eAAe,EAAE,8BAA8B,EAC/C,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,CAsChD"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { chmod, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { ENGINE_CREDENTIAL_MATERIAL } from "./contractManifest.js";
|
|
6
|
+
const MAX_CREDENTIAL_BYTES = 64 * 1024;
|
|
7
|
+
/**
|
|
8
|
+
* Seeds a runtime-writable CLI credential from Daimon's read-only ingress.
|
|
9
|
+
* A newer runtime copy wins so a CLI refresh survives process/container
|
|
10
|
+
* restarts; a later operator refresh of the ingress is imported on restart.
|
|
11
|
+
*/
|
|
12
|
+
export async function materializePortableCredential(configuredAgent, runtimeHomePath) {
|
|
13
|
+
if (configuredAgent.engine.kind !== "codex") {
|
|
14
|
+
throw new Error(`agent ${configuredAgent.id} ${configuredAgent.engine.kind} has no portable credential material`);
|
|
15
|
+
}
|
|
16
|
+
const agent = configuredAgent;
|
|
17
|
+
const rule = ENGINE_CREDENTIAL_MATERIAL[agent.engine.kind];
|
|
18
|
+
const sourcePath = contained(runtimeHomePath, rule.sourceRelativePath);
|
|
19
|
+
const destinationPath = contained(runtimeHomePath, rule.destinationRelativePath);
|
|
20
|
+
const destinationDirectory = path.dirname(destinationPath);
|
|
21
|
+
await assertPrivateDirectory(path.dirname(sourcePath), rule.directoryMode, agent, false);
|
|
22
|
+
const source = await readCredential(sourcePath, rule.fileMode, agent);
|
|
23
|
+
await prepareDestinationDirectory(destinationDirectory, rule.directoryMode, agent);
|
|
24
|
+
const existing = await existingCredential(destinationPath, rule.fileMode, agent);
|
|
25
|
+
if (existing !== undefined && existing.mtimeMs >= source.identity.mtimeMs)
|
|
26
|
+
return "preserved";
|
|
27
|
+
const temporaryPath = path.join(destinationDirectory, `.${path.basename(destinationPath)}.${randomUUID()}.tmp`);
|
|
28
|
+
let temporary;
|
|
29
|
+
try {
|
|
30
|
+
temporary = await open(temporaryPath, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | noFollow(), rule.fileMode);
|
|
31
|
+
await temporary.writeFile(source.bytes);
|
|
32
|
+
await temporary.chmod(rule.fileMode);
|
|
33
|
+
await temporary.sync();
|
|
34
|
+
await temporary.close();
|
|
35
|
+
temporary = undefined;
|
|
36
|
+
await rename(temporaryPath, destinationPath);
|
|
37
|
+
await assertCredential(destinationPath, rule.fileMode, agent);
|
|
38
|
+
return existing === undefined ? "created" : "refreshed";
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw unavailable(agent, error);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await temporary?.close().catch(() => undefined);
|
|
45
|
+
await unlink(temporaryPath).catch(() => undefined);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function readCredential(filePath, mode, agent) {
|
|
49
|
+
let handle;
|
|
50
|
+
try {
|
|
51
|
+
// Opening a read-only bind can refresh its metadata. Validate the actual
|
|
52
|
+
// descriptor before consulting the refreshed path or reading any bytes.
|
|
53
|
+
// Nonblocking open lets us reject a FIFO by type instead of hanging here.
|
|
54
|
+
handle = await open(filePath, constants.O_RDONLY | noFollow() | constants.O_NONBLOCK);
|
|
55
|
+
const before = assertCredentialEntry(await handle.stat(), mode, agent);
|
|
56
|
+
if (!sameIdentity(before, await assertCredential(filePath, mode, agent)))
|
|
57
|
+
throw new Error("credential changed during import");
|
|
58
|
+
// One extra byte detects growth without allowing a changing file to drive
|
|
59
|
+
// an unbounded read/allocation. Partial reads advance within this buffer.
|
|
60
|
+
const buffer = Buffer.alloc(before.size + 1);
|
|
61
|
+
let length = 0;
|
|
62
|
+
while (length < buffer.length) {
|
|
63
|
+
const result = await handle.read(buffer, length, buffer.length - length, length);
|
|
64
|
+
if (result.bytesRead === 0)
|
|
65
|
+
break;
|
|
66
|
+
length += result.bytesRead;
|
|
67
|
+
}
|
|
68
|
+
const bytes = buffer.subarray(0, length);
|
|
69
|
+
const after = assertCredentialEntry(await handle.stat(), mode, agent);
|
|
70
|
+
const afterPath = await assertCredential(filePath, mode, agent);
|
|
71
|
+
if (!sameIdentity(before, after) || !sameIdentity(before, afterPath) || bytes.length !== before.size) {
|
|
72
|
+
throw new Error("credential changed during import");
|
|
73
|
+
}
|
|
74
|
+
return { bytes, identity: before };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw unavailable(agent, error);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await handle?.close().catch(() => undefined);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function prepareDestinationDirectory(directoryPath, mode, agent) {
|
|
84
|
+
try {
|
|
85
|
+
await mkdir(directoryPath, { mode });
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error.code !== "EEXIST")
|
|
89
|
+
throw unavailable(agent, error);
|
|
90
|
+
}
|
|
91
|
+
await assertPrivateDirectory(directoryPath, mode, agent, true);
|
|
92
|
+
}
|
|
93
|
+
async function assertPrivateDirectory(directoryPath, mode, agent, repairMode) {
|
|
94
|
+
try {
|
|
95
|
+
const entry = await lstat(directoryPath);
|
|
96
|
+
if (!entry.isDirectory() || entry.isSymbolicLink() || entry.uid !== process.getuid?.()) {
|
|
97
|
+
throw new Error("unsafe credential directory");
|
|
98
|
+
}
|
|
99
|
+
if (repairMode && (entry.mode & 0o777) !== mode)
|
|
100
|
+
await chmod(directoryPath, mode);
|
|
101
|
+
const secured = await lstat(directoryPath);
|
|
102
|
+
if (!secured.isDirectory() || secured.isSymbolicLink() || secured.uid !== process.getuid?.()
|
|
103
|
+
|| (secured.mode & 0o777) !== mode)
|
|
104
|
+
throw new Error("unsafe credential directory");
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw unavailable(agent, error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function existingCredential(filePath, mode, agent) {
|
|
111
|
+
try {
|
|
112
|
+
return await assertCredential(filePath, mode, agent);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error.code === "ENOENT")
|
|
116
|
+
return undefined;
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function assertCredential(filePath, mode, agent) {
|
|
121
|
+
let entry;
|
|
122
|
+
try {
|
|
123
|
+
entry = await lstat(filePath);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error.code === "ENOENT")
|
|
127
|
+
throw error;
|
|
128
|
+
throw unavailable(agent, error);
|
|
129
|
+
}
|
|
130
|
+
return assertCredentialEntry(entry, mode, agent);
|
|
131
|
+
}
|
|
132
|
+
function assertCredentialEntry(entry, mode, agent) {
|
|
133
|
+
if (!entry.isFile() || entry.isSymbolicLink() || entry.uid !== process.getuid?.()
|
|
134
|
+
|| entry.nlink !== 1 || (entry.mode & 0o777) !== mode
|
|
135
|
+
|| entry.size === 0 || entry.size > MAX_CREDENTIAL_BYTES) {
|
|
136
|
+
throw unavailable(agent, new Error("unsafe credential artifact"));
|
|
137
|
+
}
|
|
138
|
+
return identity(entry);
|
|
139
|
+
}
|
|
140
|
+
function contained(root, relative) {
|
|
141
|
+
const candidate = path.resolve(root, relative);
|
|
142
|
+
const relation = path.relative(path.resolve(root), candidate);
|
|
143
|
+
if (!relation || relation === ".." || relation.startsWith(`..${path.sep}`) || path.isAbsolute(relation)) {
|
|
144
|
+
throw new Error("Daimon credential contract escapes the runtime home");
|
|
145
|
+
}
|
|
146
|
+
return candidate;
|
|
147
|
+
}
|
|
148
|
+
function identity(value) {
|
|
149
|
+
const numeric = value;
|
|
150
|
+
return {
|
|
151
|
+
dev: numeric.dev,
|
|
152
|
+
ino: numeric.ino,
|
|
153
|
+
mode: numeric.mode & 0o7777,
|
|
154
|
+
mtimeMs: numeric.mtimeMs,
|
|
155
|
+
size: numeric.size,
|
|
156
|
+
uid: numeric.uid,
|
|
157
|
+
nlink: numeric.nlink
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function sameIdentity(left, right) {
|
|
161
|
+
return left.dev === right.dev && left.ino === right.ino && left.mode === right.mode
|
|
162
|
+
&& left.mtimeMs === right.mtimeMs && left.size === right.size && left.uid === right.uid && left.nlink === right.nlink;
|
|
163
|
+
}
|
|
164
|
+
function noFollow() {
|
|
165
|
+
return constants.O_NOFOLLOW ?? 0;
|
|
166
|
+
}
|
|
167
|
+
function unavailable(agent, _cause) {
|
|
168
|
+
return new Error(`agent ${agent.id} ${agent.engine.kind} credential materialization failed`);
|
|
169
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { OrganizationRuntimeAgentConfig } from "./organizationRuntime.js";
|
|
3
|
+
import type { PiWakeEnvironmentContextRef } from "../pi/piAgentWakeSupport.js";
|
|
4
|
+
export declare function createProductionAgentTools(agent: OrganizationRuntimeAgentConfig, wakeContext?: PiWakeEnvironmentContextRef): Promise<ToolDefinition[]>;
|
|
5
|
+
//# sourceMappingURL=productionAgentTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productionAgentTools.d.ts","sourceRoot":"","sources":["../../src/runtime/productionAgentTools.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAMtE,OAAO,KAAK,EAAE,8BAA8B,EAAgC,MAAM,0BAA0B,CAAC;AAO7G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAe/E,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,8BAA8B,EAAE,WAAW,GAAE,2BAAgC,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAahK"}
|