@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 @@
1
+ {"version":3,"file":"runtimeContractManifest.d.ts","sourceRoot":"","sources":["../../src/contracts/runtimeContractManifest.ts"],"names":[],"mappings":"AAWA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyIrB,CAAC;AACX,eAAO,MAAM,sBAAsB;;;;;;;CAOzB,CAAC;AASX,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC5B,CAAC"}
@@ -0,0 +1,206 @@
1
+ import { GROK_BROKER_TASK_CLOCK } from "./grokBrokerTaskClock.js";
2
+ import { WAKE_MOMENTS } from "./wakeMomentContract.js";
3
+ import { OPERATOR_DRAIN, WORK_AVAILABILITY_SCHEMA, WORK_BLOCKED_SCHEMA } from "./attentionContract.js";
4
+ import { GROK_BROKER_MODELS, GROK_BROKER_REASONING_EFFORTS, GROK_WORKER_MAX_TURNS, GROK_WORKER_TOOL_IDS, GROK_WORKER_VISIBLE_TOOLS } from "./grokWorkerContract.js";
5
+ import { ORGANIZATION_RUNTIME_CONFIG_SCHEMA, ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA, ORGANIZATION_RUNTIME_MAX_AGENTS, ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS } from "./organizationRuntimeContract.js";
6
+ export const RUNTIME_CONTRACT_MANIFEST_VERSION = "noopolis.daimon.runtime-contract-manifest.v5";
7
+ export const ORGANIZATION_RUNTIME_ACTIVITY_V2_VERSION = "noopolis.daimon.organization-runtime-activity.v2";
8
+ export const ENGINE_CREDENTIAL_MATERIAL = {
9
+ codex: { sourceSlot: "codex-auth", sourceRelativePath: ".daimon-inbound/codex-auth", destinationRelativePath: ".codex/auth.json", directoryMode: 0o700, fileMode: 0o600 }
10
+ };
11
+ export const GROK_SUBSCRIPTION_REALM = {
12
+ agentCredentialRelativePath: ".grok/auth.json",
13
+ bootstrapMountPath: "/var/lib/spawnfile/daimon/grok-bootstrap-auth",
14
+ bootstrapSourceSlot: "grok-auth",
15
+ directoryMode: 0o700,
16
+ durableMountPath: "/var/lib/spawnfile/daimon/grok-subscription-realm",
17
+ fileMode: 0o600,
18
+ maxCredentialBytes: 64 * 1024
19
+ };
20
+ export const GROK_ENGINE_BROKER = {
21
+ nativeAbiVersion: 2,
22
+ nativeExecutablePath: "/opt/daimon/bin/daimon-engine-broker",
23
+ grokExecutablePath: "/usr/local/bin/grok",
24
+ registrationPath: "/etc/daimon-engine-broker/registrations.bin",
25
+ credentialHomePath: "/var/lib/spawnfile/daimon/grok-subscription-realm",
26
+ turnStorePath: "/var/lib/spawnfile/daimon/grok-subscription-realm/turns",
27
+ controlSocketPath: "/run/daimon-engine-broker/control.sock",
28
+ backendSocketPath: "/run/daimon-engine-broker/backend.sock",
29
+ launcherSocketPath: "/run/daimon-engine-broker/launcher.sock",
30
+ serviceConfigPath: "/etc/daimon-engine-broker/service.json",
31
+ providerProxy: { host: "127.0.0.1", port: 43_123 },
32
+ mcpFacade: { host: "127.0.0.1", port: 43_124, path: "/mcp" },
33
+ identities: { organizationUid: 2_000, brokerUid: 2_100, firstWorkerUid: 2_200 },
34
+ grokCliVersion: "1.0.34",
35
+ grokCliBuild: "3736acbc8658",
36
+ grokCliArtifacts: {
37
+ arm64: { url: "https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-aarch64", sha256: "39ab87666877d64ef3a40aa60fbe0c3b6a6acd7001b78fe60e2c76bb6cfc4a94", bytes: 136_090_504 },
38
+ x64: { url: "https://storage.googleapis.com/grok-build-public-artifacts/cli/grok-1.0.34-linux-x86_64", sha256: "be5905e107d2b8b5f3c142d21ecfe4c8fd32a913d2fd551b788707930c4dc80d", bytes: 163_035_648 }
39
+ },
40
+ worker: {
41
+ modelId: "daimon-broker-grok",
42
+ models: GROK_BROKER_MODELS,
43
+ reasoningEfforts: GROK_BROKER_REASONING_EFFORTS,
44
+ defaultModel: "grok-4.6",
45
+ defaultReasoningEffort: "low",
46
+ toolIds: GROK_WORKER_TOOL_IDS,
47
+ visibleTools: GROK_WORKER_VISIBLE_TOOLS,
48
+ maxTurns: GROK_WORKER_MAX_TURNS,
49
+ systemPromptSha256: "2c31c0085a54a4efbf9c0cf0b8124c56e47f38691b7f0c7fa233a74abaa8ddf8",
50
+ // sha256 of `renderGrokBrokerWorkerConfig({ model, reasoningEffort })`, the unchanged production config.toml bytes.
51
+ configSha256: {
52
+ "grok-4.6": { low: "ab58499ac32678097c146479896f2b8a8e2b0e39aea22dc0a60b6227e370538e", medium: "df1a5cc84346e7f6bf6090492fbd19faaefb42953e3bb2e8c6cbc0572242403f", high: "65b0212564fb74042b1503d293fb8d3620276033264c0efade2a539ca09218e3" },
53
+ "grok-4.5": { low: "8247127c3625ff7c5d8d527a53596b89ec6557a821ac46cfd00bd122b90daff6", medium: "59288cee61297bb8c002097061a48f77b09d310754187a253ee089f7172a9155", high: "c63c3387ce92d94ec3f690abfe98942afcd7c9e17ff84816bbe751f340ab251f" },
54
+ "grok-build": { low: "fb343f2809903f26d21681470943235031f946e99085542fd89555eb7782cbb5", medium: "8a587ef75c90eab70d19b24583e60051d6fba9d90c558839fdbb15588b4cc656", high: "a23724e00d670caee185ba7690d2daa868173e53905cf446f5329666f01ab4e3" }
55
+ },
56
+ // Slot-zero template pins. Other slots replace only FAKETIME_TIMESTAMP_FILE with slotFilePattern.
57
+ clockedConfigSha256: {
58
+ "grok-4.6": {
59
+ "low": "751f1dcd04983e5e5883df5a8fefa04f201e187e5ef1f344d3bf83f950830432",
60
+ "medium": "f1406f93a8091eb0c09e07321254a9c783a89b0bbf5548d9613d53a8d087a517",
61
+ "high": "203744f6f0dfc0bc80cfb896880497edfd9b3de4dcf33060e8ef4d2ef5f220a7"
62
+ },
63
+ "grok-4.5": {
64
+ "low": "3c4f3515b21c1bffb3fb770e2ecb4b918b6c43d5e77c1fd47e1e6698d1fedee7",
65
+ "medium": "9117e12b2f3f6fa045799592969cbaae1c2f3b1ea79330badac8655b9b41dd7a",
66
+ "high": "907d8967960c342b442d6d256b2585f3c85bd846a78578f596f0b605403d6d34"
67
+ },
68
+ "grok-build": {
69
+ "low": "a8c63ba910623a0686930c27db0733f4a2588c7fca9dd7da25c3f18027720ab5",
70
+ "medium": "6afcd2b90c0d19794f8c0d22147a0f011946a92e613f89dae98b0ca729313101",
71
+ "high": "6efddadc82c38020d3351829e54bb09fa456cd6d76ea1247902794d82a4a3ffa"
72
+ }
73
+ },
74
+ taskClock: GROK_BROKER_TASK_CLOCK,
75
+ // Worker `GROK_HOME` layout the broker attests before every turn. The home and
76
+ // its `sessions/` directory are root-owned, worker-group writable and sticky so
77
+ // Grok can create its own state but never replace a root-owned file.
78
+ home: {
79
+ directory: { uid: 0, group: "worker", mode: 0o1771 },
80
+ sessionsDirectory: { relativePath: "sessions", uid: 0, group: "worker", mode: 0o1771 },
81
+ readOnlyFiles: { names: ["config.toml", "managed_config.toml", "requirements.toml", "sandbox.toml", "trusted_folders.toml"], uid: 0, gid: 0, mode: 0o444 },
82
+ sandboxEvents: { relativePath: "sessions/sandbox-events.jsonl", owner: "worker", group: "broker", mode: 0o640 },
83
+ // The launcher exports TMPDIR=<worker home>/tmp; Grok's strict profile grants TMPDIR read-write.
84
+ privateTmp: { relativeToWorkerHome: "tmp", owner: "worker", mode: 0o700 },
85
+ // Strict also grants shared /tmp and /var/tmp read-write and refuses to start if either is
86
+ // denied, so the deployment keeps them from every worker by mode: root-owned, a non-worker
87
+ // group (< 2200), others read-only (Grok needs to open the directory) and no search/write.
88
+ sharedTmp: { paths: ["/tmp", "/var/tmp"], uid: 0, maxGroupExclusive: 2_200, otherMode: 0o4, mode: 0o1774 },
89
+ // The organization runtime home of a brokered Grok agent: traverse-only for the
90
+ // worker group so the worker can reach `tool-output/` and nothing else (no group
91
+ // read, no group write, no world bits; `physicalReadiness.ts` refuses anything else).
92
+ organizationRuntimeHome: { owner: "organization", group: "worker", mode: 0o710 },
93
+ // Spilled tool output the worker reads with read_file: setgid directory in the worker's group,
94
+ // files written 0640 by the runtime, never other-readable.
95
+ spillDirectory: { relativeToRuntimeHome: "tool-output", owner: "organization", group: "worker", mode: 0o2750, fileMode: 0o640 }
96
+ }
97
+ },
98
+ bounds: { promptBytes: 65_536, capabilityBytes: 4_096, capabilityBundleBytes: 8_196, outputBytes: 262_144 },
99
+ // Accounting and limits (P2). The broker is the single sealed usage writer.
100
+ controlProtocolVersion: "noopolis.daimon.engine-broker.v4",
101
+ turnRecordVersions: ["noopolis.daimon.engine-broker-turn.v1", "noopolis.daimon.engine-broker-turn.v2"],
102
+ serviceConfigVersions: ["noopolis.daimon.engine-broker-service.v1", "noopolis.daimon.engine-broker-service.v2", "noopolis.daimon.engine-broker-service.v3"],
103
+ slotRouting: { key: "slot", repeatedAgentIds: true, slotEnvironment: "DAIMON_ENGINE_BROKER_SLOT", resetRequest: "reset_slot", resetResponse: "slot_reset", turnStoreDirectory: "slot-{slot}", controlCaller: "organization", workersMayControl: false },
104
+ runRequestBudget: { maximumField: "maxRunRequests", storeField: "runRequestStore", fileName: "run-requests.json", includesInferenceGrants: true, countsCredentialRetries: true },
105
+ turnLimits: {
106
+ keys: ["maxRequests", "maxTokens", "timeoutMs"],
107
+ v1Defaults: { maxRequests: 32, maxTokens: 300_000, timeoutMs: 240_000 },
108
+ bounds: { maxRequests: [1, GROK_WORKER_MAX_TURNS], maxTokens: [1, 10_000_000], timeoutMs: [1_000, 3_600_000] },
109
+ limitReasons: ["tokens", "requests", "timeout", "none"],
110
+ wakeMayOnlyLower: true,
111
+ tokenCeilingOvershoot: "at-most-one-request",
112
+ maxInFlightRequests: 1,
113
+ // A per-request usage block above this is implausible (beyond the model
114
+ // context window) and treated as invalid rather than added to any total.
115
+ requestUsageMaxTokens: 500_000,
116
+ // A request whose response carries no valid usage is charged this estimate.
117
+ missingUsageEstimate: { inputBytesPerToken: 2, outputTokens: 4_096 }
118
+ },
119
+ wakeLimitEnvironment: { timeoutMs: "DAIMON_ENGINE_WAKE_TIMEOUT_MS", maxTokens: "DAIMON_ENGINE_WAKE_TOKEN_CEILING" },
120
+ // Evaluator inference grants (P2c). Judges and the optimizer (organization uid
121
+ // only, over the control socket) borrow the broker's Grok credential through
122
+ // the provider proxy; they never hold it, and their spend never reaches the
123
+ // subject usage ledger or wake fuse.
124
+ inferenceGrants: {
125
+ requestKinds: ["request_inference_grant", "release_inference_grant"],
126
+ purposes: ["judge", "optimizer"],
127
+ tokenPrefix: "inference_",
128
+ ttlMs: 600_000,
129
+ limits: { maxRequests: 64, maxTokens: 2_000_000 },
130
+ maxLiveGrants: 8,
131
+ maxInFlightRequestsPerGrant: 1,
132
+ // Top-level request members Grok 1.0.34 sends for a Paideia judge/optimizer call
133
+ // (live stub capture); `tools` and `tool_choice` are refused outright.
134
+ bodyMembers: ["messages", "model", "reasoning_effort", "response_format", "stream", "stream_options"],
135
+ messageRoles: ["system", "user", "assistant"],
136
+ failureCodes: ["auth_stale", "grant_limit", "invalid_request", "unavailable"],
137
+ ledgerVersion: "noopolis.daimon.inference-usage.v1",
138
+ ledgerDedupeKey: ["grant", "request"],
139
+ client: {
140
+ modelId: "daimon-inference-grok",
141
+ envKey: "DAIMON_INFERENCE_GRANT",
142
+ // sha256 of `renderGrokInferenceClientConfig` for the production proxy base URL and this env key.
143
+ configSha256: {
144
+ "grok-4.6": { low: "79314d039f787e4ebfec7dacf57adc969086b948f564dec008f0ed6367e6062f", medium: "6f538de0547c0c4e6a3f04ae08595ceadadabb06b75f6b6ee4c428744bb95cd8", high: "5652656effa82f0c4f09cf8226b16e6140332a5a358b571194bb5563312367ac" },
145
+ "grok-4.5": { low: "a07f7436f1268bb399ec233c65d3b3d8fb99a11a1f175f8da1ca133c9367bc74", medium: "1f4c0d4dad1f3b09419b5739db6423a09e0049abc091594c64123a75dd53dfb9", high: "ffbc33728b821e9854fbc7c93601e599225da421ecfd6ebf10d314afcc28d6f2" },
146
+ "grok-build": { low: "ca15c6a562a008227d39c51d3a3a83715663089b3784e8b46debb1fb67b3c4a1", medium: "01783fb6beadcf6f8486fff0836820ad43fab5662b812a907fe9cfdb83e9804d", high: "98d16f2b7d12f4eb540d625c853e51d227933e204923e43e8b9b4176f10aca2c" }
147
+ }
148
+ }
149
+ },
150
+ projectionVersion: "noopolis.daimon.grok-broker-projection.v3",
151
+ slotPreflightVersion: "noopolis.daimon.grok-slot-preflight.v2",
152
+ artifacts: {
153
+ sourceSha256: "15836d7ad69f12ef581a6e5b8635c9db43b2177dac609160c0749d3d1fefbaa8",
154
+ x64Sha256: "95aa9c272225e74ff9f45f54dde4bc30aee324e9ba24d8a876db9151c81b454d",
155
+ arm64Sha256: "d0dc1c03197c3e90f09b66ad7c89b4f7b448d06dc84c03b247dce976d6018d6e"
156
+ }
157
+ };
158
+ export const AGY_SUBSCRIPTION_REALM = {
159
+ durableMountPath: "/var/lib/spawnfile/daimon/agy-subscription-realm",
160
+ unlockMountPath: "/var/lib/spawnfile/daimon/agy-unlock-secret",
161
+ unlockSourceSlot: "agy-unlock-secret",
162
+ directoryMode: 0o700,
163
+ fileMode: 0o600,
164
+ maxUnlockBytes: 4_096
165
+ };
166
+ const text = { type: "string", minLength: 1, maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS, pattern: "\\S" };
167
+ const boundedText = { type: "string", maxLength: ORGANIZATION_RUNTIME_MAX_STRING_CODEPOINTS };
168
+ const timestamp = { type: "string", format: "date-time", pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" };
169
+ 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 } };
170
+ const wakeResultBase = { version: { const: "noopolis.daimon.wake-result.v1" }, agentId: text, wakeId: text };
171
+ 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 } };
172
+ export const RUNTIME_CONTRACT_MANIFEST = {
173
+ version: RUNTIME_CONTRACT_MANIFEST_VERSION,
174
+ 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"],
175
+ wakeMoments: WAKE_MOMENTS,
176
+ organizationRuntimeConfigSchema: ORGANIZATION_RUNTIME_CONFIG_SCHEMA,
177
+ organizationRuntimeConfigV2Schema: ORGANIZATION_RUNTIME_CONFIG_V2_SCHEMA,
178
+ wakeAcceptanceTypes: ["manual", "message", "schedule", "external"],
179
+ deliverySemantics: {
180
+ activeDeliveryIdempotency: "unbounded-until-terminal",
181
+ terminalReceiptHorizon: 2_048,
182
+ recovery: "at-least-once-with-stable-wake-id",
183
+ concurrentSameAgentTurns: false,
184
+ externalEffectsExactlyOnce: false
185
+ },
186
+ 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" },
187
+ workAvailabilityResponseSchema: WORK_AVAILABILITY_SCHEMA,
188
+ workBlockedSchema: WORK_BLOCKED_SCHEMA,
189
+ operatorDrain: OPERATOR_DRAIN,
190
+ supportedEngineKinds: ["agy", "codex", "grok"],
191
+ engineCredentialMaterial: ENGINE_CREDENTIAL_MATERIAL,
192
+ grokSubscriptionRealm: GROK_SUBSCRIPTION_REALM,
193
+ grokEngineBroker: GROK_ENGINE_BROKER,
194
+ agySubscriptionRealm: AGY_SUBSCRIPTION_REALM,
195
+ wakeRequestSchema: { type: "object", additionalProperties: false, required: ["agentId", "event"], properties: { agentId: text, event: wakeEvent } },
196
+ wakeResultSchema: { oneOf: [
197
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "text", "durationMs"], properties: { ...wakeResultBase, status: { const: "completed" }, text: boundedText, durationMs: { type: "integer", minimum: 0 } } },
198
+ { 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"] } } },
199
+ { 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" } } },
200
+ { 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"] } } },
201
+ { type: "object", additionalProperties: false, required: ["version", "status", "agentId", "wakeId", "code"], properties: { ...wakeResultBase, status: { const: "failed" }, code: { const: "engine_failed" } } }
202
+ ] },
203
+ 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"] } } } } } },
204
+ 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})$" } } },
205
+ 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"] } } } } } }
206
+ };
@@ -0,0 +1,3 @@
1
+ /** Same filter order and automatic secret exclusions for direct and brokered tools. */
2
+ export declare function shellEnvironmentPolicyEntries(env: Readonly<Record<string, string>>): readonly string[];
3
+ //# sourceMappingURL=shellEnvironmentPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shellEnvironmentPolicy.d.ts","sourceRoot":"","sources":["../../src/contracts/shellEnvironmentPolicy.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,MAAM,EAAE,CAGtG"}
@@ -0,0 +1,5 @@
1
+ /** Same filter order and automatic secret exclusions for direct and brokered tools. */
2
+ export function shellEnvironmentPolicyEntries(env) {
3
+ const set = Object.entries(env).map(([name, value]) => `${JSON.stringify(name)}=${JSON.stringify(value)}`).join(",");
4
+ return ['inherit="all"', "ignore_default_excludes=false", "exclude=[]", "include_only=[]", `set={${set}}`];
5
+ }
@@ -0,0 +1,61 @@
1
+ /** Data-only capability and on-disk bounds; presence in the manifest enables callers. */
2
+ export declare const WAKE_MOMENTS: {
3
+ readonly version: "noopolis.daimon.wake-moment.v1";
4
+ readonly rowsFile: "wake-moments.jsonl";
5
+ readonly snapshotsDirectory: "snapshots";
6
+ readonly completionSuffix: ".complete";
7
+ readonly maxSnapshotRoots: 16;
8
+ readonly maxSnapshotEntries: 200000;
9
+ readonly maxRowBytes: 4194304;
10
+ readonly maxManifestBytes: 134217728;
11
+ readonly captureDeadlineMs: 60000;
12
+ readonly finalizationDeadlineMs: 1000;
13
+ readonly configField: "agents[].recording";
14
+ };
15
+ export type WakeMomentRecording = Readonly<{
16
+ directory: string;
17
+ keepMs: number;
18
+ snapshots: readonly Readonly<{
19
+ id: string;
20
+ path: string;
21
+ }>[];
22
+ }>;
23
+ export declare const WAKE_MOMENT_RECORDING_SCHEMA: {
24
+ readonly type: "object";
25
+ readonly additionalProperties: false;
26
+ readonly required: readonly ["directory", "keepMs", "snapshots"];
27
+ readonly properties: {
28
+ readonly directory: {
29
+ readonly type: "string";
30
+ readonly pattern: "^/[^\\u0000]*$";
31
+ readonly maxLength: 4096;
32
+ };
33
+ readonly keepMs: {
34
+ readonly type: "integer";
35
+ readonly minimum: 1;
36
+ readonly maximum: 9007199254740991;
37
+ };
38
+ readonly snapshots: {
39
+ readonly type: "array";
40
+ readonly maxItems: 16;
41
+ readonly uniqueItems: true;
42
+ readonly items: {
43
+ readonly type: "object";
44
+ readonly additionalProperties: false;
45
+ readonly required: readonly ["id", "path"];
46
+ readonly properties: {
47
+ readonly id: {
48
+ readonly type: "string";
49
+ readonly pattern: "^[A-Za-z0-9._-]{1,128}$";
50
+ };
51
+ readonly path: {
52
+ readonly type: "string";
53
+ readonly pattern: "^/[^\\u0000]*$";
54
+ readonly maxLength: 4096;
55
+ };
56
+ };
57
+ };
58
+ };
59
+ };
60
+ };
61
+ //# sourceMappingURL=wakeMomentContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wakeMomentContract.d.ts","sourceRoot":"","sources":["../../src/contracts/wakeMomentContract.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,eAAO,MAAM,YAAY;;;;;;;;;;;;CAYf,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,QAAQ,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CAC9D,CAAC,CAAC;AAGH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW/B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** Data-only capability and on-disk bounds; presence in the manifest enables callers. */
2
+ export const WAKE_MOMENTS = {
3
+ version: "noopolis.daimon.wake-moment.v1",
4
+ rowsFile: "wake-moments.jsonl",
5
+ snapshotsDirectory: "snapshots",
6
+ completionSuffix: ".complete",
7
+ maxSnapshotRoots: 16,
8
+ maxSnapshotEntries: 200_000,
9
+ maxRowBytes: 4_194_304,
10
+ maxManifestBytes: 134_217_728,
11
+ captureDeadlineMs: 60_000,
12
+ finalizationDeadlineMs: 1_000,
13
+ configField: "agents[].recording"
14
+ };
15
+ const absolutePath = { type: "string", pattern: "^/[^\\u0000]*$", maxLength: 4_096 };
16
+ export const WAKE_MOMENT_RECORDING_SCHEMA = {
17
+ type: "object", additionalProperties: false, required: ["directory", "keepMs", "snapshots"],
18
+ properties: {
19
+ directory: absolutePath,
20
+ keepMs: { type: "integer", minimum: 1, maximum: 9_007_199_254_740_991 },
21
+ snapshots: { type: "array", maxItems: WAKE_MOMENTS.maxSnapshotRoots, uniqueItems: true, items: {
22
+ type: "object", additionalProperties: false, required: ["id", "path"], properties: {
23
+ id: { type: "string", pattern: "^[A-Za-z0-9._-]{1,128}$" }, path: absolutePath
24
+ }
25
+ } }
26
+ }
27
+ };
@@ -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
+ }
@@ -5,6 +5,8 @@ export interface AgentStartInput {
5
5
  instructions: string;
6
6
  workspacePath: string;
7
7
  runtimeHomePath: string;
8
+ /** Trusted host causal identity, fixed per instance; unsupported with memory until its public API accepts context. */
9
+ causalRunId?: string;
8
10
  tools?: string[];
9
11
  }
10
12
  export interface HarnessModelEndpoint {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAA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AM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,IAAI,WAAW,CAAC;IACtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC1D"}
@@ -27,6 +27,7 @@ export declare class JungianVoice {
27
27
  readonly runtimeHomePath: string;
28
28
  readonly workspacePath: string;
29
29
  private readonly memory;
30
+ private clockReady?;
30
31
  constructor(config: JungianVoiceConfig);
31
32
  prepare(): Promise<void>;
32
33
  stop(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"jungianPlayAgent.d.ts","sourceRoot":"","sources":["../../src/examples/jungianPlayAgent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAqB,KAAK,aAAa,IAAI,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEhH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB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AC,EAAE,CAYb,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { createMemoryRuntime } from "@noopolis/mneme";
3
+ import { createClockedMemoryRuntime } from "../pi/memoryClock.js";
4
+ import { verifyTaskClockProcess } from "../pi/taskClockProcess.js";
4
5
  import { runEngineDetailed } from "../pi/cliSession.js";
5
6
  const maxMemoryChars = 2200;
6
7
  const truncate = (text, maxChars) => text.length <= maxChars ? text : `${text.slice(0, maxChars).trim()}\n[truncated]`;
@@ -10,11 +11,12 @@ export class JungianVoice {
10
11
  runtimeHomePath;
11
12
  workspacePath;
12
13
  memory;
14
+ clockReady;
13
15
  constructor(config) {
14
16
  this.config = config;
15
17
  this.workspacePath = path.join(config.runtimeRoot, "selves", config.selfId, "voices", config.id, "workspace");
16
18
  this.runtimeHomePath = path.join(config.runtimeRoot, "selves", config.selfId, "voices", config.id, "runtime");
17
- this.memory = createMemoryRuntime({
19
+ this.memory = createClockedMemoryRuntime({
18
20
  agentId: config.id,
19
21
  runtimeHomePath: this.runtimeHomePath,
20
22
  source: `daimon/jungian-play/${config.engine}`,
@@ -22,6 +24,7 @@ export class JungianVoice {
22
24
  });
23
25
  }
24
26
  async prepare() {
27
+ await (this.clockReady ??= verifyTaskClockProcess(this.runtimeHomePath));
25
28
  await mkdir(this.workspacePath, { recursive: true });
26
29
  await mkdir(this.runtimeHomePath, { recursive: true });
27
30
  await writeFile(path.join(this.workspacePath, "AGENTS.md"), [
@@ -39,6 +42,7 @@ export class JungianVoice {
39
42
  // CLI-backed voices are one-process-per-wake and have no persistent handle.
40
43
  }
41
44
  async wake(event) {
45
+ await (this.clockReady ??= verifyTaskClockProcess(this.runtimeHomePath));
42
46
  const startedAt = Date.now();
43
47
  const prepareStartedAt = Date.now();
44
48
  const prepared = await this.memory.prepareTurn({
@@ -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
  }