@cursor/bdk 0.2.2 → 0.2.3

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 (284) hide show
  1. package/AGENTS.md +1 -1
  2. package/dist/bin/agent-serve.js +23 -7
  3. package/dist/channels/github/auth.d.ts.map +1 -1
  4. package/dist/channels/github/auth.js +36 -5
  5. package/dist/connections.d.ts +1 -1
  6. package/dist/connections.js +1 -1
  7. package/dist/docs/404.html +2 -2
  8. package/dist/docs/assets/{app.DtYVVVyK.js → app.BOIHhrKi.js} +4 -4
  9. package/dist/docs/assets/chunks/@localSearchIndexroot.D5L-b34G.js +1 -0
  10. package/dist/docs/assets/chunks/{VPLocalSearchBox.D47xT7J4.js → VPLocalSearchBox.D49zVZqM.js} +1 -1
  11. package/dist/docs/assets/chunks/{arc.CDJ6xzxR.js → arc.hmjb-sc4.js} +1 -1
  12. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.l1Xnjd3N.js → architectureDiagram-Q4EWVU46.CxEI1KqM.js} +1 -1
  13. package/dist/docs/assets/chunks/{baseUniq.x-finShZ.js → baseUniq.DHHvBWoV.js} +1 -1
  14. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.COC3qynH.js → blockDiagram-DXYQGD6D.DnXW-3bu.js} +1 -1
  15. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.DdQO850E.js → c4Diagram-AHTNJAMY.e-47O2jM.js} +1 -1
  16. package/dist/docs/assets/chunks/channel.BbOGaJQP.js +1 -0
  17. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.Dpn8omLk.js → chunk-4BX2VUAB.3ry4pYXB.js} +1 -1
  18. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.C0XWStUN.js → chunk-4TB4RGXK.DGIZFRx6.js} +1 -1
  19. package/dist/docs/assets/chunks/{chunk-55IACEB6.DsKSZfIM.js → chunk-55IACEB6.DKBnqg9U.js} +1 -1
  20. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.dNU6JDu6.js → chunk-EDXVE4YY.BIU8Ue5k.js} +1 -1
  21. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DN41fxKE.js → chunk-FMBD7UC4.DP-TFhjI.js} +1 -1
  22. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.COpKCZus.js → chunk-OYMX7WX6.Ux0OYj5v.js} +1 -1
  23. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.HDB-azx2.js → chunk-QZHKN3VN.BzHMwYox.js} +1 -1
  24. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.DEeX_a2j.js → chunk-YZCP3GAM.D4OGAsSP.js} +1 -1
  25. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.Db58HCb1.js +1 -0
  26. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.Db58HCb1.js +1 -0
  27. package/dist/docs/assets/chunks/clone.Co4MBflG.js +1 -0
  28. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.C3yGL2A8.js → cose-bilkent-S5V4N54A.Jq_7BUNx.js} +1 -1
  29. package/dist/docs/assets/chunks/{dagre-KV5264BT.Bpl24en4.js → dagre-KV5264BT.Di-skR2x.js} +1 -1
  30. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.nFco6seU.js → diagram-5BDNPKRD.DeREHIdH.js} +1 -1
  31. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.DXhA6DWR.js → diagram-G4DWMVQ6.C7Kcqxro.js} +1 -1
  32. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.8GoOYcwk.js → diagram-MMDJMWI5.BK3eohyo.js} +1 -1
  33. package/dist/docs/assets/chunks/{diagram-TYMM5635.DDBlqvlJ.js → diagram-TYMM5635.C6TyymXT.js} +1 -1
  34. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.vl_N81P4.js → erDiagram-SMLLAGMA.DYGG-gGx.js} +1 -1
  35. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.Cteg8g7I.js → flowDiagram-DWJPFMVM.C9nBcSV4.js} +1 -1
  36. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.D4aMhlMM.js → ganttDiagram-T4ZO3ILL.wAg_ymsp.js} +1 -1
  37. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.DF_J0D4q.js → gitGraphDiagram-UUTBAWPF.B87j9Oeg.js} +1 -1
  38. package/dist/docs/assets/chunks/{graph.DJs0LDCf.js → graph.CuFMj31w.js} +1 -1
  39. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.Bb-4RQwg.js → infoDiagram-42DDH7IO.P_mLGumP.js} +1 -1
  40. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DEtQRSbc.js → ishikawaDiagram-UXIWVN3A.DyuL_MsT.js} +1 -1
  41. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.DhQQ75FA.js → journeyDiagram-VCZTEJTY.CtP09IoJ.js} +1 -1
  42. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.C4gEw3Rk.js → kanban-definition-6JOO6SKY.BoeSYPZo.js} +1 -1
  43. package/dist/docs/assets/chunks/{layout.DT-PGlXa.js → layout.B0lMMtNo.js} +1 -1
  44. package/dist/docs/assets/chunks/{linear.BMMe__JW.js → linear.HxRBiAFX.js} +1 -1
  45. package/dist/docs/assets/chunks/{min.XyaU9K9Q.js → min.BGlFFHwS.js} +1 -1
  46. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.CbBM6xZ-.js → mindmap-definition-QFDTVHPH.JyLBD9M8.js} +1 -1
  47. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.DFJoIVou.js → pieDiagram-DEJITSTG.DnSmNZF8.js} +1 -1
  48. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.CQjkDYqb.js → quadrantDiagram-34T5L4WZ.CUCnbfCa.js} +1 -1
  49. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.D-mK-JQu.js → requirementDiagram-MS252O5E.py0IVUn5.js} +1 -1
  50. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.BStQInpd.js → sankeyDiagram-XADWPNL6.Bkc-HWYp.js} +1 -1
  51. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.CA_eooPJ.js → sequenceDiagram-FGHM5R23.Dqn8Mlv2.js} +1 -1
  52. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.BXl-b7ad.js → stateDiagram-FHFEXIEX.JikkoQUU.js} +1 -1
  53. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CMsKhrW0.js +1 -0
  54. package/dist/docs/assets/chunks/{theme.q37tOs4x.js → theme.b6HQ6zG_.js} +2 -2
  55. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.vjuaGOSe.js → timeline-definition-GMOUNBTQ.BvpSXiBj.js} +1 -1
  56. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.BxduJl-F.js → vennDiagram-DHZGUBPP.CU7MVnZx.js} +1 -1
  57. package/dist/docs/assets/chunks/wardley-RL74JXVD.BKwC4ctG.js +162 -0
  58. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.D1z3ds0D.js → wardleyDiagram-NUSXRM2D.BfaF6Uhe.js} +1 -1
  59. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.CRU5Ti9b.js → xychartDiagram-5P7HB3ND.Bg5dcpj4.js} +1 -1
  60. package/dist/docs/assets/{deployment.md.nGo1yIsa.js → deployment.md.BJ8i7Q6p.js} +5 -8
  61. package/dist/docs/assets/{deployment.md.nGo1yIsa.lean.js → deployment.md.BJ8i7Q6p.lean.js} +1 -1
  62. package/dist/docs/assets/{guides_github.md.C2_DSWlE.js → guides_github.md.Bq9kQU9B.js} +9 -3
  63. package/dist/docs/assets/{guides_github.md.C2_DSWlE.lean.js → guides_github.md.Bq9kQU9B.lean.js} +1 -1
  64. package/dist/docs/assets/{guides_slack.md.ZbHQETOT.js → guides_slack.md.diqqXTTm.js} +2 -2
  65. package/dist/docs/assets/{guides_slack.md.ZbHQETOT.lean.js → guides_slack.md.diqqXTTm.lean.js} +1 -1
  66. package/dist/docs/assets/{quickstart.md.wG4shE1f.js → quickstart.md.CHpHPBUN.js} +5 -3
  67. package/dist/docs/assets/{quickstart.md.wG4shE1f.lean.js → quickstart.md.CHpHPBUN.lean.js} +1 -1
  68. package/dist/docs/assets/{reference_artifacts.md.CFMNPreZ.js → reference_artifacts.md.CQfKq8F2.js} +1 -1
  69. package/dist/docs/assets/reference_cli.md.DgeLTO18.js +91 -0
  70. package/dist/docs/assets/reference_cli.md.DgeLTO18.lean.js +1 -0
  71. package/dist/docs/assets/{reference_connections.md._XpKiOaF.js → reference_connections.md.COq--gAm.js} +7 -3
  72. package/dist/docs/assets/{reference_connections.md._XpKiOaF.lean.js → reference_connections.md.COq--gAm.lean.js} +1 -1
  73. package/dist/docs/assets/{reference_evals.md.DqNyHMA6.js → reference_evals.md.CJm3uCUm.js} +4 -4
  74. package/dist/docs/assets/{reference_evals.md.DqNyHMA6.lean.js → reference_evals.md.CJm3uCUm.lean.js} +1 -1
  75. package/dist/docs/assets/{reference_skills.md.CRFTxt9M.js → reference_skills.md.Cy00QMKS.js} +3 -3
  76. package/dist/docs/assets/{reference_skills.md.CRFTxt9M.lean.js → reference_skills.md.Cy00QMKS.lean.js} +1 -1
  77. package/dist/docs/assets/troubleshooting.md.Cw5PKa3t.js +1 -0
  78. package/dist/docs/assets/{troubleshooting.md.BzZSu1Gz.lean.js → troubleshooting.md.Cw5PKa3t.lean.js} +1 -1
  79. package/dist/docs/building-with-agents.html +35 -35
  80. package/dist/docs/deployment.html +40 -43
  81. package/dist/docs/deployment.md +45 -15
  82. package/dist/docs/evals.html +35 -35
  83. package/dist/docs/guides/agent-to-agent.html +35 -35
  84. package/dist/docs/guides/bitbucket.html +35 -35
  85. package/dist/docs/guides/cloud-agents.html +35 -35
  86. package/dist/docs/guides/convert-automation.html +35 -35
  87. package/dist/docs/guides/github.html +43 -37
  88. package/dist/docs/guides/github.md +34 -0
  89. package/dist/docs/guides/gitlab.html +35 -35
  90. package/dist/docs/guides/grokbot-agents.html +35 -35
  91. package/dist/docs/guides/hooks.html +35 -35
  92. package/dist/docs/guides/improve.html +35 -35
  93. package/dist/docs/guides/jev.html +35 -35
  94. package/dist/docs/guides/mcp-oauth.html +35 -35
  95. package/dist/docs/guides/opentelemetry.html +35 -35
  96. package/dist/docs/guides/slack.html +37 -37
  97. package/dist/docs/guides/slack.md +5 -0
  98. package/dist/docs/guides/webhooks.html +35 -35
  99. package/dist/docs/hashmap.json +1 -1
  100. package/dist/docs/hillclimbing.html +35 -35
  101. package/dist/docs/index.html +35 -35
  102. package/dist/docs/llms-full.txt +198 -92
  103. package/dist/docs/quickstart.html +40 -38
  104. package/dist/docs/quickstart.md +7 -1
  105. package/dist/docs/reference/agent-config.html +35 -35
  106. package/dist/docs/reference/artifacts.html +37 -37
  107. package/dist/docs/reference/artifacts.md +1 -1
  108. package/dist/docs/reference/channels.html +35 -35
  109. package/dist/docs/reference/cli.html +55 -61
  110. package/dist/docs/reference/cli.md +65 -63
  111. package/dist/docs/reference/connections.html +42 -38
  112. package/dist/docs/reference/connections.md +28 -2
  113. package/dist/docs/reference/evals.html +39 -39
  114. package/dist/docs/reference/evals.md +6 -7
  115. package/dist/docs/reference/extensions.html +35 -35
  116. package/dist/docs/reference/hooks.html +35 -35
  117. package/dist/docs/reference/http-api.html +35 -35
  118. package/dist/docs/reference/instructions.html +35 -35
  119. package/dist/docs/reference/playground.html +35 -35
  120. package/dist/docs/reference/project-layout.html +35 -35
  121. package/dist/docs/reference/prompt.html +35 -35
  122. package/dist/docs/reference/schedules.html +35 -35
  123. package/dist/docs/reference/sessions.html +35 -35
  124. package/dist/docs/reference/skills.html +38 -38
  125. package/dist/docs/reference/subagents.html +35 -35
  126. package/dist/docs/reference/tools.html +35 -35
  127. package/dist/docs/templates/agentic-owners.html +35 -35
  128. package/dist/docs/templates/security-reviewer.html +35 -35
  129. package/dist/docs/templates/thermo-quality-review.html +35 -35
  130. package/dist/docs/templates/thermo-review.html +35 -35
  131. package/dist/docs/templates/triage.html +35 -35
  132. package/dist/docs/troubleshooting.html +36 -36
  133. package/dist/docs/troubleshooting.md +7 -3
  134. package/dist/extensions/cursor-grokbot-agents/extension.d.ts +77 -0
  135. package/dist/extensions/cursor-grokbot-agents/extension.d.ts.map +1 -0
  136. package/dist/extensions/cursor-grokbot-agents/extension.js +63 -0
  137. package/dist/extensions/cursor-grokbot-agents/lib/agents.d.ts +11 -0
  138. package/dist/extensions/cursor-grokbot-agents/lib/agents.d.ts.map +1 -0
  139. package/dist/extensions/cursor-grokbot-agents/lib/agents.js +31 -0
  140. package/dist/extensions/cursor-grokbot-agents/lib/backend.d.ts +56 -0
  141. package/dist/extensions/cursor-grokbot-agents/lib/backend.d.ts.map +1 -0
  142. package/dist/extensions/cursor-grokbot-agents/lib/backend.js +158 -0
  143. package/dist/extensions/cursor-grokbot-agents/lib/contacts.d.ts +28 -0
  144. package/dist/extensions/cursor-grokbot-agents/lib/contacts.d.ts.map +1 -0
  145. package/dist/extensions/cursor-grokbot-agents/lib/contacts.js +59 -0
  146. package/dist/extensions/cursor-grokbot-agents/lib/conversation.d.ts +53 -0
  147. package/dist/extensions/cursor-grokbot-agents/lib/conversation.d.ts.map +1 -0
  148. package/dist/extensions/cursor-grokbot-agents/lib/conversation.js +206 -0
  149. package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts +4 -0
  150. package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts.map +1 -0
  151. package/dist/extensions/cursor-grokbot-agents/lib/inputs.js +15 -0
  152. package/dist/extensions/cursor-grokbot-agents/lib/lock.d.ts +12 -0
  153. package/dist/extensions/cursor-grokbot-agents/lib/lock.d.ts.map +1 -0
  154. package/dist/extensions/cursor-grokbot-agents/lib/lock.js +25 -0
  155. package/dist/extensions/cursor-grokbot-agents/skills/consult.md +40 -0
  156. package/dist/extensions/cursor-grokbot-agents/tools/ask.d.ts +4 -0
  157. package/dist/extensions/cursor-grokbot-agents/tools/ask.d.ts.map +1 -0
  158. package/dist/extensions/cursor-grokbot-agents/tools/ask.js +37 -0
  159. package/dist/extensions/cursor-grokbot-agents/tools/check.d.ts +4 -0
  160. package/dist/extensions/cursor-grokbot-agents/tools/check.d.ts.map +1 -0
  161. package/dist/extensions/cursor-grokbot-agents/tools/check.js +32 -0
  162. package/dist/extensions/cursor-grokbot-agents/tools/interrupt.d.ts +4 -0
  163. package/dist/extensions/cursor-grokbot-agents/tools/interrupt.d.ts.map +1 -0
  164. package/dist/extensions/cursor-grokbot-agents/tools/interrupt.js +24 -0
  165. package/dist/extensions/cursor-grokbot-agents/tools/list.d.ts +4 -0
  166. package/dist/extensions/cursor-grokbot-agents/tools/list.d.ts.map +1 -0
  167. package/dist/extensions/cursor-grokbot-agents/tools/list.js +34 -0
  168. package/dist/internal/cli-ax.d.ts +1 -0
  169. package/dist/internal/cli-ax.d.ts.map +1 -1
  170. package/dist/internal/cli-ax.js +43 -10
  171. package/dist/internal/cli-deploy.d.ts +5 -1
  172. package/dist/internal/cli-deploy.d.ts.map +1 -1
  173. package/dist/internal/cli-deploy.js +22 -4
  174. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  175. package/dist/internal/cli-mcp-oauth.js +2 -1
  176. package/dist/internal/cli-skills.d.ts +1 -1
  177. package/dist/internal/cli-skills.d.ts.map +1 -1
  178. package/dist/internal/cli-skills.js +5 -5
  179. package/dist/internal/connection-env.d.ts +31 -0
  180. package/dist/internal/connection-env.d.ts.map +1 -0
  181. package/dist/internal/connection-env.js +84 -0
  182. package/dist/internal/cursor/backend-client.js +5 -0
  183. package/dist/internal/deploy-client.d.ts +30 -6
  184. package/dist/internal/deploy-client.d.ts.map +1 -1
  185. package/dist/internal/deploy-client.js +45 -9
  186. package/dist/internal/discovery/connections.d.ts.map +1 -1
  187. package/dist/internal/discovery/connections.js +11 -0
  188. package/dist/internal/hosted-delivery-protocol.d.ts +36 -11
  189. package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
  190. package/dist/internal/hosted-delivery-protocol.js +31 -8
  191. package/dist/internal/hosted-delivery.d.ts +2 -2
  192. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  193. package/dist/internal/hosted-delivery.js +228 -48
  194. package/dist/internal/hosting.d.ts +2 -2
  195. package/dist/internal/hosting.d.ts.map +1 -1
  196. package/dist/internal/hosting.js +9 -3
  197. package/dist/internal/install-cursor-skills.d.ts +20 -24
  198. package/dist/internal/install-cursor-skills.d.ts.map +1 -1
  199. package/dist/internal/install-cursor-skills.js +50 -48
  200. package/dist/internal/legacy-command-guard.d.ts +2 -0
  201. package/dist/internal/legacy-command-guard.d.ts.map +1 -1
  202. package/dist/internal/legacy-command-guard.js +10 -1
  203. package/dist/internal/mcp-host.d.ts +6 -0
  204. package/dist/internal/mcp-host.d.ts.map +1 -1
  205. package/dist/internal/mcp-host.js +35 -16
  206. package/dist/internal/sdk-runner.d.ts +2 -0
  207. package/dist/internal/sdk-runner.d.ts.map +1 -1
  208. package/dist/internal/sdk-runner.js +10 -0
  209. package/dist/internal/server.d.ts.map +1 -1
  210. package/dist/internal/server.js +11 -1
  211. package/dist/internal/session-engine.d.ts.map +1 -1
  212. package/dist/internal/session-engine.js +9 -5
  213. package/dist/types.d.ts +11 -1
  214. package/dist/types.d.ts.map +1 -1
  215. package/docs/deployment.md +45 -15
  216. package/docs/guides/github.md +34 -0
  217. package/docs/guides/slack.md +5 -0
  218. package/docs/quickstart.md +7 -1
  219. package/docs/reference/artifacts.md +1 -1
  220. package/docs/reference/cli.md +65 -63
  221. package/docs/reference/connections.md +28 -2
  222. package/docs/reference/evals.md +6 -7
  223. package/docs/troubleshooting.md +7 -3
  224. package/package.json +1 -3
  225. package/scripts/install-cursor-skills.mjs +1 -1
  226. package/skills/create-agent/SKILL.md +1 -1
  227. package/skills/debug/SKILL.md +1 -1
  228. package/skills/deploy/SKILL.md +1 -1
  229. package/skills/evals/SKILL.md +1 -1
  230. package/skills/framework-map/SKILL.md +1 -1
  231. package/skills/github/SKILL.md +1 -1
  232. package/skills/hillclimb/SKILL.md +1 -1
  233. package/skills/mcp-auth/SKILL.md +1 -1
  234. package/skills/otel/SKILL.md +1 -1
  235. package/skills/setup-slack/SKILL.md +1 -1
  236. package/src/bin/agent-serve.ts +27 -6
  237. package/src/channels/github/auth.ts +44 -5
  238. package/src/connections.ts +1 -1
  239. package/src/extensions/cursor-grokbot-agents/extension.ts +132 -0
  240. package/src/extensions/cursor-grokbot-agents/lib/agents.ts +42 -0
  241. package/src/extensions/cursor-grokbot-agents/lib/backend.ts +208 -0
  242. package/src/extensions/cursor-grokbot-agents/lib/contacts.ts +74 -0
  243. package/src/extensions/cursor-grokbot-agents/lib/conversation.ts +260 -0
  244. package/src/extensions/cursor-grokbot-agents/lib/inputs.ts +21 -0
  245. package/src/extensions/cursor-grokbot-agents/lib/lock.ts +26 -0
  246. package/src/extensions/cursor-grokbot-agents/skills/consult.md +40 -0
  247. package/src/extensions/cursor-grokbot-agents/tools/ask.ts +32 -0
  248. package/src/extensions/cursor-grokbot-agents/tools/check.ts +25 -0
  249. package/src/extensions/cursor-grokbot-agents/tools/interrupt.ts +17 -0
  250. package/src/extensions/cursor-grokbot-agents/tools/list.ts +26 -0
  251. package/src/internal/cli-ax.ts +52 -7
  252. package/src/internal/cli-deploy.ts +39 -6
  253. package/src/internal/cli-mcp-oauth.ts +2 -1
  254. package/src/internal/cli-skills.ts +4 -5
  255. package/src/internal/connection-env.ts +106 -0
  256. package/src/internal/cursor/backend-client.ts +6 -0
  257. package/src/internal/deploy-client.ts +79 -9
  258. package/src/internal/discovery/connections.ts +11 -0
  259. package/src/internal/hosted-delivery-protocol.ts +57 -20
  260. package/src/internal/hosted-delivery.ts +486 -228
  261. package/src/internal/hosting.ts +10 -3
  262. package/src/internal/install-cursor-skills.ts +56 -53
  263. package/src/internal/legacy-command-guard.ts +13 -1
  264. package/src/internal/mcp-host.ts +45 -17
  265. package/src/internal/sdk-runner.ts +11 -0
  266. package/src/internal/server.ts +13 -1
  267. package/src/internal/session-engine.ts +9 -5
  268. package/src/types.ts +11 -1
  269. package/templates/agents-md/bot/lib/collect.ts +1 -4
  270. package/templates/code-wiki/bot/channels/github.ts +2 -2
  271. package/templates/demo/bot/channels/github.ts +5 -1
  272. package/templates/pr-autofixer/bot/lib/start-drive.ts +4 -4
  273. package/templates/triage/bot/lib/types.ts +6 -6
  274. package/dist/docs/assets/chunks/@localSearchIndexroot.BgTA2tV1.js +0 -1
  275. package/dist/docs/assets/chunks/channel.B2nMEx82.js +0 -1
  276. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.D8iCH2ve.js +0 -1
  277. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.D8iCH2ve.js +0 -1
  278. package/dist/docs/assets/chunks/clone.5XNLjby0.js +0 -1
  279. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.yGM2uLZQ.js +0 -1
  280. package/dist/docs/assets/chunks/wardley-RL74JXVD.DKfyIejL.js +0 -162
  281. package/dist/docs/assets/reference_cli.md.BK2QUH67.js +0 -97
  282. package/dist/docs/assets/reference_cli.md.BK2QUH67.lean.js +0 -1
  283. package/dist/docs/assets/troubleshooting.md.BzZSu1Gz.js +0 -1
  284. /package/dist/docs/assets/{reference_artifacts.md.CFMNPreZ.lean.js → reference_artifacts.md.CQfKq8F2.lean.js} +0 -0
@@ -0,0 +1,260 @@
1
+ /**
2
+ * One exchange with a hosted Grok Bot agent, the way the grokbot runtime
3
+ * drives a turn: send a user message, then read the transcript until the
4
+ * agent's turn settles. Only `send-message` entries (what the agent delivers
5
+ * through SendToUser) are the reply; its internal work never appears in the
6
+ * transcript. Waits are bounded, so a long turn comes back as `running` and
7
+ * `check` picks it up from the caller's cursor.
8
+ *
9
+ * Sends and reads on one hosted agent are chained within this process, and
10
+ * a send waits for an in-flight turn to settle first, so a reply always
11
+ * attributes to the message that prompted it.
12
+ */
13
+
14
+ import type { ToolContext } from "../../../types.js";
15
+ import extension from "../extension.js";
16
+ import { resolveAgentName } from "./agents.js";
17
+ import {
18
+ type GrokBotAgentsBackend,
19
+ type GrokBotTurnStatus,
20
+ grokBotAgentsBackend,
21
+ } from "./backend.js";
22
+ import { type Contact, findContact, listContacts, saveContact } from "./contacts.js";
23
+ import { KeyedLock } from "./lock.js";
24
+
25
+ export const DEFAULT_WAIT_SECONDS = 120;
26
+ export const MAX_WAIT_SECONDS = 600;
27
+
28
+ /**
29
+ * Idle polls required before a turn counts as settled when the workflow
30
+ * never reported busy: covers the window between an accepted send and the
31
+ * workflow picking the signal up, which a `check` right after a short `ask`
32
+ * can still be inside.
33
+ */
34
+ const MIN_IDLE_POLLS_WITHOUT_BUSY = 4;
35
+ /**
36
+ * A session whose row is this young, and whose transcript is still empty,
37
+ * was created by the call that fetched it; the allowance covers clock skew
38
+ * between this host and the backend.
39
+ */
40
+ const CREATED_WINDOW_MS = 60_000;
41
+ /** The transcript tail of an agent nobody has spoken to. */
42
+ const EMPTY_TRANSCRIPT_TAIL = "-1";
43
+
44
+ export type ReplyStatus = "finished" | "running";
45
+
46
+ // Type aliases, not interfaces: these are tool results.
47
+ export type AskResult = {
48
+ agent: string;
49
+ sessionId: string;
50
+ status: ReplyStatus;
51
+ /** What the agent sent back, in order; absent when it sent nothing (yet). */
52
+ reply?: string;
53
+ /** Replies to earlier messages that this caller had not read yet. */
54
+ earlierReplies?: string[];
55
+ /** The account had no agent of that name; this call created an empty one. */
56
+ created?: true;
57
+ note?: string;
58
+ };
59
+
60
+ export type CheckResult = {
61
+ agent: string;
62
+ sessionId: string;
63
+ status: ReplyStatus;
64
+ reply?: string;
65
+ note?: string;
66
+ };
67
+
68
+ export type InterruptResult = {
69
+ agent: string;
70
+ sessionId: string;
71
+ interrupted: true;
72
+ };
73
+
74
+ type Replies = {
75
+ status: ReplyStatus;
76
+ deliveries: string[];
77
+ /** Newest `updatedSeq` consumed. */
78
+ cursor: string;
79
+ };
80
+
81
+ const agentLocks = new KeyedLock();
82
+
83
+ export async function ask(
84
+ ctx: ToolContext,
85
+ input: { agent?: string; message: string; waitSeconds: number },
86
+ ): Promise<AskResult> {
87
+ const name = resolveAgentName(input.agent, extension.config.agents);
88
+ const backend = grokBotAgentsBackend();
89
+ const startedAt = Date.now();
90
+ const session = await backend.session(name);
91
+ return agentLocks.run(session.sessionId, async () => {
92
+ const contact = (await listContacts(ctx)).find(
93
+ candidate => candidate.sessionId === session.sessionId,
94
+ );
95
+ const created =
96
+ contact === undefined &&
97
+ session.latestUpdatedSeq === EMPTY_TRANSCRIPT_TAIL &&
98
+ session.createdAtMs >= startedAt - CREATED_WINDOW_MS;
99
+ const deadline = Date.now() + input.waitSeconds * 1000;
100
+ // A turn already in flight, from an earlier message or from the person
101
+ // in the app, must settle first; otherwise its deliveries would read as
102
+ // the reply to this message. Nothing is persisted on the way out, so
103
+ // `check` still returns whatever landed meanwhile.
104
+ const before = await collectReplies(backend, session.sessionId, {
105
+ cursor: contact?.cursor ?? session.latestUpdatedSeq,
106
+ deadline,
107
+ confirmIdle: false,
108
+ });
109
+ if (before.status === "running") {
110
+ throw new Error(
111
+ `"${session.name}" is still working on an earlier message; nothing was sent. Call check to read that reply, wait, or interrupt it.`,
112
+ );
113
+ }
114
+ await backend.send(session.sessionId, input.message);
115
+ const replies = await collectReplies(backend, session.sessionId, {
116
+ cursor: before.cursor,
117
+ deadline,
118
+ confirmIdle: true,
119
+ });
120
+ const now = ctx.now().toISOString();
121
+ await saveContact(ctx, {
122
+ name: session.name,
123
+ sessionId: session.sessionId,
124
+ cursor: replies.cursor,
125
+ firstContactAt: contact?.firstContactAt ?? now,
126
+ lastContactAt: now,
127
+ });
128
+ const notes = [
129
+ created
130
+ ? `No Grok Bot agent named "${session.name}" existed on this account, so an empty one was created. Check the name if that is unexpected.`
131
+ : undefined,
132
+ runningNote(session.name, replies.status),
133
+ ].filter(note => note !== undefined);
134
+ return {
135
+ agent: session.name,
136
+ sessionId: session.sessionId,
137
+ status: replies.status,
138
+ reply: joinReplies(replies.deliveries),
139
+ earlierReplies: before.deliveries.length === 0 ? undefined : before.deliveries,
140
+ created: created ? true : undefined,
141
+ note: notes.length === 0 ? undefined : notes.join(" "),
142
+ };
143
+ });
144
+ }
145
+
146
+ export async function check(
147
+ ctx: ToolContext,
148
+ input: { agent?: string; waitSeconds: number },
149
+ ): Promise<CheckResult> {
150
+ const contact = await knownContact(ctx, input.agent);
151
+ const backend = grokBotAgentsBackend();
152
+ return agentLocks.run(contact.sessionId, async () => {
153
+ // Re-read under the lock: a parallel call may have moved the cursor.
154
+ const current =
155
+ (await listContacts(ctx)).find(candidate => candidate.sessionId === contact.sessionId) ??
156
+ contact;
157
+ const replies = await collectReplies(backend, current.sessionId, {
158
+ cursor: current.cursor,
159
+ deadline: Date.now() + input.waitSeconds * 1000,
160
+ confirmIdle: true,
161
+ });
162
+ await saveContact(ctx, { ...current, cursor: replies.cursor });
163
+ return {
164
+ agent: current.name,
165
+ sessionId: current.sessionId,
166
+ status: replies.status,
167
+ reply: joinReplies(replies.deliveries),
168
+ note: runningNote(current.name, replies.status),
169
+ };
170
+ });
171
+ }
172
+
173
+ export async function interrupt(
174
+ ctx: ToolContext,
175
+ input: { agent?: string },
176
+ ): Promise<InterruptResult> {
177
+ const contact = await knownContact(ctx, input.agent);
178
+ await grokBotAgentsBackend().interrupt(contact.sessionId, "Interrupted from the Agent SDK.");
179
+ return {
180
+ agent: contact.name,
181
+ sessionId: contact.sessionId,
182
+ interrupted: true,
183
+ };
184
+ }
185
+
186
+ /**
187
+ * The caller's record of the named agent. Only `ask` resolves a name on the
188
+ * backend, because that creates an agent when none matches; the other tools
189
+ * reach agents the caller has already spoken to.
190
+ */
191
+ async function knownContact(ctx: ToolContext, requested: string | undefined): Promise<Contact> {
192
+ const name = resolveAgentName(requested, extension.config.agents);
193
+ const contact = findContact(await listContacts(ctx), name);
194
+ if (contact === undefined) {
195
+ throw new Error(`You have not asked "${name}" anything yet; call ask first.`);
196
+ }
197
+ return contact;
198
+ }
199
+
200
+ /**
201
+ * Read the transcript after `cursor` until the agent's turn settles or the
202
+ * deadline passes. Only an empty page can settle the turn, so a backlog
203
+ * drains page by page first. With `confirmIdle`, an idle report may predate
204
+ * the workflow picking a message up, so settling takes
205
+ * {@link MIN_IDLE_POLLS_WITHOUT_BUSY} idle polls unless the turn was seen
206
+ * busy; without it, the first idle report settles.
207
+ */
208
+ async function collectReplies(
209
+ backend: GrokBotAgentsBackend,
210
+ sessionId: string,
211
+ options: { cursor: string; deadline: number; confirmIdle: boolean },
212
+ ): Promise<Replies> {
213
+ const deliveries: string[] = [];
214
+ let cursor = options.cursor;
215
+ let sawBusy = false;
216
+ let idlePolls = 0;
217
+ while (true) {
218
+ const page = await backend.entries(sessionId, cursor);
219
+ cursor = page.latestUpdatedSeq;
220
+ for (const entry of page.entries) {
221
+ if (entry.kind === "send-message" && entry.text !== undefined) {
222
+ deliveries.push(entry.text);
223
+ }
224
+ }
225
+ const busy = isBusy(page.turn);
226
+ if (busy) {
227
+ sawBusy = true;
228
+ }
229
+ if (page.entries.length === 0 && !busy && page.turn.idle) {
230
+ idlePolls += 1;
231
+ if (sawBusy || !options.confirmIdle || idlePolls >= MIN_IDLE_POLLS_WITHOUT_BUSY) {
232
+ return { status: "finished", deliveries, cursor };
233
+ }
234
+ }
235
+ if (Date.now() >= options.deadline) {
236
+ return { status: "running", deliveries, cursor };
237
+ }
238
+ await sleep(extension.config.pollIntervalMs);
239
+ }
240
+ }
241
+
242
+ function isBusy(turn: GrokBotTurnStatus): boolean {
243
+ return turn.inFlight || turn.queued > 0;
244
+ }
245
+
246
+ function joinReplies(deliveries: string[]): string | undefined {
247
+ return deliveries.length === 0 ? undefined : deliveries.join("\n\n");
248
+ }
249
+
250
+ function runningNote(name: string, status: ReplyStatus): string | undefined {
251
+ return status === "running"
252
+ ? `"${name}" is still replying. Call check with the same agent to keep waiting; a reply so far, if any, is above.`
253
+ : undefined;
254
+ }
255
+
256
+ function sleep(ms: number): Promise<void> {
257
+ return new Promise(resolve => {
258
+ setTimeout(resolve, ms);
259
+ });
260
+ }
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import { AGENT_NAME_MAX_LENGTH } from "../extension.js";
3
+ import { DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS } from "./conversation.js";
4
+
5
+ export const agentName: z.ZodOptional<z.ZodString> = z
6
+ .string()
7
+ .max(AGENT_NAME_MAX_LENGTH)
8
+ .optional()
9
+ .describe(
10
+ "The Grok Bot agent's name, as shown in the Grok Bot app. With agents configured, one of those; optional when exactly one is configured.",
11
+ );
12
+
13
+ export const waitSeconds: z.ZodDefault<z.ZodNumber> = z
14
+ .number()
15
+ .int()
16
+ .min(0)
17
+ .max(MAX_WAIT_SECONDS)
18
+ .default(DEFAULT_WAIT_SECONDS)
19
+ .describe(
20
+ `How long to wait for the reply before returning status "running" (default ${DEFAULT_WAIT_SECONDS}, max ${MAX_WAIT_SECONDS}). 0 returns after one look.`,
21
+ );
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Per-key chaining of async work. `host.kv` has no compare-and-swap, and a
3
+ * model that talks to two agents in one turn calls these tools in parallel,
4
+ * so read-modify-writes of one principal's records queue up here. The same
5
+ * chain keeps one hosted agent's sends and reads from interleaving within
6
+ * this process, so a reply attributes to the message that prompted it.
7
+ */
8
+ export class KeyedLock {
9
+ private readonly chains = new Map<string, Promise<void>>();
10
+
11
+ run<T>(key: string, task: () => Promise<T>): Promise<T> {
12
+ const previous = this.chains.get(key) ?? Promise.resolve();
13
+ const run = previous.then(task, task);
14
+ const settled = run.then(
15
+ () => undefined,
16
+ () => undefined,
17
+ );
18
+ this.chains.set(key, settled);
19
+ void settled.then(() => {
20
+ if (this.chains.get(key) === settled) {
21
+ this.chains.delete(key);
22
+ }
23
+ });
24
+ return run;
25
+ }
26
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ description: "Talk to your Grok Bot agents: when to bring one in, how to write a message it can act on alone, and how to wait for, read, and interrupt its reply."
3
+ ---
4
+
5
+ # Consulting a Grok Bot agent
6
+
7
+ Bring a Grok Bot agent in when the person set one up for the job: a specialist with its own instructions, memory, and tools, such as one that decides whether an outdoor plan survives a forecast or one that keeps a household's calendar. Answer questions you can answer yourself.
8
+
9
+ The tools below are this extension's; they appear under its mount namespace, as `<namespace>__ask` and so on. Every agent is addressed by its `agent` name, as it appears in the Grok Bot app. When exactly one agent is configured, `agent` can be omitted.
10
+
11
+ ## Write for a stranger
12
+
13
+ Your message lands in the person's own conversation with that agent, the same one they see in the app. The agent does not see this conversation, your tools, or your earlier results. Say who is asking and why, paste the facts it needs rather than referring to them, and say what you want back and in what shape. One complete message beats a back-and-forth.
14
+
15
+ ## Ask
16
+
17
+ Call `ask` with the `agent` and the `message`. It sends the message and waits up to `wait_seconds` for the agent's turn to finish. The result carries `status`, the `reply` (everything the agent sent back during that turn, in order), and `sessionId`.
18
+
19
+ - `status: "finished"`: the turn is over; `reply` is the whole answer. No `reply` means the agent finished without sending anything.
20
+ - `status: "running"`: the agent is still working. Call `check` with the same `agent` to keep waiting; whatever it had sent so far is already in `reply`.
21
+
22
+ If `earlierReplies` is present, the agent had answered earlier messages that nobody read yet; pass them on when they matter, and do not mistake them for the reply to this message.
23
+
24
+ If `created` is true, no agent of that name existed on the account and an empty one was created. Tell the person and check the spelling before asking it anything else.
25
+
26
+ If `ask` fails because an agent of that name already exists in the Grok Bot app, nothing was created and nothing was sent. Tell the person. Do not invent a different name to get around it.
27
+
28
+ If `ask` refuses because the agent is still working on an earlier message, nothing was sent. If you have already asked that agent, call `check` to read the reply, then ask again; use `interrupt` when the earlier work should stop. On first contact, `check` and `interrupt` cannot address the agent yet, so tell the person it is busy, wait for the existing turn to finish in the Grok Bot app, and retry `ask`.
29
+
30
+ ## Wait for a long reply
31
+
32
+ Call `check` with the `agent`. It returns what the agent has sent since you last read, and `status: "running"` while the turn is still going. Pass `wait_seconds: 0` for a single look. Check when you need the answer, not in a tight loop; a long task can take minutes.
33
+
34
+ ## Interrupt
35
+
36
+ Call `interrupt` with the `agent` to stop its current turn. The agent keeps its conversation, so a later `ask` continues from there.
37
+
38
+ ## Which agents
39
+
40
+ `list` returns the agents configured for you, with what each is for, and the ones you have already asked. Names outside the configured set are refused; with no set configured, any name works, and an unknown name creates an agent.
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "../../../tools.js";
3
+ import type { ToolDefinition } from "../../../types.js";
4
+ import extension from "../extension.js";
5
+ import { ask as askAgent } from "../lib/conversation.js";
6
+ import { agentName, waitSeconds } from "../lib/inputs.js";
7
+
8
+ const ask: ToolDefinition = defineTool({
9
+ description:
10
+ 'Send a message to one of your Grok Bot agents and wait for its reply. The message lands in your own conversation with that agent, which does not see this one, so include everything it needs. Long turns return status "running": call check to keep waiting.',
11
+ effect: "write",
12
+ needsApproval: () => extension.config.needsApproval,
13
+ inputSchema: z.object({
14
+ agent: agentName,
15
+ message: z
16
+ .string()
17
+ .min(1)
18
+ .describe(
19
+ "What to tell or ask the agent. Self-contained: who is asking, the facts it needs, and what you want back.",
20
+ ),
21
+ wait_seconds: waitSeconds,
22
+ }),
23
+ async execute(input, ctx) {
24
+ return askAgent(ctx, {
25
+ agent: input.agent,
26
+ message: input.message,
27
+ waitSeconds: input.wait_seconds,
28
+ });
29
+ },
30
+ });
31
+
32
+ export default ask;
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "../../../tools.js";
3
+ import type { ToolDefinition } from "../../../types.js";
4
+ import { check as checkAgent } from "../lib/conversation.js";
5
+ import { agentName, waitSeconds } from "../lib/inputs.js";
6
+
7
+ const check: ToolDefinition = defineTool({
8
+ description:
9
+ 'Wait for, or poll, the reply of a Grok Bot agent you asked: everything it has sent since you last read, and whether it is still working. Returns status "running" to keep waiting; pass wait_seconds 0 for a single look.',
10
+ // Reading advances the caller's cursor, which their other sessions read
11
+ // back, so a dry run answers this instead of running it.
12
+ effect: "write",
13
+ inputSchema: z.object({
14
+ agent: agentName,
15
+ wait_seconds: waitSeconds,
16
+ }),
17
+ async execute(input, ctx) {
18
+ return checkAgent(ctx, {
19
+ agent: input.agent,
20
+ waitSeconds: input.wait_seconds,
21
+ });
22
+ },
23
+ });
24
+
25
+ export default check;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "../../../tools.js";
3
+ import type { ToolDefinition } from "../../../types.js";
4
+ import { interrupt as interruptAgent } from "../lib/conversation.js";
5
+ import { agentName } from "../lib/inputs.js";
6
+
7
+ const interrupt: ToolDefinition = defineTool({
8
+ description:
9
+ "Stop what a Grok Bot agent you asked is doing right now. It keeps its conversation; ask it again to continue.",
10
+ effect: "write",
11
+ inputSchema: z.object({ agent: agentName }),
12
+ async execute(input, ctx) {
13
+ return interruptAgent(ctx, { agent: input.agent });
14
+ },
15
+ });
16
+
17
+ export default interrupt;
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "../../../tools.js";
3
+ import type { ToolDefinition } from "../../../types.js";
4
+ import extension from "../extension.js";
5
+ import { listContacts } from "../lib/contacts.js";
6
+
7
+ const list: ToolDefinition = defineTool({
8
+ description:
9
+ "List the Grok Bot agents you can talk to: the ones configured for this agent, with what each is for, and the ones you have already asked, most recent first.",
10
+ effect: "read",
11
+ inputSchema: z.object({}),
12
+ async execute(_input, ctx) {
13
+ const contacts = await listContacts(ctx);
14
+ return {
15
+ configured: extension.config.agents ?? [],
16
+ contacted: contacts.map(contact => ({
17
+ name: contact.name,
18
+ sessionId: contact.sessionId,
19
+ firstContactAt: contact.firstContactAt,
20
+ lastContactAt: contact.lastContactAt,
21
+ })),
22
+ };
23
+ },
24
+ });
25
+
26
+ export default list;
@@ -17,7 +17,11 @@ import { lookupSessionContinuation, runChat } from "./chat-client.js";
17
17
  import { ensureCursorLogin } from "./cli-cursor.js";
18
18
  import { resolveDeployAuth } from "./cli-deploy.js";
19
19
  import { resolveApiKey } from "./cursor/credentials.js";
20
- import { type AgentkitSessionRuns, DeployApiError } from "./deploy-client.js";
20
+ import {
21
+ type AgentkitSessionEventPoll,
22
+ type AgentkitSessionRuns,
23
+ DeployApiError,
24
+ } from "./deploy-client.js";
21
25
  import { CLI_COMMAND_NAME, PACKAGE_NAME } from "./distribution.js";
22
26
  import {
23
27
  discoverEvals,
@@ -48,7 +52,7 @@ import {
48
52
  resolveTemplate,
49
53
  } from "./init-project.js";
50
54
  import { offerInstallCursorSkills } from "./install-cursor-skills.js";
51
- import { rejectV2ForLegacyCommand } from "./legacy-command-guard.js";
55
+ import { rejectV2ForLegacyCommand, v2HostedVerifyHint } from "./legacy-command-guard.js";
52
56
  import { runLogsTail, sanitizeCustomerError } from "./logs-client.js";
53
57
  import { mapPool } from "./map-pool.js";
54
58
  import { openBrowser } from "./open-browser.js";
@@ -750,6 +754,9 @@ async function cmdHostedSession(options: AxCliOptions): Promise<number | "fallba
750
754
  componentKey: trimNonEmpty(options.componentKey),
751
755
  });
752
756
  console.log(JSON.stringify(accepted, null, 2));
757
+ if (accepted.sessionId === undefined) {
758
+ process.stderr.write(`${v2HostedVerifyHint(slug)}\n`);
759
+ }
753
760
  return 0;
754
761
  } catch (error) {
755
762
  if (error instanceof DeployApiError && error.status === 404) {
@@ -811,7 +818,15 @@ export async function cmdCall(options: AxCliOptions): Promise<number> {
811
818
  }
812
819
  }
813
820
 
814
- const target = await resolveTarget(options);
821
+ let target: ResolvedAgentTarget;
822
+ try {
823
+ target = await resolveTarget(options);
824
+ } catch (error) {
825
+ process.stderr.write(
826
+ `${sanitizeCustomerError(error instanceof Error ? error.message : String(error))}\n`,
827
+ );
828
+ return 1;
829
+ }
815
830
  try {
816
831
  const body: { input: unknown; sessionId?: string } = { input };
817
832
  if (options.sessionId !== undefined) {
@@ -1906,7 +1921,13 @@ export async function cmdSessions(options: AxCliOptions): Promise<number> {
1906
1921
  }
1907
1922
  }
1908
1923
 
1909
- function formatHostedSessionRuns(sessionId: string, runs: AgentkitSessionRuns): string {
1924
+ export const HOSTED_RUNS_LAG_NOTE = "Turn running; runs may lag behind events.";
1925
+
1926
+ function formatHostedSessionRuns(
1927
+ sessionId: string,
1928
+ runs: AgentkitSessionRuns,
1929
+ events?: AgentkitSessionEventPoll,
1930
+ ): string {
1910
1931
  const lines = [`Session ${sessionId}`, `Hosted executions: ${runs.executions.length}`];
1911
1932
  for (const run of runs.executions) {
1912
1933
  const failure = run.error?.message ?? run.message ?? "";
@@ -1916,6 +1937,17 @@ function formatHostedSessionRuns(sessionId: string, runs: AgentkitSessionRuns):
1916
1937
  ...run.logs.map(log => ` ${log.line}`),
1917
1938
  );
1918
1939
  }
1940
+ const latestType = events?.events.at(-1)?.type;
1941
+ if (events !== undefined && events.events.length > 0) {
1942
+ const latest = latestType === undefined ? "" : ` (latest ${latestType})`;
1943
+ lines.push("", `Events: ${events.events.length}${latest}`);
1944
+ }
1945
+ const turnRunning =
1946
+ runs.executions.at(-1)?.turnStatus === "running" ||
1947
+ (runs.executions.length === 0 && events?.execution?.turnStatus === "running");
1948
+ if (turnRunning && (events?.events.length ?? 0) > 0) {
1949
+ lines.push(HOSTED_RUNS_LAG_NOTE);
1950
+ }
1919
1951
  return `${lines.join("\n")}\n`;
1920
1952
  }
1921
1953
 
@@ -1933,19 +1965,32 @@ async function readHostedSessionRuns(
1933
1965
  return auth;
1934
1966
  }
1935
1967
  try {
1968
+ const slug = resolveProdSlug(options);
1936
1969
  const runs = await auth.client.getAgentkitSessionRuns({
1937
1970
  teamId: auth.teamId,
1938
- slug: resolveProdSlug(options),
1971
+ slug,
1939
1972
  sessionId,
1940
1973
  });
1941
1974
  if (options.rawEvents === true || trimNonEmpty(options.out) !== undefined) {
1942
1975
  process.stderr.write("--events and --out need an engine trajectory.\n");
1943
1976
  return 2;
1944
1977
  }
1978
+ const latest = runs.executions.at(-1);
1979
+ const events =
1980
+ runs.executions.length === 0 || latest?.turnStatus === "running"
1981
+ ? await auth.client
1982
+ .getAgentkitSessionEvents({
1983
+ teamId: auth.teamId,
1984
+ slug,
1985
+ sessionId,
1986
+ afterEventIndex: -1,
1987
+ })
1988
+ .catch(() => undefined)
1989
+ : undefined;
1945
1990
  process.stdout.write(
1946
1991
  options.json === true
1947
1992
  ? `${JSON.stringify({ sessionId, ...runs }, null, 2)}\n`
1948
- : formatHostedSessionRuns(sessionId, runs),
1993
+ : formatHostedSessionRuns(sessionId, runs, events),
1949
1994
  );
1950
1995
  return 0;
1951
1996
  } catch (error) {
@@ -1988,7 +2033,7 @@ export async function cmdSession(
1988
2033
  }
1989
2034
  if (sessionId === undefined || sessionId.trim() === "") {
1990
2035
  process.stderr.write(
1991
- `Usage: ${CLI_COMMAND_NAME} session <sessionId> [--url | --prod] [--json | --text | --events] [--out <file.ndjson>]\n` +
2036
+ `Usage: ${CLI_COMMAND_NAME} session <ses_> [--url | --prod] [--slug <slug>] [--json | --text | --events] [--out <file.ndjson>]\n` +
1992
2037
  ` or: ${CLI_COMMAND_NAME} session --prod [<sessionId>] --slug <slug> --message "…" [--dry-run] [--as-of <instant>]\n`,
1993
2038
  );
1994
2039
  return 2;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `agent-sdk deploy | deployments | deployment | stop | delete | rotate-token |
2
+ * `agent-sdk deploy | deployments | deployment | stop | rollback | delete | rotate-token |
3
3
  * secrets set|list|unset` — Heroku-style deploys
4
4
  * onto Cursor's managed agent-serve hosting.
5
5
  *
@@ -1787,12 +1787,45 @@ const RELEASE_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]
1787
1787
  export async function cmdUpgrade(
1788
1788
  args: { slug: string | undefined; release: string | undefined },
1789
1789
  options: DeployCliOptions,
1790
+ ): Promise<number> {
1791
+ return cmdPinRelease(args, options, {
1792
+ usage: `Usage: ${CLI} upgrade <slug> [--release <id|version>] [--team <id>] [--json]\n`,
1793
+ pin: (client, request) => client.upgradeAgentkitInstall(request),
1794
+ success: (slug, releaseId) => `${slug} now runs release ${releaseId}.\n`,
1795
+ });
1796
+ }
1797
+
1798
+ export async function cmdRollback(
1799
+ args: { slug: string | undefined; release: string | undefined },
1800
+ options: DeployCliOptions,
1801
+ ): Promise<number> {
1802
+ return cmdPinRelease(args, options, {
1803
+ usage: `Usage: ${CLI} rollback <slug> [--release <id|version>] [--team <id>] [--json]\n`,
1804
+ pin: (client, request) => client.rollbackAgentkitInstall(request),
1805
+ success: (slug, releaseId) => `${slug} rolled back to release ${releaseId}.\n`,
1806
+ });
1807
+ }
1808
+
1809
+ async function cmdPinRelease(
1810
+ args: { slug: string | undefined; release: string | undefined },
1811
+ options: DeployCliOptions,
1812
+ pin: {
1813
+ usage: string;
1814
+ pin: (
1815
+ client: AgentServeDeployClient,
1816
+ request: {
1817
+ teamId: number;
1818
+ slug: string;
1819
+ releaseId?: string;
1820
+ version?: string;
1821
+ },
1822
+ ) => Promise<string>;
1823
+ success: (slug: string, releaseId: string) => string;
1824
+ },
1790
1825
  ): Promise<number> {
1791
1826
  const { slug, release } = args;
1792
1827
  if (slug === undefined || slug === "") {
1793
- (options.err ?? ((text: string) => void process.stderr.write(text)))(
1794
- `Usage: ${CLI} upgrade <slug> [--release <id|version>] [--team <id>] [--json]\n`,
1795
- );
1828
+ (options.err ?? ((text: string) => void process.stderr.write(text)))(pin.usage);
1796
1829
  return 1;
1797
1830
  }
1798
1831
  const ctx = await prepare(options);
@@ -1802,7 +1835,7 @@ export async function cmdUpgrade(
1802
1835
  const selector = release?.trim() ?? "";
1803
1836
  let releaseId: string;
1804
1837
  try {
1805
- releaseId = await ctx.client.upgradeAgentkitInstall({
1838
+ releaseId = await pin.pin(ctx.client, {
1806
1839
  teamId: ctx.teamId,
1807
1840
  slug,
1808
1841
  ...(selector === ""
@@ -1817,7 +1850,7 @@ export async function cmdUpgrade(
1817
1850
  if (ctx.json) {
1818
1851
  ctx.out(`${JSON.stringify({ releaseId }, null, 2)}\n`);
1819
1852
  } else {
1820
- ctx.out(`${slug} now runs release ${releaseId}.\n`);
1853
+ ctx.out(pin.success(slug, releaseId));
1821
1854
  }
1822
1855
  return 0;
1823
1856
  }
@@ -15,6 +15,7 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/
15
15
  import type { OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
16
16
  import { isCursorAccountTransport } from "../types.js";
17
17
  import { resolveDeployAuth } from "./cli-deploy.js";
18
+ import { resolveConnectionEnvTemplates } from "./connection-env.js";
18
19
  import { CursorBackendClient } from "./cursor/backend-client.js";
19
20
  import { authorizeCursorAccountConnectors } from "./cursor-account-mcp-auth.js";
20
21
  import { deploymentServiceAccountId } from "./deploy-client.js";
@@ -76,7 +77,7 @@ export async function cmdMcpOauth(options: McpOauthCliOptions): Promise<number>
76
77
  return 1;
77
78
  }
78
79
 
79
- const transport = connection.transport;
80
+ const transport = resolveConnectionEnvTemplates(connection.transport);
80
81
  if (isCursorAccountTransport(transport)) {
81
82
  return cmdMcpOauthCursorAccount(options, {
82
83
  servers: transport.servers,