@cursor/july 0.1.107 → 0.1.109

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 (523) hide show
  1. package/AGENTS.md +2 -6
  2. package/README.md +13 -11
  3. package/dist/bin/agent-serve.js +30 -8
  4. package/dist/channels/bitbucket/api.d.ts +41 -0
  5. package/dist/channels/bitbucket/api.d.ts.map +1 -1
  6. package/dist/channels/bitbucket/api.js +260 -0
  7. package/dist/channels/bitbucket/binding.d.ts +4 -0
  8. package/dist/channels/bitbucket/binding.d.ts.map +1 -1
  9. package/dist/channels/bitbucket/binding.js +16 -0
  10. package/dist/channels/bitbucket/index.d.ts +1 -1
  11. package/dist/channels/bitbucket/index.d.ts.map +1 -1
  12. package/dist/channels/bitbucket/index.js +1 -1
  13. package/dist/channels/github/github-channel.js +8 -5
  14. package/dist/channels/github/types.d.ts +5 -1
  15. package/dist/channels/github/types.d.ts.map +1 -1
  16. package/dist/channels/gitlab/api.d.ts +27 -0
  17. package/dist/channels/gitlab/api.d.ts.map +1 -1
  18. package/dist/channels/gitlab/api.js +88 -0
  19. package/dist/channels/gitlab/binding.d.ts +5 -0
  20. package/dist/channels/gitlab/binding.d.ts.map +1 -1
  21. package/dist/channels/gitlab/binding.js +10 -0
  22. package/dist/channels/gitlab/index.d.ts +1 -1
  23. package/dist/channels/gitlab/index.d.ts.map +1 -1
  24. package/dist/channels/gitlab/index.js +1 -1
  25. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  26. package/dist/channels/origin/origin-channel.js +27 -13
  27. package/dist/channels/origin/types.d.ts +5 -1
  28. package/dist/channels/origin/types.d.ts.map +1 -1
  29. package/dist/channels/slack/dispatch.d.ts +10 -0
  30. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  31. package/dist/channels/slack/dispatch.js +20 -3
  32. package/dist/channels/slack/slack-channel.d.ts +12 -5
  33. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  34. package/dist/channels/slack/slack-channel.js +59 -8
  35. package/dist/channels.d.ts +45 -0
  36. package/dist/channels.d.ts.map +1 -1
  37. package/dist/channels.js +106 -7
  38. package/dist/connections.d.ts +2 -1
  39. package/dist/connections.d.ts.map +1 -1
  40. package/dist/connections.js +2 -1
  41. package/dist/docs/404.html +2 -2
  42. package/dist/docs/assets/{app.CtuckIiL.js → app.Cr-wVbnB.js} +1 -1
  43. package/dist/docs/assets/{building-with-agents.md.CUSWxlP_.js → building-with-agents.md.D0KbSkJn.js} +2 -2
  44. package/dist/docs/assets/{building-with-agents.md.CUSWxlP_.lean.js → building-with-agents.md.D0KbSkJn.lean.js} +1 -1
  45. package/dist/docs/assets/chunks/@localSearchIndexroot.CFVQ4S17.js +1 -0
  46. package/dist/docs/assets/chunks/{VPLocalSearchBox.Bkkhnu8K.js → VPLocalSearchBox.CVQERt56.js} +1 -1
  47. package/dist/docs/assets/chunks/{theme.DhpIe0Pa.js → theme.Dnsd3XOn.js} +2 -2
  48. package/dist/docs/assets/concepts.md.B4o63Gul.js +1 -0
  49. package/dist/docs/assets/{deployment.md.MFPKqsqI.js → deployment.md.JenwuCCB.js} +4 -4
  50. package/dist/docs/assets/{deployment.md.MFPKqsqI.lean.js → deployment.md.JenwuCCB.lean.js} +1 -1
  51. package/dist/docs/assets/evals.md.C7JLjoEP.js +211 -0
  52. package/dist/docs/assets/evals.md.C7JLjoEP.lean.js +1 -0
  53. package/dist/docs/assets/guides_bitbucket.md.DZPzmUjU.js +10 -0
  54. package/dist/docs/assets/guides_bitbucket.md.DZPzmUjU.lean.js +1 -0
  55. package/dist/docs/assets/guides_cloud-agents.md.BsloyHdY.js +9 -0
  56. package/dist/docs/assets/{guides_cloud-agents.md.DS8RIjwx.lean.js → guides_cloud-agents.md.BsloyHdY.lean.js} +1 -1
  57. package/dist/docs/assets/{guides_github.md.c0gdGJ-D.js → guides_github.md.TZaTZlfz.js} +13 -3
  58. package/dist/docs/assets/{guides_github.md.c0gdGJ-D.lean.js → guides_github.md.TZaTZlfz.lean.js} +1 -1
  59. package/dist/docs/assets/guides_gitlab.md.BmqwQfdG.js +14 -0
  60. package/dist/docs/assets/guides_gitlab.md.BmqwQfdG.lean.js +1 -0
  61. package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.js → guides_grokbot-agents.md.DyV-WArv.js} +1 -1
  62. package/dist/docs/assets/guides_improve.md.BGVk32bK.js +14 -0
  63. package/dist/docs/assets/guides_improve.md.BGVk32bK.lean.js +1 -0
  64. package/dist/docs/assets/{guides_slack.md.9oHPye9o.js → guides_slack.md.D4RVMM4G.js} +3 -3
  65. package/dist/docs/assets/{guides_slack.md.9oHPye9o.lean.js → guides_slack.md.D4RVMM4G.lean.js} +1 -1
  66. package/dist/docs/assets/{guides_webhooks.md.DKdA43Qm.js → guides_webhooks.md.CJK484ex.js} +2 -2
  67. package/dist/docs/assets/{hillclimbing.md.CpTGTCle.js → hillclimbing.md.BOiVo1tf.js} +1 -1
  68. package/dist/docs/assets/index.md.DD9Q2XuJ.js +5 -0
  69. package/dist/docs/assets/{index.md.BW_6tOgR.lean.js → index.md.DD9Q2XuJ.lean.js} +1 -1
  70. package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.js → reference_agent-config.md.CvoL6pof.js} +1 -1
  71. package/dist/docs/assets/{reference_channels.md.D-qTqwcq.js → reference_channels.md.CAo-iK4j.js} +2 -2
  72. package/dist/docs/assets/{reference_channels.md.D-qTqwcq.lean.js → reference_channels.md.CAo-iK4j.lean.js} +1 -1
  73. package/dist/docs/assets/{reference_cli.md.Dm67hd2D.js → reference_cli.md.Deg7849l.js} +7 -7
  74. package/dist/docs/assets/{reference_cli.md.Dm67hd2D.lean.js → reference_cli.md.Deg7849l.lean.js} +1 -1
  75. package/dist/docs/assets/{reference_connections.md.Di6jJAXF.js → reference_connections.md.BojkC6c5.js} +1 -1
  76. package/dist/docs/assets/{reference_extensions.md.CGmMLblt.js → reference_extensions.md.ZAVUyuEX.js} +3 -3
  77. package/dist/docs/assets/{reference_hooks.md.Ddt5DdgJ.js → reference_hooks.md.BlM_bOg6.js} +3 -3
  78. package/dist/docs/assets/{reference_hooks.md.Ddt5DdgJ.lean.js → reference_hooks.md.BlM_bOg6.lean.js} +1 -1
  79. package/dist/docs/assets/{reference_http-api.md.oySXBO8o.js → reference_http-api.md.BwaCo-VO.js} +1 -1
  80. package/dist/docs/assets/{reference_playground.md.4myJPxrf.js → reference_playground.md.DLnoaczX.js} +1 -1
  81. package/dist/docs/assets/{reference_playground.md.4myJPxrf.lean.js → reference_playground.md.DLnoaczX.lean.js} +1 -1
  82. package/dist/docs/assets/{reference_project-layout.md.DuBu9a96.js → reference_project-layout.md.BEU8MtQV.js} +3 -3
  83. package/dist/docs/assets/{reference_project-layout.md.DuBu9a96.lean.js → reference_project-layout.md.BEU8MtQV.lean.js} +1 -1
  84. package/dist/docs/assets/reference_sessions.md.CyXV1MUw.js +1 -0
  85. package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.js → scaffolding-agents.md.Kctn3OVb.js} +1 -1
  86. package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.js → skills_create-agent.md.Q3h6Je-e.js} +1 -1
  87. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.js → skills_debug.md.CVjCXMFF.js} +1 -1
  88. package/dist/docs/assets/{skills_debug.md.CDbPhHfg.lean.js → skills_debug.md.CVjCXMFF.lean.js} +1 -1
  89. package/dist/docs/assets/skills_deploy.md.CWqi_ZxW.js +35 -0
  90. package/dist/docs/assets/skills_deploy.md.CWqi_ZxW.lean.js +1 -0
  91. package/dist/docs/assets/skills_evals.md.DFxYPErF.js +25 -0
  92. package/dist/docs/assets/skills_evals.md.DFxYPErF.lean.js +1 -0
  93. package/dist/docs/assets/skills_framework-map.md.BxLSOhSY.js +1 -0
  94. package/dist/docs/assets/{skills_framework-map.md.haibFyoB.lean.js → skills_framework-map.md.BxLSOhSY.lean.js} +1 -1
  95. package/dist/docs/assets/{skills_github.md.D0JahM8c.js → skills_github.md.hgFX_oKY.js} +1 -1
  96. package/dist/docs/assets/skills_index.md.DL7EHaQ-.js +1 -0
  97. package/dist/docs/assets/skills_index.md.DL7EHaQ-.lean.js +1 -0
  98. package/dist/docs/assets/{storage.md.BOHeqk2M.js → storage.md.BUrhJ-Zz.js} +4 -4
  99. package/dist/docs/assets/{storage.md.BOHeqk2M.lean.js → storage.md.BUrhJ-Zz.lean.js} +1 -1
  100. package/dist/docs/assets/troubleshooting.md.CYEAO9bM.js +1 -0
  101. package/dist/docs/building-with-agents.html +5 -5
  102. package/dist/docs/building-with-agents.md +3 -2
  103. package/dist/docs/concepts.html +5 -5
  104. package/dist/docs/concepts.md +2 -4
  105. package/dist/docs/deployment.html +7 -7
  106. package/dist/docs/deployment.md +7 -2
  107. package/dist/docs/evals.html +161 -35
  108. package/dist/docs/evals.md +612 -296
  109. package/dist/docs/guides/agent-to-agent.html +4 -4
  110. package/dist/docs/guides/bitbucket.html +36 -0
  111. package/dist/docs/guides/bitbucket.md +84 -0
  112. package/dist/docs/guides/cloud-agents.html +6 -6
  113. package/dist/docs/guides/cloud-agents.md +4 -3
  114. package/dist/docs/guides/convert-automation.html +4 -4
  115. package/dist/docs/guides/github.html +17 -7
  116. package/dist/docs/guides/github.md +33 -1
  117. package/dist/docs/guides/gitlab.html +40 -0
  118. package/dist/docs/guides/gitlab.md +92 -0
  119. package/dist/docs/guides/grokbot-agents.html +6 -6
  120. package/dist/docs/guides/grokbot-agents.md +2 -2
  121. package/dist/docs/guides/human-in-the-loop.html +4 -4
  122. package/dist/docs/guides/improve.html +40 -0
  123. package/dist/docs/guides/improve.md +91 -0
  124. package/dist/docs/guides/mcp-oauth.html +4 -4
  125. package/dist/docs/guides/opentelemetry.html +5 -5
  126. package/dist/docs/guides/slack.html +7 -7
  127. package/dist/docs/guides/slack.md +2 -1
  128. package/dist/docs/guides/webhooks.html +6 -6
  129. package/dist/docs/guides/webhooks.md +4 -2
  130. package/dist/docs/hashmap.json +1 -1
  131. package/dist/docs/hillclimbing.html +6 -6
  132. package/dist/docs/hillclimbing.md +2 -2
  133. package/dist/docs/index.html +6 -6
  134. package/dist/docs/index.md +14 -6
  135. package/dist/docs/llms-full.txt +1274 -814
  136. package/dist/docs/llms.txt +7 -5
  137. package/dist/docs/quickstart.html +4 -4
  138. package/dist/docs/reference/agent-config.html +6 -6
  139. package/dist/docs/reference/agent-config.md +5 -2
  140. package/dist/docs/reference/artifacts.html +4 -4
  141. package/dist/docs/reference/channels.html +6 -6
  142. package/dist/docs/reference/channels.md +16 -3
  143. package/dist/docs/reference/cli.html +11 -11
  144. package/dist/docs/reference/cli.md +24 -15
  145. package/dist/docs/reference/connections.html +6 -6
  146. package/dist/docs/reference/connections.md +2 -1
  147. package/dist/docs/reference/extensions.html +8 -8
  148. package/dist/docs/reference/extensions.md +2 -3
  149. package/dist/docs/reference/hooks.html +7 -7
  150. package/dist/docs/reference/hooks.md +9 -12
  151. package/dist/docs/reference/http-api.html +6 -6
  152. package/dist/docs/reference/http-api.md +2 -3
  153. package/dist/docs/reference/instructions.html +4 -4
  154. package/dist/docs/reference/playground.html +5 -5
  155. package/dist/docs/reference/playground.md +0 -4
  156. package/dist/docs/reference/project-layout.html +7 -7
  157. package/dist/docs/reference/project-layout.md +1 -8
  158. package/dist/docs/reference/prompt.html +4 -4
  159. package/dist/docs/reference/result.html +4 -4
  160. package/dist/docs/reference/schedules.html +4 -4
  161. package/dist/docs/reference/sessions.html +5 -5
  162. package/dist/docs/reference/sessions.md +1 -2
  163. package/dist/docs/reference/skills.html +4 -4
  164. package/dist/docs/reference/subagents.html +4 -4
  165. package/dist/docs/reference/tools.html +4 -4
  166. package/dist/docs/scaffolding-agents.html +5 -5
  167. package/dist/docs/scaffolding-agents.md +2 -1
  168. package/dist/docs/skills/create-agent.html +6 -6
  169. package/dist/docs/skills/create-agent.md +1 -1
  170. package/dist/docs/skills/debug.html +5 -5
  171. package/dist/docs/skills/debug.md +1 -1
  172. package/dist/docs/skills/deploy.html +61 -0
  173. package/dist/docs/skills/deploy.md +161 -0
  174. package/dist/docs/skills/evals.html +8 -8
  175. package/dist/docs/skills/evals.md +44 -6
  176. package/dist/docs/skills/framework-map.html +5 -5
  177. package/dist/docs/skills/framework-map.md +5 -4
  178. package/dist/docs/skills/github.html +6 -6
  179. package/dist/docs/skills/github.md +1 -1
  180. package/dist/docs/skills/hillclimb.html +4 -4
  181. package/dist/docs/skills/index.html +6 -6
  182. package/dist/docs/skills/index.md +1 -1
  183. package/dist/docs/skills/mcp-auth.html +4 -4
  184. package/dist/docs/skills/otel.html +4 -4
  185. package/dist/docs/skills/setup-slack.html +4 -4
  186. package/dist/docs/storage.html +8 -8
  187. package/dist/docs/storage.md +15 -24
  188. package/dist/docs/templates/agentic-owners.html +4 -4
  189. package/dist/docs/templates/agents-md.html +4 -4
  190. package/dist/docs/templates/code-wiki.html +4 -4
  191. package/dist/docs/templates/demo.html +4 -4
  192. package/dist/docs/templates/grokbot-agents.html +4 -4
  193. package/dist/docs/templates/pr-autofixer.html +4 -4
  194. package/dist/docs/templates/security-help.html +4 -4
  195. package/dist/docs/templates/security-reviewer.html +4 -4
  196. package/dist/docs/templates/triage.html +4 -4
  197. package/dist/docs/troubleshooting.html +5 -5
  198. package/dist/docs/troubleshooting.md +1 -1
  199. package/dist/extensions/improve/extension.d.ts +46 -0
  200. package/dist/extensions/improve/extension.d.ts.map +1 -0
  201. package/dist/extensions/improve/extension.js +41 -0
  202. package/dist/extensions/improve/skills/yourself.d.ts +4 -0
  203. package/dist/extensions/improve/skills/yourself.d.ts.map +1 -0
  204. package/dist/extensions/improve/skills/yourself.js +43 -0
  205. package/dist/extensions.d.ts +2 -3
  206. package/dist/extensions.d.ts.map +1 -1
  207. package/dist/extensions.js +2 -5
  208. package/dist/index.d.ts +2 -3
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +1 -2
  211. package/dist/internal/authored-alias-hooks.d.ts +5 -0
  212. package/dist/internal/authored-alias-hooks.d.ts.map +1 -1
  213. package/dist/internal/authored-alias-hooks.js +17 -0
  214. package/dist/internal/authored-loaders.d.ts +4 -0
  215. package/dist/internal/authored-loaders.d.ts.map +1 -1
  216. package/dist/internal/authored-loaders.js +21 -2
  217. package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -1
  218. package/dist/internal/builtin-tools/artifacts.js +2 -3
  219. package/dist/internal/channel-route-dispatch.d.ts +13 -0
  220. package/dist/internal/channel-route-dispatch.d.ts.map +1 -0
  221. package/dist/internal/channel-route-dispatch.js +62 -0
  222. package/dist/internal/channel-state.d.ts +17 -0
  223. package/dist/internal/channel-state.d.ts.map +1 -0
  224. package/dist/internal/channel-state.js +78 -0
  225. package/dist/internal/cli-ax.d.ts +8 -2
  226. package/dist/internal/cli-ax.d.ts.map +1 -1
  227. package/dist/internal/cli-ax.js +100 -3
  228. package/dist/internal/cli-cursor.d.ts.map +1 -1
  229. package/dist/internal/cli-cursor.js +2 -0
  230. package/dist/internal/cli-deploy.d.ts.map +1 -1
  231. package/dist/internal/cli-deploy.js +38 -14
  232. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  233. package/dist/internal/cli-mcp-oauth.js +15 -0
  234. package/dist/internal/cli-mcp.d.ts.map +1 -1
  235. package/dist/internal/cli-mcp.js +12 -0
  236. package/dist/internal/cli-slack.d.ts.map +1 -1
  237. package/dist/internal/cli-slack.js +8 -2
  238. package/dist/internal/continuation-channel.d.ts.map +1 -1
  239. package/dist/internal/continuation-channel.js +2 -2
  240. package/dist/internal/continuation-identity.js +8 -3
  241. package/dist/internal/cursor/credentials.d.ts +8 -2
  242. package/dist/internal/cursor/credentials.d.ts.map +1 -1
  243. package/dist/internal/cursor/credentials.js +27 -5
  244. package/dist/internal/deploy-client.d.ts +27 -0
  245. package/dist/internal/deploy-client.d.ts.map +1 -1
  246. package/dist/internal/deploy-client.js +32 -0
  247. package/dist/internal/deploy-manifest.d.ts +23 -0
  248. package/dist/internal/deploy-manifest.d.ts.map +1 -1
  249. package/dist/internal/deploy-manifest.js +84 -1
  250. package/dist/internal/describe-error.d.ts +1 -0
  251. package/dist/internal/describe-error.d.ts.map +1 -1
  252. package/dist/internal/describe-error.js +25 -0
  253. package/dist/internal/discovery/agent.d.ts +1 -1
  254. package/dist/internal/discovery/agent.d.ts.map +1 -1
  255. package/dist/internal/discovery/agent.js +0 -5
  256. package/dist/internal/discovery/extension-overlay.d.ts +1 -2
  257. package/dist/internal/discovery/extension-overlay.d.ts.map +1 -1
  258. package/dist/internal/discovery/extension-overlay.js +0 -14
  259. package/dist/internal/discovery/extensions.d.ts +1 -2
  260. package/dist/internal/discovery/extensions.d.ts.map +1 -1
  261. package/dist/internal/discovery/extensions.js +4 -22
  262. package/dist/internal/discovery/info.d.ts.map +1 -1
  263. package/dist/internal/discovery/info.js +42 -24
  264. package/dist/internal/discovery/modules.js +0 -1
  265. package/dist/internal/discovery/project.d.ts.map +1 -1
  266. package/dist/internal/discovery/project.js +0 -16
  267. package/dist/internal/eval-runner.js +0 -1
  268. package/dist/internal/framework-file-storage.d.ts +4 -5
  269. package/dist/internal/framework-file-storage.d.ts.map +1 -1
  270. package/dist/internal/framework-file-storage.js +4 -5
  271. package/dist/internal/framework-storage-selection.d.ts +2 -2
  272. package/dist/internal/framework-storage-selection.js +2 -2
  273. package/dist/internal/guest-network.d.ts +4 -10
  274. package/dist/internal/guest-network.d.ts.map +1 -1
  275. package/dist/internal/guest-network.js +42 -26
  276. package/dist/internal/hosted-admission-adapter.d.ts +2 -0
  277. package/dist/internal/hosted-admission-adapter.d.ts.map +1 -1
  278. package/dist/internal/hosted-catch-protocol.d.ts +51 -0
  279. package/dist/internal/hosted-catch-protocol.d.ts.map +1 -0
  280. package/dist/internal/hosted-catch-protocol.js +103 -0
  281. package/dist/internal/hosted-catch.d.ts +40 -0
  282. package/dist/internal/hosted-catch.d.ts.map +1 -0
  283. package/dist/internal/hosted-catch.js +149 -0
  284. package/dist/internal/hosted-delivery-protocol.d.ts +41 -0
  285. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  286. package/dist/internal/hosted-delivery-protocol.js +249 -0
  287. package/dist/internal/hosted-delivery.d.ts +10 -1
  288. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  289. package/dist/internal/hosted-delivery.js +100 -22
  290. package/dist/internal/hosted-execution-diag.d.ts +4 -1
  291. package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
  292. package/dist/internal/hosted-execution-diag.js +13 -4
  293. package/dist/internal/hosted-execution-flush.d.ts +3 -0
  294. package/dist/internal/hosted-execution-flush.d.ts.map +1 -1
  295. package/dist/internal/hosted-execution-flush.js +2 -4
  296. package/dist/internal/http-control-plane-session.d.ts +30 -0
  297. package/dist/internal/http-control-plane-session.d.ts.map +1 -0
  298. package/dist/internal/http-control-plane-session.js +83 -0
  299. package/dist/internal/init-scaffold.d.ts.map +1 -1
  300. package/dist/internal/init-scaffold.js +1 -2
  301. package/dist/internal/install-cursor-skills.d.ts +5 -2
  302. package/dist/internal/install-cursor-skills.d.ts.map +1 -1
  303. package/dist/internal/install-cursor-skills.js +25 -5
  304. package/dist/internal/legacy-command-guard.d.ts +22 -0
  305. package/dist/internal/legacy-command-guard.d.ts.map +1 -0
  306. package/dist/internal/legacy-command-guard.js +51 -0
  307. package/dist/internal/platform-timers.d.ts +7 -0
  308. package/dist/internal/platform-timers.d.ts.map +1 -1
  309. package/dist/internal/platform-timers.js +139 -0
  310. package/dist/internal/reminder-control-plane-protocol.d.ts +2 -0
  311. package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -1
  312. package/dist/internal/reminder-control-plane-protocol.js +9 -2
  313. package/dist/internal/reminder-runner.d.ts +8 -0
  314. package/dist/internal/reminder-runner.d.ts.map +1 -1
  315. package/dist/internal/reminder-runner.js +36 -9
  316. package/dist/internal/resolve-prod-target.d.ts +2 -0
  317. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  318. package/dist/internal/resolve-prod-target.js +13 -0
  319. package/dist/internal/run-client.d.ts +1 -1
  320. package/dist/internal/sdk-runner.d.ts.map +1 -1
  321. package/dist/internal/sdk-runner.js +5 -4
  322. package/dist/internal/server.d.ts.map +1 -1
  323. package/dist/internal/server.js +57 -70
  324. package/dist/internal/session-engine.d.ts +7 -41
  325. package/dist/internal/session-engine.d.ts.map +1 -1
  326. package/dist/internal/session-engine.js +110 -227
  327. package/dist/internal/storage-coordinator.d.ts +5 -19
  328. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  329. package/dist/internal/storage-coordinator.js +3 -62
  330. package/dist/internal/storage-roles.d.ts +4 -9
  331. package/dist/internal/storage-roles.d.ts.map +1 -1
  332. package/dist/internal/storage-roles.js +2 -2
  333. package/dist/playground/assets/index-Bhxzrcf6.css +1 -0
  334. package/dist/playground/assets/index-CqLX5uF3.js +67 -0
  335. package/dist/playground/index.html +2 -2
  336. package/dist/storage-backends/cursor-hosted-v2.d.ts +4 -5
  337. package/dist/storage-backends/cursor-hosted-v2.d.ts.map +1 -1
  338. package/dist/storage-backends/cursor-hosted-v2.js +4 -5
  339. package/dist/storage-backends/cursor-hosted.d.ts +7 -2
  340. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
  341. package/dist/storage-backends/cursor-hosted.js +29 -31
  342. package/dist/storage-backends/file-kv.d.ts +9 -12
  343. package/dist/storage-backends/file-kv.d.ts.map +1 -1
  344. package/dist/storage-backends/file-kv.js +11 -47
  345. package/dist/storage-protocol.d.ts +3 -11
  346. package/dist/storage-protocol.d.ts.map +1 -1
  347. package/dist/storage-protocol.js +3 -11
  348. package/dist/storage.d.ts +8 -36
  349. package/dist/storage.d.ts.map +1 -1
  350. package/dist/storage.js +8 -44
  351. package/dist/types.d.ts +53 -62
  352. package/dist/types.d.ts.map +1 -1
  353. package/docs/README.md +14 -6
  354. package/docs/building-with-agents.md +3 -2
  355. package/docs/concepts.md +2 -4
  356. package/docs/deployment.md +7 -2
  357. package/docs/evals.md +613 -297
  358. package/docs/guides/bitbucket.md +89 -0
  359. package/docs/guides/cloud-agents.md +4 -3
  360. package/docs/guides/github.md +33 -1
  361. package/docs/guides/gitlab.md +97 -0
  362. package/docs/guides/grokbot-agents.md +2 -2
  363. package/docs/guides/improve.md +96 -0
  364. package/docs/guides/slack.md +2 -1
  365. package/docs/guides/webhooks.md +4 -2
  366. package/docs/hillclimbing.md +2 -2
  367. package/docs/reference/agent-config.md +5 -2
  368. package/docs/reference/channels.md +16 -3
  369. package/docs/reference/cli.md +24 -15
  370. package/docs/reference/connections.md +2 -1
  371. package/docs/reference/extensions.md +2 -3
  372. package/docs/reference/hooks.md +9 -12
  373. package/docs/reference/http-api.md +2 -3
  374. package/docs/reference/playground.md +0 -4
  375. package/docs/reference/project-layout.md +1 -8
  376. package/docs/reference/sessions.md +1 -2
  377. package/docs/scaffolding-agents.md +2 -1
  378. package/docs/skills/index.md +2 -2
  379. package/docs/storage.md +15 -24
  380. package/docs/troubleshooting.md +1 -1
  381. package/package.json +8 -7
  382. package/skills/create-agent/SKILL.md +1 -1
  383. package/skills/debug/SKILL.md +1 -1
  384. package/skills/deploy/SKILL.md +169 -0
  385. package/skills/evals/SKILL.md +45 -8
  386. package/skills/framework-map/SKILL.md +5 -4
  387. package/skills/github/SKILL.md +1 -1
  388. package/src/bin/agent-serve.ts +27 -2
  389. package/src/channels/bitbucket/api.ts +341 -0
  390. package/src/channels/bitbucket/binding.ts +25 -0
  391. package/src/channels/bitbucket/index.ts +2 -0
  392. package/src/channels/github/github-channel.ts +8 -8
  393. package/src/channels/github/types.ts +5 -0
  394. package/src/channels/gitlab/api.ts +123 -0
  395. package/src/channels/gitlab/binding.ts +12 -0
  396. package/src/channels/gitlab/index.ts +1 -0
  397. package/src/channels/origin/origin-channel.ts +29 -13
  398. package/src/channels/origin/types.ts +5 -0
  399. package/src/channels/slack/dispatch.ts +30 -0
  400. package/src/channels/slack/slack-channel.ts +69 -7
  401. package/src/channels.ts +157 -10
  402. package/src/connections.ts +2 -1
  403. package/src/extensions/improve/extension.ts +70 -0
  404. package/src/extensions/improve/skills/yourself.ts +50 -0
  405. package/src/extensions.ts +2 -6
  406. package/src/index.ts +0 -3
  407. package/src/internal/authored-alias-hooks.ts +32 -0
  408. package/src/internal/authored-loaders.ts +26 -2
  409. package/src/internal/builtin-tools/artifacts.ts +2 -3
  410. package/src/internal/channel-route-dispatch.ts +66 -0
  411. package/src/internal/channel-state.ts +96 -0
  412. package/src/internal/cli-ax.ts +111 -3
  413. package/src/internal/cli-cursor.ts +4 -1
  414. package/src/internal/cli-deploy.ts +50 -10
  415. package/src/internal/cli-mcp-oauth.ts +18 -0
  416. package/src/internal/cli-mcp.ts +11 -0
  417. package/src/internal/cli-slack.ts +15 -2
  418. package/src/internal/continuation-channel.ts +2 -1
  419. package/src/internal/continuation-identity.ts +10 -2
  420. package/src/internal/cursor/credentials.ts +35 -7
  421. package/src/internal/deploy-client.ts +54 -0
  422. package/src/internal/deploy-manifest.ts +115 -1
  423. package/src/internal/describe-error.ts +28 -0
  424. package/src/internal/discovery/agent.ts +1 -7
  425. package/src/internal/discovery/extension-overlay.ts +0 -18
  426. package/src/internal/discovery/extensions.ts +2 -26
  427. package/src/internal/discovery/info.ts +3 -13
  428. package/src/internal/discovery/modules.ts +0 -1
  429. package/src/internal/discovery/project.ts +0 -16
  430. package/src/internal/eval-runner.ts +0 -1
  431. package/src/internal/framework-file-storage.ts +4 -5
  432. package/src/internal/framework-storage-selection.ts +2 -2
  433. package/src/internal/guest-network.ts +43 -29
  434. package/src/internal/hosted-admission-adapter.ts +2 -0
  435. package/src/internal/hosted-catch-protocol.ts +130 -0
  436. package/src/internal/hosted-catch.ts +192 -0
  437. package/src/internal/hosted-delivery-protocol.ts +387 -0
  438. package/src/internal/hosted-delivery.ts +155 -22
  439. package/src/internal/hosted-execution-diag.ts +21 -3
  440. package/src/internal/hosted-execution-flush.ts +6 -3
  441. package/src/internal/http-control-plane-session.ts +104 -0
  442. package/src/internal/init-scaffold.ts +1 -2
  443. package/src/internal/install-cursor-skills.ts +38 -5
  444. package/src/internal/legacy-command-guard.ts +59 -0
  445. package/src/internal/platform-timers.ts +191 -0
  446. package/src/internal/reminder-control-plane-protocol.ts +15 -2
  447. package/src/internal/reminder-runner.ts +60 -9
  448. package/src/internal/resolve-prod-target.ts +15 -0
  449. package/src/internal/run-client.ts +1 -1
  450. package/src/internal/sdk-runner.ts +3 -2
  451. package/src/internal/server.ts +89 -95
  452. package/src/internal/session-engine.ts +155 -285
  453. package/src/internal/storage-coordinator.ts +5 -76
  454. package/src/internal/storage-roles.ts +4 -9
  455. package/src/storage-backends/cursor-hosted-v2.ts +4 -7
  456. package/src/storage-backends/cursor-hosted.ts +40 -38
  457. package/src/storage-backends/file-kv.ts +10 -51
  458. package/src/storage-protocol.ts +3 -17
  459. package/src/storage.ts +10 -101
  460. package/src/types.ts +58 -62
  461. package/templates/demo/README.md +10 -6
  462. package/templates/demo/agent/channels/github.ts +2 -0
  463. package/templates/demo/agent/channels/queue.ts +6 -2
  464. package/templates/demo/agent/lib/repos.ts +5 -0
  465. package/templates/demo/init.json +25 -0
  466. package/dist/ab.d.ts +0 -209
  467. package/dist/ab.d.ts.map +0 -1
  468. package/dist/ab.js +0 -246
  469. package/dist/docs/ab.html +0 -80
  470. package/dist/docs/ab.md +0 -332
  471. package/dist/docs/assets/ab.md.mlVgqvSk.js +0 -54
  472. package/dist/docs/assets/ab.md.mlVgqvSk.lean.js +0 -1
  473. package/dist/docs/assets/chunks/@localSearchIndexroot.DXXZxiMv.js +0 -1
  474. package/dist/docs/assets/concepts.md.DgEcZOfT.js +0 -1
  475. package/dist/docs/assets/evals.md.CbMoebP1.js +0 -85
  476. package/dist/docs/assets/evals.md.CbMoebP1.lean.js +0 -1
  477. package/dist/docs/assets/guides_cloud-agents.md.DS8RIjwx.js +0 -9
  478. package/dist/docs/assets/index.md.BW_6tOgR.js +0 -5
  479. package/dist/docs/assets/reference_sessions.md.CueyOHSL.js +0 -1
  480. package/dist/docs/assets/skills_ab.md.CsFNatVx.js +0 -26
  481. package/dist/docs/assets/skills_ab.md.CsFNatVx.lean.js +0 -1
  482. package/dist/docs/assets/skills_evals.md.723kpUmA.js +0 -25
  483. package/dist/docs/assets/skills_evals.md.723kpUmA.lean.js +0 -1
  484. package/dist/docs/assets/skills_framework-map.md.haibFyoB.js +0 -1
  485. package/dist/docs/assets/skills_index.md.DKwIxzGg.js +0 -1
  486. package/dist/docs/assets/skills_index.md.DKwIxzGg.lean.js +0 -1
  487. package/dist/docs/assets/troubleshooting.md.Cus_YZga.js +0 -1
  488. package/dist/docs/skills/ab.html +0 -52
  489. package/dist/docs/skills/ab.md +0 -50
  490. package/dist/internal/ab-collector.d.ts +0 -44
  491. package/dist/internal/ab-collector.d.ts.map +0 -1
  492. package/dist/internal/ab-collector.js +0 -142
  493. package/dist/internal/ab-fold.d.ts +0 -36
  494. package/dist/internal/ab-fold.d.ts.map +0 -1
  495. package/dist/internal/ab-fold.js +0 -175
  496. package/dist/internal/ab-snapshot.d.ts +0 -68
  497. package/dist/internal/ab-snapshot.d.ts.map +0 -1
  498. package/dist/internal/ab-snapshot.js +0 -208
  499. package/dist/internal/discovery/ab.d.ts +0 -9
  500. package/dist/internal/discovery/ab.d.ts.map +0 -1
  501. package/dist/internal/discovery/ab.js +0 -113
  502. package/dist/playground/assets/index-Bq2HpEQB.js +0 -67
  503. package/dist/playground/assets/index-CZKKNlmb.css +0 -1
  504. package/docs/ab.md +0 -337
  505. package/skills/ab/SKILL.md +0 -58
  506. package/src/ab.ts +0 -430
  507. package/src/internal/ab-collector.ts +0 -200
  508. package/src/internal/ab-fold.ts +0 -232
  509. package/src/internal/ab-snapshot.ts +0 -331
  510. package/src/internal/discovery/ab.ts +0 -131
  511. /package/dist/docs/assets/{concepts.md.DgEcZOfT.lean.js → concepts.md.B4o63Gul.lean.js} +0 -0
  512. /package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.lean.js → guides_grokbot-agents.md.DyV-WArv.lean.js} +0 -0
  513. /package/dist/docs/assets/{guides_webhooks.md.DKdA43Qm.lean.js → guides_webhooks.md.CJK484ex.lean.js} +0 -0
  514. /package/dist/docs/assets/{hillclimbing.md.CpTGTCle.lean.js → hillclimbing.md.BOiVo1tf.lean.js} +0 -0
  515. /package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.lean.js → reference_agent-config.md.CvoL6pof.lean.js} +0 -0
  516. /package/dist/docs/assets/{reference_connections.md.Di6jJAXF.lean.js → reference_connections.md.BojkC6c5.lean.js} +0 -0
  517. /package/dist/docs/assets/{reference_extensions.md.CGmMLblt.lean.js → reference_extensions.md.ZAVUyuEX.lean.js} +0 -0
  518. /package/dist/docs/assets/{reference_http-api.md.oySXBO8o.lean.js → reference_http-api.md.BwaCo-VO.lean.js} +0 -0
  519. /package/dist/docs/assets/{reference_sessions.md.CueyOHSL.lean.js → reference_sessions.md.CyXV1MUw.lean.js} +0 -0
  520. /package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.lean.js → scaffolding-agents.md.Kctn3OVb.lean.js} +0 -0
  521. /package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.lean.js → skills_create-agent.md.Q3h6Je-e.lean.js} +0 -0
  522. /package/dist/docs/assets/{skills_github.md.D0JahM8c.lean.js → skills_github.md.hgFX_oKY.lean.js} +0 -0
  523. /package/dist/docs/assets/{troubleshooting.md.Cus_YZga.lean.js → troubleshooting.md.CYEAO9bM.lean.js} +0 -0
@@ -18,7 +18,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
18
  import { AsyncLocalStorage } from "node:async_hooks";
19
19
  import { mkdir, rm, writeFile } from "node:fs/promises";
20
20
  import { dirname, join } from "node:path";
21
- import { mergeABInstructions, resolveABMaxPlaygroundSessions, resolveABSplit, } from "../ab.js";
22
21
  import { SLACK_CHANNEL_ID } from "../channels/slack/constants.js";
23
22
  import { materializeSlackNudgeCarrier } from "../channels/slack/nudge-carrier.js";
24
23
  import { SlackAskDedupeStore, SlackNudgeStore, } from "../channels/slack/nudge-store.js";
@@ -28,19 +27,17 @@ import { cursorHostedFiles, isCursorHostedFilesAvailable, isCursorUserStoreFiles
28
27
  import { isFileSystemToolAlias, isMutatingFileSystemTool, localFileSystem, resolveFileSystemTools, resolveHostHarnessToolOptions, tempFs, unionFs, writeWorkspaceFilesToRoot, } from "../filesystem.js";
29
28
  import { storageKeysForArchitecture } from "../storage.js";
30
29
  import { DEFAULT_MODEL, DIRECT_TOOL_CALL_CHANNEL_ID, isCursorAccountTransport, isHostOauthConnectionTransport, isSymbolicConnectionTransport, } from "../types.js";
31
- import { ABCollector } from "./ab-collector.js";
32
- import { foldABStream } from "./ab-fold.js";
33
- import { buildABSnapshot } from "./ab-snapshot.js";
34
30
  import { resolveAdvertisedTools, } from "./advertise-tools.js";
35
31
  import { ApprovalGate } from "./approval-gate.js";
36
32
  import { ArtifactsStore } from "./artifacts-store.js";
37
33
  import { assertTimeArgs, normalizeAsOf, schemaTimeWindowKeys, sessionClock, } from "./as-of.js";
38
34
  import { SessionAuthError, samePrincipal } from "./auth.js";
35
+ import { mergeChannelStateMutation, mergeChannelStateSkipNull, } from "./channel-state.js";
39
36
  import { mergeCloudOptions, resolveSessionRuntime } from "./cloud-merge.js";
40
37
  import { applyCloudUsageToEvents, cloudSdkAgentIdFromEvents, isUnpricedCompletedTurn, mapSdkTokenUsage, } from "./cloud-turn-cost.js";
41
38
  import { applyAgentContinuationDefaults, channelContinuationIdentity, httpContinuationIdentity, } from "./continuation-channel.js";
42
39
  import { continuationSource, resolveV2Key, V2EngineError, } from "./continuation-identity.js";
43
- import { describeError } from "./describe-error.js";
40
+ import { describeError, describeErrorCode } from "./describe-error.js";
44
41
  import { isDevMode } from "./dev-mode.js";
45
42
  import { EventLogStore } from "./event-log.js";
46
43
  import { TurnEventMapper } from "./event-mapper.js";
@@ -52,6 +49,7 @@ import { createHostKvApi } from "./host-kv.js";
52
49
  import { createHostOtelApi } from "./host-otel.js";
53
50
  import { createHostPlatforms, createHostSlackClient, } from "./host-platforms.js";
54
51
  import { HostedAdmissionLocalSendError, isDuringHostedAdmission, } from "./hosted-admission-context.js";
52
+ import { hostedSessionResumeKey } from "./hosted-catch-protocol.js";
55
53
  import { formatContinuationToken, newContinuationKey, newSessionId, newToolCallId, parseContinuationToken, } from "./ids.js";
56
54
  import { validateToolInput } from "./json-schema.js";
57
55
  import { isMcpNeedsAuthError, McpHost } from "./mcp-host.js";
@@ -75,6 +73,7 @@ import { resolveAgentV2Hosting } from "./v2-hosting.js";
75
73
  import { buildAgentsMdContent, buildCloudMemorySection, buildCloudSessionWorkspaceSection, buildCloudWorkspaceSection, ensureOwnGitRoot, isNestedInGitRepo, materializeWorkspace, SERVER_TOOLS_MCP_SERVER_NAME, } from "./workspace.js";
76
74
  import { syncSessionWorkspaceFiles, syncWorkspaceToStore, WorkspaceFileRefusal, wipeSessionWorkspace, } from "./workspace-sync.js";
77
75
  export const HTTP_CHANNEL_ID = "http";
76
+ export { mergeChannelStateSkipNull } from "./channel-state.js";
78
77
  export { SCHEDULE_CHANNEL_PREFIX } from "./prompt-context.js";
79
78
  export class SessionBusyError extends Error {
80
79
  constructor(sessionId) {
@@ -284,9 +283,6 @@ export class SessionEngine {
284
283
  config: options.project.artifacts,
285
284
  sink: managedV2Files === null || managedV2Files === void 0 ? void 0 : managedV2Files(),
286
285
  });
287
- this.abCollector = new ABCollector(options.project.abs, this.logger, (sessionId) => __awaiter(this, void 0, void 0, function* () { return (yield this.logs.get(sessionId)).snapshot(0); }),
288
- // Samples flow to the defineStorage `abs` table (no-op without one).
289
- { persistSample: (sample) => { var _a; return (_a = this.storage) === null || _a === void 0 ? void 0 : _a.abSample(sample); } });
290
286
  // Peer and Cursor-account transports are symbolic until the serve host
291
287
  // resolves them; the host-side MCP registry starts with the concrete
292
288
  // connections and gains the rest via setResolvedConnections.
@@ -570,8 +566,8 @@ export class SessionEngine {
570
566
  */
571
567
  send(channelId_1, message_1) {
572
568
  return __awaiter(this, arguments, void 0, function* (channelId, message, options = {}) {
573
- var _a;
574
- var _b, _c, _d, _e, _f, _g;
569
+ var _a, _b;
570
+ var _c, _d, _e, _f, _g, _h;
575
571
  if (isDuringHostedAdmission()) {
576
572
  // Only sends that bypassed the admission capture stub (typically a
577
573
  // startup-captured `onStart` send) reach the engine inside the
@@ -592,7 +588,7 @@ export class SessionEngine {
592
588
  sendOptions = Object.assign(Object.assign({}, options), { continuationToken: cKey });
593
589
  skipContinuationLookup = cKey.startsWith("evt:");
594
590
  }
595
- const auth = (_b = sendOptions.auth) !== null && _b !== void 0 ? _b : null;
591
+ const auth = (_c = sendOptions.auth) !== null && _c !== void 0 ? _c : null;
596
592
  let existing = skipContinuationLookup || sendOptions.continuationToken === undefined
597
593
  ? undefined
598
594
  : yield this.sessions.findByContinuation(channelId, sendOptions.continuationToken);
@@ -603,6 +599,16 @@ export class SessionEngine {
603
599
  // fell outside the startup restore window, or restore is lazy-only).
604
600
  existing = yield this.restoreSessionByContinuation(channelId, sendOptions.continuationToken);
605
601
  }
602
+ if (existing === undefined &&
603
+ sendOptions.hostedSessionId !== undefined &&
604
+ ((_a = sendOptions.mailboxContinuation) === null || _a === void 0 ? void 0 : _a.key) ===
605
+ hostedSessionResumeKey(sendOptions.hostedSessionId)) {
606
+ // Explicit control-plane resume of an existing session: the CP named
607
+ // the session by its own id and stamped the matching resume key. The
608
+ // session keeps its original continuation key (a PR lane must stay
609
+ // addressable by its webhooks); this is a follow-up turn by id.
610
+ existing = yield this.getOrRestoreSession(sendOptions.hostedSessionId);
611
+ }
606
612
  if (existing !== undefined) {
607
613
  if (sendOptions.hostedSessionId !== undefined &&
608
614
  existing.sessionId !== sendOptions.hostedSessionId) {
@@ -638,7 +644,7 @@ export class SessionEngine {
638
644
  record = yield this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateSkipNull(current.channelState, sendOptions.refreshState) })));
639
645
  }
640
646
  const since = (yield this.logs.get(record.sessionId)).count;
641
- const coalesced = yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_c = sendOptions.admission) !== null && _c !== void 0 ? _c : "preempt" }, (sendOptions.coalesceSourceTs === undefined
647
+ const coalesced = yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_d = sendOptions.admission) !== null && _d !== void 0 ? _d : "preempt" }, (sendOptions.coalesceSourceTs === undefined
642
648
  ? {}
643
649
  : { sourceTs: sendOptions.coalesceSourceTs })));
644
650
  return this.channelSession(record.sessionId, record, false, coalesced, since);
@@ -654,14 +660,14 @@ export class SessionEngine {
654
660
  const purpose = sendOptions.purpose === "eval" ? "eval" : "live";
655
661
  const frozenAsOf = normalizeAsOf(sendOptions.asOf);
656
662
  assertTimeArgs(this.project.agent.tools, frozenAsOf);
657
- let record = {
658
- sessionId: (_d = sendOptions.hostedSessionId) !== null && _d !== void 0 ? _d : newSessionId(),
663
+ const record = {
664
+ sessionId: (_e = sendOptions.hostedSessionId) !== null && _e !== void 0 ? _e : newSessionId(),
659
665
  channelId,
660
- mode: (_e = sendOptions.mode) !== null && _e !== void 0 ? _e : "chat",
666
+ mode: (_f = sendOptions.mode) !== null && _f !== void 0 ? _f : "chat",
661
667
  purpose,
662
668
  dryRun: sendOptions.dryRun === true ? true : undefined,
663
669
  asOf: frozenAsOf,
664
- continuationKey: (_f = sendOptions.continuationToken) !== null && _f !== void 0 ? _f : newContinuationKey(),
670
+ continuationKey: (_g = sendOptions.continuationToken) !== null && _g !== void 0 ? _g : newContinuationKey(),
665
671
  auth,
666
672
  title: sendOptions.title,
667
673
  channelState,
@@ -675,7 +681,7 @@ export class SessionEngine {
675
681
  updatedAt: now,
676
682
  };
677
683
  yield this.sessions.save(record);
678
- (_a = this.storage) === null || _a === void 0 ? void 0 : _a.sessionRecord(record);
684
+ (_b = this.storage) === null || _b === void 0 ? void 0 : _b.sessionRecord(record);
679
685
  yield this.appendEvent(record.sessionId, {
680
686
  type: "session.started",
681
687
  data: {
@@ -683,9 +689,8 @@ export class SessionEngine {
683
689
  dryRun: record.dryRun === true ? true : undefined,
684
690
  },
685
691
  });
686
- record = yield this.enrollABs(record);
687
692
  const since = (yield this.logs.get(record.sessionId)).count;
688
- yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_g = sendOptions.admission) !== null && _g !== void 0 ? _g : "preempt" }, (sendOptions.coalesceSourceTs === undefined
693
+ yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_h = sendOptions.admission) !== null && _h !== void 0 ? _h : "preempt" }, (sendOptions.coalesceSourceTs === undefined
689
694
  ? {}
690
695
  : { sourceTs: sendOptions.coalesceSourceTs })));
691
696
  return this.channelSession(record.sessionId, record, true, false, since);
@@ -741,85 +746,6 @@ export class SessionEngine {
741
746
  return existing !== undefined;
742
747
  });
743
748
  }
744
- /**
745
- * Sticky A/B enrollment at session creation — before the first turn, so
746
- * variants are in the durable stream (and on {@link SessionRecord.abs})
747
- * ahead of model/instructions work. Failures persist as `variant: null`
748
- * (sticky skip). Eval harness sessions (`purpose: "eval"`) are never
749
- * enrolled.
750
- */
751
- enrollABs(record) {
752
- return __awaiter(this, void 0, void 0, function* () {
753
- if (!this.abCollector.enabled || record.purpose === "eval") {
754
- return record;
755
- }
756
- const sessionInfo = this.sessionInfo(record);
757
- const abs = {};
758
- for (const experiment of this.project.abs) {
759
- const def = experiment.definition;
760
- const variantKeys = Object.keys(def.variants);
761
- let variant = null;
762
- try {
763
- variant = yield resolveABSplit(def.split, {
764
- agent: { name: this.project.name },
765
- channel: { id: record.channelId },
766
- session: sessionInfo,
767
- experiment: experiment.name,
768
- variants: variantKeys,
769
- });
770
- if (variant !== null && !(variant in def.variants)) {
771
- throw new Error(`split resolved to ${JSON.stringify(variant)}; expected one of ${variantKeys.join(", ")} or null to skip`);
772
- }
773
- }
774
- catch (error) {
775
- this.logger(`[agent-sdk] ab "${experiment.name}" enrollment failed (sticky skip): ${describeError(error)}`);
776
- variant = null;
777
- }
778
- abs[experiment.name] = variant;
779
- yield this.appendEvent(record.sessionId, {
780
- type: "ab.assigned",
781
- data: { experiment: experiment.name, variant },
782
- });
783
- }
784
- return this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { abs })));
785
- });
786
- }
787
- /**
788
- * Ensure {@link SessionRecord.abs} is populated (hydrate from the durable
789
- * `ab.assigned` stream when missing — e.g. older sessions after upgrade).
790
- */
791
- ensureAbs(record) {
792
- return __awaiter(this, void 0, void 0, function* () {
793
- if (record.abs !== undefined || record.purpose === "eval") {
794
- return record;
795
- }
796
- if (!this.abCollector.enabled) {
797
- return record;
798
- }
799
- const events = yield this.listEvents(record.sessionId, 0);
800
- const folded = foldABStream(events);
801
- if (folded.arms.size === 0) {
802
- return record;
803
- }
804
- const abs = Object.fromEntries(folded.arms);
805
- return this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { abs })));
806
- });
807
- }
808
- /**
809
- * Agent config for this session: base project agent plus any per-variant
810
- * `instructions` overlays from enrolled A/B arms.
811
- */
812
- agentForSession(record) {
813
- const base = this.project.agent;
814
- const instructions = mergeABInstructions(base.instructions, record.abs, this.project.abs.map((experiment) => ({
815
- name: experiment.name,
816
- definition: experiment.definition,
817
- })));
818
- if (instructions === base.instructions) {
819
- return base;
820
- }
821
- return Object.assign(Object.assign({}, base), { instructions });
822
- }
823
749
  /** Look up a session as a channel-scoped handle. */
824
750
  getChannelSession(channelId, sessionId) {
825
751
  return __awaiter(this, void 0, void 0, function* () {
@@ -1094,9 +1020,7 @@ export class SessionEngine {
1094
1020
  this.pendingTurns.add(sessionId);
1095
1021
  let lifecycleInstalled = false;
1096
1022
  try {
1097
- let record = yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { turnCount: current.turnCount + 1 })));
1098
- // Arms must be on the record before tools/instructions see SessionInfo.
1099
- record = yield this.ensureAbs(record);
1023
+ const record = yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { turnCount: current.turnCount + 1 })));
1100
1024
  const turnId = `turn_${record.turnCount}`;
1101
1025
  const isFirstTurn = record.turnCount === 1;
1102
1026
  yield this.appendEvent(sessionId, {
@@ -1118,11 +1042,17 @@ export class SessionEngine {
1118
1042
  poll.unref();
1119
1043
  try {
1120
1044
  outcome = yield this.executeTurn(record, turnId, message, isFirstTurn, abort.signal);
1045
+ if (outcome.status === "cancelled") {
1046
+ outcome.cancellationReason = abort.signal.aborted
1047
+ ? "signal"
1048
+ : "runner";
1049
+ }
1121
1050
  }
1122
1051
  catch (error) {
1123
1052
  outcome = {
1124
1053
  status: "error",
1125
1054
  errorMessage: describeError(error),
1055
+ errorCode: describeErrorCode(error),
1126
1056
  };
1127
1057
  }
1128
1058
  finally {
@@ -1562,10 +1492,15 @@ export class SessionEngine {
1562
1492
  }
1563
1493
  executeTurn(record, turnId, message, isFirstTurn, signal) {
1564
1494
  return __awaiter(this, void 0, void 0, function* () {
1565
- var _a, _b, _c, _d, _e, _f, _g, _h;
1495
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1566
1496
  const sessionId = record.sessionId;
1567
1497
  const workspaceDir = this.scaffoldDir(record);
1568
1498
  const harnessCwd = this.harnessCwd(record);
1499
+ const turnChannelState = structuredClone((_a = record.channelState) !== null && _a !== void 0 ? _a : null);
1500
+ const eventContext = {
1501
+ channelState: structuredClone(turnChannelState),
1502
+ session: this.sessionInfo(record),
1503
+ };
1569
1504
  // Hold the open log so tool events append synchronously. Fire-and-forget
1570
1505
  // `appendEvent` races parallel tool completions and delays the live stream
1571
1506
  // until the next await tick — often after *all* parallel tools finish.
@@ -1573,7 +1508,7 @@ export class SessionEngine {
1573
1508
  const emit = (payload) => {
1574
1509
  try {
1575
1510
  const event = log.append(Object.assign(Object.assign({}, payload), { turnId }));
1576
- this.queueDispatch(sessionId, event);
1511
+ this.queueDispatch(sessionId, event, eventContext);
1577
1512
  }
1578
1513
  catch (error) {
1579
1514
  this.logger(`[agent-sdk] failed to record event for ${sessionId}: ${describeError(error)}`);
@@ -1606,12 +1541,10 @@ export class SessionEngine {
1606
1541
  emit({ type: "turn.started", data: {} });
1607
1542
  try {
1608
1543
  // Scaffold agent files into the session workspace even when the harness
1609
- // cwd is overridden (e.g. a PR worktree). A/B variant instruction
1610
- // overlays are applied via agentForSession.
1611
- const agent = this.agentForSession(record);
1544
+ // cwd is overridden (e.g. a PR worktree).
1612
1545
  if (!this.hasRootOverride()) {
1613
1546
  yield materializeWorkspace({
1614
- agent,
1547
+ agent: this.project.agent,
1615
1548
  workspaceDir,
1616
1549
  seed: isFirstTurn,
1617
1550
  stateRoot: this.stateRoot,
@@ -1633,14 +1566,14 @@ export class SessionEngine {
1633
1566
  const pendingFiles = record.pendingWorkspaceFiles;
1634
1567
  const pendingImages = record.pendingImages;
1635
1568
  const runtime = resolveSessionRuntime({
1636
- agentRuntime: agent.runtime,
1569
+ agentRuntime: this.project.agent.runtime,
1637
1570
  cloudOverride: record.cloudOverride,
1638
1571
  });
1639
1572
  const hasPendingFiles = pendingFiles !== undefined && Object.keys(pendingFiles).length > 0;
1640
1573
  if (hasPendingFiles && runtime !== "cloud") {
1641
1574
  const root = yield this.resolveFileSystem({
1642
1575
  sessionId,
1643
- continuationKey: (_a = record.continuationKey) !== null && _a !== void 0 ? _a : undefined,
1576
+ continuationKey: (_b = record.continuationKey) !== null && _b !== void 0 ? _b : undefined,
1644
1577
  cache: true,
1645
1578
  cwd: harnessCwd,
1646
1579
  });
@@ -1664,7 +1597,7 @@ export class SessionEngine {
1664
1597
  const instructionsInvisibleToHarness = isFirstTurn &&
1665
1598
  (this.hasBorrowedWorkspace(record) ||
1666
1599
  (yield isNestedInGitRepo(harnessCwd)));
1667
- const request = yield this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, (update) => __awaiter(this, void 0, void 0, function* () {
1600
+ const request = yield this.buildTurnRequest(record, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, eventContext, (update) => __awaiter(this, void 0, void 0, function* () {
1668
1601
  const turn = this.turnRoots.get(sessionId);
1669
1602
  if (turn !== undefined) {
1670
1603
  update = yield applyWebScratchUpdate({
@@ -1700,7 +1633,11 @@ export class SessionEngine {
1700
1633
  catch (error) {
1701
1634
  this.approvals.cancelSession(sessionId, "deny");
1702
1635
  this.auths.cancelSession(sessionId, "deny");
1703
- outcome = { status: "error", errorMessage: describeError(error) };
1636
+ outcome = {
1637
+ status: "error",
1638
+ errorMessage: describeError(error),
1639
+ errorCode: describeErrorCode(error),
1640
+ };
1704
1641
  }
1705
1642
  finally {
1706
1643
  permit.release();
@@ -1718,16 +1655,17 @@ export class SessionEngine {
1718
1655
  if (mapper.title !== undefined) {
1719
1656
  const title = mapper.title;
1720
1657
  yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { title })));
1658
+ eventContext.session = Object.assign(Object.assign({}, eventContext.session), { title });
1721
1659
  }
1722
- const finalResult = (_b = outcome.result) !== null && _b !== void 0 ? _b : mapper.finalText;
1723
- const finalUsage = (_c = outcome.usage) !== null && _c !== void 0 ? _c : mapper.usage;
1660
+ const finalResult = (_c = outcome.result) !== null && _c !== void 0 ? _c : mapper.finalText;
1661
+ const finalUsage = (_d = outcome.usage) !== null && _d !== void 0 ? _d : mapper.usage;
1724
1662
  const finalCost = finalUsage === undefined
1725
1663
  ? undefined
1726
1664
  : yield this.estimateTurnCost({
1727
- model: (_d = this.project.agent.model) !== null && _d !== void 0 ? _d : DEFAULT_MODEL,
1665
+ model: (_e = this.project.agent.model) !== null && _e !== void 0 ? _e : DEFAULT_MODEL,
1728
1666
  usage: finalUsage,
1729
1667
  agentId: record.sdkAgentId,
1730
- conversationId: (_e = record.sdkAgentId) !== null && _e !== void 0 ? _e : sessionId,
1668
+ conversationId: (_f = record.sdkAgentId) !== null && _f !== void 0 ? _f : sessionId,
1731
1669
  });
1732
1670
  if (finalCost !== undefined) {
1733
1671
  outcome = Object.assign(Object.assign({}, outcome), { cost: finalCost });
@@ -1739,7 +1677,8 @@ export class SessionEngine {
1739
1677
  text: finalResult,
1740
1678
  dryRun: record.dryRun === true,
1741
1679
  ctx: {
1742
- session: this.sessionInfo(record),
1680
+ session: eventContext.session,
1681
+ channelState: turnChannelState,
1743
1682
  host: this.hostForSession(sessionId),
1744
1683
  artifacts: this.artifactsApi({ sessionId, turnId }),
1745
1684
  stateRoot: this.stateRoot,
@@ -1765,7 +1704,7 @@ export class SessionEngine {
1765
1704
  usage: finalUsage,
1766
1705
  cost: finalCost,
1767
1706
  },
1768
- });
1707
+ }, eventContext);
1769
1708
  }
1770
1709
  else {
1771
1710
  const interrupted = signal.aborted && outcome.status === "cancelled";
@@ -1773,24 +1712,25 @@ export class SessionEngine {
1773
1712
  type: "turn.failed",
1774
1713
  turnId,
1775
1714
  data: {
1715
+ status: outcome.status,
1776
1716
  message: interrupted
1777
1717
  ? "turn interrupted"
1778
- : ((_f = outcome.errorMessage) !== null && _f !== void 0 ? _f : (outcome.status === "cancelled"
1718
+ : ((_g = outcome.errorMessage) !== null && _g !== void 0 ? _g : (outcome.status === "cancelled"
1779
1719
  ? "turn cancelled"
1780
1720
  : "turn failed")),
1781
1721
  },
1782
- });
1722
+ }, eventContext);
1783
1723
  }
1784
1724
  const current = yield this.sessions.get(sessionId);
1785
- const mode = (_g = current === null || current === void 0 ? void 0 : current.mode) !== null && _g !== void 0 ? _g : record.mode;
1725
+ const mode = (_h = current === null || current === void 0 ? void 0 : current.mode) !== null && _h !== void 0 ? _h : record.mode;
1786
1726
  if (mode === "task") {
1787
1727
  yield this.appendEvent(sessionId, outcome.status === "finished"
1788
1728
  ? { type: "session.completed", turnId, data: {} }
1789
1729
  : {
1790
1730
  type: "session.failed",
1791
1731
  turnId,
1792
- data: { message: (_h = outcome.errorMessage) !== null && _h !== void 0 ? _h : "task failed" },
1793
- });
1732
+ data: { message: (_j = outcome.errorMessage) !== null && _j !== void 0 ? _j : "task failed" },
1733
+ }, eventContext);
1794
1734
  yield this.wipeCloudSessionWorkspace(sessionId);
1795
1735
  }
1796
1736
  else {
@@ -1798,7 +1738,7 @@ export class SessionEngine {
1798
1738
  type: "session.waiting",
1799
1739
  turnId,
1800
1740
  data: {},
1801
- });
1741
+ }, eventContext);
1802
1742
  }
1803
1743
  return Object.assign(Object.assign({}, outcome), { result: finalResult, usage: finalUsage });
1804
1744
  });
@@ -1952,10 +1892,11 @@ export class SessionEngine {
1952
1892
  }
1953
1893
  return undefined;
1954
1894
  }
1955
- buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, onUpdate, signal, images) {
1895
+ buildTurnRequest(record, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, eventContext, onUpdate, signal, images) {
1956
1896
  return __awaiter(this, void 0, void 0, function* () {
1957
1897
  var _a, _b, _c;
1958
1898
  var _d;
1899
+ const agent = this.project.agent;
1959
1900
  // Per-session cloud attach (channel/tool handoff) forces cloud runtime
1960
1901
  // even when the agent defaults to local for chat server tools.
1961
1902
  const runtime = resolveSessionRuntime({
@@ -2124,9 +2065,7 @@ export class SessionEngine {
2124
2065
  }
2125
2066
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
2126
2067
  ? {}
2127
- : { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: authoredRoot
2128
- ? false
2129
- : ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true }), (runtime === "local" && harnessTools !== undefined
2068
+ : { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: authoredRoot ? false : ((_c = agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true }), (runtime === "local" && harnessTools !== undefined
2130
2069
  ? Object.assign(Object.assign({}, (harnessTools.tools === undefined
2131
2070
  ? {}
2132
2071
  : { tools: harnessTools.tools })), (harnessTools.disallowedTools === undefined
@@ -2142,7 +2081,7 @@ export class SessionEngine {
2142
2081
  : undefined }), (runtime === "cloud" && !isCursorHostedFilesAvailable()
2143
2082
  ? { agentServeAgent: this.project.name }
2144
2083
  : {})), { customTools: runtime === "local"
2145
- ? yield this.buildCustomTools(record, agent, turnId, emit, synthesized)
2084
+ ? yield this.buildCustomTools(record, turnId, emit, synthesized)
2146
2085
  : {}, mcpServers: this.buildMcpServers(runtime, record.sessionId, yield this.evaluateConnectionAuth(record)) }), (runtime === "local" && this.hasAttachedAuthedConnections()
2147
2086
  ? { perSendMcpServers: true }
2148
2087
  : {})), { subagents: buildRunnerSubagents(agent), onUpdate,
@@ -2157,13 +2096,14 @@ export class SessionEngine {
2157
2096
  }
2158
2097
  yield this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { sdkAgentId })));
2159
2098
  record.sdkAgentId = sdkAgentId;
2099
+ eventContext.session = Object.assign(Object.assign({}, eventContext.session), { sdkAgentId });
2160
2100
  yield this.appendEvent(record.sessionId, {
2161
2101
  type: "agent.bound",
2162
2102
  turnId,
2163
2103
  data: Object.assign({ sdkAgentId }, (sdkAgentId.startsWith("bc-")
2164
2104
  ? { url: `https://cursor.com/agents/${sdkAgentId}` }
2165
2105
  : {})),
2166
- });
2106
+ }, eventContext);
2167
2107
  }) });
2168
2108
  });
2169
2109
  }
@@ -2365,8 +2305,9 @@ export class SessionEngine {
2365
2305
  return evaluated;
2366
2306
  });
2367
2307
  }
2368
- buildCustomTools(record_1, agent_1, turnId_1, emit_1) {
2369
- return __awaiter(this, arguments, void 0, function* (record, agent, turnId, emit, extraTools = []) {
2308
+ buildCustomTools(record_1, turnId_1, emit_1) {
2309
+ return __awaiter(this, arguments, void 0, function* (record, turnId, emit, extraTools = []) {
2310
+ const agent = this.project.agent;
2370
2311
  const tools = {};
2371
2312
  const register = (tool) => {
2372
2313
  tools[tool.name] = Object.assign(Object.assign(Object.assign({ description: tool.description, inputSchema: tool.inputSchema }, (tool.outputSchema === undefined
@@ -3389,15 +3330,15 @@ export class SessionEngine {
3389
3330
  // ==========================================================================
3390
3331
  // Events: append, dispatch to channel handlers + hooks
3391
3332
  // ==========================================================================
3392
- appendEvent(sessionId, payload) {
3333
+ appendEvent(sessionId, payload, context) {
3393
3334
  return __awaiter(this, void 0, void 0, function* () {
3394
3335
  const log = yield this.logs.get(sessionId);
3395
3336
  const event = log.append(payload);
3396
- this.queueDispatch(sessionId, event);
3337
+ this.queueDispatch(sessionId, event, context);
3397
3338
  return event;
3398
3339
  });
3399
3340
  }
3400
- queueDispatch(sessionId, event) {
3341
+ queueDispatch(sessionId, event, context) {
3401
3342
  var _a;
3402
3343
  var _b;
3403
3344
  // Single funnel for both append paths (appendEvent + the held-log emit),
@@ -3405,7 +3346,7 @@ export class SessionEngine {
3405
3346
  (_a = this.storage) === null || _a === void 0 ? void 0 : _a.event(event);
3406
3347
  const chain = (_b = this.dispatchChains.get(sessionId)) !== null && _b !== void 0 ? _b : Promise.resolve();
3407
3348
  const next = chain
3408
- .then(() => this.dispatchEvent(sessionId, event))
3349
+ .then(() => this.dispatchEvent(sessionId, event, context))
3409
3350
  .catch((error) => {
3410
3351
  this.logger(`[agent-sdk] event dispatch failed for ${sessionId}: ${describeError(error)}`);
3411
3352
  })
@@ -3418,17 +3359,25 @@ export class SessionEngine {
3418
3359
  });
3419
3360
  this.dispatchChains.set(sessionId, next);
3420
3361
  }
3421
- dispatchEvent(sessionId, event) {
3362
+ dispatchEvent(sessionId, event, context) {
3422
3363
  return __awaiter(this, void 0, void 0, function* () {
3423
3364
  var _a;
3424
- var _b;
3365
+ var _b, _c;
3425
3366
  const record = yield this.sessions.get(sessionId);
3426
3367
  if (record === undefined) {
3427
3368
  return;
3428
3369
  }
3370
+ const channelState = context === undefined
3371
+ ? ((_b = record.channelState) !== null && _b !== void 0 ? _b : null)
3372
+ : context.channelState;
3373
+ const channelStateBefore = context === undefined ? undefined : structuredClone(channelState);
3429
3374
  const sessionCtx = {
3430
- session: this.sessionInfo(record),
3375
+ session: (_c = context === null || context === void 0 ? void 0 : context.session) !== null && _c !== void 0 ? _c : this.sessionInfo(record),
3431
3376
  host: this.hostForSession(record.sessionId),
3377
+ artifacts: this.artifactsApi({
3378
+ sessionId: record.sessionId,
3379
+ turnId: event.turnId,
3380
+ }),
3432
3381
  };
3433
3382
  const channelEvents = this.channelEventHandlersFor(record.channelId);
3434
3383
  if (channelEvents !== undefined) {
@@ -3440,7 +3389,7 @@ export class SessionEngine {
3440
3389
  ];
3441
3390
  const channelCtx = {
3442
3391
  channelId: record.channelId,
3443
- state: ((_b = record.channelState) !== null && _b !== void 0 ? _b : null),
3392
+ state: channelState,
3444
3393
  continuationToken: record.continuationKey,
3445
3394
  setContinuationToken: (token) => this.setContinuationToken(sessionId, token),
3446
3395
  };
@@ -3455,8 +3404,19 @@ export class SessionEngine {
3455
3404
  this.logger(`[agent-sdk] channel "${record.channelId}" handler for ${event.type} threw: ${describeError(error)}`);
3456
3405
  }
3457
3406
  }
3458
- // Handlers mutate channel state in place; persist after each batch.
3459
- yield this.updateRecord(sessionId, (current) => (Object.assign({}, current)));
3407
+ if (context === undefined || channelStateBefore === undefined) {
3408
+ // Handlers mutate live channel state in place; save the current record.
3409
+ yield this.updateRecord(sessionId, (current) => (Object.assign({}, current)));
3410
+ }
3411
+ else {
3412
+ const updatedState = channelCtx.state;
3413
+ context.channelState = updatedState;
3414
+ yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateMutation({
3415
+ current: current.channelState,
3416
+ before: channelStateBefore,
3417
+ after: updatedState,
3418
+ }) })));
3419
+ }
3460
3420
  }
3461
3421
  for (const hook of this.project.hooks) {
3462
3422
  const handlers = [
@@ -3471,19 +3431,13 @@ export class SessionEngine {
3471
3431
  yield handler(event, Object.assign(Object.assign({}, sessionCtx), { agent: { name: this.project.name }, channel: {
3472
3432
  id: record.channelId,
3473
3433
  continuationToken: record.continuationKey,
3474
- }, stateRoot: this.stateRoot, artifacts: this.artifactsApi({
3475
- sessionId: record.sessionId,
3476
- turnId: event.turnId,
3477
- }) }));
3434
+ }, stateRoot: this.stateRoot }));
3478
3435
  }
3479
3436
  catch (error) {
3480
3437
  this.logger(`[agent-sdk] hook "${hook.name}" handler for ${event.type} threw: ${describeError(error)}`);
3481
3438
  }
3482
3439
  }
3483
3440
  }
3484
- if (this.abCollector.enabled) {
3485
- yield this.abCollector.onEvent(event, sessionCtx.session, this.project.name);
3486
- }
3487
3441
  (_a = this.otel) === null || _a === void 0 ? void 0 : _a.onEvent(event, sessionCtx.session);
3488
3442
  });
3489
3443
  }
@@ -3542,6 +3496,10 @@ export class SessionEngine {
3542
3496
  yield active;
3543
3497
  continue;
3544
3498
  }
3499
+ const dispatch = this.dispatchChains.get(sessionId);
3500
+ if (dispatch !== undefined) {
3501
+ yield dispatch.catch(() => { });
3502
+ }
3545
3503
  return (_a = this.lastOutcomes.get(sessionId)) !== null && _a !== void 0 ? _a : { status: "finished" };
3546
3504
  }
3547
3505
  });
@@ -3756,57 +3714,6 @@ export class SessionEngine {
3756
3714
  };
3757
3715
  });
3758
3716
  }
3759
- /**
3760
- * Fold durable session streams into per-session A/B assignments and
3761
- * aggregate arm metrics (`GET /v1/abs`). Collector-independent: always
3762
- * reads `events.ndjson`.
3763
- */
3764
- abSnapshot(caller, options) {
3765
- return __awaiter(this, void 0, void 0, function* () {
3766
- var _a, _b;
3767
- var _c;
3768
- const sessions = yield this.listSessions(caller, options);
3769
- const abConfig = this.project.abConfig;
3770
- const maxPlaygroundSessions = resolveABMaxPlaygroundSessions(abConfig === null || abConfig === void 0 ? void 0 : abConfig.maxPlaygroundSessions);
3771
- const foldedSessions = sessions.slice(0, maxPlaygroundSessions);
3772
- // Backfill for a replacement host with nothing local to fold (e.g.
3773
- // lazy-only restore before any session resumed): serve the persisted
3774
- // aggregate instead of an empty surface. Gated on the host having no
3775
- // sessions AT ALL — the persisted snapshot spans every principal, so a
3776
- // caller who merely owns no sessions must not see it. Loaded once per
3777
- // process (playground polls this route ~every 4s); skip the persist
3778
- // side effect below — re-saving a restored snapshot would echo stale
3779
- // data back into the store.
3780
- if (foldedSessions.length === 0 &&
3781
- this.storage !== undefined &&
3782
- (yield this.sessions.list()).length === 0) {
3783
- (_c = this.restoredAbSnapshot) !== null && _c !== void 0 ? _c : (this.restoredAbSnapshot = this.storage.getLatestAbSnapshot());
3784
- const restoredSnapshot = yield this.restoredAbSnapshot;
3785
- if (restoredSnapshot !== undefined) {
3786
- return restoredSnapshot;
3787
- }
3788
- }
3789
- const abTable = (_a = this.project.storage) === null || _a === void 0 ? void 0 : _a.abs;
3790
- const snapshot = yield buildABSnapshot({
3791
- experiments: this.project.abs,
3792
- agentName: this.project.name,
3793
- sessions: foldedSessions,
3794
- loadRecord: (sessionId) => this.sessions.get(sessionId),
3795
- loadEvents: (sessionId) => this.listEvents(sessionId, 0),
3796
- sessionInfo: (record) => this.sessionInfo(record),
3797
- logger: this.logger,
3798
- config: {
3799
- maxPlaygroundSessions,
3800
- durableSamples: abTable !== undefined,
3801
- durableSnapshots: (abTable === null || abTable === void 0 ? void 0 : abTable.putSnapshot) !== undefined,
3802
- },
3803
- });
3804
- // Side effect on the read path: playground polls GET /v1/abs ~every 4s;
3805
- // the coordinator throttles the actual table write.
3806
- (_b = this.storage) === null || _b === void 0 ? void 0 : _b.abSnapshot(snapshot);
3807
- return snapshot;
3808
- });
3809
- }
3810
3717
  eventStream(sessionId_1) {
3811
3718
  return __awaiter(this, arguments, void 0, function* (sessionId, startIndex = 0) {
3812
3719
  // Playground Trace replays this stream; backfill before the snapshot
@@ -4017,7 +3924,7 @@ export class SessionEngine {
4017
3924
  this.coalesceDrains.has(sessionId));
4018
3925
  }
4019
3926
  sessionInfo(record) {
4020
- return Object.assign(Object.assign(Object.assign({ id: record.sessionId, channelId: record.channelId, mode: record.mode, purpose: record.purpose === "eval" ? "eval" : "live", dryRun: record.dryRun === true ? true : undefined, asOf: record.asOf, auth: record.auth, continuationKey: record.continuationKey }, (record.abs === undefined ? {} : { abs: record.abs })), (record.title === undefined ? {} : { title: record.title })), (record.sdkAgentId === undefined
3927
+ return Object.assign(Object.assign({ id: record.sessionId, channelId: record.channelId, mode: record.mode, purpose: record.purpose === "eval" ? "eval" : "live", dryRun: record.dryRun === true ? true : undefined, asOf: record.asOf, auth: record.auth, continuationKey: record.continuationKey }, (record.title === undefined ? {} : { title: record.title })), (record.sdkAgentId === undefined
4021
3928
  ? {}
4022
3929
  : { sdkAgentId: record.sdkAgentId }));
4023
3930
  }
@@ -4079,9 +3986,9 @@ export class SessionEngine {
4079
3986
  * serve start, before channels accept traffic: any persisted session
4080
3987
  * missing from the local `--state-root` is materialized there — events
4081
3988
  * as `events.ndjson`, record as `session.json` — after which every
4082
- * existing read path (continuation lookup, event replay/streams, A/B
4083
- * fold hydration) works unchanged. Local state always wins over the
4084
- * sink, so restarts on the same host are no-ops.
3989
+ * existing read path (continuation lookup, event replay/streams) works
3990
+ * unchanged. Local state always wins over the sink, so restarts on the
3991
+ * same host are no-ops.
4085
3992
  *
4086
3993
  * Failures are logged and skipped; a broken store (including rows that
4087
3994
  * violate the SessionRecord shape) never blocks serve start.
@@ -4345,30 +4252,6 @@ function mergePendingWorkspaceFiles(current, incoming) {
4345
4252
  }
4346
4253
  return Object.assign(Object.assign({}, current), incoming);
4347
4254
  }
4348
- /**
4349
- * Shallow-merge a wake patch into durable channel state. Null / undefined
4350
- * patch values leave the existing key alone so sticky fields survive.
4351
- */
4352
- export function mergeChannelStateSkipNull(current, patch) {
4353
- if (patch === undefined) {
4354
- return current;
4355
- }
4356
- if (typeof patch !== "object" ||
4357
- patch === null ||
4358
- Array.isArray(patch) ||
4359
- typeof current !== "object" ||
4360
- current === null ||
4361
- Array.isArray(current)) {
4362
- return structuredClone(patch);
4363
- }
4364
- const merged = Object.assign({}, current);
4365
- for (const [key, value] of Object.entries(patch)) {
4366
- if (value !== null && value !== undefined) {
4367
- merged[key] = value;
4368
- }
4369
- }
4370
- return merged;
4371
- }
4372
4255
  function eventsNdjson(events) {
4373
4256
  if (events.length === 0) {
4374
4257
  return undefined;