@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 @@
1
+ {"version":3,"file":"runtimeContractManifest.d.ts","sourceRoot":"","sources":["../../src/contracts/runtimeContractManifest.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iCAAiC,EAAG,8CAAuD,CAAC;AACzG,eAAO,MAAM,wCAAwC,EAAG,kDAA2D,CAAC;AACpH,eAAO,MAAM,0BAA0B;;;;;;;;CAE7B,CAAC;AACX,eAAO,MAAM,uBAAuB;;;;;;;;CAQ1B,CAAC;AACX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoHrB,CAAC;AACX,eAAO,MAAM,sBAAsB;;;;;;;CAOzB,CAAC;AASX,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC5B,CAAC"}
@@ -0,0 +1,181 @@
1
+ import { WORK_AVAILABILITY_SCHEMA, WORK_BLOCKED_SCHEMA } from "./attentionContract.js";
2
+ import { GROK_BROKER_MODELS, GROK_BROKER_REASONING_EFFORTS, GROK_WORKER_MAX_TURNS, GROK_WORKER_TOOL_IDS, GROK_WORKER_VISIBLE_TOOLS } from "./grokWorkerContract.js";
3
+ import { ORGANIZATION_RUNTIME_CONFIG_SCHEMA, ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA, ORGANIZATION_RUNTIME_MAX_AGENTS, ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS } from "./organizationRuntimeContract.js";
4
+ export const RUNTIME_CONTRACT_MANIFEST_VERSION = "noopolis.daimon.runtime-contract-manifest.v3";
5
+ export const ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION = "noopolis.daimon.organization-runtime-activity.v2";
6
+ export const ENGINE_CREDENTIAL_MATERIAL = {
7
+ codex: { sourceSlot: "codex-auth", sourceRelativePath: ".daimon-inbound/codex-auth", destinationRelativePath: ".codex/auth.json", directoryMode: 0o700, fileMode: 0o600 }
8
+ };
9
+ export const GROK_SUBSCRIPTION_REALM = {
10
+ agentCredentialRelativePath: ".grok/auth.json",
11
+ bootstrapMountPath: "/var/lib/spawnfile/daimon/grok-bootstrap-auth",
12
+ bootstrapSourceSlot: "grok-auth",
13
+ directoryMode: 0o700,
14
+ durableMountPath: "/var/lib/spawnfile/daimon/grok-subscription-realm",
15
+ fileMode: 0o600,
16
+ maxCredentialBytes: 64 * 1024
17
+ };
18
+ export const GROK_ENGINE_BROKER = {
19
+ nativeAbiVersion: 2,
20
+ nativeExecutablePath: "/opt/daimon/bin/daimon-engine-broker",
21
+ grokExecutablePath: "/usr/local/bin/grok",
22
+ registrationPath: "/etc/daimon-engine-broker/registrations.bin",
23
+ credentialHomePath: "/var/lib/spawnfile/daimon/grok-subscription-realm",
24
+ turnStorePath: "/var/lib/spawnfile/daimon/grok-subscription-realm/turns",
25
+ controlSocketPath: "/run/daimon-engine-broker/control.sock",
26
+ backendSocketPath: "/run/daimon-engine-broker/backend.sock",
27
+ launcherSocketPath: "/run/daimon-engine-broker/launcher.sock",
28
+ serviceConfigPath: "/etc/daimon-engine-broker/service.json",
29
+ providerProxy: { host: "127.0.0.1", port: 43_123 },
30
+ mcpFacade: { host: "127.0.0.1", port: 43_124, path: "/mcp" },
31
+ identities: { organizationUid: 2_000, brokerUid: 2_100, firstWorkerUid: 2_200 },
32
+ grokCliVersion: "1.0.34",
33
+ grokCliBuild: "3736acbc8658",
34
+ grokCliArtifacts: {
35
+ arm64: { url: "https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-aarch64", sha256: "39ab87666877d64ef3a40aa60fbe0c3b6a6acd7001b78fe60e2c76bb6cfc4a94", bytes: 136_090_504 },
36
+ x64: { url: "https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-x86_64", sha256: "be5905e107d2b8b5f3c142d21ecfe4c8fd32a913d2fd551b788707930c4dc80d", bytes: 163_035_648 }
37
+ },
38
+ worker: {
39
+ modelId: "daimon-broker-grok",
40
+ models: GROK_BROKER_MODELS,
41
+ reasoningEfforts: GROK_BROKER_REASONING_EFFORTS,
42
+ defaultModel: "grok-4.6",
43
+ defaultReasoningEffort: "low",
44
+ toolIds: GROK_WORKER_TOOL_IDS,
45
+ visibleTools: GROK_WORKER_VISIBLE_TOOLS,
46
+ maxTurns: GROK_WORKER_MAX_TURNS,
47
+ systemPromptSha256: "2c31c0085a54a4efbf9c0cf0b8124c56e47f38691b7f0c7fa233a74abaa8ddf8",
48
+ // sha256 of `renderGrokBrokerWorkerConfig({ model, reasoningEffort })`, the only accepted config.toml bytes.
49
+ configSha256: {
50
+ "grok-4.6": { low: "ab58499ac32678097c146479896f2b8a8e2b0e39aea22dc0a60b6227e370538e", medium: "df1a5cc84346e7f6bf6090492fbd19faaefb42953e3bb2e8c6cbc0572242403f", high: "65b0212564fb74042b1503d293fb8d3620276033264c0efade2a539ca09218e3" },
51
+ "grok-4.5": { low: "8247127c3625ff7c5d8d527a53596b89ec6557a821ac46cfd00bd122b90daff6", medium: "59288cee61297bb8c002097061a48f77b09d310754187a253ee089f7172a9155", high: "c63c3387ce92d94ec3f690abfe98942afcd7c9e17ff84816bbe751f340ab251f" },
52
+ "grok-build": { low: "fb343f2809903f26d21681470943235031f946e99085542fd89555eb7782cbb5", medium: "8a587ef75c90eab70d19b24583e60051d6fba9d90c558839fdbb15588b4cc656", high: "a23724e00d670caee185ba7690d2daa868173e53905cf446f5329666f01ab4e3" }
53
+ },
54
+ // Worker `GROK_HOME` layout the broker attests before every turn. The home and
55
+ // its `sessions/` directory are root-owned, worker-group writable and sticky so
56
+ // Grok can create its own state but never replace a root-owned file.
57
+ home: {
58
+ directory: { uid: 0, group: "worker", mode: 0o1771 },
59
+ sessionsDirectory: { relativePath: "sessions", uid: 0, group: "worker", mode: 0o1771 },
60
+ readOnlyFiles: { names: ["config.toml", "managed_config.toml", "requirements.toml", "sandbox.toml", "trusted_folders.toml"], uid: 0, gid: 0, mode: 0o444 },
61
+ sandboxEvents: { relativePath: "sessions/sandbox-events.jsonl", owner: "worker", group: "broker", mode: 0o640 },
62
+ // The launcher exports TMPDIR=<worker home>/tmp; Grok's strict profile grants TMPDIR read-write.
63
+ privateTmp: { relativeToWorkerHome: "tmp", owner: "worker", mode: 0o700 },
64
+ // Strict also grants shared /tmp and /var/tmp read-write and refuses to start if either is
65
+ // denied, so the deployment keeps them from every worker by mode: root-owned, a non-worker
66
+ // group (< 2200), others read-only (Grok needs to open the directory) and no search/write.
67
+ sharedTmp: { paths: ["/tmp", "/var/tmp"], uid: 0, maxGroupExclusive: 2_200, otherMode: 0o4, mode: 0o1774 },
68
+ // The organization runtime home of a brokered Grok agent: traverse-only for the
69
+ // worker group so the worker can reach `tool-output/` and nothing else (no group
70
+ // read, no group write, no world bits; `physicalReadiness.ts` refuses anything else).
71
+ organizationRuntimeHome: { owner: "organization", group: "worker", mode: 0o710 },
72
+ // Spilled tool output the worker reads with read_file: setgid directory in the worker's group,
73
+ // files written 0640 by the runtime, never other-readable.
74
+ spillDirectory: { relativeToRuntimeHome: "tool-output", owner: "organization", group: "worker", mode: 0o2750, fileMode: 0o640 }
75
+ }
76
+ },
77
+ bounds: { promptBytes: 65_536, capabilityBytes: 4_096, capabilityBundleBytes: 8_196, outputBytes: 262_144 },
78
+ // Accounting and limits (P2). The broker is the single sealed usage writer.
79
+ controlProtocolVersion: "noopolis.daimon.engine-broker.v2",
80
+ turnRecordVersions: ["noopolis.daimon.engine-broker-turn.v1", "noopolis.daimon.engine-broker-turn.v2"],
81
+ serviceConfigVersions: ["noopolis.daimon.engine-broker-service.v1", "noopolis.daimon.engine-broker-service.v2"],
82
+ turnLimits: {
83
+ keys: ["maxRequests", "maxTokens", "timeoutMs"],
84
+ v1Defaults: { maxRequests: 32, maxTokens: 300_000, timeoutMs: 240_000 },
85
+ bounds: { maxRequests: [1, GROK_WORKER_MAX_TURNS], maxTokens: [1, 10_000_000], timeoutMs: [1_000, 3_600_000] },
86
+ limitReasons: ["tokens", "requests", "timeout", "none"],
87
+ wakeMayOnlyLower: true,
88
+ tokenCeilingOvershoot: "at-most-one-request",
89
+ maxInFlightRequests: 1,
90
+ // A per-request usage block above this is implausible (beyond the model
91
+ // context window) and treated as invalid rather than added to any total.
92
+ requestUsageMaxTokens: 500_000,
93
+ // A request whose response carries no valid usage is charged this estimate.
94
+ missingUsageEstimate: { inputBytesPerToken: 2, outputTokens: 4_096 }
95
+ },
96
+ wakeLimitEnvironment: { timeoutMs: "DAIMON_ENGINE_WAKE_TIMEOUT_MS", maxTokens: "DAIMON_ENGINE_WAKE_TOKEN_CEILING" },
97
+ // Evaluator inference grants (P2c). Judges and the optimizer (organization uid
98
+ // only, over the control socket) borrow the broker's Grok credential through
99
+ // the provider proxy; they never hold it, and their spend never reaches the
100
+ // subject usage ledger or wake fuse.
101
+ inferenceGrants: {
102
+ requestKinds: ["request_inference_grant", "release_inference_grant"],
103
+ purposes: ["judge", "optimizer"],
104
+ tokenPrefix: "inference_",
105
+ ttlMs: 600_000,
106
+ limits: { maxRequests: 64, maxTokens: 2_000_000 },
107
+ maxLiveGrants: 8,
108
+ maxInFlightRequestsPerGrant: 1,
109
+ // Top-level request members Grok 1.0.34 sends for a Paideia judge/optimizer call
110
+ // (live stub capture); `tools` and `tool_choice` are refused outright.
111
+ bodyMembers: ["messages", "model", "reasoning_effort", "response_format", "stream", "stream_options"],
112
+ messageRoles: ["system", "user", "assistant"],
113
+ failureCodes: ["auth_stale", "grant_limit", "invalid_request", "unavailable"],
114
+ ledgerVersion: "noopolis.daimon.inference-usage.v1",
115
+ ledgerDedupeKey: ["grant", "request"],
116
+ client: {
117
+ modelId: "daimon-inference-grok",
118
+ envKey: "DAIMON_INFERENCE_GRANT",
119
+ // sha256 of `renderGrokInferenceClientConfig` for the production proxy base URL and this env key.
120
+ configSha256: {
121
+ "grok-4.6": { low: "79314d039f787e4ebfec7dacf57adc969086b948f564dec008f0ed6367e6062f", medium: "6f538de0547c0c4e6a3f04ae08595ceadadabb06b75f6b6ee4c428744bb95cd8", high: "5652656effa82f0c4f09cf8226b16e6140332a5a358b571194bb5563312367ac" },
122
+ "grok-4.5": { low: "a07f7436f1268bb399ec233c65d3b3d8fb99a11a1f175f8da1ca133c9367bc74", medium: "1f4c0d4dad1f3b09419b5739db6423a09e0049abc091594c64123a75dd53dfb9", high: "ffbc33728b821e9854fbc7c93601e599225da421ecfd6ebf10d314afcc28d6f2" },
123
+ "grok-build": { low: "ca15c6a562a008227d39c51d3a3a83715663089b3784e8b46debb1fb67b3c4a1", medium: "01783fb6beadcf6f8486fff0836820ad43fab5662b812a907fe9cfdb83e9804d", high: "98d16f2b7d12f4eb540d625c853e51d227933e204923e43e8b9b4176f10aca2c" }
124
+ }
125
+ }
126
+ },
127
+ projectionVersion: "noopolis.daimon.grok-broker-projection.v1",
128
+ slotPreflightVersion: "noopolis.daimon.grok-slot-preflight.v2",
129
+ artifacts: {
130
+ sourceSha256: "dd39aacfece496cc6528f6acdb4f1066a848a0fb5b0961f5c70b0ba00440dc24",
131
+ x64Sha256: "67e3624d3198e9c59e1ffafa4eca7c895dfe265d5b8bb0614cb547b68b8b93a7",
132
+ arm64Sha256: "c07d22225ff968bc289e5ddf0981cdd5d64040eee6e3ea45da7d03e1439dea98"
133
+ }
134
+ };
135
+ export const AGY_SUBSCRIPTION_REALM = {
136
+ durableMountPath: "/var/lib/spawnfile/daimon/agy-subscription-realm",
137
+ unlockMountPath: "/var/lib/spawnfile/daimon/agy-unlock-secret",
138
+ unlockSourceSlot: "agy-unlock-secret",
139
+ directoryMode: 0o700,
140
+ fileMode: 0o600,
141
+ maxUnlockBytes: 4_096
142
+ };
143
+ const text = { type: "string", minLength: 1, maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS, pattern: "\\S" };
144
+ const boundedText = { type: "string", maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS };
145
+ const timestamp = { type: "string", format: "date-time", pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" };
146
+ const wakeEvent = { type: "object", additionalProperties: false, required: ["version", "id", "kind", "text", "occurredAt"], properties: { version: { const: "noopolis.daimon.wake.v1" }, id: text, kind: { enum: ["manual", "message", "schedule", "external"] }, text: boundedText, occurredAt: timestamp } };
147
+ const wakeResultBase = { version: { const: "noopolis.daimon.wake-result.v1" }, agentId: text, wakeId: text };
148
+ const activityItem = { type: "object", additionalProperties: false, required: ["id", "agentId", "kind", "occurredAt"], properties: { id: { type: "string", 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}$" }, agentId: text, wakeId: text, kind: { enum: ["wake_started", "wake_completed", "wake_rejected", "wake_aborted", "agent_stopped"] }, occurredAt: timestamp } };
149
+ export const RUNTIME_CONTRACT_MANIFEST = {
150
+ version: RUNTIME_CONTRACT_MANIFEST_VERSION,
151
+ 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"],
152
+ organizationRuntimeConfigSchema: ORGANIZATION_RUNTIME_CONFIG_SCHEMA,
153
+ organizationRuntimeConfigV2Schema: ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA,
154
+ wakeAcceptanceTypes: ["manual", "message", "schedule", "external"],
155
+ deliverySemantics: {
156
+ activeDeliveryIdempotency: "unbounded-until-terminal",
157
+ terminalReceiptHorizon: 2_048,
158
+ recovery: "at-least-once-with-stable-wake-id",
159
+ concurrentSameAgentTurns: false,
160
+ externalEffectsExactlyOnce: false
161
+ },
162
+ attention: { enabledBy: "agents[].attention", defaultMaxBatchMessages: 8, defaultMaxBatchBytes: 12000, idleDispatch: "immediate", busyDispatch: "bounded-pending-message-batch", completion: "explicit-per-delivery", unhandled: "deferred-until-new-input", accounting: "execution-start-reservations" },
163
+ workAvailabilityResponseSchema: WORK_AVAILABILITY_SCHEMA,
164
+ workBlockedSchema: WORK_BLOCKED_SCHEMA,
165
+ supportedEngineKinds: ["agy", "codex", "grok"],
166
+ engineCredentialMaterial: ENGINE_CREDENTIAL_MATERIAL,
167
+ grokSubscriptionRealm: GROK_SUBSCRIPTION_REALM,
168
+ grokEngineBroker: GROK_ENGINE_BROKER,
169
+ agySubscriptionRealm: AGY_SUBSCRIPTION_REALM,
170
+ wakeRequestSchema: { type: "object", additionalProperties: false, required: ["agentId", "event"], properties: { agentId: text, event: wakeEvent } },
171
+ wakeResultSchema: { oneOf: [
172
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "text", "durationMs"], properties: { ...wakeResultBase, status: { const: "completed" }, text: boundedText, durationMs: { type: "integer", minimum: 0 } } },
173
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "code"], properties: { ...wakeResultBase, status: { const: "rejected" }, code: { enum: ["unauthorized", "unknown_agent", "queue_full", "durable_inbox_required"] } } },
174
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "code"], properties: { version: { const: "noopolis.daimon.wake-result.v1" }, status: { const: "rejected" }, agentId: { type: "string", maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS }, wakeId: { type: "string", maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS }, code: { const: "invalid_request" } } },
175
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "code"], properties: { ...wakeResultBase, status: { const: "stopped" }, code: { enum: ["host_stopping", "host_stopped", "queued_wake_stopped", "active_wake_aborted"] } } },
176
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "code"], properties: { ...wakeResultBase, status: { const: "failed" }, code: { const: "engine_failed" } } }
177
+ ] },
178
+ healthResponseSchema: { type: "object", additionalProperties: false, required: ["version", "state", "agents"], properties: { version: { const: "noopolis.daimon.organization-runtime-health.v1" }, state: { enum: ["starting", "running", "stopping", "stopped"] }, agents: { type: "array", maxItems: ORGANIZATION_RUNTIME_MAX_AGENTS, items: { type: "object", additionalProperties: false, required: ["agentId", "state"], properties: { agentId: text, state: { enum: ["starting", "running", "stopping", "stopped", "idle", "failed"] } } } } } },
179
+ activityResponseSchema: { type: "object", additionalProperties: false, required: ["version", "items"], properties: { version: { const: "noopolis.daimon.organization-runtime-activity.v1" }, items: { type: "array", maxItems: 100, items: activityItem }, nextCursor: { type: "string", minLength: 1, maxLength: 16, pattern: "^(0|[1-9][0-9]{0,15})$" } } },
180
+ activityV2ResponseSchema: { type: "object", additionalProperties: false, required: ["version", "items"], properties: { version: { const: ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION }, state: { enum: ["running", "stopped"] }, executions: { type: "array", maxItems: ORGANIZATION_RUNTIME_MAX_AGENTS, items: { type: "object", additionalProperties: false, required: ["agent_id", "execution_id", "state", "delivery_ids"], properties: { agent_id: text, execution_id: { type: "string" }, state: { const: "running" }, delivery_ids: { type: "array", maxItems: 32, items: text } } } }, items: { type: "array", maxItems: 2_112, items: { type: "object", additionalProperties: false, required: ["version", "acceptance_id", "agent_id", "delivery_id", "request_digest", "state", "accepted_at", "updated_at", "active"], properties: { version: { const: "noopolis.daimon.wake-receipt-status.v2" }, acceptance_id: { type: "string" }, agent_id: text, delivery_id: text, request_digest: { type: "string" }, state: { enum: ["accepted", "running", "completed", "failed", "stopped"] }, accepted_at: timestamp, updated_at: timestamp, active: { type: "boolean" }, execution_id: { type: "string" }, deferred: { type: "boolean" }, text: { type: "string", maxLength: 16384 }, queue_position: { type: "integer", minimum: 1 }, code: { enum: ["engine_failed", "host_stopped", "host_stopping", "queued_wake_stopped", "active_wake_aborted", "queue_full", "unknown_agent"] } } } } } }
181
+ };
@@ -0,0 +1,4 @@
1
+ /** Redacts provider credentials before text crosses any reply or diagnostic boundary. */
2
+ export declare function redactCredentialText(value: unknown, exactSecrets?: readonly string[], maxBytes?: number): string;
3
+ export declare function redactCredentialError(error: unknown, exactSecrets?: readonly string[], maxBytes?: number): Error;
4
+ //# sourceMappingURL=credentialRedaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentialRedaction.d.ts","sourceRoot":"","sources":["../../src/core/credentialRedaction.ts"],"names":[],"mappings":"AASA,yFAAyF;AACzF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,YAAY,GAAE,SAAS,MAAM,EAAO,EACpC,QAAQ,GAAE,MAA0B,GACnC,MAAM,CAoBR;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,YAAY,GAAE,SAAS,MAAM,EAAO,EACpC,QAAQ,GAAE,MAA0B,GACnC,KAAK,CAEP"}
@@ -0,0 +1,28 @@
1
+ const DEFAULT_MAX_BYTES = 16_384;
2
+ const truncateUtf8 = (value, maxBytes) => {
3
+ if (Buffer.byteLength(value, "utf8") <= maxBytes)
4
+ return value;
5
+ let result = Buffer.from(value, "utf8").subarray(0, maxBytes).toString("utf8");
6
+ while (result.endsWith("\uFFFD"))
7
+ result = result.slice(0, -1);
8
+ return result;
9
+ };
10
+ /** Redacts provider credentials before text crosses any reply or diagnostic boundary. */
11
+ export function redactCredentialText(value, exactSecrets = [], maxBytes = DEFAULT_MAX_BYTES) {
12
+ let result = String(value);
13
+ for (const secret of [...new Set(exactSecrets.filter((entry) => entry.length > 0))]
14
+ .sort((left, right) => right.length - left.length)) {
15
+ result = result.split(secret).join("[REDACTED]");
16
+ }
17
+ result = result
18
+ .replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/giu, "Bearer [REDACTED]")
19
+ .replace(/\bmagt_v1_[A-Za-z0-9_-]{16,}\b/gu, "[REDACTED]")
20
+ .replace(/\b(?:sk|sk-proj|xai)-[A-Za-z0-9_-]{20,}\b/gu, "[REDACTED]")
21
+ .replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/gu, "[REDACTED]")
22
+ .replace(/("(?:api[_-]?key|authorization|client[_-]?secret|credential|key|password|secret|(?:access|refresh|id)[_-]?token|token)"\s*:\s*")([^"\\]*(?:\\.[^"\\]*)*)(")/giu, "$1[REDACTED]$3")
23
+ .replace(/\b(api[_-]?key|authorization|client[_-]?secret|credential|password|secret|(?:access|refresh|id)[_-]?token|token)\b(\s*[:=]\s*)(["']?)[^\s"',&]{8,}\3/giu, "$1$2[REDACTED]");
24
+ return truncateUtf8(result, maxBytes);
25
+ }
26
+ export function redactCredentialError(error, exactSecrets = [], maxBytes = DEFAULT_MAX_BYTES) {
27
+ return new Error(redactCredentialText(error instanceof Error ? error.message : error, exactSecrets, maxBytes));
28
+ }
@@ -6,9 +6,26 @@ export declare class McpToolTurnLimitError extends Error {
6
6
  export declare class McpWakeDeadlineError extends Error {
7
7
  constructor();
8
8
  }
9
+ /**
10
+ * A non-standard request AGY issues during its MCP handshake.
11
+ *
12
+ * Captured live from `agy --print … --output-format stream-json`, the client
13
+ * sends `initialize`, `notifications/initialized`, **`server/discover`**,
14
+ * `tools/list`, `tools/call`. `server/discover` is not in the MCP
15
+ * specification, and the throwaway probe that proved AGY's headless tool
16
+ * calling answered it with `{}`. Codex and Grok never send it.
17
+ *
18
+ * This server answers it the same way that working probe did, rather than the
19
+ * SDK default of `MethodNotFound`, because a refusal here is the one observable
20
+ * difference between this server and the one AGY is known to work against, and
21
+ * the cost of being wrong is that every AGY agent silently loses every tool.
22
+ * The allowance is exactly this one method: any other unknown method still gets
23
+ * `MethodNotFound`, so a genuine protocol mistake is never hidden.
24
+ */
25
+ export declare const AGY_SERVER_DISCOVER_METHOD: "server/discover";
9
26
  export interface PiToolMcpServerOptions {
10
- readonly maxToolTurns: number;
11
- readonly wakeDeadline: number;
27
+ readonly maxToolTurns?: number;
28
+ readonly wakeDeadline?: number;
12
29
  }
13
30
  export declare const createPiToolMcpServer: (tools: ToolDefinition[], options: PiToolMcpServerOptions) => Server;
14
31
  //# sourceMappingURL=toolServer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolServer.d.ts","sourceRoot":"","sources":["../../src/mcp/toolServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,qBAAa,qBAAsB,SAAQ,KAAK;gBAC3B,YAAY,EAAE,MAAM;CAIxC;AAED,qBAAa,oBAAqB,SAAQ,KAAK;;CAK9C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAqCD,eAAO,MAAM,qBAAqB,GAChC,OAAO,cAAc,EAAE,EACvB,SAAS,sBAAsB,KAC9B,MAmEF,CAAC"}
1
+ {"version":3,"file":"toolServer.d.ts","sourceRoot":"","sources":["../../src/mcp/toolServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,qBAAa,qBAAsB,SAAQ,KAAK;gBAC3B,YAAY,EAAE,MAAM;CAIxC;AAED,qBAAa,oBAAqB,SAAQ,KAAK;;CAK9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAG,iBAA0B,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAyDD,eAAO,MAAM,qBAAqB,GAChC,OAAO,cAAc,EAAE,EACvB,SAAS,sBAAsB,KAC9B,MAgEF,CAAC"}
@@ -13,6 +13,23 @@ export class McpWakeDeadlineError extends Error {
13
13
  this.name = "McpWakeDeadlineError";
14
14
  }
15
15
  }
16
+ /**
17
+ * A non-standard request AGY issues during its MCP handshake.
18
+ *
19
+ * Captured live from `agy --print … --output-format stream-json`, the client
20
+ * sends `initialize`, `notifications/initialized`, **`server/discover`**,
21
+ * `tools/list`, `tools/call`. `server/discover` is not in the MCP
22
+ * specification, and the throwaway probe that proved AGY's headless tool
23
+ * calling answered it with `{}`. Codex and Grok never send it.
24
+ *
25
+ * This server answers it the same way that working probe did, rather than the
26
+ * SDK default of `MethodNotFound`, because a refusal here is the one observable
27
+ * difference between this server and the one AGY is known to work against, and
28
+ * the cost of being wrong is that every AGY agent silently loses every tool.
29
+ * The allowance is exactly this one method: any other unknown method still gets
30
+ * `MethodNotFound`, so a genuine protocol mistake is never hidden.
31
+ */
32
+ export const AGY_SERVER_DISCOVER_METHOD = "server/discover";
16
33
  const jsonSchema = (parameters) => {
17
34
  if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
18
35
  throw new TypeError("Pi tool parameters must be a JSON schema object");
@@ -25,6 +42,25 @@ const toolResult = (result) => ({
25
42
  ? { structuredContent: Object.fromEntries(Object.entries(result.details)) }
26
43
  : {})
27
44
  });
45
+ /** Bound on the rendered Ajv violations, so a pathological schema cannot flood a turn. */
46
+ const MAX_SCHEMA_VIOLATION_BYTES = 2_048;
47
+ /**
48
+ * Why the arguments were rejected, in the schema's own words.
49
+ *
50
+ * A bare `Invalid arguments for tool X` tells an agent that its call was wrong
51
+ * and nothing about how, which leaves trial and error as the only way to learn
52
+ * a tool's argument shape. Ajv already knows which instance path failed and
53
+ * which keyword it failed on; saying so turns a guessing loop into one
54
+ * correction.
55
+ */
56
+ const schemaViolations = (validator) => {
57
+ const rendered = (validator.errors ?? [])
58
+ .map((issue) => `${issue.instancePath === "" ? "(root)" : issue.instancePath} ${issue.message ?? "is invalid"}`.trim())
59
+ .join("; ");
60
+ if (rendered.length === 0)
61
+ return "the arguments do not match the tool's declared input schema";
62
+ return rendered.length > MAX_SCHEMA_VIOLATION_BYTES ? `${rendered.slice(0, MAX_SCHEMA_VIOLATION_BYTES)}…` : rendered;
63
+ };
28
64
  const toolError = (error) => ({
29
65
  content: [{ type: "text", text: error instanceof Error ? `${error.name}: ${error.message}` : String(error) }],
30
66
  isError: true
@@ -34,16 +70,22 @@ const toolError = (error) => ({
34
70
  // The MCP mount deliberately has no Pi session context; `never` preserves typed positional checks.
35
71
  const NO_PI_EXTENSION_CONTEXT = undefined;
36
72
  const validateOptions = (options) => {
37
- if (!Number.isSafeInteger(options.maxToolTurns) || options.maxToolTurns < 1) {
73
+ if (options.maxToolTurns !== undefined && (!Number.isSafeInteger(options.maxToolTurns) || options.maxToolTurns < 1)) {
38
74
  throw new TypeError("maxToolTurns must be a positive safe integer");
39
75
  }
40
- if (!Number.isFinite(options.wakeDeadline)) {
76
+ if (options.wakeDeadline !== undefined && !Number.isFinite(options.wakeDeadline)) {
41
77
  throw new TypeError("wakeDeadline must be a finite epoch-millisecond deadline");
42
78
  }
43
79
  };
44
80
  export const createPiToolMcpServer = (tools, options) => {
45
81
  validateOptions(options);
46
82
  const server = new Server({ name: "daimon-pi-tools", version: "0.1.2" });
83
+ server.fallbackRequestHandler = async (request) => {
84
+ if (request.method !== AGY_SERVER_DISCOVER_METHOD) {
85
+ throw new McpError(ErrorCode.MethodNotFound, `Method not found: ${request.method}`);
86
+ }
87
+ return {};
88
+ };
47
89
  const validators = new Map(tools.map((tool) => {
48
90
  const schema = jsonSchema(tool.parameters);
49
91
  return [tool.name, new Ajv2020({ strict: false }).compile(schema)];
@@ -60,9 +102,9 @@ export const createPiToolMcpServer = (tools, options) => {
60
102
  }));
61
103
  server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
62
104
  try {
63
- if (Date.now() >= options.wakeDeadline)
105
+ if (options.wakeDeadline !== undefined && Date.now() >= options.wakeDeadline)
64
106
  throw new McpWakeDeadlineError();
65
- if (toolTurns >= options.maxToolTurns)
107
+ if (options.maxToolTurns !== undefined && toolTurns >= options.maxToolTurns)
66
108
  throw new McpToolTurnLimitError(options.maxToolTurns);
67
109
  const tool = tools.find((candidate) => candidate.name === request.params.name);
68
110
  const validator = validators.get(request.params.name);
@@ -71,29 +113,27 @@ export const createPiToolMcpServer = (tools, options) => {
71
113
  }
72
114
  const args = request.params.arguments ?? {};
73
115
  if (!validator(args)) {
74
- throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${tool.name}`);
116
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${tool.name}: ${schemaViolations(validator)}`);
75
117
  }
76
118
  toolTurns += 1;
77
119
  // Ajv validated this value against this tool's own schema immediately above.
78
120
  const validatedArgs = args;
79
- const deadlineController = new AbortController();
80
- const remainingMs = Math.max(0, options.wakeDeadline - Date.now());
81
- const deadlineTimer = setTimeout(() => deadlineController.abort(), remainingMs);
82
- const signal = extra.signal === undefined
83
- ? deadlineController.signal
84
- : AbortSignal.any([extra.signal, deadlineController.signal]);
85
- const deadline = new Promise((_resolve, reject) => {
121
+ const deadlineController = options.wakeDeadline === undefined ? undefined : new AbortController();
122
+ const remainingMs = options.wakeDeadline === undefined ? undefined : Math.max(0, options.wakeDeadline - Date.now());
123
+ const deadlineTimer = deadlineController === undefined ? undefined : setTimeout(() => deadlineController.abort(), remainingMs);
124
+ const signal = deadlineController === undefined ? extra.signal
125
+ : extra.signal === undefined ? deadlineController.signal : AbortSignal.any([extra.signal, deadlineController.signal]);
126
+ const deadline = deadlineController === undefined ? undefined : new Promise((_resolve, reject) => {
86
127
  deadlineController.signal.addEventListener("abort", () => reject(new McpWakeDeadlineError()), { once: true });
87
128
  });
88
129
  let result;
89
130
  try {
90
- result = await Promise.race([
91
- tool.execute(`mcp-tool-turn-${toolTurns}`, validatedArgs, signal, undefined, NO_PI_EXTENSION_CONTEXT),
92
- deadline
93
- ]);
131
+ const execution = tool.execute(`mcp-tool-turn-${toolTurns}`, validatedArgs, signal, undefined, NO_PI_EXTENSION_CONTEXT);
132
+ result = deadline === undefined ? await execution : await Promise.race([execution, deadline]);
94
133
  }
95
134
  finally {
96
- clearTimeout(deadlineTimer);
135
+ if (deadlineTimer !== undefined)
136
+ clearTimeout(deadlineTimer);
97
137
  }
98
138
  return toolResult(result);
99
139
  }
@@ -62,9 +62,9 @@ export declare const turnOutputCompletedEventId: (turnId: string) => string;
62
62
  export declare const replyCauseEventIds: (turnId: string) => string[];
63
63
  /**
64
64
  * Allocates the next contiguous seq number for `(run_id, stream_id)`,
65
- * persisted under `runtimeHome/telemetry/causal.seq.json`. Daimon runs at
66
- * most one wake at a time per agent (`PiAgentHandle.wakeQueue` serializes
67
- * them), so read-modify-write here does not need extra locking.
65
+ * persisted under `runtimeHome/telemetry/causal.seq.json`. Allocation is
66
+ * serialized in-process and mutually excluded across processes by a lock
67
+ * file; the counter is written atomically and fsynced.
68
68
  */
69
69
  export declare const nextCausalSeq: (input: {
70
70
  runId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"causalEvents.d.ts","sourceRoot":"","sources":["../../src/observability/causalEvents.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAG,0BAAmC,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,QAAQ,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,oBAAoB,CAAC;CACtC;AAED,wFAAwF;AACxF,MAAM,WAAW,yBAA0B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;I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B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,GACjC,OAAO,2BAA2B,KACjC,OAAO,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAe7C,CAAC;AAEL,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,GAClC,OAAO,4BAA4B,KAClC,OAAO,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAa9C,CAAC"}
@@ -1,6 +1,8 @@
1
- import { createHash } from "node:crypto";
2
- import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { constants } from "node:fs";
3
+ import { appendFile, open, readFile, rename, stat, unlink } from "node:fs/promises";
3
4
  import path from "node:path";
5
+ import { ensureRuntimeHomeDirectory } from "../runtime/runtimeHomeLayout.js";
4
6
  /**
5
7
  * Daimon's own copy of the `noopolis.causal-event.v1` wire envelope. Field-
6
8
  * for-field the canonical shape in `specs/causal-event.v1.schema.json` and
@@ -43,6 +45,8 @@ export const replyCauseEventIds = (turnId) => [turnOutputCompletedEventId(turnId
43
45
  const telemetryDir = (runtimeHomePath) => path.join(runtimeHomePath, "telemetry");
44
46
  const seqFilePath = (runtimeHomePath) => path.join(telemetryDir(runtimeHomePath), "causal.seq.json");
45
47
  const jsonlFilePath = (runtimeHomePath) => path.join(telemetryDir(runtimeHomePath), "causal.jsonl");
48
+ const STALE_LOCK_MS = 30_000;
49
+ const seqAllocationQueues = new Map();
46
50
  const readSeqStore = async (runtimeHomePath) => {
47
51
  try {
48
52
  const raw = await readFile(seqFilePath(runtimeHomePath), "utf8");
@@ -56,27 +60,111 @@ const readSeqStore = async (runtimeHomePath) => {
56
60
  }
57
61
  };
58
62
  const writeSeqStore = async (runtimeHomePath, store) => {
59
- await mkdir(telemetryDir(runtimeHomePath), { recursive: true });
60
- await writeFile(seqFilePath(runtimeHomePath), `${JSON.stringify(store, null, 2)}\n`, "utf8");
63
+ const directory = await ensureRuntimeHomeDirectory(runtimeHomePath, "telemetry");
64
+ const file = seqFilePath(runtimeHomePath);
65
+ const temporary = `${file}.${randomUUID()}.tmp`;
66
+ const handle = await open(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600);
67
+ try {
68
+ await handle.writeFile(`${JSON.stringify(store, null, 2)}\n`, "utf8");
69
+ await handle.sync();
70
+ }
71
+ finally {
72
+ await handle.close();
73
+ }
74
+ try {
75
+ await rename(temporary, file);
76
+ await syncDirectory(directory);
77
+ }
78
+ finally {
79
+ await unlink(temporary).catch((error) => {
80
+ if (error.code !== "ENOENT")
81
+ throw error;
82
+ });
83
+ }
84
+ };
85
+ const syncDirectory = async (directory) => {
86
+ const handle = await open(directory, constants.O_RDONLY);
87
+ try {
88
+ await handle.sync();
89
+ }
90
+ finally {
91
+ await handle.close();
92
+ }
93
+ };
94
+ const acquireSeqLock = async (lockPath) => {
95
+ const startedAt = Date.now();
96
+ let backoffMs = 2;
97
+ while (Date.now() - startedAt < 5_000) {
98
+ try {
99
+ const handle = await open(lockPath, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600);
100
+ await handle.close();
101
+ return;
102
+ }
103
+ catch (error) {
104
+ if (!(error && typeof error === "object" && "code" in error && error.code === "EEXIST"))
105
+ throw error;
106
+ }
107
+ try {
108
+ const observed = await stat(lockPath);
109
+ if (Date.now() - observed.mtimeMs > STALE_LOCK_MS) {
110
+ const confirmed = await stat(lockPath);
111
+ if (confirmed.mtimeMs === observed.mtimeMs) {
112
+ await unlink(lockPath).catch((error) => {
113
+ if (error.code !== "ENOENT")
114
+ throw error;
115
+ });
116
+ continue;
117
+ }
118
+ }
119
+ }
120
+ catch (error) {
121
+ if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT"))
122
+ throw error;
123
+ continue;
124
+ }
125
+ await new Promise((resolve) => setTimeout(resolve, backoffMs));
126
+ backoffMs = Math.min(backoffMs * 2, 25);
127
+ }
128
+ throw new Error(`Timed out acquiring causal sequence lock: ${lockPath}`);
61
129
  };
62
130
  /**
63
131
  * Allocates the next contiguous seq number for `(run_id, stream_id)`,
64
- * persisted under `runtimeHome/telemetry/causal.seq.json`. Daimon runs at
65
- * most one wake at a time per agent (`PiAgentHandle.wakeQueue` serializes
66
- * them), so read-modify-write here does not need extra locking.
132
+ * persisted under `runtimeHome/telemetry/causal.seq.json`. Allocation is
133
+ * serialized in-process and mutually excluded across processes by a lock
134
+ * file; the counter is written atomically and fsynced.
67
135
  */
68
136
  export const nextCausalSeq = async (input) => {
69
- const store = await readSeqStore(input.runtimeHomePath);
70
- const forRun = store[input.runId] ?? {};
71
- const next = (forRun[input.streamId] ?? 0) + 1;
72
- forRun[input.streamId] = next;
73
- store[input.runId] = forRun;
74
- await writeSeqStore(input.runtimeHomePath, store);
75
- return next;
137
+ const lockPath = path.resolve(telemetryDir(input.runtimeHomePath), "causal.seq.lock");
138
+ const previous = seqAllocationQueues.get(lockPath) ?? Promise.resolve();
139
+ const allocation = previous.catch(() => undefined).then(async () => {
140
+ await ensureRuntimeHomeDirectory(input.runtimeHomePath, "telemetry");
141
+ await acquireSeqLock(lockPath);
142
+ try {
143
+ const store = await readSeqStore(input.runtimeHomePath);
144
+ const forRun = store[input.runId] ?? {};
145
+ const next = (forRun[input.streamId] ?? 0) + 1;
146
+ forRun[input.streamId] = next;
147
+ store[input.runId] = forRun;
148
+ await writeSeqStore(input.runtimeHomePath, store);
149
+ return next;
150
+ }
151
+ finally {
152
+ await unlink(lockPath).catch((error) => {
153
+ if (error.code !== "ENOENT")
154
+ throw error;
155
+ });
156
+ }
157
+ });
158
+ seqAllocationQueues.set(lockPath, allocation);
159
+ void allocation.finally(() => {
160
+ if (seqAllocationQueues.get(lockPath) === allocation)
161
+ seqAllocationQueues.delete(lockPath);
162
+ }).catch(() => undefined);
163
+ return allocation;
76
164
  };
77
165
  /** Appends one CausalEvent record as a line of `runtimeHome/telemetry/causal.jsonl`. */
78
166
  export const appendCausalEvent = async (runtimeHomePath, event) => {
79
- await mkdir(telemetryDir(runtimeHomePath), { recursive: true });
167
+ await ensureRuntimeHomeDirectory(runtimeHomePath, "telemetry");
80
168
  await appendFile(jsonlFilePath(runtimeHomePath), `${JSON.stringify(event)}\n`, "utf8");
81
169
  };
82
170
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"orgObserver.d.ts","sourceRoot":"","sources":["../../src/observability/orgObserver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB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Z,GAAG,uBAAuB;IAa3B,SAAS,IAAI,YAAY,EAAE;IAgB3B,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAepG,eAAe,IAAI;QACjB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,wBAAwB,EAAE,MAAM,CAAC;QACjC,gBAAgB,EAAE,MAAM,CAAC;QACzB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;KACpB;IAaD,YAAY,IAAI,MAAM;IAchB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B/C,UAAU,IAAI,MAAM;CAoErB"}
@@ -1,5 +1,6 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
1
+ import { writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { ensureRuntimeHomeDirectory } from "../runtime/runtimeHomeLayout.js";
3
4
  const maxExcerptChars = 280;
4
5
  const excerpt = (text) => text.length <= maxExcerptChars ? text : `${text.slice(0, maxExcerptChars).trim()}...`;
5
6
  export const mentionsFrom = (text) => [...new Set([...text.matchAll(/@([a-z0-9-]+)/gi)].map((match) => match[1].toLowerCase()))];
@@ -110,8 +111,7 @@ export class OrgObserver {
110
111
  };
111
112
  }
112
113
  async write(runtimeRoot) {
113
- const telemetryDir = path.join(runtimeRoot, "telemetry");
114
- await mkdir(telemetryDir, { recursive: true });
114
+ const telemetryDir = await ensureRuntimeHomeDirectory(runtimeRoot, "telemetry");
115
115
  const summaryRecord = {
116
116
  assertions: this.assertions,
117
117
  behavior: this.behaviorSummary(),