@noopolis/daimon 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/README.md +307 -45
  2. package/dist/contracts/attentionContract.d.ts +117 -0
  3. package/dist/contracts/attentionContract.d.ts.map +1 -0
  4. package/dist/contracts/attentionContract.js +14 -0
  5. package/dist/contracts/canonicalJson.d.ts +3 -0
  6. package/dist/contracts/canonicalJson.d.ts.map +1 -0
  7. package/dist/contracts/canonicalJson.js +54 -0
  8. package/dist/contracts/grokWorkerContract.d.ts +74 -0
  9. package/dist/contracts/grokWorkerContract.d.ts.map +1 -0
  10. package/dist/contracts/grokWorkerContract.js +88 -0
  11. package/dist/contracts/organizationRuntimeContract.d.ts +765 -0
  12. package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -0
  13. package/dist/contracts/organizationRuntimeContract.js +121 -0
  14. package/dist/contracts/runtimeContractManifest.d.ts +1615 -0
  15. package/dist/contracts/runtimeContractManifest.d.ts.map +1 -0
  16. package/dist/contracts/runtimeContractManifest.js +181 -0
  17. package/dist/core/credentialRedaction.d.ts +4 -0
  18. package/dist/core/credentialRedaction.d.ts.map +1 -0
  19. package/dist/core/credentialRedaction.js +28 -0
  20. package/dist/core/siblingBuildFreshness.d.ts +21 -0
  21. package/dist/core/siblingBuildFreshness.d.ts.map +1 -0
  22. package/dist/core/siblingBuildFreshness.js +25 -0
  23. package/dist/core/types.d.ts +10 -1
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/examples/exampleCausalId.d.ts +3 -0
  26. package/dist/examples/exampleCausalId.d.ts.map +1 -0
  27. package/dist/examples/exampleCausalId.js +8 -0
  28. package/dist/examples/jungian-play-org.js +3 -2
  29. package/dist/examples/jungian-triad-org.js +3 -2
  30. package/dist/examples/jungianPlayAgent.d.ts +1 -1
  31. package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
  32. package/dist/examples/jungianPlayAgent.js +1 -1
  33. package/dist/examples/jungianProfiles.d.ts +1 -1
  34. package/dist/examples/jungianProfiles.d.ts.map +1 -1
  35. package/dist/examples/jungianTriadProfiles.d.ts +1 -1
  36. package/dist/examples/jungianTriadProfiles.d.ts.map +1 -1
  37. package/dist/examples/pi-agent.js +3 -2
  38. package/dist/examples/pi-memory-org.js +6 -5
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/mcp/toolServer.d.ts +31 -0
  43. package/dist/mcp/toolServer.d.ts.map +1 -0
  44. package/dist/mcp/toolServer.js +145 -0
  45. package/dist/observability/causalEvents.d.ts +118 -0
  46. package/dist/observability/causalEvents.d.ts.map +1 -0
  47. package/dist/observability/causalEvents.js +223 -0
  48. package/dist/observability/controlCausal.d.ts +117 -0
  49. package/dist/observability/controlCausal.d.ts.map +1 -0
  50. package/dist/observability/controlCausal.js +107 -0
  51. package/dist/observability/emitCausalFixture.d.ts +25 -0
  52. package/dist/observability/emitCausalFixture.d.ts.map +1 -0
  53. package/dist/observability/emitCausalFixture.js +98 -0
  54. package/dist/observability/index.d.ts +2 -0
  55. package/dist/observability/index.d.ts.map +1 -1
  56. package/dist/observability/index.js +2 -0
  57. package/dist/observability/orgObserver.d.ts.map +1 -1
  58. package/dist/observability/orgObserver.js +3 -3
  59. package/dist/pi/agyHeadlessResult.d.ts +60 -0
  60. package/dist/pi/agyHeadlessResult.d.ts.map +1 -0
  61. package/dist/pi/agyHeadlessResult.js +95 -0
  62. package/dist/pi/cliChildOutput.d.ts +67 -0
  63. package/dist/pi/cliChildOutput.d.ts.map +1 -0
  64. package/dist/pi/cliChildOutput.js +269 -0
  65. package/dist/pi/cliEngineRun.d.ts +16 -0
  66. package/dist/pi/cliEngineRun.d.ts.map +1 -0
  67. package/dist/pi/cliEngineRun.js +27 -0
  68. package/dist/pi/cliEngineSpawn.d.ts +55 -0
  69. package/dist/pi/cliEngineSpawn.d.ts.map +1 -0
  70. package/dist/pi/cliEngineSpawn.js +164 -0
  71. package/dist/pi/cliEnvironment.d.ts +12 -0
  72. package/dist/pi/cliEnvironment.d.ts.map +1 -0
  73. package/dist/pi/cliEnvironment.js +32 -0
  74. package/dist/pi/cliMcpRegistration.d.ts +61 -0
  75. package/dist/pi/cliMcpRegistration.d.ts.map +1 -0
  76. package/dist/pi/cliMcpRegistration.js +75 -0
  77. package/dist/pi/cliProcess.d.ts +7 -0
  78. package/dist/pi/cliProcess.d.ts.map +1 -0
  79. package/dist/pi/cliProcess.js +132 -0
  80. package/dist/pi/cliSession.d.ts +106 -0
  81. package/dist/pi/cliSession.d.ts.map +1 -0
  82. package/dist/pi/cliSession.js +379 -0
  83. package/dist/pi/cliTurnMetering.d.ts +60 -0
  84. package/dist/pi/cliTurnMetering.d.ts.map +1 -0
  85. package/dist/pi/cliTurnMetering.js +60 -0
  86. package/dist/pi/codexFilesystemRules.d.ts +3 -0
  87. package/dist/pi/codexFilesystemRules.d.ts.map +1 -0
  88. package/dist/pi/codexFilesystemRules.js +28 -0
  89. package/dist/pi/codexHeadlessResult.d.ts +68 -0
  90. package/dist/pi/codexHeadlessResult.d.ts.map +1 -0
  91. package/dist/pi/codexHeadlessResult.js +122 -0
  92. package/dist/pi/codexRolloutUsage.d.ts +95 -0
  93. package/dist/pi/codexRolloutUsage.d.ts.map +1 -0
  94. package/dist/pi/codexRolloutUsage.js +221 -0
  95. package/dist/pi/engineWakeLimits.d.ts +39 -0
  96. package/dist/pi/engineWakeLimits.d.ts.map +1 -0
  97. package/dist/pi/engineWakeLimits.js +55 -0
  98. package/dist/pi/grokHeadlessResult.d.ts +36 -0
  99. package/dist/pi/grokHeadlessResult.d.ts.map +1 -0
  100. package/dist/pi/grokHeadlessResult.js +118 -0
  101. package/dist/pi/grokHomeMcpRegistration.d.ts +21 -0
  102. package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -0
  103. package/dist/pi/grokHomeMcpRegistration.js +57 -0
  104. package/dist/pi/grokSandbox.d.ts +11 -0
  105. package/dist/pi/grokSandbox.d.ts.map +1 -0
  106. package/dist/pi/grokSandbox.js +216 -0
  107. package/dist/pi/grokStreamUsage.d.ts +31 -0
  108. package/dist/pi/grokStreamUsage.d.ts.map +1 -0
  109. package/dist/pi/grokStreamUsage.js +51 -0
  110. package/dist/pi/index.d.ts +5 -0
  111. package/dist/pi/index.d.ts.map +1 -1
  112. package/dist/pi/index.js +5 -0
  113. package/dist/pi/memoryTools.d.ts +55 -1
  114. package/dist/pi/memoryTools.d.ts.map +1 -1
  115. package/dist/pi/memoryTools.js +144 -24
  116. package/dist/pi/modelRegistry.d.ts +13 -0
  117. package/dist/pi/modelRegistry.d.ts.map +1 -0
  118. package/dist/pi/modelRegistry.js +19 -0
  119. package/dist/pi/piAgentHandle.d.ts +46 -0
  120. package/dist/pi/piAgentHandle.d.ts.map +1 -0
  121. package/dist/pi/piAgentHandle.js +351 -0
  122. package/dist/pi/piAgentWakeSupport.d.ts +103 -0
  123. package/dist/pi/piAgentWakeSupport.d.ts.map +1 -0
  124. package/dist/pi/piAgentWakeSupport.js +151 -0
  125. package/dist/pi/piHarness.d.ts +40 -5
  126. package/dist/pi/piHarness.d.ts.map +1 -1
  127. package/dist/pi/piHarness.js +151 -256
  128. package/dist/pi/prompts.d.ts +10 -0
  129. package/dist/pi/prompts.d.ts.map +1 -0
  130. package/dist/pi/prompts.js +63 -0
  131. package/dist/pi/rawTrainingCapture.d.ts +59 -0
  132. package/dist/pi/rawTrainingCapture.d.ts.map +1 -0
  133. package/dist/pi/rawTrainingCapture.js +175 -0
  134. package/dist/pi/turnCausal.d.ts +73 -0
  135. package/dist/pi/turnCausal.d.ts.map +1 -0
  136. package/dist/pi/turnCausal.js +75 -0
  137. package/dist/pi/turnTrace.d.ts +128 -0
  138. package/dist/pi/turnTrace.d.ts.map +1 -0
  139. package/dist/pi/turnTrace.js +138 -0
  140. package/dist/pi/wakeAcceptance.d.ts +49 -0
  141. package/dist/pi/wakeAcceptance.d.ts.map +1 -0
  142. package/dist/pi/wakeAcceptance.js +281 -0
  143. package/dist/pi/wakeAcceptanceFs.d.ts +44 -0
  144. package/dist/pi/wakeAcceptanceFs.d.ts.map +1 -0
  145. package/dist/pi/wakeAcceptanceFs.js +318 -0
  146. package/dist/pi/wakeAcceptanceSchema.d.ts +75 -0
  147. package/dist/pi/wakeAcceptanceSchema.d.ts.map +1 -0
  148. package/dist/pi/wakeAcceptanceSchema.js +265 -0
  149. package/dist/pi/wakeModes.d.ts +9 -0
  150. package/dist/pi/wakeModes.d.ts.map +1 -0
  151. package/dist/pi/wakeModes.js +19 -0
  152. package/dist/pi/worldNudge.d.ts +22 -0
  153. package/dist/pi/worldNudge.d.ts.map +1 -0
  154. package/dist/pi/worldNudge.js +62 -0
  155. package/dist/pi/worldToolProtocol.d.ts +13 -0
  156. package/dist/pi/worldToolProtocol.d.ts.map +1 -0
  157. package/dist/pi/worldToolProtocol.js +49 -0
  158. package/dist/pi/worldTools.d.ts +32 -0
  159. package/dist/pi/worldTools.d.ts.map +1 -0
  160. package/dist/pi/worldTools.js +373 -0
  161. package/dist/pi/worldTrajectory.d.ts +52 -0
  162. package/dist/pi/worldTrajectory.d.ts.map +1 -0
  163. package/dist/pi/worldTrajectory.js +131 -0
  164. package/dist/runtime/agySubscriptionBootstrap.d.ts +16 -0
  165. package/dist/runtime/agySubscriptionBootstrap.d.ts.map +1 -0
  166. package/dist/runtime/agySubscriptionBootstrap.js +80 -0
  167. package/dist/runtime/agySubscriptionRealm.d.ts +38 -0
  168. package/dist/runtime/agySubscriptionRealm.d.ts.map +1 -0
  169. package/dist/runtime/agySubscriptionRealm.js +242 -0
  170. package/dist/runtime/attention.d.ts +21 -0
  171. package/dist/runtime/attention.d.ts.map +1 -0
  172. package/dist/runtime/attention.js +36 -0
  173. package/dist/runtime/attentionDispatcher.d.ts +66 -0
  174. package/dist/runtime/attentionDispatcher.d.ts.map +1 -0
  175. package/dist/runtime/attentionDispatcher.js +271 -0
  176. package/dist/runtime/cli.d.ts +7 -0
  177. package/dist/runtime/cli.d.ts.map +1 -0
  178. package/dist/runtime/cli.js +251 -0
  179. package/dist/runtime/codexSandboxProjection.d.ts +17 -0
  180. package/dist/runtime/codexSandboxProjection.d.ts.map +1 -0
  181. package/dist/runtime/codexSandboxProjection.js +40 -0
  182. package/dist/runtime/contract-manifest.json +1 -0
  183. package/dist/runtime/contract-manifest.sha256 +1 -0
  184. package/dist/runtime/contractManifest.d.ts +8 -0
  185. package/dist/runtime/contractManifest.d.ts.map +1 -0
  186. package/dist/runtime/contractManifest.js +4 -0
  187. package/dist/runtime/engineBrokerCapabilities.d.ts +30 -0
  188. package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -0
  189. package/dist/runtime/engineBrokerCapabilities.js +59 -0
  190. package/dist/runtime/engineBrokerControlClient.d.ts +44 -0
  191. package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -0
  192. package/dist/runtime/engineBrokerControlClient.js +132 -0
  193. package/dist/runtime/engineBrokerCredentialJournal.d.ts +10 -0
  194. package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -0
  195. package/dist/runtime/engineBrokerCredentialJournal.js +17 -0
  196. package/dist/runtime/engineBrokerInferenceProtocol.d.ts +52 -0
  197. package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -0
  198. package/dist/runtime/engineBrokerInferenceProtocol.js +65 -0
  199. package/dist/runtime/engineBrokerMcpCallLog.d.ts +160 -0
  200. package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -0
  201. package/dist/runtime/engineBrokerMcpCallLog.js +219 -0
  202. package/dist/runtime/engineBrokerMcpFacade.d.ts +56 -0
  203. package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -0
  204. package/dist/runtime/engineBrokerMcpFacade.js +343 -0
  205. package/dist/runtime/engineBrokerNativeClient.d.ts +52 -0
  206. package/dist/runtime/engineBrokerNativeClient.d.ts.map +1 -0
  207. package/dist/runtime/engineBrokerNativeClient.js +151 -0
  208. package/dist/runtime/engineBrokerProtocol.d.ts +135 -0
  209. package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -0
  210. package/dist/runtime/engineBrokerProtocol.js +274 -0
  211. package/dist/runtime/engineBrokerSealLedger.d.ts +70 -0
  212. package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -0
  213. package/dist/runtime/engineBrokerSealLedger.js +123 -0
  214. package/dist/runtime/engineBrokerService.d.ts +37 -0
  215. package/dist/runtime/engineBrokerService.d.ts.map +1 -0
  216. package/dist/runtime/engineBrokerService.js +138 -0
  217. package/dist/runtime/engineBrokerServiceCli.d.ts +5 -0
  218. package/dist/runtime/engineBrokerServiceCli.d.ts.map +1 -0
  219. package/dist/runtime/engineBrokerServiceCli.js +32 -0
  220. package/dist/runtime/engineBrokerServiceConfig.d.ts +50 -0
  221. package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -0
  222. package/dist/runtime/engineBrokerServiceConfig.js +92 -0
  223. package/dist/runtime/engineBrokerSingleflight.d.ts +13 -0
  224. package/dist/runtime/engineBrokerSingleflight.d.ts.map +1 -0
  225. package/dist/runtime/engineBrokerSingleflight.js +24 -0
  226. package/dist/runtime/engineBrokerTurnAccounting.d.ts +76 -0
  227. package/dist/runtime/engineBrokerTurnAccounting.d.ts.map +1 -0
  228. package/dist/runtime/engineBrokerTurnAccounting.js +108 -0
  229. package/dist/runtime/engineBrokerTurnRegistry.d.ts +57 -0
  230. package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -0
  231. package/dist/runtime/engineBrokerTurnRegistry.js +158 -0
  232. package/dist/runtime/engineDispatcher.d.ts +36 -0
  233. package/dist/runtime/engineDispatcher.d.ts.map +1 -0
  234. package/dist/runtime/engineDispatcher.js +216 -0
  235. package/dist/runtime/engineReadiness.d.ts +23 -0
  236. package/dist/runtime/engineReadiness.d.ts.map +1 -0
  237. package/dist/runtime/engineReadiness.js +222 -0
  238. package/dist/runtime/grokAuthenticationError.d.ts +8 -0
  239. package/dist/runtime/grokAuthenticationError.d.ts.map +1 -0
  240. package/dist/runtime/grokAuthenticationError.js +20 -0
  241. package/dist/runtime/grokBrokerCredentialAuthority.d.ts +22 -0
  242. package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -0
  243. package/dist/runtime/grokBrokerCredentialAuthority.js +124 -0
  244. package/dist/runtime/grokBrokerCredentialReader.d.ts +5 -0
  245. package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -0
  246. package/dist/runtime/grokBrokerCredentialReader.js +37 -0
  247. package/dist/runtime/grokBrokerModelPolicy.d.ts +23 -0
  248. package/dist/runtime/grokBrokerModelPolicy.d.ts.map +1 -0
  249. package/dist/runtime/grokBrokerModelPolicy.js +28 -0
  250. package/dist/runtime/grokBrokerProjection.d.ts +106 -0
  251. package/dist/runtime/grokBrokerProjection.d.ts.map +1 -0
  252. package/dist/runtime/grokBrokerProjection.js +94 -0
  253. package/dist/runtime/grokBrokerProxy.d.ts +55 -0
  254. package/dist/runtime/grokBrokerProxy.d.ts.map +1 -0
  255. package/dist/runtime/grokBrokerProxy.js +262 -0
  256. package/dist/runtime/grokBrokerProxyRequest.d.ts +30 -0
  257. package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -0
  258. package/dist/runtime/grokBrokerProxyRequest.js +74 -0
  259. package/dist/runtime/grokBrokerRealmLease.d.ts +4 -0
  260. package/dist/runtime/grokBrokerRealmLease.d.ts.map +1 -0
  261. package/dist/runtime/grokBrokerRealmLease.js +33 -0
  262. package/dist/runtime/grokBrokerRefresh.d.ts +2 -0
  263. package/dist/runtime/grokBrokerRefresh.d.ts.map +1 -0
  264. package/dist/runtime/grokBrokerRefresh.js +15 -0
  265. package/dist/runtime/grokBrokerTurnMeter.d.ts +128 -0
  266. package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -0
  267. package/dist/runtime/grokBrokerTurnMeter.js +251 -0
  268. package/dist/runtime/grokBrokerWorkerConfig.d.ts +86 -0
  269. package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -0
  270. package/dist/runtime/grokBrokerWorkerConfig.js +135 -0
  271. package/dist/runtime/grokEngineBroker.d.ts +48 -0
  272. package/dist/runtime/grokEngineBroker.d.ts.map +1 -0
  273. package/dist/runtime/grokEngineBroker.js +114 -0
  274. package/dist/runtime/grokEngineBrokerLedger.d.ts +52 -0
  275. package/dist/runtime/grokEngineBrokerLedger.d.ts.map +1 -0
  276. package/dist/runtime/grokEngineBrokerLedger.js +114 -0
  277. package/dist/runtime/grokEngineBrokerMetering.d.ts +51 -0
  278. package/dist/runtime/grokEngineBrokerMetering.d.ts.map +1 -0
  279. package/dist/runtime/grokEngineBrokerMetering.js +34 -0
  280. package/dist/runtime/grokEngineBrokerTurn.d.ts +58 -0
  281. package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -0
  282. package/dist/runtime/grokEngineBrokerTurn.js +165 -0
  283. package/dist/runtime/grokInferenceClientConfig.d.ts +41 -0
  284. package/dist/runtime/grokInferenceClientConfig.d.ts.map +1 -0
  285. package/dist/runtime/grokInferenceClientConfig.js +62 -0
  286. package/dist/runtime/grokInferenceGrants.d.ts +77 -0
  287. package/dist/runtime/grokInferenceGrants.d.ts.map +1 -0
  288. package/dist/runtime/grokInferenceGrants.js +116 -0
  289. package/dist/runtime/grokInferenceProxy.d.ts +29 -0
  290. package/dist/runtime/grokInferenceProxy.d.ts.map +1 -0
  291. package/dist/runtime/grokInferenceProxy.js +82 -0
  292. package/dist/runtime/grokInferenceProxyRequest.d.ts +23 -0
  293. package/dist/runtime/grokInferenceProxyRequest.d.ts.map +1 -0
  294. package/dist/runtime/grokInferenceProxyRequest.js +63 -0
  295. package/dist/runtime/grokSlotPreflightReceipt.d.ts +70 -0
  296. package/dist/runtime/grokSlotPreflightReceipt.d.ts.map +1 -0
  297. package/dist/runtime/grokSlotPreflightReceipt.js +101 -0
  298. package/dist/runtime/grokSubscriptionRealm.d.ts +4 -0
  299. package/dist/runtime/grokSubscriptionRealm.d.ts.map +1 -0
  300. package/dist/runtime/grokSubscriptionRealm.js +435 -0
  301. package/dist/runtime/grokSubscriptionRealmTypes.d.ts +26 -0
  302. package/dist/runtime/grokSubscriptionRealmTypes.d.ts.map +1 -0
  303. package/dist/runtime/grokSubscriptionRealmTypes.js +1 -0
  304. package/dist/runtime/grokWorkerAttestation.d.ts +170 -0
  305. package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -0
  306. package/dist/runtime/grokWorkerAttestation.js +266 -0
  307. package/dist/runtime/grokWorkerDenyPlacement.d.ts +80 -0
  308. package/dist/runtime/grokWorkerDenyPlacement.d.ts.map +1 -0
  309. package/dist/runtime/grokWorkerDenyPlacement.js +128 -0
  310. package/dist/runtime/grokWorkerHomeAttestation.d.ts +30 -0
  311. package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -0
  312. package/dist/runtime/grokWorkerHomeAttestation.js +69 -0
  313. package/dist/runtime/grokWorkerSandboxProfile.d.ts +27 -0
  314. package/dist/runtime/grokWorkerSandboxProfile.d.ts.map +1 -0
  315. package/dist/runtime/grokWorkerSandboxProfile.js +44 -0
  316. package/dist/runtime/grokWorkerTmpAttestation.d.ts +55 -0
  317. package/dist/runtime/grokWorkerTmpAttestation.d.ts.map +1 -0
  318. package/dist/runtime/grokWorkerTmpAttestation.js +63 -0
  319. package/dist/runtime/index.d.ts +26 -0
  320. package/dist/runtime/index.d.ts.map +1 -0
  321. package/dist/runtime/index.js +23 -0
  322. package/dist/runtime/inferenceUsageLedger.d.ts +38 -0
  323. package/dist/runtime/inferenceUsageLedger.d.ts.map +1 -0
  324. package/dist/runtime/inferenceUsageLedger.js +53 -0
  325. package/dist/runtime/mcpToolResult.d.ts +127 -0
  326. package/dist/runtime/mcpToolResult.d.ts.map +1 -0
  327. package/dist/runtime/mcpToolResult.js +214 -0
  328. package/dist/runtime/moltnetMachineRead.d.ts +97 -0
  329. package/dist/runtime/moltnetMachineRead.d.ts.map +1 -0
  330. package/dist/runtime/moltnetMachineRead.js +183 -0
  331. package/dist/runtime/native/daimon-engine-broker +0 -0
  332. package/dist/runtime/organizationRuntime.d.ts +165 -0
  333. package/dist/runtime/organizationRuntime.d.ts.map +1 -0
  334. package/dist/runtime/organizationRuntime.js +3 -0
  335. package/dist/runtime/organizationRuntimeControl.d.ts +42 -0
  336. package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -0
  337. package/dist/runtime/organizationRuntimeControl.js +235 -0
  338. package/dist/runtime/organizationRuntimeHost.d.ts +19 -0
  339. package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -0
  340. package/dist/runtime/organizationRuntimeHost.js +359 -0
  341. package/dist/runtime/organizationRuntimeParsing.d.ts +6 -0
  342. package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -0
  343. package/dist/runtime/organizationRuntimeParsing.js +370 -0
  344. package/dist/runtime/organizationRuntimeReadiness.d.ts +12 -0
  345. package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -0
  346. package/dist/runtime/organizationRuntimeReadiness.js +59 -0
  347. package/dist/runtime/physicalReadiness.d.ts +47 -0
  348. package/dist/runtime/physicalReadiness.d.ts.map +1 -0
  349. package/dist/runtime/physicalReadiness.js +142 -0
  350. package/dist/runtime/portableCredentialAuth.d.ts +6 -0
  351. package/dist/runtime/portableCredentialAuth.d.ts.map +1 -0
  352. package/dist/runtime/portableCredentialAuth.js +70 -0
  353. package/dist/runtime/portableCredentialMaterial.d.ts +8 -0
  354. package/dist/runtime/portableCredentialMaterial.d.ts.map +1 -0
  355. package/dist/runtime/portableCredentialMaterial.js +169 -0
  356. package/dist/runtime/productionAgentTools.d.ts +5 -0
  357. package/dist/runtime/productionAgentTools.d.ts.map +1 -0
  358. package/dist/runtime/productionAgentTools.js +328 -0
  359. package/dist/runtime/runtimeHomeLayout.d.ts +48 -0
  360. package/dist/runtime/runtimeHomeLayout.d.ts.map +1 -0
  361. package/dist/runtime/runtimeHomeLayout.js +84 -0
  362. package/dist/runtime/schedule.d.ts +40 -0
  363. package/dist/runtime/schedule.d.ts.map +1 -0
  364. package/dist/runtime/schedule.js +371 -0
  365. package/dist/runtime/storeCoordination.d.ts +23 -0
  366. package/dist/runtime/storeCoordination.d.ts.map +1 -0
  367. package/dist/runtime/storeCoordination.js +94 -0
  368. package/dist/runtime/toolResultSpill.d.ts +152 -0
  369. package/dist/runtime/toolResultSpill.d.ts.map +1 -0
  370. package/dist/runtime/toolResultSpill.js +351 -0
  371. package/dist/runtime/turnRequestLedger.d.ts +160 -0
  372. package/dist/runtime/turnRequestLedger.d.ts.map +1 -0
  373. package/dist/runtime/turnRequestLedger.js +249 -0
  374. package/dist/runtime/turnUsageLedger.d.ts +143 -0
  375. package/dist/runtime/turnUsageLedger.d.ts.map +1 -0
  376. package/dist/runtime/turnUsageLedger.js +203 -0
  377. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +17 -0
  378. package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -0
  379. package/dist/runtime/wakeAcceptanceProcessIdentity.js +50 -0
  380. package/dist/runtime/wakeAcceptanceReconciliation.d.ts +211 -0
  381. package/dist/runtime/wakeAcceptanceReconciliation.d.ts.map +1 -0
  382. package/dist/runtime/wakeAcceptanceReconciliation.js +289 -0
  383. package/dist/runtime/wakeAcceptanceRecord.d.ts +23 -0
  384. package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -0
  385. package/dist/runtime/wakeAcceptanceRecord.js +56 -0
  386. package/dist/runtime/wakeAcceptanceRetention.d.ts +12 -0
  387. package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -0
  388. package/dist/runtime/wakeAcceptanceRetention.js +12 -0
  389. package/dist/runtime/wakeAcceptanceStore.d.ts +113 -0
  390. package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -0
  391. package/dist/runtime/wakeAcceptanceStore.js +558 -0
  392. package/dist/runtime/wakeAcceptanceTypes.d.ts +179 -0
  393. package/dist/runtime/wakeAcceptanceTypes.d.ts.map +1 -0
  394. package/dist/runtime/wakeAcceptanceTypes.js +95 -0
  395. package/dist/runtime/wakeFuse.d.ts +69 -0
  396. package/dist/runtime/wakeFuse.d.ts.map +1 -0
  397. package/dist/runtime/wakeFuse.js +367 -0
  398. package/package.json +25 -17
  399. package/dist/examples/mixed-engine-org.d.ts +0 -2
  400. package/dist/examples/mixed-engine-org.d.ts.map +0 -1
  401. package/dist/examples/mixed-engine-org.js +0 -351
  402. package/dist/examples/mixedEngineCli.d.ts +0 -15
  403. package/dist/examples/mixedEngineCli.d.ts.map +0 -1
  404. package/dist/examples/mixedEngineCli.js +0 -174
@@ -0,0 +1,128 @@
1
+ import { type EngineBrokerLimitReason, type EngineBrokerTurnLimits, type EngineBrokerTurnUsage } from "./engineBrokerTurnAccounting.js";
2
+ /**
3
+ * `estimated` marks a request whose response carried no valid usage and was
4
+ * charged {@link estimateGrokRequestUsage}. `toolCalls` are the tool-call names
5
+ * that request's response carried, names only ({@link parseGrokResponseToolNames});
6
+ * absent means the response could not be decoded, `[]` that it called nothing.
7
+ */
8
+ export type GrokBrokerRequestTiming = Readonly<{
9
+ startedAt: string;
10
+ endedAt?: string;
11
+ usage?: EngineBrokerTurnUsage;
12
+ estimated?: true;
13
+ toolCalls?: readonly string[];
14
+ }>;
15
+ export type GrokBrokerTurnMeterSnapshot = Readonly<{
16
+ requests: number;
17
+ tokens: number;
18
+ limitReason: EngineBrokerLimitReason;
19
+ usage: EngineBrokerTurnUsage | null;
20
+ estimatedRequests: number;
21
+ timings: readonly GrokBrokerRequestTiming[];
22
+ }>;
23
+ /**
24
+ * The proxy's per-turn spend gate.
25
+ *
26
+ * Every forwarded model request of one turn passes through {@link admit}
27
+ * *before* a bearer is attached, so the checks are hard for requests and
28
+ * elapsed time and between-requests for tokens:
29
+ *
30
+ * - `maxRequests`: request `maxRequests + 1` is refused; upstream never sees it.
31
+ * - `timeoutMs`: a request arriving after the deadline is refused (the broker's
32
+ * own timer additionally kills a worker that is mid-request).
33
+ * - `maxTokens`: checked against the running total of upstream-reported usage
34
+ * of the requests already answered. A request is admitted while that total is
35
+ * still below the ceiling, so the overshoot is bounded by exactly one
36
+ * request's usage — the last admitted one. Usage counts total input
37
+ * *including* cached tokens (P0 observed an uncached replay at +55%).
38
+ *
39
+ * The first limit that fires is sticky: every later request is refused with
40
+ * the same reason, and `onLimit` runs once.
41
+ *
42
+ * The token bound is only a bound if no request can be admitted on a total
43
+ * that an in-flight request has not yet reported into. So a turn has at most
44
+ * ONE upstream request in flight: a second request arriving before the first
45
+ * settled is refused (`busy`, HTTP 429) without being counted or tripping a
46
+ * limit. Grok's headless loop is sequential — every live capture (P1
47
+ * live-round1, P2 live) shows each request ending before the next starts — so
48
+ * this refuses only a worker that is not behaving like Grok. Tripping a limit
49
+ * (including the broker's timer) aborts that in-flight upstream call through
50
+ * its own `AbortSignal` rather than letting it run to completion.
51
+ */
52
+ export declare class GrokBrokerTurnMeter {
53
+ readonly limits: EngineBrokerTurnLimits;
54
+ private readonly onLimit;
55
+ private readonly now;
56
+ private readonly startedAt;
57
+ private readonly timings;
58
+ private tokens;
59
+ private reason;
60
+ private inFlight;
61
+ constructor(limits: EngineBrokerTurnLimits, onLimit?: (reason: Exclude<EngineBrokerLimitReason, "none">) => void, now?: () => number);
62
+ /** Returns the request index and its upstream abort signal when admitted, the limit that refused it, or `busy` while another request is in flight. */
63
+ admit(): Readonly<{
64
+ index: number;
65
+ signal: AbortSignal;
66
+ } | {
67
+ refused: Exclude<EngineBrokerLimitReason, "none">;
68
+ } | {
69
+ busy: true;
70
+ }>;
71
+ /**
72
+ * Records one admitted request's end, its usage, and the tool-call names its
73
+ * response carried. A response without valid usage (absent, malformed,
74
+ * implausible, or a failed/aborted call) is charged a conservative estimate
75
+ * from the request body size, so a missing `usage` can never silently disable
76
+ * the token ceiling. `toolCalls` is observation only: it never affects
77
+ * admission, the running total, or any limit.
78
+ */
79
+ settle(index: number, usage: EngineBrokerTurnUsage | undefined, requestBytes: number, toolCalls?: readonly string[]): void;
80
+ /** Trips a limit from outside the request path (the broker's wall-clock timer). */
81
+ trip(reason: Exclude<EngineBrokerLimitReason, "none">): void;
82
+ /** Aborts the in-flight upstream call, if any (limit trip, or the broker ending the turn). */
83
+ abortInFlight(): void;
84
+ snapshot(): GrokBrokerTurnMeterSnapshot;
85
+ }
86
+ /** The charge for a request without valid usage: `ceil(bodyBytes / 2)` input plus a fixed output allowance. */
87
+ export declare const estimateGrokRequestUsage: (requestBytes: number) => EngineBrokerTurnUsage;
88
+ /**
89
+ * Upstream-reported usage of one chat-completions response, or `undefined`.
90
+ *
91
+ * The proxy buffers the whole upstream body, so the last `usage` object of an
92
+ * SSE stream (`stream_options.include_usage`) or of a JSON body is available
93
+ * before the body is returned to the worker. OpenAI-shaped `prompt_tokens`
94
+ * include cached tokens; they are split into disjoint buckets here, and any
95
+ * reasoning tokens reported outside `completion_tokens` (visible as
96
+ * `total_tokens` above prompt + completion) are folded into `output` so the
97
+ * total invariant holds. A malformed block, or one whose total exceeds
98
+ * `GROK_ENGINE_BROKER.turnLimits.requestUsageMaxTokens`, is invalid: never
99
+ * zero-filled and never added — the meter charges an estimate instead.
100
+ */
101
+ export declare function parseGrokUpstreamUsage(body: Uint8Array, contentType: string | undefined): EngineBrokerTurnUsage | undefined;
102
+ /** At most this many names per request row; a longer list ends in {@link GROK_TOOL_CALL_TRUNCATED}. */
103
+ export declare const GROK_REQUEST_TOOL_CALLS_MAX = 16;
104
+ /** A `name` that is not a plain short identifier is counted, never passed through. */
105
+ export declare const GROK_TOOL_CALL_INVALID = "<invalid>";
106
+ export declare const GROK_TOOL_CALL_TRUNCATED = "<truncated>";
107
+ /**
108
+ * The tool-call NAMES one upstream response carried, and nothing else.
109
+ *
110
+ * Two live turns could not answer "did the model ever try `use_tool` or
111
+ * `search_tool`", because the per-request rows recorded timings and tokens but
112
+ * never an attempt. This is that answer, under four rules:
113
+ *
114
+ * - names only. No arguments, no message content, no tokens, no header. A
115
+ * `name` that is not a plain short identifier is recorded as
116
+ * {@link GROK_TOOL_CALL_INVALID} rather than passing provider bytes through;
117
+ * - bounded. At most {@link GROK_REQUEST_TOOL_CALLS_MAX} entries, the last being
118
+ * {@link GROK_TOOL_CALL_TRUNCATED} when the response carried more, so a
119
+ * pathological response cannot write an unbounded row;
120
+ * - absence stays absence. A decoded response that called nothing returns `[]`;
121
+ * a response that could not be decoded returns `undefined` and the row records
122
+ * no field at all;
123
+ * - one streaming call names itself in one delta and streams its arguments in
124
+ * the rest, so a repeat of the same `(choice, call)` index is that same call,
125
+ * not a second attempt.
126
+ */
127
+ export declare function parseGrokResponseToolNames(body: Uint8Array, contentType: string | undefined): readonly string[] | undefined;
128
+ //# sourceMappingURL=grokBrokerTurnMeter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grokBrokerTurnMeter.d.ts","sourceRoot":"","sources":["../../src/runtime/grokBrokerTurnMeter.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAElK;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AACxK,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,uBAAuB,CAAC;IAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAA;CAAE,CAAC,CAAC;AAE5O;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,mBAAmB;IAMlB,QAAQ,CAAC,MAAM,EAAE,sBAAsB;IAAE,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAgF,OAAO,CAAC,QAAQ,CAAC,GAAG;IALjL,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiI;IACzJ,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,QAAQ,CAA6D;gBACxD,MAAM,EAAE,sBAAsB,EAAmB,OAAO,GAAE,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,KAAK,IAAsB,EAAmB,GAAG,GAAE,MAAM,MAAiB;IAI1M,sJAAsJ;IACtJ,KAAK,IAAI,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;IAclI;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAW1H,mFAAmF;IACnF,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,GAAG,IAAI;IAO5D,8FAA8F;IAC9F,aAAa,IAAI,IAAI;IAErB,QAAQ,IAAI,2BAA2B;CAIxC;AAID,+GAA+G;AAC/G,eAAO,MAAM,wBAAwB,GAAI,cAAc,MAAM,KAAG,qBAG/D,CAAC;AAMF;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAU3H;AA0BD,uGAAuG;AACvG,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAClD,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CA2B3H"}
@@ -0,0 +1,251 @@
1
+ import { GROK_ENGINE_BROKER } from "../contracts/runtimeContractManifest.js";
2
+ import { sumEngineBrokerTurnUsage } from "./engineBrokerTurnAccounting.js";
3
+ /**
4
+ * The proxy's per-turn spend gate.
5
+ *
6
+ * Every forwarded model request of one turn passes through {@link admit}
7
+ * *before* a bearer is attached, so the checks are hard for requests and
8
+ * elapsed time and between-requests for tokens:
9
+ *
10
+ * - `maxRequests`: request `maxRequests + 1` is refused; upstream never sees it.
11
+ * - `timeoutMs`: a request arriving after the deadline is refused (the broker's
12
+ * own timer additionally kills a worker that is mid-request).
13
+ * - `maxTokens`: checked against the running total of upstream-reported usage
14
+ * of the requests already answered. A request is admitted while that total is
15
+ * still below the ceiling, so the overshoot is bounded by exactly one
16
+ * request's usage — the last admitted one. Usage counts total input
17
+ * *including* cached tokens (P0 observed an uncached replay at +55%).
18
+ *
19
+ * The first limit that fires is sticky: every later request is refused with
20
+ * the same reason, and `onLimit` runs once.
21
+ *
22
+ * The token bound is only a bound if no request can be admitted on a total
23
+ * that an in-flight request has not yet reported into. So a turn has at most
24
+ * ONE upstream request in flight: a second request arriving before the first
25
+ * settled is refused (`busy`, HTTP 429) without being counted or tripping a
26
+ * limit. Grok's headless loop is sequential — every live capture (P1
27
+ * live-round1, P2 live) shows each request ending before the next starts — so
28
+ * this refuses only a worker that is not behaving like Grok. Tripping a limit
29
+ * (including the broker's timer) aborts that in-flight upstream call through
30
+ * its own `AbortSignal` rather than letting it run to completion.
31
+ */
32
+ export class GrokBrokerTurnMeter {
33
+ limits;
34
+ onLimit;
35
+ now;
36
+ startedAt;
37
+ timings = [];
38
+ tokens = 0;
39
+ reason = "none";
40
+ inFlight;
41
+ constructor(limits, onLimit = () => undefined, now = Date.now) {
42
+ this.limits = limits;
43
+ this.onLimit = onLimit;
44
+ this.now = now;
45
+ this.startedAt = now();
46
+ }
47
+ /** Returns the request index and its upstream abort signal when admitted, the limit that refused it, or `busy` while another request is in flight. */
48
+ admit() {
49
+ if (this.reason === "none") {
50
+ if (this.now() - this.startedAt >= this.limits.timeoutMs)
51
+ this.trip("timeout");
52
+ else if (this.timings.length >= this.limits.maxRequests)
53
+ this.trip("requests");
54
+ else if (this.tokens >= this.limits.maxTokens)
55
+ this.trip("tokens");
56
+ }
57
+ if (this.reason !== "none")
58
+ return { refused: this.reason };
59
+ if (this.inFlight !== undefined)
60
+ return { busy: true };
61
+ this.timings.push({ startedAt: new Date(this.now()).toISOString() });
62
+ const controller = new AbortController();
63
+ this.inFlight = { index: this.timings.length - 1, controller };
64
+ return { index: this.inFlight.index, signal: controller.signal };
65
+ }
66
+ /**
67
+ * Records one admitted request's end, its usage, and the tool-call names its
68
+ * response carried. A response without valid usage (absent, malformed,
69
+ * implausible, or a failed/aborted call) is charged a conservative estimate
70
+ * from the request body size, so a missing `usage` can never silently disable
71
+ * the token ceiling. `toolCalls` is observation only: it never affects
72
+ * admission, the running total, or any limit.
73
+ */
74
+ settle(index, usage, requestBytes, toolCalls) {
75
+ const timing = this.timings[index];
76
+ if (timing === undefined || timing.endedAt !== undefined)
77
+ return;
78
+ if (this.inFlight?.index === index)
79
+ this.inFlight = undefined;
80
+ timing.endedAt = new Date(this.now()).toISOString();
81
+ if (usage === undefined) {
82
+ timing.usage = estimateGrokRequestUsage(requestBytes);
83
+ timing.estimated = true;
84
+ }
85
+ else
86
+ timing.usage = usage;
87
+ if (toolCalls !== undefined)
88
+ timing.toolCalls = toolCalls;
89
+ this.tokens += timing.usage.total;
90
+ }
91
+ /** Trips a limit from outside the request path (the broker's wall-clock timer). */
92
+ trip(reason) {
93
+ if (this.reason !== "none")
94
+ return;
95
+ this.reason = reason;
96
+ this.abortInFlight();
97
+ this.onLimit(reason);
98
+ }
99
+ /** Aborts the in-flight upstream call, if any (limit trip, or the broker ending the turn). */
100
+ abortInFlight() { this.inFlight?.controller.abort(); }
101
+ snapshot() {
102
+ const measured = this.timings.flatMap((timing) => timing.usage === undefined ? [] : [timing.usage]);
103
+ return { requests: this.timings.length, tokens: this.tokens, limitReason: this.reason, usage: sumEngineBrokerTurnUsage(measured), estimatedRequests: this.timings.filter((timing) => timing.estimated === true).length, timings: this.timings.map((timing) => Object.freeze({ ...timing })) };
104
+ }
105
+ }
106
+ const { requestUsageMaxTokens, missingUsageEstimate } = GROK_ENGINE_BROKER.turnLimits;
107
+ /** The charge for a request without valid usage: `ceil(bodyBytes / 2)` input plus a fixed output allowance. */
108
+ export const estimateGrokRequestUsage = (requestBytes) => {
109
+ const input = Math.ceil(Math.max(0, requestBytes) / missingUsageEstimate.inputBytesPerToken), output = missingUsageEstimate.outputTokens;
110
+ return { input, cacheRead: 0, cacheWrite: 0, output, total: input + output };
111
+ };
112
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
113
+ const count = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
114
+ /**
115
+ * Upstream-reported usage of one chat-completions response, or `undefined`.
116
+ *
117
+ * The proxy buffers the whole upstream body, so the last `usage` object of an
118
+ * SSE stream (`stream_options.include_usage`) or of a JSON body is available
119
+ * before the body is returned to the worker. OpenAI-shaped `prompt_tokens`
120
+ * include cached tokens; they are split into disjoint buckets here, and any
121
+ * reasoning tokens reported outside `completion_tokens` (visible as
122
+ * `total_tokens` above prompt + completion) are folded into `output` so the
123
+ * total invariant holds. A malformed block, or one whose total exceeds
124
+ * `GROK_ENGINE_BROKER.turnLimits.requestUsageMaxTokens`, is invalid: never
125
+ * zero-filled and never added — the meter charges an estimate instead.
126
+ */
127
+ export function parseGrokUpstreamUsage(body, contentType) {
128
+ let found;
129
+ for (const candidate of decodeUpstreamResponse(body, contentType) ?? []) {
130
+ if (!isRecord(candidate) || !isRecord(candidate.usage))
131
+ continue;
132
+ // Last usage block wins even when invalid: an implausible final report
133
+ // must not fall back to an earlier, smaller block (the request is then
134
+ // charged the estimate instead).
135
+ found = decodeOpenAiUsage(candidate.usage);
136
+ }
137
+ return found;
138
+ }
139
+ /**
140
+ * Every decodable JSON object of one upstream response: each `data:` event of
141
+ * an SSE stream, or the single body of a JSON response.
142
+ *
143
+ * `undefined` means *nothing* decoded — an unparseable or non-JSON response.
144
+ * Callers must keep that distinct from a decoded response that said nothing,
145
+ * because the ledger never fabricates an observation it did not make.
146
+ */
147
+ function decodeUpstreamResponse(body, contentType) {
148
+ const text = Buffer.from(body.buffer, body.byteOffset, body.byteLength).toString("utf8");
149
+ const candidates = [];
150
+ if (contentType?.includes("text/event-stream") === true || text.startsWith("data:")) {
151
+ for (const line of text.split(/\r?\n/u)) {
152
+ if (!line.startsWith("data:"))
153
+ continue;
154
+ const payload = line.slice(5).trim();
155
+ if (payload === "[DONE]" || payload.length === 0)
156
+ continue;
157
+ try {
158
+ candidates.push(JSON.parse(payload));
159
+ }
160
+ catch { /* a non-JSON event carries neither usage nor a tool call */ }
161
+ }
162
+ }
163
+ else {
164
+ try {
165
+ candidates.push(JSON.parse(text));
166
+ }
167
+ catch {
168
+ return undefined;
169
+ }
170
+ }
171
+ return candidates.length === 0 ? undefined : candidates;
172
+ }
173
+ /** At most this many names per request row; a longer list ends in {@link GROK_TOOL_CALL_TRUNCATED}. */
174
+ export const GROK_REQUEST_TOOL_CALLS_MAX = 16;
175
+ /** A `name` that is not a plain short identifier is counted, never passed through. */
176
+ export const GROK_TOOL_CALL_INVALID = "<invalid>";
177
+ export const GROK_TOOL_CALL_TRUNCATED = "<truncated>";
178
+ const TOOL_CALL_NAME = /^[A-Za-z0-9_.-]{1,64}$/u;
179
+ /**
180
+ * The tool-call NAMES one upstream response carried, and nothing else.
181
+ *
182
+ * Two live turns could not answer "did the model ever try `use_tool` or
183
+ * `search_tool`", because the per-request rows recorded timings and tokens but
184
+ * never an attempt. This is that answer, under four rules:
185
+ *
186
+ * - names only. No arguments, no message content, no tokens, no header. A
187
+ * `name` that is not a plain short identifier is recorded as
188
+ * {@link GROK_TOOL_CALL_INVALID} rather than passing provider bytes through;
189
+ * - bounded. At most {@link GROK_REQUEST_TOOL_CALLS_MAX} entries, the last being
190
+ * {@link GROK_TOOL_CALL_TRUNCATED} when the response carried more, so a
191
+ * pathological response cannot write an unbounded row;
192
+ * - absence stays absence. A decoded response that called nothing returns `[]`;
193
+ * a response that could not be decoded returns `undefined` and the row records
194
+ * no field at all;
195
+ * - one streaming call names itself in one delta and streams its arguments in
196
+ * the rest, so a repeat of the same `(choice, call)` index is that same call,
197
+ * not a second attempt.
198
+ */
199
+ export function parseGrokResponseToolNames(body, contentType) {
200
+ const candidates = decodeUpstreamResponse(body, contentType);
201
+ if (candidates === undefined)
202
+ return undefined;
203
+ const names = [], seen = new Set();
204
+ scan: for (const candidate of candidates) {
205
+ if (!isRecord(candidate) || !Array.isArray(candidate.choices))
206
+ continue;
207
+ for (const choice of candidate.choices) {
208
+ if (!isRecord(choice))
209
+ continue;
210
+ for (const source of [choice.delta, choice.message]) {
211
+ if (!isRecord(source) || !Array.isArray(source.tool_calls))
212
+ continue;
213
+ for (const call of source.tool_calls) {
214
+ if (!isRecord(call) || !isRecord(call.function))
215
+ continue;
216
+ const name = call.function.name;
217
+ // An arguments-only delta names nothing; it is not an attempt of its own.
218
+ if (typeof name !== "string" || name.length === 0)
219
+ continue;
220
+ if (typeof choice.index === "number" && typeof call.index === "number") {
221
+ const key = `${choice.index}:${call.index}`;
222
+ if (seen.has(key))
223
+ continue;
224
+ seen.add(key);
225
+ }
226
+ names.push(TOOL_CALL_NAME.test(name) ? name : GROK_TOOL_CALL_INVALID);
227
+ if (names.length > GROK_REQUEST_TOOL_CALLS_MAX)
228
+ break scan;
229
+ }
230
+ }
231
+ }
232
+ }
233
+ return names.length > GROK_REQUEST_TOOL_CALLS_MAX ? [...names.slice(0, GROK_REQUEST_TOOL_CALLS_MAX - 1), GROK_TOOL_CALL_TRUNCATED] : names;
234
+ }
235
+ function decodeOpenAiUsage(usage) {
236
+ const prompt = count(usage.prompt_tokens), completion = count(usage.completion_tokens);
237
+ if (prompt === undefined || completion === undefined)
238
+ return undefined;
239
+ const details = isRecord(usage.prompt_tokens_details) ? usage.prompt_tokens_details : {};
240
+ const cached = details.cached_tokens === undefined ? 0 : count(details.cached_tokens);
241
+ const reported = usage.total_tokens === undefined ? prompt + completion : count(usage.total_tokens);
242
+ if (cached === undefined || reported === undefined || cached > prompt)
243
+ return undefined;
244
+ const total = Math.max(reported, prompt + completion);
245
+ const completionDetails = isRecord(usage.completion_tokens_details) ? usage.completion_tokens_details : {};
246
+ const reasoning = count(completionDetails.reasoning_tokens);
247
+ const output = total - prompt;
248
+ if (total > requestUsageMaxTokens)
249
+ return undefined;
250
+ return { input: prompt - cached, cacheRead: cached, cacheWrite: 0, output, total, ...(reasoning === undefined || reasoning > output ? {} : { reasoning }) };
251
+ }
@@ -0,0 +1,86 @@
1
+ import { type GrokBrokerModelPolicy } from "./grokBrokerModelPolicy.js";
2
+ export { DAIMON_GROK_SYSTEM_PROMPT, GROK_WORKER_MAX_TURNS, GROK_WORKER_TOOL_IDS, GROK_WORKER_VISIBLE_TOOLS } from "../contracts/grokWorkerContract.js";
3
+ /**
4
+ * Bundled skills shipped by Grok CLI 1.0.34. Names are version-specific:
5
+ * `[skills] disabled` removed all ~2.1k skill tokens in the P0 matrix, and a
6
+ * CLI bump must re-derive this list rather than inherit it.
7
+ */
8
+ export declare const GROK_1_0_34_BUNDLED_SKILLS: readonly ["build-with-ai", "code-review", "create-skill", "create-workflow", "design", "docx", "execute-plan", "game-animation-frames", "game-asset-core", "game-character-consistency", "game-tilesets", "game-ui-icons", "imagine", "implement", "learn", "long-running-background-tasks", "pdf", "pptx", "pr-babysit", "resume-claude", "resume-codex", "resume-cursor", "review", "skill-design-principles", "statusline"];
9
+ /** The worker's only model id; the argv selects it and the proxy never sees another. */
10
+ export declare const GROK_BROKER_WORKER_MODEL_ID: "daimon-broker-grok";
11
+ /**
12
+ * Grok 1.0.34 sends a `session_title` model request before every headless
13
+ * turn, and no config key or environment variable disables it
14
+ * (`features.title_refresh` governs only the later refresh; verified against a
15
+ * loopback stub). `[models] session_summary` does select the model it uses, so
16
+ * the title goes to a hidden model whose endpoint is the broker's own provider
17
+ * proxy with a placeholder key that can never be a turn capability (shorter
18
+ * than the 40-character capability alphabet). The proxy refuses it before any
19
+ * capability lookup, isolation guard, credential read, or upstream call, and
20
+ * Grok falls back to the truncated prompt as the title. The endpoint is always
21
+ * listening while a worker runs, so the refusal is bounded by one loopback
22
+ * round trip rather than by a connect timeout, and a prompt-derived title is
23
+ * never delivered anywhere but Daimon's own proxy.
24
+ */
25
+ export declare const GROK_SESSION_TITLE_SINK_MODEL_ID: "daimon-session-title-disabled";
26
+ export declare const GROK_SESSION_TITLE_SINK_KEY: "session-title-disabled";
27
+ /**
28
+ * The turn-scoped proxy capability reaches the worker's only model through
29
+ * `env_key`, set by the native launcher. Grok 1.0.34 accepts
30
+ * `[auth_provider.<name>]` tables but never runs the helper for a custom model
31
+ * (verified against a loopback stub: no helper invocation and no Authorization
32
+ * header, with and without `args`, `api_backend`, `model_providers`, or a
33
+ * passwd-home config), while `env_key` attaches the bearer on every request.
34
+ * The capability is exactly as exposed as `DAIMON_MCP_CAPABILITY`: visible to
35
+ * the worker's own tool children, which run network-restricted, and revoked
36
+ * when the turn ends.
37
+ */
38
+ export declare const GROK_BROKER_PROVIDER_CAPABILITY_ENV: "DAIMON_PROVIDER_CAPABILITY";
39
+ type WorkerEndpoints = Readonly<{
40
+ proxyPort: number;
41
+ mcpUrl: string;
42
+ }>;
43
+ /**
44
+ * Sections shared by every Grok worker Daimon configures, broker or direct.
45
+ *
46
+ * Each toggle is either measured (skills −2.1k tokens, workflows −314, the
47
+ * per-turn `session_title` model request) or behavioural hardening that P0
48
+ * showed to be token-neutral and warning-free on 1.0.34.
49
+ */
50
+ export declare const renderGrokLeanBaseConfig: () => string;
51
+ /**
52
+ * `max_retries = 0` on the worker's own model, for the same reason its two
53
+ * siblings already carry it (the session-title sink above,
54
+ * `grokInferenceClientConfig.ts` for the evaluator): with Grok 1.0.34's
55
+ * default, a refused or failed request is retried with backoff **past 45 s**
56
+ * instead of failing in ~0.35 s, and the retries are blind — one live turn
57
+ * emitted the same refusal fifteen times over five minutes, spent $0, and died
58
+ * with no account of why. Only this model block was left on the default, so
59
+ * the one request path that spends money was also the only one that could
60
+ * stall a turn for minutes after its work was done. Daimon owns the retry
61
+ * decision here because the proxy is the thing being retried: a genuinely
62
+ * transient fault is already answered 503 and is the broker's to retry, and
63
+ * anything else is a refusal that repeating cannot fix. The worker instead
64
+ * fails fast and the turn reaches the host with a status.
65
+ */
66
+ /**
67
+ * The only source of broker worker `config.toml` bytes.
68
+ *
69
+ * Effort is declared here, not on the compiled launcher argv: the argv is one
70
+ * constant for every registration while effort is declared per deployment, and
71
+ * Grok 1.0.34 drops both `--reasoning-effort` and `[models]
72
+ * default_reasoning_effort` unless the model advertises effort support. A
73
+ * one-entry `reasoning_efforts` table makes the declared effort the model's
74
+ * default *and* its closed enum, so it reaches the request body and nothing
75
+ * else can be selected; the proxy then re-verifies it on every body.
76
+ */
77
+ export declare function renderGrokBrokerWorkerConfig(policy?: Partial<GrokBrokerModelPolicy>): string;
78
+ /** Explicit-endpoint variant for the local live probe; production bytes come only from the function above. */
79
+ export declare function renderGrokBrokerWorkerConfigWith(policy: GrokBrokerModelPolicy, endpoints: WorkerEndpoints): string;
80
+ export declare const grokBrokerWorkerConfigSha256: (policy?: Partial<GrokBrokerModelPolicy>) => string;
81
+ /**
82
+ * TypeScript mirror of the argv compiled into `native/engineBrokerLauncherCore.inc`.
83
+ * `native/launcherArgv.test.ts` parses the C source and fails on any divergence.
84
+ */
85
+ export declare const renderGrokBrokerWorkerArgs: (promptFile: string, cwd: string) => readonly string[];
86
+ //# sourceMappingURL=grokBrokerWorkerConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grokBrokerWorkerConfig.d.ts","sourceRoot":"","sources":["../../src/runtime/grokBrokerWorkerConfig.ts"],"names":[],"mappings":"AAKA,OAAO,EAA8B,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAEvJ;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,gaAK5B,CAAC;AAEZ,wFAAwF;AACxF,eAAO,MAAM,2BAA2B,EAAG,oBAA6B,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,EAAG,+BAAwC,CAAC;AACzF,eAAO,MAAM,2BAA2B,EAAG,wBAAiC,CAAC;AAM7E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mCAAmC,EAAG,4BAAqC,CAAC;AAEzF,KAAK,eAAe,GAAG,QAAQ,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAMvE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAQhC,CAAC;AAEb;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,GAAE,OAAO,CAAC,qBAAqB,CAAM,GAAG,MAAM,CAEhG;AAED,8GAA8G;AAC9G,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAgBlH;AAED,eAAO,MAAM,4BAA4B,GAAI,SAAQ,OAAO,CAAC,qBAAqB,CAAM,KAAG,MACV,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,YAAY,MAAM,EAAE,KAAK,MAAM,KAAG,SAAS,MAAM,EAU3F,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { createHash } from "node:crypto";
2
+ import path from "node:path";
3
+ import { GROK_ENGINE_BROKER } from "../contracts/runtimeContractManifest.js";
4
+ import { DAIMON_GROK_SYSTEM_PROMPT, GROK_WORKER_MAX_TURNS, GROK_WORKER_TOOL_IDS } from "../contracts/grokWorkerContract.js";
5
+ import { parseGrokBrokerModelPolicy } from "./grokBrokerModelPolicy.js";
6
+ export { DAIMON_GROK_SYSTEM_PROMPT, GROK_WORKER_MAX_TURNS, GROK_WORKER_TOOL_IDS, GROK_WORKER_VISIBLE_TOOLS } from "../contracts/grokWorkerContract.js";
7
+ /**
8
+ * Bundled skills shipped by Grok CLI 1.0.34. Names are version-specific:
9
+ * `[skills] disabled` removed all ~2.1k skill tokens in the P0 matrix, and a
10
+ * CLI bump must re-derive this list rather than inherit it.
11
+ */
12
+ export const GROK_1_0_34_BUNDLED_SKILLS = Object.freeze([
13
+ "build-with-ai", "code-review", "create-skill", "create-workflow", "design", "docx", "execute-plan",
14
+ "game-animation-frames", "game-asset-core", "game-character-consistency", "game-tilesets", "game-ui-icons",
15
+ "imagine", "implement", "learn", "long-running-background-tasks", "pdf", "pptx", "pr-babysit",
16
+ "resume-claude", "resume-codex", "resume-cursor", "review", "skill-design-principles", "statusline"
17
+ ]);
18
+ /** The worker's only model id; the argv selects it and the proxy never sees another. */
19
+ export const GROK_BROKER_WORKER_MODEL_ID = "daimon-broker-grok";
20
+ /**
21
+ * Grok 1.0.34 sends a `session_title` model request before every headless
22
+ * turn, and no config key or environment variable disables it
23
+ * (`features.title_refresh` governs only the later refresh; verified against a
24
+ * loopback stub). `[models] session_summary` does select the model it uses, so
25
+ * the title goes to a hidden model whose endpoint is the broker's own provider
26
+ * proxy with a placeholder key that can never be a turn capability (shorter
27
+ * than the 40-character capability alphabet). The proxy refuses it before any
28
+ * capability lookup, isolation guard, credential read, or upstream call, and
29
+ * Grok falls back to the truncated prompt as the title. The endpoint is always
30
+ * listening while a worker runs, so the refusal is bounded by one loopback
31
+ * round trip rather than by a connect timeout, and a prompt-derived title is
32
+ * never delivered anywhere but Daimon's own proxy.
33
+ */
34
+ export const GROK_SESSION_TITLE_SINK_MODEL_ID = "daimon-session-title-disabled";
35
+ export const GROK_SESSION_TITLE_SINK_KEY = "session-title-disabled";
36
+ const renderSessionTitleSink = (proxyPort) => [
37
+ `[model.${GROK_SESSION_TITLE_SINK_MODEL_ID}]`, 'model = "disabled"', `base_url = "http://127.0.0.1:${proxyPort}/v1"`, `api_key = "${GROK_SESSION_TITLE_SINK_KEY}"`,
38
+ "max_retries = 0", "hidden = true", ""
39
+ ];
40
+ /**
41
+ * The turn-scoped proxy capability reaches the worker's only model through
42
+ * `env_key`, set by the native launcher. Grok 1.0.34 accepts
43
+ * `[auth_provider.<name>]` tables but never runs the helper for a custom model
44
+ * (verified against a loopback stub: no helper invocation and no Authorization
45
+ * header, with and without `args`, `api_backend`, `model_providers`, or a
46
+ * passwd-home config), while `env_key` attaches the bearer on every request.
47
+ * The capability is exactly as exposed as `DAIMON_MCP_CAPABILITY`: visible to
48
+ * the worker's own tool children, which run network-restricted, and revoked
49
+ * when the turn ends.
50
+ */
51
+ export const GROK_BROKER_PROVIDER_CAPABILITY_ENV = "DAIMON_PROVIDER_CAPABILITY";
52
+ const PRODUCTION_ENDPOINTS = Object.freeze({
53
+ proxyPort: GROK_ENGINE_BROKER.providerProxy.port,
54
+ mcpUrl: `http://${GROK_ENGINE_BROKER.mcpFacade.host}:${GROK_ENGINE_BROKER.mcpFacade.port}${GROK_ENGINE_BROKER.mcpFacade.path}`
55
+ });
56
+ /**
57
+ * Sections shared by every Grok worker Daimon configures, broker or direct.
58
+ *
59
+ * Each toggle is either measured (skills −2.1k tokens, workflows −314, the
60
+ * per-turn `session_title` model request) or behavioural hardening that P0
61
+ * showed to be token-neutral and warning-free on 1.0.34.
62
+ */
63
+ export const renderGrokLeanBaseConfig = () => [
64
+ "[cli]", "auto_update = false", "use_leader = false", "show_tips = false", "",
65
+ "[features]", "telemetry = false", "title_refresh = false", "session_recap = false", "turn_summary = false",
66
+ "repo_status_in_system_prompt = false", "codebase_indexing = false", "backend_tools = false", "ask_user_question = false",
67
+ "image_gen = false", "video_gen = false", "web_fetch = false", "campaigns = false", "managed_config = false", "",
68
+ "[managed_mcps]", "enabled = false", "",
69
+ "[skills]", `disabled = [${GROK_1_0_34_BUNDLED_SKILLS.map((name) => JSON.stringify(name)).join(", ")}]`, "",
70
+ "[workflows]", "enabled = false", ""
71
+ ].join("\n");
72
+ /**
73
+ * `max_retries = 0` on the worker's own model, for the same reason its two
74
+ * siblings already carry it (the session-title sink above,
75
+ * `grokInferenceClientConfig.ts` for the evaluator): with Grok 1.0.34's
76
+ * default, a refused or failed request is retried with backoff **past 45 s**
77
+ * instead of failing in ~0.35 s, and the retries are blind — one live turn
78
+ * emitted the same refusal fifteen times over five minutes, spent $0, and died
79
+ * with no account of why. Only this model block was left on the default, so
80
+ * the one request path that spends money was also the only one that could
81
+ * stall a turn for minutes after its work was done. Daimon owns the retry
82
+ * decision here because the proxy is the thing being retried: a genuinely
83
+ * transient fault is already answered 503 and is the broker's to retry, and
84
+ * anything else is a refusal that repeating cannot fix. The worker instead
85
+ * fails fast and the turn reaches the host with a status.
86
+ */
87
+ /**
88
+ * The only source of broker worker `config.toml` bytes.
89
+ *
90
+ * Effort is declared here, not on the compiled launcher argv: the argv is one
91
+ * constant for every registration while effort is declared per deployment, and
92
+ * Grok 1.0.34 drops both `--reasoning-effort` and `[models]
93
+ * default_reasoning_effort` unless the model advertises effort support. A
94
+ * one-entry `reasoning_efforts` table makes the declared effort the model's
95
+ * default *and* its closed enum, so it reaches the request body and nothing
96
+ * else can be selected; the proxy then re-verifies it on every body.
97
+ */
98
+ export function renderGrokBrokerWorkerConfig(policy = {}) {
99
+ return renderGrokBrokerWorkerConfigWith(parseGrokBrokerModelPolicy(policy), PRODUCTION_ENDPOINTS);
100
+ }
101
+ /** Explicit-endpoint variant for the local live probe; production bytes come only from the function above. */
102
+ export function renderGrokBrokerWorkerConfigWith(policy, endpoints) {
103
+ const declared = parseGrokBrokerModelPolicy(policy);
104
+ const { proxyPort, mcpUrl } = endpoints;
105
+ if (!Number.isInteger(proxyPort) || proxyPort < 1 || proxyPort > 65_535 || !/^http:\/\/127\.0\.0\.1:\d{1,5}\/mcp$/u.test(mcpUrl)) {
106
+ throw new TypeError("invalid Grok broker worker configuration");
107
+ }
108
+ const label = `${declared.reasoningEffort[0].toUpperCase()}${declared.reasoningEffort.slice(1)}`;
109
+ return [
110
+ renderGrokLeanBaseConfig(),
111
+ "[models]", `default = "${GROK_BROKER_WORKER_MODEL_ID}"`, `default_reasoning_effort = "${declared.reasoningEffort}"`, `session_summary = "${GROK_SESSION_TITLE_SINK_MODEL_ID}"`, "",
112
+ ...renderSessionTitleSink(proxyPort),
113
+ `[model.${GROK_BROKER_WORKER_MODEL_ID}]`, `model = "${declared.model}"`, `base_url = "http://127.0.0.1:${proxyPort}/v1"`, `env_key = "${GROK_BROKER_PROVIDER_CAPABILITY_ENV}"`,
114
+ 'api_backend = "chat_completions"', "context_window = 131072", "supports_backend_search = false", "max_retries = 0", "",
115
+ `[[model.${GROK_BROKER_WORKER_MODEL_ID}.reasoning_efforts]]`, `value = "${declared.reasoningEffort}"`, `label = "${label}"`, "default = true", "",
116
+ "[mcp_servers.daimon]", `url = "${mcpUrl}"`, 'bearer_token_env_var = "DAIMON_MCP_CAPABILITY"', ""
117
+ ].join("\n");
118
+ }
119
+ export const grokBrokerWorkerConfigSha256 = (policy = {}) => createHash("sha256").update(renderGrokBrokerWorkerConfig(policy)).digest("hex");
120
+ /**
121
+ * TypeScript mirror of the argv compiled into `native/engineBrokerLauncherCore.inc`.
122
+ * `native/launcherArgv.test.ts` parses the C source and fails on any divergence.
123
+ */
124
+ export const renderGrokBrokerWorkerArgs = (promptFile, cwd) => {
125
+ if (!path.posix.isAbsolute(promptFile) || !path.posix.isAbsolute(cwd))
126
+ throw new TypeError("invalid Grok broker worker path");
127
+ return [
128
+ "--sandbox", "daimon-strict", "--always-approve", "--no-subagents", "--prompt-file", promptFile,
129
+ "--no-memory", "--disable-web-search", "--no-plan", "--verbatim",
130
+ "--system-prompt-override", DAIMON_GROK_SYSTEM_PROMPT,
131
+ "--tools", GROK_WORKER_TOOL_IDS.join(","),
132
+ "--max-turns", String(GROK_WORKER_MAX_TURNS),
133
+ "--cwd", cwd, "--output-format", "streaming-messages-json", "--model", GROK_BROKER_WORKER_MODEL_ID
134
+ ];
135
+ };