@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,40 @@
1
+ import path from "node:path";
2
+ import { renderCodexArgs } from "../pi/cliEngineSpawn.js";
3
+ import { codexSandboxProtectedPaths, codexSandboxReadablePaths } from "./engineDispatcher.js";
4
+ import { engineHomeName, prepareEngineExecutable } from "./engineReadiness.js";
5
+ import { parseOrganizationRuntimeConfig } from "./organizationRuntime.js";
6
+ import { prepareOrganizationRuntimePaths } from "./physicalReadiness.js";
7
+ export const CODEX_SANDBOX_PROJECTION_VERSION = "noopolis.daimon.codex-sandbox-projection.v1";
8
+ /** Resolves the production command policy without importing auth or accepting a wake. */
9
+ export async function resolveOrganizationCodexSandboxProjection(config, agentId, options) {
10
+ const parsed = parseOrganizationRuntimeConfig(config);
11
+ const selected = parsed.agents.find(agent => agent.id === agentId);
12
+ if (!selected || selected.engine.kind !== "codex" || selected.engine.codexSandbox === undefined) {
13
+ throw new Error("Sandbox projection requires a known strict Codex agent");
14
+ }
15
+ if (!path.isAbsolute(options.acceptanceStorePath))
16
+ throw new Error("Sandbox projection requires an absolute acceptance store path");
17
+ const authority = await prepareOrganizationRuntimePaths(parsed.agents);
18
+ try {
19
+ const paths = authority.forAgent(selected);
20
+ await paths.verify();
21
+ const agent = { ...selected, workspacePath: paths.workspacePath, runtimeHomePath: paths.runtimeHomePath };
22
+ const engineHomePath = path.join(agent.runtimeHomePath, engineHomeName("codex"));
23
+ const executable = await prepareEngineExecutable(agent.id, "codex");
24
+ // These are the same collectors, canonical roots and renderer used by
25
+ // startOrganizationRuntimeEngine and its strict production invocation.
26
+ const args = renderCodexArgs({ codexSandbox: agent.engine.codexSandbox,
27
+ codexSandboxProtectedPaths: codexSandboxProtectedPaths(agent.id, agent, engineHomePath, parsed.agents, [options.acceptanceStorePath]),
28
+ codexSandboxReadablePaths: codexSandboxReadablePaths(agent) }, agent.workspacePath, undefined);
29
+ const permissionConfig = args.find(arg => arg.startsWith("permissions="));
30
+ const profileName = JSON.parse(args.find(arg => arg.startsWith("default_permissions=")).slice("default_permissions=".length));
31
+ await paths.verify();
32
+ await executable.verify();
33
+ return { version: CODEX_SANDBOX_PROJECTION_VERSION, agentId, workspacePath: agent.workspacePath,
34
+ runtimeHomePath: agent.runtimeHomePath, engineHomePath, executablePath: executable.executablePath, profileName, permissionConfig,
35
+ sandboxArgs: ["sandbox", "-P", profileName, "-C", agent.workspacePath, "-c", permissionConfig] };
36
+ }
37
+ finally {
38
+ await authority.close();
39
+ }
40
+ }
@@ -0,0 +1 @@
1
+ {"activityResponseSchema":{"additionalProperties":false,"properties":{"items":{"items":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"id":{"format":"uuid","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","type":"string"},"kind":{"enum":["wake_started","wake_completed","wake_rejected","wake_aborted","agent_stopped"]},"occurredAt":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["id","agentId","kind","occurredAt"],"type":"object"},"maxItems":100,"type":"array"},"nextCursor":{"maxLength":16,"minLength":1,"pattern":"^(0|[1-9][0-9]{0,15})$","type":"string"},"version":{"const":"noopolis.daimon.organization-runtime-activity.v1"}},"required":["version","items"],"type":"object"},"activityV2ResponseSchema":{"additionalProperties":false,"properties":{"executions":{"items":{"additionalProperties":false,"properties":{"agent_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"delivery_ids":{"items":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"maxItems":32,"type":"array"},"execution_id":{"type":"string"},"state":{"const":"running"}},"required":["agent_id","execution_id","state","delivery_ids"],"type":"object"},"maxItems":32,"type":"array"},"items":{"items":{"additionalProperties":false,"properties":{"acceptance_id":{"type":"string"},"accepted_at":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"active":{"type":"boolean"},"agent_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["engine_failed","host_stopped","host_stopping","queued_wake_stopped","active_wake_aborted","queue_full","unknown_agent"]},"deferred":{"type":"boolean"},"delivery_id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"execution_id":{"type":"string"},"queue_position":{"minimum":1,"type":"integer"},"request_digest":{"type":"string"},"state":{"enum":["accepted","running","completed","failed","stopped"]},"text":{"maxLength":16384,"type":"string"},"updated_at":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"version":{"const":"noopolis.daimon.wake-receipt-status.v2"}},"required":["version","acceptance_id","agent_id","delivery_id","request_digest","state","accepted_at","updated_at","active"],"type":"object"},"maxItems":2112,"type":"array"},"state":{"enum":["running","stopped"]},"version":{"const":"noopolis.daimon.organization-runtime-activity.v2"}},"required":["version","items"],"type":"object"},"agySubscriptionRealm":{"directoryMode":448,"durableMountPath":"/var/lib/spawnfile/daimon/agy-subscription-realm","fileMode":384,"maxUnlockBytes":4096,"unlockMountPath":"/var/lib/spawnfile/daimon/agy-unlock-secret","unlockSourceSlot":"agy-unlock-secret"},"attention":{"accounting":"execution-start-reservations","busyDispatch":"bounded-pending-message-batch","completion":"explicit-per-delivery","defaultMaxBatchBytes":12000,"defaultMaxBatchMessages":8,"enabledBy":"agents[].attention","idleDispatch":"immediate","unhandled":"deferred-until-new-input"},"consumedConfigFields":["version","host.bindHost","host.port","host.controlTokenEnv","agents[].id","agents[].name","agents[].instructions","agents[].workspacePath","agents[].runtimeHomePath","agents[].engine.kind","agents[].engine.model","agents[].engine.reasoningEffort","agents[].engine.codexSandbox","agents[].schedule.kind","agents[].schedule.interval_ms","agents[].schedule.cron","agents[].schedule.timezone","agents[].schedule.prompt","agents[].schedule.jitter_seconds","agents[].mcp","agents[].moltnet","agents[].memory","agents[].attention","agents[].recording"],"deliverySemantics":{"activeDeliveryIdempotency":"unbounded-until-terminal","concurrentSameAgentTurns":false,"externalEffectsExactlyOnce":false,"recovery":"at-least-once-with-stable-wake-id","terminalReceiptHorizon":2048},"engineCredentialMaterial":{"codex":{"destinationRelativePath":".codex/auth.json","directoryMode":448,"fileMode":384,"sourceRelativePath":".daimon-inbound/codex-auth","sourceSlot":"codex-auth"}},"grokEngineBroker":{"artifacts":{"arm64Sha256":"d0dc1c03197c3e90f09b66ad7c89b4f7b448d06dc84c03b247dce976d6018d6e","sourceSha256":"15836d7ad69f12ef581a6e5b8635c9db43b2177dac609160c0749d3d1fefbaa8","x64Sha256":"95aa9c272225e74ff9f45f54dde4bc30aee324e9ba24d8a876db9151c81b454d"},"backendSocketPath":"/run/daimon-engine-broker/backend.sock","bounds":{"capabilityBundleBytes":8196,"capabilityBytes":4096,"outputBytes":262144,"promptBytes":65536},"controlProtocolVersion":"noopolis.daimon.engine-broker.v4","controlSocketPath":"/run/daimon-engine-broker/control.sock","credentialHomePath":"/var/lib/spawnfile/daimon/grok-subscription-realm","grokCliArtifacts":{"arm64":{"bytes":136090504,"sha256":"39ab87666877d64ef3a40aa60fbe0c3b6a6acd7001b78fe60e2c76bb6cfc4a94","url":"https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-aarch64"},"x64":{"bytes":163035648,"sha256":"be5905e107d2b8b5f3c142d21ecfe4c8fd32a913d2fd551b788707930c4dc80d","url":"https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-x86_64"}},"grokCliBuild":"3736acbc8658","grokCliVersion":"1.0.34","grokExecutablePath":"/usr/local/bin/grok","identities":{"brokerUid":2100,"firstWorkerUid":2200,"organizationUid":2000},"inferenceGrants":{"bodyMembers":["messages","model","reasoning_effort","response_format","stream","stream_options"],"client":{"configSha256":{"grok-4.5":{"high":"ffbc33728b821e9854fbc7c93601e599225da421ecfd6ebf10d314afcc28d6f2","low":"a07f7436f1268bb399ec233c65d3b3d8fb99a11a1f175f8da1ca133c9367bc74","medium":"1f4c0d4dad1f3b09419b5739db6423a09e0049abc091594c64123a75dd53dfb9"},"grok-4.6":{"high":"5652656effa82f0c4f09cf8226b16e6140332a5a358b571194bb5563312367ac","low":"79314d039f787e4ebfec7dacf57adc969086b948f564dec008f0ed6367e6062f","medium":"6f538de0547c0c4e6a3f04ae08595ceadadabb06b75f6b6ee4c428744bb95cd8"},"grok-build":{"high":"98d16f2b7d12f4eb540d625c853e51d227933e204923e43e8b9b4176f10aca2c","low":"ca15c6a562a008227d39c51d3a3a83715663089b3784e8b46debb1fb67b3c4a1","medium":"01783fb6beadcf6f8486fff0836820ad43fab5662b812a907fe9cfdb83e9804d"}},"envKey":"DAIMON_INFERENCE_GRANT","modelId":"daimon-inference-grok"},"failureCodes":["auth_stale","grant_limit","invalid_request","unavailable"],"ledgerDedupeKey":["grant","request"],"ledgerVersion":"noopolis.daimon.inference-usage.v1","limits":{"maxRequests":64,"maxTokens":2000000},"maxInFlightRequestsPerGrant":1,"maxLiveGrants":8,"messageRoles":["system","user","assistant"],"purposes":["judge","optimizer"],"requestKinds":["request_inference_grant","release_inference_grant"],"tokenPrefix":"inference_","ttlMs":600000},"launcherSocketPath":"/run/daimon-engine-broker/launcher.sock","mcpFacade":{"host":"127.0.0.1","path":"/mcp","port":43124},"nativeAbiVersion":2,"nativeExecutablePath":"/opt/daimon/bin/daimon-engine-broker","projectionVersion":"noopolis.daimon.grok-broker-projection.v3","providerProxy":{"host":"127.0.0.1","port":43123},"registrationPath":"/etc/daimon-engine-broker/registrations.bin","runRequestBudget":{"countsCredentialRetries":true,"fileName":"run-requests.json","includesInferenceGrants":true,"maximumField":"maxRunRequests","storeField":"runRequestStore"},"serviceConfigPath":"/etc/daimon-engine-broker/service.json","serviceConfigVersions":["noopolis.daimon.engine-broker-service.v1","noopolis.daimon.engine-broker-service.v2","noopolis.daimon.engine-broker-service.v3"],"slotPreflightVersion":"noopolis.daimon.grok-slot-preflight.v2","slotRouting":{"controlCaller":"organization","key":"slot","repeatedAgentIds":true,"resetRequest":"reset_slot","resetResponse":"slot_reset","slotEnvironment":"DAIMON_ENGINE_BROKER_SLOT","turnStoreDirectory":"slot-{slot}","workersMayControl":false},"turnLimits":{"bounds":{"maxRequests":[1,48],"maxTokens":[1,10000000],"timeoutMs":[1000,3600000]},"keys":["maxRequests","maxTokens","timeoutMs"],"limitReasons":["tokens","requests","timeout","none"],"maxInFlightRequests":1,"missingUsageEstimate":{"inputBytesPerToken":2,"outputTokens":4096},"requestUsageMaxTokens":500000,"tokenCeilingOvershoot":"at-most-one-request","v1Defaults":{"maxRequests":32,"maxTokens":300000,"timeoutMs":240000},"wakeMayOnlyLower":true},"turnRecordVersions":["noopolis.daimon.engine-broker-turn.v1","noopolis.daimon.engine-broker-turn.v2"],"turnStorePath":"/var/lib/spawnfile/daimon/grok-subscription-realm/turns","wakeLimitEnvironment":{"maxTokens":"DAIMON_ENGINE_WAKE_TOKEN_CEILING","timeoutMs":"DAIMON_ENGINE_WAKE_TIMEOUT_MS"},"worker":{"clockedConfigSha256":{"grok-4.5":{"high":"907d8967960c342b442d6d256b2585f3c85bd846a78578f596f0b605403d6d34","low":"3c4f3515b21c1bffb3fb770e2ecb4b918b6c43d5e77c1fd47e1e6698d1fedee7","medium":"9117e12b2f3f6fa045799592969cbaae1c2f3b1ea79330badac8655b9b41dd7a"},"grok-4.6":{"high":"203744f6f0dfc0bc80cfb896880497edfd9b3de4dcf33060e8ef4d2ef5f220a7","low":"751f1dcd04983e5e5883df5a8fefa04f201e187e5ef1f344d3bf83f950830432","medium":"f1406f93a8091eb0c09e07321254a9c783a89b0bbf5548d9613d53a8d087a517"},"grok-build":{"high":"6efddadc82c38020d3351829e54bb09fa456cd6d76ea1247902794d82a4a3ffa","low":"a8c63ba910623a0686930c27db0733f4a2588c7fca9dd7da25c3f18027720ab5","medium":"6afcd2b90c0d19794f8c0d22147a0f011946a92e613f89dae98b0ca729313101"}},"configSha256":{"grok-4.5":{"high":"c63c3387ce92d94ec3f690abfe98942afcd7c9e17ff84816bbe751f340ab251f","low":"8247127c3625ff7c5d8d527a53596b89ec6557a821ac46cfd00bd122b90daff6","medium":"59288cee61297bb8c002097061a48f77b09d310754187a253ee089f7172a9155"},"grok-4.6":{"high":"65b0212564fb74042b1503d293fb8d3620276033264c0efade2a539ca09218e3","low":"ab58499ac32678097c146479896f2b8a8e2b0e39aea22dc0a60b6227e370538e","medium":"df1a5cc84346e7f6bf6090492fbd19faaefb42953e3bb2e8c6cbc0572242403f"},"grok-build":{"high":"a23724e00d670caee185ba7690d2daa868173e53905cf446f5329666f01ab4e3","low":"fb343f2809903f26d21681470943235031f946e99085542fd89555eb7782cbb5","medium":"8a587ef75c90eab70d19b24583e60051d6fba9d90c558839fdbb15588b4cc656"}},"defaultModel":"grok-4.6","defaultReasoningEffort":"low","home":{"directory":{"group":"worker","mode":1017,"uid":0},"organizationRuntimeHome":{"group":"worker","mode":456,"owner":"organization"},"privateTmp":{"mode":448,"owner":"worker","relativeToWorkerHome":"tmp"},"readOnlyFiles":{"gid":0,"mode":292,"names":["config.toml","managed_config.toml","requirements.toml","sandbox.toml","trusted_folders.toml"],"uid":0},"sandboxEvents":{"group":"broker","mode":416,"owner":"worker","relativePath":"sessions/sandbox-events.jsonl"},"sessionsDirectory":{"group":"worker","mode":1017,"relativePath":"sessions","uid":0},"sharedTmp":{"maxGroupExclusive":2200,"mode":1020,"otherMode":4,"paths":["/tmp","/var/tmp"],"uid":0},"spillDirectory":{"fileMode":416,"group":"worker","mode":1512,"owner":"organization","relativeToRuntimeHome":"tool-output"}},"maxTurns":48,"modelId":"daimon-broker-grok","models":["grok-4.6","grok-4.5","grok-build"],"reasoningEfforts":["low","medium","high"],"systemPromptSha256":"2c31c0085a54a4efbf9c0cf0b8124c56e47f38691b7f0c7fa233a74abaa8ddf8","taskClock":{"directoryMode":493,"directoryPath":"/run/daimon-engine-broker/task-clock/slot-0","fileMode":420,"ownerUid":2100,"preloadPath":"/usr/local/lib/daimon/libfaketime.so.1","rootDirectoryPath":"/run/daimon-engine-broker/task-clock","slotDirectoryPattern":"/run/daimon-engine-broker/task-clock/slot-{slot}","slotFilePattern":"/run/daimon-engine-broker/task-clock/slot-{slot}/faketime","timestampFilePath":"/run/daimon-engine-broker/task-clock/slot-0/faketime","version":"noopolis.daimon.grok-broker-task-clock.v2","workerView":"own-directory-visible-sibling-directories-denied"},"toolIds":["run_terminal_cmd","read_file","grep","list_dir","search_tool","use_tool"],"visibleTools":["grep","list_dir","read_file","run_terminal_command","search_tool","use_tool"]}},"grokSubscriptionRealm":{"agentCredentialRelativePath":".grok/auth.json","bootstrapMountPath":"/var/lib/spawnfile/daimon/grok-bootstrap-auth","bootstrapSourceSlot":"grok-auth","directoryMode":448,"durableMountPath":"/var/lib/spawnfile/daimon/grok-subscription-realm","fileMode":384,"maxCredentialBytes":65536},"healthResponseSchema":{"additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"state":{"enum":["starting","running","stopping","stopped","idle","failed"]}},"required":["agentId","state"],"type":"object"},"maxItems":32,"type":"array"},"state":{"enum":["starting","running","stopping","stopped"]},"version":{"const":"noopolis.daimon.organization-runtime-health.v1"}},"required":["version","state","agents"],"type":"object"},"operatorDrain":{"authorization":"control-bearer","blockedReason":"operator_stop","drainRoute":"POST /v2/drain","queuedWakes":"retained","response":"workAvailabilityResponseSchema","resumeClearsOperatorStop":false,"resumeRoute":"POST /v2/resume","runningTurns":"finish","scope":"process"},"organizationRuntimeConfigSchema":{"$id":"noopolis.daimon.organization-runtime.v1","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"attention":{"additionalProperties":false,"properties":{"maxBatchBytes":{"maximum":12000,"minimum":1024,"type":"integer"},"maxBatchMessages":{"maximum":32,"minimum":1,"type":"integer"},"maxExecutions":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"maxTokens":{"maximum":9007199254740991,"minimum":1,"type":"integer"}},"type":"object"},"engine":{"additionalProperties":false,"allOf":[{"if":{"properties":{"kind":{"const":"grok"}}},"then":{"dependentRequired":{"model":["reasoningEffort"],"reasoningEffort":["model"]},"properties":{"codexSandbox":false,"model":{"enum":["grok-4.6","grok-4.5","grok-build"]},"reasoningEffort":{"enum":["low","medium","high"]}}}},{"if":{"properties":{"kind":{"const":"agy"}}},"then":{"properties":{"codexSandbox":false,"model":false,"reasoningEffort":false}}}],"properties":{"codexSandbox":{"additionalProperties":false,"properties":{"mode":{"const":"workspace-write"},"networkAccess":{"const":false},"webSearch":{"const":"disabled"}},"required":["mode","networkAccess","webSearch"],"type":"object"},"kind":{"enum":["codex","grok","agy"]},"model":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"reasoningEffort":{"enum":["none","minimal","low","medium","high","xhigh","max","ultra","persistent"]}},"required":["kind"],"type":"object"},"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"instructions":{"maxLength":16384,"minLength":1,"pattern":"\\S","type":"string"},"mcp":{"items":{"additionalProperties":false,"properties":{"args":{"items":{"maxLength":4096,"type":"string"},"maxItems":32,"type":"array"},"authSecretEnv":{"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"command":{"pattern":"^/","type":"string"},"env":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"maxLength":4096,"minLength":1,"type":"string"},"tools":{"items":{"maxLength":4096,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"transport":{"enum":["stdio","sse","streamable_http"]},"url":{"type":"string"}},"required":["name","transport","args","env","tools"],"type":"object"},"maxItems":8,"type":"array"},"memory":{"additionalProperties":false,"properties":{"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"source":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"tokenBudget":{"maximum":1000000,"minimum":1,"type":"integer"}},"required":["runtimeHomePath"],"type":"object"},"moltnet":{"additionalProperties":false,"properties":{"cliPath":{"pattern":"^/","type":"string"},"configPath":{"pattern":"^/","type":"string"},"networks":{"items":{"additionalProperties":false,"properties":{"dms":{"type":"boolean"},"id":{"minLength":1,"type":"string"},"rooms":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true}},"required":["id","rooms","dms"],"type":"object"},"maxItems":16,"type":"array"}},"required":["cliPath","configPath","networks"],"type":"object"},"name":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"recording":{"additionalProperties":false,"properties":{"directory":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"},"keepMs":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"snapshots":{"items":{"additionalProperties":false,"properties":{"id":{"pattern":"^[A-Za-z0-9._-]{1,128}$","type":"string"},"path":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"}},"required":["id","path"],"type":"object"},"maxItems":16,"type":"array","uniqueItems":true}},"required":["directory","keepMs","snapshots"],"type":"object"},"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"workspacePath":{"maxLength":4096,"pattern":"^/","type":"string"}},"required":["id","name","instructions","workspacePath","runtimeHomePath","engine"],"type":"object"},"maxItems":32,"minItems":1,"type":"array"},"host":{"additionalProperties":false,"properties":{"bindHost":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"controlTokenEnv":{"maxLength":4096,"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"port":{"maximum":65535,"minimum":1,"type":"integer"}},"required":["bindHost","port","controlTokenEnv"],"type":"object"},"version":{"const":"noopolis.daimon.organization-runtime.v1"}},"required":["version","host","agents"],"type":"object"},"organizationRuntimeConfigV2Schema":{"$id":"noopolis.daimon.organization-runtime.v2","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"attention":{"additionalProperties":false,"properties":{"maxBatchBytes":{"maximum":12000,"minimum":1024,"type":"integer"},"maxBatchMessages":{"maximum":32,"minimum":1,"type":"integer"},"maxExecutions":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"maxTokens":{"maximum":9007199254740991,"minimum":1,"type":"integer"}},"type":"object"},"engine":{"additionalProperties":false,"allOf":[{"if":{"properties":{"kind":{"const":"grok"}}},"then":{"dependentRequired":{"model":["reasoningEffort"],"reasoningEffort":["model"]},"properties":{"codexSandbox":false,"model":{"enum":["grok-4.6","grok-4.5","grok-build"]},"reasoningEffort":{"enum":["low","medium","high"]}}}},{"if":{"properties":{"kind":{"const":"agy"}}},"then":{"properties":{"codexSandbox":false,"model":false,"reasoningEffort":false}}}],"properties":{"codexSandbox":{"additionalProperties":false,"properties":{"mode":{"const":"workspace-write"},"networkAccess":{"const":false},"webSearch":{"const":"disabled"}},"required":["mode","networkAccess","webSearch"],"type":"object"},"kind":{"enum":["codex","grok","agy"]},"model":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"reasoningEffort":{"enum":["none","minimal","low","medium","high","xhigh","max","ultra","persistent"]}},"required":["kind"],"type":"object"},"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"instructions":{"maxLength":16384,"minLength":1,"pattern":"\\S","type":"string"},"mcp":{"items":{"additionalProperties":false,"properties":{"args":{"items":{"maxLength":4096,"type":"string"},"maxItems":32,"type":"array"},"authSecretEnv":{"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"command":{"pattern":"^/","type":"string"},"env":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"maxLength":4096,"minLength":1,"type":"string"},"tools":{"items":{"maxLength":4096,"minLength":1,"type":"string"},"maxItems":32,"minItems":1,"type":"array","uniqueItems":true},"transport":{"enum":["stdio","sse","streamable_http"]},"url":{"type":"string"}},"required":["name","transport","args","env","tools"],"type":"object"},"maxItems":8,"type":"array"},"memory":{"additionalProperties":false,"properties":{"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"source":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"tokenBudget":{"maximum":1000000,"minimum":1,"type":"integer"}},"required":["runtimeHomePath"],"type":"object"},"moltnet":{"additionalProperties":false,"properties":{"cliPath":{"pattern":"^/","type":"string"},"configPath":{"pattern":"^/","type":"string"},"networks":{"items":{"additionalProperties":false,"properties":{"dms":{"type":"boolean"},"id":{"minLength":1,"type":"string"},"rooms":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true}},"required":["id","rooms","dms"],"type":"object"},"maxItems":16,"type":"array"}},"required":["cliPath","configPath","networks"],"type":"object"},"name":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"recording":{"additionalProperties":false,"properties":{"directory":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"},"keepMs":{"maximum":9007199254740991,"minimum":1,"type":"integer"},"snapshots":{"items":{"additionalProperties":false,"properties":{"id":{"pattern":"^[A-Za-z0-9._-]{1,128}$","type":"string"},"path":{"maxLength":4096,"pattern":"^/[^\\u0000]*$","type":"string"}},"required":["id","path"],"type":"object"},"maxItems":16,"type":"array","uniqueItems":true}},"required":["directory","keepMs","snapshots"],"type":"object"},"runtimeHomePath":{"maxLength":4096,"pattern":"^/","type":"string"},"schedule":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"disabled"}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"interval_ms":{"maximum":31536000000,"minimum":1,"type":"integer"},"jitter_seconds":{"maximum":3600,"minimum":0,"type":"integer"},"kind":{"const":"every"},"prompt":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["kind","interval_ms","prompt"],"type":"object"},{"additionalProperties":false,"properties":{"cron":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"jitter_seconds":{"maximum":3600,"minimum":0,"type":"integer"},"kind":{"const":"cron"},"prompt":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"timezone":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["kind","cron","timezone","prompt"],"type":"object"}]},"workspacePath":{"maxLength":4096,"pattern":"^/","type":"string"}},"required":["id","name","instructions","workspacePath","runtimeHomePath","engine","schedule"],"type":"object"},"maxItems":32,"minItems":1,"type":"array"},"host":{"additionalProperties":false,"properties":{"bindHost":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"controlTokenEnv":{"maxLength":4096,"pattern":"^[A-Za-z_][A-Za-z0-9_]*$","type":"string"},"port":{"maximum":65535,"minimum":1,"type":"integer"}},"required":["bindHost","port","controlTokenEnv"],"type":"object"},"version":{"const":"noopolis.daimon.organization-runtime.v2"}},"required":["version","host","agents"],"type":"object"},"supportedEngineKinds":["agy","codex","grok"],"version":"noopolis.daimon.runtime-contract-manifest.v5","wakeAcceptanceTypes":["manual","message","schedule","external"],"wakeMoments":{"captureDeadlineMs":60000,"completionSuffix":".complete","configField":"agents[].recording","finalizationDeadlineMs":1000,"maxManifestBytes":134217728,"maxRowBytes":4194304,"maxSnapshotEntries":200000,"maxSnapshotRoots":16,"rowsFile":"wake-moments.jsonl","snapshotsDirectory":"snapshots","version":"noopolis.daimon.wake-moment.v1"},"wakeRequestSchema":{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"event":{"additionalProperties":false,"properties":{"id":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"kind":{"enum":["manual","message","schedule","external"]},"occurredAt":{"format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$","type":"string"},"text":{"maxLength":4096,"type":"string"},"version":{"const":"noopolis.daimon.wake.v1"}},"required":["version","id","kind","text","occurredAt"],"type":"object"}},"required":["agentId","event"],"type":"object"},"wakeResultSchema":{"oneOf":[{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"durationMs":{"minimum":0,"type":"integer"},"status":{"const":"completed"},"text":{"maxLength":4096,"type":"string"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","text","durationMs"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["unauthorized","unknown_agent","queue_full","durable_inbox_required"]},"status":{"const":"rejected"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"type":"string"},"code":{"const":"invalid_request"},"status":{"const":"rejected"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"enum":["host_stopping","host_stopped","queued_wake_stopped","active_wake_aborted"]},"status":{"const":"stopped"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"},{"additionalProperties":false,"properties":{"agentId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"},"code":{"const":"engine_failed"},"status":{"const":"failed"},"version":{"const":"noopolis.daimon.wake-result.v1"},"wakeId":{"maxLength":4096,"minLength":1,"pattern":"\\S","type":"string"}},"required":["version","status","agentId","wakeId","code"],"type":"object"}]},"workAvailabilityResponseSchema":{"additionalProperties":false,"properties":{"agents":{"items":{"additionalProperties":false,"properties":{"agent_id":{"type":"string"},"budget":{"additionalProperties":false,"properties":{"agent_executions_remaining":{"minimum":0,"type":"integer"},"agent_executions_used":{"minimum":0,"type":"integer"},"agent_tokens_remaining":{"minimum":0,"type":"integer"},"agent_tokens_used":{"minimum":0,"type":"integer"},"armed":{"type":"boolean"},"epoch":{"type":"string"},"executions_remaining":{"minimum":0,"type":"integer"},"executions_used":{"minimum":0,"type":"integer"},"reason":{"type":"string"},"state":{"enum":["available","paused","stopped"]},"tokens_remaining":{"minimum":0,"type":"integer"},"tokens_used":{"minimum":0,"type":"integer"}},"required":["armed","epoch","state","executions_used","executions_remaining","tokens_used","tokens_remaining","agent_executions_used","agent_tokens_used"],"type":"object"},"deferred":{"minimum":0,"type":"integer"},"error":{"type":"string"},"pending":{"minimum":0,"type":"integer"},"running":{"type":"boolean"}},"required":["agent_id","pending","running","deferred","budget"],"type":"object"},"maxItems":32,"type":"array"},"drain":{"additionalProperties":false,"properties":{"since":{"type":"string"},"state":{"enum":["draining","drained"]}},"required":["state","since"],"type":"object"},"state":{"enum":["running","paused","stopped"]},"version":{"const":"noopolis.daimon.work-availability.v1"}},"required":["version","state","agents"],"type":"object"},"workBlockedSchema":{"additionalProperties":false,"properties":{"reason":{"enum":["operator_stop","ledger_unavailable","host_stopping","host_stopped","queue_full"]},"retry_after_ms":{"maximum":300000,"minimum":1000,"type":"integer"},"version":{"const":"noopolis.daimon.work-blocked.v1"}},"required":["version","reason","retry_after_ms"],"type":"object"}}
@@ -0,0 +1 @@
1
+ sha256:e39551277c6727c8807b1247e759f57addcee3f17f1405ebc927179647d64de6
@@ -0,0 +1,8 @@
1
+ import { canonicalJson } from "../contracts/canonicalJson.js";
2
+ import { AGY_SUBSCRIPTION_REALM, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION } from "../contracts/runtimeContractManifest.js";
3
+ export { AGY_SUBSCRIPTION_REALM, canonicalJson, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION };
4
+ export type RuntimeContractManifest = typeof RUNTIME_CONTRACT_MANIFEST;
5
+ export type EngineCredentialKind = keyof typeof ENGINE_CREDENTIAL_MATERIAL;
6
+ export type EngineCredentialSlot = (typeof ENGINE_CREDENTIAL_MATERIAL)[EngineCredentialKind]["sourceSlot"];
7
+ export declare const canonicalRuntimeContractManifest: () => string;
8
+ //# sourceMappingURL=contractManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contractManifest.d.ts","sourceRoot":"","sources":["../../src/runtime/contractManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,wCAAwC,EACxC,yBAAyB,EACzB,iCAAiC,EAClC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,wCAAwC,EACxC,yBAAyB,EACzB,iCAAiC,EAClC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,OAAO,yBAAyB,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,0BAA0B,CAAC;AAC3E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC;AAE3G,eAAO,MAAM,gCAAgC,QAAO,MAAkD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { canonicalJson } from "../contracts/canonicalJson.js";
2
+ import { AGY_SUBSCRIPTION_REALM, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION } from "../contracts/runtimeContractManifest.js";
3
+ export { AGY_SUBSCRIPTION_REALM, canonicalJson, ENGINE_CREDENTIAL_MATERIAL, GROK_ENGINE_BROKER, GROK_SUBSCRIPTION_REALM, ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION, RUNTIME_CONTRACT_MANIFEST, RUNTIME_CONTRACT_MANIFEST_VERSION };
4
+ export const canonicalRuntimeContractManifest = () => canonicalJson(RUNTIME_CONTRACT_MANIFEST);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * How long a turn's capabilities outlive the turn's own wall-clock limit.
3
+ *
4
+ * A capability that expires before its turn does strands the worker mid-turn:
5
+ * on 2026-10-05 a 30-minute turn kept a fixed 15-minute grant, lost every tool
6
+ * at minute 16 (MCP 403, mcp_refused=expired) and then timed out unfiled. The
7
+ * turn timer is what ends a turn; the grant only has to not end it first.
8
+ */
9
+ export declare const ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS = 60000;
10
+ export declare const engineBrokerCapabilityTtlMs: (turnTimeoutMs: number) => number;
11
+ export declare class EngineBrokerCapabilities {
12
+ private readonly grants;
13
+ issue(agentId: string, turnId: string, ttlMs?: number, maxRequests?: number): string;
14
+ authorize(agentId: string, turnId: string, token: string): boolean;
15
+ authorizeToken(token: string): Readonly<{
16
+ agentId: string;
17
+ turnId: string;
18
+ }> | undefined;
19
+ /**
20
+ * Which grant a token names and why it would be refused, *without* spending
21
+ * it.
22
+ *
23
+ * The facade needs this on its refusal path alone. A 403 it cannot attribute
24
+ * to a turn is a 403 that seals as nothing at all, and a turn whose every
25
+ * request was refused then reads exactly like a healthy one — the silence
26
+ * `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
27
+ * no turn and stays unattributed; nothing here returns the token, the grant
28
+ * or the agent's capability, only the turn id and a closed reason.
29
+ */
30
+ classifyToken(token: string): Readonly<{
31
+ turnId: string;
32
+ state: "live" | "expired" | "exhausted";
33
+ }> | undefined;
34
+ inspectToken(token: string): Readonly<{
35
+ agentId: string;
36
+ turnId: string;
37
+ }> | undefined;
38
+ revoke(turnId: string): void;
39
+ }
40
+ //# sourceMappingURL=engineBrokerCapabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineBrokerCapabilities.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerCapabilities.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,QAAS,CAAC;AAC7D,eAAO,MAAM,2BAA2B,GAAI,eAAe,MAAM,KAAG,MAAgE,CAAC;AAIrI,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;IAC1E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAc,EAAE,WAAW,SAAK,GAAG,MAAM;IAMrF,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAKlE,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS;IAQxF;;;;;;;;;;OAUG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAA;KAAE,CAAC,GAAG,SAAS;IAW/G,YAAY,CAAC,KAAK,EAAC,MAAM,GAAE,QAAQ,CAAC;QAAC,OAAO,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAA;KAAC,CAAC,GAAC,SAAS;IAC7E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAC7B"}
@@ -0,0 +1,69 @@
1
+ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
2
+ /**
3
+ * How long a turn's capabilities outlive the turn's own wall-clock limit.
4
+ *
5
+ * A capability that expires before its turn does strands the worker mid-turn:
6
+ * on 2026-10-05 a 30-minute turn kept a fixed 15-minute grant, lost every tool
7
+ * at minute 16 (MCP 403, mcp_refused=expired) and then timed out unfiled. The
8
+ * turn timer is what ends a turn; the grant only has to not end it first.
9
+ */
10
+ export const ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS = 60_000;
11
+ export const engineBrokerCapabilityTtlMs = (turnTimeoutMs) => turnTimeoutMs + ENGINE_BROKER_CAPABILITY_TTL_MARGIN_MS;
12
+ export class EngineBrokerCapabilities {
13
+ grants = new Map();
14
+ issue(agentId, turnId, ttlMs = 15 * 60_000, maxRequests = 64) {
15
+ if (ttlMs < 1 || maxRequests < 1)
16
+ throw new TypeError("invalid broker capability policy");
17
+ const token = randomBytes(32).toString("base64url");
18
+ this.grants.set(turnId, { agentId, turnId, digest: hash(token), expiresAt: Date.now() + ttlMs, maxRequests, requests: 0 });
19
+ return token;
20
+ }
21
+ authorize(agentId, turnId, token) {
22
+ const grant = this.grants.get(turnId);
23
+ const candidate = hash(token);
24
+ if (grant === undefined || grant.agentId !== agentId || grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
25
+ return false;
26
+ grant.requests += 1;
27
+ return true;
28
+ }
29
+ authorizeToken(token) {
30
+ const candidate = hash(token);
31
+ for (const grant of this.grants.values()) {
32
+ if (grant.expiresAt <= Date.now() || grant.requests >= grant.maxRequests || !timingSafeEqual(grant.digest, candidate))
33
+ continue;
34
+ grant.requests += 1;
35
+ return { agentId: grant.agentId, turnId: grant.turnId };
36
+ }
37
+ return undefined;
38
+ }
39
+ /**
40
+ * Which grant a token names and why it would be refused, *without* spending
41
+ * it.
42
+ *
43
+ * The facade needs this on its refusal path alone. A 403 it cannot attribute
44
+ * to a turn is a 403 that seals as nothing at all, and a turn whose every
45
+ * request was refused then reads exactly like a healthy one — the silence
46
+ * `engineBrokerMcpCallLog.ts` exists to end. A token no grant matches names
47
+ * no turn and stays unattributed; nothing here returns the token, the grant
48
+ * or the agent's capability, only the turn id and a closed reason.
49
+ */
50
+ classifyToken(token) {
51
+ const candidate = hash(token);
52
+ for (const grant of this.grants.values()) {
53
+ if (!timingSafeEqual(grant.digest, candidate))
54
+ continue;
55
+ // Budget before expiry: the TTL outlives every declared turn limit, so an
56
+ // exhausted grant is the reachable refusal and the actionable answer.
57
+ if (grant.requests >= grant.maxRequests)
58
+ return { turnId: grant.turnId, state: "exhausted" };
59
+ return { turnId: grant.turnId, state: grant.expiresAt <= Date.now() ? "expired" : "live" };
60
+ }
61
+ return undefined;
62
+ }
63
+ inspectToken(token) { const candidate = hash(token); for (const grant of this.grants.values()) {
64
+ if (grant.expiresAt > Date.now() && grant.requests < grant.maxRequests && timingSafeEqual(grant.digest, candidate))
65
+ return { agentId: grant.agentId, turnId: grant.turnId };
66
+ } return undefined; }
67
+ revoke(turnId) { const grant = this.grants.get(turnId); grant?.digest.fill(0); this.grants.delete(turnId); }
68
+ }
69
+ const hash = (value) => createHash("sha256").update(value).digest();
@@ -0,0 +1,55 @@
1
+ import { type Socket } from "node:net";
2
+ import type { EngineBrokerInferenceFailureCode, EngineBrokerInferenceResponse } from "./engineBrokerInferenceProtocol.js";
3
+ import type { EngineBrokerTurnLimitOverrides } from "./engineBrokerTurnAccounting.js";
4
+ import type { GrokBrokerModel, GrokBrokerReasoningEffort } from "./grokBrokerModelPolicy.js";
5
+ import type { GrokInferencePurpose } from "./inferenceUsageLedger.js";
6
+ import type { GrokBrokerProviderClockObservation } from "./grokBrokerProviderClock.js";
7
+ export type EngineBrokerInferenceGrant = Omit<Extract<EngineBrokerInferenceResponse, {
8
+ kind: "inference_grant";
9
+ }>, "version" | "kind" | "requestId">;
10
+ /** A refused grant request; `code` is closed (`auth_stale` is the stale shared realm, `grant_limit` the live-grant cap). */
11
+ export declare class EngineBrokerInferenceGrantRefused extends Error {
12
+ readonly code: EngineBrokerInferenceFailureCode;
13
+ constructor(code: EngineBrokerInferenceFailureCode);
14
+ }
15
+ /**
16
+ * What the organization runtime asks of a brokered turn beyond the prompt:
17
+ * `limits` may only lower the registration's declared limits, and `model`,
18
+ * when the agent declared one, must equal the model the broker sealed.
19
+ */
20
+ export type EngineBrokerTurnOptions = Readonly<{
21
+ limits?: EngineBrokerTurnLimitOverrides;
22
+ model?: string;
23
+ processClock?: string;
24
+ slot?: number;
25
+ /** Sealed observation on completion, failure and replay; sink errors never change the turn. */
26
+ onProviderClock?: (observation: GrokBrokerProviderClockObservation) => void;
27
+ }>;
28
+ export interface EngineBrokerTurnClient {
29
+ turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
30
+ }
31
+ export declare class EngineBrokerControlClient implements EngineBrokerTurnClient {
32
+ private readonly socketPath;
33
+ /** Internal transport seam; the production client always opens the Unix socket. */
34
+ private readonly connect;
35
+ constructor(socketPath?: string,
36
+ /** Internal transport seam; the production client always opens the Unix socket. */
37
+ connect?: (path: string) => Socket);
38
+ ready(): Promise<void>;
39
+ /**
40
+ * Evaluator side (organization uid only; the native relay enforces it):
41
+ * borrow the broker credential for one sequential lane of judge or optimizer
42
+ * requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
43
+ * a broker that cannot answer rejects with `engine broker unavailable`.
44
+ */
45
+ requestInferenceGrant(request: Readonly<{
46
+ model: GrokBrokerModel;
47
+ reasoningEffort: GrokBrokerReasoningEffort;
48
+ purpose: GrokInferencePurpose;
49
+ }>): Promise<EngineBrokerInferenceGrant>;
50
+ releaseInferenceGrant(grantId: string): Promise<boolean>;
51
+ resetSlot(slot: number): Promise<void>;
52
+ private exchange;
53
+ turn(agentId: string, wakeId: string, prompt: string, mcpEndpoint: string, signal?: AbortSignal, options?: EngineBrokerTurnOptions): Promise<string>;
54
+ }
55
+ //# sourceMappingURL=engineBrokerControlClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineBrokerControlClient.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerControlClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEzD,OAAO,KAAK,EAAE,gCAAgC,EAAgC,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAExJ,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAevF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC;AACrJ,4HAA4H;AAC5H,qBAAa,iCAAkC,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,gCAAgC;gBAAtC,IAAI,EAAE,gCAAgC;CAC5D;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,MAAM,CAAC,EAAE,8BAA8B,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9F,+FAA+F;IAC/F,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,kCAAkC,KAAK,IAAI,CAAC;CAC7E,CAAC,CAAC;AACH,MAAM,WAAW,sBAAsB;IAAG,IAAI,CAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,WAAW,EAAC,MAAM,EAAC,MAAM,CAAC,EAAC,WAAW,EAAC,OAAO,CAAC,EAAC,uBAAuB,GAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAAE;AACrL,qBAAa,yBAA0B,YAAW,sBAAsB;IAEpE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,mFAAmF;IACnF,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,UAAU,SAA2C;IACtE,mFAAmF;IAClE,OAAO,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAA6C;IAErF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B5B;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAC,QAAQ,CAAC;QAAC,KAAK,EAAC,eAAe,CAAC;QAAA,eAAe,EAAC,yBAAyB,CAAC;QAAA,OAAO,EAAC,oBAAoB,CAAA;KAAC,CAAC,GAAE,OAAO,CAAC,0BAA0B,CAAC;IAM3K,qBAAqB,CAAC,OAAO,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC;IAMtD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,OAAO,CAAC,QAAQ;IA6BV,IAAI,CACR,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EACpE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,GAAE,uBAA4B,GAC1D,OAAO,CAAC,MAAM,CAAC;CA+EnB"}
@@ -0,0 +1,228 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { createConnection } from "node:net";
3
+ import { ENGINE_BROKER_VERSION, EngineBrokerProtocolMismatch, encodeEngineBrokerFrame, EngineBrokerFrameDecoder, parseEngineBrokerResponse, parseEngineBrokerSlot } from "./engineBrokerProtocol.js";
4
+ import { ENGINE_BROKER_MCP_REFUSAL_REASONS } from "./engineBrokerMcpCallLog.js";
5
+ /**
6
+ * What the broker saw of the worker's MCP tool calls on a failed turn
7
+ * (`engineBrokerMcpCallLog.ts`). Absent for a turn with no observation at all;
8
+ * `outstanding` names every call that started and was never answered, with how
9
+ * long it had been waiting — the one thing a completion-only tool receipt can
10
+ * never say.
11
+ */
12
+ const renderMcpCalls = (calls) => calls === undefined ? "" : `; mcp=${calls.answered}/${calls.started} answered${calls.undecoded === 0 ? "" : `; mcp_undecoded=${calls.undecoded}`}${calls.outstanding.length === 0 ? "" : `; mcp_outstanding=${calls.outstanding.map((call) => `${call.name}@${call.outstandingMs}ms`).join(",")}`}${renderMcpRefusals(calls.refusals)}${renderMcpTunnels(calls.tunnels)}`;
13
+ /** The refusals the facade never relayed, by reason class, and only the classes that happened: a turn refused 403 must not read as a turn that was served. */
14
+ const renderMcpRefusals = (refusals) => { if (refusals === undefined)
15
+ return ""; const named = ENGINE_BROKER_MCP_REFUSAL_REASONS.filter((reason) => refusals[reason] > 0); return named.length === 0 ? "" : `; mcp_refused=${named.map((reason) => `${reason}:${refusals[reason]}`).join(",")}`; };
16
+ /** The session's GET SSE tunnels: how many closed of how many opened, and each one still open with its age and whether the mount ever pushed through it. */
17
+ const renderMcpTunnels = (tunnels) => tunnels === undefined ? "" : `; mcp_get=${tunnels.closed}/${tunnels.opened} closed, ${tunnels.delivered} delivered${tunnels.open.length === 0 ? "" : `; mcp_get_open=${tunnels.open.map((tunnel) => `${tunnel.openMs}ms/${tunnel.delivered ? "delivered" : "silent"}`).join(",")}`}`;
18
+ /** A refused grant request; `code` is closed (`auth_stale` is the stale shared realm, `grant_limit` the live-grant cap). */
19
+ export class EngineBrokerInferenceGrantRefused extends Error {
20
+ code;
21
+ constructor(code) {
22
+ super(`engine broker inference grant refused (${code})`);
23
+ this.code = code;
24
+ }
25
+ }
26
+ export class EngineBrokerControlClient {
27
+ socketPath;
28
+ connect;
29
+ constructor(socketPath = "/run/daimon-engine-broker/control.sock",
30
+ /** Internal transport seam; the production client always opens the Unix socket. */
31
+ connect = (path) => createConnection({ path })) {
32
+ this.socketPath = socketPath;
33
+ this.connect = connect;
34
+ }
35
+ async ready() {
36
+ const requestId = randomUUID();
37
+ const socket = this.connect(this.socketPath);
38
+ const decoder = new EngineBrokerFrameDecoder();
39
+ await new Promise((resolve, reject) => {
40
+ let settled = false;
41
+ const fail = (error) => {
42
+ if (settled)
43
+ return;
44
+ settled = true;
45
+ socket.destroy();
46
+ reject(controlFailure(error));
47
+ };
48
+ socket.once("error", fail);
49
+ socket.once("close", fail);
50
+ socket.once("connect", () => socket.write(encodeEngineBrokerFrame({
51
+ version: ENGINE_BROKER_VERSION, kind: "health", requestId
52
+ })));
53
+ socket.on("data", (chunk) => {
54
+ try {
55
+ for (const value of decoder.push(chunk)) {
56
+ const response = parseEngineBrokerResponse(value);
57
+ if (response.kind !== "ready" || response.requestId !== requestId || settled)
58
+ throw new Error();
59
+ settled = true;
60
+ socket.destroy();
61
+ resolve();
62
+ }
63
+ }
64
+ catch (error) {
65
+ fail(error);
66
+ }
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Evaluator side (organization uid only; the native relay enforces it):
72
+ * borrow the broker credential for one sequential lane of judge or optimizer
73
+ * requests. Refusals reject with {@link EngineBrokerInferenceGrantRefused};
74
+ * a broker that cannot answer rejects with `engine broker unavailable`.
75
+ */
76
+ async requestInferenceGrant(request) {
77
+ const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "request_inference_grant", requestId: randomUUID(), model: request.model, reasoningEffort: request.reasoningEffort, purpose: request.purpose });
78
+ if (response.kind === "inference_grant_refused")
79
+ throw new EngineBrokerInferenceGrantRefused(response.code);
80
+ if (response.kind !== "inference_grant" || response.model !== request.model || response.reasoningEffort !== request.reasoningEffort || response.purpose !== request.purpose)
81
+ throw new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
82
+ const { version: _version, kind: _kind, requestId: _requestId, ...grant } = response;
83
+ return grant;
84
+ }
85
+ async releaseInferenceGrant(grantId) {
86
+ const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "release_inference_grant", requestId: randomUUID(), grantId });
87
+ if (response.kind === "inference_grant_refused")
88
+ throw new EngineBrokerInferenceGrantRefused(response.code);
89
+ if (response.kind !== "inference_grant_released" || response.grantId !== grantId)
90
+ throw new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
91
+ return response.released;
92
+ }
93
+ async resetSlot(slot) {
94
+ const response = await this.exchange({ version: ENGINE_BROKER_VERSION, kind: "reset_slot", requestId: randomUUID(), slot: parseEngineBrokerSlot(slot) });
95
+ if (response.kind !== "slot_reset" || response.slot !== slot)
96
+ throw new Error("engine broker reset unavailable");
97
+ }
98
+ exchange(request) {
99
+ const socket = this.connect(this.socketPath);
100
+ const decoder = new EngineBrokerFrameDecoder();
101
+ return new Promise((resolve, reject) => {
102
+ let settled = false;
103
+ const fail = (error) => {
104
+ if (settled)
105
+ return;
106
+ settled = true;
107
+ socket.destroy();
108
+ reject(controlFailure(error));
109
+ };
110
+ socket.once("error", fail);
111
+ socket.once("close", fail);
112
+ socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request)));
113
+ socket.on("data", (chunk) => {
114
+ try {
115
+ for (const value of decoder.push(chunk)) {
116
+ const response = parseEngineBrokerResponse(value);
117
+ if (settled || response.requestId !== request.requestId ||
118
+ (response.kind !== "inference_grant" && response.kind !== "inference_grant_released" &&
119
+ response.kind !== "inference_grant_refused" && response.kind !== "slot_reset"))
120
+ throw new Error();
121
+ settled = true;
122
+ socket.destroy();
123
+ resolve(response);
124
+ }
125
+ }
126
+ catch (error) {
127
+ fail(error);
128
+ }
129
+ });
130
+ });
131
+ }
132
+ async turn(agentId, wakeId, prompt, mcpEndpoint, signal, options = {}) {
133
+ const configured = process.env.DAIMON_ENGINE_BROKER_SLOT;
134
+ const slot = options.slot ?? (configured === undefined ? undefined : parseEngineBrokerSlot(/^(0|[1-9][0-9]*)$/u.test(configured) ? Number(configured) : NaN));
135
+ if (slot !== undefined)
136
+ parseEngineBrokerSlot(slot);
137
+ const turnId = createHash("sha256").update(`${slot === undefined ? "" : `${slot}\0`}${agentId}\0${wakeId}`).digest("hex");
138
+ const requestId = randomUUID();
139
+ const request = {
140
+ version: ENGINE_BROKER_VERSION, kind: "start_turn", requestId, turnId, agentId, wakeId, prompt, mcpEndpoint,
141
+ ...(slot === undefined ? {} : { slot }),
142
+ ...(options.limits === undefined ? {} : { limits: options.limits }),
143
+ ...(options.processClock === undefined ? {} : { processClock: options.processClock })
144
+ };
145
+ const socket = this.connect(this.socketPath);
146
+ const decoder = new EngineBrokerFrameDecoder();
147
+ return new Promise((resolve, reject) => {
148
+ let accepted = false;
149
+ let settled = false;
150
+ const fail = (error) => {
151
+ if (settled)
152
+ return;
153
+ settled = true;
154
+ cleanup();
155
+ reject(controlFailure(error));
156
+ };
157
+ const cleanup = () => {
158
+ signal?.removeEventListener("abort", abort);
159
+ socket.destroy();
160
+ };
161
+ const abort = () => fail();
162
+ signal?.addEventListener("abort", abort, { once: true });
163
+ if (signal?.aborted)
164
+ return abort();
165
+ socket.once("connect", () => socket.write(encodeEngineBrokerFrame(request)));
166
+ socket.on("data", (chunk) => {
167
+ try {
168
+ for (const value of decoder.push(chunk)) {
169
+ const response = parseEngineBrokerResponse(value);
170
+ if ((response.kind !== "accepted" && response.kind !== "completed" && response.kind !== "failed") ||
171
+ response.requestId !== requestId || response.turnId !== turnId)
172
+ throw new Error();
173
+ if (response.kind === "accepted") {
174
+ if (accepted)
175
+ throw new Error();
176
+ accepted = true;
177
+ continue;
178
+ }
179
+ if (!accepted || settled)
180
+ throw new Error();
181
+ settled = true;
182
+ cleanup();
183
+ if (response.providerClock !== undefined) {
184
+ try {
185
+ options.onProviderClock?.(response.providerClock);
186
+ }
187
+ catch { /* Observation cannot discard a terminal result. */ }
188
+ }
189
+ if (options.model !== undefined && response.model !== options.model) {
190
+ reject(new Error(`engine broker turn used model ${response.model}, not the declared ${options.model}`));
191
+ return;
192
+ }
193
+ if (response.kind === "completed") {
194
+ if (response.cleanupDiagnostic !== undefined) {
195
+ try {
196
+ console.warn(`daimon: engine broker ${response.cleanupDiagnostic}`);
197
+ }
198
+ catch {
199
+ // An operational warning must not discard completed work.
200
+ }
201
+ }
202
+ resolve(response.text);
203
+ }
204
+ else {
205
+ const limit = response.limitReason === "none" ? "" : `; limit=${response.limitReason}`;
206
+ const detail = response.diagnostic;
207
+ const reason = detail?.reason === undefined ? "" : `; reason=${detail.reason}`;
208
+ const diagnostic = detail === undefined ? "" :
209
+ `; ${detail.stage}/${detail.failureClass}; exit=${detail.exitCode}; signal=${detail.termSignal}${reason}`;
210
+ const cleanupDiagnostic = response.cleanupDiagnostic === undefined ? "" : `; ${response.cleanupDiagnostic}`;
211
+ reject(new Error(`engine broker turn failed (${response.code}${limit}${diagnostic}${renderMcpCalls(response.mcpCalls)}${cleanupDiagnostic})`));
212
+ }
213
+ }
214
+ }
215
+ catch (error) {
216
+ fail(error);
217
+ }
218
+ });
219
+ socket.once("error", fail);
220
+ socket.once("close", () => { if (!settled)
221
+ fail(); });
222
+ });
223
+ }
224
+ }
225
+ function controlFailure(error) {
226
+ return error instanceof EngineBrokerProtocolMismatch ? error :
227
+ new Error(`engine broker unavailable (requires control protocol ${ENGINE_BROKER_VERSION})`);
228
+ }
@@ -0,0 +1,12 @@
1
+ export type BrokerCredentialJournal = Readonly<{
2
+ version: "noopolis.daimon.broker-credential-journal.v1";
3
+ state: "refreshing" | "promoted" | "stale";
4
+ generation: number;
5
+ sourceDigest: string;
6
+ promotedDigest?: string;
7
+ ancestorDigests?: readonly string[];
8
+ }>;
9
+ export declare const BROKER_CREDENTIAL_MAX_ANCESTORS = 900;
10
+ export declare function parseBrokerCredentialJournal(value: unknown): BrokerCredentialJournal;
11
+ export declare function recoverBrokerCredentialJournal(journal: BrokerCredentialJournal, authorityDigest: string): "ready" | "stale";
12
+ //# sourceMappingURL=engineBrokerCredentialJournal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineBrokerCredentialJournal.d.ts","sourceRoot":"","sources":["../../src/runtime/engineBrokerCredentialJournal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,8CAA8C,CAAC;IAAC,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AAEhQ,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAGnD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAWpF;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAI3H"}
@@ -0,0 +1,26 @@
1
+ // At most 61 KiB including the rest of the record; all readers allow 64 KiB.
2
+ export const BROKER_CREDENTIAL_MAX_ANCESTORS = 900;
3
+ const DIGEST = /^[a-f0-9]{64}$/u;
4
+ export function parseBrokerCredentialJournal(value) {
5
+ if (value === null || typeof value !== "object" || Array.isArray(value))
6
+ throw new TypeError("invalid credential journal");
7
+ const input = value;
8
+ const fields = input.state === "refreshing" ? ["version", "state", "generation", "sourceDigest"] : ["version", "state", "generation", "sourceDigest", "promotedDigest"];
9
+ if (Object.hasOwn(input, "ancestorDigests")) {
10
+ fields.push("ancestorDigests");
11
+ if (!Array.isArray(input.ancestorDigests) || input.ancestorDigests.length > BROKER_CREDENTIAL_MAX_ANCESTORS ||
12
+ input.ancestorDigests.some((entry) => typeof entry !== "string" || !DIGEST.test(entry)) ||
13
+ new Set(input.ancestorDigests).size !== input.ancestorDigests.length)
14
+ throw new TypeError("invalid credential journal");
15
+ }
16
+ if (Object.keys(input).length !== fields.length || fields.some((key) => !Object.hasOwn(input, key)) || input.version !== "noopolis.daimon.broker-credential-journal.v1" || !["refreshing", "promoted", "stale"].includes(String(input.state)) || !Number.isSafeInteger(input.generation) || input.generation < 0 || !DIGEST.test(String(input.sourceDigest)) || (input.state !== "refreshing" && !DIGEST.test(String(input.promotedDigest))))
17
+ throw new TypeError("invalid credential journal");
18
+ return input;
19
+ }
20
+ export function recoverBrokerCredentialJournal(journal, authorityDigest) {
21
+ if (journal.state === "stale")
22
+ return "stale";
23
+ if (journal.state === "refreshing")
24
+ return authorityDigest === journal.sourceDigest ? "ready" : "stale";
25
+ return authorityDigest === journal.promotedDigest ? "ready" : "stale";
26
+ }