@noopolis/daimon 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/README.md +275 -51
  2. package/dist/contracts/attentionContract.d.ts +142 -0
  3. package/dist/contracts/attentionContract.d.ts.map +1 -0
  4. package/dist/contracts/attentionContract.js +21 -0
  5. package/dist/contracts/canonicalJson.d.ts +3 -0
  6. package/dist/contracts/canonicalJson.d.ts.map +1 -0
  7. package/dist/contracts/canonicalJson.js +54 -0
  8. package/dist/contracts/grokBrokerTaskClock.d.ts +18 -0
  9. package/dist/contracts/grokBrokerTaskClock.d.ts.map +1 -0
  10. package/dist/contracts/grokBrokerTaskClock.js +16 -0
  11. package/dist/contracts/grokWorkerContract.d.ts +74 -0
  12. package/dist/contracts/grokWorkerContract.d.ts.map +1 -0
  13. package/dist/contracts/grokWorkerContract.js +88 -0
  14. package/dist/contracts/organizationRuntimeContract.d.ts +841 -0
  15. package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
  16. package/dist/contracts/organizationRuntimeContract.js +123 -0
  17. package/dist/contracts/runtimeContractManifest.d.ts +1822 -0
  18. package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
  19. package/dist/contracts/runtimeContractManifest.js +206 -0
  20. package/dist/contracts/shellEnvironmentPolicy.d.ts +3 -0
  21. package/dist/contracts/shellEnvironmentPolicy.d.ts.map +1 -0
  22. package/dist/contracts/shellEnvironmentPolicy.js +5 -0
  23. package/dist/contracts/wakeMomentContract.d.ts +61 -0
  24. package/dist/contracts/wakeMomentContract.d.ts.map +1 -0
  25. package/dist/contracts/wakeMomentContract.js +27 -0
  26. package/dist/core/credentialRedaction.d.ts +4 -0
  27. package/dist/core/credentialRedaction.d.ts.map +1 -0
  28. package/dist/core/credentialRedaction.js +28 -0
  29. package/dist/core/types.d.ts +2 -0
  30. package/dist/core/types.d.ts.map +1 -1
  31. package/dist/examples/jungianPlayAgent.d.ts +1 -0
  32. package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
  33. package/dist/examples/jungianPlayAgent.js +6 -2
  34. package/dist/mcp/toolServer.d.ts +19 -2
  35. package/dist/mcp/toolServer.d.ts.map +1 -1
  36. package/dist/mcp/toolServer.js +57 -17
  37. package/dist/observability/causalEvents.d.ts +6 -6
  38. package/dist/observability/causalEvents.d.ts.map +1 -1
  39. package/dist/observability/causalEvents.js +107 -19
  40. package/dist/observability/orgObserver.d.ts.map +1 -1
  41. package/dist/observability/orgObserver.js +3 -3
  42. package/dist/pi/agyHeadlessResult.d.ts +60 -0
  43. package/dist/pi/agyHeadlessResult.d.ts.map +1 -0
  44. package/dist/pi/agyHeadlessResult.js +95 -0
  45. package/dist/pi/cliChildOutput.d.ts +67 -0
  46. package/dist/pi/cliChildOutput.d.ts.map +1 -0
  47. package/dist/pi/cliChildOutput.js +269 -0
  48. package/dist/pi/cliEngineRun.d.ts +16 -0
  49. package/dist/pi/cliEngineRun.d.ts.map +1 -0
  50. package/dist/pi/cliEngineRun.js +27 -0
  51. package/dist/pi/cliEngineSpawn.d.ts +55 -0
  52. package/dist/pi/cliEngineSpawn.d.ts.map +1 -0
  53. package/dist/pi/cliEngineSpawn.js +169 -0
  54. package/dist/pi/cliEnvironment.d.ts +12 -0
  55. package/dist/pi/cliEnvironment.d.ts.map +1 -0
  56. package/dist/pi/cliEnvironment.js +34 -0
  57. package/dist/pi/cliMcpRegistration.d.ts +61 -0
  58. package/dist/pi/cliMcpRegistration.d.ts.map +1 -0
  59. package/dist/pi/cliMcpRegistration.js +75 -0
  60. package/dist/pi/cliProcess.d.ts +7 -0
  61. package/dist/pi/cliProcess.d.ts.map +1 -0
  62. package/dist/pi/cliProcess.js +132 -0
  63. package/dist/pi/cliSession.d.ts +86 -24
  64. package/dist/pi/cliSession.d.ts.map +1 -1
  65. package/dist/pi/cliSession.js +251 -173
  66. package/dist/pi/cliSessionMcp.d.ts +9 -0
  67. package/dist/pi/cliSessionMcp.d.ts.map +1 -0
  68. package/dist/pi/cliSessionMcp.js +80 -0
  69. package/dist/pi/cliTurnMetering.d.ts +60 -0
  70. package/dist/pi/cliTurnMetering.d.ts.map +1 -0
  71. package/dist/pi/cliTurnMetering.js +60 -0
  72. package/dist/pi/codexFilesystemRules.d.ts +3 -0
  73. package/dist/pi/codexFilesystemRules.d.ts.map +1 -0
  74. package/dist/pi/codexFilesystemRules.js +28 -0
  75. package/dist/pi/codexHeadlessResult.d.ts +68 -0
  76. package/dist/pi/codexHeadlessResult.d.ts.map +1 -0
  77. package/dist/pi/codexHeadlessResult.js +122 -0
  78. package/dist/pi/codexRolloutUsage.d.ts +95 -0
  79. package/dist/pi/codexRolloutUsage.d.ts.map +1 -0
  80. package/dist/pi/codexRolloutUsage.js +221 -0
  81. package/dist/pi/engineTaskClock.d.ts +9 -0
  82. package/dist/pi/engineTaskClock.d.ts.map +1 -0
  83. package/dist/pi/engineTaskClock.js +28 -0
  84. package/dist/pi/engineWakeLimits.d.ts +39 -0
  85. package/dist/pi/engineWakeLimits.d.ts.map +1 -0
  86. package/dist/pi/engineWakeLimits.js +55 -0
  87. package/dist/pi/grokHeadlessResult.d.ts +36 -0
  88. package/dist/pi/grokHeadlessResult.d.ts.map +1 -0
  89. package/dist/pi/grokHeadlessResult.js +118 -0
  90. package/dist/pi/grokHomeMcpRegistration.d.ts +21 -0
  91. package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -0
  92. package/dist/pi/grokHomeMcpRegistration.js +58 -0
  93. package/dist/pi/grokSandbox.d.ts +11 -0
  94. package/dist/pi/grokSandbox.d.ts.map +1 -0
  95. package/dist/pi/grokSandbox.js +216 -0
  96. package/dist/pi/grokStreamUsage.d.ts +31 -0
  97. package/dist/pi/grokStreamUsage.d.ts.map +1 -0
  98. package/dist/pi/grokStreamUsage.js +51 -0
  99. package/dist/pi/memoryClock.d.ts +25 -0
  100. package/dist/pi/memoryClock.d.ts.map +1 -0
  101. package/dist/pi/memoryClock.js +18 -0
  102. package/dist/pi/piAgentHandle.d.ts +6 -3
  103. package/dist/pi/piAgentHandle.d.ts.map +1 -1
  104. package/dist/pi/piAgentHandle.js +42 -12
  105. package/dist/pi/piAgentWakeSupport.d.ts +35 -0
  106. package/dist/pi/piAgentWakeSupport.d.ts.map +1 -1
  107. package/dist/pi/piAgentWakeSupport.js +4 -0
  108. package/dist/pi/piHarness.d.ts +18 -3
  109. package/dist/pi/piHarness.d.ts.map +1 -1
  110. package/dist/pi/piHarness.js +83 -14
  111. package/dist/pi/prompts.d.ts +1 -0
  112. package/dist/pi/prompts.d.ts.map +1 -1
  113. package/dist/pi/prompts.js +24 -0
  114. package/dist/pi/taskClockProcess.d.ts +6 -0
  115. package/dist/pi/taskClockProcess.d.ts.map +1 -0
  116. package/dist/pi/taskClockProcess.js +8 -0
  117. package/dist/pi/turnCausal.d.ts +4 -2
  118. package/dist/pi/turnCausal.d.ts.map +1 -1
  119. package/dist/pi/turnCausal.js +4 -4
  120. package/dist/pi/turnTrace.d.ts.map +1 -1
  121. package/dist/pi/turnTrace.js +5 -8
  122. package/dist/pi/wakeAcceptance.d.ts +1 -1
  123. package/dist/pi/wakeAcceptance.d.ts.map +1 -1
  124. package/dist/pi/wakeAcceptance.js +2 -2
  125. package/dist/pi/worldTrajectory.d.ts +1 -1
  126. package/dist/pi/worldTrajectory.d.ts.map +1 -1
  127. package/dist/pi/worldTrajectory.js +3 -3
  128. package/dist/runtime/agySubscriptionBootstrap.d.ts +16 -0
  129. package/dist/runtime/agySubscriptionBootstrap.d.ts.map +1 -0
  130. package/dist/runtime/agySubscriptionBootstrap.js +80 -0
  131. package/dist/runtime/agySubscriptionRealm.d.ts +38 -0
  132. package/dist/runtime/agySubscriptionRealm.d.ts.map +1 -0
  133. package/dist/runtime/agySubscriptionRealm.js +242 -0
  134. package/dist/runtime/attention.d.ts +26 -0
  135. package/dist/runtime/attention.d.ts.map +1 -0
  136. package/dist/runtime/attention.js +49 -0
  137. package/dist/runtime/attentionDispatcher.d.ts +78 -0
  138. package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
  139. package/dist/runtime/attentionDispatcher.js +365 -0
  140. package/dist/runtime/cli.d.ts +7 -0
  141. package/dist/runtime/cli.d.ts.map +1 -0
  142. package/dist/runtime/cli.js +256 -0
  143. package/dist/runtime/codexSandboxProjection.d.ts +17 -0
  144. package/dist/runtime/codexSandboxProjection.d.ts.map +1 -0
  145. package/dist/runtime/codexSandboxProjection.js +40 -0
  146. package/dist/runtime/contract-manifest.json +1 -0
  147. package/dist/runtime/contract-manifest.sha256 +1 -0
  148. package/dist/runtime/contractManifest.d.ts +8 -0
  149. package/dist/runtime/contractManifest.d.ts.map +1 -0
  150. package/dist/runtime/contractManifest.js +4 -0
  151. package/dist/runtime/engineBrokerCapabilities.d.ts +40 -0
  152. package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
  153. package/dist/runtime/engineBrokerCapabilities.js +69 -0
  154. package/dist/runtime/engineBrokerControlClient.d.ts +55 -0
  155. package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
  156. package/dist/runtime/engineBrokerControlClient.js +228 -0
  157. package/dist/runtime/engineBrokerCredentialJournal.d.ts +12 -0
  158. package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
  159. package/dist/runtime/engineBrokerCredentialJournal.js +26 -0
  160. package/dist/runtime/engineBrokerInferenceProtocol.d.ts +53 -0
  161. package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
  162. package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
  163. package/dist/runtime/engineBrokerMcpCallLog.d.ts +171 -0
  164. package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
  165. package/dist/runtime/engineBrokerMcpCallLog.js +231 -0
  166. package/dist/runtime/engineBrokerMcpFacade.d.ts +59 -0
  167. package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
  168. package/dist/runtime/engineBrokerMcpFacade.js +346 -0
  169. package/dist/runtime/engineBrokerNativeClient.d.ts +52 -0
  170. package/dist/runtime/engineBrokerNativeClient.d.ts.map +1 -0
  171. package/dist/runtime/engineBrokerNativeClient.js +151 -0
  172. package/dist/runtime/engineBrokerProtocol.d.ts +167 -0
  173. package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
  174. package/dist/runtime/engineBrokerProtocol.js +357 -0
  175. package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
  176. package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
  177. package/dist/runtime/engineBrokerSealLedger.js +132 -0
  178. package/dist/runtime/engineBrokerService.d.ts +43 -0
  179. package/dist/runtime/engineBrokerService.d.ts.map +1 -0
  180. package/dist/runtime/engineBrokerService.js +196 -0
  181. package/dist/runtime/engineBrokerServiceCli.d.ts +5 -0
  182. package/dist/runtime/engineBrokerServiceCli.d.ts.map +1 -0
  183. package/dist/runtime/engineBrokerServiceCli.js +32 -0
  184. package/dist/runtime/engineBrokerServiceConfig.d.ts +55 -0
  185. package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
  186. package/dist/runtime/engineBrokerServiceConfig.js +130 -0
  187. package/dist/runtime/engineBrokerSingleflight.d.ts +13 -0
  188. package/dist/runtime/engineBrokerSingleflight.d.ts.map +1 -0
  189. package/dist/runtime/engineBrokerSingleflight.js +24 -0
  190. package/dist/runtime/engineBrokerTurnAccounting.d.ts +76 -0
  191. package/dist/runtime/engineBrokerTurnAccounting.d.ts.map +1 -0
  192. package/dist/runtime/engineBrokerTurnAccounting.js +108 -0
  193. package/dist/runtime/engineBrokerTurnRegistry.d.ts +57 -0
  194. package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -0
  195. package/dist/runtime/engineBrokerTurnRegistry.js +159 -0
  196. package/dist/runtime/engineDispatcher.d.ts +38 -0
  197. package/dist/runtime/engineDispatcher.d.ts.map +1 -0
  198. package/dist/runtime/engineDispatcher.js +228 -0
  199. package/dist/runtime/engineReadiness.d.ts +23 -0
  200. package/dist/runtime/engineReadiness.d.ts.map +1 -0
  201. package/dist/runtime/engineReadiness.js +222 -0
  202. package/dist/runtime/grokAuthenticationError.d.ts +8 -0
  203. package/dist/runtime/grokAuthenticationError.d.ts.map +1 -0
  204. package/dist/runtime/grokAuthenticationError.js +20 -0
  205. package/dist/runtime/grokBrokerCredentialAuthority.d.ts +23 -0
  206. package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
  207. package/dist/runtime/grokBrokerCredentialAuthority.js +150 -0
  208. package/dist/runtime/grokBrokerCredentialReader.d.ts +6 -0
  209. package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
  210. package/dist/runtime/grokBrokerCredentialReader.js +38 -0
  211. package/dist/runtime/grokBrokerModelPolicy.d.ts +23 -0
  212. package/dist/runtime/grokBrokerModelPolicy.d.ts.map +1 -0
  213. package/dist/runtime/grokBrokerModelPolicy.js +28 -0
  214. package/dist/runtime/grokBrokerProjection.d.ts +114 -0
  215. package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
  216. package/dist/runtime/grokBrokerProjection.js +101 -0
  217. package/dist/runtime/grokBrokerProviderClock.d.ts +26 -0
  218. package/dist/runtime/grokBrokerProviderClock.d.ts.map +1 -0
  219. package/dist/runtime/grokBrokerProviderClock.js +133 -0
  220. package/dist/runtime/grokBrokerProxy.d.ts +69 -0
  221. package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
  222. package/dist/runtime/grokBrokerProxy.js +326 -0
  223. package/dist/runtime/grokBrokerProxyJson.d.ts +10 -0
  224. package/dist/runtime/grokBrokerProxyJson.d.ts.map +1 -0
  225. package/dist/runtime/grokBrokerProxyJson.js +31 -0
  226. package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
  227. package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
  228. package/dist/runtime/grokBrokerProxyRequest.js +85 -0
  229. package/dist/runtime/grokBrokerRealmLease.d.ts +4 -0
  230. package/dist/runtime/grokBrokerRealmLease.d.ts.map +1 -0
  231. package/dist/runtime/grokBrokerRealmLease.js +33 -0
  232. package/dist/runtime/grokBrokerRefresh.d.ts +2 -0
  233. package/dist/runtime/grokBrokerRefresh.d.ts.map +1 -0
  234. package/dist/runtime/grokBrokerRefresh.js +15 -0
  235. package/dist/runtime/grokBrokerRunBudget.d.ts +20 -0
  236. package/dist/runtime/grokBrokerRunBudget.d.ts.map +1 -0
  237. package/dist/runtime/grokBrokerRunBudget.js +85 -0
  238. package/dist/runtime/grokBrokerSlot.d.ts +6 -0
  239. package/dist/runtime/grokBrokerSlot.d.ts.map +1 -0
  240. package/dist/runtime/grokBrokerSlot.js +21 -0
  241. package/dist/runtime/grokBrokerTaskClock.d.ts +32 -0
  242. package/dist/runtime/grokBrokerTaskClock.d.ts.map +1 -0
  243. package/dist/runtime/grokBrokerTaskClock.js +120 -0
  244. package/dist/runtime/grokBrokerTurnMeter.d.ts +180 -0
  245. package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
  246. package/dist/runtime/grokBrokerTurnMeter.js +337 -0
  247. package/dist/runtime/grokBrokerWorkerConfig.d.ts +89 -0
  248. package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
  249. package/dist/runtime/grokBrokerWorkerConfig.js +154 -0
  250. package/dist/runtime/grokEngineBroker.d.ts +88 -0
  251. package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
  252. package/dist/runtime/grokEngineBroker.js +202 -0
  253. package/dist/runtime/grokEngineBrokerLedger.d.ts +52 -0
  254. package/dist/runtime/grokEngineBrokerLedger.d.ts.map +1 -0
  255. package/dist/runtime/grokEngineBrokerLedger.js +114 -0
  256. package/dist/runtime/grokEngineBrokerMetering.d.ts +51 -0
  257. package/dist/runtime/grokEngineBrokerMetering.d.ts.map +1 -0
  258. package/dist/runtime/grokEngineBrokerMetering.js +34 -0
  259. package/dist/runtime/grokEngineBrokerTurn.d.ts +82 -0
  260. package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
  261. package/dist/runtime/grokEngineBrokerTurn.js +348 -0
  262. package/dist/runtime/grokEngineBrokerTurnEnd.d.ts +88 -0
  263. package/dist/runtime/grokEngineBrokerTurnEnd.d.ts.map +1 -0
  264. package/dist/runtime/grokEngineBrokerTurnEnd.js +148 -0
  265. package/dist/runtime/grokInferenceClientConfig.d.ts +41 -0
  266. package/dist/runtime/grokInferenceClientConfig.d.ts.map +1 -0
  267. package/dist/runtime/grokInferenceClientConfig.js +62 -0
  268. package/dist/runtime/grokInferenceGrants.d.ts +77 -0
  269. package/dist/runtime/grokInferenceGrants.d.ts.map +1 -0
  270. package/dist/runtime/grokInferenceGrants.js +116 -0
  271. package/dist/runtime/grokInferenceProxy.d.ts +29 -0
  272. package/dist/runtime/grokInferenceProxy.d.ts.map +1 -0
  273. package/dist/runtime/grokInferenceProxy.js +85 -0
  274. package/dist/runtime/grokInferenceProxyRequest.d.ts +23 -0
  275. package/dist/runtime/grokInferenceProxyRequest.d.ts.map +1 -0
  276. package/dist/runtime/grokInferenceProxyRequest.js +63 -0
  277. package/dist/runtime/grokSlotPreflightReceipt.d.ts +70 -0
  278. package/dist/runtime/grokSlotPreflightReceipt.d.ts.map +1 -0
  279. package/dist/runtime/grokSlotPreflightReceipt.js +101 -0
  280. package/dist/runtime/grokSubscriptionRealm.d.ts +4 -0
  281. package/dist/runtime/grokSubscriptionRealm.d.ts.map +1 -0
  282. package/dist/runtime/grokSubscriptionRealm.js +435 -0
  283. package/dist/runtime/grokSubscriptionRealmTypes.d.ts +26 -0
  284. package/dist/runtime/grokSubscriptionRealmTypes.d.ts.map +1 -0
  285. package/dist/runtime/grokSubscriptionRealmTypes.js +1 -0
  286. package/dist/runtime/grokWorkerAttestation.d.ts +175 -0
  287. package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -0
  288. package/dist/runtime/grokWorkerAttestation.js +266 -0
  289. package/dist/runtime/grokWorkerDenyPlacement.d.ts +80 -0
  290. package/dist/runtime/grokWorkerDenyPlacement.d.ts.map +1 -0
  291. package/dist/runtime/grokWorkerDenyPlacement.js +128 -0
  292. package/dist/runtime/grokWorkerHomeAttestation.d.ts +32 -0
  293. package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
  294. package/dist/runtime/grokWorkerHomeAttestation.js +75 -0
  295. package/dist/runtime/grokWorkerSandboxProfile.d.ts +27 -0
  296. package/dist/runtime/grokWorkerSandboxProfile.d.ts.map +1 -0
  297. package/dist/runtime/grokWorkerSandboxProfile.js +44 -0
  298. package/dist/runtime/grokWorkerTmpAttestation.d.ts +55 -0
  299. package/dist/runtime/grokWorkerTmpAttestation.d.ts.map +1 -0
  300. package/dist/runtime/grokWorkerTmpAttestation.js +63 -0
  301. package/dist/runtime/index.d.ts +31 -0
  302. package/dist/runtime/index.d.ts.map +1 -0
  303. package/dist/runtime/index.js +27 -0
  304. package/dist/runtime/inferenceUsageLedger.d.ts +38 -0
  305. package/dist/runtime/inferenceUsageLedger.d.ts.map +1 -0
  306. package/dist/runtime/inferenceUsageLedger.js +53 -0
  307. package/dist/runtime/mcpToolResult.d.ts +127 -0
  308. package/dist/runtime/mcpToolResult.d.ts.map +1 -0
  309. package/dist/runtime/mcpToolResult.js +214 -0
  310. package/dist/runtime/moltnetMachineRead.d.ts +97 -0
  311. package/dist/runtime/moltnetMachineRead.d.ts.map +1 -0
  312. package/dist/runtime/moltnetMachineRead.js +183 -0
  313. package/dist/runtime/native/daimon-engine-broker +0 -0
  314. package/dist/runtime/organizationRuntime.d.ts +168 -0
  315. package/dist/runtime/organizationRuntime.d.ts.map +1 -0
  316. package/dist/runtime/organizationRuntime.js +3 -0
  317. package/dist/runtime/organizationRuntimeAdmission.d.ts +6 -0
  318. package/dist/runtime/organizationRuntimeAdmission.d.ts.map +1 -0
  319. package/dist/runtime/organizationRuntimeAdmission.js +22 -0
  320. package/dist/runtime/organizationRuntimeControl.d.ts +51 -0
  321. package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
  322. package/dist/runtime/organizationRuntimeControl.js +283 -0
  323. package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
  324. package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
  325. package/dist/runtime/organizationRuntimeHost.js +368 -0
  326. package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
  327. package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
  328. package/dist/runtime/organizationRuntimeParsing.js +373 -0
  329. package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
  330. package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
  331. package/dist/runtime/organizationRuntimeReadiness.js +67 -0
  332. package/dist/runtime/organizationRuntimeRecording.d.ts +7 -0
  333. package/dist/runtime/organizationRuntimeRecording.d.ts.map +1 -0
  334. package/dist/runtime/organizationRuntimeRecording.js +58 -0
  335. package/dist/runtime/physicalReadiness.d.ts +59 -0
  336. package/dist/runtime/physicalReadiness.d.ts.map +1 -0
  337. package/dist/runtime/physicalReadiness.js +176 -0
  338. package/dist/runtime/portableCredentialAuth.d.ts +6 -0
  339. package/dist/runtime/portableCredentialAuth.d.ts.map +1 -0
  340. package/dist/runtime/portableCredentialAuth.js +70 -0
  341. package/dist/runtime/portableCredentialMaterial.d.ts +8 -0
  342. package/dist/runtime/portableCredentialMaterial.d.ts.map +1 -0
  343. package/dist/runtime/portableCredentialMaterial.js +169 -0
  344. package/dist/runtime/productionAgentTools.d.ts +5 -0
  345. package/dist/runtime/productionAgentTools.d.ts.map +1 -0
  346. package/dist/runtime/productionAgentTools.js +336 -0
  347. package/dist/runtime/relocateRuntimeConfig.d.ts +14 -0
  348. package/dist/runtime/relocateRuntimeConfig.d.ts.map +1 -0
  349. package/dist/runtime/relocateRuntimeConfig.js +38 -0
  350. package/dist/runtime/runtimeHomeLayout.d.ts +48 -0
  351. package/dist/runtime/runtimeHomeLayout.d.ts.map +1 -0
  352. package/dist/runtime/runtimeHomeLayout.js +84 -0
  353. package/dist/runtime/schedule.d.ts +40 -0
  354. package/dist/runtime/schedule.d.ts.map +1 -0
  355. package/dist/runtime/schedule.js +376 -0
  356. package/dist/runtime/storeCoordination.d.ts +33 -0
  357. package/dist/runtime/storeCoordination.d.ts.map +1 -0
  358. package/dist/runtime/storeCoordination.js +117 -0
  359. package/dist/runtime/taskClock.d.ts +42 -0
  360. package/dist/runtime/taskClock.d.ts.map +1 -0
  361. package/dist/runtime/taskClock.js +102 -0
  362. package/dist/runtime/taskClockProcess.d.ts +17 -0
  363. package/dist/runtime/taskClockProcess.d.ts.map +1 -0
  364. package/dist/runtime/taskClockProcess.js +58 -0
  365. package/dist/runtime/toolResultSpill.d.ts +152 -0
  366. package/dist/runtime/toolResultSpill.d.ts.map +1 -0
  367. package/dist/runtime/toolResultSpill.js +351 -0
  368. package/dist/runtime/turnRequestLedger.d.ts +155 -0
  369. package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
  370. package/dist/runtime/turnRequestLedger.js +251 -0
  371. package/dist/runtime/turnUsageLedger.d.ts +143 -0
  372. package/dist/runtime/turnUsageLedger.d.ts.map +1 -0
  373. package/dist/runtime/turnUsageLedger.js +203 -0
  374. package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts +34 -0
  375. package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts.map +1 -0
  376. package/dist/runtime/wakeAcceptanceClaimDiagnostics.js +79 -0
  377. package/dist/runtime/wakeAcceptanceIndex.d.ts +55 -0
  378. package/dist/runtime/wakeAcceptanceIndex.d.ts.map +1 -0
  379. package/dist/runtime/wakeAcceptanceIndex.js +158 -0
  380. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +25 -0
  381. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
  382. package/dist/runtime/wakeAcceptanceProcessIdentity.js +54 -0
  383. package/dist/runtime/wakeAcceptanceReconciliation.d.ts +211 -0
  384. package/dist/runtime/wakeAcceptanceReconciliation.d.ts.map +1 -0
  385. package/dist/runtime/wakeAcceptanceReconciliation.js +289 -0
  386. package/dist/runtime/wakeAcceptanceRecord.d.ts +25 -0
  387. package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
  388. package/dist/runtime/wakeAcceptanceRecord.js +58 -0
  389. package/dist/runtime/wakeAcceptanceRetention.d.ts +36 -0
  390. package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
  391. package/dist/runtime/wakeAcceptanceRetention.js +38 -0
  392. package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
  393. package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
  394. package/dist/runtime/wakeAcceptanceStore.js +561 -0
  395. package/dist/runtime/wakeAcceptanceTypes.d.ts +179 -0
  396. package/dist/runtime/wakeAcceptanceTypes.d.ts.map +1 -0
  397. package/dist/runtime/wakeAcceptanceTypes.js +95 -0
  398. package/dist/runtime/wakeFuse.d.ts +124 -0
  399. package/dist/runtime/wakeFuse.d.ts.map +1 -0
  400. package/dist/runtime/wakeFuse.js +466 -0
  401. package/dist/runtime/wakeMomentFs.d.ts +27 -0
  402. package/dist/runtime/wakeMomentFs.d.ts.map +1 -0
  403. package/dist/runtime/wakeMomentFs.js +223 -0
  404. package/dist/runtime/wakeMomentHistory.d.ts +26 -0
  405. package/dist/runtime/wakeMomentHistory.d.ts.map +1 -0
  406. package/dist/runtime/wakeMomentHistory.js +109 -0
  407. package/dist/runtime/wakeMomentIo.d.ts +22 -0
  408. package/dist/runtime/wakeMomentIo.d.ts.map +1 -0
  409. package/dist/runtime/wakeMomentIo.js +114 -0
  410. package/dist/runtime/wakeMomentRecorder.d.ts +33 -0
  411. package/dist/runtime/wakeMomentRecorder.d.ts.map +1 -0
  412. package/dist/runtime/wakeMomentRecorder.js +81 -0
  413. package/dist/runtime/wakeMomentRetention.d.ts +7 -0
  414. package/dist/runtime/wakeMomentRetention.d.ts.map +1 -0
  415. package/dist/runtime/wakeMomentRetention.js +143 -0
  416. package/dist/runtime/wakeMomentRows.d.ts +8 -0
  417. package/dist/runtime/wakeMomentRows.d.ts.map +1 -0
  418. package/dist/runtime/wakeMomentRows.js +66 -0
  419. package/dist/runtime/wakeMomentSnapshot.d.ts +56 -0
  420. package/dist/runtime/wakeMomentSnapshot.d.ts.map +1 -0
  421. package/dist/runtime/wakeMomentSnapshot.js +248 -0
  422. package/package.json +22 -11
@@ -0,0 +1,51 @@
1
+ import { GROK_ENGINE_BROKER } from "../contracts/runtimeContractManifest.js";
2
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
+ const tokenCount = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
4
+ const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9-]{0,63}$/u;
5
+ const MODEL_KEY = /^[a-z0-9][a-z0-9.-]{0,63}$/u;
6
+ const decodeUsage = (usage) => {
7
+ if (!isRecord(usage))
8
+ return undefined;
9
+ const input = tokenCount(usage.input_tokens), output = tokenCount(usage.output_tokens), cacheRead = tokenCount(usage.cache_read_input_tokens), cacheWrite = tokenCount(usage.cache_creation_input_tokens);
10
+ if (input === undefined || output === undefined || cacheRead === undefined || cacheWrite === undefined)
11
+ return undefined;
12
+ const total = input + cacheRead + cacheWrite + output;
13
+ // Beyond the model context window one request cannot have spent it: invalid, like a malformed block.
14
+ if (total > GROK_ENGINE_BROKER.turnLimits.requestUsageMaxTokens)
15
+ return undefined;
16
+ return { input, cacheRead, cacheWrite, output, total };
17
+ };
18
+ export const decodeGrokStreamUsage = (output) => {
19
+ const byMessage = new Map();
20
+ const reportedModels = new Set();
21
+ let sessionId, corrupt = false;
22
+ for (const line of output.split(/\r?\n/u)) {
23
+ if (line.trim().length === 0)
24
+ continue;
25
+ let event;
26
+ try {
27
+ event = JSON.parse(line);
28
+ }
29
+ catch {
30
+ continue;
31
+ }
32
+ if (!isRecord(event))
33
+ continue;
34
+ if (typeof event.session_id === "string" && SESSION_ID.test(event.session_id))
35
+ sessionId ??= event.session_id;
36
+ if (event.type === "result" && isRecord(event.modelUsage))
37
+ for (const key of Object.keys(event.modelUsage))
38
+ reportedModels.add(MODEL_KEY.test(key) ? key : "invalid");
39
+ if (event.type !== "assistant" || event.parent_tool_use_id !== null || !isRecord(event.message) || event.message.usage === undefined)
40
+ continue;
41
+ const decoded = decodeUsage(event.message.usage);
42
+ if (decoded === undefined || typeof event.message.id !== "string") {
43
+ corrupt = true;
44
+ continue;
45
+ }
46
+ // One request can surface as more than one frame of the same message; it is one request.
47
+ byMessage.set(event.message.id, decoded);
48
+ }
49
+ const requests = corrupt ? [] : [...byMessage.values()].map((usage, index) => Object.freeze({ index, ...usage }));
50
+ return { requests, ...(sessionId === undefined ? {} : { sessionId }), reportedModels: [...reportedModels].sort() };
51
+ };
@@ -0,0 +1,25 @@
1
+ import * as mneme from "@noopolis/mneme";
2
+ import { type TaskClock } from "../runtime/taskClock.js";
3
+ type MnemeClockModule = {
4
+ readonly createOffsetClock?: unknown;
5
+ };
6
+ type MemoryConfig = Parameters<typeof mneme.createMemoryRuntime>[0];
7
+ type MemoryModule = MnemeClockModule & {
8
+ createMemoryRuntime(config: MemoryConfig & {
9
+ clock?: () => number;
10
+ }): ReturnType<typeof mneme.createMemoryRuntime>;
11
+ };
12
+ /** Keep construction and capability detection together while the published types catch up. */
13
+ export declare function createClockedMemoryRuntime(config: MemoryConfig, clock?: Readonly<{
14
+ raw: string;
15
+ origin: string;
16
+ anchorEpochMs: number;
17
+ at(realEpochMs: number): number;
18
+ now(): number;
19
+ }> | undefined, moduleRoot?: MemoryModule): mneme.MemoryRuntime;
20
+ /** The root export is Mneme's capability signal, including across older published versions. */
21
+ export declare function memoryClockOptions(clock?: TaskClock | undefined, moduleRoot?: MnemeClockModule): {
22
+ clock?: () => number;
23
+ };
24
+ export {};
25
+ //# sourceMappingURL=memoryClock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryClock.d.ts","sourceRoot":"","sources":["../../src/pi/memoryClock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAExE,KAAK,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjE,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,KAAK,YAAY,GAAG,gBAAgB,GAAG;IAAE,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,MAAM,CAAA;KAAE,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAA;CAAE,CAAC;AAE9J,8FAA8F;AAC9F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK;;;;;;cAAkB,EAAE,UAAU,GAAE,YAAoB,uBAEzH;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAChC,KAAK,GAAE,SAAS,GAAG,SAA2B,EAC9C,UAAU,GAAE,gBAA4C,GACvD;IAAE,KAAK,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,CAQ1B"}
@@ -0,0 +1,18 @@
1
+ import * as mneme from "@noopolis/mneme";
2
+ import { readTaskClock } from "../runtime/taskClock.js";
3
+ /** Keep construction and capability detection together while the published types catch up. */
4
+ export function createClockedMemoryRuntime(config, clock = readTaskClock(), moduleRoot = mneme) {
5
+ return moduleRoot.createMemoryRuntime({ ...config, ...memoryClockOptions(clock, moduleRoot) });
6
+ }
7
+ /** The root export is Mneme's capability signal, including across older published versions. */
8
+ export function memoryClockOptions(clock = readTaskClock(), moduleRoot = mneme) {
9
+ if (clock === undefined)
10
+ return {};
11
+ if (typeof moduleRoot.createOffsetClock !== "function") {
12
+ throw new Error("NOOPOLIS_TASK_CLOCK requires @noopolis/mneme with the root createOffsetClock export and createMemoryRuntime({ clock }) support");
13
+ }
14
+ const memoryClock = moduleRoot.createOffsetClock({ origin: clock.origin, anchorMs: clock.anchorEpochMs });
15
+ if (typeof memoryClock !== "function")
16
+ throw new Error("@noopolis/mneme createOffsetClock must return an epoch-ms clock function");
17
+ return { clock: memoryClock };
18
+ }
@@ -6,7 +6,7 @@ import { persistPiTurnTrace, type PiTurnTraceModel } from "./turnTrace.js";
6
6
  import { type PiRawTrainingCaptureOptions, type PiRawTrainingCaptureRef } from "./rawTrainingCapture.js";
7
7
  import { type PiWorldToolContextRef } from "./worldNudge.js";
8
8
  import { type PiWorldTrajectoryIdentity } from "./worldTrajectory.js";
9
- import { type PiNativeSessionCreator, type PiSession, type PiSessionCreator, type PiSessionLike } from "./piAgentWakeSupport.js";
9
+ import type { PiNativeSessionCreator, PiSession, PiSessionCreator, PiSessionLike, PiWakeEnvironmentContextRef } from "./piAgentWakeSupport.js";
10
10
  import { type MemoryRuntime } from "@noopolis/mneme";
11
11
  export type { PiSession, PiSessionLike, PiSessionCreator, PiNativeSessionCreator } from "./piAgentWakeSupport.js";
12
12
  export type WakeAcceptanceInput = {
@@ -14,6 +14,7 @@ export type WakeAcceptanceInput = {
14
14
  completeTurn?: typeof stampTurnOutputCompleted;
15
15
  traceTurn?: typeof persistPiTurnTrace;
16
16
  createWakeAcceptance?: (runtimeHomePath: string, agentId: string) => WakeAcceptanceStoreLike;
17
+ causalRunId?: string;
17
18
  };
18
19
  export declare class PiAgentHandle implements AgentHandle {
19
20
  readonly id: string;
@@ -28,6 +29,7 @@ export declare class PiAgentHandle implements AgentHandle {
28
29
  private readonly rawTrainingCaptureOptions?;
29
30
  private readonly worldTrajectoryIdentity?;
30
31
  private readonly piSessionForRawCapture?;
32
+ private readonly wakeEnvironmentContext?;
31
33
  private state;
32
34
  private lastWakeAt;
33
35
  private lastError;
@@ -35,8 +37,9 @@ export declare class PiAgentHandle implements AgentHandle {
35
37
  private readonly stampTurnInputSubmitted;
36
38
  private readonly stampTurnOutputCompleted;
37
39
  private readonly persistTrace;
38
- constructor(id: string, session: PiSession, createSession: PiNativeSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: PiRawTrainingCaptureRef, rawTrainingCaptureOptions?: PiRawTrainingCaptureOptions, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: PiSession);
39
- constructor(id: string, session: PiSessionLike, createSession: PiSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: never, rawTrainingCaptureOptions?: never, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: never);
40
+ private readonly causalRunId?;
41
+ constructor(id: string, session: PiSession, createSession: PiNativeSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: PiRawTrainingCaptureRef, rawTrainingCaptureOptions?: PiRawTrainingCaptureOptions, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: PiSession, wakeEnvironmentContext?: PiWakeEnvironmentContextRef);
42
+ constructor(id: string, session: PiSessionLike, createSession: PiSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: never, rawTrainingCaptureOptions?: never, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: never, wakeEnvironmentContext?: PiWakeEnvironmentContextRef);
40
43
  wake(event: WakeEvent): Promise<WakeResult>;
41
44
  private runWake;
42
45
  status(): AgentStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"piAg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memoryTools.js";
2
- import { formatWakePrompt } from "./prompts.js";
2
+ import { formatWakePrompt, preserveModelFacingWakeIdentity } from "./prompts.js";
3
3
  import { stampTurnInputSubmitted, stampTurnOutputCompleted } from "./turnCausal.js";
4
4
  import { WakeAcceptanceStore } from "./wakeAcceptance.js";
5
5
  import { persistPiTurnTrace } from "./turnTrace.js";
@@ -7,7 +7,7 @@ import { formatDreamPrompt } from "./wakeModes.js";
7
7
  import { createPiRawTrainingCapture } from "./rawTrainingCapture.js";
8
8
  import { formatWorldWakePrompt, worldWakeContext } from "./worldNudge.js";
9
9
  import { createPiWorldTrajectoryCapture } from "./worldTrajectory.js";
10
- import { cloneWakeEvent, persistPiTurnArtifacts, PiWakeDeliveryQueue, selectPiSessionForWake, subscribeToPiTurnEvents } from "./piAgentWakeSupport.js";
10
+ import { cloneWakeEvent, disposePiSession, persistPiTurnArtifacts, PiWakeDeliveryQueue, selectPiSessionForWake, subscribeToPiTurnEvents } from "./piAgentWakeSupport.js";
11
11
  import { readMemoryContext } from "@noopolis/mneme";
12
12
  export class PiAgentHandle {
13
13
  id;
@@ -22,6 +22,7 @@ export class PiAgentHandle {
22
22
  rawTrainingCaptureOptions;
23
23
  worldTrajectoryIdentity;
24
24
  piSessionForRawCapture;
25
+ wakeEnvironmentContext;
25
26
  state = "idle";
26
27
  lastWakeAt;
27
28
  lastError;
@@ -29,7 +30,8 @@ export class PiAgentHandle {
29
30
  stampTurnInputSubmitted;
30
31
  stampTurnOutputCompleted;
31
32
  persistTrace;
32
- constructor(id, session, createSession, runtimeHomePath, traceModel, memory, memoryToolContext, dependencies = {}, worldToolContext, rawTrainingCaptureRef, rawTrainingCaptureOptions, worldTrajectoryIdentity, piSessionForRawCapture) {
33
+ causalRunId;
34
+ constructor(id, session, createSession, runtimeHomePath, traceModel, memory, memoryToolContext, dependencies = {}, worldToolContext, rawTrainingCaptureRef, rawTrainingCaptureOptions, worldTrajectoryIdentity, piSessionForRawCapture, wakeEnvironmentContext) {
33
35
  this.id = id;
34
36
  this.session = session;
35
37
  this.createSession = createSession;
@@ -42,11 +44,12 @@ export class PiAgentHandle {
42
44
  this.rawTrainingCaptureOptions = rawTrainingCaptureOptions;
43
45
  this.worldTrajectoryIdentity = worldTrajectoryIdentity;
44
46
  this.piSessionForRawCapture = piSessionForRawCapture;
47
+ this.wakeEnvironmentContext = wakeEnvironmentContext;
45
48
  this.stampTurnInputSubmitted = dependencies.runWake ?? stampTurnInputSubmitted;
46
49
  this.stampTurnOutputCompleted = dependencies.completeTurn ?? stampTurnOutputCompleted;
47
50
  this.persistTrace = dependencies.traceTurn ?? persistPiTurnTrace;
48
- const wakeAcceptance = dependencies.createWakeAcceptance?.(runtimeHomePath, id) ??
49
- new WakeAcceptanceStore(runtimeHomePath, id);
51
+ this.causalRunId = dependencies.causalRunId;
52
+ const wakeAcceptance = dependencies.createWakeAcceptance?.(runtimeHomePath, id) ?? new WakeAcceptanceStore(runtimeHomePath, id, undefined, this.causalRunId);
50
53
  this.wakeDeliveryQueue = new PiWakeDeliveryQueue(id, wakeAcceptance);
51
54
  }
52
55
  async wake(event) {
@@ -88,7 +91,7 @@ export class PiAgentHandle {
88
91
  ? undefined
89
92
  : createPiWorldTrajectoryCapture();
90
93
  const request = {
91
- eventId: event.id,
94
+ eventId: /^(simfile|moltnet|mneme|daimon):.+$/u.test(event.id) ? event.id : `daimon:${event.id}`,
92
95
  kind: event.kind,
93
96
  text: safeWakeText,
94
97
  from: event.from,
@@ -98,6 +101,10 @@ export class PiAgentHandle {
98
101
  ? formatWakePrompt(event)
99
102
  : safeWakeText;
100
103
  try {
104
+ if (this.wakeEnvironmentContext !== undefined) {
105
+ this.wakeEnvironmentContext.current = event.id;
106
+ this.wakeEnvironmentContext.spokeFor = undefined;
107
+ }
101
108
  if (this.worldToolContext !== undefined) {
102
109
  this.worldToolContext.current = worldContext;
103
110
  }
@@ -139,7 +146,7 @@ export class PiAgentHandle {
139
146
  prepared,
140
147
  status: "completed"
141
148
  };
142
- promptText = prepared.promptText;
149
+ promptText = preserveModelFacingWakeIdentity(prepared.promptText, event, request.eventId);
143
150
  if (this.memoryToolContext !== undefined) {
144
151
  this.memoryToolContext.observeTool = (toolEvent) => tools.push(toolEvent);
145
152
  this.memoryToolContext.current = createTrustedPiMemoryToolContext({
@@ -157,6 +164,7 @@ export class PiAgentHandle {
157
164
  }
158
165
  stage = "causal_input";
159
166
  const turnInput = await this.stampTurnInputSubmitted({
167
+ runId: this.causalRunId,
160
168
  agentId: this.id,
161
169
  event,
162
170
  prepared,
@@ -169,18 +177,24 @@ export class PiAgentHandle {
169
177
  }
170
178
  stage = "engine_prompt";
171
179
  const engineStartedAt = Date.now();
180
+ selectedSession.session.bindWake?.(event);
172
181
  await selectedSession.session.prompt(promptText, { expandPromptTemplates: false });
173
182
  enginePromptMs = Date.now() - engineStartedAt;
174
183
  this.state = "idle";
175
184
  const outputText = chunks.join("\n").trim();
176
185
  stage = "causal_output";
177
186
  await this.stampTurnOutputCompleted({
187
+ runId: this.causalRunId,
178
188
  agentId: this.id,
179
189
  causeEventId: turnInput.event_id,
180
190
  outputText,
181
191
  runtimeHomePath: this.runtimeHomePath,
182
192
  turnId: event.id
183
193
  });
194
+ if (this.memory !== undefined && prepared !== undefined) {
195
+ await this.memory.recordTurn({ principal: prepared.principal, prompt: prepared.packet, request, recall: prepared.recall, result: "completed", outputText, toolEvents: tools })
196
+ .catch((recordError) => { this.lastError = `memory record failed: ${recordError instanceof Error ? recordError.message : String(recordError)}`; });
197
+ }
184
198
  await this.persistTrace({
185
199
  agentId: this.id,
186
200
  enginePromptMs,
@@ -203,9 +217,6 @@ export class PiAgentHandle {
203
217
  if (rawTrainingCapture !== undefined
204
218
  && this.rawTrainingCaptureOptions !== undefined
205
219
  && this.piSessionForRawCapture !== undefined) {
206
- // Do not retry a partially failed private capture in the catch path.
207
- // The first failure is authoritative and retrying the same immutable
208
- // turn path would only mask it with an EEXIST/partial-write error.
209
220
  rawTrainingCapturePersistAttempted = true;
210
221
  }
211
222
  await persistPiTurnArtifacts({
@@ -225,9 +236,18 @@ export class PiAgentHandle {
225
236
  worldTrajectory,
226
237
  worldTrajectoryIdentity: this.worldTrajectoryIdentity
227
238
  });
239
+ // An agent with a mounted `moltnet_send` tool has exactly one
240
+ // legitimate publication channel; its terminal text is always a
241
+ // private note to the runtime — whether it spoke, stayed silent, or
242
+ // narrated a failure back as its reply — never the bridge's
243
+ // terminal-text fallback (moltnet/internal/bridge/daimon/
244
+ // receipt_tracker.go), which is reserved for agents with no send tool
245
+ // at all. `outputText` itself stays intact for the turn trace and
246
+ // memory record above.
247
+ const hasSendCapability = this.wakeEnvironmentContext?.hasSendCapability === true;
228
248
  return {
229
249
  agentId: this.id,
230
- text: outputText,
250
+ text: hasSendCapability ? "" : outputText,
231
251
  durationMs: Date.now() - startedAtMs
232
252
  };
233
253
  }
@@ -264,6 +284,9 @@ export class PiAgentHandle {
264
284
  ? {}
265
285
  : { worldContextBound: worldContext !== undefined })
266
286
  }).catch(() => undefined);
287
+ if (this.memory !== undefined && prepared !== undefined) {
288
+ await this.memory.recordTurn({ principal: prepared.principal, prompt: prepared.packet, request, recall: prepared.recall, result: "failed", error: message, outputText: chunks.join("\n").trim(), toolEvents: tools }).catch(() => undefined);
289
+ }
267
290
  const persistRawCapture = !rawTrainingCapturePersistAttempted
268
291
  && selectedSession !== undefined;
269
292
  if (persistRawCapture && rawTrainingCapture !== undefined) {
@@ -293,6 +316,11 @@ export class PiAgentHandle {
293
316
  throw error;
294
317
  }
295
318
  finally {
319
+ selectedSession?.session.bindWake?.();
320
+ if (this.wakeEnvironmentContext !== undefined) {
321
+ this.wakeEnvironmentContext.current = undefined;
322
+ this.wakeEnvironmentContext.spokeFor = undefined;
323
+ }
296
324
  if (this.memoryToolContext !== undefined) {
297
325
  this.memoryToolContext.current = undefined;
298
326
  this.memoryToolContext.observeTool = undefined;
@@ -318,7 +346,9 @@ export class PiAgentHandle {
318
346
  };
319
347
  }
320
348
  async stop() {
321
- this.session.dispose();
349
+ // CLI-backed sessions may own a process group, while native Pi remains
350
+ // source-compatible through the synchronous dispose() hook.
351
+ await disposePiSession(this.session);
322
352
  this.state = "stopped";
323
353
  }
324
354
  }
@@ -10,8 +10,43 @@ export type PiSession = Awaited<ReturnType<typeof createAgentSession>>["session"
10
10
  export interface PiSessionLike {
11
11
  subscribe(listener: Parameters<PiSession["subscribe"]>[0]): () => void;
12
12
  prompt(text: string, options?: Parameters<PiSession["prompt"]>[1]): Promise<void>;
13
+ /** Optional per-turn context for isolated CLI child environments. */
14
+ bindWake?(event?: WakeEvent): void;
15
+ /** Kept synchronous for existing Pi session implementations. */
13
16
  dispose(): void;
17
+ /** Optional additive hook for sessions that must asynchronously quiesce children. */
18
+ disposeAsync?(): Promise<void>;
14
19
  }
20
+ export type PiWakeEnvironmentContextRef = {
21
+ current?: string;
22
+ /**
23
+ * Set to the delivery id of the current wake once `moltnet_send` has been
24
+ * accepted during it. Bookkeeping only: it no longer gates whether the wake
25
+ * completion path publishes terminal text (see `hasSendCapability`), but it
26
+ * still records, per wake, whether this agent actually spoke. Never a
27
+ * boolean: a boolean could survive a stale reset and silently misattribute
28
+ * a later wake.
29
+ */
30
+ spokeFor?: string;
31
+ /**
32
+ * Set once per agent, at harness construction, to whether a `moltnet_send`
33
+ * tool is mounted for it (`piHarness.ts`, from `productionTools`) — never
34
+ * reset per wake, unlike `current`/`spokeFor`.
35
+ *
36
+ * A turn that fails partway (a tool error the model narrates back as
37
+ * terminal text, e.g. "Blocked: Moltnet auth is not mounted...") still
38
+ * completes structurally and used to publish that narration through the
39
+ * terminal-text fallback even though `moltnet_send` was never actually
40
+ * called — a second, unintended echo into the room. An agent with a
41
+ * mounted send tool has exactly one legitimate publication channel
42
+ * (`moltnet_send`); its terminal text is always a private note to the
43
+ * runtime, whether it spoke, stayed silent, or failed. Only an agent with
44
+ * no send tool at all keeps the documented terminal-text fallback
45
+ * (`moltnet/internal/bridge/daimon/AGENTS.md`).
46
+ */
47
+ hasSendCapability?: boolean;
48
+ };
49
+ export declare function disposePiSession(session: PiSessionLike): Promise<void>;
15
50
  export type PiSessionCreator = (mode: MemoryWakeMode, sessionDirectory: string) => Promise<PiSessionLike>;
16
51
  export type PiNativeSessionCreator = (mode: MemoryWakeMode, sessionDirectory: string) => Promise<PiSession>;
17
52
  export interface WakeSessionSelection {
@@ -1 +1 @@
1
- {"version":3,"file":"piAgentWakeSupport.d.ts","sourceRoot":"","sources":["../../src/pi/piAgentWakeSupport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAClF,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;IACvE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,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AC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;CACxB,KAAG,OAAO,CAAC,oBAAoB,CAmB/B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO;IAC7C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,wBAAwB,CAAC;CAC5C,KAAG,CAAC,MAAM,IAAI,CAkBd,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAU,OAAO;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,sBAAsB,CAAC,EAAE,SAAS,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C,yBAAyB,CAAC,EAAE,2BAA2B,CAAC;IACxD,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,uBAAuB,CAAC,EAAE,yBAAyB,CAAC;CACrD,KAAG,OAAO,CAAC,IAAI,CAqCf,CAAC"}
@@ -3,6 +3,10 @@ import { summarizeSessionEvent, } from "./turnTrace.js";
3
3
  import { createAwakeThreadId, createDreamSessionDirectory, createDreamSessionKey, createDreamThreadId, } from "./wakeModes.js";
4
4
  import { WakeAcceptanceError, } from "./wakeAcceptance.js";
5
5
  import { capturePiWorldTrajectoryEvent, persistPiWorldTrajectory, } from "./worldTrajectory.js";
6
+ export async function disposePiSession(session) {
7
+ await Promise.resolve(session.dispose());
8
+ await session.disposeAsync?.();
9
+ }
6
10
  export class PiWakeDeliveryQueue {
7
11
  agentId;
8
12
  acceptance;
@@ -1,8 +1,10 @@
1
- import { createAgentSession } from "@earendil-works/pi-coding-agent";
2
- import { type MemoryAuthorityConfig } from "@noopolis/mneme";
1
+ import { createAgentSession, type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+ import type { MemoryAuthorityConfig } from "@noopolis/mneme";
3
3
  import type { AgentHandle, AgentHarnessAdapter, AgentStartInput, HarnessModelSpec } from "../core/types.js";
4
4
  import { type PiSessionLike } from "./piAgentHandle.js";
5
+ import { type PiWakeEnvironmentContextRef } from "./piAgentWakeSupport.js";
5
6
  import { type PiWorldBinding } from "./worldTools.js";
7
+ import { type TaskClockProcessProbe } from "./taskClockProcess.js";
6
8
  import { type PiRawTrainingCaptureOptions } from "./rawTrainingCapture.js";
7
9
  type HarnessMemoryEmbeddingProvider = {
8
10
  dimensions?: number;
@@ -18,6 +20,8 @@ type PiHarnessBaseOptions = {
18
20
  name: string;
19
21
  };
20
22
  modelsPath?: string;
23
+ /** Host-only names removed from every engine and Pi bash child environment. */
24
+ protectedEnvironmentNames?: readonly string[];
21
25
  memory?: {
22
26
  authority?: MemoryAuthorityConfig;
23
27
  embeddingProvider?: HarnessMemoryEmbeddingProvider;
@@ -27,6 +31,10 @@ type PiHarnessBaseOptions = {
27
31
  };
28
32
  thinkingLevel?: PiThinkingLevel;
29
33
  world?: PiWorldBinding;
34
+ productionTools?: readonly ToolDefinition[];
35
+ /** Engine-owned default; an empty list disables Pi builtins for confined CLI engines. */
36
+ toolNames?: readonly string[];
37
+ wakeEnvironmentContext?: PiWakeEnvironmentContextRef;
30
38
  };
31
39
  export type PiHarnessOptions = PiHarnessBaseOptions & ({
32
40
  rawTrainingCapture?: PiRawTrainingCaptureOptions;
@@ -37,16 +45,23 @@ export type PiHarnessOptions = PiHarnessBaseOptions & ({
37
45
  });
38
46
  export type PiSessionFactoryInput = Exclude<Parameters<typeof createAgentSession>[0], undefined> & {
39
47
  daimonSecretEnvironmentNames?: readonly string[];
48
+ /** The isolated runtime home assigned by Daimon to this one agent. */
49
+ runtimeHomePath?: string;
40
50
  };
41
51
  export type PiSessionFactory = (input: PiSessionFactoryInput) => Promise<{
42
52
  session: PiSessionLike;
43
53
  }>;
44
54
  export declare class PiHarnessAdapter implements AgentHarnessAdapter {
45
55
  private readonly options;
56
+ private readonly taskClockProbe?;
57
+ static readonly capabilities: Readonly<{
58
+ causalRunId: true;
59
+ memoryCausalRunId: false;
60
+ }>;
46
61
  private readonly authStorage;
47
62
  private readonly modelRegistry;
48
63
  private readonly sessionFactory;
49
- constructor(options: PiHarnessOptions);
64
+ constructor(options: PiHarnessOptions, /** @internal */ taskClockProbe?: TaskClockProcessProbe | undefined);
50
65
  startAgent(input: AgentStartInput): Promise<AgentHandle>;
51
66
  }
52
67
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"piHarness.d.ts","sourceRoot":"","sources":["../../src/pi/piHarness.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,kBAAkB,EAInB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAElF,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAM5G,OAAO,EAAqE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3H,OAAO,EAAwC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAGL,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAC;AAEjC,KAAK,8BAA8B,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,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