@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,102 @@
1
+ export const TASK_CLOCK_ENV = "NOOPOLIS_TASK_CLOCK";
2
+ export const TASK_CLOCK_VERSION = "noopolis.task-clock.v1";
3
+ export const TASK_CLOCK_MIN_MS = 0;
4
+ export const TASK_CLOCK_MAX_MS = 253_402_300_799_999;
5
+ export function validTaskInstant(value) {
6
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= TASK_CLOCK_MIN_MS && value <= TASK_CLOCK_MAX_MS;
7
+ }
8
+ export function assertTaskInstant(value) {
9
+ if (!validTaskInstant(value))
10
+ throw invalid("task instant must be within 1970-01-01T00:00:00.000Z .. 9999-12-31T23:59:59.999Z");
11
+ return value;
12
+ }
13
+ /** Environment-only contract: no clock callbacks or compiler config in the public API. */
14
+ export function readTaskClock(environment = process.env) {
15
+ return parseTaskClock(environment[TASK_CLOCK_ENV]);
16
+ }
17
+ export function parseTaskClock(raw) {
18
+ if (raw === undefined)
19
+ return undefined;
20
+ let value;
21
+ try {
22
+ value = JSON.parse(raw);
23
+ }
24
+ catch {
25
+ throw invalid("must be valid JSON");
26
+ }
27
+ if (value === null || typeof value !== "object" || Array.isArray(value))
28
+ throw invalid("must be an object");
29
+ const fields = value;
30
+ if (Object.keys(fields).sort().join() !== "anchorEpochMs,origin,version")
31
+ throw invalid("requires exactly version, origin, anchorEpochMs (no unknown fields)");
32
+ if (fields.version !== TASK_CLOCK_VERSION)
33
+ throw invalid(`version must be ${TASK_CLOCK_VERSION}`);
34
+ if (typeof fields.origin !== "string" || !validInstant(fields.origin))
35
+ throw invalid("origin must be a valid ISO-8601 instant with Z or an explicit offset");
36
+ if (typeof fields.anchorEpochMs !== "number" || !Number.isSafeInteger(fields.anchorEpochMs))
37
+ throw invalid("anchorEpochMs must be a safe integer");
38
+ const origin = fields.origin, anchorEpochMs = fields.anchorEpochMs, originMs = Date.parse(origin);
39
+ assertTaskInstant(originMs);
40
+ const at = (realEpochMs) => assertTaskInstant(originMs + (realEpochMs - anchorEpochMs));
41
+ return Object.freeze({ raw, origin, anchorEpochMs, at, now: () => at(Date.now()) });
42
+ }
43
+ /** The caller installs libfaketime; Daimon derives one process-independent offset. */
44
+ export function taskClockChildEnvironment(declared = {}, clock = readTaskClock(), environment = process.env) {
45
+ if (clock === undefined)
46
+ return {};
47
+ for (const name of Object.keys(declared)) {
48
+ if (declared[name] !== undefined && clockVariable(name))
49
+ throw invalid(`declared child environment conflicts with ${name}`);
50
+ }
51
+ // Integer arithmetic keeps every millisecond even at the safe-integer anchor limits.
52
+ const offset = BigInt(Date.parse(clock.origin)) - BigInt(clock.anchorEpochMs);
53
+ const magnitude = offset < 0n ? -offset : offset;
54
+ const fraction = magnitude % 1000n;
55
+ const seconds = `${offset < 0n ? "-" : "+"}${magnitude / 1000n}${fraction === 0n ? "" : `.${String(fraction).padStart(3, "0")}`}`;
56
+ const preload = taskClockPreload(environment.LD_PRELOAD);
57
+ if (preload === undefined)
58
+ throw invalid("process clock startup probe requires caller-provided LD_PRELOAD naming libfaketime*.so*; refusing clocked execution");
59
+ return {
60
+ // The child process clock owns the offset; Mneme and nested consumers use Date.now().
61
+ // libfaketime's relative format defaults to seconds; an `s` suffix is not supported.
62
+ FAKETIME: seconds,
63
+ FAKETIME_DONT_FAKE_MONOTONIC: "1",
64
+ // libfaketime parses decimal fractions using the process locale.
65
+ LC_ALL: "C",
66
+ LD_PRELOAD: preload
67
+ };
68
+ }
69
+ /** Inherited environments must not reintroduce another offset owner or loader controls. */
70
+ export function taskClockProcessEnvironment(inherited, derived = taskClockChildEnvironment()) {
71
+ if (Object.keys(derived).length === 0)
72
+ return inherited;
73
+ return { ...Object.fromEntries(Object.entries(inherited).filter(([name]) => !clockVariable(name))), ...derived };
74
+ }
75
+ function clockVariable(name) {
76
+ return /^(?:LD_PRELOAD$|DYLD_|FAKETIME|NOOPOLIS_TASK_CLOCK$|MNEME_CLOCK_)/u.test(name);
77
+ }
78
+ /** Provider/auth/control processes must never inherit the agent's process clock. */
79
+ export function realTimeProcessEnvironment(inherited) {
80
+ if (readTaskClock() === undefined)
81
+ return inherited;
82
+ return Object.fromEntries(Object.entries(inherited).filter(([name]) => !clockVariable(name)));
83
+ }
84
+ /** Reject mixed loader lists: unrelated libraries must never ride this exception. */
85
+ export function taskClockPreload(value) {
86
+ const libraries = value?.split(/[\s:]+/u).filter(Boolean);
87
+ return libraries?.length && libraries.every((library) => /^libfaketime[^/]*\.so[^/]*$/u.test(library.split("/").at(-1))) ? value : undefined;
88
+ }
89
+ /** Project real delivery/receipt timestamps, never historical dates inside tool payloads. */
90
+ export function taskClockTimestamp(realTimestamp, clock = readTaskClock()) {
91
+ return clock === undefined ? realTimestamp : new Date(clock.at(Date.parse(realTimestamp))).toISOString();
92
+ }
93
+ function invalid(reason) { return new Error(`${TASK_CLOCK_ENV}: ${reason}`); }
94
+ function validInstant(value) {
95
+ const match = /^(\d{4})-(\d{2})-(\d{2})T([01]\d|2[0-3]):([0-5]\d):([0-5]\d)(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):?[0-5]\d)$/u.exec(value);
96
+ if (match === null || !Number.isFinite(Date.parse(value)))
97
+ return false;
98
+ const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
99
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
100
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
101
+ return month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1];
102
+ }
@@ -0,0 +1,17 @@
1
+ import childProcess from "node:child_process";
2
+ import { type TaskClock } from "./taskClock.js";
3
+ export type { ChildProcess } from "node:child_process";
4
+ /** @internal Synchronous injection seam; never runtime configuration. */
5
+ export type TaskClockProcessProbe = (command: string, args: readonly string[], environment: NodeJS.ProcessEnv) => string;
6
+ /** @internal Isolate simulated probes between tests. */
7
+ export declare function resetTaskClockProcessForTest(): void;
8
+ /** Shared child-launch boundary, including SDK transports and Pi's spawn hook.
9
+ * Keep the synchronous spawn API: only the first launch blocks for the bounded probes.
10
+ * Every launch derives a fresh environment; only successful interposition is memoized.
11
+ */
12
+ export declare function readyTaskClockEnvironment(environment: NodeJS.ProcessEnv, clock?: TaskClock | undefined, probe?: TaskClockProcessProbe): NodeJS.ProcessEnv;
13
+ /** Only agent-facing tool/server children cross the shifted readiness gate. */
14
+ export declare const spawn: typeof childProcess.spawn;
15
+ /** Engine CLIs and operational helpers stay real; no libfaketime probe runs here. */
16
+ export declare const spawnRealTime: typeof childProcess.spawn;
17
+ //# sourceMappingURL=taskClockProcess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskClockProcess.d.ts","sourceRoot":"","sources":["../../src/runtime/taskClockProcess.ts"],"names":[],"mappings":"AAAA,OAAO,YAAmC,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAqG,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEnJ,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,yEAAyE;AACzE,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC;AAGzH,wDAAwD;AACxD,wBAAgB,4BAA4B,IAAI,IAAI,CAAsB;AAS1E;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,GAAE,SAAS,GAAG,SAA2B,EAAE,KAAK,GAAE,qBAAiC,GACvH,MAAM,CAAC,UAAU,CAyBnB;AAED,+EAA+E;AAC/E,eAAO,MAAM,KAAK,EAAE,OAAO,YAAY,CAAC,KAIT,CAAC;AAEhC,qFAAqF;AACrF,eAAO,MAAM,aAAa,EAAE,OAAO,YAAY,CAAC,KAIjB,CAAC"}
@@ -0,0 +1,58 @@
1
+ import childProcess from "node:child_process";
2
+ import { readTaskClock, realTimeProcessEnvironment, taskClockChildEnvironment, taskClockProcessEnvironment } from "./taskClock.js";
3
+ const verified = new Set();
4
+ /** @internal Isolate simulated probes between tests. */
5
+ export function resetTaskClockProcessForTest() { verified.clear(); }
6
+ const dateProbe = (command, args, env) => {
7
+ const result = childProcess.spawnSync(command, [...args], { env, encoding: "utf8", timeout: 5000, killSignal: "SIGKILL", maxBuffer: 1024 });
8
+ // Loaders can ignore a missing library and still exit zero, including at zero offset.
9
+ if (result.error || result.status !== 0 || result.stderr?.trim())
10
+ throw result.error ?? new Error("date/libfaketime emitted a startup diagnostic");
11
+ return result.stdout;
12
+ };
13
+ /** Shared child-launch boundary, including SDK transports and Pi's spawn hook.
14
+ * Keep the synchronous spawn API: only the first launch blocks for the bounded probes.
15
+ * Every launch derives a fresh environment; only successful interposition is memoized.
16
+ */
17
+ export function readyTaskClockEnvironment(environment, clock = readTaskClock(), probe = dateProbe) {
18
+ if (clock === undefined)
19
+ return environment;
20
+ const refuse = (reason) => new Error(`NOOPOLIS_TASK_CLOCK: process clock startup probe ${reason}; refusing clocked execution`);
21
+ if (process.platform !== "linux")
22
+ throw refuse("requires Linux libfaketime interposition");
23
+ const derived = taskClockChildEnvironment({}, clock);
24
+ const env = taskClockProcessEnvironment(environment, derived);
25
+ clock.now(); // A cached process clock never permits reads outside the supported calendar.
26
+ const key = JSON.stringify([process.pid, process.platform, derived.LD_PRELOAD, derived.FAKETIME]);
27
+ if (verified.has(key))
28
+ return env;
29
+ for (const sentinel of [true, false]) {
30
+ let output;
31
+ try {
32
+ // Absolute path: engine-specific PATHs need not contain system utilities.
33
+ output = probe("/bin/date", ["-u", "+%s"], sentinel ? { ...env, FAKETIME: "-31536000" } : env);
34
+ }
35
+ catch (cause) {
36
+ throw new Error(refuse("could not run date -u +%s (date/libfaketime missing or unusable)").message, { cause });
37
+ }
38
+ const seconds = Number(output.trim());
39
+ const expected = sentinel ? Date.now() - 31_536_000_000 : clock.now();
40
+ if (!/^-?\d+$/u.test(output.trim()) || !Number.isSafeInteger(seconds) || Math.abs(seconds * 1000 - expected) > 5000) {
41
+ throw refuse(`did not observe ${sentinel ? "sentinel offset" : "task time"} within ±5 seconds (check libfaketime and its offset)`);
42
+ }
43
+ }
44
+ verified.add(key);
45
+ return env;
46
+ }
47
+ /** Only agent-facing tool/server children cross the shifted readiness gate. */
48
+ export const spawn = ((command, args, options) => {
49
+ const argv = Array.isArray(args) ? args : [];
50
+ const settings = (Array.isArray(args) ? options : args ?? options);
51
+ return childProcess.spawn(command, argv, { ...settings, env: readyTaskClockEnvironment(settings?.env ?? process.env) });
52
+ });
53
+ /** Engine CLIs and operational helpers stay real; no libfaketime probe runs here. */
54
+ export const spawnRealTime = ((command, args, options) => {
55
+ const argv = Array.isArray(args) ? args : [];
56
+ const settings = (Array.isArray(args) ? options : args ?? options);
57
+ return childProcess.spawn(command, argv, { ...settings, env: realTimeProcessEnvironment(settings?.env ?? process.env) });
58
+ });
@@ -0,0 +1,152 @@
1
+ import { type McpUpstreamResult, type RenderedMcpToolResult } from "./mcpToolResult.js";
2
+ /**
3
+ * Cap one declared MCP tool result, and spill the rest of it to disk.
4
+ *
5
+ * ## Why
6
+ *
7
+ * Production agents make 3–37 tool calls per wake, and every tool result stays
8
+ * in the transcript for every *subsequent* model request of that wake. Context
9
+ * per request is flat at 23–32k tokens, so one oversized result is not paid
10
+ * once — it is paid again on every request that follows it, at cache-read rates
11
+ * for the ones that hit and at fresh rates for the one that does not. A 40 KiB
12
+ * result returned on call three of thirty is re-billed twenty-seven times.
13
+ *
14
+ * Before this, Daimon applied no cap of its own to a declared MCP tool's answer.
15
+ * `mcpToolResult.ts` bounded it at 61,440 bytes — the receipt bound, not a
16
+ * context bound — and above that degraded it to a *head only*, with no way to
17
+ * recover the rest.
18
+ *
19
+ * ## The reference pattern
20
+ *
21
+ * `references/oh-my-pi` wraps **every** tool, MCP included, with the same
22
+ * centralized spill (`packages/coding-agent/src/tools/output-meta.ts:724-891`,
23
+ * mounted in `sdk.ts:2862-2869`):
24
+ *
25
+ * - a byte threshold (`tools.artifactSpillThreshold`, default 50 KiB);
26
+ * - **head + tail retention** with the middle elided, so the model keeps both
27
+ * ends of the output (`truncateMiddle`,
28
+ * `packages/coding-agent/src/session/streaming-output.ts`), defaults
29
+ * 20 KiB head + 20 KiB tail — an even split at 80% of the threshold;
30
+ * - the **full output written to disk** and addressed by an id
31
+ * (`session/artifacts.ts`);
32
+ * - a notice naming the ranges shown and the re-fetch address:
33
+ * `Showing lines X-Y of Z … Read artifact://ID for full output`
34
+ * (`formatTruncationMetaNotice`, `formatFullOutputReference`);
35
+ * - and the rule that a **failed save still truncates** — the recovery link is
36
+ * attached only when the write actually succeeded, because re-exposing the
37
+ * full output on a disk error is the one outcome worse than truncating.
38
+ *
39
+ * All five are reproduced here. What differs is only the address: oh-my-pi's
40
+ * `artifact://<id>` is resolved by its own `read` tool, and Daimon has no such
41
+ * protocol — so the notice names the **absolute path**, which every Daimon agent
42
+ * can already read with the mounted `bash` tool (`piHarness.ts`) or the engine's
43
+ * own shell. The file lives under the agent's own runtime home, which is exactly
44
+ * the tree that home is for and the one tree every sandbox profile leaves the
45
+ * agent (`grokSandboxProtectedPaths` denies *peers'* homes, never its own).
46
+ */
47
+ /**
48
+ * The cap on one lowered MCP tool result, measured the way
49
+ * `mcpToolResult.ts` measures: the serialized `{content, structuredContent}`
50
+ * record, both channels included.
51
+ *
52
+ * **16 KiB, ≈4k tokens.** oh-my-pi's 50 KiB default is calibrated for an
53
+ * interactive coding agent with a 200k+ context; Daimon's whole per-request
54
+ * context is 23–32k tokens, so a 50 KiB result would be *half of it* and would
55
+ * be replayed on every remaining request of the wake. 16 KiB keeps any single
56
+ * result under roughly a sixth of a request while leaving a realistic answer
57
+ * — a page of messages, a document, a query result — entirely untouched: it is
58
+ * a ceiling on the pathological case, not a working budget.
59
+ */
60
+ export declare const DEFAULT_TOOL_RESULT_MAX_BYTES: number;
61
+ export declare const TOOL_RESULT_MAX_BYTES_ENV: "DAIMON_TOOL_RESULT_MAX_BYTES";
62
+ /**
63
+ * Tools that must never be truncated, by mounted tool name
64
+ * (`mcp_<server>_<tool>`), comma-separated.
65
+ *
66
+ * Empty by default. It exists because Daimon cannot know what an organization
67
+ * declared: if a deployment has one MCP tool whose *whole* answer is load
68
+ * bearing — a signature, a checksummed document, a payload the agent must
69
+ * reproduce verbatim — head+tail is not a degradation there, it is a wrong
70
+ * answer, and no re-fetch instruction fixes a model that did not notice. That
71
+ * judgement belongs to whoever declared the tool, so it is configuration rather
72
+ * than a Daimon-side guess. An exempt tool keeps exactly today's behaviour,
73
+ * including `mcpToolResult.ts`'s 61,440-byte receipt bound.
74
+ */
75
+ export declare const TOOL_RESULT_EXEMPT_ENV: "DAIMON_TOOL_RESULT_NO_TRUNCATE";
76
+ /**
77
+ * A result may never be capped below this. Below roughly a kilobyte the head and
78
+ * tail stop being usable at all and the notice dominates the payload, so a
79
+ * mistyped bound degrades into "every tool is blind" — worse than no cap.
80
+ */
81
+ export declare const MIN_TOOL_RESULT_MAX_BYTES = 2048;
82
+ /** Spilled files live here, under the agent's own runtime home. */
83
+ export declare const TOOL_OUTPUT_DIRECTORY_NAME: "tool-output";
84
+ /** Newest-first retention for spilled files, mirroring `pruneReceipts`. */
85
+ export declare const TOOL_OUTPUT_RETAINED_FILES = 256;
86
+ export declare const resolveToolResultMaxBytes: (environment?: NodeJS.ProcessEnv) => number;
87
+ export declare const resolveExemptToolNames: (environment?: NodeJS.ProcessEnv) => ReadonlySet<string>;
88
+ /** Cut on a code-point boundary, from the front. */
89
+ /** Exported for the bounded diagnostic window (`cliChildOutput.ts`): one boundary-safe implementation, not two. */
90
+ export declare const headUtf8: (value: string, maxBytes: number) => string;
91
+ /** Cut on a code-point boundary, from the back. */
92
+ /** Exported for the bounded diagnostic window (`cliChildOutput.ts`): one boundary-safe implementation, not two. */
93
+ export declare const tailUtf8: (value: string, maxBytes: number) => string;
94
+ /**
95
+ * The complete payload, as the text that gets written to disk and sliced.
96
+ *
97
+ * A result that is nothing but text parts is spilled as that text, because a
98
+ * human-readable log is what the agent will `grep` and `sed`. Anything else — a
99
+ * structured result, an image part, a mixed result — is spilled as the
100
+ * serialized upstream record, which is lossless and is the same serialization
101
+ * `mcpToolResult.ts` already degrades to today.
102
+ */
103
+ export declare const spillPayload: (result: McpUpstreamResult) => {
104
+ text: string;
105
+ format: "text" | "json";
106
+ };
107
+ /**
108
+ * Spilled files are group-readable and never other-readable.
109
+ *
110
+ * A brokered Grok worker runs as its own uid and reads a spill with
111
+ * `read_file`, so a 0600 file owned by the runtime (uid 2000) was unreadable to
112
+ * the very agent the notice sends there. The group grant reaches exactly that
113
+ * agent's worker only when the deployment provisions `tool-output` as
114
+ * `<runtime uid>:<worker gid> 2750` (setgid, so each file inherits the worker
115
+ * group; `GROK_ENGINE_BROKER.worker.home.spillDirectory`). A directory Daimon
116
+ * creates itself stays 0700, so for every other engine nothing new is exposed.
117
+ */
118
+ export declare const SPILL_FILE_MODE = 416;
119
+ export declare const SPILL_DIRECTORY_MAX_MODE = 1512;
120
+ /** Pure so a foreign owner is testable without root. */
121
+ export declare const assertSpillDirectoryStat: (entry: Readonly<{
122
+ uid: number;
123
+ gid: number;
124
+ mode: number;
125
+ isDirectory(): boolean;
126
+ }>, runtime: Readonly<{
127
+ uid: number;
128
+ gid: number;
129
+ }>) => void;
130
+ export type CappedToolResult = RenderedMcpToolResult & {
131
+ /** Absolute path of the spilled full result, when one was written. */
132
+ readonly spillPath?: string;
133
+ };
134
+ /**
135
+ * Return `rendered` untouched when it fits, or a head+tail view of the full
136
+ * payload plus a notice naming the file that holds the rest.
137
+ *
138
+ * A result under the cap passes through **byte-identical**: the `mcp_*`
139
+ * passthrough contract — both channels carrying the payload, an upstream
140
+ * `structuredContent` forwarded verbatim — is unchanged for every result that
141
+ * does not blow the bound, which is the overwhelming majority of them.
142
+ */
143
+ export declare const capToolResult: (input: Readonly<{
144
+ toolName: string;
145
+ rendered: RenderedMcpToolResult;
146
+ result: McpUpstreamResult;
147
+ maxBytes: number;
148
+ exempt: ReadonlySet<string>;
149
+ spillDirectory: string;
150
+ spillId: string;
151
+ }>) => Promise<CappedToolResult>;
152
+ //# sourceMappingURL=toolResultSpill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolResultSpill.d.ts","sourceRoot":"","sources":["../../src/runtime/toolResultSpill.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAExG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,6BAA6B,QAAY,CAAC;AAEvD,eAAO,MAAM,yBAAyB,EAAG,8BAAuC,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,EAAG,gCAAyC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAE/C,mEAAmE;AACnE,eAAO,MAAM,0BAA0B,EAAG,aAAsB,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,eAAO,MAAM,yBAAyB,GAAI,cAAa,MAAM,CAAC,UAAwB,KAAG,MAQxF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,cAAa,MAAM,CAAC,UAAwB,KAAG,WAAW,CAAC,MAAM,CACsB,CAAC;AAS/H,oDAAoD;AACpD,mHAAmH;AACnH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,MAM1D,CAAC;AAEF,mDAAmD;AACnD,mHAAmH;AACnH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,MAM1D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,iBAAiB,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CAc/F,CAAC;AAyBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,MAAQ,CAAC;AACrC,eAAO,MAAM,wBAAwB,OAAS,CAAC;AA0D/C,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,GAAI,OAAO,QAAQ,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,IAAI,OAAO,CAAA;CAAE,CAAC,EAAE,SAAS,QAAQ,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAAG,IAO/K,CAAC;AAoBF,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG;IACrD,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAU,OAAO,QAAQ,CAAC;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,KAAG,OAAO,CAAC,gBAAgB,CA6D5B,CAAC"}