@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,269 @@
|
|
|
1
|
+
import { redactCredentialText } from "../core/credentialRedaction.js";
|
|
2
|
+
import { headUtf8, tailUtf8 } from "../runtime/toolResultSpill.js";
|
|
3
|
+
import { decodeCodexTurnUsage } from "./codexHeadlessResult.js";
|
|
4
|
+
import { terminateChild, trackCliChild } from "./cliProcess.js";
|
|
5
|
+
/** Maximum assistant reply bytes retained from stdout. */
|
|
6
|
+
export const CLI_ENGINE_MAX_OUTPUT_BYTES = 64 * 1024;
|
|
7
|
+
/** Diagnostic bytes retained from stderr for a failed child: its head and its tail together. */
|
|
8
|
+
export const CLI_ENGINE_MAX_DIAGNOSTIC_BYTES = 768;
|
|
9
|
+
const CLI_ENGINE_FAILURE_SCAN_CHARS = 256;
|
|
10
|
+
/**
|
|
11
|
+
* Which bound or condition failed a wake, carried on the error object itself.
|
|
12
|
+
*
|
|
13
|
+
* The caller needs this to label the usage row a failed wake still owes the
|
|
14
|
+
* ledger, and matching on the message text would make that label depend on
|
|
15
|
+
* prose. The tag is a non-enumerable symbol property, so it never widens the
|
|
16
|
+
* error's serialized form and never reaches a diagnostic string.
|
|
17
|
+
*/
|
|
18
|
+
const CLI_CHILD_FAILURE_REASON = Symbol("daimon.cliChildFailureReason");
|
|
19
|
+
export const tagCliChildFailure = (error, reason) => {
|
|
20
|
+
if (!(error instanceof Error))
|
|
21
|
+
return error;
|
|
22
|
+
// Labelling a failure must never become a second failure: a frozen or sealed
|
|
23
|
+
// error simply goes untagged and its row reads `unknown`.
|
|
24
|
+
try {
|
|
25
|
+
Object.defineProperty(error, CLI_CHILD_FAILURE_REASON, { configurable: true, enumerable: false, value: reason, writable: true });
|
|
26
|
+
}
|
|
27
|
+
catch { /* the reason is advisory; the failure it describes is not */ }
|
|
28
|
+
return error;
|
|
29
|
+
};
|
|
30
|
+
export const cliChildFailureReason = (error) => error instanceof Error
|
|
31
|
+
? error[CLI_CHILD_FAILURE_REASON]
|
|
32
|
+
: undefined;
|
|
33
|
+
const redactChildOutput = (value, secretValues) => {
|
|
34
|
+
return redactCredentialText(value, secretValues, CLI_ENGINE_MAX_OUTPUT_BYTES);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* One bounded window over a failed child's own output: its head AND its tail,
|
|
38
|
+
* with an explicit marker naming the bytes elided between them.
|
|
39
|
+
*
|
|
40
|
+
* A pure tail is the wrong end for the process this exists for. A worker that
|
|
41
|
+
* dies early prints its error first and then echoes its own input, so the tail
|
|
42
|
+
* is the echo: one live brokered turn reported 512 bytes of its own prompt
|
|
43
|
+
* read back, with the actual error already off the front and discarded. Both
|
|
44
|
+
* ends cost the same window, and the marker is the one oversized tool results
|
|
45
|
+
* already use (`toolResultSpill.ts`), so a reader meets one shape everywhere.
|
|
46
|
+
*
|
|
47
|
+
* The marker is paid for out of the same budget — it is sized against the
|
|
48
|
+
* largest count it could carry — so the result never exceeds `maxBytes`, and
|
|
49
|
+
* output that fits is returned byte-identical with no marker at all.
|
|
50
|
+
*/
|
|
51
|
+
export const boundedDiagnosticWindow = (value, maxBytes) => {
|
|
52
|
+
const total = Buffer.byteLength(value, "utf8");
|
|
53
|
+
if (total <= maxBytes)
|
|
54
|
+
return value;
|
|
55
|
+
const budget = Math.max(0, maxBytes - Buffer.byteLength(elisionMarker(total), "utf8"));
|
|
56
|
+
const head = headUtf8(value, Math.floor(budget / 2));
|
|
57
|
+
const tail = tailUtf8(value, budget - Buffer.byteLength(head, "utf8"));
|
|
58
|
+
const elided = total - Buffer.byteLength(head, "utf8") - Buffer.byteLength(tail, "utf8");
|
|
59
|
+
return `${head}${elisionMarker(elided)}${tail}`;
|
|
60
|
+
};
|
|
61
|
+
const elisionMarker = (elided) => `[… ${elided} bytes elided …]`;
|
|
62
|
+
const childDiagnostic = (stdout, stderr, secretValues) => {
|
|
63
|
+
const output = stderr.trim().length > 0 ? stderr : stdout;
|
|
64
|
+
const redacted = redactCredentialText(output, secretValues, Number.MAX_SAFE_INTEGER).trim();
|
|
65
|
+
const bounded = boundedDiagnosticWindow(redacted, CLI_ENGINE_MAX_DIAGNOSTIC_BYTES).trim();
|
|
66
|
+
return bounded.length > 0 ? `: ${bounded}` : "";
|
|
67
|
+
};
|
|
68
|
+
export const readChild = (child, timeoutMs, secretValues, options = {}) => new Promise((resolve, reject) => {
|
|
69
|
+
trackCliChild(child);
|
|
70
|
+
const stdout = [];
|
|
71
|
+
let stdoutTail = Buffer.alloc(0);
|
|
72
|
+
let droppingStdoutLine = false;
|
|
73
|
+
// Both ends of stderr, retained as it streams: the head frozen once it is
|
|
74
|
+
// full, the tail sliding. A single sliding tail dropped the head at capture
|
|
75
|
+
// time, which is where the cause of an early death lives — no later window
|
|
76
|
+
// can recover what was never kept.
|
|
77
|
+
let stderrHead = Buffer.alloc(0);
|
|
78
|
+
let stderrTail = Buffer.alloc(0);
|
|
79
|
+
let stderrBytes = 0;
|
|
80
|
+
let stdoutBytes = 0;
|
|
81
|
+
let stdoutRemainder = Buffer.alloc(0);
|
|
82
|
+
let droppingNdjsonLine = false;
|
|
83
|
+
let ndjsonCalls = 0;
|
|
84
|
+
let settled = false;
|
|
85
|
+
let cleanupStarted = false;
|
|
86
|
+
let classifiedFailure;
|
|
87
|
+
let failureScanTail = "";
|
|
88
|
+
/**
|
|
89
|
+
* Each retained end carries its reported share PLUS one whole secret, which
|
|
90
|
+
* is the invariant that keeps exact redaction exact: a secret that reaches
|
|
91
|
+
* the reported window can extend at most its own length past that window's
|
|
92
|
+
* cut, so retaining that much more on each side means the redactor always
|
|
93
|
+
* sees the secret whole. Halving one shared budget instead broke it — a
|
|
94
|
+
* 2000-byte secret was cut in the middle and its tail fragment
|
|
95
|
+
* (`…qqq-secret-end`) reached the diagnostic verbatim.
|
|
96
|
+
*/
|
|
97
|
+
const stderrSecretAllowance = Math.max(0, ...secretValues.map((secret) => Buffer.byteLength(secret, "utf8")));
|
|
98
|
+
const stderrHeadBytes = Math.floor(CLI_ENGINE_MAX_DIAGNOSTIC_BYTES / 2) + stderrSecretAllowance;
|
|
99
|
+
const stderrTailBytes = CLI_ENGINE_MAX_DIAGNOSTIC_BYTES - Math.floor(CLI_ENGINE_MAX_DIAGNOSTIC_BYTES / 2) + stderrSecretAllowance;
|
|
100
|
+
const settle = (action) => {
|
|
101
|
+
if (settled)
|
|
102
|
+
return;
|
|
103
|
+
settled = true;
|
|
104
|
+
if (timer !== undefined)
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
action();
|
|
107
|
+
};
|
|
108
|
+
const abort = (error) => {
|
|
109
|
+
if (cleanupStarted)
|
|
110
|
+
return;
|
|
111
|
+
cleanupStarted = true;
|
|
112
|
+
void terminateChild(child).then(() => settle(() => reject(error)), (cleanupError) => settle(() => reject(cleanupError instanceof Error ? cleanupError : error)));
|
|
113
|
+
};
|
|
114
|
+
const classifyFailure = (chunk) => {
|
|
115
|
+
if (classifiedFailure !== undefined || options.failureClassifier === undefined)
|
|
116
|
+
return;
|
|
117
|
+
const diagnostic = `${failureScanTail}${chunk.toString("utf8")}`;
|
|
118
|
+
classifiedFailure = options.failureClassifier(diagnostic);
|
|
119
|
+
failureScanTail = diagnostic.slice(-CLI_ENGINE_FAILURE_SCAN_CHARS);
|
|
120
|
+
};
|
|
121
|
+
const retainStdout = (chunk) => {
|
|
122
|
+
const value = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
123
|
+
classifyFailure(value);
|
|
124
|
+
if (options.retainNdjson !== undefined) {
|
|
125
|
+
let incoming = value;
|
|
126
|
+
if (droppingNdjsonLine) {
|
|
127
|
+
const newline = incoming.indexOf(0x0a);
|
|
128
|
+
if (newline < 0)
|
|
129
|
+
return;
|
|
130
|
+
droppingNdjsonLine = false;
|
|
131
|
+
incoming = incoming.subarray(newline + 1);
|
|
132
|
+
}
|
|
133
|
+
stdoutRemainder = Buffer.concat([stdoutRemainder, incoming]);
|
|
134
|
+
let newline;
|
|
135
|
+
while ((newline = stdoutRemainder.indexOf(0x0a)) >= 0) {
|
|
136
|
+
const line = stdoutRemainder.subarray(0, newline).toString("utf8");
|
|
137
|
+
stdoutRemainder = Buffer.from(stdoutRemainder.subarray(newline + 1));
|
|
138
|
+
let frame;
|
|
139
|
+
try {
|
|
140
|
+
const parsed = JSON.parse(line);
|
|
141
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
|
|
142
|
+
frame = parsed;
|
|
143
|
+
}
|
|
144
|
+
catch { /* decoder reports malformed retained protocol lines */ }
|
|
145
|
+
if (frame === undefined) {
|
|
146
|
+
stdout.push(Buffer.from(`${line}\n`));
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (frame.type === "thread.started" && typeof frame.thread_id === "string") {
|
|
150
|
+
options.onCodexThreadStarted?.(frame.thread_id);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const item = typeof frame.item === "object" && frame.item !== null && !Array.isArray(frame.item) ? frame.item : undefined;
|
|
154
|
+
if (frame.type === "item.completed" && (item?.type === "command_execution" || item?.type === "mcp_tool_call")) {
|
|
155
|
+
ndjsonCalls += 1;
|
|
156
|
+
stdout.push(Buffer.from(`${JSON.stringify({ type: frame.type, item: { type: item.type } })}\n`));
|
|
157
|
+
}
|
|
158
|
+
else if ((frame.type === "item.completed" && item?.type === "agent_message") || frame.type === "turn.completed" || frame.type === "turn.failed") {
|
|
159
|
+
if (frame.type === "turn.completed") {
|
|
160
|
+
// Decode and publish first, kill second: the ceiling breach is the
|
|
161
|
+
// one path guaranteed to destroy this stream, so the accounting
|
|
162
|
+
// has to leave the reader before the child does.
|
|
163
|
+
const usage = decodeCodexTurnUsage(frame, ndjsonCalls);
|
|
164
|
+
options.onCodexTurnCompleted?.(usage);
|
|
165
|
+
if (options.codexTokenCeiling !== undefined && usage !== undefined && usage.total >= options.codexTokenCeiling) {
|
|
166
|
+
abort(tagCliChildFailure(new Error(`Codex wake exceeded its ${options.codexTokenCeiling}-token per-wake ceiling (turn usage ${usage.total} tokens)`), "token_ceiling"));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
stdout.push(Buffer.from(`${line}\n`));
|
|
171
|
+
}
|
|
172
|
+
stdoutBytes = stdout.reduce((total, part) => total + part.length, 0);
|
|
173
|
+
if (stdoutBytes > CLI_ENGINE_MAX_OUTPUT_BYTES) {
|
|
174
|
+
abort(tagCliChildFailure(new Error(`CLI engine output exceeded ${CLI_ENGINE_MAX_OUTPUT_BYTES} bytes`), "output_limit"));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (stdoutRemainder.length > CLI_ENGINE_MAX_OUTPUT_BYTES) {
|
|
179
|
+
const prefix = stdoutRemainder.subarray(0, Math.min(stdoutRemainder.length, 4096)).toString("utf8");
|
|
180
|
+
if (/"type"\s*:\s*"item\.completed"/u.test(prefix)
|
|
181
|
+
&& !/"type"\s*:\s*"agent_message"/u.test(prefix)) {
|
|
182
|
+
const toolType = prefix.match(/"type"\s*:\s*"(command_execution|mcp_tool_call)"/u)?.[1];
|
|
183
|
+
if (toolType !== undefined) {
|
|
184
|
+
ndjsonCalls += 1;
|
|
185
|
+
stdout.push(Buffer.from(`${JSON.stringify({ type: "item.completed", item: { type: toolType } })}\n`));
|
|
186
|
+
}
|
|
187
|
+
stdoutRemainder = Buffer.alloc(0);
|
|
188
|
+
droppingNdjsonLine = true;
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
abort(tagCliChildFailure(new Error(`CLI engine output exceeded ${CLI_ENGINE_MAX_OUTPUT_BYTES} bytes`), "output_limit"));
|
|
192
|
+
}
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (options.retainStdoutTail === true) {
|
|
196
|
+
let remainder = value;
|
|
197
|
+
if (droppingStdoutLine) {
|
|
198
|
+
const newline = remainder.indexOf(0x0a);
|
|
199
|
+
if (newline < 0)
|
|
200
|
+
return;
|
|
201
|
+
droppingStdoutLine = false;
|
|
202
|
+
remainder = remainder.subarray(newline + 1);
|
|
203
|
+
}
|
|
204
|
+
const combined = Buffer.concat([stdoutTail, remainder]);
|
|
205
|
+
if (combined.length <= CLI_ENGINE_MAX_OUTPUT_BYTES) {
|
|
206
|
+
stdoutTail = combined;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const overflow = combined.length - CLI_ENGINE_MAX_OUTPUT_BYTES;
|
|
210
|
+
if (combined[overflow - 1] === 0x0a) {
|
|
211
|
+
stdoutTail = Buffer.from(combined.subarray(overflow));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const newline = combined.indexOf(0x0a, overflow);
|
|
215
|
+
stdoutTail = newline < 0 ? Buffer.alloc(0) : Buffer.from(combined.subarray(newline + 1));
|
|
216
|
+
droppingStdoutLine = newline < 0;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
stdoutBytes += value.length;
|
|
220
|
+
if (stdoutBytes > CLI_ENGINE_MAX_OUTPUT_BYTES) {
|
|
221
|
+
abort(tagCliChildFailure(new Error(`CLI engine output exceeded ${CLI_ENGINE_MAX_OUTPUT_BYTES} bytes`), "output_limit"));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
stdout.push(value);
|
|
225
|
+
};
|
|
226
|
+
const retainStderrWindow = (chunk) => {
|
|
227
|
+
const value = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
228
|
+
classifyFailure(value);
|
|
229
|
+
stderrBytes += value.length;
|
|
230
|
+
if (stderrHead.length < stderrHeadBytes)
|
|
231
|
+
stderrHead = Buffer.concat([stderrHead, value.subarray(0, stderrHeadBytes - stderrHead.length)]);
|
|
232
|
+
if (value.length >= stderrTailBytes) {
|
|
233
|
+
stderrTail = Buffer.from(value.subarray(value.length - stderrTailBytes));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const overflow = stderrTail.length + value.length - stderrTailBytes;
|
|
237
|
+
stderrTail = Buffer.concat([overflow > 0 ? stderrTail.subarray(overflow) : stderrTail, value]);
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* The retained stderr, reassembled exactly.
|
|
241
|
+
*
|
|
242
|
+
* Nothing was elided while the whole output fitted the budget, and then the
|
|
243
|
+
* two ends overlap: they tile the stream, so dropping the overlap from the
|
|
244
|
+
* tail rebuilds it byte-identically. Above the budget the ends are joined by
|
|
245
|
+
* the marker, which names how many bytes never reached this process at all.
|
|
246
|
+
*/
|
|
247
|
+
const retainedStderr = () => {
|
|
248
|
+
const elided = stderrBytes - stderrHead.length - stderrTail.length;
|
|
249
|
+
if (elided <= 0)
|
|
250
|
+
return Buffer.concat([stderrHead, stderrTail.subarray(stderrHead.length + stderrTail.length - stderrBytes)]).toString("utf8");
|
|
251
|
+
return `${stderrHead.toString("utf8")}${elisionMarker(elided)}${stderrTail.toString("utf8")}`;
|
|
252
|
+
};
|
|
253
|
+
child.stdout?.on("data", retainStdout);
|
|
254
|
+
child.stderr?.on("data", retainStderrWindow);
|
|
255
|
+
const timer = timeoutMs === undefined ? undefined : setTimeout(() => abort(tagCliChildFailure(new Error(options.timeoutErrorMessage ?? "CLI engine timed out"), "wake_timeout")), timeoutMs);
|
|
256
|
+
child.once("error", abort);
|
|
257
|
+
child.once("close", (code, signal) => {
|
|
258
|
+
if (cleanupStarted)
|
|
259
|
+
return;
|
|
260
|
+
if (options.retainNdjson !== undefined && stdoutRemainder.length > 0)
|
|
261
|
+
stdout.push(stdoutRemainder);
|
|
262
|
+
const retainedStdout = options.retainStdoutTail === true ? stdoutTail : Buffer.concat(stdout);
|
|
263
|
+
if (code === 0) {
|
|
264
|
+
settle(() => resolve(redactChildOutput(retainedStdout.toString("utf8"), secretValues).trim()));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
settle(() => reject(tagCliChildFailure(classifiedFailure ?? new Error(`CLI engine exited ${code ?? signal}${childDiagnostic(retainedStdout.toString("utf8"), retainedStderr(), secretValues)}`), "engine_exit")));
|
|
268
|
+
});
|
|
269
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CliEngineKind } from "./cliSession.js";
|
|
2
|
+
export interface EngineRunResult {
|
|
3
|
+
readonly durationMs: number;
|
|
4
|
+
readonly outputChars: number;
|
|
5
|
+
readonly promptChars: number;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const runEngineDetailed: (engine: CliEngineKind, prompt: string, paths: {
|
|
9
|
+
readonly workspacePath: string;
|
|
10
|
+
readonly runtimeHomePath?: string;
|
|
11
|
+
}) => Promise<EngineRunResult>;
|
|
12
|
+
export declare const runEngine: (engine: CliEngineKind, prompt: string, paths: {
|
|
13
|
+
readonly workspacePath: string;
|
|
14
|
+
readonly runtimeHomePath?: string;
|
|
15
|
+
}) => Promise<string>;
|
|
16
|
+
//# sourceMappingURL=cliEngineRun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliEngineRun.d.ts","sourceRoot":"","sources":["../../src/pi/cliEngineRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,aAAa,EAAyB,MAAM,iBAAiB,CAAC;AAEzH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,aAAa,EACrB,QAAQ,MAAM,EACd,OAAO;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,OAAO,CAAC,eAAe,CAsBzB,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,QAAQ,aAAa,EACrB,QAAQ,MAAM,EACd,OAAO;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,OAAO,CAAC,MAAM,CAA0D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AGY_MAX_TOOL_TURNS, createCliSessionFactory } from "./cliSession.js";
|
|
2
|
+
export const runEngineDetailed = async (engine, prompt, paths) => {
|
|
3
|
+
const startedAt = Date.now();
|
|
4
|
+
const options = engine === "agy"
|
|
5
|
+
? { engine, maxToolTurns: AGY_MAX_TOOL_TURNS, timeoutMs: 180_000 }
|
|
6
|
+
: { engine };
|
|
7
|
+
const { session } = await createCliSessionFactory(options)({
|
|
8
|
+
cwd: paths.workspacePath,
|
|
9
|
+
runtimeHomePath: paths.runtimeHomePath
|
|
10
|
+
});
|
|
11
|
+
let text = "";
|
|
12
|
+
const unsubscribe = session.subscribe((event) => {
|
|
13
|
+
if (event.type !== "turn_end")
|
|
14
|
+
return;
|
|
15
|
+
if (!("content" in event.message))
|
|
16
|
+
return;
|
|
17
|
+
text = Array.isArray(event.message.content)
|
|
18
|
+
? event.message.content.filter((entry) => entry.type === "text").map((entry) => entry.text).join("")
|
|
19
|
+
: event.message.content;
|
|
20
|
+
});
|
|
21
|
+
await session.prompt(prompt);
|
|
22
|
+
unsubscribe();
|
|
23
|
+
session.dispose();
|
|
24
|
+
await session.disposeAsync?.();
|
|
25
|
+
return { durationMs: Date.now() - startedAt, outputChars: text.length, promptChars: prompt.length, text };
|
|
26
|
+
};
|
|
27
|
+
export const runEngine = async (engine, prompt, paths) => (await runEngineDetailed(engine, prompt, paths)).text;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import type { CliEngineOptions, CliSessionInput } from "./cliSession.js";
|
|
3
|
+
export declare const GROK_STRICT_SANDBOX_PROFILE = "strict";
|
|
4
|
+
export declare const renderGrokSandboxArgs: (commandArgs: readonly string[] | undefined, profile: string) => string[];
|
|
5
|
+
/**
|
|
6
|
+
* Codex's `--json` stream is unconditional: it is the only output shape that
|
|
7
|
+
* carries `turn.completed.usage`, and an unmetered Codex turn is one whose
|
|
8
|
+
* subscription cost is invisible. The guarded arguments make this Daimon's
|
|
9
|
+
* security and metering boundary rather than a caller-controlled format.
|
|
10
|
+
*
|
|
11
|
+
* `model`/`reasoningEffort` come from parsed, bounded organization-runtime
|
|
12
|
+
* config, but are rendered defensively anyway: each is emitted as a single
|
|
13
|
+
* `--flag=value` argv token (never a bare flag followed by a separate value
|
|
14
|
+
* token), so a value that itself looks like a flag (e.g. `--sandbox`) can
|
|
15
|
+
* never be parsed as a second, independent argument — the same shape already
|
|
16
|
+
* used below for `mcp_servers.daimon.url=`. Omitting both fields leaves Codex's
|
|
17
|
+
* model defaults unchanged.
|
|
18
|
+
*
|
|
19
|
+
* The per-wake MCP server is always enabled and required. Otherwise Codex can
|
|
20
|
+
* continue a normal turn with only built-in tools after MCP startup fails.
|
|
21
|
+
* Subscription apps and installed plugins are not caller-declared tools.
|
|
22
|
+
* Disable their discovery per invocation, including with strict config: the
|
|
23
|
+
* CLI's defaults can otherwise add them even when user config is ignored.
|
|
24
|
+
*/
|
|
25
|
+
export declare const renderCodexArgs: (options: Pick<CliEngineOptions, "commandArgs" | "model" | "reasoningEffort" | "codexSandbox" | "codexSandboxProtectedPaths" | "codexSandboxReadablePaths">, cwd: string, endpoint: string | undefined, sandbox?: string) => string[];
|
|
26
|
+
export declare const renderCodexPermissionProfile: (profileName: string, protectedPaths: readonly string[], readablePaths?: readonly string[], workspacePath?: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* AGY's headless invocation.
|
|
29
|
+
*
|
|
30
|
+
* `--output-format stream-json` is unconditional: it is the only shape that
|
|
31
|
+
* carries `result.usage`, and an AGY turn that is not metered is an AGY turn
|
|
32
|
+
* whose subscription cost is invisible (see `agyHeadlessResult.ts`).
|
|
33
|
+
*
|
|
34
|
+
* `--dangerously-skip-permissions` is required for tools to work at all. AGY's
|
|
35
|
+
* default headless permission mode is `request-review`, and there is no
|
|
36
|
+
* reviewer inside a container, so a tool call can never be approved without it;
|
|
37
|
+
* the live probe that proved AGY's MCP tool calling ran with exactly this flag
|
|
38
|
+
* and reported `permission_mode: always-proceed`. Every Daimon CLI agent mounts
|
|
39
|
+
* at least the protected bash tool (`piHarness.ts`), so there is no AGY wake
|
|
40
|
+
* for which this is unnecessary and no conditional worth forking behavior over.
|
|
41
|
+
*
|
|
42
|
+
* SECURITY: the flag also auto-approves AGY's own ~50 built-in tools —
|
|
43
|
+
* `run_command`, `write_to_file`, the browser tools — none of which Daimon
|
|
44
|
+
* mediates. Inside the container that is the exposure Codex already has
|
|
45
|
+
* (`--sandbox danger-full-access`), but unlike Grok there is no kernel-enforced
|
|
46
|
+
* per-agent profile confining it to this agent's own workspace and runtime
|
|
47
|
+
* home. `DAIMON_AGY_SANDBOX=1` opts into AGY's own terminal-restricting
|
|
48
|
+
* sandbox; it is off by default only because its interaction with the MCP
|
|
49
|
+
* transport could not be verified without spending the operator's subscription
|
|
50
|
+
* quota, and shipping an unverified default that silently disables every tool
|
|
51
|
+
* would be worse than shipping the exposure with this note on it.
|
|
52
|
+
*/
|
|
53
|
+
export declare const renderAgyArgs: (options: Pick<CliEngineOptions, "commandArgs" | "timeoutMs">, prompt: string, sandbox?: boolean) => string[];
|
|
54
|
+
export declare const spawnEngine: (options: CliEngineOptions, prompt: string, input: CliSessionInput, endpoint: string | undefined, wakeId?: string) => ChildProcess;
|
|
55
|
+
//# sourceMappingURL=cliEngineSpawn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliEngineSpawn.d.ts","sourceRoot":"","sources":["../../src/pi/cliEngineSpawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEzE,eAAO,MAAM,2BAA2B,WAAW,CAAC;AAEpD,eAAO,MAAM,qBAAqB,GAChC,aAAa,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,SAAS,MAAM,KACd,MAAM,EAAuE,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,OAAO,GAAG,iBAAiB,GAAG,cAAc,GAAG,4BAA4B,GAAG,2BAA2B,CAAC,EAC1J,KAAK,MAAM,EACX,UAAU,MAAM,GAAG,SAAS,EAC5B,UAAS,MAA+F,KACvG,MAAM,EAyBR,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,aAAa,MAAM,EACnB,gBAAgB,SAAS,MAAM,EAAE,EACjC,gBAAe,SAAS,MAAM,EAAO,EACrC,gBAAgB,MAAM,KACrB,MAUF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,WAAW,CAAC,EAC5D,QAAQ,MAAM,EACd,UAAS,OAAgD,KACxD,MAAM,EAOR,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,SAAS,gBAAgB,EACzB,QAAQ,MAAM,EACd,OAAO,eAAe,EACtB,UAAU,MAAM,GAAG,SAAS,EAC5B,SAAS,MAAM,KACd,YAyBF,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { trackCliChild } from "./cliProcess.js";
|
|
3
|
+
import { cliChildEnvironment } from "./cliEnvironment.js";
|
|
4
|
+
import { codexFilesystemRules } from "./codexFilesystemRules.js";
|
|
5
|
+
export const GROK_STRICT_SANDBOX_PROFILE = "strict";
|
|
6
|
+
export const renderGrokSandboxArgs = (commandArgs, profile) => [...assertSafeGrokCommandArgs(commandArgs), "--sandbox", profile];
|
|
7
|
+
/**
|
|
8
|
+
* Codex's `--json` stream is unconditional: it is the only output shape that
|
|
9
|
+
* carries `turn.completed.usage`, and an unmetered Codex turn is one whose
|
|
10
|
+
* subscription cost is invisible. The guarded arguments make this Daimon's
|
|
11
|
+
* security and metering boundary rather than a caller-controlled format.
|
|
12
|
+
*
|
|
13
|
+
* `model`/`reasoningEffort` come from parsed, bounded organization-runtime
|
|
14
|
+
* config, but are rendered defensively anyway: each is emitted as a single
|
|
15
|
+
* `--flag=value` argv token (never a bare flag followed by a separate value
|
|
16
|
+
* token), so a value that itself looks like a flag (e.g. `--sandbox`) can
|
|
17
|
+
* never be parsed as a second, independent argument — the same shape already
|
|
18
|
+
* used below for `mcp_servers.daimon.url=`. Omitting both fields leaves Codex's
|
|
19
|
+
* model defaults unchanged.
|
|
20
|
+
*
|
|
21
|
+
* The per-wake MCP server is always enabled and required. Otherwise Codex can
|
|
22
|
+
* continue a normal turn with only built-in tools after MCP startup fails.
|
|
23
|
+
* Subscription apps and installed plugins are not caller-declared tools.
|
|
24
|
+
* Disable their discovery per invocation, including with strict config: the
|
|
25
|
+
* CLI's defaults can otherwise add them even when user config is ignored.
|
|
26
|
+
*/
|
|
27
|
+
export const renderCodexArgs = (options, cwd, endpoint, sandbox = options.codexSandbox?.mode ?? process.env.DAIMON_CODEX_SANDBOX ?? "danger-full-access") => {
|
|
28
|
+
const strictPolicy = options.codexSandbox;
|
|
29
|
+
if (strictPolicy !== undefined && (strictPolicy.mode !== "workspace-write" || strictPolicy.networkAccess !== false || strictPolicy.webSearch !== "disabled" || Object.keys(strictPolicy).length !== 3)) {
|
|
30
|
+
throw new Error("Codex sandbox policy is Daimon-owned and must be workspace-write with network and web search disabled");
|
|
31
|
+
}
|
|
32
|
+
const effectiveSandbox = strictPolicy?.mode ?? sandbox;
|
|
33
|
+
const profileName = "daimon-strict";
|
|
34
|
+
const policyArgs = strictPolicy === undefined ? [] : [
|
|
35
|
+
"--ignore-user-config",
|
|
36
|
+
"--ignore-rules",
|
|
37
|
+
"--strict-config",
|
|
38
|
+
"-c", "web_search=\"disabled\"",
|
|
39
|
+
"-c", `default_permissions=${JSON.stringify(profileName)}`,
|
|
40
|
+
"-c", renderCodexPermissionProfile(profileName, options.codexSandboxProtectedPaths ?? [], options.codexSandboxReadablePaths ?? [], cwd),
|
|
41
|
+
"-c", "approval_policy=\"never\"",
|
|
42
|
+
"-c", `mcp_servers={daimon={url=\"${endpoint}\",enabled=true,default_tools_approval_mode=\"approve\"}}`
|
|
43
|
+
];
|
|
44
|
+
return [...assertSafeCodexCommandArgs(options.commandArgs, strictPolicy !== undefined), "exec", ...(strictPolicy === undefined ? ["--sandbox", effectiveSandbox] : []), ...policyArgs, "--skip-git-repo-check",
|
|
45
|
+
...(options.model === undefined ? [] : [`--model=${options.model}`]),
|
|
46
|
+
...(options.reasoningEffort === undefined ? [] : ["-c", `model_reasoning_effort=${options.reasoningEffort}`]),
|
|
47
|
+
"--color", "never", "--json", "-C", cwd,
|
|
48
|
+
"-c", `mcp_servers.daimon.url=${endpoint}`,
|
|
49
|
+
"-c", "features.apps=false", "-c", "features.plugins=false",
|
|
50
|
+
"-c", "mcp_servers.daimon.enabled=true",
|
|
51
|
+
"-c", "mcp_servers.daimon.required=true", "-"];
|
|
52
|
+
};
|
|
53
|
+
export const renderCodexPermissionProfile = (profileName, protectedPaths, readablePaths = [], workspacePath) => {
|
|
54
|
+
const filesystem = {
|
|
55
|
+
":workspace_roots": { ".": "write" },
|
|
56
|
+
...codexFilesystemRules(protectedPaths, readablePaths, workspacePath)
|
|
57
|
+
};
|
|
58
|
+
return `permissions=${tomlInline({ [profileName]: {
|
|
59
|
+
extends: ":workspace",
|
|
60
|
+
filesystem,
|
|
61
|
+
network: { enabled: false }
|
|
62
|
+
} })}`;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* AGY's headless invocation.
|
|
66
|
+
*
|
|
67
|
+
* `--output-format stream-json` is unconditional: it is the only shape that
|
|
68
|
+
* carries `result.usage`, and an AGY turn that is not metered is an AGY turn
|
|
69
|
+
* whose subscription cost is invisible (see `agyHeadlessResult.ts`).
|
|
70
|
+
*
|
|
71
|
+
* `--dangerously-skip-permissions` is required for tools to work at all. AGY's
|
|
72
|
+
* default headless permission mode is `request-review`, and there is no
|
|
73
|
+
* reviewer inside a container, so a tool call can never be approved without it;
|
|
74
|
+
* the live probe that proved AGY's MCP tool calling ran with exactly this flag
|
|
75
|
+
* and reported `permission_mode: always-proceed`. Every Daimon CLI agent mounts
|
|
76
|
+
* at least the protected bash tool (`piHarness.ts`), so there is no AGY wake
|
|
77
|
+
* for which this is unnecessary and no conditional worth forking behavior over.
|
|
78
|
+
*
|
|
79
|
+
* SECURITY: the flag also auto-approves AGY's own ~50 built-in tools —
|
|
80
|
+
* `run_command`, `write_to_file`, the browser tools — none of which Daimon
|
|
81
|
+
* mediates. Inside the container that is the exposure Codex already has
|
|
82
|
+
* (`--sandbox danger-full-access`), but unlike Grok there is no kernel-enforced
|
|
83
|
+
* per-agent profile confining it to this agent's own workspace and runtime
|
|
84
|
+
* home. `DAIMON_AGY_SANDBOX=1` opts into AGY's own terminal-restricting
|
|
85
|
+
* sandbox; it is off by default only because its interaction with the MCP
|
|
86
|
+
* transport could not be verified without spending the operator's subscription
|
|
87
|
+
* quota, and shipping an unverified default that silently disables every tool
|
|
88
|
+
* would be worse than shipping the exposure with this note on it.
|
|
89
|
+
*/
|
|
90
|
+
export const renderAgyArgs = (options, prompt, sandbox = process.env.DAIMON_AGY_SANDBOX === "1") => [
|
|
91
|
+
...assertSafeAgyCommandArgs(options.commandArgs),
|
|
92
|
+
"--print", prompt,
|
|
93
|
+
"--output-format", "stream-json",
|
|
94
|
+
"--dangerously-skip-permissions",
|
|
95
|
+
...(sandbox ? ["--sandbox"] : []),
|
|
96
|
+
...(options.timeoutMs === undefined ? [] : ["--print-timeout", `${options.timeoutMs}ms`])
|
|
97
|
+
];
|
|
98
|
+
export const spawnEngine = (options, prompt, input, endpoint, wakeId) => {
|
|
99
|
+
const command = options.command ?? options.engine;
|
|
100
|
+
const env = cliChildEnvironment([
|
|
101
|
+
...(options.redactedEnvironmentNames ?? []),
|
|
102
|
+
...(input.daimonSecretEnvironmentNames ?? [])
|
|
103
|
+
], input.runtimeHomePath, {
|
|
104
|
+
dbusSessionBusAddress: options.engine === "agy" ? options.dbusSessionBusAddress : undefined,
|
|
105
|
+
engine: options.engine,
|
|
106
|
+
executablePath: options.command,
|
|
107
|
+
engineHomePath: options.engineHomePath,
|
|
108
|
+
wakeId
|
|
109
|
+
});
|
|
110
|
+
if (options.engine === "codex") {
|
|
111
|
+
const child = trackCliChild(spawn(command, renderCodexArgs(options, input.cwd, endpoint), { cwd: input.cwd, env, detached: process.platform !== "win32", stdio: ["pipe", "pipe", "pipe"] }));
|
|
112
|
+
child.stdin.on("error", () => undefined);
|
|
113
|
+
child.stdin.write(prompt);
|
|
114
|
+
child.stdin.end();
|
|
115
|
+
return child;
|
|
116
|
+
}
|
|
117
|
+
// Production supplies a Daimon-owned custom profile whose enforcement and
|
|
118
|
+
// explicit realm/peer denies are verified before every Grok process.
|
|
119
|
+
const args = options.engine === "grok"
|
|
120
|
+
? [...renderGrokSandboxArgs(options.commandArgs, options.grokSandboxProfile ?? GROK_STRICT_SANDBOX_PROFILE), "--always-approve", "--no-subagents", "--single", prompt, "--no-memory", "--disable-web-search", "--cwd", input.cwd,
|
|
121
|
+
"--output-format", "streaming-messages-json"]
|
|
122
|
+
: renderAgyArgs(options, prompt);
|
|
123
|
+
return trackCliChild(spawn(command, args, { cwd: input.cwd, env, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"] }));
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* AGY's output format, permission mode, sandbox, and session continuity are
|
|
127
|
+
* Daimon-owned, exactly as Grok's sandbox and approval flags are. A caller
|
|
128
|
+
* cannot re-open the permission boundary, silence the metering stream, or turn
|
|
129
|
+
* a per-wake cold process into a resumed conversation through `commandArgs`.
|
|
130
|
+
*/
|
|
131
|
+
const assertSafeAgyCommandArgs = (args) => {
|
|
132
|
+
const values = args ?? [];
|
|
133
|
+
if (values.some((value) => /^(?:--dangerously-skip-permissions|--sandbox|--output-format|--print|--prompt|--prompt-interactive|--mode|--continue|--conversation|-p|-i|-c)(?:=|$)/u.test(value))) {
|
|
134
|
+
throw new Error("AGY security-boundary arguments are Daimon-owned");
|
|
135
|
+
}
|
|
136
|
+
return values;
|
|
137
|
+
};
|
|
138
|
+
/** Caller arguments cannot reopen Codex's sandbox, output, cwd, or config boundary. */
|
|
139
|
+
const assertSafeCodexCommandArgs = (args, strictPolicy = false) => {
|
|
140
|
+
const values = args ?? [];
|
|
141
|
+
const pattern = /^(?:--json|--sandbox|--dangerously-bypass-approvals-and-sandbox|--output-last-message|--config|--ignore-user-config|--ignore-rules|--skip-git-repo-check|--color|--cd|--enable|-c|-C)(?:=|$)/u;
|
|
142
|
+
const strictPattern = /^(?:--strict-config|--profile|-p|-P|--permissions-profile|--enable|--disable|--add-dir|--search)(?:=|$)|^(?:default_permissions|permissions)(?:=|\.)/u;
|
|
143
|
+
if (values.some((value) => pattern.test(value) || (strictPolicy && strictPattern.test(value)))) {
|
|
144
|
+
throw new Error("Codex security-boundary arguments are Daimon-owned");
|
|
145
|
+
}
|
|
146
|
+
return values;
|
|
147
|
+
};
|
|
148
|
+
const assertSafeGrokCommandArgs = (args) => {
|
|
149
|
+
const values = args ?? [];
|
|
150
|
+
if (values.some((value) => /^(?:--sandbox|--always-approve|--permission-mode|--leader-socket)(?:=|$)/u.test(value))) {
|
|
151
|
+
throw new Error("Grok security-boundary arguments are Daimon-owned");
|
|
152
|
+
}
|
|
153
|
+
return values;
|
|
154
|
+
};
|
|
155
|
+
function tomlInline(value) {
|
|
156
|
+
if (typeof value === "string")
|
|
157
|
+
return JSON.stringify(value);
|
|
158
|
+
if (typeof value === "boolean")
|
|
159
|
+
return value ? "true" : "false";
|
|
160
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
161
|
+
return `{${Object.entries(value).map(([key, entry]) => `${JSON.stringify(key)}=${tomlInline(entry)}`).join(",")}}`;
|
|
162
|
+
}
|
|
163
|
+
throw new Error("unsupported Codex permission profile value");
|
|
164
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CliEnvironmentIntent = Readonly<{
|
|
2
|
+
dbusSessionBusAddress?: string;
|
|
3
|
+
engine?: "codex" | "grok" | "agy";
|
|
4
|
+
executablePath?: string;
|
|
5
|
+
engineHomePath?: string;
|
|
6
|
+
wakeId?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const DAIMON_WAKE_ID_ENV: "DAIMON_WAKE_ID";
|
|
9
|
+
/** Build a positive child environment; agent CLIs never inherit host secrets. */
|
|
10
|
+
export declare const cliChildEnvironment: (_redactedNames: readonly string[], runtimeHomePath?: string, intent?: CliEnvironmentIntent) => NodeJS.ProcessEnv;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=cliEnvironment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliEnvironment.d.ts","sourceRoot":"","sources":["../../src/pi/cliEnvironment.ts"],"names":[],"mappings":"AAEA,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAG,gBAAyB,CAAC;AAE5D,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,GAC9B,gBAAgB,SAAS,MAAM,EAAE,EAAE,kBAAkB,MAAM,EAAE,SAAQ,oBAAyB,KAC7F,MAAM,CAAC,UA2BT,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export const DAIMON_WAKE_ID_ENV = "DAIMON_WAKE_ID";
|
|
3
|
+
/** Build a positive child environment; agent CLIs never inherit host secrets. */
|
|
4
|
+
export const cliChildEnvironment = (_redactedNames, runtimeHomePath, intent = {}) => {
|
|
5
|
+
if (runtimeHomePath === undefined) {
|
|
6
|
+
// This legacy branch is only used by the standalone Pi helpers, which do
|
|
7
|
+
// not claim production organization-runtime isolation.
|
|
8
|
+
return { PATH: process.env.PATH, LANG: process.env.LANG ?? "C", LC_ALL: process.env.LC_ALL ?? "C", TZ: process.env.TZ ?? "UTC" };
|
|
9
|
+
}
|
|
10
|
+
const engine = intent.engine;
|
|
11
|
+
const engineVariable = engine === "codex" ? "CODEX_HOME" : engine === "grok" ? "GROK_HOME" : engine === "agy" ? "ANTIGRAVITY_CLI_HOME" : undefined;
|
|
12
|
+
const engineHome = intent.engineHomePath;
|
|
13
|
+
const keyringBus = engine === "agy" ? localSecretServiceBus(intent.dbusSessionBusAddress) : undefined;
|
|
14
|
+
return {
|
|
15
|
+
// The executable is pinned absolutely. PATH remains only for a trusted
|
|
16
|
+
// interpreter in a local shebang (and never selects the engine itself).
|
|
17
|
+
PATH: intent.executablePath === undefined ? process.env.PATH : `${path.dirname(intent.executablePath)}${path.delimiter}${path.dirname(process.execPath)}`,
|
|
18
|
+
LANG: process.env.LANG ?? "C",
|
|
19
|
+
LC_ALL: process.env.LC_ALL ?? "C",
|
|
20
|
+
TZ: process.env.TZ ?? "UTC",
|
|
21
|
+
HOME: runtimeHomePath,
|
|
22
|
+
XDG_CONFIG_HOME: `${runtimeHomePath}/.config`,
|
|
23
|
+
XDG_DATA_HOME: `${runtimeHomePath}/.local/share`,
|
|
24
|
+
XDG_STATE_HOME: `${runtimeHomePath}/.local/state`,
|
|
25
|
+
XDG_CACHE_HOME: `${runtimeHomePath}/.cache`,
|
|
26
|
+
TMPDIR: `${runtimeHomePath}/.tmp`,
|
|
27
|
+
...(engineVariable === undefined || engineHome === undefined ? {} : { [engineVariable]: engineHome }),
|
|
28
|
+
...(keyringBus === undefined ? {} : { DBUS_SESSION_BUS_ADDRESS: keyringBus }),
|
|
29
|
+
...(intent.wakeId === undefined ? {} : { [DAIMON_WAKE_ID_ENV]: intent.wakeId })
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const localSecretServiceBus = (value) => value !== undefined && /^unix:(?:path|abstract)=[^;,\r\n]+$/u.test(value) ? value : undefined;
|