@prismatic-io/lux 0.0.2-preview.3 → 0.0.2-preview.32

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 (727) hide show
  1. package/lib/answerers/claude-code/index.d.ts +15 -3
  2. package/lib/answerers/claude-code/index.d.ts.map +1 -1
  3. package/lib/answerers/claude-code/index.js +6 -5
  4. package/lib/answerers/claude-code/index.js.map +1 -1
  5. package/lib/answerers/persona/index.d.ts +44 -5
  6. package/lib/answerers/persona/index.d.ts.map +1 -1
  7. package/lib/answerers/persona/index.js +60 -34
  8. package/lib/answerers/persona/index.js.map +1 -1
  9. package/lib/answerers/terminal/index.d.ts +9 -3
  10. package/lib/answerers/terminal/index.d.ts.map +1 -1
  11. package/lib/answerers/terminal/index.js +7 -5
  12. package/lib/answerers/terminal/index.js.map +1 -1
  13. package/lib/assertions/authoring.d.ts +2 -2
  14. package/lib/assertions/authoring.d.ts.map +1 -1
  15. package/lib/assertions/authoring.js.map +1 -1
  16. package/lib/assertions/core/command-exits-zero.d.ts +4 -1
  17. package/lib/assertions/core/command-exits-zero.d.ts.map +1 -1
  18. package/lib/assertions/core/command-exits-zero.js +50 -7
  19. package/lib/assertions/core/command-exits-zero.js.map +1 -1
  20. package/lib/assertions/core/event-checks.d.ts +3 -0
  21. package/lib/assertions/core/event-checks.d.ts.map +1 -1
  22. package/lib/assertions/core/event-checks.js +49 -3
  23. package/lib/assertions/core/event-checks.js.map +1 -1
  24. package/lib/assertions/core/file-checks.d.ts +6 -0
  25. package/lib/assertions/core/file-checks.d.ts.map +1 -1
  26. package/lib/assertions/core/helpers.d.ts +2 -7
  27. package/lib/assertions/core/helpers.d.ts.map +1 -1
  28. package/lib/assertions/core/helpers.js +2 -6
  29. package/lib/assertions/core/helpers.js.map +1 -1
  30. package/lib/assertions/core/index.d.ts.map +1 -1
  31. package/lib/assertions/core/index.js +2 -1
  32. package/lib/assertions/core/index.js.map +1 -1
  33. package/lib/assertions/core/json-pointer-equals.d.ts +1 -0
  34. package/lib/assertions/core/json-pointer-equals.d.ts.map +1 -1
  35. package/lib/assertions/core/output-checks.d.ts +3 -0
  36. package/lib/assertions/core/output-checks.d.ts.map +1 -1
  37. package/lib/assertions/core/predicate.d.ts +1 -0
  38. package/lib/assertions/core/predicate.d.ts.map +1 -1
  39. package/lib/assertions/core/resource-checks.d.ts +25 -0
  40. package/lib/assertions/core/resource-checks.d.ts.map +1 -1
  41. package/lib/assertions/core/resource-checks.js +35 -5
  42. package/lib/assertions/core/resource-checks.js.map +1 -1
  43. package/lib/assertions/rubric/index.d.ts +28 -3
  44. package/lib/assertions/rubric/index.d.ts.map +1 -1
  45. package/lib/assertions/rubric/index.js +59 -13
  46. package/lib/assertions/rubric/index.js.map +1 -1
  47. package/lib/assertions/rubric/internal.d.ts +30 -5
  48. package/lib/assertions/rubric/internal.d.ts.map +1 -1
  49. package/lib/assertions/rubric/internal.js +181 -28
  50. package/lib/assertions/rubric/internal.js.map +1 -1
  51. package/lib/authoring.d.ts +36 -2
  52. package/lib/authoring.d.ts.map +1 -1
  53. package/lib/authoring.js +36 -1
  54. package/lib/authoring.js.map +1 -1
  55. package/lib/cli/bin.js +2 -13
  56. package/lib/cli/bin.js.map +1 -1
  57. package/lib/cli/command-runtime.d.ts +3 -3
  58. package/lib/cli/command-runtime.d.ts.map +1 -1
  59. package/lib/cli/command-runtime.js +17 -6
  60. package/lib/cli/command-runtime.js.map +1 -1
  61. package/lib/cli/doctor.d.ts +55 -0
  62. package/lib/cli/doctor.d.ts.map +1 -0
  63. package/lib/cli/doctor.js +14 -0
  64. package/lib/cli/doctor.js.map +1 -0
  65. package/lib/cli/harness-plan.d.ts +26 -0
  66. package/lib/cli/harness-plan.d.ts.map +1 -0
  67. package/lib/cli/harness-plan.js +75 -0
  68. package/lib/cli/harness-plan.js.map +1 -0
  69. package/lib/cli/init-templates.d.ts +11 -0
  70. package/lib/cli/init-templates.d.ts.map +1 -0
  71. package/lib/cli/init-templates.js +215 -0
  72. package/lib/cli/init-templates.js.map +1 -0
  73. package/lib/cli/init.d.ts +10 -0
  74. package/lib/cli/init.d.ts.map +1 -1
  75. package/lib/cli/init.js +34 -173
  76. package/lib/cli/init.js.map +1 -1
  77. package/lib/cli/output-schemas.d.ts +1408 -0
  78. package/lib/cli/output-schemas.d.ts.map +1 -0
  79. package/lib/cli/output-schemas.js +91 -0
  80. package/lib/cli/output-schemas.js.map +1 -0
  81. package/lib/cli/program.d.ts +140 -12
  82. package/lib/cli/program.d.ts.map +1 -1
  83. package/lib/cli/program.js +779 -646
  84. package/lib/cli/program.js.map +1 -1
  85. package/lib/cli/render/reporter.d.ts.map +1 -1
  86. package/lib/cli/render/reporter.js +48 -8
  87. package/lib/cli/render/reporter.js.map +1 -1
  88. package/lib/cli/run-options.d.ts +20 -4
  89. package/lib/cli/run-options.d.ts.map +1 -1
  90. package/lib/cli/run-options.js +100 -19
  91. package/lib/cli/run-options.js.map +1 -1
  92. package/lib/cli/view.d.ts +15 -0
  93. package/lib/cli/view.d.ts.map +1 -0
  94. package/lib/cli/view.js +168 -0
  95. package/lib/cli/view.js.map +1 -0
  96. package/lib/container/driver.d.ts +27 -0
  97. package/lib/container/driver.d.ts.map +1 -0
  98. package/lib/container/driver.js +197 -0
  99. package/lib/container/driver.js.map +1 -0
  100. package/lib/container/protocol.d.ts +12 -0
  101. package/lib/container/protocol.d.ts.map +1 -0
  102. package/lib/container/protocol.js +38 -0
  103. package/lib/container/protocol.js.map +1 -0
  104. package/lib/container/resources.d.ts +12 -0
  105. package/lib/container/resources.d.ts.map +1 -0
  106. package/lib/container/resources.js +133 -0
  107. package/lib/container/resources.js.map +1 -0
  108. package/lib/container/worker.d.ts +2 -0
  109. package/lib/container/worker.d.ts.map +1 -0
  110. package/lib/container/worker.js +85 -0
  111. package/lib/container/worker.js.map +1 -0
  112. package/lib/core/action-events.d.ts +29 -0
  113. package/lib/core/action-events.d.ts.map +1 -0
  114. package/lib/core/action-events.js +51 -0
  115. package/lib/core/action-events.js.map +1 -0
  116. package/lib/core/agent-activity.d.ts +49 -0
  117. package/lib/core/agent-activity.d.ts.map +1 -0
  118. package/lib/core/agent-activity.js +206 -0
  119. package/lib/core/agent-activity.js.map +1 -0
  120. package/lib/core/agent-environment.d.ts +5 -0
  121. package/lib/core/agent-environment.d.ts.map +1 -0
  122. package/lib/core/agent-environment.js +47 -0
  123. package/lib/core/agent-environment.js.map +1 -0
  124. package/lib/core/agent-events.d.ts +26 -0
  125. package/lib/core/agent-events.d.ts.map +1 -0
  126. package/lib/core/agent-events.js +13 -0
  127. package/lib/core/agent-events.js.map +1 -0
  128. package/lib/core/annotation.d.ts +6 -2
  129. package/lib/core/annotation.d.ts.map +1 -1
  130. package/lib/core/annotation.js +2 -1
  131. package/lib/core/annotation.js.map +1 -1
  132. package/lib/core/answerer.d.ts +12 -0
  133. package/lib/core/answerer.d.ts.map +1 -1
  134. package/lib/core/answerer.js +2 -0
  135. package/lib/core/answerer.js.map +1 -1
  136. package/lib/core/artifact-evidence.d.ts +8 -0
  137. package/lib/core/artifact-evidence.d.ts.map +1 -1
  138. package/lib/core/artifact-evidence.js +36 -4
  139. package/lib/core/artifact-evidence.js.map +1 -1
  140. package/lib/core/assertion.d.ts +20 -2
  141. package/lib/core/assertion.d.ts.map +1 -1
  142. package/lib/core/assertion.js +19 -1
  143. package/lib/core/assertion.js.map +1 -1
  144. package/lib/core/case.d.ts +111 -3
  145. package/lib/core/case.d.ts.map +1 -1
  146. package/lib/core/case.js +17 -2
  147. package/lib/core/case.js.map +1 -1
  148. package/lib/core/command-verification.d.ts +10 -0
  149. package/lib/core/command-verification.d.ts.map +1 -0
  150. package/lib/core/command-verification.js +66 -0
  151. package/lib/core/command-verification.js.map +1 -0
  152. package/lib/core/driver-execution.d.ts +83 -0
  153. package/lib/core/driver-execution.d.ts.map +1 -0
  154. package/lib/core/driver-execution.js +72 -0
  155. package/lib/core/driver-execution.js.map +1 -0
  156. package/lib/core/driver-metrics.d.ts +98 -0
  157. package/lib/core/driver-metrics.d.ts.map +1 -0
  158. package/lib/core/driver-metrics.js +36 -0
  159. package/lib/core/driver-metrics.js.map +1 -0
  160. package/lib/core/driver.d.ts +64 -0
  161. package/lib/core/driver.d.ts.map +1 -1
  162. package/lib/core/driver.js +28 -0
  163. package/lib/core/driver.js.map +1 -1
  164. package/lib/core/duration.d.ts +5 -0
  165. package/lib/core/duration.d.ts.map +1 -0
  166. package/lib/core/duration.js +49 -0
  167. package/lib/core/duration.js.map +1 -0
  168. package/lib/core/environment.d.ts +18 -0
  169. package/lib/core/environment.d.ts.map +1 -0
  170. package/lib/core/environment.js +21 -0
  171. package/lib/core/environment.js.map +1 -0
  172. package/lib/core/evaluation-clusters.d.ts +17 -0
  173. package/lib/core/evaluation-clusters.d.ts.map +1 -0
  174. package/lib/core/evaluation-clusters.js +23 -0
  175. package/lib/core/evaluation-clusters.js.map +1 -0
  176. package/lib/core/events.d.ts +36 -0
  177. package/lib/core/events.d.ts.map +1 -1
  178. package/lib/core/events.js +12 -2
  179. package/lib/core/events.js.map +1 -1
  180. package/lib/core/experiment.d.ts +32 -2
  181. package/lib/core/experiment.d.ts.map +1 -1
  182. package/lib/core/experiment.js +35 -18
  183. package/lib/core/experiment.js.map +1 -1
  184. package/lib/core/file-tree.d.ts +7 -0
  185. package/lib/core/file-tree.d.ts.map +1 -0
  186. package/lib/core/file-tree.js +35 -0
  187. package/lib/core/file-tree.js.map +1 -0
  188. package/lib/core/global-id.d.ts +6 -0
  189. package/lib/core/global-id.d.ts.map +1 -0
  190. package/lib/core/global-id.js +17 -0
  191. package/lib/core/global-id.js.map +1 -0
  192. package/lib/core/harness-catalog.d.ts +35 -0
  193. package/lib/core/harness-catalog.d.ts.map +1 -0
  194. package/lib/core/harness-catalog.js +45 -0
  195. package/lib/core/harness-catalog.js.map +1 -0
  196. package/lib/core/harness-catalogs/antigravity.d.ts +11 -0
  197. package/lib/core/harness-catalogs/antigravity.d.ts.map +1 -0
  198. package/lib/core/harness-catalogs/antigravity.js +23 -0
  199. package/lib/core/harness-catalogs/antigravity.js.map +1 -0
  200. package/lib/core/harness-catalogs/claude-code.d.ts +12 -0
  201. package/lib/core/harness-catalogs/claude-code.d.ts.map +1 -0
  202. package/lib/core/harness-catalogs/claude-code.js +24 -0
  203. package/lib/core/harness-catalogs/claude-code.js.map +1 -0
  204. package/lib/core/harness-catalogs/codex.d.ts +11 -0
  205. package/lib/core/harness-catalogs/codex.d.ts.map +1 -0
  206. package/lib/core/harness-catalogs/codex.js +26 -0
  207. package/lib/core/harness-catalogs/codex.js.map +1 -0
  208. package/lib/core/harness-catalogs/copilot.d.ts +29 -0
  209. package/lib/core/harness-catalogs/copilot.d.ts.map +1 -0
  210. package/lib/core/harness-catalogs/copilot.js +45 -0
  211. package/lib/core/harness-catalogs/copilot.js.map +1 -0
  212. package/lib/core/harness-catalogs/cursor.d.ts +2 -0
  213. package/lib/core/harness-catalogs/cursor.d.ts.map +1 -0
  214. package/lib/core/harness-catalogs/cursor.js +13 -0
  215. package/lib/core/harness-catalogs/cursor.js.map +1 -0
  216. package/lib/core/harness-catalogs/grok-build.d.ts +7 -0
  217. package/lib/core/harness-catalogs/grok-build.d.ts.map +1 -0
  218. package/lib/core/harness-catalogs/grok-build.js +18 -0
  219. package/lib/core/harness-catalogs/grok-build.js.map +1 -0
  220. package/lib/core/harness-catalogs/index.d.ts +73 -0
  221. package/lib/core/harness-catalogs/index.d.ts.map +1 -0
  222. package/lib/core/harness-catalogs/index.js +17 -0
  223. package/lib/core/harness-catalogs/index.js.map +1 -0
  224. package/lib/core/harness-matrix.d.ts +154 -0
  225. package/lib/core/harness-matrix.d.ts.map +1 -0
  226. package/lib/core/harness-matrix.js +204 -0
  227. package/lib/core/harness-matrix.js.map +1 -0
  228. package/lib/core/index.d.ts +12 -0
  229. package/lib/core/index.d.ts.map +1 -1
  230. package/lib/core/index.js +12 -0
  231. package/lib/core/index.js.map +1 -1
  232. package/lib/core/lifecycle-fixtures.d.ts.map +1 -1
  233. package/lib/core/lifecycle-fixtures.js +4 -2
  234. package/lib/core/lifecycle-fixtures.js.map +1 -1
  235. package/lib/core/model-cli.d.ts +9 -11
  236. package/lib/core/model-cli.d.ts.map +1 -1
  237. package/lib/core/model-cli.js +31 -19
  238. package/lib/core/model-cli.js.map +1 -1
  239. package/lib/core/platform-process.d.ts +6 -1
  240. package/lib/core/platform-process.d.ts.map +1 -1
  241. package/lib/core/platform-process.js +49 -11
  242. package/lib/core/platform-process.js.map +1 -1
  243. package/lib/core/rubric.d.ts +1 -0
  244. package/lib/core/rubric.d.ts.map +1 -1
  245. package/lib/core/run.d.ts +293 -1
  246. package/lib/core/run.d.ts.map +1 -1
  247. package/lib/core/run.js +27 -0
  248. package/lib/core/run.js.map +1 -1
  249. package/lib/core/secure-copy.d.ts.map +1 -0
  250. package/lib/core/secure-copy.js.map +1 -0
  251. package/lib/core/usage.d.ts +5 -0
  252. package/lib/core/usage.d.ts.map +1 -1
  253. package/lib/core/usage.js +3 -0
  254. package/lib/core/usage.js.map +1 -1
  255. package/lib/core/wire.d.ts +12 -0
  256. package/lib/core/wire.d.ts.map +1 -1
  257. package/lib/core/wire.js +5 -1
  258. package/lib/core/wire.js.map +1 -1
  259. package/lib/drivers/antigravity/artifacts.d.ts +2 -0
  260. package/lib/drivers/antigravity/artifacts.d.ts.map +1 -0
  261. package/lib/drivers/antigravity/artifacts.js +33 -0
  262. package/lib/drivers/antigravity/artifacts.js.map +1 -0
  263. package/lib/drivers/antigravity/config.d.ts +88 -0
  264. package/lib/drivers/antigravity/config.d.ts.map +1 -0
  265. package/lib/drivers/antigravity/config.js +87 -0
  266. package/lib/drivers/antigravity/config.js.map +1 -0
  267. package/lib/drivers/antigravity/events.d.ts +4 -0
  268. package/lib/drivers/antigravity/events.d.ts.map +1 -0
  269. package/lib/drivers/antigravity/events.js +241 -0
  270. package/lib/drivers/antigravity/events.js.map +1 -0
  271. package/lib/drivers/antigravity/index.d.ts +114 -0
  272. package/lib/drivers/antigravity/index.d.ts.map +1 -0
  273. package/lib/drivers/antigravity/index.js +113 -0
  274. package/lib/drivers/antigravity/index.js.map +1 -0
  275. package/lib/drivers/antigravity/runtime.d.ts +7 -0
  276. package/lib/drivers/antigravity/runtime.d.ts.map +1 -0
  277. package/lib/drivers/antigravity/runtime.js +83 -0
  278. package/lib/drivers/antigravity/runtime.js.map +1 -0
  279. package/lib/drivers/claude-code/deferred-process.d.ts +17 -0
  280. package/lib/drivers/claude-code/deferred-process.d.ts.map +1 -0
  281. package/lib/drivers/claude-code/deferred-process.js +108 -0
  282. package/lib/drivers/claude-code/deferred-process.js.map +1 -0
  283. package/lib/drivers/claude-code/index.d.ts +180 -10
  284. package/lib/drivers/claude-code/index.d.ts.map +1 -1
  285. package/lib/drivers/claude-code/index.js +186 -252
  286. package/lib/drivers/claude-code/index.js.map +1 -1
  287. package/lib/drivers/claude-code/isolation.d.ts +8 -0
  288. package/lib/drivers/claude-code/isolation.d.ts.map +1 -0
  289. package/lib/drivers/claude-code/isolation.js +199 -0
  290. package/lib/drivers/claude-code/isolation.js.map +1 -0
  291. package/lib/drivers/claude-code/parse-events.d.ts.map +1 -1
  292. package/lib/drivers/claude-code/parse-events.js +73 -8
  293. package/lib/drivers/claude-code/parse-events.js.map +1 -1
  294. package/lib/drivers/codex/app-events.d.ts +9 -2
  295. package/lib/drivers/codex/app-events.d.ts.map +1 -1
  296. package/lib/drivers/codex/app-events.js +104 -12
  297. package/lib/drivers/codex/app-events.js.map +1 -1
  298. package/lib/drivers/codex/config.d.ts +66 -5
  299. package/lib/drivers/codex/config.d.ts.map +1 -1
  300. package/lib/drivers/codex/config.js +39 -8
  301. package/lib/drivers/codex/config.js.map +1 -1
  302. package/lib/drivers/codex/exec-events.d.ts +4 -0
  303. package/lib/drivers/codex/exec-events.d.ts.map +1 -0
  304. package/lib/drivers/codex/exec-events.js +230 -0
  305. package/lib/drivers/codex/exec-events.js.map +1 -0
  306. package/lib/drivers/codex/index.d.ts +138 -4
  307. package/lib/drivers/codex/index.d.ts.map +1 -1
  308. package/lib/drivers/codex/index.js +112 -276
  309. package/lib/drivers/codex/index.js.map +1 -1
  310. package/lib/drivers/copilot/config.d.ts +84 -0
  311. package/lib/drivers/copilot/config.d.ts.map +1 -0
  312. package/lib/drivers/copilot/config.js +57 -0
  313. package/lib/drivers/copilot/config.js.map +1 -0
  314. package/lib/drivers/copilot/index.d.ts +107 -0
  315. package/lib/drivers/copilot/index.d.ts.map +1 -0
  316. package/lib/drivers/copilot/index.js +268 -0
  317. package/lib/drivers/copilot/index.js.map +1 -0
  318. package/lib/drivers/cursor/config.d.ts +28 -0
  319. package/lib/drivers/cursor/config.d.ts.map +1 -0
  320. package/lib/drivers/cursor/config.js +28 -0
  321. package/lib/drivers/cursor/config.js.map +1 -0
  322. package/lib/drivers/cursor/index.d.ts +44 -0
  323. package/lib/drivers/cursor/index.d.ts.map +1 -0
  324. package/lib/drivers/cursor/index.js +286 -0
  325. package/lib/drivers/cursor/index.js.map +1 -0
  326. package/lib/drivers/cursor/interaction.d.ts +6 -0
  327. package/lib/drivers/cursor/interaction.d.ts.map +1 -0
  328. package/lib/drivers/cursor/interaction.js +55 -0
  329. package/lib/drivers/cursor/interaction.js.map +1 -0
  330. package/lib/drivers/grok-build/config.d.ts +68 -0
  331. package/lib/drivers/grok-build/config.d.ts.map +1 -0
  332. package/lib/drivers/grok-build/config.js +40 -0
  333. package/lib/drivers/grok-build/config.js.map +1 -0
  334. package/lib/drivers/grok-build/index.d.ts +87 -0
  335. package/lib/drivers/grok-build/index.d.ts.map +1 -0
  336. package/lib/drivers/grok-build/index.js +293 -0
  337. package/lib/drivers/grok-build/index.js.map +1 -0
  338. package/lib/drivers/mcp/index.d.ts +37 -4
  339. package/lib/drivers/mcp/index.d.ts.map +1 -1
  340. package/lib/drivers/mcp/index.js +25 -11
  341. package/lib/drivers/mcp/index.js.map +1 -1
  342. package/lib/drivers/shared/acp-events.d.ts +15 -0
  343. package/lib/drivers/shared/acp-events.d.ts.map +1 -0
  344. package/lib/drivers/shared/acp-events.js +83 -0
  345. package/lib/drivers/shared/acp-events.js.map +1 -0
  346. package/lib/drivers/shared/acp-interaction.d.ts +7 -0
  347. package/lib/drivers/shared/acp-interaction.d.ts.map +1 -0
  348. package/lib/drivers/shared/acp-interaction.js +20 -0
  349. package/lib/drivers/shared/acp-interaction.js.map +1 -0
  350. package/lib/drivers/shared/acp-session.d.ts +4 -0
  351. package/lib/drivers/shared/acp-session.d.ts.map +1 -0
  352. package/lib/drivers/shared/acp-session.js +23 -0
  353. package/lib/drivers/shared/acp-session.js.map +1 -0
  354. package/lib/drivers/shared/acp-transport.d.ts +40 -0
  355. package/lib/drivers/shared/acp-transport.d.ts.map +1 -0
  356. package/lib/drivers/shared/acp-transport.js +152 -0
  357. package/lib/drivers/shared/acp-transport.js.map +1 -0
  358. package/lib/drivers/shared/artifacts.d.ts.map +1 -1
  359. package/lib/drivers/shared/artifacts.js +3 -2
  360. package/lib/drivers/shared/artifacts.js.map +1 -1
  361. package/lib/drivers/shared/experiment-behavior.d.ts +13 -0
  362. package/lib/drivers/shared/experiment-behavior.d.ts.map +1 -0
  363. package/lib/drivers/shared/experiment-behavior.js +197 -0
  364. package/lib/drivers/shared/experiment-behavior.js.map +1 -0
  365. package/lib/drivers/shared/experiment-policy.d.ts +4 -0
  366. package/lib/drivers/shared/experiment-policy.d.ts.map +1 -0
  367. package/lib/drivers/shared/experiment-policy.js +143 -0
  368. package/lib/drivers/shared/experiment-policy.js.map +1 -0
  369. package/lib/drivers/subprocess/index.d.ts +39 -4
  370. package/lib/drivers/subprocess/index.d.ts.map +1 -1
  371. package/lib/drivers/subprocess/index.js +56 -12
  372. package/lib/drivers/subprocess/index.js.map +1 -1
  373. package/lib/index.d.ts +22 -8
  374. package/lib/index.d.ts.map +1 -1
  375. package/lib/index.js +20 -6
  376. package/lib/index.js.map +1 -1
  377. package/lib/optimization/reflective.d.ts +3 -1
  378. package/lib/optimization/reflective.d.ts.map +1 -1
  379. package/lib/optimization/reflective.js +3 -2
  380. package/lib/optimization/reflective.js.map +1 -1
  381. package/lib/orchestrator/annotation-loader.d.ts +6 -2
  382. package/lib/orchestrator/annotation-loader.d.ts.map +1 -1
  383. package/lib/orchestrator/annotation-loader.js +8 -0
  384. package/lib/orchestrator/annotation-loader.js.map +1 -1
  385. package/lib/orchestrator/annotation-store.d.ts.map +1 -1
  386. package/lib/orchestrator/annotation-store.js +16 -2
  387. package/lib/orchestrator/annotation-store.js.map +1 -1
  388. package/lib/orchestrator/artifact-origin.d.ts +3 -0
  389. package/lib/orchestrator/artifact-origin.d.ts.map +1 -0
  390. package/lib/orchestrator/artifact-origin.js +40 -0
  391. package/lib/orchestrator/artifact-origin.js.map +1 -0
  392. package/lib/orchestrator/campaign-lifecycle.d.ts +1 -0
  393. package/lib/orchestrator/campaign-lifecycle.d.ts.map +1 -1
  394. package/lib/orchestrator/campaign-lifecycle.js +4 -1
  395. package/lib/orchestrator/campaign-lifecycle.js.map +1 -1
  396. package/lib/orchestrator/candidates.d.ts.map +1 -1
  397. package/lib/orchestrator/candidates.js +3 -2
  398. package/lib/orchestrator/candidates.js.map +1 -1
  399. package/lib/orchestrator/compare.d.ts +19 -3
  400. package/lib/orchestrator/compare.d.ts.map +1 -1
  401. package/lib/orchestrator/compare.js +32 -6
  402. package/lib/orchestrator/compare.js.map +1 -1
  403. package/lib/orchestrator/comparison-identity.d.ts.map +1 -1
  404. package/lib/orchestrator/comparison-identity.js +2 -0
  405. package/lib/orchestrator/comparison-identity.js.map +1 -1
  406. package/lib/orchestrator/config.d.ts +179 -1
  407. package/lib/orchestrator/config.d.ts.map +1 -1
  408. package/lib/orchestrator/config.js +18 -4
  409. package/lib/orchestrator/config.js.map +1 -1
  410. package/lib/orchestrator/discover.d.ts +1 -0
  411. package/lib/orchestrator/discover.d.ts.map +1 -1
  412. package/lib/orchestrator/discover.js +7 -1
  413. package/lib/orchestrator/discover.js.map +1 -1
  414. package/lib/orchestrator/doctor.d.ts +1 -0
  415. package/lib/orchestrator/doctor.d.ts.map +1 -1
  416. package/lib/orchestrator/doctor.js +121 -33
  417. package/lib/orchestrator/doctor.js.map +1 -1
  418. package/lib/orchestrator/driver-capabilities.d.ts +4 -0
  419. package/lib/orchestrator/driver-capabilities.d.ts.map +1 -0
  420. package/lib/orchestrator/driver-capabilities.js +13 -0
  421. package/lib/orchestrator/driver-capabilities.js.map +1 -0
  422. package/lib/orchestrator/driver-identity.d.ts +5 -0
  423. package/lib/orchestrator/driver-identity.d.ts.map +1 -0
  424. package/lib/orchestrator/driver-identity.js +51 -0
  425. package/lib/orchestrator/driver-identity.js.map +1 -0
  426. package/lib/orchestrator/experiment-context.d.ts +51 -3
  427. package/lib/orchestrator/experiment-context.d.ts.map +1 -1
  428. package/lib/orchestrator/experiment-context.js.map +1 -1
  429. package/lib/orchestrator/experiment-contracts.d.ts +30 -1
  430. package/lib/orchestrator/experiment-contracts.d.ts.map +1 -1
  431. package/lib/orchestrator/experiment-corpus.d.ts +2 -1
  432. package/lib/orchestrator/experiment-corpus.d.ts.map +1 -1
  433. package/lib/orchestrator/experiment-corpus.js +28 -22
  434. package/lib/orchestrator/experiment-corpus.js.map +1 -1
  435. package/lib/orchestrator/experiment-effects.d.ts +33 -0
  436. package/lib/orchestrator/experiment-effects.d.ts.map +1 -0
  437. package/lib/orchestrator/experiment-effects.js +44 -0
  438. package/lib/orchestrator/experiment-effects.js.map +1 -0
  439. package/lib/orchestrator/experiment-evaluation.d.ts.map +1 -1
  440. package/lib/orchestrator/experiment-evaluation.js +56 -5
  441. package/lib/orchestrator/experiment-evaluation.js.map +1 -1
  442. package/lib/orchestrator/experiment-identity.d.ts +3 -0
  443. package/lib/orchestrator/experiment-identity.d.ts.map +1 -1
  444. package/lib/orchestrator/experiment-identity.js +22 -33
  445. package/lib/orchestrator/experiment-identity.js.map +1 -1
  446. package/lib/orchestrator/experiment-loader.d.ts +8 -3
  447. package/lib/orchestrator/experiment-loader.d.ts.map +1 -1
  448. package/lib/orchestrator/experiment-preflight.d.ts +3 -0
  449. package/lib/orchestrator/experiment-preflight.d.ts.map +1 -0
  450. package/lib/orchestrator/experiment-preflight.js +21 -0
  451. package/lib/orchestrator/experiment-preflight.js.map +1 -0
  452. package/lib/orchestrator/experiment-report.d.ts +90 -1
  453. package/lib/orchestrator/experiment-report.d.ts.map +1 -1
  454. package/lib/orchestrator/experiment-report.js +9 -1
  455. package/lib/orchestrator/experiment-report.js.map +1 -1
  456. package/lib/orchestrator/experiment-runs.d.ts +61 -2
  457. package/lib/orchestrator/experiment-runs.d.ts.map +1 -1
  458. package/lib/orchestrator/experiment-runs.js +13 -5
  459. package/lib/orchestrator/experiment-runs.js.map +1 -1
  460. package/lib/orchestrator/experiment-runtime-identity.d.ts +0 -16
  461. package/lib/orchestrator/experiment-runtime-identity.d.ts.map +1 -1
  462. package/lib/orchestrator/experiment-runtime-identity.js +5 -220
  463. package/lib/orchestrator/experiment-runtime-identity.js.map +1 -1
  464. package/lib/orchestrator/experiment-selection.d.ts.map +1 -1
  465. package/lib/orchestrator/experiment-selection.js +52 -0
  466. package/lib/orchestrator/experiment-selection.js.map +1 -1
  467. package/lib/orchestrator/experiment.d.ts +3 -3
  468. package/lib/orchestrator/experiment.d.ts.map +1 -1
  469. package/lib/orchestrator/experiment.js +26 -21
  470. package/lib/orchestrator/experiment.js.map +1 -1
  471. package/lib/orchestrator/fixture-identity.d.ts +1 -0
  472. package/lib/orchestrator/fixture-identity.d.ts.map +1 -1
  473. package/lib/orchestrator/fixture-identity.js +6 -1
  474. package/lib/orchestrator/fixture-identity.js.map +1 -1
  475. package/lib/orchestrator/fs-read.d.ts +1 -6
  476. package/lib/orchestrator/fs-read.d.ts.map +1 -1
  477. package/lib/orchestrator/fs-read.js +2 -32
  478. package/lib/orchestrator/fs-read.js.map +1 -1
  479. package/lib/orchestrator/grader-experiment.d.ts +33 -3
  480. package/lib/orchestrator/grader-experiment.d.ts.map +1 -1
  481. package/lib/orchestrator/grader-experiment.js +54 -9
  482. package/lib/orchestrator/grader-experiment.js.map +1 -1
  483. package/lib/orchestrator/grading.d.ts +2 -1
  484. package/lib/orchestrator/grading.d.ts.map +1 -1
  485. package/lib/orchestrator/grading.js +46 -31
  486. package/lib/orchestrator/grading.js.map +1 -1
  487. package/lib/orchestrator/harness-catalog-drift.d.ts +22 -0
  488. package/lib/orchestrator/harness-catalog-drift.d.ts.map +1 -0
  489. package/lib/orchestrator/harness-catalog-drift.js +90 -0
  490. package/lib/orchestrator/harness-catalog-drift.js.map +1 -0
  491. package/lib/orchestrator/harness-registry.d.ts +4 -0
  492. package/lib/orchestrator/harness-registry.d.ts.map +1 -0
  493. package/lib/orchestrator/harness-registry.js +5 -0
  494. package/lib/orchestrator/harness-registry.js.map +1 -0
  495. package/lib/orchestrator/index.d.ts +1 -1
  496. package/lib/orchestrator/index.d.ts.map +1 -1
  497. package/lib/orchestrator/index.js +1 -1
  498. package/lib/orchestrator/index.js.map +1 -1
  499. package/lib/orchestrator/list-runs.d.ts +8 -1
  500. package/lib/orchestrator/list-runs.d.ts.map +1 -1
  501. package/lib/orchestrator/list-runs.js +81 -14
  502. package/lib/orchestrator/list-runs.js.map +1 -1
  503. package/lib/orchestrator/optimization-lifecycle.d.ts.map +1 -1
  504. package/lib/orchestrator/optimization-lifecycle.js +3 -1
  505. package/lib/orchestrator/optimization-lifecycle.js.map +1 -1
  506. package/lib/orchestrator/orchestrator.d.ts +18 -2
  507. package/lib/orchestrator/orchestrator.d.ts.map +1 -1
  508. package/lib/orchestrator/orchestrator.js +50 -168
  509. package/lib/orchestrator/orchestrator.js.map +1 -1
  510. package/lib/orchestrator/paired-effects.d.ts +34 -0
  511. package/lib/orchestrator/paired-effects.d.ts.map +1 -0
  512. package/lib/orchestrator/paired-effects.js +158 -0
  513. package/lib/orchestrator/paired-effects.js.map +1 -0
  514. package/lib/orchestrator/provenance.d.ts +5 -1
  515. package/lib/orchestrator/provenance.d.ts.map +1 -1
  516. package/lib/orchestrator/provenance.js +16 -3
  517. package/lib/orchestrator/provenance.js.map +1 -1
  518. package/lib/orchestrator/regrade.d.ts +9 -1
  519. package/lib/orchestrator/regrade.d.ts.map +1 -1
  520. package/lib/orchestrator/rubric-loader.js +1 -1
  521. package/lib/orchestrator/rubric-loader.js.map +1 -1
  522. package/lib/orchestrator/run-dir.d.ts +2 -0
  523. package/lib/orchestrator/run-dir.d.ts.map +1 -1
  524. package/lib/orchestrator/run-dir.js +1 -1
  525. package/lib/orchestrator/run-dir.js.map +1 -1
  526. package/lib/orchestrator/run-execution.d.ts +3 -0
  527. package/lib/orchestrator/run-execution.d.ts.map +1 -1
  528. package/lib/orchestrator/run-execution.js +66 -12
  529. package/lib/orchestrator/run-execution.js.map +1 -1
  530. package/lib/orchestrator/run-lifecycle.d.ts +1 -0
  531. package/lib/orchestrator/run-lifecycle.d.ts.map +1 -1
  532. package/lib/orchestrator/run-lifecycle.js +3 -2
  533. package/lib/orchestrator/run-lifecycle.js.map +1 -1
  534. package/lib/orchestrator/run-workspace.d.ts +10 -0
  535. package/lib/orchestrator/run-workspace.d.ts.map +1 -0
  536. package/lib/orchestrator/run-workspace.js +58 -0
  537. package/lib/orchestrator/run-workspace.js.map +1 -0
  538. package/lib/orchestrator/suite-compare.d.ts +37 -0
  539. package/lib/orchestrator/suite-compare.d.ts.map +1 -1
  540. package/lib/orchestrator/suite-compare.js +27 -17
  541. package/lib/orchestrator/suite-compare.js.map +1 -1
  542. package/lib/orchestrator/suite-runs.d.ts +6 -1
  543. package/lib/orchestrator/suite-runs.d.ts.map +1 -1
  544. package/lib/orchestrator/suite-runs.js +14 -2
  545. package/lib/orchestrator/suite-runs.js.map +1 -1
  546. package/lib/orchestrator/suite-summary.d.ts +77 -0
  547. package/lib/orchestrator/suite-summary.d.ts.map +1 -1
  548. package/lib/orchestrator/suite-summary.js +61 -12
  549. package/lib/orchestrator/suite-summary.js.map +1 -1
  550. package/lib/previewer/artifacts.d.ts +25 -0
  551. package/lib/previewer/artifacts.d.ts.map +1 -0
  552. package/lib/previewer/artifacts.js +180 -0
  553. package/lib/previewer/artifacts.js.map +1 -0
  554. package/lib/previewer/server.d.ts +111 -0
  555. package/lib/previewer/server.d.ts.map +1 -0
  556. package/lib/previewer/server.js +558 -0
  557. package/lib/previewer/server.js.map +1 -0
  558. package/package.json +3 -3
  559. package/skills/lux-answerer/SKILL.md +2 -2
  560. package/src/answerers/claude-code/index.ts +6 -5
  561. package/src/answerers/persona/index.ts +75 -34
  562. package/src/answerers/terminal/index.ts +8 -12
  563. package/src/assertions/authoring.ts +2 -0
  564. package/src/assertions/core/command-exits-zero.ts +61 -7
  565. package/src/assertions/core/event-checks.ts +64 -3
  566. package/src/assertions/core/helpers.ts +3 -6
  567. package/src/assertions/core/index.ts +2 -0
  568. package/src/assertions/core/resource-checks.ts +38 -5
  569. package/src/assertions/rubric/index.ts +68 -13
  570. package/src/assertions/rubric/internal.ts +227 -27
  571. package/src/authoring.ts +345 -2
  572. package/src/cli/bin.ts +2 -12
  573. package/src/cli/command-runtime.ts +20 -9
  574. package/src/cli/doctor.ts +17 -0
  575. package/src/cli/harness-plan.ts +117 -0
  576. package/src/cli/init-templates.ts +238 -0
  577. package/src/cli/init.ts +53 -184
  578. package/src/cli/output-schemas.ts +106 -0
  579. package/src/cli/program.ts +691 -721
  580. package/src/cli/render/reporter.ts +50 -8
  581. package/src/cli/run-options.ts +132 -25
  582. package/src/cli/view.ts +129 -0
  583. package/src/container/driver.ts +211 -0
  584. package/src/container/protocol.ts +48 -0
  585. package/src/container/resources.ts +153 -0
  586. package/src/container/worker.ts +107 -0
  587. package/src/core/action-events.ts +59 -0
  588. package/src/core/agent-activity.ts +236 -0
  589. package/src/core/agent-environment.ts +64 -0
  590. package/src/core/agent-events.ts +17 -0
  591. package/src/core/annotation.ts +2 -1
  592. package/src/core/answerer.ts +9 -0
  593. package/src/core/artifact-evidence.ts +47 -4
  594. package/src/core/assertion.ts +21 -1
  595. package/src/core/case.ts +21 -3
  596. package/src/core/command-verification.ts +74 -0
  597. package/src/core/driver-execution.ts +84 -0
  598. package/src/core/driver-metrics.ts +51 -0
  599. package/src/core/driver.ts +76 -0
  600. package/src/core/duration.ts +52 -0
  601. package/src/core/environment.ts +22 -0
  602. package/src/core/evaluation-clusters.ts +35 -0
  603. package/src/core/events.ts +14 -2
  604. package/src/core/experiment.ts +64 -24
  605. package/src/core/file-tree.ts +35 -0
  606. package/src/core/global-id.ts +26 -0
  607. package/src/core/harness-catalog.ts +100 -0
  608. package/src/core/harness-catalogs/antigravity.ts +24 -0
  609. package/src/core/harness-catalogs/claude-code.ts +25 -0
  610. package/src/core/harness-catalogs/codex.ts +27 -0
  611. package/src/core/harness-catalogs/copilot.ts +46 -0
  612. package/src/core/harness-catalogs/cursor.ts +13 -0
  613. package/src/core/harness-catalogs/grok-build.ts +19 -0
  614. package/src/core/harness-catalogs/index.ts +31 -0
  615. package/src/core/harness-matrix.ts +316 -0
  616. package/src/core/index.ts +12 -0
  617. package/src/core/lifecycle-fixtures.ts +4 -2
  618. package/src/core/model-cli.ts +52 -23
  619. package/src/core/platform-process.ts +58 -10
  620. package/src/core/run.ts +31 -0
  621. package/src/core/usage.ts +8 -0
  622. package/src/core/wire.ts +5 -1
  623. package/src/drivers/antigravity/README.md +171 -0
  624. package/src/drivers/antigravity/artifacts.ts +37 -0
  625. package/src/drivers/antigravity/config.ts +92 -0
  626. package/src/drivers/antigravity/events.ts +290 -0
  627. package/src/drivers/antigravity/index.ts +132 -0
  628. package/src/drivers/antigravity/runtime.ts +94 -0
  629. package/src/drivers/claude-code/deferred-process.ts +118 -0
  630. package/src/drivers/claude-code/index.ts +216 -281
  631. package/src/drivers/claude-code/isolation.ts +228 -0
  632. package/src/drivers/claude-code/parse-events.ts +98 -12
  633. package/src/drivers/codex/app-events.ts +126 -16
  634. package/src/drivers/codex/config.ts +50 -8
  635. package/src/drivers/codex/exec-events.ts +258 -0
  636. package/src/drivers/codex/index.ts +144 -312
  637. package/src/drivers/copilot/README.md +60 -0
  638. package/src/drivers/copilot/config.ts +61 -0
  639. package/src/drivers/copilot/index.ts +310 -0
  640. package/src/drivers/cursor/README.md +66 -0
  641. package/src/drivers/cursor/config.ts +31 -0
  642. package/src/drivers/cursor/index.ts +326 -0
  643. package/src/drivers/cursor/interaction.ts +74 -0
  644. package/src/drivers/grok-build/README.md +112 -0
  645. package/src/drivers/grok-build/config.ts +43 -0
  646. package/src/drivers/grok-build/index.ts +331 -0
  647. package/src/drivers/mcp/index.ts +25 -11
  648. package/src/drivers/shared/acp-events.ts +94 -0
  649. package/src/drivers/shared/acp-interaction.ts +27 -0
  650. package/src/drivers/shared/acp-session.ts +40 -0
  651. package/src/drivers/shared/acp-transport.ts +187 -0
  652. package/src/drivers/shared/artifacts.ts +6 -2
  653. package/src/drivers/shared/experiment-behavior.ts +214 -0
  654. package/src/drivers/shared/experiment-policy.ts +195 -0
  655. package/src/drivers/subprocess/index.ts +55 -12
  656. package/src/index.ts +115 -10
  657. package/src/optimization/reflective.ts +3 -2
  658. package/src/orchestrator/annotation-loader.ts +10 -0
  659. package/src/orchestrator/annotation-store.ts +24 -3
  660. package/src/orchestrator/artifact-origin.ts +50 -0
  661. package/src/orchestrator/campaign-lifecycle.ts +5 -1
  662. package/src/orchestrator/candidates.ts +3 -2
  663. package/src/orchestrator/compare.ts +41 -6
  664. package/src/orchestrator/comparison-identity.ts +2 -0
  665. package/src/orchestrator/config.ts +20 -3
  666. package/src/orchestrator/discover.ts +8 -1
  667. package/src/orchestrator/doctor.ts +189 -28
  668. package/src/orchestrator/driver-capabilities.ts +21 -0
  669. package/src/orchestrator/driver-identity.ts +69 -0
  670. package/src/orchestrator/experiment-context.ts +3 -2
  671. package/src/orchestrator/experiment-corpus.ts +53 -37
  672. package/src/orchestrator/experiment-effects.ts +61 -0
  673. package/src/orchestrator/experiment-evaluation.ts +71 -10
  674. package/src/orchestrator/experiment-identity.ts +42 -48
  675. package/src/orchestrator/experiment-preflight.ts +27 -0
  676. package/src/orchestrator/experiment-report.ts +21 -1
  677. package/src/orchestrator/experiment-runs.ts +11 -4
  678. package/src/orchestrator/experiment-runtime-identity.ts +5 -243
  679. package/src/orchestrator/experiment-selection.ts +77 -0
  680. package/src/orchestrator/experiment.ts +29 -29
  681. package/src/orchestrator/fixture-identity.ts +9 -1
  682. package/src/orchestrator/fs-read.ts +2 -32
  683. package/src/orchestrator/grader-experiment.ts +74 -13
  684. package/src/orchestrator/grading.ts +67 -28
  685. package/src/orchestrator/harness-catalog-drift.ts +132 -0
  686. package/src/orchestrator/harness-registry.ts +12 -0
  687. package/src/orchestrator/index.ts +1 -0
  688. package/src/orchestrator/list-runs.ts +98 -13
  689. package/src/orchestrator/optimization-lifecycle.ts +4 -1
  690. package/src/orchestrator/orchestrator.ts +92 -216
  691. package/src/orchestrator/paired-effects.ts +209 -0
  692. package/src/orchestrator/provenance.ts +23 -3
  693. package/src/orchestrator/rubric-loader.ts +1 -1
  694. package/src/orchestrator/run-dir.ts +8 -1
  695. package/src/orchestrator/run-execution.ts +77 -11
  696. package/src/orchestrator/run-lifecycle.ts +4 -2
  697. package/src/orchestrator/run-workspace.ts +62 -0
  698. package/src/orchestrator/suite-compare.ts +29 -19
  699. package/src/orchestrator/suite-runs.ts +13 -2
  700. package/src/orchestrator/suite-summary.ts +122 -13
  701. package/src/previewer/artifacts.ts +221 -0
  702. package/src/previewer/server.ts +787 -0
  703. package/viewer/app.css +2079 -0
  704. package/viewer/app.js +627 -0
  705. package/viewer/artifact-view.js +48 -0
  706. package/viewer/charts.js +86 -0
  707. package/viewer/detail.js +1237 -0
  708. package/viewer/format.js +129 -0
  709. package/viewer/index.html +151 -0
  710. package/lib/answerers/scripted/index.d.ts +0 -8
  711. package/lib/answerers/scripted/index.d.ts.map +0 -1
  712. package/lib/answerers/scripted/index.js +0 -163
  713. package/lib/answerers/scripted/index.js.map +0 -1
  714. package/lib/cli/skills.d.ts +0 -38
  715. package/lib/cli/skills.d.ts.map +0 -1
  716. package/lib/cli/skills.js +0 -84
  717. package/lib/cli/skills.js.map +0 -1
  718. package/lib/drivers/shared/secure-copy.d.ts.map +0 -1
  719. package/lib/drivers/shared/secure-copy.js.map +0 -1
  720. package/skills/lux/SKILL.md +0 -85
  721. package/skills/lux/references/cli.md +0 -102
  722. package/skills/lux/references/eval-authoring.md +0 -105
  723. package/src/answerers/scripted/index.ts +0 -186
  724. package/src/cli/skills.ts +0 -129
  725. /package/lib/{drivers/shared → core}/secure-copy.d.ts +0 -0
  726. /package/lib/{drivers/shared → core}/secure-copy.js +0 -0
  727. /package/src/{drivers/shared → core}/secure-copy.ts +0 -0
@@ -0,0 +1,48 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+
3
+ export type Message = {
4
+ id: number;
5
+ method?: string;
6
+ event?: string;
7
+ value?: unknown;
8
+ error?: string;
9
+ ack?: boolean;
10
+ };
11
+ export const writeMessage = (stream: Writable, message: Message): void => {
12
+ const line = JSON.stringify(message);
13
+ if (line.length > 8_000_000) throw new Error("container protocol message exceeds 8 MB");
14
+ stream.write(`${line}\n`);
15
+ };
16
+ export const readMessages = (
17
+ stream: Readable,
18
+ receive: (message: Message) => void,
19
+ fail: (error: Error) => void,
20
+ ): void => {
21
+ let buffer = "";
22
+ stream.setEncoding("utf8");
23
+ stream.on("data", (chunk: string) => {
24
+ try {
25
+ buffer += chunk;
26
+ for (;;) {
27
+ const newline = buffer.indexOf("\n");
28
+ if (newline < 0) break;
29
+ if (newline > 8_000_000) throw new Error("container protocol message exceeds 8 MB");
30
+ const message: unknown = JSON.parse(buffer.slice(0, newline));
31
+ buffer = buffer.slice(newline + 1);
32
+ if (
33
+ !message ||
34
+ typeof message !== "object" ||
35
+ !("id" in message) ||
36
+ !Number.isSafeInteger(message.id)
37
+ )
38
+ throw new Error("invalid container protocol message");
39
+ receive(message as Message);
40
+ }
41
+ if (buffer.length > 8_000_000) throw new Error("container protocol buffer exceeds 8 MB");
42
+ } catch (error) {
43
+ buffer = "";
44
+ stream.pause();
45
+ fail(error instanceof Error ? error : new Error(String(error)));
46
+ }
47
+ });
48
+ };
@@ -0,0 +1,153 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { chmod, copyFile, lstat, mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, isAbsolute, join, resolve } from "node:path";
5
+ import type { ContainerExecution } from "../core/driver-execution.js";
6
+ import { exec } from "../core/exec.js";
7
+
8
+ const mount = (source: string, target: string, readOnly = false): string => {
9
+ if ([source, target].some((path) => !isAbsolute(path) || /[,\r\n\0]/u.test(path)))
10
+ throw new Error(
11
+ "container mount paths must be absolute and contain no commas or control characters",
12
+ );
13
+ return `type=bind,source=${source},target=${target}${readOnly ? ",readonly" : ""}`;
14
+ };
15
+
16
+ export const prepareContainer = async (config: ContainerExecution, workspace: string) => {
17
+ const command = config.command ?? "docker";
18
+ const inspected = await exec(command, ["image", "inspect", "--format", "{{.Id}}", config.image], {
19
+ timeoutMs: config.startupTimeoutMs ?? 30_000,
20
+ maxBuffer: 4096,
21
+ });
22
+ if (inspected.exitCode !== 0 || !/^sha256:[a-f0-9]{64}$/u.test(inspected.stdout.trim()))
23
+ throw new Error(
24
+ "container image is unavailable; build or pull the configured image before running Lux",
25
+ );
26
+ const image = inspected.stdout.trim();
27
+ const home = await mkdtemp(join(tmpdir(), "lux-container-home-"));
28
+ const name = `lux-${randomUUID()}`;
29
+ const cleanup = async () => {
30
+ // Killing the Docker client does not stop the daemon-owned container.
31
+ const removed = await exec(command, ["rm", "--force", name], {
32
+ timeoutMs: 15_000,
33
+ maxBuffer: 4096,
34
+ });
35
+ if (removed.exitCode !== 0 && !removed.stderr.includes("No such container"))
36
+ throw new Error(
37
+ `failed to remove owned container '${name}'; private home retained at ${home}`,
38
+ );
39
+ await rm(home, { recursive: true, force: true });
40
+ };
41
+ try {
42
+ await chmod(home, 0o700);
43
+ for (const file of config.homeFiles ?? []) {
44
+ const target = join(home, file.destination);
45
+ await mkdir(dirname(target), { recursive: true, mode: 0o700 });
46
+ if (file.source.kind === "file") {
47
+ if (!(await lstat(file.source.path)).isFile())
48
+ throw new Error("container home credential source must be a regular file");
49
+ await copyFile(file.source.path, target);
50
+ } else {
51
+ if (process.platform !== "darwin")
52
+ throw new Error("container Keychain credentials require macOS");
53
+ const result = await exec(
54
+ "/usr/bin/security",
55
+ ["find-generic-password", "-s", file.source.service, "-a", file.source.account, "-w"],
56
+ { timeoutMs: 10_000, maxBuffer: 1_000_000 },
57
+ );
58
+ if (result.exitCode !== 0 || result.stdoutTruncated)
59
+ throw new Error("could not read the explicitly configured container Keychain credential");
60
+ const value = result.stdout.trimEnd();
61
+ await writeFile(
62
+ target,
63
+ file.source.encoding === "go-keyring-base64" && value.startsWith("go-keyring-base64:")
64
+ ? Buffer.from(value.slice("go-keyring-base64:".length), "base64")
65
+ : value,
66
+ { mode: 0o600 },
67
+ );
68
+ }
69
+ await chmod(target, 0o600);
70
+ }
71
+ const root = await realpath(workspace);
72
+ const args = [
73
+ "run",
74
+ "--init",
75
+ "-i",
76
+ "--pull",
77
+ "never",
78
+ "--name",
79
+ name,
80
+ "--read-only",
81
+ "--cap-drop",
82
+ "ALL",
83
+ "--security-opt",
84
+ "no-new-privileges",
85
+ "--network",
86
+ config.network ?? "bridge",
87
+ "--memory",
88
+ config.memory ?? "4g",
89
+ "--cpus",
90
+ String(config.cpus ?? 2),
91
+ "--pids-limit",
92
+ String(config.pidsLimit ?? 512),
93
+ "--user",
94
+ config.user ?? `${process.getuid?.() ?? 1000}:${process.getgid?.() ?? 1000}`,
95
+ "--tmpfs",
96
+ "/tmp:rw,nosuid,nodev,exec,size=1g,mode=1777",
97
+ "--workdir",
98
+ root,
99
+ "--mount",
100
+ mount(root, root),
101
+ "--mount",
102
+ mount(await realpath(home), "/home/lux"),
103
+ "--env",
104
+ "HOME=/home/lux",
105
+ "--env",
106
+ "npm_config_yes=true",
107
+ ];
108
+ for (const entry of config.mounts ?? []) {
109
+ const source = await realpath(entry.source);
110
+ const target = resolve(entry.target ?? source);
111
+ if (
112
+ [
113
+ "/",
114
+ "/home",
115
+ "/home/lux",
116
+ "/tmp",
117
+ "/opt",
118
+ "/opt/lux",
119
+ "/usr",
120
+ "/bin",
121
+ "/etc",
122
+ "/proc",
123
+ "/sys",
124
+ "/dev",
125
+ ].some(
126
+ (reserved) =>
127
+ target === reserved || (reserved !== "/" && target.startsWith(`${reserved}/`)),
128
+ ) ||
129
+ target === root ||
130
+ root.startsWith(`${target}/`) ||
131
+ target.startsWith(`${root}/`)
132
+ )
133
+ throw new Error(
134
+ "additional container mounts must not overlap the workspace or runtime paths",
135
+ );
136
+ args.push("--mount", mount(source, target, entry.readOnly ?? true));
137
+ }
138
+ const env = { ...process.env };
139
+ for (const key of new Set([...(config.passEnv ?? []), ...Object.keys(config.env ?? {})])) {
140
+ if (["HOME", "NODE_OPTIONS", "NODE_PATH", "LD_PRELOAD", "LD_LIBRARY_PATH"].includes(key))
141
+ throw new Error(`reserved container environment variable '${key}'`);
142
+ const value = config.env?.[key] ?? process.env[key];
143
+ if (value === undefined) throw new Error(`container environment variable '${key}' is unset`);
144
+ env[key] = value;
145
+ args.push("--env", key);
146
+ }
147
+ args.push("--entrypoint", "node", image, config.worker ?? "/opt/lux/lib/container/worker.js");
148
+ return { command, args, env, image, root, cleanup };
149
+ } catch (error) {
150
+ await rm(home, { recursive: true, force: true });
151
+ throw error;
152
+ }
153
+ };
@@ -0,0 +1,107 @@
1
+ import { mkdir } from "node:fs/promises";
2
+ import type { AgentDriver, DriverPlugin, StartContext } from "../core/driver.js";
3
+ import { AnswerSchema } from "../core/events.js";
4
+ import { buildRegistryFromConfig, LuxConfigSchema } from "../orchestrator/config.js";
5
+ import { LUX_VERSION } from "../orchestrator/package-version.js";
6
+ import { validatePluginConfig } from "../orchestrator/validate-plugin-config.js";
7
+ import { type Message, readMessages, writeMessage } from "./protocol.js";
8
+
9
+ let driver: AgentDriver | undefined;
10
+ let eventId = 0;
11
+ const acknowledgements = new Map<number, () => void>();
12
+ const abort = new AbortController();
13
+ const dispatch = async (message: Message): Promise<unknown> => {
14
+ if (message.method === "start") {
15
+ if (driver) throw new Error("container driver already started");
16
+ const request = message.value as {
17
+ version: string;
18
+ name: string;
19
+ module?: string;
20
+ config: unknown;
21
+ context: Omit<StartContext, "abortSignal">;
22
+ };
23
+ if (request.version !== LUX_VERSION)
24
+ throw new Error("container worker and host Lux versions differ; rebuild the image");
25
+ const plugin: DriverPlugin | undefined = request.module
26
+ ? (await import(request.module)).default
27
+ : buildRegistryFromConfig({
28
+ ...LuxConfigSchema.parse({}),
29
+ rootDir: process.cwd(),
30
+ configPath: null,
31
+ }).getDriver(request.name);
32
+ if (!plugin || plugin.name !== request.name)
33
+ throw new Error("container driver plugin is unavailable");
34
+ driver = await plugin.create(
35
+ validatePluginConfig(
36
+ plugin.configSchema,
37
+ request.config,
38
+ `container driver '${request.name}'`,
39
+ ),
40
+ );
41
+ for (const event of ["interrupt", "progress", "done", "error"] as const) {
42
+ driver.on(
43
+ event,
44
+ (value) =>
45
+ new Promise<void>((resolve) => {
46
+ const id = ++eventId;
47
+ acknowledgements.set(id, resolve);
48
+ writeMessage(process.stdout, { id, event, value });
49
+ }),
50
+ );
51
+ }
52
+ await mkdir("/tmp/lux-run", { recursive: true });
53
+ await mkdir("/tmp/lux-runs", { recursive: true });
54
+ return driver.start({
55
+ ...request.context,
56
+ isolatedHome: "/home/lux",
57
+ abortSignal: abort.signal,
58
+ });
59
+ }
60
+ if (!driver) throw new Error("container driver has not started");
61
+ switch (message.method) {
62
+ case "respond":
63
+ return driver.respond(AnswerSchema.parse(message.value));
64
+ case "quiesce":
65
+ return driver.quiesce?.();
66
+ case "collect":
67
+ return driver.collect();
68
+ case "close":
69
+ return driver.close();
70
+ default:
71
+ throw new Error("unknown container RPC method");
72
+ }
73
+ };
74
+ readMessages(
75
+ process.stdin,
76
+ (message) => {
77
+ if (message.ack) {
78
+ acknowledgements.get(message.id)?.();
79
+ acknowledgements.delete(message.id);
80
+ return;
81
+ }
82
+ void dispatch(message).then(
83
+ (value) => writeMessage(process.stdout, { id: message.id, value }),
84
+ (error: unknown) =>
85
+ writeMessage(process.stdout, {
86
+ id: message.id,
87
+ error: error instanceof Error ? error.message : String(error),
88
+ }),
89
+ );
90
+ },
91
+ () => {
92
+ abort.abort();
93
+ process.exitCode = 1;
94
+ process.stdin.destroy();
95
+ },
96
+ );
97
+ process.stdin.on("end", () => {
98
+ abort.abort();
99
+ for (const resolve of acknowledgements.values()) resolve();
100
+ void driver?.close().finally(() => {
101
+ process.exitCode = 0;
102
+ });
103
+ });
104
+ process.stdout.on("error", () => {
105
+ abort.abort();
106
+ process.exitCode = 1;
107
+ });
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import type { RunEvent } from "./events.js";
3
+
4
+ export const ActionCategorySchema = z.enum([
5
+ "query",
6
+ "mutation",
7
+ "durable-mutation",
8
+ "execution",
9
+ "interaction",
10
+ ]);
11
+ export type ActionCategory = z.infer<typeof ActionCategorySchema>;
12
+
13
+ export const ActionProgressPayloadSchema = z
14
+ .object({
15
+ name: z.string(),
16
+ category: ActionCategorySchema,
17
+ })
18
+ .strict();
19
+ export type ActionProgressPayload = z.infer<typeof ActionProgressPayloadSchema>;
20
+
21
+ export const ActionTimingSchema = z.object({
22
+ timeToFirstActionMs: z.exactOptional(z.number().nonnegative()),
23
+ timeToFirstMutationMs: z.exactOptional(z.number().nonnegative()),
24
+ timeToFirstDurableMutationMs: z.exactOptional(z.number().nonnegative()),
25
+ });
26
+ export type ActionTiming = z.infer<typeof ActionTimingSchema>;
27
+
28
+ export const actionTiming = (events: readonly RunEvent[]): ActionTiming => {
29
+ const startEvent = events.find(
30
+ (event) => event.type === "lifecycle" && event.stage === "start-driver",
31
+ );
32
+ const startedAt = startEvent?.type === "lifecycle" ? startEvent.ts : undefined;
33
+ if (startedAt === undefined) return {};
34
+
35
+ const actions = events.flatMap((event) => {
36
+ if (event.type !== "progress" || event.kind !== "action") return [];
37
+ const payload = ActionProgressPayloadSchema.safeParse(event.payload).data;
38
+ return payload ? [{ ...payload, ts: event.ts }] : [];
39
+ });
40
+ const elapsed = (category: "any" | "mutation" | "durable-mutation") => {
41
+ const timestamps = actions.flatMap(({ category: candidate, ts }) => {
42
+ if (category === "any") return [ts];
43
+ if (category === "mutation") {
44
+ return candidate === "mutation" || candidate === "durable-mutation" ? [ts] : [];
45
+ }
46
+ return candidate === category ? [ts] : [];
47
+ });
48
+ return timestamps.length > 0 ? Math.max(0, Math.min(...timestamps) - startedAt) : undefined;
49
+ };
50
+
51
+ const timeToFirstActionMs = elapsed("any");
52
+ const timeToFirstMutationMs = elapsed("mutation");
53
+ const timeToFirstDurableMutationMs = elapsed("durable-mutation");
54
+ return {
55
+ ...(timeToFirstActionMs === undefined ? {} : { timeToFirstActionMs }),
56
+ ...(timeToFirstMutationMs === undefined ? {} : { timeToFirstMutationMs }),
57
+ ...(timeToFirstDurableMutationMs === undefined ? {} : { timeToFirstDurableMutationMs }),
58
+ };
59
+ };
@@ -0,0 +1,236 @@
1
+ import { z } from "zod";
2
+ import { ActionProgressPayloadSchema } from "./action-events.js";
3
+ import { AgentCompletedPayloadSchema, AgentSpawnPayloadSchema } from "./agent-events.js";
4
+ import type { AgentAttribution, ReadyState, RunEvent } from "./events.js";
5
+ import { ToolCallPayloadSchema, ToolResultPayloadSchema } from "./tool-events.js";
6
+ import { TokenUsageSchema } from "./usage.js";
7
+
8
+ export const AgentActivitySchema = z.object({
9
+ agent: z.object({
10
+ id: z.string(),
11
+ role: z.enum(["main", "subagent"]),
12
+ parentId: z.exactOptional(z.string()),
13
+ spawnToolUseId: z.exactOptional(z.string()),
14
+ name: z.exactOptional(z.string()),
15
+ model: z.exactOptional(z.string()),
16
+ }),
17
+ startedAt: z.number(),
18
+ endedAt: z.number(),
19
+ durationMs: z.number().nonnegative(),
20
+ status: z.enum(["completed", "failed", "cancelled", "unknown"]),
21
+ eventCount: z.number().int().nonnegative(),
22
+ usage: TokenUsageSchema.extend({ total: z.number().int().nonnegative() }),
23
+ toolCalls: z.object({
24
+ total: z.number().int().nonnegative(),
25
+ succeeded: z.number().int().nonnegative(),
26
+ failed: z.number().int().nonnegative(),
27
+ unresolved: z.number().int().nonnegative(),
28
+ }),
29
+ actions: z.object({
30
+ total: z.number().int().nonnegative(),
31
+ mutations: z.number().int().nonnegative(),
32
+ durableMutations: z.number().int().nonnegative(),
33
+ timeToFirstActionMs: z.exactOptional(z.number().nonnegative()),
34
+ timeToFirstMutationMs: z.exactOptional(z.number().nonnegative()),
35
+ timeToFirstDurableMutationMs: z.exactOptional(z.number().nonnegative()),
36
+ }),
37
+ });
38
+ export type AgentActivity = z.infer<typeof AgentActivitySchema>;
39
+
40
+ const legacyAttribution = (
41
+ event: Extract<RunEvent, { type: "progress" }>,
42
+ ready: ReadyState,
43
+ ): AgentAttribution => {
44
+ const payload = event.payload;
45
+ const parentToolUseId =
46
+ typeof payload === "object" && payload !== null && "parentToolUseId" in payload
47
+ ? payload.parentToolUseId
48
+ : undefined;
49
+ const spawnToolUseId =
50
+ typeof parentToolUseId === "string" && parentToolUseId.length > 0 ? parentToolUseId : undefined;
51
+ return spawnToolUseId
52
+ ? {
53
+ id: `subagent:${spawnToolUseId}`,
54
+ role: "subagent" as const,
55
+ parentId: ready.agentId,
56
+ spawnToolUseId,
57
+ }
58
+ : { id: ready.agentId, role: "main" as const, ...(ready.model ? { model: ready.model } : {}) };
59
+ };
60
+
61
+ type MutableActivity = AgentActivity & { calls: Map<string, "pending" | "succeeded" | "failed"> };
62
+ type ProgressEvent = Extract<RunEvent, { type: "progress" }>;
63
+ type SpawnInfo = { ts: number; name?: string; model?: string };
64
+
65
+ const initialActivity = (agent: AgentAttribution, startedAt: number): MutableActivity => ({
66
+ agent,
67
+ startedAt,
68
+ endedAt: startedAt,
69
+ durationMs: 0,
70
+ status: "unknown",
71
+ eventCount: 0,
72
+ usage: { input: 0, output: 0, cacheRead: 0, cacheCreation: 0, total: 0 },
73
+ toolCalls: { total: 0, succeeded: 0, failed: 0, unresolved: 0 },
74
+ actions: { total: 0, mutations: 0, durableMutations: 0 },
75
+ calls: new Map(),
76
+ });
77
+
78
+ const collectSpawnInfo = (events: RunEvent[]): Map<string, SpawnInfo> => {
79
+ const spawns = new Map<string, SpawnInfo>();
80
+ for (const event of events) {
81
+ if (event.type !== "progress" || event.kind !== "tool-call") continue;
82
+ const call = ToolCallPayloadSchema.safeParse(event.payload).data;
83
+ if (!call) continue;
84
+ const input = z
85
+ .object({
86
+ name: z.string().min(1).optional(),
87
+ subagent_type: z.string().min(1).optional(),
88
+ agent: z.string().min(1).optional(),
89
+ role: z.string().min(1).optional(),
90
+ model: z.string().min(1).optional(),
91
+ })
92
+ .loose()
93
+ .safeParse(call.input).data;
94
+ const name = input?.name ?? input?.subagent_type ?? input?.agent ?? input?.role;
95
+ spawns.set(call.toolUseId, {
96
+ ts: event.ts,
97
+ ...(name ? { name } : {}),
98
+ ...(input?.model ? { model: input.model } : {}),
99
+ });
100
+ }
101
+ return spawns;
102
+ };
103
+
104
+ const applyLifecycle = (
105
+ event: ProgressEvent,
106
+ activities: Map<string, MutableActivity>,
107
+ ): boolean => {
108
+ if (event.kind === "agent-spawn") {
109
+ const spawn = AgentSpawnPayloadSchema.safeParse(event.payload).data;
110
+ if (spawn && !activities.has(spawn.agent.id)) {
111
+ activities.set(spawn.agent.id, initialActivity(spawn.agent, event.ts));
112
+ }
113
+ return true;
114
+ }
115
+ if (event.kind !== "agent-completed") return false;
116
+ const completed = AgentCompletedPayloadSchema.safeParse(event.payload).data;
117
+ const activity = completed ? activities.get(completed.agentId) : undefined;
118
+ if (activity && completed) {
119
+ activity.endedAt = Math.max(activity.endedAt, event.ts);
120
+ activity.durationMs = Math.max(0, activity.endedAt - activity.startedAt);
121
+ activity.status = completed.status;
122
+ }
123
+ return true;
124
+ };
125
+
126
+ const activityFor = (
127
+ event: ProgressEvent,
128
+ ready: ReadyState,
129
+ driverStartedAt: number,
130
+ spawns: Map<string, SpawnInfo>,
131
+ activities: Map<string, MutableActivity>,
132
+ ): MutableActivity => {
133
+ const agent = event.agent ?? legacyAttribution(event, ready);
134
+ const existing = activities.get(agent.id);
135
+ if (existing) return existing;
136
+ const spawn = agent.spawnToolUseId ? spawns.get(agent.spawnToolUseId) : undefined;
137
+ const name = agent.name ?? spawn?.name;
138
+ const model = agent.model ?? spawn?.model;
139
+ const attributedAgent = {
140
+ ...agent,
141
+ ...(name ? { name } : {}),
142
+ ...(model ? { model } : {}),
143
+ };
144
+ const startedAt =
145
+ agent.role === "subagent" && agent.spawnToolUseId
146
+ ? (spawn?.ts ?? event.ts)
147
+ : driverStartedAt || event.ts;
148
+ return activities.get(agent.id) ?? initialActivity(attributedAgent, startedAt);
149
+ };
150
+
151
+ const addAction = (event: ProgressEvent, activity: MutableActivity): void => {
152
+ const action = ActionProgressPayloadSchema.safeParse(event.payload).data;
153
+ if (!action) return;
154
+ const elapsed = Math.max(0, event.ts - activity.startedAt);
155
+ activity.actions.total++;
156
+ activity.actions.timeToFirstActionMs ??= elapsed;
157
+ if (action.category === "mutation" || action.category === "durable-mutation") {
158
+ activity.actions.mutations++;
159
+ activity.actions.timeToFirstMutationMs ??= elapsed;
160
+ }
161
+ if (action.category === "durable-mutation") {
162
+ activity.actions.durableMutations++;
163
+ activity.actions.timeToFirstDurableMutationMs ??= elapsed;
164
+ }
165
+ };
166
+
167
+ const addUsage = (event: ProgressEvent, activity: MutableActivity): void => {
168
+ const usage = TokenUsageSchema.safeParse(event.payload).data;
169
+ if (!usage) return;
170
+ activity.usage.input += usage.input;
171
+ activity.usage.output += usage.output;
172
+ activity.usage.cacheRead += usage.cacheRead;
173
+ activity.usage.cacheCreation += usage.cacheCreation;
174
+ activity.usage.total += usage.input + usage.output + usage.cacheRead + usage.cacheCreation;
175
+ };
176
+
177
+ const addWork = (event: ProgressEvent, activity: MutableActivity): void => {
178
+ activity.eventCount++;
179
+ activity.endedAt = Math.max(activity.endedAt, event.ts);
180
+ activity.durationMs = Math.max(0, activity.endedAt - activity.startedAt);
181
+ if (event.kind === "tool-call") {
182
+ const call = ToolCallPayloadSchema.safeParse(event.payload).data;
183
+ if (call && !activity.calls.has(call.toolUseId)) {
184
+ activity.calls.set(call.toolUseId, "pending");
185
+ activity.toolCalls.total++;
186
+ }
187
+ return;
188
+ }
189
+ if (event.kind === "tool-result") {
190
+ const result = ToolResultPayloadSchema.safeParse(event.payload).data;
191
+ if (result && activity.calls.has(result.toolUseId)) {
192
+ activity.calls.set(result.toolUseId, result.isError ? "failed" : "succeeded");
193
+ }
194
+ return;
195
+ }
196
+ if (event.kind === "action") addAction(event, activity);
197
+ if (event.kind === "usage") addUsage(event, activity);
198
+ };
199
+
200
+ export const summarizeAgentActivity = (events: RunEvent[], ready: ReadyState): AgentActivity[] => {
201
+ const driverStart = events.find(
202
+ (event): event is Extract<RunEvent, { type: "lifecycle" }> =>
203
+ event.type === "lifecycle" && event.stage === "start-driver",
204
+ );
205
+ const driverStartedAt = driverStart?.ts ?? 0;
206
+ const spawns = collectSpawnInfo(events);
207
+ const activities = new Map<string, MutableActivity>();
208
+ for (const event of events) {
209
+ if (event.type !== "progress") continue;
210
+ if (applyLifecycle(event, activities)) continue;
211
+ const activity = activityFor(event, ready, driverStartedAt, spawns, activities);
212
+ addWork(event, activity);
213
+ activities.set(activity.agent.id, activity);
214
+ }
215
+
216
+ if (!activities.has(ready.agentId)) {
217
+ activities.set(
218
+ ready.agentId,
219
+ initialActivity(
220
+ {
221
+ id: ready.agentId,
222
+ role: "main",
223
+ ...(ready.model ? { model: ready.model } : {}),
224
+ },
225
+ driverStartedAt,
226
+ ),
227
+ );
228
+ }
229
+ return [...activities.values()]
230
+ .map(({ calls, ...activity }) => {
231
+ for (const outcome of calls.values())
232
+ activity.toolCalls[outcome === "pending" ? "unresolved" : outcome]++;
233
+ return AgentActivitySchema.parse(activity);
234
+ })
235
+ .sort((a, b) => a.startedAt - b.startedAt || a.agent.id.localeCompare(b.agent.id));
236
+ };
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+
3
+ export const InheritEnvironmentSchema = z.union([z.array(z.string().min(1)), z.literal(true)]);
4
+ export type InheritEnvironment = z.infer<typeof InheritEnvironmentSchema>;
5
+
6
+ const nativeEnvironment = new Set([
7
+ "PATH",
8
+ "HOME",
9
+ "USER",
10
+ "LOGNAME",
11
+ "SHELL",
12
+ "TMPDIR",
13
+ "TMP",
14
+ "TEMP",
15
+ "LANG",
16
+ "LANGUAGE",
17
+ "TERM",
18
+ "COLORTERM",
19
+ "NO_COLOR",
20
+ "FORCE_COLOR",
21
+ "CI",
22
+ "TZ",
23
+ "XDG_CONFIG_HOME",
24
+ "XDG_DATA_HOME",
25
+ "XDG_CACHE_HOME",
26
+ "XDG_STATE_HOME",
27
+ "CODEX_HOME",
28
+ "CLAUDE_CONFIG_DIR",
29
+ "CLAUDE_SECURESTORAGE_CONFIG_DIR",
30
+ "GROK_HOME",
31
+ "SYSTEMROOT",
32
+ "WINDIR",
33
+ "COMSPEC",
34
+ "PATHEXT",
35
+ "APPDATA",
36
+ "LOCALAPPDATA",
37
+ "USERPROFILE",
38
+ "HOMEDRIVE",
39
+ "HOMEPATH",
40
+ "USERNAME",
41
+ ]);
42
+
43
+ export const agentEnvironment = (
44
+ parent: NodeJS.ProcessEnv,
45
+ inherit: InheritEnvironment = true,
46
+ overrides?: NodeJS.ProcessEnv,
47
+ ): Record<string, string> => {
48
+ const selected =
49
+ inherit === true
50
+ ? { ...parent }
51
+ : Object.fromEntries(
52
+ Object.entries(parent).filter(
53
+ ([name]) =>
54
+ nativeEnvironment.has(name.toUpperCase()) ||
55
+ name.startsWith("LC_") ||
56
+ inherit.includes(name),
57
+ ),
58
+ );
59
+ return Object.fromEntries(
60
+ Object.entries({ ...selected, ...overrides }).filter(
61
+ (entry): entry is [string, string] => entry[1] !== undefined,
62
+ ),
63
+ );
64
+ };
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ import { AgentAttributionSchema } from "./events.js";
3
+
4
+ export const AGENT_SPAWN_KIND = "agent-spawn" as const;
5
+ export const AGENT_COMPLETED_KIND = "agent-completed" as const;
6
+
7
+ export const AgentSpawnPayloadSchema = z.object({
8
+ agent: AgentAttributionSchema.extend({ role: z.literal("subagent") }),
9
+ prompt: z.exactOptional(z.string()),
10
+ });
11
+ export type AgentSpawnPayload = z.infer<typeof AgentSpawnPayloadSchema>;
12
+
13
+ export const AgentCompletedPayloadSchema = z.object({
14
+ agentId: z.string().min(1),
15
+ status: z.enum(["completed", "failed", "cancelled", "unknown"]),
16
+ });
17
+ export type AgentCompletedPayload = z.infer<typeof AgentCompletedPayloadSchema>;