@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
package/dist/pi/piHarness.js
CHANGED
|
@@ -1,228 +1,16 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { AuthStorage,
|
|
3
|
+
import { AuthStorage, createBashTool, createAgentSession, SessionManager, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { createMemoryRuntime } from "@noopolis/mneme";
|
|
4
5
|
import { resolvePiHarnessModel } from "./modelConfig.js";
|
|
6
|
+
import { createPiModelRegistry } from "./modelRegistry.js";
|
|
5
7
|
import { createPiMemoryTools, piMemoryToolNames } from "./memoryTools.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { modelsConfig } = resolvePiHarnessModel(options.model);
|
|
13
|
-
for (const [provider, config] of Object.entries(modelsConfig.providers)) {
|
|
14
|
-
registry.registerProvider(provider, {
|
|
15
|
-
api: config.api,
|
|
16
|
-
apiKey: config.apiKey,
|
|
17
|
-
baseUrl: config.baseUrl,
|
|
18
|
-
models: config.models
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return registry;
|
|
23
|
-
};
|
|
24
|
-
const fallbackPacket = (input) => ({
|
|
25
|
-
principal: {
|
|
26
|
-
agentId: "unknown",
|
|
27
|
-
scope: "global"
|
|
28
|
-
},
|
|
29
|
-
sections: [{ heading: "Wake event", text: formatWakePrompt(input) }],
|
|
30
|
-
rawHint: "memory bypass active"
|
|
31
|
-
});
|
|
32
|
-
const extractOutputText = (chunks) => chunks.join("\n").trim();
|
|
33
|
-
class PiAgentHandle {
|
|
34
|
-
id;
|
|
35
|
-
session;
|
|
36
|
-
memory;
|
|
37
|
-
memoryToolContext;
|
|
38
|
-
state = "idle";
|
|
39
|
-
lastWakeAt;
|
|
40
|
-
lastError;
|
|
41
|
-
wakeQueue = Promise.resolve();
|
|
42
|
-
constructor(id, session, memory, memoryToolContext) {
|
|
43
|
-
this.id = id;
|
|
44
|
-
this.session = session;
|
|
45
|
-
this.memory = memory;
|
|
46
|
-
this.memoryToolContext = memoryToolContext;
|
|
47
|
-
}
|
|
48
|
-
async wake(event) {
|
|
49
|
-
const queued = this.wakeQueue.then(() => this.runWake(event), () => this.runWake(event));
|
|
50
|
-
this.wakeQueue = queued.then(() => undefined, () => undefined);
|
|
51
|
-
return queued;
|
|
52
|
-
}
|
|
53
|
-
async runWake(event) {
|
|
54
|
-
const startedAt = Date.now();
|
|
55
|
-
const chunks = [];
|
|
56
|
-
const toolEvents = [];
|
|
57
|
-
this.state = "running";
|
|
58
|
-
this.lastWakeAt = new Date().toISOString();
|
|
59
|
-
this.lastError = undefined;
|
|
60
|
-
const unsubscribe = this.session.subscribe((piEvent) => {
|
|
61
|
-
if (piEvent && typeof piEvent === "object" && "type" in piEvent && piEvent.type !== "turn_end") {
|
|
62
|
-
toolEvents.push(piEvent);
|
|
63
|
-
}
|
|
64
|
-
if (piEvent.type !== "turn_end") {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const message = piEvent.message;
|
|
68
|
-
const content = message.content;
|
|
69
|
-
if (typeof content === "string") {
|
|
70
|
-
chunks.push(content);
|
|
71
|
-
}
|
|
72
|
-
else if (Array.isArray(content)) {
|
|
73
|
-
chunks.push(content
|
|
74
|
-
.filter((item) => {
|
|
75
|
-
const candidate = item;
|
|
76
|
-
return candidate.type === "text" && typeof candidate.text === "string";
|
|
77
|
-
})
|
|
78
|
-
.map((item) => item.text)
|
|
79
|
-
.join(""));
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const memoryContext = readMemoryContext({
|
|
83
|
-
kind: event.kind,
|
|
84
|
-
id: event.id,
|
|
85
|
-
from: event.from,
|
|
86
|
-
text: event.text,
|
|
87
|
-
context: event.context
|
|
88
|
-
});
|
|
89
|
-
const request = {
|
|
90
|
-
eventId: event.id,
|
|
91
|
-
kind: event.kind,
|
|
92
|
-
text: event.text,
|
|
93
|
-
from: event.from,
|
|
94
|
-
context: memoryContext
|
|
95
|
-
};
|
|
96
|
-
let prepared;
|
|
97
|
-
let promptText = formatWakePrompt(event);
|
|
98
|
-
try {
|
|
99
|
-
if (this.memory) {
|
|
100
|
-
prepared = await this.memory.prepareTurn(request);
|
|
101
|
-
promptText = prepared.promptText;
|
|
102
|
-
if (this.memoryToolContext) {
|
|
103
|
-
this.memoryToolContext.current = {
|
|
104
|
-
wakeId: event.id,
|
|
105
|
-
threadId: `${memoryContext.networkId ?? "local"}:${memoryContext.roomId ?? event.from ?? "manual"}`,
|
|
106
|
-
principal: prepared.principal,
|
|
107
|
-
conversationScope: memoryScopeId(prepared.principal),
|
|
108
|
-
audienceKey: memoryContext.roomId ?? event.from ?? this.id,
|
|
109
|
-
transport: "in_process"
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
await this.session.prompt(promptText, { expandPromptTemplates: false });
|
|
114
|
-
this.state = "idle";
|
|
115
|
-
const outputText = extractOutputText(chunks);
|
|
116
|
-
if (this.memory) {
|
|
117
|
-
const promptPacket = prepared?.packet ?? fallbackPacket(event);
|
|
118
|
-
await this.memory.recordTurn({
|
|
119
|
-
principal: {
|
|
120
|
-
agentId: this.id,
|
|
121
|
-
scope: prepared?.principal.scope ?? "global",
|
|
122
|
-
qualifier: prepared?.principal.qualifier
|
|
123
|
-
},
|
|
124
|
-
prompt: {
|
|
125
|
-
...promptPacket,
|
|
126
|
-
principal: {
|
|
127
|
-
agentId: this.id,
|
|
128
|
-
scope: prepared?.principal.scope ?? "global",
|
|
129
|
-
qualifier: prepared?.principal.qualifier
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
request,
|
|
133
|
-
recall: prepared?.recall,
|
|
134
|
-
result: "completed",
|
|
135
|
-
outputText,
|
|
136
|
-
toolEvents
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
agentId: this.id,
|
|
141
|
-
text: outputText,
|
|
142
|
-
durationMs: Date.now() - startedAt
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
this.state = "failed";
|
|
147
|
-
this.lastError = error instanceof Error ? error.message : String(error);
|
|
148
|
-
if (this.memory) {
|
|
149
|
-
try {
|
|
150
|
-
const promptPacket = prepared?.packet ?? fallbackPacket(event);
|
|
151
|
-
await this.memory.recordTurn({
|
|
152
|
-
principal: {
|
|
153
|
-
agentId: this.id,
|
|
154
|
-
scope: prepared?.principal.scope ?? "global",
|
|
155
|
-
qualifier: prepared?.principal.qualifier
|
|
156
|
-
},
|
|
157
|
-
prompt: {
|
|
158
|
-
...promptPacket,
|
|
159
|
-
principal: {
|
|
160
|
-
agentId: this.id,
|
|
161
|
-
scope: prepared?.principal.scope ?? "global",
|
|
162
|
-
qualifier: prepared?.principal.qualifier
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
request,
|
|
166
|
-
recall: prepared?.recall,
|
|
167
|
-
result: "failed",
|
|
168
|
-
outputText: extractOutputText(chunks),
|
|
169
|
-
toolEvents,
|
|
170
|
-
error: this.lastError
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch {
|
|
174
|
-
// Memory write-back is best-effort when waking fails.
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
finally {
|
|
180
|
-
if (this.memoryToolContext) {
|
|
181
|
-
this.memoryToolContext.current = undefined;
|
|
182
|
-
}
|
|
183
|
-
unsubscribe();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
status() {
|
|
187
|
-
return {
|
|
188
|
-
agentId: this.id,
|
|
189
|
-
state: this.state,
|
|
190
|
-
lastWakeAt: this.lastWakeAt,
|
|
191
|
-
lastError: this.lastError
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
async stop() {
|
|
195
|
-
this.session.dispose();
|
|
196
|
-
this.state = "stopped";
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const formatWakePrompt = (event) => `Wake event:
|
|
200
|
-
- id: ${event.id}
|
|
201
|
-
- kind: ${event.kind}
|
|
202
|
-
- from: ${event.from ?? "operator"}
|
|
203
|
-
|
|
204
|
-
${event.text}`;
|
|
205
|
-
const createResourceLoader = (input) => {
|
|
206
|
-
const systemPrompt = [
|
|
207
|
-
`You are ${input.name} (${input.id}).`,
|
|
208
|
-
input.instructions,
|
|
209
|
-
"You are running inside a harnessed workspace prepared by the caller.",
|
|
210
|
-
"Use the available coding tools when asked to read, write, edit, or inspect files.",
|
|
211
|
-
"Use memory_search, memory_locate, memory_register, memory_summarize, and memory_forget when scoped memory matters.",
|
|
212
|
-
"Keep responses brief and report the exact files you created or modified."
|
|
213
|
-
].join("\n\n");
|
|
214
|
-
return {
|
|
215
|
-
getExtensions: () => ({ extensions: [], errors: [], runtime: createExtensionRuntime() }),
|
|
216
|
-
getSkills: () => ({ skills: [], diagnostics: [] }),
|
|
217
|
-
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
|
218
|
-
getThemes: () => ({ themes: [], diagnostics: [] }),
|
|
219
|
-
getAgentsFiles: () => ({ agentsFiles: [] }),
|
|
220
|
-
getSystemPrompt: () => systemPrompt,
|
|
221
|
-
getAppendSystemPrompt: () => [],
|
|
222
|
-
extendResources: () => { },
|
|
223
|
-
reload: async () => { }
|
|
224
|
-
};
|
|
225
|
-
};
|
|
8
|
+
import { createResourceLoader } from "./prompts.js";
|
|
9
|
+
import { PiAgentHandle } from "./piAgentHandle.js";
|
|
10
|
+
import { DAIMON_WAKE_ID_ENV } from "./cliEnvironment.js";
|
|
11
|
+
import { createPiWorldTools, piWorldToolNames } from "./worldTools.js";
|
|
12
|
+
import { ensureRuntimeHome, ensureRuntimeHomeDirectory } from "../runtime/runtimeHomeLayout.js";
|
|
13
|
+
import { bindPiRawTrainingCapture, validatePiRawTrainingCaptureOptions } from "./rawTrainingCapture.js";
|
|
226
14
|
export class PiHarnessAdapter {
|
|
227
15
|
options;
|
|
228
16
|
authStorage;
|
|
@@ -231,12 +19,17 @@ export class PiHarnessAdapter {
|
|
|
231
19
|
constructor(options) {
|
|
232
20
|
this.options = options;
|
|
233
21
|
this.authStorage = AuthStorage.create(options.authPath);
|
|
234
|
-
this.modelRegistry =
|
|
22
|
+
this.modelRegistry = createPiModelRegistry(this.authStorage, options);
|
|
235
23
|
this.sessionFactory = options.sessionFactory ?? createAgentSession;
|
|
236
24
|
}
|
|
237
25
|
async startAgent(input) {
|
|
238
|
-
|
|
26
|
+
validatePiRawTrainingCaptureOptions(this.options.rawTrainingCapture);
|
|
27
|
+
await ensureRuntimeHome(input.runtimeHomePath);
|
|
28
|
+
await Promise.all([".config", ".local/share", ".local/state", ".cache", ".tmp", "tool-state"]
|
|
29
|
+
.map((relative) => ensureRuntimeHomeDirectory(input.runtimeHomePath, relative)));
|
|
239
30
|
await mkdir(input.workspacePath, { recursive: true });
|
|
31
|
+
const memoryRuntimeHomePath = this.options.memory?.runtimeHomePath ?? input.runtimeHomePath;
|
|
32
|
+
await ensureRuntimeHome(memoryRuntimeHomePath);
|
|
240
33
|
const modelSpec = this.options.model ?? {
|
|
241
34
|
auth: { method: "codex" },
|
|
242
35
|
provider: "openai",
|
|
@@ -247,38 +40,140 @@ export class PiHarnessAdapter {
|
|
|
247
40
|
if (!model) {
|
|
248
41
|
throw new Error(`Pi model not found: ${resolvedModel.provider}/${resolvedModel.name}`);
|
|
249
42
|
}
|
|
250
|
-
const memory =
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
43
|
+
const memory = this.options.memory === undefined
|
|
44
|
+
? undefined
|
|
45
|
+
: createMemoryRuntime({
|
|
46
|
+
agentId: input.id,
|
|
47
|
+
authority: this.options.memory.authority,
|
|
48
|
+
embeddingProvider: this.options.memory.embeddingProvider,
|
|
49
|
+
runtimeHomePath: memoryRuntimeHomePath,
|
|
50
|
+
source: this.options.memory.source,
|
|
51
|
+
tokenBudget: this.options.memory.tokenBudget
|
|
52
|
+
});
|
|
53
|
+
const memoryToolContext = memory === undefined ? undefined : {};
|
|
54
|
+
const worldToolContext = this.options.world === undefined ? undefined : {};
|
|
55
|
+
const rawTrainingCaptureRef = this.options.rawTrainingCapture === undefined ? undefined : {};
|
|
56
|
+
const wakeEnvironmentContext = this.options.wakeEnvironmentContext ?? {};
|
|
57
|
+
// Fixed for the life of this agent, not per wake: whether it can publish
|
|
58
|
+
// through `moltnet_send` at all. Gates the terminal-text fallback in
|
|
59
|
+
// `PiAgentHandle.runWake` (see `PiWakeEnvironmentContextRef.hasSendCapability`).
|
|
60
|
+
wakeEnvironmentContext.hasSendCapability = (this.options.productionTools ?? []).some((tool) => tool.name === "moltnet_send");
|
|
61
|
+
const sessionInput = (mode, sessionDirectory) => {
|
|
62
|
+
const memoryTools = memory === undefined || memoryToolContext === undefined
|
|
63
|
+
? []
|
|
64
|
+
: createPiMemoryTools({
|
|
65
|
+
agentId: input.id,
|
|
66
|
+
memory,
|
|
67
|
+
contextRef: memoryToolContext,
|
|
68
|
+
mode
|
|
69
|
+
});
|
|
70
|
+
const worldTools = this.options.world === undefined
|
|
71
|
+
? undefined
|
|
72
|
+
: createPiWorldTools({
|
|
73
|
+
world: this.options.world,
|
|
74
|
+
contextRef: worldToolContext
|
|
75
|
+
});
|
|
76
|
+
// Every child tool inherits the same denylist: host control values,
|
|
77
|
+
// Daimon-held world/model secrets, and caller-protected names.
|
|
78
|
+
const protectedNames = [...new Set([
|
|
79
|
+
...(this.options.protectedEnvironmentNames ?? []),
|
|
80
|
+
...(this.options.world === undefined ? [] : [this.options.world.tokenEnv])
|
|
81
|
+
])];
|
|
82
|
+
const requestedTools = this.options.toolNames ?? input.tools;
|
|
83
|
+
const protectedBash = protectedNames.length === 0 || requestedTools?.includes("bash") === false
|
|
84
|
+
? []
|
|
85
|
+
: [createProtectedBashTool(input.workspacePath, input.runtimeHomePath, protectedNames, wakeEnvironmentContext)];
|
|
86
|
+
const toolNames = [
|
|
87
|
+
...(requestedTools ?? ["read", "write", "edit", "bash", "grep", "find", "ls"]),
|
|
88
|
+
...piMemoryToolNames(memoryTools),
|
|
89
|
+
...(worldTools === undefined ? [] : piWorldToolNames(worldTools)),
|
|
90
|
+
...(this.options.productionTools ?? []).map((tool) => tool.name)
|
|
91
|
+
];
|
|
92
|
+
return {
|
|
93
|
+
cwd: input.workspacePath,
|
|
94
|
+
agentDir: input.runtimeHomePath,
|
|
95
|
+
runtimeHomePath: input.runtimeHomePath,
|
|
96
|
+
daimonSecretEnvironmentNames: this.options.world === undefined ? [] : [this.options.world.tokenEnv],
|
|
97
|
+
authStorage: this.authStorage,
|
|
98
|
+
modelRegistry: this.modelRegistry,
|
|
99
|
+
model,
|
|
100
|
+
thinkingLevel: this.options.thinkingLevel ?? "off",
|
|
101
|
+
resourceLoader: createResourceLoader(input, mode, {
|
|
102
|
+
memory: memory !== undefined,
|
|
103
|
+
world: worldTools !== undefined
|
|
104
|
+
}),
|
|
105
|
+
tools: [...new Set(toolNames)],
|
|
106
|
+
customTools: worldTools === undefined
|
|
107
|
+
? [...protectedBash, ...memoryTools, ...(this.options.productionTools ?? [])]
|
|
108
|
+
: [...protectedBash, ...memoryTools, ...worldTools, ...(this.options.productionTools ?? [])],
|
|
109
|
+
sessionManager: SessionManager.create(input.workspacePath, sessionDirectory),
|
|
110
|
+
settingsManager: SettingsManager.inMemory({
|
|
111
|
+
compaction: { enabled: false },
|
|
112
|
+
retry: { enabled: true, maxRetries: 1 }
|
|
113
|
+
})
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
if (this.options.rawTrainingCapture !== undefined) {
|
|
117
|
+
const createSession = async (mode, sessionDirectory) => {
|
|
118
|
+
const { session } = await createAgentSession(sessionInput(mode, sessionDirectory));
|
|
119
|
+
if (rawTrainingCaptureRef !== undefined) {
|
|
120
|
+
bindPiRawTrainingCapture(session, rawTrainingCaptureRef);
|
|
121
|
+
}
|
|
122
|
+
return session;
|
|
123
|
+
};
|
|
124
|
+
const session = await createSession("awake", path.join(input.runtimeHomePath, "sessions"));
|
|
125
|
+
return new PiAgentHandle(input.id, session, createSession, input.runtimeHomePath, {
|
|
126
|
+
authMethod: modelSpec.auth?.method ?? "none",
|
|
127
|
+
model: resolvedModel.name,
|
|
128
|
+
provider: resolvedModel.provider
|
|
129
|
+
}, memory, memoryToolContext, {}, worldToolContext, rawTrainingCaptureRef, this.options.rawTrainingCapture, worldToolContext === undefined
|
|
130
|
+
? undefined
|
|
131
|
+
: { instructions: input.instructions, thinkingLevel: this.options.thinkingLevel ?? "off" }, session, wakeEnvironmentContext);
|
|
132
|
+
}
|
|
133
|
+
const createSession = async (mode, sessionDirectory) => {
|
|
134
|
+
const { session } = await (this.options.sessionFactory ?? createAgentSession)(sessionInput(mode, sessionDirectory));
|
|
135
|
+
return session;
|
|
136
|
+
};
|
|
137
|
+
const session = await createSession("awake", path.join(input.runtimeHomePath, "sessions"));
|
|
138
|
+
return new PiAgentHandle(input.id, session, createSession, input.runtimeHomePath, {
|
|
139
|
+
authMethod: modelSpec.auth?.method ?? "none",
|
|
140
|
+
model: resolvedModel.name,
|
|
141
|
+
provider: resolvedModel.provider
|
|
142
|
+
}, memory, memoryToolContext, {}, worldToolContext, undefined, undefined, worldToolContext === undefined
|
|
143
|
+
? undefined
|
|
144
|
+
: {
|
|
145
|
+
instructions: input.instructions,
|
|
146
|
+
thinkingLevel: this.options.thinkingLevel ?? "off"
|
|
147
|
+
}, undefined, wakeEnvironmentContext);
|
|
283
148
|
}
|
|
284
149
|
}
|
|
150
|
+
function createProtectedBashTool(workspacePath, runtimeHomePath, protectedNames, wakeEnvironmentContext) {
|
|
151
|
+
const bash = createBashTool(workspacePath, {
|
|
152
|
+
spawnHook: (context) => ({
|
|
153
|
+
...context,
|
|
154
|
+
env: {
|
|
155
|
+
...Object.fromEntries(Object.entries(context.env).filter(([name]) => !protectedNames.includes(name))),
|
|
156
|
+
HOME: runtimeHomePath,
|
|
157
|
+
XDG_CONFIG_HOME: `${runtimeHomePath}/.config`,
|
|
158
|
+
XDG_DATA_HOME: `${runtimeHomePath}/.local/share`,
|
|
159
|
+
XDG_STATE_HOME: `${runtimeHomePath}/.local/state`,
|
|
160
|
+
XDG_CACHE_HOME: `${runtimeHomePath}/.cache`,
|
|
161
|
+
TMPDIR: `${runtimeHomePath}/.tmp`,
|
|
162
|
+
...(wakeEnvironmentContext.current === undefined
|
|
163
|
+
? {}
|
|
164
|
+
: { [DAIMON_WAKE_ID_ENV]: wakeEnvironmentContext.current })
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
name: bash.name,
|
|
170
|
+
label: bash.label,
|
|
171
|
+
description: bash.description,
|
|
172
|
+
parameters: bash.parameters,
|
|
173
|
+
...(bash.prepareArguments === undefined ? {} : { prepareArguments: bash.prepareArguments }),
|
|
174
|
+
...(bash.executionMode === undefined ? {} : { executionMode: bash.executionMode }),
|
|
175
|
+
async execute(toolCallId, params, signal, onUpdate) {
|
|
176
|
+
return bash.execute(toolCallId, params, signal, onUpdate);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ResourceLoader } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type MemoryWakeMode } from "@noopolis/mneme";
|
|
3
|
+
import type { AgentStartInput, WakeEvent } from "../core/types.js";
|
|
4
|
+
export declare const formatWakePrompt: (event: WakeEvent) => string;
|
|
5
|
+
export declare const preserveModelFacingWakeIdentity: (promptText: string, event: WakeEvent, memoryEventId: string) => string;
|
|
6
|
+
export declare const createResourceLoader: (input: AgentStartInput, mode: MemoryWakeMode, capabilities: Readonly<{
|
|
7
|
+
memory: boolean;
|
|
8
|
+
world: boolean;
|
|
9
|
+
}>) => ResourceLoader;
|
|
10
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/pi/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEnE,eAAO,MAAM,gBAAgB,GAAI,OAAO,SAAS,KAAG,MAKtC,CAAC;AAYf,eAAO,MAAM,+BAA+B,GAC1C,YAAY,MAAM,EAClB,OAAO,SAAS,EAChB,eAAe,MAAM,KACpB,MAiBF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,eAAe,EACtB,MAAM,cAAc,EACpB,cAAc,QAAQ,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,KAC1D,cA+BF,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createExtensionRuntime } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getMemorySkillTextForMode } from "@noopolis/mneme";
|
|
3
|
+
export const formatWakePrompt = (event) => `Wake event:
|
|
4
|
+
- id: ${event.id}
|
|
5
|
+
- kind: ${event.kind}
|
|
6
|
+
- from: ${event.from === undefined ? "[no attribution supplied] (absence)" : JSON.stringify(event.from)}
|
|
7
|
+
|
|
8
|
+
${event.text}`;
|
|
9
|
+
const WAKE_HEADER_PATTERN = /(^|\r?\n)## Wake\r?\nid: ([^\r\n]*)(?=\r?\n|$)/u;
|
|
10
|
+
const formatAuthoritativeWakeIdentity = (event) => [
|
|
11
|
+
"Wake identity:",
|
|
12
|
+
"Use this exact wake id as the delivery id/event key when a tool asks for event_key.",
|
|
13
|
+
`- id: ${event.id}`,
|
|
14
|
+
`- kind: ${event.kind}`,
|
|
15
|
+
`- from: ${event.from === undefined ? "[no attribution supplied] (absence)" : JSON.stringify(event.from)}`
|
|
16
|
+
].join("\n");
|
|
17
|
+
export const preserveModelFacingWakeIdentity = (promptText, event, memoryEventId) => {
|
|
18
|
+
if (event.id === memoryEventId)
|
|
19
|
+
return promptText;
|
|
20
|
+
const match = WAKE_HEADER_PATTERN.exec(promptText);
|
|
21
|
+
if (match === null) {
|
|
22
|
+
return `${formatAuthoritativeWakeIdentity(event)}\n\n${promptText}`;
|
|
23
|
+
}
|
|
24
|
+
const currentId = match[2];
|
|
25
|
+
if (currentId === event.id)
|
|
26
|
+
return promptText;
|
|
27
|
+
if (currentId !== memoryEventId) {
|
|
28
|
+
throw new Error("memory-prepared wake prompt carried an unexpected wake id");
|
|
29
|
+
}
|
|
30
|
+
const idStart = match.index + match[0].length - currentId.length;
|
|
31
|
+
return `${promptText.slice(0, idStart)}${event.id}${promptText.slice(idStart + currentId.length)}`;
|
|
32
|
+
};
|
|
33
|
+
export const createResourceLoader = (input, mode, capabilities) => {
|
|
34
|
+
const systemPrompt = [
|
|
35
|
+
`You are ${input.name} (${input.id}).`,
|
|
36
|
+
input.instructions,
|
|
37
|
+
"You are running inside a harnessed workspace prepared by the caller.",
|
|
38
|
+
...(input.tools === undefined || input.tools.length > 0
|
|
39
|
+
? [
|
|
40
|
+
"Use the available coding tools when asked to read, write, edit, or inspect files.",
|
|
41
|
+
"Keep responses brief and report the exact files you created or modified."
|
|
42
|
+
]
|
|
43
|
+
: []),
|
|
44
|
+
...(capabilities.memory ? [getMemorySkillTextForMode(mode)] : []),
|
|
45
|
+
...(capabilities.world
|
|
46
|
+
? [
|
|
47
|
+
"Use only the authenticated world tools and standing instructions to perceive and act. "
|
|
48
|
+
+ "The harness binds wake authority and request identity; choose only the sense, affordance, target, and typed action input exposed by tool schemas."
|
|
49
|
+
]
|
|
50
|
+
: [])
|
|
51
|
+
].filter((section) => section.length > 0).join("\n\n");
|
|
52
|
+
return {
|
|
53
|
+
getExtensions: () => ({ extensions: [], errors: [], runtime: createExtensionRuntime() }),
|
|
54
|
+
getSkills: () => ({ skills: [], diagnostics: [] }),
|
|
55
|
+
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
|
56
|
+
getThemes: () => ({ themes: [], diagnostics: [] }),
|
|
57
|
+
getAgentsFiles: () => ({ agentsFiles: [] }),
|
|
58
|
+
getSystemPrompt: () => systemPrompt,
|
|
59
|
+
getAppendSystemPrompt: () => [],
|
|
60
|
+
extendResources: () => { },
|
|
61
|
+
reload: async () => { }
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { createAgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { PiWorldTurnContext } from "./worldNudge.js";
|
|
3
|
+
export declare const PI_RAW_TRAINING_CAPTURE_SCHEMA: "daimon.pi.raw_training_capture.v2";
|
|
4
|
+
export interface PiRawTrainingCaptureOptions {
|
|
5
|
+
enabled: true;
|
|
6
|
+
retention: {
|
|
7
|
+
maxTurns: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PiRawTrainingCapture {
|
|
11
|
+
readonly events: string[];
|
|
12
|
+
readonly requests: Array<{
|
|
13
|
+
model: unknown;
|
|
14
|
+
payload: unknown;
|
|
15
|
+
requested_at: string;
|
|
16
|
+
response?: unknown;
|
|
17
|
+
response_at?: string;
|
|
18
|
+
sequence: number;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface PiRawTrainingCaptureRef {
|
|
22
|
+
current?: PiRawTrainingCapture;
|
|
23
|
+
}
|
|
24
|
+
type PiNativeSession = Awaited<ReturnType<typeof createAgentSession>>["session"];
|
|
25
|
+
type PiRawTrainingSession = Pick<PiNativeSession, "agent" | "model" | "sessionFile" | "sessionId" | "thinkingLevel">;
|
|
26
|
+
export interface PersistPiRawTrainingCaptureInput {
|
|
27
|
+
agentId: string;
|
|
28
|
+
capture: PiRawTrainingCapture;
|
|
29
|
+
completedAt: Date;
|
|
30
|
+
options: PiRawTrainingCaptureOptions;
|
|
31
|
+
runtimeHomePath: string;
|
|
32
|
+
session: PiRawTrainingSession;
|
|
33
|
+
startedAt: Date;
|
|
34
|
+
status: "completed" | "failed";
|
|
35
|
+
totalMs: number;
|
|
36
|
+
turnId: string;
|
|
37
|
+
world?: PiWorldTurnContext;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Installs a transparent recorder at Pi's native provider-payload seam.
|
|
41
|
+
*
|
|
42
|
+
* The recorder returns the exact result of any pre-existing hook, so enabling
|
|
43
|
+
* capture cannot alter the request sent to the model.
|
|
44
|
+
*/
|
|
45
|
+
export declare const bindPiRawTrainingCapture: (session: PiRawTrainingSession, ref: PiRawTrainingCaptureRef) => void;
|
|
46
|
+
export declare const createPiRawTrainingCapture: () => PiRawTrainingCapture;
|
|
47
|
+
export declare const capturePiRawTrainingEvent: (capture: PiRawTrainingCapture, event: unknown, now?: Date) => void;
|
|
48
|
+
export declare const validatePiRawTrainingCaptureOptions: (options: PiRawTrainingCaptureOptions | undefined) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Persists a deliberately private, unredacted training artifact.
|
|
51
|
+
*
|
|
52
|
+
* `pi-session.jsonl` is copied byte-for-byte from Pi's SessionManager. The
|
|
53
|
+
* request payloads come from Pi AI's `onPayload` seam after any prior payload
|
|
54
|
+
* transform, so they contain the exact structured provider input, including
|
|
55
|
+
* system/character prompts, messages, tool schemas, and sampling fields.
|
|
56
|
+
*/
|
|
57
|
+
export declare const persistPiRawTrainingCapture: (input: PersistPiRawTrainingCaptureInput) => Promise<string>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=rawTrainingCapture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawTrainingCapture.d.ts","sourceRoot":"","sources":["../../src/pi/rawTrainingCapture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,eAAO,MAAM,8BAA8B,EACzC,mCAA4C,CAAC;AAE/C,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;QACvB,KAAK,EAAE,OAAO,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,KAAK,eAAe,GAClB,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAC5D,KAAK,oBAAoB,GAAG,IAAI,CAC9B,eAAe,EACf,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAClE,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,2BAA2B,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAMD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,oBAAoB,EAC7B,KAAK,uBAAuB,KAC3B,IA4BF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,oBAG5C,CAAC;AAEH,eAAO,MAAM,yBAAyB,GACpC,SAAS,oBAAoB,EAC7B,OAAO,OAAO,EACd,UAAgB,KACf,IAKF,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAC9C,SAAS,2BAA2B,GAAG,SAAS,KAC/C,IAUF,CAAC;AAaF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,OAAO,gCAAgC,KACtC,OAAO,CAAC,MAAM,CAoIhB,CAAC"}
|