@prismatic-io/lux 0.0.2-preview.14 → 0.0.2-preview.16

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 (388) hide show
  1. package/lib/answerers/claude-code/index.d.ts +14 -2
  2. package/lib/answerers/claude-code/index.d.ts.map +1 -1
  3. package/lib/answerers/claude-code/index.js +3 -3
  4. package/lib/answerers/claude-code/index.js.map +1 -1
  5. package/lib/answerers/persona/index.d.ts +28 -2
  6. package/lib/answerers/persona/index.d.ts.map +1 -1
  7. package/lib/answerers/persona/index.js +3 -3
  8. package/lib/answerers/persona/index.js.map +1 -1
  9. package/lib/answerers/terminal/index.d.ts +8 -2
  10. package/lib/answerers/terminal/index.d.ts.map +1 -1
  11. package/lib/answerers/terminal/index.js +3 -2
  12. package/lib/answerers/terminal/index.js.map +1 -1
  13. package/lib/assertions/core/resource-checks.d.ts.map +1 -1
  14. package/lib/assertions/core/resource-checks.js +3 -5
  15. package/lib/assertions/core/resource-checks.js.map +1 -1
  16. package/lib/assertions/rubric/index.d.ts.map +1 -1
  17. package/lib/assertions/rubric/index.js +7 -1
  18. package/lib/assertions/rubric/index.js.map +1 -1
  19. package/lib/assertions/rubric/internal.d.ts +16 -5
  20. package/lib/assertions/rubric/internal.d.ts.map +1 -1
  21. package/lib/assertions/rubric/internal.js +10 -6
  22. package/lib/assertions/rubric/internal.js.map +1 -1
  23. package/lib/authoring.d.ts +32 -2
  24. package/lib/authoring.d.ts.map +1 -1
  25. package/lib/authoring.js +33 -1
  26. package/lib/authoring.js.map +1 -1
  27. package/lib/cli/bin.js +2 -13
  28. package/lib/cli/bin.js.map +1 -1
  29. package/lib/cli/command-runtime.d.ts +3 -3
  30. package/lib/cli/command-runtime.d.ts.map +1 -1
  31. package/lib/cli/command-runtime.js +17 -6
  32. package/lib/cli/command-runtime.js.map +1 -1
  33. package/lib/cli/init-templates.d.ts +11 -0
  34. package/lib/cli/init-templates.d.ts.map +1 -0
  35. package/lib/cli/init-templates.js +207 -0
  36. package/lib/cli/init-templates.js.map +1 -0
  37. package/lib/cli/init.d.ts +7 -0
  38. package/lib/cli/init.d.ts.map +1 -1
  39. package/lib/cli/init.js +23 -173
  40. package/lib/cli/init.js.map +1 -1
  41. package/lib/cli/output-schemas.d.ts +1399 -0
  42. package/lib/cli/output-schemas.d.ts.map +1 -0
  43. package/lib/cli/output-schemas.js +91 -0
  44. package/lib/cli/output-schemas.js.map +1 -0
  45. package/lib/cli/program.d.ts +135 -4
  46. package/lib/cli/program.d.ts.map +1 -1
  47. package/lib/cli/program.js +725 -520
  48. package/lib/cli/program.js.map +1 -1
  49. package/lib/cli/render/reporter.d.ts.map +1 -1
  50. package/lib/cli/render/reporter.js +24 -4
  51. package/lib/cli/render/reporter.js.map +1 -1
  52. package/lib/cli/run-options.d.ts +0 -4
  53. package/lib/cli/run-options.d.ts.map +1 -1
  54. package/lib/cli/run-options.js +8 -19
  55. package/lib/cli/run-options.js.map +1 -1
  56. package/lib/cli/view.d.ts +5 -3
  57. package/lib/cli/view.d.ts.map +1 -1
  58. package/lib/cli/view.js +120 -78
  59. package/lib/cli/view.js.map +1 -1
  60. package/lib/core/annotation.d.ts +6 -2
  61. package/lib/core/annotation.d.ts.map +1 -1
  62. package/lib/core/annotation.js +2 -1
  63. package/lib/core/annotation.js.map +1 -1
  64. package/lib/core/answerer.d.ts +12 -0
  65. package/lib/core/answerer.d.ts.map +1 -1
  66. package/lib/core/answerer.js +2 -0
  67. package/lib/core/answerer.js.map +1 -1
  68. package/lib/core/assertion.d.ts +3 -0
  69. package/lib/core/assertion.d.ts.map +1 -1
  70. package/lib/core/assertion.js +3 -0
  71. package/lib/core/assertion.js.map +1 -1
  72. package/lib/core/case.d.ts +24 -2
  73. package/lib/core/case.d.ts.map +1 -1
  74. package/lib/core/case.js +5 -1
  75. package/lib/core/case.js.map +1 -1
  76. package/lib/core/driver.d.ts +40 -0
  77. package/lib/core/driver.d.ts.map +1 -1
  78. package/lib/core/driver.js +12 -0
  79. package/lib/core/driver.js.map +1 -1
  80. package/lib/core/environment.d.ts +18 -0
  81. package/lib/core/environment.d.ts.map +1 -0
  82. package/lib/core/environment.js +21 -0
  83. package/lib/core/environment.js.map +1 -0
  84. package/lib/core/evaluation-clusters.d.ts +17 -0
  85. package/lib/core/evaluation-clusters.d.ts.map +1 -0
  86. package/lib/core/evaluation-clusters.js +23 -0
  87. package/lib/core/evaluation-clusters.js.map +1 -0
  88. package/lib/core/experiment.d.ts +11 -0
  89. package/lib/core/experiment.d.ts.map +1 -1
  90. package/lib/core/experiment.js +31 -17
  91. package/lib/core/experiment.js.map +1 -1
  92. package/lib/core/file-tree.d.ts +7 -0
  93. package/lib/core/file-tree.d.ts.map +1 -0
  94. package/lib/core/file-tree.js +35 -0
  95. package/lib/core/file-tree.js.map +1 -0
  96. package/lib/core/index.d.ts +1 -0
  97. package/lib/core/index.d.ts.map +1 -1
  98. package/lib/core/index.js +1 -0
  99. package/lib/core/index.js.map +1 -1
  100. package/lib/core/lifecycle-fixtures.d.ts.map +1 -1
  101. package/lib/core/lifecycle-fixtures.js +4 -2
  102. package/lib/core/lifecycle-fixtures.js.map +1 -1
  103. package/lib/core/platform-process.d.ts +5 -1
  104. package/lib/core/platform-process.d.ts.map +1 -1
  105. package/lib/core/platform-process.js +48 -10
  106. package/lib/core/platform-process.js.map +1 -1
  107. package/lib/core/run.d.ts +93 -1
  108. package/lib/core/run.d.ts.map +1 -1
  109. package/lib/core/run.js +16 -0
  110. package/lib/core/run.js.map +1 -1
  111. package/lib/core/usage.d.ts +5 -0
  112. package/lib/core/usage.d.ts.map +1 -1
  113. package/lib/core/usage.js +3 -0
  114. package/lib/core/usage.js.map +1 -1
  115. package/lib/drivers/claude-code/index.d.ts +65 -2
  116. package/lib/drivers/claude-code/index.d.ts.map +1 -1
  117. package/lib/drivers/claude-code/index.js +30 -3
  118. package/lib/drivers/claude-code/index.js.map +1 -1
  119. package/lib/drivers/codex/app-events.d.ts.map +1 -1
  120. package/lib/drivers/codex/app-events.js +41 -30
  121. package/lib/drivers/codex/app-events.js.map +1 -1
  122. package/lib/drivers/codex/exec-events.d.ts +4 -0
  123. package/lib/drivers/codex/exec-events.d.ts.map +1 -0
  124. package/lib/drivers/codex/exec-events.js +230 -0
  125. package/lib/drivers/codex/exec-events.js.map +1 -0
  126. package/lib/drivers/codex/index.d.ts +76 -4
  127. package/lib/drivers/codex/index.d.ts.map +1 -1
  128. package/lib/drivers/codex/index.js +35 -232
  129. package/lib/drivers/codex/index.js.map +1 -1
  130. package/lib/drivers/cursor/acp-transport.d.ts +38 -0
  131. package/lib/drivers/cursor/acp-transport.d.ts.map +1 -0
  132. package/lib/drivers/cursor/acp-transport.js +152 -0
  133. package/lib/drivers/cursor/acp-transport.js.map +1 -0
  134. package/lib/drivers/cursor/config.d.ts +22 -0
  135. package/lib/drivers/cursor/config.d.ts.map +1 -0
  136. package/lib/drivers/cursor/config.js +26 -0
  137. package/lib/drivers/cursor/config.js.map +1 -0
  138. package/lib/drivers/cursor/events.d.ts +13 -0
  139. package/lib/drivers/cursor/events.d.ts.map +1 -0
  140. package/lib/drivers/cursor/events.js +73 -0
  141. package/lib/drivers/cursor/events.js.map +1 -0
  142. package/lib/drivers/cursor/index.d.ts +37 -0
  143. package/lib/drivers/cursor/index.d.ts.map +1 -0
  144. package/lib/drivers/cursor/index.js +276 -0
  145. package/lib/drivers/cursor/index.js.map +1 -0
  146. package/lib/drivers/cursor/interaction.d.ts +7 -0
  147. package/lib/drivers/cursor/interaction.d.ts.map +1 -0
  148. package/lib/drivers/cursor/interaction.js +66 -0
  149. package/lib/drivers/cursor/interaction.js.map +1 -0
  150. package/lib/drivers/mcp/index.d.ts +35 -2
  151. package/lib/drivers/mcp/index.d.ts.map +1 -1
  152. package/lib/drivers/mcp/index.js +16 -3
  153. package/lib/drivers/mcp/index.js.map +1 -1
  154. package/lib/drivers/shared/experiment-behavior.d.ts +13 -0
  155. package/lib/drivers/shared/experiment-behavior.d.ts.map +1 -0
  156. package/lib/drivers/shared/experiment-behavior.js +197 -0
  157. package/lib/drivers/shared/experiment-behavior.js.map +1 -0
  158. package/lib/drivers/shared/experiment-policy.d.ts +4 -0
  159. package/lib/drivers/shared/experiment-policy.d.ts.map +1 -0
  160. package/lib/drivers/shared/experiment-policy.js +143 -0
  161. package/lib/drivers/shared/experiment-policy.js.map +1 -0
  162. package/lib/drivers/subprocess/index.d.ts +37 -2
  163. package/lib/drivers/subprocess/index.d.ts.map +1 -1
  164. package/lib/drivers/subprocess/index.js +46 -6
  165. package/lib/drivers/subprocess/index.js.map +1 -1
  166. package/lib/index.d.ts +6 -5
  167. package/lib/index.d.ts.map +1 -1
  168. package/lib/index.js +4 -3
  169. package/lib/index.js.map +1 -1
  170. package/lib/orchestrator/annotation-loader.d.ts +6 -2
  171. package/lib/orchestrator/annotation-loader.d.ts.map +1 -1
  172. package/lib/orchestrator/annotation-loader.js +8 -0
  173. package/lib/orchestrator/annotation-loader.js.map +1 -1
  174. package/lib/orchestrator/annotation-store.d.ts.map +1 -1
  175. package/lib/orchestrator/annotation-store.js +16 -2
  176. package/lib/orchestrator/annotation-store.js.map +1 -1
  177. package/lib/orchestrator/campaign-lifecycle.d.ts +1 -0
  178. package/lib/orchestrator/campaign-lifecycle.d.ts.map +1 -1
  179. package/lib/orchestrator/campaign-lifecycle.js +4 -1
  180. package/lib/orchestrator/campaign-lifecycle.js.map +1 -1
  181. package/lib/orchestrator/compare.d.ts +4 -0
  182. package/lib/orchestrator/compare.d.ts.map +1 -1
  183. package/lib/orchestrator/compare.js +13 -1
  184. package/lib/orchestrator/compare.js.map +1 -1
  185. package/lib/orchestrator/comparison-identity.d.ts.map +1 -1
  186. package/lib/orchestrator/comparison-identity.js +1 -0
  187. package/lib/orchestrator/comparison-identity.js.map +1 -1
  188. package/lib/orchestrator/config.d.ts +42 -0
  189. package/lib/orchestrator/config.d.ts.map +1 -1
  190. package/lib/orchestrator/config.js +6 -2
  191. package/lib/orchestrator/config.js.map +1 -1
  192. package/lib/orchestrator/discover.d.ts +1 -0
  193. package/lib/orchestrator/discover.d.ts.map +1 -1
  194. package/lib/orchestrator/discover.js +7 -1
  195. package/lib/orchestrator/discover.js.map +1 -1
  196. package/lib/orchestrator/doctor.d.ts.map +1 -1
  197. package/lib/orchestrator/doctor.js +34 -26
  198. package/lib/orchestrator/doctor.js.map +1 -1
  199. package/lib/orchestrator/driver-capabilities.d.ts +3 -0
  200. package/lib/orchestrator/driver-capabilities.d.ts.map +1 -0
  201. package/lib/orchestrator/driver-capabilities.js +10 -0
  202. package/lib/orchestrator/driver-capabilities.js.map +1 -0
  203. package/lib/orchestrator/driver-identity.d.ts +5 -0
  204. package/lib/orchestrator/driver-identity.d.ts.map +1 -0
  205. package/lib/orchestrator/driver-identity.js +41 -0
  206. package/lib/orchestrator/driver-identity.js.map +1 -0
  207. package/lib/orchestrator/experiment-context.d.ts +10 -0
  208. package/lib/orchestrator/experiment-context.d.ts.map +1 -1
  209. package/lib/orchestrator/experiment-contracts.d.ts +10 -0
  210. package/lib/orchestrator/experiment-contracts.d.ts.map +1 -1
  211. package/lib/orchestrator/experiment-corpus.d.ts.map +1 -1
  212. package/lib/orchestrator/experiment-corpus.js +17 -19
  213. package/lib/orchestrator/experiment-corpus.js.map +1 -1
  214. package/lib/orchestrator/experiment-effects.d.ts +33 -0
  215. package/lib/orchestrator/experiment-effects.d.ts.map +1 -0
  216. package/lib/orchestrator/experiment-effects.js +44 -0
  217. package/lib/orchestrator/experiment-effects.js.map +1 -0
  218. package/lib/orchestrator/experiment-evaluation.d.ts.map +1 -1
  219. package/lib/orchestrator/experiment-evaluation.js +36 -3
  220. package/lib/orchestrator/experiment-evaluation.js.map +1 -1
  221. package/lib/orchestrator/experiment-identity.d.ts.map +1 -1
  222. package/lib/orchestrator/experiment-identity.js +18 -29
  223. package/lib/orchestrator/experiment-identity.js.map +1 -1
  224. package/lib/orchestrator/experiment-loader.d.ts +7 -2
  225. package/lib/orchestrator/experiment-loader.d.ts.map +1 -1
  226. package/lib/orchestrator/experiment-report.d.ts +70 -0
  227. package/lib/orchestrator/experiment-report.d.ts.map +1 -1
  228. package/lib/orchestrator/experiment-report.js +9 -1
  229. package/lib/orchestrator/experiment-report.js.map +1 -1
  230. package/lib/orchestrator/experiment-runs.d.ts +22 -1
  231. package/lib/orchestrator/experiment-runs.d.ts.map +1 -1
  232. package/lib/orchestrator/experiment-runs.js +13 -5
  233. package/lib/orchestrator/experiment-runs.js.map +1 -1
  234. package/lib/orchestrator/experiment-runtime-identity.d.ts +0 -16
  235. package/lib/orchestrator/experiment-runtime-identity.d.ts.map +1 -1
  236. package/lib/orchestrator/experiment-runtime-identity.js +5 -220
  237. package/lib/orchestrator/experiment-runtime-identity.js.map +1 -1
  238. package/lib/orchestrator/experiment-selection.d.ts.map +1 -1
  239. package/lib/orchestrator/experiment-selection.js +52 -0
  240. package/lib/orchestrator/experiment-selection.js.map +1 -1
  241. package/lib/orchestrator/experiment.d.ts +0 -2
  242. package/lib/orchestrator/experiment.d.ts.map +1 -1
  243. package/lib/orchestrator/experiment.js +23 -15
  244. package/lib/orchestrator/experiment.js.map +1 -1
  245. package/lib/orchestrator/fs-read.d.ts +1 -6
  246. package/lib/orchestrator/fs-read.d.ts.map +1 -1
  247. package/lib/orchestrator/fs-read.js +2 -32
  248. package/lib/orchestrator/fs-read.js.map +1 -1
  249. package/lib/orchestrator/grader-experiment.d.ts +17 -1
  250. package/lib/orchestrator/grader-experiment.d.ts.map +1 -1
  251. package/lib/orchestrator/grader-experiment.js +52 -7
  252. package/lib/orchestrator/grader-experiment.js.map +1 -1
  253. package/lib/orchestrator/grading.d.ts.map +1 -1
  254. package/lib/orchestrator/grading.js +13 -6
  255. package/lib/orchestrator/grading.js.map +1 -1
  256. package/lib/orchestrator/list-runs.d.ts +1 -0
  257. package/lib/orchestrator/list-runs.d.ts.map +1 -1
  258. package/lib/orchestrator/list-runs.js +27 -6
  259. package/lib/orchestrator/list-runs.js.map +1 -1
  260. package/lib/orchestrator/optimization-lifecycle.d.ts.map +1 -1
  261. package/lib/orchestrator/optimization-lifecycle.js +3 -1
  262. package/lib/orchestrator/optimization-lifecycle.js.map +1 -1
  263. package/lib/orchestrator/orchestrator.d.ts +6 -1
  264. package/lib/orchestrator/orchestrator.d.ts.map +1 -1
  265. package/lib/orchestrator/orchestrator.js +17 -143
  266. package/lib/orchestrator/orchestrator.js.map +1 -1
  267. package/lib/orchestrator/paired-effects.d.ts +34 -0
  268. package/lib/orchestrator/paired-effects.d.ts.map +1 -0
  269. package/lib/orchestrator/paired-effects.js +158 -0
  270. package/lib/orchestrator/paired-effects.js.map +1 -0
  271. package/lib/orchestrator/provenance.d.ts +5 -1
  272. package/lib/orchestrator/provenance.d.ts.map +1 -1
  273. package/lib/orchestrator/provenance.js +16 -3
  274. package/lib/orchestrator/provenance.js.map +1 -1
  275. package/lib/orchestrator/regrade.d.ts +1 -0
  276. package/lib/orchestrator/regrade.d.ts.map +1 -1
  277. package/lib/orchestrator/run-execution.d.ts +2 -0
  278. package/lib/orchestrator/run-execution.d.ts.map +1 -1
  279. package/lib/orchestrator/run-execution.js +18 -3
  280. package/lib/orchestrator/run-execution.js.map +1 -1
  281. package/lib/orchestrator/run-lifecycle.d.ts +1 -0
  282. package/lib/orchestrator/run-lifecycle.d.ts.map +1 -1
  283. package/lib/orchestrator/run-lifecycle.js +3 -2
  284. package/lib/orchestrator/run-lifecycle.js.map +1 -1
  285. package/lib/orchestrator/suite-runs.d.ts +3 -1
  286. package/lib/orchestrator/suite-runs.d.ts.map +1 -1
  287. package/lib/orchestrator/suite-runs.js +12 -2
  288. package/lib/orchestrator/suite-runs.js.map +1 -1
  289. package/lib/orchestrator/suite-summary.d.ts.map +1 -1
  290. package/lib/orchestrator/suite-summary.js +2 -1
  291. package/lib/orchestrator/suite-summary.js.map +1 -1
  292. package/lib/previewer/server.d.ts +6 -0
  293. package/lib/previewer/server.d.ts.map +1 -1
  294. package/lib/previewer/server.js +21 -5
  295. package/lib/previewer/server.js.map +1 -1
  296. package/package.json +2 -2
  297. package/skills/lux/references/cli.md +5 -2
  298. package/skills/lux/references/eval-authoring.md +0 -7
  299. package/skills/lux-answerer/SKILL.md +1 -1
  300. package/src/answerers/claude-code/index.ts +3 -3
  301. package/src/answerers/persona/index.ts +3 -3
  302. package/src/answerers/terminal/index.ts +4 -9
  303. package/src/assertions/core/resource-checks.ts +3 -5
  304. package/src/assertions/rubric/index.ts +7 -1
  305. package/src/assertions/rubric/internal.ts +13 -8
  306. package/src/authoring.ts +331 -2
  307. package/src/cli/bin.ts +2 -12
  308. package/src/cli/command-runtime.ts +20 -9
  309. package/src/cli/init-templates.ts +223 -0
  310. package/src/cli/init.ts +38 -184
  311. package/src/cli/output-schemas.ts +106 -0
  312. package/src/cli/program.ts +621 -548
  313. package/src/cli/render/reporter.ts +25 -4
  314. package/src/cli/run-options.ts +8 -25
  315. package/src/cli/view.ts +45 -84
  316. package/src/core/annotation.ts +2 -1
  317. package/src/core/answerer.ts +9 -0
  318. package/src/core/assertion.ts +3 -0
  319. package/src/core/case.ts +5 -1
  320. package/src/core/driver.ts +38 -0
  321. package/src/core/environment.ts +22 -0
  322. package/src/core/evaluation-clusters.ts +35 -0
  323. package/src/core/experiment.ts +60 -23
  324. package/src/core/file-tree.ts +35 -0
  325. package/src/core/index.ts +1 -0
  326. package/src/core/lifecycle-fixtures.ts +4 -2
  327. package/src/core/platform-process.ts +54 -6
  328. package/src/core/run.ts +20 -0
  329. package/src/core/usage.ts +8 -0
  330. package/src/drivers/claude-code/index.ts +34 -3
  331. package/src/drivers/codex/app-events.ts +43 -33
  332. package/src/drivers/codex/exec-events.ts +258 -0
  333. package/src/drivers/codex/index.ts +37 -262
  334. package/src/drivers/cursor/README.md +57 -0
  335. package/src/drivers/cursor/acp-transport.ts +182 -0
  336. package/src/drivers/cursor/config.ts +29 -0
  337. package/src/drivers/cursor/events.ts +83 -0
  338. package/src/drivers/cursor/index.ts +316 -0
  339. package/src/drivers/cursor/interaction.ts +90 -0
  340. package/src/drivers/mcp/index.ts +16 -3
  341. package/src/drivers/shared/experiment-behavior.ts +214 -0
  342. package/src/drivers/shared/experiment-policy.ts +195 -0
  343. package/src/drivers/subprocess/index.ts +45 -6
  344. package/src/index.ts +16 -5
  345. package/src/orchestrator/annotation-loader.ts +10 -0
  346. package/src/orchestrator/annotation-store.ts +24 -3
  347. package/src/orchestrator/campaign-lifecycle.ts +5 -1
  348. package/src/orchestrator/compare.ts +16 -1
  349. package/src/orchestrator/comparison-identity.ts +1 -0
  350. package/src/orchestrator/config.ts +6 -2
  351. package/src/orchestrator/discover.ts +8 -1
  352. package/src/orchestrator/doctor.ts +40 -22
  353. package/src/orchestrator/driver-capabilities.ts +16 -0
  354. package/src/orchestrator/driver-identity.ts +59 -0
  355. package/src/orchestrator/experiment-corpus.ts +23 -28
  356. package/src/orchestrator/experiment-effects.ts +61 -0
  357. package/src/orchestrator/experiment-evaluation.ts +45 -5
  358. package/src/orchestrator/experiment-identity.ts +27 -36
  359. package/src/orchestrator/experiment-report.ts +21 -1
  360. package/src/orchestrator/experiment-runs.ts +11 -4
  361. package/src/orchestrator/experiment-runtime-identity.ts +5 -243
  362. package/src/orchestrator/experiment-selection.ts +77 -0
  363. package/src/orchestrator/experiment.ts +26 -24
  364. package/src/orchestrator/fs-read.ts +2 -32
  365. package/src/orchestrator/grader-experiment.ts +72 -8
  366. package/src/orchestrator/grading.ts +15 -6
  367. package/src/orchestrator/list-runs.ts +29 -6
  368. package/src/orchestrator/optimization-lifecycle.ts +4 -1
  369. package/src/orchestrator/orchestrator.ts +26 -183
  370. package/src/orchestrator/paired-effects.ts +209 -0
  371. package/src/orchestrator/provenance.ts +23 -3
  372. package/src/orchestrator/run-execution.ts +18 -3
  373. package/src/orchestrator/run-lifecycle.ts +4 -2
  374. package/src/orchestrator/suite-runs.ts +10 -1
  375. package/src/orchestrator/suite-summary.ts +2 -1
  376. package/src/previewer/server.ts +27 -5
  377. package/viewer/app.js +27 -6
  378. package/viewer/detail.js +22 -5
  379. package/lib/answerers/scripted/index.d.ts +0 -18
  380. package/lib/answerers/scripted/index.d.ts.map +0 -1
  381. package/lib/answerers/scripted/index.js +0 -63
  382. package/lib/answerers/scripted/index.js.map +0 -1
  383. package/lib/cli/skills.d.ts +0 -38
  384. package/lib/cli/skills.d.ts.map +0 -1
  385. package/lib/cli/skills.js +0 -84
  386. package/lib/cli/skills.js.map +0 -1
  387. package/src/answerers/scripted/index.ts +0 -78
  388. package/src/cli/skills.ts +0 -129
@@ -0,0 +1,152 @@
1
+ import { spawnManagedProcess } from "../../core/index.js";
2
+ export const asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
3
+ ? value
4
+ : undefined;
5
+ export class AcpTransport {
6
+ process;
7
+ pending = new Map();
8
+ nextId = 1;
9
+ buffer = Buffer.alloc(0);
10
+ queuedBytes = 0;
11
+ chain = Promise.resolve();
12
+ stopped = false;
13
+ stderrTail = "";
14
+ options;
15
+ constructor(options) {
16
+ this.options = options;
17
+ this.process = spawnManagedProcess(options.command, options.args, {
18
+ cwd: options.cwd,
19
+ ...(options.env ? { env: options.env } : {}),
20
+ signal: options.signal,
21
+ });
22
+ this.process.child.stdout.on("data", (chunk) => this.read(chunk));
23
+ this.process.child.stderr.setEncoding("utf8");
24
+ this.process.child.stderr.on("data", (chunk) => {
25
+ this.stderrTail = (this.stderrTail + chunk).slice(-8_192);
26
+ });
27
+ void this.process.exited.then(({ exitCode, signal }) => {
28
+ if (!this.stopped)
29
+ this.fail(new Error(`Cursor ACP exited before completion (code=${exitCode}, signal=${signal})${this.stderrTail ? `: ${this.stderrTail}` : ""}`));
30
+ });
31
+ }
32
+ async spawned() {
33
+ await this.process.spawned;
34
+ }
35
+ request(method, params, timeoutMs) {
36
+ if (this.stopped)
37
+ return Promise.reject(new Error("Cursor ACP is closed"));
38
+ const id = this.nextId++;
39
+ return new Promise((resolve, reject) => {
40
+ const timer = timeoutMs === undefined
41
+ ? undefined
42
+ : setTimeout(() => {
43
+ this.fail(new Error(`Cursor ACP ${method} timed out after ${timeoutMs}ms`));
44
+ }, timeoutMs);
45
+ this.pending.set(id, { resolve, reject, timer });
46
+ try {
47
+ this.write({ id, method, params });
48
+ }
49
+ catch (error) {
50
+ this.fail(error instanceof Error ? error : new Error(String(error)));
51
+ }
52
+ });
53
+ }
54
+ write(message) {
55
+ if (this.stopped)
56
+ throw new Error("Cursor ACP is closed");
57
+ const line = `${JSON.stringify({ jsonrpc: "2.0", ...message })}\n`;
58
+ if (Buffer.byteLength(line) > this.options.maxLineBytes)
59
+ throw new Error("Cursor ACP outgoing message exceeded maxLineBytes");
60
+ this.process.child.stdin.write(line);
61
+ }
62
+ async drained() {
63
+ await this.chain;
64
+ }
65
+ async close() {
66
+ this.stopped = true;
67
+ this.rejectPending(new Error("Cursor ACP is closed"));
68
+ this.buffer = Buffer.alloc(0);
69
+ await this.process.terminate();
70
+ }
71
+ rejectPending(error) {
72
+ for (const pending of this.pending.values()) {
73
+ clearTimeout(pending.timer);
74
+ pending.reject(error);
75
+ }
76
+ this.pending.clear();
77
+ }
78
+ fail(error) {
79
+ if (this.stopped)
80
+ return;
81
+ this.stopped = true;
82
+ this.rejectPending(error);
83
+ this.options.onFailure(error);
84
+ void this.process.terminate();
85
+ }
86
+ read(chunk) {
87
+ let offset = 0;
88
+ while (offset < chunk.length && !this.stopped) {
89
+ const newline = chunk.indexOf(0x0a, offset);
90
+ const end = newline === -1 ? chunk.length : newline;
91
+ const segment = chunk.subarray(offset, end);
92
+ if (this.buffer.length + segment.length > this.options.maxLineBytes) {
93
+ this.fail(new Error("Cursor ACP stdout line exceeded maxLineBytes"));
94
+ return;
95
+ }
96
+ this.buffer = Buffer.concat([this.buffer, segment]);
97
+ if (newline === -1)
98
+ return;
99
+ const line = this.buffer;
100
+ this.buffer = Buffer.alloc(0);
101
+ this.line(line);
102
+ offset = newline + 1;
103
+ }
104
+ }
105
+ line(line) {
106
+ if (!line.toString("utf8").trim())
107
+ return;
108
+ let message;
109
+ try {
110
+ message = asRecord(JSON.parse(line.toString("utf8")));
111
+ }
112
+ catch {
113
+ /* Rejected below. */
114
+ }
115
+ if (message?.jsonrpc !== "2.0") {
116
+ this.fail(new Error("Cursor ACP returned an invalid JSON-RPC message"));
117
+ return;
118
+ }
119
+ this.options.onActivity();
120
+ if (message.method === undefined) {
121
+ const pending = this.pending.get(message.id);
122
+ if (!pending)
123
+ return;
124
+ this.pending.delete(message.id);
125
+ clearTimeout(pending.timer);
126
+ const error = asRecord(message.error);
127
+ if (error)
128
+ pending.reject(new Error(String(error.message ?? "Cursor ACP request failed")));
129
+ else
130
+ pending.resolve(asRecord(message.result) ?? {});
131
+ return;
132
+ }
133
+ this.queuedBytes += line.length;
134
+ if (this.queuedBytes > this.options.maxQueuedBytes) {
135
+ this.fail(new Error("Cursor ACP pending events exceeded maxQueuedBytes"));
136
+ return;
137
+ }
138
+ const queued = message;
139
+ this.chain = this.chain
140
+ .then(async () => {
141
+ try {
142
+ if (!this.stopped)
143
+ await this.options.onMessage(queued);
144
+ }
145
+ finally {
146
+ this.queuedBytes -= line.length;
147
+ }
148
+ })
149
+ .catch((error) => this.fail(error instanceof Error ? error : new Error(String(error))));
150
+ }
151
+ }
152
+ //# sourceMappingURL=acp-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-transport.js","sourceRoot":"","sources":["../../../src/drivers/cursor/acp-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI/E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAyB,EAAE,CAChE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IAClE,CAAC,CAAE,KAAmB;IACtB,CAAC,CAAC,SAAS,CAAC;AAehB,MAAM,OAAO,YAAY;IACN,OAAO,CAAiB;IACxB,OAAO,GAAG,IAAI,GAAG,EAO/B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IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;aACpB,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,IAAI,CAAC;gBACH,IAAI,CAAC,IAAI,CAAC,OAAO;oBAAE,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC1D,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC;YAClC,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACrE,CAAC;IACN,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ export declare const CursorDriverConfigSchema: z.ZodObject<{
3
+ command: z.ZodDefault<z.ZodString>;
4
+ model: z.ZodString;
5
+ reasoningEffort: z.ZodOptional<z.ZodString>;
6
+ mode: z.ZodDefault<z.ZodEnum<{
7
+ agent: "agent";
8
+ ask: "ask";
9
+ plan: "plan";
10
+ }>>;
11
+ cwd: z.ZodOptional<z.ZodString>;
12
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13
+ startupTimeoutMs: z.ZodDefault<z.ZodNumber>;
14
+ idleTimeoutMs: z.ZodDefault<z.ZodNumber>;
15
+ maxInterrupts: z.ZodDefault<z.ZodNumber>;
16
+ maxLineBytes: z.ZodDefault<z.ZodNumber>;
17
+ maxQueuedBytes: z.ZodDefault<z.ZodNumber>;
18
+ maxToolCalls: z.ZodDefault<z.ZodNumber>;
19
+ }, z.core.$strict>;
20
+ export type CursorDriverConfig = z.infer<typeof CursorDriverConfigSchema>;
21
+ export declare const buildCursorArgs: (config: CursorDriverConfig) => string[];
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/drivers/cursor/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;kBAiB1B,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,eAAe,WAAY,kBAAkB,KAAG,MAAM,EAKlE,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export const CursorDriverConfigSchema = z
3
+ .object({
4
+ command: z.string().min(1).default("agent"),
5
+ /** Cursor model IDs may include an effort suffix; never inherit Auto. */
6
+ model: z.string().min(1),
7
+ /** Applied only through an advertised ACP thought-level selector. */
8
+ reasoningEffort: z.string().min(1).optional(),
9
+ mode: z.enum(["agent", "plan", "ask"]).default("agent"),
10
+ cwd: z.string().optional(),
11
+ env: z.record(z.string(), z.string()).optional(),
12
+ startupTimeoutMs: z.number().int().positive().default(30_000),
13
+ idleTimeoutMs: z.number().int().positive().default(600_000),
14
+ maxInterrupts: z.number().int().positive().default(20),
15
+ maxLineBytes: z.number().int().positive().default(10_000_000),
16
+ maxQueuedBytes: z.number().int().positive().default(20_000_000),
17
+ maxToolCalls: z.number().int().positive().default(10_000),
18
+ })
19
+ .strict();
20
+ export const buildCursorArgs = (config) => [
21
+ "--model",
22
+ config.model,
23
+ ...(config.mode === "agent" ? [] : ["--mode", config.mode]),
24
+ "acp",
25
+ ];
26
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js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CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC/D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;CAC1D,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAA0B,EAAY,EAAE,CAAC;IACvE,SAAS;IACT,MAAM,CAAC,KAAK;IACZ,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3D,KAAK;CACN,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Progress } from "../../core/index.js";
2
+ import { type RpcRecord } from "./acp-transport.js";
3
+ export declare class CursorEvents {
4
+ private seq;
5
+ private retainedBytes;
6
+ private readonly tools;
7
+ private readonly completed;
8
+ private readonly maxToolCalls;
9
+ private readonly maxBytes;
10
+ constructor(maxToolCalls: number, maxBytes: number);
11
+ update(update: RpcRecord): Progress[];
12
+ }
13
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/drivers/cursor/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAsB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK9D,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,YAAY,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAGjD;IAED,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,CA6DpC;CACF"}
@@ -0,0 +1,73 @@
1
+ import { toolResultProgress } from "../../core/index.js";
2
+ import { asRecord } from "./acp-transport.js";
3
+ import { records } from "./interaction.js";
4
+ export class CursorEvents {
5
+ seq = 0;
6
+ retainedBytes = 0;
7
+ tools = new Map();
8
+ completed = new Set();
9
+ maxToolCalls;
10
+ maxBytes;
11
+ constructor(maxToolCalls, maxBytes) {
12
+ this.maxToolCalls = maxToolCalls;
13
+ this.maxBytes = maxBytes;
14
+ }
15
+ update(update) {
16
+ const ts = Date.now();
17
+ if (update.sessionUpdate === "agent_message_chunk" ||
18
+ update.sessionUpdate === "agent_thought_chunk") {
19
+ const content = asRecord(update.content);
20
+ if (content?.type !== "text" || typeof content.text !== "string")
21
+ return [];
22
+ return [
23
+ {
24
+ id: `cursor-message-${++this.seq}`,
25
+ kind: update.sessionUpdate === "agent_message_chunk" ? "agent-message" : "reasoning",
26
+ payload: { text: content.text },
27
+ ts,
28
+ },
29
+ ];
30
+ }
31
+ if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
32
+ return [{ id: `cursor-update-${++this.seq}`, kind: "cursor-update", payload: update, ts }];
33
+ }
34
+ const id = update.toolCallId;
35
+ if (typeof id !== "string")
36
+ throw new Error("Cursor ACP tool update omitted toolCallId");
37
+ if (this.completed.has(id))
38
+ return [];
39
+ const old = this.tools.get(id);
40
+ if (!old && this.tools.size + this.completed.size >= this.maxToolCalls)
41
+ throw new Error("Cursor ACP exceeded maxToolCalls");
42
+ const value = { ...old?.value, ...update };
43
+ const bytes = Buffer.byteLength(JSON.stringify(value));
44
+ this.retainedBytes += bytes - (old?.bytes ?? 0);
45
+ if (this.retainedBytes > this.maxBytes)
46
+ throw new Error("Cursor ACP tool state exceeded maxQueuedBytes");
47
+ const name = old?.name ?? String(value.title ?? value.kind ?? "cursor-tool");
48
+ this.tools.set(id, { value, bytes, name });
49
+ const events = old
50
+ ? []
51
+ : [
52
+ {
53
+ id: `tc-${id}`,
54
+ kind: "tool-call",
55
+ payload: { name, input: value.rawInput ?? {}, toolUseId: id },
56
+ ts,
57
+ },
58
+ ];
59
+ if (value.status === "completed" || value.status === "failed") {
60
+ const content = value.rawOutput ?? value.content ?? [];
61
+ const text = records(value.content)
62
+ .map((block) => asRecord(block.content)?.text)
63
+ .filter((entry) => typeof entry === "string")
64
+ .join("\n");
65
+ events.push(toolResultProgress(++this.seq, { name, toolUseId: id, content, isError: value.status === "failed", text }, ts));
66
+ this.retainedBytes -= bytes;
67
+ this.tools.delete(id);
68
+ this.completed.add(id);
69
+ }
70
+ return events;
71
+ }
72
+ }
73
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/drivers/cursor/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAkB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,MAAM,OAAO,YAAY;IACf,GAAG,GAAG,CAAC,CAAC;IACR,aAAa,GAAG,CAAC,CAAC;IACT,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IACrC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,YAAY,CAAS;IACrB,QAAQ,CAAS;IAElC,YAAY,YAAoB,EAAE,QAAgB;QAChD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,MAAiB;QACtB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACtB,IACE,MAAM,CAAC,a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OAAO,CAAC,EAAE,IAAI,CAAC;iBAC7C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;iBAC5C,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,EAAE,IAAI,CAAC,GAAG,EACV,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,IAAI,EAAE,EAC1E,EAAE,CACH,CACF,CAAC;YACF,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACtB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ import { buildCursorArgs, type CursorDriverConfig, CursorDriverConfigSchema } from "./config.js";
2
+ export declare const cursorDriver: Omit<import("../../core/driver.js").DriverPlugin<{
3
+ command: string;
4
+ model: string;
5
+ reasoningEffort?: string | undefined;
6
+ mode: "agent" | "ask" | "plan";
7
+ cwd?: string | undefined;
8
+ env?: Record<string, string> | undefined;
9
+ startupTimeoutMs: number;
10
+ idleTimeoutMs: number;
11
+ maxInterrupts: number;
12
+ maxLineBytes: number;
13
+ maxQueuedBytes: number;
14
+ maxToolCalls: number;
15
+ }>, "configSchema"> & {
16
+ configSchema: import("zod").ZodObject<{
17
+ command: import("zod").ZodDefault<import("zod").ZodString>;
18
+ model: import("zod").ZodString;
19
+ reasoningEffort: import("zod").ZodOptional<import("zod").ZodString>;
20
+ mode: import("zod").ZodDefault<import("zod").ZodEnum<{
21
+ agent: "agent";
22
+ ask: "ask";
23
+ plan: "plan";
24
+ }>>;
25
+ cwd: import("zod").ZodOptional<import("zod").ZodString>;
26
+ env: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
27
+ startupTimeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
28
+ idleTimeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
29
+ maxInterrupts: import("zod").ZodDefault<import("zod").ZodNumber>;
30
+ maxLineBytes: import("zod").ZodDefault<import("zod").ZodNumber>;
31
+ maxQueuedBytes: import("zod").ZodDefault<import("zod").ZodNumber>;
32
+ maxToolCalls: import("zod").ZodDefault<import("zod").ZodNumber>;
33
+ }, import("zod/v4/core").$strict>;
34
+ };
35
+ export type { CursorDriverConfig };
36
+ export { buildCursorArgs, CursorDriverConfigSchema };
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drivers/cursor/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AA0RjG,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEH,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,CAAC"}
@@ -0,0 +1,276 @@
1
+ import { realpath } from "node:fs/promises";
2
+ import { defineDriver, discoverCliVersion, TypedEmitter, } from "../../core/index.js";
3
+ import { walkArtifacts } from "../shared/artifacts.js";
4
+ import { AcpTransport, asRecord } from "./acp-transport.js";
5
+ import { buildCursorArgs, CursorDriverConfigSchema } from "./config.js";
6
+ import { CursorEvents } from "./events.js";
7
+ import { cursorAnswer, cursorQuestionText, effortSelector, records } from "./interaction.js";
8
+ class CursorDriver {
9
+ emitter = new TypedEmitter();
10
+ events;
11
+ transport;
12
+ sessionId;
13
+ cwd;
14
+ artifactsDir;
15
+ ready = false;
16
+ runPromise;
17
+ terminal = false;
18
+ idleTimer;
19
+ interruptCount = 0;
20
+ interrupts = new Map();
21
+ config;
22
+ constructor(config) {
23
+ this.config = config;
24
+ this.events = new CursorEvents(config.maxToolCalls, config.maxQueuedBytes);
25
+ }
26
+ on(event, handler) {
27
+ this.emitter.on(event, handler);
28
+ }
29
+ off(event, handler) {
30
+ this.emitter.off(event, handler);
31
+ }
32
+ async start(ctx) {
33
+ if (this.transport || this.terminal)
34
+ throw new Error("Cursor driver cannot be started twice or after close");
35
+ this.cwd = await realpath(this.config.cwd ?? ctx.artifactsDir);
36
+ this.artifactsDir = await realpath(ctx.artifactsDir);
37
+ const cliVersion = await discoverCliVersion(this.config.command);
38
+ const transport = new AcpTransport({
39
+ command: this.config.command,
40
+ args: buildCursorArgs(this.config),
41
+ cwd: this.cwd,
42
+ env: { ...process.env, ...this.config.env },
43
+ signal: ctx.abortSignal,
44
+ maxLineBytes: this.config.maxLineBytes,
45
+ maxQueuedBytes: this.config.maxQueuedBytes,
46
+ onMessage: (message) => this.message(message),
47
+ onFailure: (error) => this.fail(error),
48
+ onActivity: () => this.bumpIdleTimer(),
49
+ });
50
+ this.transport = transport;
51
+ try {
52
+ await transport.spawned();
53
+ const initialized = await this.request("initialize", {
54
+ protocolVersion: 1,
55
+ clientInfo: { name: "lux", version: "1" },
56
+ clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
57
+ });
58
+ if (initialized.protocolVersion !== 1)
59
+ throw new Error("Cursor ACP returned an unsupported protocol version");
60
+ if (!records(initialized.authMethods).some((method) => method.id === "cursor_login")) {
61
+ throw new Error("Expected Cursor ACP with cursor_login authentication; check the configured command points to Cursor CLI");
62
+ }
63
+ await this.request("authenticate", { methodId: "cursor_login" });
64
+ let session = await this.request("session/new", { cwd: this.cwd, mcpServers: [] });
65
+ if (typeof session.sessionId !== "string")
66
+ throw new Error("Cursor ACP omitted sessionId");
67
+ this.sessionId = session.sessionId;
68
+ if (this.config.reasoningEffort) {
69
+ const selection = effortSelector(session, this.config.reasoningEffort);
70
+ const updated = await this.request("session/set_config_option", {
71
+ sessionId: this.sessionId,
72
+ ...selection,
73
+ });
74
+ const applied = records(updated.configOptions).find((option) => option.id === selection.configId);
75
+ if (applied?.currentValue !== this.config.reasoningEffort)
76
+ throw new Error("Cursor ACP did not apply the requested reasoning effort");
77
+ session = { ...session, ...updated };
78
+ }
79
+ const model = records(session.configOptions).find((option) => option.category === "model" || option.id === "model")?.currentValue ?? asRecord(session.models)?.currentModelId;
80
+ if (typeof model === "string" && model !== this.config.model)
81
+ throw new Error(`Cursor ACP selected '${model}' instead of requested '${this.config.model}'`);
82
+ this.ready = true;
83
+ this.bumpIdleTimer();
84
+ this.runPromise = this.run(ctx.prompt).catch((error) => this.fail(error));
85
+ return {
86
+ agentId: "cursor",
87
+ model: this.config.model,
88
+ detail: {
89
+ sessionId: this.sessionId,
90
+ transport: "acp",
91
+ protocolVersion: 1,
92
+ ...(cliVersion ? { cliVersion } : {}),
93
+ modelResolution: typeof model === "string" ? "reported" : "requested",
94
+ nativeConfig: session.configOptions ?? [],
95
+ usageAvailability: "unknown",
96
+ isolation: "none",
97
+ },
98
+ };
99
+ }
100
+ catch (error) {
101
+ await this.close();
102
+ throw error;
103
+ }
104
+ }
105
+ request(method, params) {
106
+ if (!this.transport)
107
+ throw new Error("Cursor ACP has not started");
108
+ return this.transport.request(method, params, this.config.startupTimeoutMs);
109
+ }
110
+ async run(prompt) {
111
+ const result = await this.transport?.request("session/prompt", {
112
+ sessionId: this.sessionId,
113
+ prompt: [{ type: "text", text: prompt }],
114
+ });
115
+ await this.transport?.drained();
116
+ if (this.terminal)
117
+ return;
118
+ if (result?.stopReason !== "end_turn")
119
+ throw new Error(`Cursor stopped with ${String(result?.stopReason ?? "unknown reason")}`);
120
+ this.terminal = true;
121
+ clearTimeout(this.idleTimer);
122
+ await this.emitter.emit("done", {
123
+ exitReason: "done",
124
+ summary: {
125
+ sessionId: this.sessionId,
126
+ stopReason: result.stopReason,
127
+ usageAvailability: "unknown",
128
+ },
129
+ });
130
+ }
131
+ async message(message) {
132
+ if (this.terminal)
133
+ return;
134
+ const method = String(message.method);
135
+ const params = asRecord(message.params) ?? {};
136
+ const id = message.id;
137
+ if (typeof id === "number" || typeof id === "string") {
138
+ if (typeof params.sessionId === "string" && params.sessionId !== this.sessionId) {
139
+ this.transport?.write({ id, error: { code: -32602, message: "Unknown session" } });
140
+ return;
141
+ }
142
+ if (!["session/request_permission", "cursor/ask_question", "cursor/create_plan"].includes(method)) {
143
+ this.transport?.write({
144
+ id,
145
+ error: { code: -32601, message: `Unsupported method: ${method}` },
146
+ });
147
+ return;
148
+ }
149
+ if (++this.interruptCount > this.config.maxInterrupts)
150
+ throw new Error("Cursor exceeded maxInterrupts");
151
+ const interruptId = `cursor-${id}`;
152
+ if (this.interrupts.has(interruptId))
153
+ throw new Error("Cursor reused a pending request ID");
154
+ this.interrupts.set(interruptId, { id, method, params });
155
+ clearTimeout(this.idleTimer);
156
+ if (method === "cursor/ask_question") {
157
+ await this.emitter.emit("interrupt", {
158
+ kind: "ask",
159
+ id: interruptId,
160
+ question: cursorQuestionText(params),
161
+ context: params,
162
+ });
163
+ }
164
+ else {
165
+ await this.emitter.emit("interrupt", {
166
+ kind: "approve",
167
+ id: interruptId,
168
+ request: method === "cursor/create_plan"
169
+ ? String(params.plan ?? params.overview ?? "Approve this plan?")
170
+ : String(asRecord(params.toolCall)?.title ?? "Approve this tool call?"),
171
+ context: params,
172
+ });
173
+ }
174
+ return;
175
+ }
176
+ if (method === "session/update") {
177
+ if (params.sessionId !== this.sessionId)
178
+ return;
179
+ const update = asRecord(params.update);
180
+ if (update)
181
+ for (const event of this.events.update(update))
182
+ await this.emitter.emit("progress", event);
183
+ }
184
+ else if (method.startsWith("cursor/")) {
185
+ await this.emitter.emit("progress", {
186
+ id: `cursor-native-${Date.now()}-${method}`,
187
+ kind: "cursor-event",
188
+ payload: { method, params },
189
+ ts: Date.now(),
190
+ });
191
+ }
192
+ }
193
+ async respond(answer) {
194
+ const pending = this.interrupts.get(answer.id);
195
+ if (!pending)
196
+ throw new Error(`Cursor has no pending interrupt '${answer.id}'`);
197
+ const result = cursorAnswer(pending.method, pending.params, answer);
198
+ this.transport?.write({ id: pending.id, result });
199
+ this.interrupts.delete(answer.id);
200
+ this.bumpIdleTimer();
201
+ }
202
+ bumpIdleTimer() {
203
+ clearTimeout(this.idleTimer);
204
+ if (!this.ready || this.terminal || this.interrupts.size > 0)
205
+ return;
206
+ this.idleTimer = setTimeout(() => this.fail(new Error(`Cursor emitted no event for ${this.config.idleTimeoutMs}ms`), "idle-timeout"), this.config.idleTimeoutMs);
207
+ }
208
+ fail(error, exitReason = "error") {
209
+ if (this.terminal)
210
+ return;
211
+ this.terminal = true;
212
+ clearTimeout(this.idleTimer);
213
+ if (this.ready)
214
+ void this.transport?.drained().then(() => this.emitter.emit("error", {
215
+ exitReason,
216
+ reason: error instanceof Error ? error.message : String(error),
217
+ }));
218
+ void this.transport?.close();
219
+ }
220
+ async quiesce() {
221
+ clearTimeout(this.idleTimer);
222
+ const cancelling = !this.terminal && this.sessionId !== undefined;
223
+ this.terminal = true;
224
+ if (cancelling) {
225
+ for (const pending of this.interrupts.values())
226
+ this.transport?.write({ id: pending.id, result: { outcome: { outcome: "cancelled" } } });
227
+ this.transport?.write({ method: "session/cancel", params: { sessionId: this.sessionId } });
228
+ let timer;
229
+ try {
230
+ await Promise.race([
231
+ this.runPromise,
232
+ new Promise((resolve) => {
233
+ timer = setTimeout(resolve, 200);
234
+ }),
235
+ ]);
236
+ }
237
+ finally {
238
+ clearTimeout(timer);
239
+ }
240
+ }
241
+ this.interrupts.clear();
242
+ await this.transport?.close();
243
+ }
244
+ async collect() {
245
+ await this.quiesce();
246
+ if (!this.cwd)
247
+ return [];
248
+ const artifacts = await walkArtifacts(this.cwd);
249
+ return this.cwd === this.artifactsDir
250
+ ? artifacts
251
+ : artifacts.map((artifact) => ({ ...artifact, root: this.cwd }));
252
+ }
253
+ async close() {
254
+ await this.quiesce();
255
+ this.emitter.removeAllListeners();
256
+ }
257
+ }
258
+ export const cursorDriver = defineDriver({
259
+ name: "cursor",
260
+ configSchema: CursorDriverConfigSchema,
261
+ runtime: (config) => ({
262
+ commands: [config.command],
263
+ capabilities: {
264
+ interactive: true,
265
+ "tool-calls": true,
266
+ "tool-results": true,
267
+ artifacts: true,
268
+ usage: false,
269
+ cost: false,
270
+ isolation: false,
271
+ },
272
+ }),
273
+ create: (config) => new CursorDriver(config),
274
+ });
275
+ export { buildCursorArgs, CursorDriverConfigSchema };
276
+ //# sourceMappingURL=index.js.map