@noopolis/daimon 0.1.2 → 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.
Files changed (330) hide show
  1. package/README.md +269 -51
  2. package/dist/contracts/attentionContract.d.ts +117 -0
  3. package/dist/contracts/attentionContract.d.ts.map +1 -0
  4. package/dist/contracts/attentionContract.js +14 -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/grokWorkerContract.d.ts +74 -0
  9. package/dist/contracts/grokWorkerContract.d.ts.map +1 -0
  10. package/dist/contracts/grokWorkerContract.js +88 -0
  11. package/dist/contracts/organizationRuntimeContract.d.ts +765 -0
  12. package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
  13. package/dist/contracts/organizationRuntimeContract.js +121 -0
  14. package/dist/contracts/runtimeContractManifest.d.ts +1615 -0
  15. package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
  16. package/dist/contracts/runtimeContractManifest.js +181 -0
  17. package/dist/core/credentialRedaction.d.ts +4 -0
  18. package/dist/core/credentialRedaction.d.ts.map +1 -0
  19. package/dist/core/credentialRedaction.js +28 -0
  20. package/dist/mcp/toolServer.d.ts +19 -2
  21. package/dist/mcp/toolServer.d.ts.map +1 -1
  22. package/dist/mcp/toolServer.js +57 -17
  23. package/dist/observability/causalEvents.d.ts +3 -3
  24. package/dist/observability/causalEvents.d.ts.map +1 -1
  25. package/dist/observability/causalEvents.js +103 -15
  26. package/dist/observability/orgObserver.d.ts.map +1 -1
  27. package/dist/observability/orgObserver.js +3 -3
  28. package/dist/pi/agyHeadlessResult.d.ts +60 -0
  29. package/dist/pi/agyHeadlessResult.d.ts.map +1 -0
  30. package/dist/pi/agyHeadlessResult.js +95 -0
  31. package/dist/pi/cliChildOutput.d.ts +67 -0
  32. package/dist/pi/cliChildOutput.d.ts.map +1 -0
  33. package/dist/pi/cliChildOutput.js +269 -0
  34. package/dist/pi/cliEngineRun.d.ts +16 -0
  35. package/dist/pi/cliEngineRun.d.ts.map +1 -0
  36. package/dist/pi/cliEngineRun.js +27 -0
  37. package/dist/pi/cliEngineSpawn.d.ts +55 -0
  38. package/dist/pi/cliEngineSpawn.d.ts.map +1 -0
  39. package/dist/pi/cliEngineSpawn.js +164 -0
  40. package/dist/pi/cliEnvironment.d.ts +12 -0
  41. package/dist/pi/cliEnvironment.d.ts.map +1 -0
  42. package/dist/pi/cliEnvironment.js +32 -0
  43. package/dist/pi/cliMcpRegistration.d.ts +61 -0
  44. package/dist/pi/cliMcpRegistration.d.ts.map +1 -0
  45. package/dist/pi/cliMcpRegistration.js +75 -0
  46. package/dist/pi/cliProcess.d.ts +7 -0
  47. package/dist/pi/cliProcess.d.ts.map +1 -0
  48. package/dist/pi/cliProcess.js +132 -0
  49. package/dist/pi/cliSession.d.ts +84 -24
  50. package/dist/pi/cliSession.d.ts.map +1 -1
  51. package/dist/pi/cliSession.js +313 -158
  52. package/dist/pi/cliTurnMetering.d.ts +60 -0
  53. package/dist/pi/cliTurnMetering.d.ts.map +1 -0
  54. package/dist/pi/cliTurnMetering.js +60 -0
  55. package/dist/pi/codexFilesystemRules.d.ts +3 -0
  56. package/dist/pi/codexFilesystemRules.d.ts.map +1 -0
  57. package/dist/pi/codexFilesystemRules.js +28 -0
  58. package/dist/pi/codexHeadlessResult.d.ts +68 -0
  59. package/dist/pi/codexHeadlessResult.d.ts.map +1 -0
  60. package/dist/pi/codexHeadlessResult.js +122 -0
  61. package/dist/pi/codexRolloutUsage.d.ts +95 -0
  62. package/dist/pi/codexRolloutUsage.d.ts.map +1 -0
  63. package/dist/pi/codexRolloutUsage.js +221 -0
  64. package/dist/pi/engineWakeLimits.d.ts +39 -0
  65. package/dist/pi/engineWakeLimits.d.ts.map +1 -0
  66. package/dist/pi/engineWakeLimits.js +55 -0
  67. package/dist/pi/grokHeadlessResult.d.ts +36 -0
  68. package/dist/pi/grokHeadlessResult.d.ts.map +1 -0
  69. package/dist/pi/grokHeadlessResult.js +118 -0
  70. package/dist/pi/grokHomeMcpRegistration.d.ts +21 -0
  71. package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -0
  72. package/dist/pi/grokHomeMcpRegistration.js +57 -0
  73. package/dist/pi/grokSandbox.d.ts +11 -0
  74. package/dist/pi/grokSandbox.d.ts.map +1 -0
  75. package/dist/pi/grokSandbox.js +216 -0
  76. package/dist/pi/grokStreamUsage.d.ts +31 -0
  77. package/dist/pi/grokStreamUsage.d.ts.map +1 -0
  78. package/dist/pi/grokStreamUsage.js +51 -0
  79. package/dist/pi/piAgentHandle.d.ts +4 -3
  80. package/dist/pi/piAgentHandle.d.ts.map +1 -1
  81. package/dist/pi/piAgentHandle.js +37 -10
  82. package/dist/pi/piAgentWakeSupport.d.ts +35 -0
  83. package/dist/pi/piAgentWakeSupport.d.ts.map +1 -1
  84. package/dist/pi/piAgentWakeSupport.js +4 -0
  85. package/dist/pi/piHarness.d.ts +10 -1
  86. package/dist/pi/piHarness.d.ts.map +1 -1
  87. package/dist/pi/piHarness.js +61 -8
  88. package/dist/pi/prompts.d.ts +1 -0
  89. package/dist/pi/prompts.d.ts.map +1 -1
  90. package/dist/pi/prompts.js +24 -0
  91. package/dist/pi/turnTrace.d.ts.map +1 -1
  92. package/dist/pi/turnTrace.js +5 -8
  93. package/dist/pi/worldTrajectory.d.ts +1 -1
  94. package/dist/pi/worldTrajectory.d.ts.map +1 -1
  95. package/dist/pi/worldTrajectory.js +3 -3
  96. package/dist/runtime/agySubscriptionBootstrap.d.ts +16 -0
  97. package/dist/runtime/agySubscriptionBootstrap.d.ts.map +1 -0
  98. package/dist/runtime/agySubscriptionBootstrap.js +80 -0
  99. package/dist/runtime/agySubscriptionRealm.d.ts +38 -0
  100. package/dist/runtime/agySubscriptionRealm.d.ts.map +1 -0
  101. package/dist/runtime/agySubscriptionRealm.js +242 -0
  102. package/dist/runtime/attention.d.ts +21 -0
  103. package/dist/runtime/attention.d.ts.map +1 -0
  104. package/dist/runtime/attention.js +36 -0
  105. package/dist/runtime/attentionDispatcher.d.ts +66 -0
  106. package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
  107. package/dist/runtime/attentionDispatcher.js +271 -0
  108. package/dist/runtime/cli.d.ts +7 -0
  109. package/dist/runtime/cli.d.ts.map +1 -0
  110. package/dist/runtime/cli.js +251 -0
  111. package/dist/runtime/codexSandboxProjection.d.ts +17 -0
  112. package/dist/runtime/codexSandboxProjection.d.ts.map +1 -0
  113. package/dist/runtime/codexSandboxProjection.js +40 -0
  114. package/dist/runtime/contract-manifest.json +1 -0
  115. package/dist/runtime/contract-manifest.sha256 +1 -0
  116. package/dist/runtime/contractManifest.d.ts +8 -0
  117. package/dist/runtime/contractManifest.d.ts.map +1 -0
  118. package/dist/runtime/contractManifest.js +4 -0
  119. package/dist/runtime/engineBrokerCapabilities.d.ts +30 -0
  120. package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
  121. package/dist/runtime/engineBrokerCapabilities.js +59 -0
  122. package/dist/runtime/engineBrokerControlClient.d.ts +44 -0
  123. package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
  124. package/dist/runtime/engineBrokerControlClient.js +132 -0
  125. package/dist/runtime/engineBrokerCredentialJournal.d.ts +10 -0
  126. package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
  127. package/dist/runtime/engineBrokerCredentialJournal.js +17 -0
  128. package/dist/runtime/engineBrokerInferenceProtocol.d.ts +52 -0
  129. package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
  130. package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
  131. package/dist/runtime/engineBrokerMcpCallLog.d.ts +160 -0
  132. package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
  133. package/dist/runtime/engineBrokerMcpCallLog.js +219 -0
  134. package/dist/runtime/engineBrokerMcpFacade.d.ts +56 -0
  135. package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
  136. package/dist/runtime/engineBrokerMcpFacade.js +343 -0
  137. package/dist/runtime/engineBrokerNativeClient.d.ts +52 -0
  138. package/dist/runtime/engineBrokerNativeClient.d.ts.map +1 -0
  139. package/dist/runtime/engineBrokerNativeClient.js +151 -0
  140. package/dist/runtime/engineBrokerProtocol.d.ts +135 -0
  141. package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
  142. package/dist/runtime/engineBrokerProtocol.js +274 -0
  143. package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
  144. package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
  145. package/dist/runtime/engineBrokerSealLedger.js +123 -0
  146. package/dist/runtime/engineBrokerService.d.ts +37 -0
  147. package/dist/runtime/engineBrokerService.d.ts.map +1 -0
  148. package/dist/runtime/engineBrokerService.js +138 -0
  149. package/dist/runtime/engineBrokerServiceCli.d.ts +5 -0
  150. package/dist/runtime/engineBrokerServiceCli.d.ts.map +1 -0
  151. package/dist/runtime/engineBrokerServiceCli.js +32 -0
  152. package/dist/runtime/engineBrokerServiceConfig.d.ts +50 -0
  153. package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
  154. package/dist/runtime/engineBrokerServiceConfig.js +92 -0
  155. package/dist/runtime/engineBrokerSingleflight.d.ts +13 -0
  156. package/dist/runtime/engineBrokerSingleflight.d.ts.map +1 -0
  157. package/dist/runtime/engineBrokerSingleflight.js +24 -0
  158. package/dist/runtime/engineBrokerTurnAccounting.d.ts +76 -0
  159. package/dist/runtime/engineBrokerTurnAccounting.d.ts.map +1 -0
  160. package/dist/runtime/engineBrokerTurnAccounting.js +108 -0
  161. package/dist/runtime/engineBrokerTurnRegistry.d.ts +57 -0
  162. package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -0
  163. package/dist/runtime/engineBrokerTurnRegistry.js +158 -0
  164. package/dist/runtime/engineDispatcher.d.ts +36 -0
  165. package/dist/runtime/engineDispatcher.d.ts.map +1 -0
  166. package/dist/runtime/engineDispatcher.js +216 -0
  167. package/dist/runtime/engineReadiness.d.ts +23 -0
  168. package/dist/runtime/engineReadiness.d.ts.map +1 -0
  169. package/dist/runtime/engineReadiness.js +222 -0
  170. package/dist/runtime/grokAuthenticationError.d.ts +8 -0
  171. package/dist/runtime/grokAuthenticationError.d.ts.map +1 -0
  172. package/dist/runtime/grokAuthenticationError.js +20 -0
  173. package/dist/runtime/grokBrokerCredentialAuthority.d.ts +22 -0
  174. package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
  175. package/dist/runtime/grokBrokerCredentialAuthority.js +124 -0
  176. package/dist/runtime/grokBrokerCredentialReader.d.ts +5 -0
  177. package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
  178. package/dist/runtime/grokBrokerCredentialReader.js +37 -0
  179. package/dist/runtime/grokBrokerModelPolicy.d.ts +23 -0
  180. package/dist/runtime/grokBrokerModelPolicy.d.ts.map +1 -0
  181. package/dist/runtime/grokBrokerModelPolicy.js +28 -0
  182. package/dist/runtime/grokBrokerProjection.d.ts +106 -0
  183. package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
  184. package/dist/runtime/grokBrokerProjection.js +94 -0
  185. package/dist/runtime/grokBrokerProxy.d.ts +55 -0
  186. package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
  187. package/dist/runtime/grokBrokerProxy.js +262 -0
  188. package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
  189. package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
  190. package/dist/runtime/grokBrokerProxyRequest.js +74 -0
  191. package/dist/runtime/grokBrokerRealmLease.d.ts +4 -0
  192. package/dist/runtime/grokBrokerRealmLease.d.ts.map +1 -0
  193. package/dist/runtime/grokBrokerRealmLease.js +33 -0
  194. package/dist/runtime/grokBrokerRefresh.d.ts +2 -0
  195. package/dist/runtime/grokBrokerRefresh.d.ts.map +1 -0
  196. package/dist/runtime/grokBrokerRefresh.js +15 -0
  197. package/dist/runtime/grokBrokerTurnMeter.d.ts +128 -0
  198. package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
  199. package/dist/runtime/grokBrokerTurnMeter.js +251 -0
  200. package/dist/runtime/grokBrokerWorkerConfig.d.ts +86 -0
  201. package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
  202. package/dist/runtime/grokBrokerWorkerConfig.js +135 -0
  203. package/dist/runtime/grokEngineBroker.d.ts +48 -0
  204. package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
  205. package/dist/runtime/grokEngineBroker.js +114 -0
  206. package/dist/runtime/grokEngineBrokerLedger.d.ts +52 -0
  207. package/dist/runtime/grokEngineBrokerLedger.d.ts.map +1 -0
  208. package/dist/runtime/grokEngineBrokerLedger.js +114 -0
  209. package/dist/runtime/grokEngineBrokerMetering.d.ts +51 -0
  210. package/dist/runtime/grokEngineBrokerMetering.d.ts.map +1 -0
  211. package/dist/runtime/grokEngineBrokerMetering.js +34 -0
  212. package/dist/runtime/grokEngineBrokerTurn.d.ts +58 -0
  213. package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
  214. package/dist/runtime/grokEngineBrokerTurn.js +165 -0
  215. package/dist/runtime/grokInferenceClientConfig.d.ts +41 -0
  216. package/dist/runtime/grokInferenceClientConfig.d.ts.map +1 -0
  217. package/dist/runtime/grokInferenceClientConfig.js +62 -0
  218. package/dist/runtime/grokInferenceGrants.d.ts +77 -0
  219. package/dist/runtime/grokInferenceGrants.d.ts.map +1 -0
  220. package/dist/runtime/grokInferenceGrants.js +116 -0
  221. package/dist/runtime/grokInferenceProxy.d.ts +29 -0
  222. package/dist/runtime/grokInferenceProxy.d.ts.map +1 -0
  223. package/dist/runtime/grokInferenceProxy.js +82 -0
  224. package/dist/runtime/grokInferenceProxyRequest.d.ts +23 -0
  225. package/dist/runtime/grokInferenceProxyRequest.d.ts.map +1 -0
  226. package/dist/runtime/grokInferenceProxyRequest.js +63 -0
  227. package/dist/runtime/grokSlotPreflightReceipt.d.ts +70 -0
  228. package/dist/runtime/grokSlotPreflightReceipt.d.ts.map +1 -0
  229. package/dist/runtime/grokSlotPreflightReceipt.js +101 -0
  230. package/dist/runtime/grokSubscriptionRealm.d.ts +4 -0
  231. package/dist/runtime/grokSubscriptionRealm.d.ts.map +1 -0
  232. package/dist/runtime/grokSubscriptionRealm.js +435 -0
  233. package/dist/runtime/grokSubscriptionRealmTypes.d.ts +26 -0
  234. package/dist/runtime/grokSubscriptionRealmTypes.d.ts.map +1 -0
  235. package/dist/runtime/grokSubscriptionRealmTypes.js +1 -0
  236. package/dist/runtime/grokWorkerAttestation.d.ts +170 -0
  237. package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -0
  238. package/dist/runtime/grokWorkerAttestation.js +266 -0
  239. package/dist/runtime/grokWorkerDenyPlacement.d.ts +80 -0
  240. package/dist/runtime/grokWorkerDenyPlacement.d.ts.map +1 -0
  241. package/dist/runtime/grokWorkerDenyPlacement.js +128 -0
  242. package/dist/runtime/grokWorkerHomeAttestation.d.ts +30 -0
  243. package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
  244. package/dist/runtime/grokWorkerHomeAttestation.js +69 -0
  245. package/dist/runtime/grokWorkerSandboxProfile.d.ts +27 -0
  246. package/dist/runtime/grokWorkerSandboxProfile.d.ts.map +1 -0
  247. package/dist/runtime/grokWorkerSandboxProfile.js +44 -0
  248. package/dist/runtime/grokWorkerTmpAttestation.d.ts +55 -0
  249. package/dist/runtime/grokWorkerTmpAttestation.d.ts.map +1 -0
  250. package/dist/runtime/grokWorkerTmpAttestation.js +63 -0
  251. package/dist/runtime/index.d.ts +26 -0
  252. package/dist/runtime/index.d.ts.map +1 -0
  253. package/dist/runtime/index.js +23 -0
  254. package/dist/runtime/inferenceUsageLedger.d.ts +38 -0
  255. package/dist/runtime/inferenceUsageLedger.d.ts.map +1 -0
  256. package/dist/runtime/inferenceUsageLedger.js +53 -0
  257. package/dist/runtime/mcpToolResult.d.ts +127 -0
  258. package/dist/runtime/mcpToolResult.d.ts.map +1 -0
  259. package/dist/runtime/mcpToolResult.js +214 -0
  260. package/dist/runtime/moltnetMachineRead.d.ts +97 -0
  261. package/dist/runtime/moltnetMachineRead.d.ts.map +1 -0
  262. package/dist/runtime/moltnetMachineRead.js +183 -0
  263. package/dist/runtime/native/daimon-engine-broker +0 -0
  264. package/dist/runtime/organizationRuntime.d.ts +165 -0
  265. package/dist/runtime/organizationRuntime.d.ts.map +1 -0
  266. package/dist/runtime/organizationRuntime.js +3 -0
  267. package/dist/runtime/organizationRuntimeControl.d.ts +42 -0
  268. package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
  269. package/dist/runtime/organizationRuntimeControl.js +235 -0
  270. package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
  271. package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
  272. package/dist/runtime/organizationRuntimeHost.js +359 -0
  273. package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
  274. package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
  275. package/dist/runtime/organizationRuntimeParsing.js +370 -0
  276. package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
  277. package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
  278. package/dist/runtime/organizationRuntimeReadiness.js +59 -0
  279. package/dist/runtime/physicalReadiness.d.ts +47 -0
  280. package/dist/runtime/physicalReadiness.d.ts.map +1 -0
  281. package/dist/runtime/physicalReadiness.js +142 -0
  282. package/dist/runtime/portableCredentialAuth.d.ts +6 -0
  283. package/dist/runtime/portableCredentialAuth.d.ts.map +1 -0
  284. package/dist/runtime/portableCredentialAuth.js +70 -0
  285. package/dist/runtime/portableCredentialMaterial.d.ts +8 -0
  286. package/dist/runtime/portableCredentialMaterial.d.ts.map +1 -0
  287. package/dist/runtime/portableCredentialMaterial.js +169 -0
  288. package/dist/runtime/productionAgentTools.d.ts +5 -0
  289. package/dist/runtime/productionAgentTools.d.ts.map +1 -0
  290. package/dist/runtime/productionAgentTools.js +328 -0
  291. package/dist/runtime/runtimeHomeLayout.d.ts +48 -0
  292. package/dist/runtime/runtimeHomeLayout.d.ts.map +1 -0
  293. package/dist/runtime/runtimeHomeLayout.js +84 -0
  294. package/dist/runtime/schedule.d.ts +40 -0
  295. package/dist/runtime/schedule.d.ts.map +1 -0
  296. package/dist/runtime/schedule.js +371 -0
  297. package/dist/runtime/storeCoordination.d.ts +23 -0
  298. package/dist/runtime/storeCoordination.d.ts.map +1 -0
  299. package/dist/runtime/storeCoordination.js +94 -0
  300. package/dist/runtime/toolResultSpill.d.ts +152 -0
  301. package/dist/runtime/toolResultSpill.d.ts.map +1 -0
  302. package/dist/runtime/toolResultSpill.js +351 -0
  303. package/dist/runtime/turnRequestLedger.d.ts +160 -0
  304. package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
  305. package/dist/runtime/turnRequestLedger.js +249 -0
  306. package/dist/runtime/turnUsageLedger.d.ts +143 -0
  307. package/dist/runtime/turnUsageLedger.d.ts.map +1 -0
  308. package/dist/runtime/turnUsageLedger.js +203 -0
  309. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +17 -0
  310. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
  311. package/dist/runtime/wakeAcceptanceProcessIdentity.js +50 -0
  312. package/dist/runtime/wakeAcceptanceReconciliation.d.ts +211 -0
  313. package/dist/runtime/wakeAcceptanceReconciliation.d.ts.map +1 -0
  314. package/dist/runtime/wakeAcceptanceReconciliation.js +289 -0
  315. package/dist/runtime/wakeAcceptanceRecord.d.ts +23 -0
  316. package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
  317. package/dist/runtime/wakeAcceptanceRecord.js +56 -0
  318. package/dist/runtime/wakeAcceptanceRetention.d.ts +12 -0
  319. package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
  320. package/dist/runtime/wakeAcceptanceRetention.js +12 -0
  321. package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
  322. package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
  323. package/dist/runtime/wakeAcceptanceStore.js +558 -0
  324. package/dist/runtime/wakeAcceptanceTypes.d.ts +179 -0
  325. package/dist/runtime/wakeAcceptanceTypes.d.ts.map +1 -0
  326. package/dist/runtime/wakeAcceptanceTypes.js +95 -0
  327. package/dist/runtime/wakeFuse.d.ts +69 -0
  328. package/dist/runtime/wakeFuse.d.ts.map +1 -0
  329. package/dist/runtime/wakeFuse.js +367 -0
  330. package/package.json +20 -9
@@ -0,0 +1,359 @@
1
+ import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
2
+ import { sanitizeWakeCompletionText } from "./wakeAcceptanceTypes.js";
3
+ import { startOrganizationRuntimeEngine } from "./engineDispatcher.js";
4
+ import { prepareProductionReadiness } from "./organizationRuntimeReadiness.js";
5
+ import { parseOrganizationRuntimeConfig, parseOrganizationRuntimeWakeRequest } from "./organizationRuntime.js";
6
+ /** Creates the public host with Daimon's closed production engine dispatcher. */
7
+ export function createOrganizationRuntimeHost(config, options = {}) {
8
+ const parsed = parseOrganizationRuntimeConfig(config);
9
+ if (parsed.agents.some((agent) => agent.attention !== undefined))
10
+ throw new Error("attention requires createOrganizationRuntimeControlHost and POST /v2/wakes for durable inbox ownership");
11
+ return createOrganizationRuntimeHostWithAttention(parsed, options, new Map());
12
+ }
13
+ /** @internal Control-owned attention registry, never a caller-supplied config hook. */
14
+ export function createOrganizationRuntimeHostWithAttention(config, options, attention) {
15
+ const parsed = parseOrganizationRuntimeConfig(config);
16
+ let agyBusAddress;
17
+ let grokBroker;
18
+ return createHost(parsed, (agent, paths) => startOrganizationRuntimeEngine(agent, parsed.host.controlTokenEnv, paths, agyBusAddress, grokBroker, parsed.agents, options.sharedProtectedPaths, attention), async () => {
19
+ const ready = await prepareProductionReadiness(parsed);
20
+ agyBusAddress = ready.agyRealm?.busAddress;
21
+ grokBroker = ready.grokBroker;
22
+ return {
23
+ ...ready,
24
+ async close() {
25
+ try {
26
+ await ready.close();
27
+ }
28
+ finally {
29
+ agyBusAddress = undefined;
30
+ grokBroker = undefined;
31
+ }
32
+ }
33
+ };
34
+ });
35
+ }
36
+ /** @internal Test-only construction seam; it is intentionally not package-exported. */
37
+ export function createOrganizationRuntimeHostForTest(config, factory, preflight) {
38
+ return createHost(parseOrganizationRuntimeConfig(config), factory, preflight === undefined ? undefined : async () => {
39
+ const paths = await preflight();
40
+ return { paths, close: () => paths.close() };
41
+ });
42
+ }
43
+ function createHost(config, factory, preflight = undefined) {
44
+ const maxPendingWakes = 64;
45
+ const maxActivity = 512;
46
+ const agents = new Map(config.agents.map((agent) => [agent.id, {
47
+ config: agent,
48
+ state: "stopped",
49
+ draining: false,
50
+ pending: [],
51
+ stopped: false
52
+ }]));
53
+ const activity = [];
54
+ let nextActivitySequence = 0;
55
+ // Capture the expected token before any operation can route by agent id.
56
+ const controlToken = process.env[config.host.controlTokenEnv];
57
+ let state = "stopped";
58
+ let startPromise;
59
+ let stopPromise;
60
+ let stopRequested = false;
61
+ let readiness;
62
+ const addActivity = (agentId, kind, wakeId) => {
63
+ activity.push({
64
+ sequence: nextActivitySequence++,
65
+ value: { id: randomUUID(), agentId, ...(wakeId === undefined ? {} : { wakeId }), kind, occurredAt: new Date().toISOString() }
66
+ });
67
+ if (activity.length > maxActivity)
68
+ activity.shift();
69
+ };
70
+ const stoppedResult = (request, code) => ({
71
+ version: "noopolis.daimon.wake-result.v1",
72
+ status: "stopped",
73
+ agentId: request.agentId,
74
+ wakeId: request.event.id,
75
+ code
76
+ });
77
+ const settle = (job, result) => {
78
+ if (job.settled)
79
+ return;
80
+ job.settled = true;
81
+ job.resolve(result);
82
+ };
83
+ const drain = async (agent) => {
84
+ if (agent.draining)
85
+ return;
86
+ agent.draining = true;
87
+ try {
88
+ while (state === "running" && agent.pending.length > 0) {
89
+ const job = agent.pending.shift();
90
+ if (job === undefined)
91
+ continue;
92
+ agent.active = job;
93
+ agent.state = "running";
94
+ addActivity(agent.config.id, "wake_started", job.request.event.id);
95
+ try {
96
+ const result = await agent.handle.wake(toCoreWake(job.request));
97
+ if (!job.settled && !job.aborting) {
98
+ agent.state = "idle";
99
+ addActivity(agent.config.id, "wake_completed", job.request.event.id);
100
+ settle(job, completed(job.request, result.text, result.durationMs));
101
+ }
102
+ }
103
+ catch (error) {
104
+ if (!job.settled && !job.aborting) {
105
+ agent.state = "failed";
106
+ settle(job, failed(job.request, error));
107
+ }
108
+ }
109
+ finally {
110
+ if (agent.active === job)
111
+ agent.active = undefined;
112
+ }
113
+ }
114
+ }
115
+ finally {
116
+ agent.draining = false;
117
+ }
118
+ };
119
+ const start = async () => {
120
+ if (state === "running")
121
+ return;
122
+ if (startPromise !== undefined)
123
+ return startPromise;
124
+ if (stopRequested)
125
+ throw new Error("organization runtime host has been stopped");
126
+ if (controlToken === undefined || !controlToken.trim()) {
127
+ throw new Error(`required control token ${config.host.controlTokenEnv} is missing or blank`);
128
+ }
129
+ state = "starting";
130
+ for (const agent of agents.values())
131
+ agent.state = "starting";
132
+ startPromise = (async () => {
133
+ // This runs before a factory can create an adapter or child process.
134
+ try {
135
+ readiness = await preflight?.();
136
+ }
137
+ catch (error) {
138
+ state = "stopped";
139
+ for (const agent of agents.values())
140
+ agent.state = "stopped";
141
+ throw error;
142
+ }
143
+ const started = await Promise.allSettled([...agents.values()].map(async (agent) => {
144
+ const paths = readiness?.paths.forAgent(agent.config);
145
+ await paths?.verify();
146
+ agent.handle = await factory(agent.config, paths);
147
+ await paths?.verify();
148
+ return agent;
149
+ }));
150
+ const failedStart = started.find((result) => result.status === "rejected");
151
+ if (failedStart !== undefined || stopRequested) {
152
+ state = "stopping";
153
+ stopRequested = true;
154
+ const startedAgents = [...agents.values()].filter((agent) => agent.handle !== undefined);
155
+ const stopped = await Promise.allSettled(startedAgents.map(async (agent) => {
156
+ await agent.handle.stop();
157
+ agent.handle = undefined;
158
+ agent.stopped = true;
159
+ agent.state = "stopped";
160
+ }));
161
+ const cleanupFailures = stopped.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
162
+ for (const agent of agents.values()) {
163
+ if (agent.handle !== undefined)
164
+ agent.state = "stopping";
165
+ else if (!agent.stopped)
166
+ agent.state = "stopped";
167
+ }
168
+ if (cleanupFailures.length > 0) {
169
+ // A handle that cannot stop remains visible and retryable.
170
+ state = "stopping";
171
+ throw new AggregateError([...(failedStart === undefined ? [] : [failedStart.reason]), ...cleanupFailures], "organization runtime startup cleanup failed");
172
+ }
173
+ await readiness?.close();
174
+ readiness = undefined;
175
+ state = "stopped";
176
+ if (failedStart !== undefined)
177
+ throw failedStart.reason;
178
+ return;
179
+ }
180
+ try {
181
+ state = "running";
182
+ for (const agent of agents.values())
183
+ agent.state = "idle";
184
+ }
185
+ catch (error) {
186
+ state = "stopping";
187
+ await Promise.allSettled([...agents.values()].flatMap((agent) => agent.handle === undefined ? [] : [agent.handle.stop()]));
188
+ await readiness?.close();
189
+ readiness = undefined;
190
+ for (const agent of agents.values()) {
191
+ agent.handle = undefined;
192
+ agent.state = "stopped";
193
+ }
194
+ state = "stopped";
195
+ throw error;
196
+ }
197
+ })().finally(() => {
198
+ startPromise = undefined;
199
+ });
200
+ return startPromise;
201
+ };
202
+ const wake = async (request) => {
203
+ let parsed;
204
+ try {
205
+ parsed = parseOrganizationRuntimeWakeRequest(request);
206
+ }
207
+ catch {
208
+ return invalidRequest();
209
+ }
210
+ if (controlToken === undefined || !tokensEqual(controlToken, parsed.token)) {
211
+ return rejected(parsed, "unauthorized");
212
+ }
213
+ if (state !== "running" || stopRequested) {
214
+ return stoppedResult(parsed, stopRequested || state === "stopping" ? "host_stopping" : "host_stopped");
215
+ }
216
+ const agent = agents.get(parsed.agentId);
217
+ if (agent === undefined) {
218
+ addActivity(parsed.agentId, "wake_rejected", parsed.event.id);
219
+ return rejected(parsed, "unknown_agent");
220
+ }
221
+ if (agent.pending.length >= maxPendingWakes) {
222
+ addActivity(parsed.agentId, "wake_rejected", parsed.event.id);
223
+ return rejected(parsed, "queue_full");
224
+ }
225
+ return new Promise((resolve) => {
226
+ const job = { request: parsed, resolve, settled: false, aborting: false };
227
+ agent.pending.push(job);
228
+ void drain(agent);
229
+ });
230
+ };
231
+ const health = async (agentId) => ({
232
+ version: "noopolis.daimon.organization-runtime-health.v1",
233
+ state,
234
+ agents: [...agents.values()]
235
+ .filter((agent) => agentId === undefined || agent.config.id === agentId)
236
+ .map((agent) => ({ agentId: agent.config.id, engine: agent.config.engine.kind, state: agentHealthState(agent) }))
237
+ });
238
+ const activityPage = async (request) => {
239
+ const offset = cursorOffset(request.cursor);
240
+ if (!Number.isInteger(request.limit) || request.limit < 1 || request.limit > 100) {
241
+ throw new TypeError("activity.limit must be an integer between 1 and 100");
242
+ }
243
+ const filtered = activity.filter((entry) => entry.sequence >= offset
244
+ && (request.agentId === undefined || entry.value.agentId === request.agentId));
245
+ const entries = filtered.slice(0, request.limit);
246
+ const items = entries.map((entry) => entry.value);
247
+ const next = entries.length === 0 ? undefined : entries[entries.length - 1].sequence + 1;
248
+ return {
249
+ version: "noopolis.daimon.organization-runtime-activity.v1",
250
+ items,
251
+ ...(next !== undefined && filtered.length > entries.length ? { nextCursor: String(next) } : {})
252
+ };
253
+ };
254
+ const stop = () => {
255
+ if (stopPromise !== undefined)
256
+ return stopPromise;
257
+ stopRequested = true;
258
+ const attempt = (async () => {
259
+ if (startPromise !== undefined)
260
+ await startPromise.catch(() => undefined);
261
+ if (state === "stopped")
262
+ return { version: "noopolis.daimon.organization-runtime-stop.v1", state: "stopped" };
263
+ state = "stopping";
264
+ const active = [];
265
+ for (const agent of agents.values()) {
266
+ for (const job of agent.pending.splice(0))
267
+ settle(job, stoppedResult(job.request, "queued_wake_stopped"));
268
+ if (agent.active !== undefined) {
269
+ agent.active.aborting = true;
270
+ active.push({ agent, job: agent.active });
271
+ }
272
+ }
273
+ const liveAgents = [...agents.values()].filter((agent) => agent.handle !== undefined && !agent.stopped);
274
+ const stopped = await Promise.allSettled(liveAgents.map(async (agent) => {
275
+ await agent.handle.stop();
276
+ agent.handle = undefined;
277
+ agent.stopped = true;
278
+ agent.state = "stopped";
279
+ }));
280
+ const failures = stopped.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
281
+ for (const { agent, job } of active) {
282
+ addActivity(agent.config.id, "wake_aborted", job.request.event.id);
283
+ settle(job, stoppedResult(job.request, "active_wake_aborted"));
284
+ }
285
+ if (failures.length > 0) {
286
+ for (const agent of liveAgents)
287
+ if (agent.handle !== undefined)
288
+ agent.state = "stopping";
289
+ throw new AggregateError(failures, "organization runtime shutdown cleanup failed");
290
+ }
291
+ await readiness?.close();
292
+ readiness = undefined;
293
+ for (const agent of agents.values())
294
+ agent.stopped = true;
295
+ for (const agent of agents.values()) {
296
+ agent.state = "stopped";
297
+ addActivity(agent.config.id, "agent_stopped");
298
+ }
299
+ state = "stopped";
300
+ return { version: "noopolis.daimon.organization-runtime-stop.v1", state: "stopped" };
301
+ })();
302
+ stopPromise = attempt;
303
+ void attempt.catch(() => { if (stopPromise === attempt)
304
+ stopPromise = undefined; });
305
+ return attempt;
306
+ };
307
+ return { start, wake, health, activity: activityPage, stop };
308
+ }
309
+ function toCoreWake(request) {
310
+ return {
311
+ id: request.event.id,
312
+ kind: request.event.kind === "external" ? "manual" : request.event.kind,
313
+ text: request.event.text
314
+ };
315
+ }
316
+ function agentHealthState(agent) {
317
+ const status = agent.handle?.status();
318
+ return agent.state === "running" || agent.state === "failed" || agent.state === "stopped"
319
+ ? agent.state
320
+ : status?.state ?? agent.state;
321
+ }
322
+ function tokensEqual(expected, actual) {
323
+ const digest = (value) => createHash("sha256").update(value).digest();
324
+ return timingSafeEqual(digest(expected), digest(actual ?? ""));
325
+ }
326
+ function cursorOffset(cursor) {
327
+ if (cursor === undefined)
328
+ return 0;
329
+ if (!/^(0|[1-9][0-9]{0,15})$/.test(cursor))
330
+ throw new TypeError("activity.cursor is invalid");
331
+ const offset = Number(cursor);
332
+ if (!Number.isSafeInteger(offset))
333
+ throw new TypeError("activity.cursor is invalid");
334
+ return offset;
335
+ }
336
+ function completed(request, text, durationMs) {
337
+ return { version: "noopolis.daimon.wake-result.v1", status: "completed", agentId: request.agentId, wakeId: request.event.id, text: sanitizeWakeCompletionText(text), durationMs };
338
+ }
339
+ /** Engine failures are undiagnosable without the cause, so carry a bounded excerpt. */
340
+ export const ENGINE_FAILURE_DETAIL_MAX_BYTES = 2_048;
341
+ function failed(request, error) {
342
+ const detail = engineFailureDetail(error);
343
+ return { version: "noopolis.daimon.wake-result.v1", status: "failed", agentId: request.agentId, wakeId: request.event.id, code: "engine_failed", ...(detail === undefined ? {} : { detail }) };
344
+ }
345
+ export function engineFailureDetail(error) {
346
+ const raw = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
347
+ if (raw === undefined)
348
+ return undefined;
349
+ const trimmed = raw.replaceAll(/\s+/gu, " ").trim();
350
+ if (trimmed.length === 0)
351
+ return undefined;
352
+ return Buffer.from(trimmed, "utf8").subarray(0, ENGINE_FAILURE_DETAIL_MAX_BYTES).toString("utf8");
353
+ }
354
+ function rejected(request, code) {
355
+ return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: request.agentId, wakeId: request.event.id, code };
356
+ }
357
+ function invalidRequest() {
358
+ return { version: "noopolis.daimon.wake-result.v1", status: "rejected", agentId: "", wakeId: "", code: "invalid_request" };
359
+ }
@@ -0,0 +1,6 @@
1
+ import { type OrganizationRuntimeConfig, type OrganizationRuntimeWakeRequest } from "./organizationRuntime.js";
2
+ export declare function parseOrganizationRuntimeConfig(value: unknown): OrganizationRuntimeConfig;
3
+ export declare function parseOrganizationRuntimeWakeRequest(value: unknown): OrganizationRuntimeWakeRequest;
4
+ export declare function validateOrganizationRuntimeConfig(value: unknown): value is OrganizationRuntimeConfig;
5
+ export declare const isOrganizationRuntimeConfig: typeof validateOrganizationRuntimeConfig;
6
+ //# sourceMappingURL=organizationRuntimeParsing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizationRuntimeParsing.d.ts","sourceRoot":"","sources":["../../src/runtime/organizationRuntimeParsing.ts"],"names":[],"mappings":"AAEA,OAAO,EAcL,KAAK,yBAAyB,EAK9B,KAAK,8BAA8B,EACpC,MAAM,0BAA0B,CAAC;AAOlC,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CAuBxF;AAED,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,OAAO,GAAG,8BAA8B,CAWlG;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,yBAAyB,CAEpG;AAED,eAAO,MAAM,2BAA2B,0CAAoC,CAAC"}