@cursor/july 0.1.113 → 0.1.114

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 (229) hide show
  1. package/dist/docs/404.html +2 -2
  2. package/dist/docs/assets/{app.CAeK13eM.js → app.BqkJwOZ-.js} +4 -4
  3. package/dist/docs/assets/chunks/@localSearchIndexroot.BnSgidYE.js +1 -0
  4. package/dist/docs/assets/chunks/{VPLocalSearchBox.C9LbPHod.js → VPLocalSearchBox.BJAi2KiV.js} +1 -1
  5. package/dist/docs/assets/chunks/{arc.CmMq2zmS.js → arc.BZpXTgvV.js} +1 -1
  6. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.CCXB8Uj5.js → architectureDiagram-Q4EWVU46.WYI-7F-Y.js} +1 -1
  7. package/dist/docs/assets/chunks/{baseUniq.CyQo6eLe.js → baseUniq.CZaUPpg0.js} +1 -1
  8. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.JYq6w91N.js → blockDiagram-DXYQGD6D.D6UES2pD.js} +1 -1
  9. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.BRV8GPJJ.js → c4Diagram-AHTNJAMY.cwebIe4i.js} +1 -1
  10. package/dist/docs/assets/chunks/channel.DdM5EfNW.js +1 -0
  11. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.Bv4ooYQR.js → chunk-4BX2VUAB.fVyFnjxg.js} +1 -1
  12. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.t4JtKPcj.js → chunk-4TB4RGXK.BanufG1c.js} +1 -1
  13. package/dist/docs/assets/chunks/{chunk-55IACEB6.34lCHj9Y.js → chunk-55IACEB6.VaSMz5-2.js} +1 -1
  14. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.BSwrPNrt.js → chunk-EDXVE4YY.CN2diZOM.js} +1 -1
  15. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.Beeun-R-.js → chunk-FMBD7UC4.g4ivypu3.js} +1 -1
  16. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.BUUFUcJc.js → chunk-OYMX7WX6.GZXKn9JJ.js} +1 -1
  17. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.B2XjHzN_.js → chunk-QZHKN3VN.itXxJZCd.js} +1 -1
  18. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.CLYG8znk.js → chunk-YZCP3GAM.-rw2GfvX.js} +1 -1
  19. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CjfGHeg2.js +1 -0
  20. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CjfGHeg2.js +1 -0
  21. package/dist/docs/assets/chunks/clone.wSOICb_f.js +1 -0
  22. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.DVEa6fZp.js → cose-bilkent-S5V4N54A.CmaI5br0.js} +1 -1
  23. package/dist/docs/assets/chunks/{dagre-KV5264BT.C9PZQK-S.js → dagre-KV5264BT.4wY9S4Kt.js} +1 -1
  24. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.DoN0uv3Y.js → diagram-5BDNPKRD.Pc3c0u9W.js} +1 -1
  25. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Czv3duqx.js → diagram-G4DWMVQ6.CYrWz-nj.js} +1 -1
  26. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BinJ5kWb.js → diagram-MMDJMWI5.Bgj5hukb.js} +1 -1
  27. package/dist/docs/assets/chunks/{diagram-TYMM5635.DW326M4K.js → diagram-TYMM5635.DGMEXalS.js} +1 -1
  28. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.U2pR_OA7.js → erDiagram-SMLLAGMA.GepTV9Im.js} +1 -1
  29. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.ByWJXeYK.js → flowDiagram-DWJPFMVM.DVKywg3j.js} +1 -1
  30. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.OquF0Rtg.js → ganttDiagram-T4ZO3ILL.C7qt9Mlo.js} +1 -1
  31. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.Bpn01P7X.js → gitGraphDiagram-UUTBAWPF.U30_r82P.js} +1 -1
  32. package/dist/docs/assets/chunks/{graph.CNRB6ETL.js → graph.CyyMyAWv.js} +1 -1
  33. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.CqhknMWi.js → infoDiagram-42DDH7IO.Dn9ACW3y.js} +1 -1
  34. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.C6xpR2af.js → ishikawaDiagram-UXIWVN3A.DlIdIGOA.js} +1 -1
  35. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.Cg5f7oB3.js → journeyDiagram-VCZTEJTY.DZj4vy4E.js} +1 -1
  36. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.Cx9YTwlU.js → kanban-definition-6JOO6SKY.Dl63eMUV.js} +1 -1
  37. package/dist/docs/assets/chunks/{layout.ljS-wFtK.js → layout.BLHZLWPH.js} +1 -1
  38. package/dist/docs/assets/chunks/{linear.jSxNrsFC.js → linear.aXKGKaNw.js} +1 -1
  39. package/dist/docs/assets/chunks/{min.Cum8AlQw.js → min.zWnFcpcc.js} +1 -1
  40. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.BLiysLpe.js → mindmap-definition-QFDTVHPH.Qs4MQBea.js} +1 -1
  41. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BoIDyuKF.js → pieDiagram-DEJITSTG.BmPHgsk7.js} +1 -1
  42. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.DLkpDytR.js → quadrantDiagram-34T5L4WZ.D5MQ3gwA.js} +1 -1
  43. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DqTVqSu2.js → requirementDiagram-MS252O5E.CkdUFrO7.js} +1 -1
  44. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.CG_6FF7j.js → sankeyDiagram-XADWPNL6.KZrljrAV.js} +1 -1
  45. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.BIp9602K.js → sequenceDiagram-FGHM5R23.XMoEW-Lx.js} +1 -1
  46. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.COSXsD9I.js → stateDiagram-FHFEXIEX.BmTzePLj.js} +1 -1
  47. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.Cu5X28zZ.js +1 -0
  48. package/dist/docs/assets/chunks/{theme.CXJ7PNwy.js → theme.BfQzpxsg.js} +2 -2
  49. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.CXdVqkLq.js → timeline-definition-GMOUNBTQ.Dug0oamp.js} +1 -1
  50. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.CZxGuc4r.js → vennDiagram-DHZGUBPP.BOTHrEFu.js} +1 -1
  51. package/dist/docs/assets/chunks/{wardley-RL74JXVD.3oVgfqQk.js → wardley-RL74JXVD.DXy2i1LS.js} +1 -1
  52. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.6_irCgGJ.js → wardleyDiagram-NUSXRM2D.CoXKdfi6.js} +1 -1
  53. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.TRPe92m3.js → xychartDiagram-5P7HB3ND.DXoSCjAW.js} +1 -1
  54. package/dist/docs/assets/{deployment.md.D2jQZuFx.js → deployment.md.D2YX7u_I.js} +1 -1
  55. package/dist/docs/assets/{guides_agent-to-agent.md.CD4T5FIl.js → guides_agent-to-agent.md.C6kPY8nu.js} +2 -2
  56. package/dist/docs/assets/{guides_cloud-agents.md.Cp1O3u-X.js → guides_cloud-agents.md.BPJqTZjT.js} +1 -1
  57. package/dist/docs/assets/{guides_grokbot-agents.md.CMhZNdEU.js → guides_grokbot-agents.md.CzV715v8.js} +1 -1
  58. package/dist/docs/assets/guides_hooks.md.BT9GLwEp.js +50 -0
  59. package/dist/docs/assets/guides_hooks.md.BT9GLwEp.lean.js +1 -0
  60. package/dist/docs/assets/{guides_jev.md.F5fAkkfN.js → guides_jev.md.DeSCqMaO.js} +6 -44
  61. package/dist/docs/assets/guides_jev.md.DeSCqMaO.lean.js +1 -0
  62. package/dist/docs/assets/reference_agent-config.md.BRxAlnRy.js +36 -0
  63. package/dist/docs/assets/{reference_agent-config.md.DGPyw7ms.lean.js → reference_agent-config.md.BRxAlnRy.lean.js} +1 -1
  64. package/dist/docs/assets/reference_artifacts.md.KRX0sAdt.js +18 -0
  65. package/dist/docs/assets/reference_artifacts.md.KRX0sAdt.lean.js +1 -0
  66. package/dist/docs/assets/reference_channels.md.DZr14vm7.js +23 -0
  67. package/dist/docs/assets/reference_channels.md.DZr14vm7.lean.js +1 -0
  68. package/dist/docs/assets/{reference_connections.md.Je9dMsdd.js → reference_connections.md.DJGUCxrr.js} +18 -30
  69. package/dist/docs/assets/{reference_connections.md.Je9dMsdd.lean.js → reference_connections.md.DJGUCxrr.lean.js} +1 -1
  70. package/dist/docs/assets/{reference_evals.md.DNJzM_yf.js → reference_evals.md.C6umwNC6.js} +6 -7
  71. package/dist/docs/assets/reference_evals.md.C6umwNC6.lean.js +1 -0
  72. package/dist/docs/assets/{reference_extensions.md.Cv5aLCz_.js → reference_extensions.md.DbNYu-DP.js} +3 -3
  73. package/dist/docs/assets/{reference_extensions.md.Cv5aLCz_.lean.js → reference_extensions.md.DbNYu-DP.lean.js} +1 -1
  74. package/dist/docs/assets/reference_hooks.md.BfOkhTU0.js +45 -0
  75. package/dist/docs/assets/{reference_hooks.md.B7uzNENk.lean.js → reference_hooks.md.BfOkhTU0.lean.js} +1 -1
  76. package/dist/docs/assets/reference_http-api.md.DdwtBeCj.js +11 -0
  77. package/dist/docs/assets/{reference_http-api.md.CduHavZ2.lean.js → reference_http-api.md.DdwtBeCj.lean.js} +1 -1
  78. package/dist/docs/assets/reference_instructions.md.B2mcIzT6.js +14 -0
  79. package/dist/docs/assets/reference_instructions.md.B2mcIzT6.lean.js +1 -0
  80. package/dist/docs/assets/reference_playground.md.CyrQD_n3.js +1 -0
  81. package/dist/docs/assets/reference_playground.md.CyrQD_n3.lean.js +1 -0
  82. package/dist/docs/assets/reference_project-layout.md.BEMzxAkq.js +19 -0
  83. package/dist/docs/assets/{reference_project-layout.md.BGhgpy9V.lean.js → reference_project-layout.md.BEMzxAkq.lean.js} +1 -1
  84. package/dist/docs/assets/reference_prompt.md.BFrqjHFL.js +9 -0
  85. package/dist/docs/assets/reference_prompt.md.BFrqjHFL.lean.js +1 -0
  86. package/dist/docs/assets/reference_schedules.md.BB9N3tRR.js +47 -0
  87. package/dist/docs/assets/reference_schedules.md.BB9N3tRR.lean.js +1 -0
  88. package/dist/docs/assets/reference_sessions.md.BBp-GIt-.js +1 -0
  89. package/dist/docs/assets/{reference_sessions.md.1_6Vyv7x.lean.js → reference_sessions.md.BBp-GIt-.lean.js} +1 -1
  90. package/dist/docs/assets/reference_skills.md.BVmi3UJ_.js +15 -0
  91. package/dist/docs/assets/{reference_skills.md.DjQkRefx.lean.js → reference_skills.md.BVmi3UJ_.lean.js} +1 -1
  92. package/dist/docs/assets/reference_subagents.md.DRoRy2Uj.js +10 -0
  93. package/dist/docs/assets/{reference_subagents.md.Dl16gcBj.lean.js → reference_subagents.md.DRoRy2Uj.lean.js} +1 -1
  94. package/dist/docs/assets/{reference_tools.md.B1dH1lpa.js → reference_tools.md.CgocLDX1.js} +9 -6
  95. package/dist/docs/assets/{reference_tools.md.B1dH1lpa.lean.js → reference_tools.md.CgocLDX1.lean.js} +1 -1
  96. package/dist/docs/assets/troubleshooting.md.HY95rCCz.js +1 -0
  97. package/dist/docs/building-with-agents.html +35 -35
  98. package/dist/docs/deployment.html +37 -37
  99. package/dist/docs/deployment.md +1 -1
  100. package/dist/docs/evals.html +35 -35
  101. package/dist/docs/guides/agent-to-agent.html +38 -38
  102. package/dist/docs/guides/agent-to-agent.md +11 -12
  103. package/dist/docs/guides/bitbucket.html +35 -35
  104. package/dist/docs/guides/cloud-agents.html +36 -36
  105. package/dist/docs/guides/cloud-agents.md +1 -1
  106. package/dist/docs/guides/convert-automation.html +35 -35
  107. package/dist/docs/guides/github.html +35 -35
  108. package/dist/docs/guides/gitlab.html +35 -35
  109. package/dist/docs/guides/grokbot-agents.html +37 -37
  110. package/dist/docs/guides/grokbot-agents.md +1 -1
  111. package/dist/docs/guides/hooks.html +109 -0
  112. package/dist/docs/guides/hooks.md +111 -0
  113. package/dist/docs/guides/improve.html +35 -35
  114. package/dist/docs/guides/jev.html +42 -80
  115. package/dist/docs/guides/jev.md +22 -79
  116. package/dist/docs/guides/mcp-oauth.html +36 -36
  117. package/dist/docs/guides/opentelemetry.html +35 -35
  118. package/dist/docs/guides/slack.html +35 -35
  119. package/dist/docs/guides/webhooks.html +35 -35
  120. package/dist/docs/hashmap.json +1 -1
  121. package/dist/docs/hillclimbing.html +35 -35
  122. package/dist/docs/index.html +35 -35
  123. package/dist/docs/llms-full.txt +993 -1303
  124. package/dist/docs/llms.txt +8 -7
  125. package/dist/docs/quickstart.html +35 -35
  126. package/dist/docs/reference/agent-config.html +42 -46
  127. package/dist/docs/reference/agent-config.md +48 -81
  128. package/dist/docs/reference/artifacts.html +39 -40
  129. package/dist/docs/reference/artifacts.md +71 -70
  130. package/dist/docs/reference/channels.html +41 -61
  131. package/dist/docs/reference/channels.md +134 -201
  132. package/dist/docs/reference/cli.html +35 -35
  133. package/dist/docs/reference/connections.html +54 -66
  134. package/dist/docs/reference/connections.md +92 -128
  135. package/dist/docs/reference/evals.html +42 -43
  136. package/dist/docs/reference/evals.md +42 -50
  137. package/dist/docs/reference/extensions.html +38 -38
  138. package/dist/docs/reference/extensions.md +9 -13
  139. package/dist/docs/reference/hooks.html +39 -67
  140. package/dist/docs/reference/hooks.md +72 -146
  141. package/dist/docs/reference/http-api.html +39 -39
  142. package/dist/docs/reference/http-api.md +137 -161
  143. package/dist/docs/reference/instructions.html +39 -39
  144. package/dist/docs/reference/instructions.md +21 -36
  145. package/dist/docs/reference/playground.html +36 -36
  146. package/dist/docs/reference/playground.md +26 -43
  147. package/dist/docs/reference/project-layout.html +38 -38
  148. package/dist/docs/reference/project-layout.md +12 -17
  149. package/dist/docs/reference/prompt.html +42 -42
  150. package/dist/docs/reference/prompt.md +18 -13
  151. package/dist/docs/reference/schedules.html +56 -91
  152. package/dist/docs/reference/schedules.md +52 -99
  153. package/dist/docs/reference/sessions.html +36 -36
  154. package/dist/docs/reference/sessions.md +36 -40
  155. package/dist/docs/reference/skills.html +38 -38
  156. package/dist/docs/reference/skills.md +15 -26
  157. package/dist/docs/reference/subagents.html +38 -38
  158. package/dist/docs/reference/subagents.md +20 -30
  159. package/dist/docs/reference/tools.html +44 -41
  160. package/dist/docs/reference/tools.md +45 -64
  161. package/dist/docs/templates/agentic-owners.html +35 -35
  162. package/dist/docs/templates/pr-autofixer.html +35 -35
  163. package/dist/docs/templates/security-reviewer.html +35 -35
  164. package/dist/docs/templates/thermo-quality-review.html +35 -35
  165. package/dist/docs/templates/thermo-review.html +35 -35
  166. package/dist/docs/templates/triage.html +35 -35
  167. package/dist/docs/troubleshooting.html +36 -36
  168. package/dist/docs/troubleshooting.md +1 -1
  169. package/dist/playground/assets/{index-DSMAewbx.css → index-C61EWMBK.css} +1 -1
  170. package/dist/playground/index.html +2 -2
  171. package/docs/deployment.md +1 -1
  172. package/docs/guides/agent-to-agent.md +11 -12
  173. package/docs/guides/cloud-agents.md +1 -1
  174. package/docs/guides/grokbot-agents.md +1 -1
  175. package/docs/guides/hooks.md +116 -0
  176. package/docs/guides/jev.md +23 -80
  177. package/docs/reference/agent-config.md +48 -81
  178. package/docs/reference/artifacts.md +72 -71
  179. package/docs/reference/channels.md +135 -202
  180. package/docs/reference/connections.md +93 -129
  181. package/docs/reference/evals.md +43 -51
  182. package/docs/reference/extensions.md +9 -13
  183. package/docs/reference/hooks.md +72 -146
  184. package/docs/reference/http-api.md +137 -161
  185. package/docs/reference/instructions.md +22 -37
  186. package/docs/reference/playground.md +26 -43
  187. package/docs/reference/project-layout.md +12 -17
  188. package/docs/reference/prompt.md +20 -15
  189. package/docs/reference/schedules.md +52 -99
  190. package/docs/reference/sessions.md +36 -40
  191. package/docs/reference/skills.md +15 -26
  192. package/docs/reference/subagents.md +20 -30
  193. package/docs/reference/tools.md +45 -64
  194. package/docs/troubleshooting.md +1 -1
  195. package/package.json +1 -1
  196. package/dist/docs/assets/chunks/@localSearchIndexroot.Ck9E52Ls.js +0 -1
  197. package/dist/docs/assets/chunks/channel.BHiYmnZ4.js +0 -1
  198. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.Degh8l90.js +0 -1
  199. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.Degh8l90.js +0 -1
  200. package/dist/docs/assets/chunks/clone.BIywbczV.js +0 -1
  201. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.qrxrbFsX.js +0 -1
  202. package/dist/docs/assets/guides_jev.md.F5fAkkfN.lean.js +0 -1
  203. package/dist/docs/assets/reference_agent-config.md.DGPyw7ms.js +0 -40
  204. package/dist/docs/assets/reference_artifacts.md.Bu_4HmsD.js +0 -19
  205. package/dist/docs/assets/reference_artifacts.md.Bu_4HmsD.lean.js +0 -1
  206. package/dist/docs/assets/reference_channels.md.nFWbzAic.js +0 -43
  207. package/dist/docs/assets/reference_channels.md.nFWbzAic.lean.js +0 -1
  208. package/dist/docs/assets/reference_evals.md.DNJzM_yf.lean.js +0 -1
  209. package/dist/docs/assets/reference_hooks.md.B7uzNENk.js +0 -73
  210. package/dist/docs/assets/reference_http-api.md.CduHavZ2.js +0 -11
  211. package/dist/docs/assets/reference_instructions.md.CU1My5My.js +0 -14
  212. package/dist/docs/assets/reference_instructions.md.CU1My5My.lean.js +0 -1
  213. package/dist/docs/assets/reference_playground.md.Ch2d0Iqi.js +0 -1
  214. package/dist/docs/assets/reference_playground.md.Ch2d0Iqi.lean.js +0 -1
  215. package/dist/docs/assets/reference_project-layout.md.BGhgpy9V.js +0 -19
  216. package/dist/docs/assets/reference_prompt.md.Ccp0R53H.js +0 -1
  217. package/dist/docs/assets/reference_prompt.md.Ccp0R53H.lean.js +0 -1
  218. package/dist/docs/assets/reference_schedules.md.B2Nm6FaD.js +0 -82
  219. package/dist/docs/assets/reference_schedules.md.B2Nm6FaD.lean.js +0 -1
  220. package/dist/docs/assets/reference_sessions.md.1_6Vyv7x.js +0 -1
  221. package/dist/docs/assets/reference_skills.md.DjQkRefx.js +0 -15
  222. package/dist/docs/assets/reference_subagents.md.Dl16gcBj.js +0 -10
  223. package/dist/docs/assets/troubleshooting.md.mnfFG2Em.js +0 -1
  224. /package/dist/docs/assets/{deployment.md.D2jQZuFx.lean.js → deployment.md.D2YX7u_I.lean.js} +0 -0
  225. /package/dist/docs/assets/{guides_agent-to-agent.md.CD4T5FIl.lean.js → guides_agent-to-agent.md.C6kPY8nu.lean.js} +0 -0
  226. /package/dist/docs/assets/{guides_cloud-agents.md.Cp1O3u-X.lean.js → guides_cloud-agents.md.BPJqTZjT.lean.js} +0 -0
  227. /package/dist/docs/assets/{guides_grokbot-agents.md.CMhZNdEU.lean.js → guides_grokbot-agents.md.CzV715v8.lean.js} +0 -0
  228. /package/dist/docs/assets/{troubleshooting.md.mnfFG2Em.lean.js → troubleshooting.md.HY95rCCz.lean.js} +0 -0
  229. /package/dist/playground/assets/{index-De_lpFxE.js → index-CrMWlgUU.js} +0 -0
@@ -5,18 +5,16 @@ description: "Observe-only subscribers to the session event stream: audit logs,
5
5
 
6
6
  # Hooks
7
7
 
8
- A hook subscribes to the session event stream and runs a side effect
9
- after each event is recorded: an audit line, a metric, a copy of the
10
- transcript in your own store, or derived state for later turns. Hooks
11
- run in the serving process for every session of the agent, on local and
12
- cloud runtime turns alike.
13
-
14
- Hooks observe. They can't change the turn, the prompt, or the reply, and
15
- a handler that throws is logged and skipped. Treat the event as
16
- read-only; later subscribers see the same object. That makes hooks safe
17
- to add to a production agent, and the wrong tool for anything that must
18
- happen before the model runs or must fail a turn; see
19
- [When not to use a hook](#when-not-to-use-a-hook).
8
+ A hook subscribes to selected session events and can run a side effect
9
+ after each matching event is recorded: an audit line, a metric, a
10
+ transcript copy, or derived state. Hooks run for every session of the
11
+ agent, on local and cloud turns alike. They cannot change the turn, the
12
+ prompt, or the reply; a handler that throws is logged and skipped.
13
+
14
+ Treat the event as read-only. Later subscribers see the same object.
15
+ That makes hooks safe to add to a production agent, and the wrong
16
+ surface for anything that must run before the model or must fail a
17
+ turn; see [Hook boundaries](#hook-boundaries).
20
18
 
21
19
  `defineHook` is unrelated to
22
20
  [Cursor Agent hooks](https://cursor.com/docs/agent/hooks), the
@@ -65,95 +63,54 @@ later sessions to read. Delete the file to opt out.
65
63
  ## Events and payloads
66
64
 
67
65
  Keys are event types from the
68
- [event vocabulary](./sessions.md#which-events-can-i-stream), or `"*"`
66
+ [event vocabulary](./sessions.md#stream-events), or `"*"`
69
67
  for every event. A typed key narrows `event.data`; a `"*"` handler
70
68
  receives the union, so switch on `event.type`. Every event carries the
71
69
  stream envelope `{ type, index, sessionId, turnId?, at, data }`, with
72
- `turnId` set on turn-scoped events.
73
-
74
- The payloads hooks read most often:
70
+ `turnId` set on turn-scoped events. Skip `*.appended` deltas when you
71
+ want the final text; `message.completed` already has it.
75
72
 
76
73
  | Event | `event.data` |
77
74
  | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
78
75
  | `message.received` | `{ text }` |
79
76
  | `turn.completed` | `{ result?, usage?, cost? }`. `usage` has `inputTokens`, `outputTokens`, `cacheReadTokens`, `cacheWriteTokens`, and optional `reasoningTokens`. `cost` has `totalUsd` and the `model` it was priced against |
80
- | `turn.failed` | `{ message }` |
81
- | `actions.requested` | `{ calls: [{ callId, toolName, args? }] }`. A call with `parentCallId` belongs to a subagent |
82
- | `action.result` | `{ callId, toolName, output?, isError, stubbed? }`. `stubbed` means a dry-run session answered a write without running it |
77
+ | `turn.failed` | `{ message, status? }`. `status` is `"error"` or `"cancelled"` when present |
78
+ | `actions.requested` | `{ calls: [{ callId, toolName, args?, parentCallId? }], parentCallId? }`. `parentCallId` marks subagent work |
79
+ | `action.result` | `{ callId, toolName, output?, isError, stubbed?, parentCallId? }`. `stubbed` means a dry-run session answered a write without running it |
83
80
 
84
81
  The types are `SessionEvent`, `SessionEventType`, and `HookContext`,
85
82
  exported from `@cursor/july`.
86
83
 
87
84
  ## Handler context
88
85
 
89
- | Member | What it is |
90
- | --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
91
- | `ctx.session` | Read-only session info: `id`, `channelId`, `mode` (`chat` or `task`), `purpose` (`live` or `eval`), `auth`, plus `title` and `sdkAgentId` when set |
92
- | `ctx.agent` | `{ name }` of the agent the event belongs to |
93
- | `ctx.channel` | `{ id, continuationToken }`. The token is `null` when the session can't take follow-ups |
94
- | `ctx.host.kv` | Durable JSON, shared by every session of the agent; the storage backend decides whether it survives a hosted replace. Prefix keys with `ctx.session.id` for per-session state |
95
- | `ctx.host.files` | Durable files, bound to this session. Pass `{ scope: "deployment" }` for agent-wide files |
96
- | `ctx.host.otel` | Counters, histograms, and tags, attributed to this session |
97
- | `ctx.host.mcp`, `ctx.host.github`, `ctx.host.slack` | The same shared clients tools get |
98
- | `ctx.host.reminders` | Per-session [reminders](./schedules.md), the same API tools get |
99
- | `ctx.artifacts` | Session-bound [artifacts](./artifacts.md) facade: `tag` fills in `sessionId` and `turnId` |
100
- | `ctx.stateRoot` | Absolute path of the local state root. It resets when a hosted deployment is replaced; keep derived state in `kv` or `files` |
101
-
102
- ## When hooks run
103
-
104
- A hook runs after the event is durably recorded. It never delays the
105
- model turn and never sees an event that wasn't recorded.
106
-
107
- Within one session, events dispatch in order, one at a time: the
108
- channel's `events` handlers first, then each hook in discovery order.
109
- Sessions don't wait on each other.
110
-
111
- Two consequences:
112
-
113
- - A slow handler holds up the next event's handlers for that session,
114
- not the model. Keep handlers short and queue anything slow.
115
- - Hooks fire for eval sessions too. Check
116
- `ctx.session.purpose === "eval"` before metering or paging.
117
-
118
- Each event reaches a hook at most once. A restart doesn't replay the log
119
- into hooks, so a mirror needs no dedupe, and the event log rather than
120
- the hook's copy is the source of truth.
121
-
122
- ## Hooks, channel events, or evals?
123
-
124
- All of them consume the same stream, for different jobs:
125
-
126
- | | Hooks | Channel `events` | Evals |
127
- | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------- | --------------------------------- |
128
- | Scope | every session of the agent | sessions the channel owns | one test turn |
129
- | Job | observe: audit, metrics, mirrors, derived state | deliver: replies back to the channel's surface | assert: gates over the trajectory |
130
- | Context | `ctx.host`, `ctx.artifacts`, session info | `channel.state`, `setContinuationToken`, `ctx.host`, session info | the `t` assertion helpers |
131
- | Can affect the run | no | yes, it owns the surface | n/a |
132
- | Authored at | `agent/hooks/*.ts` | channel config | `evals/**/*.eval.ts` |
133
-
134
- ## When not to use a hook
135
-
136
- | You want to | Use instead |
137
- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
138
- | Add context before the model runs | The channel's `send` message and `workspaceFiles`, `instructions.md`, skills, or `sandbox/workspace/` seed files |
139
- | Reply on Slack, comment on a PR, or post any other delivery | The channel's `events` map, or the Slack and GitHub packs |
140
- | Show PR progress (merge-box check, sticky banner) | `githubChannel({ progress: { commitStatus, banner } })`; see the [PR autofixer](../templates/pr-autofixer.md) |
141
- | Block, approve, or rewrite a tool call | [`needsApproval`](./tools.md#gate-a-tool-on-human-approval) on the tool |
142
- | Act on the final assistant text, reject it for a same-turn repair, or fail a bad turn | `defineResult` |
143
- | Gate a change on behavior | [Evals](../evals.md) |
144
-
145
- ## Patterns
146
-
147
- Usage metering is the [authoring example](#author-a-hook). Three more:
148
-
149
- ### Alert on failure
150
-
151
- `turn.failed` carries the message, and `ctx.session.id` points at the
152
- trace. Skip interrupted turns; those are preemptions, not failures. Read
153
- secrets inside the handler: hosted deployments bind them after the
154
- process starts, so a module-scope read stays empty. Give the call a
155
- timeout, since a stalled request holds up later handlers on that
156
- session.
86
+ | Member | What it is |
87
+ | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | `ctx.session` | Read-only session info: `id`, `channelId`, `mode` (`chat` or `task`), `purpose` (`live` or `eval`), `auth`, plus `title` and `sdkAgentId` when set |
89
+ | `ctx.agent` | `{ name }` of the agent the event belongs to |
90
+ | `ctx.channel` | `{ id, continuationToken }`. The token is `null` when the session can't take follow-ups |
91
+ | `ctx.host.kv` | Durable JSON, shared by every session of the agent. Prefix keys with `ctx.session.id` for per-session state |
92
+ | `ctx.host.files` | Durable files, bound to this session. Pass `{ scope: "deployment" }` for agent-wide files |
93
+ | `ctx.host.otel` | Counters, histograms, and tags, attributed to this session |
94
+ | `ctx.host.mcp`, `ctx.host.github`, `ctx.host.slack` | The same shared clients tools get |
95
+ | `ctx.host.reminders` | Per-session [reminders](./schedules.md#reminders), the same API tools get |
96
+ | `ctx.artifacts` | Session-bound [artifacts](./artifacts.md) facade: `tag` fills in `sessionId` and `turnId` |
97
+ | `ctx.stateRoot` | Absolute path of the local state root. It resets when a hosted deployment is replaced; keep derived state in `kv` or `files` |
98
+
99
+ ## Hook dispatch
100
+
101
+ A hook runs after the event is recorded. It never delays the model and
102
+ never sees an event that wasn't recorded.
103
+
104
+ | Rule | What happens |
105
+ | --- | --- |
106
+ | Same session | Events dispatch one at a time |
107
+ | Eval sessions | The same stream fires; skip metering or paging when `ctx.session.purpose === "eval"` |
108
+ | Host restart | Recorded events are not replayed into hooks, so a mirror needs no dedupe |
109
+ | Slow handler | Holds the next event's handlers on that session, not the model. Keep handlers short and queue anything slow |
110
+
111
+ Read hosted secrets inside the handler, not at module scope. Give
112
+ outbound calls a timeout; a stalled request holds later handlers on that
113
+ session. Skip cancelled turns when paging; they record interrupted work.
157
114
 
158
115
  ```ts
159
116
  // agent/hooks/page-on-failure.ts
@@ -166,7 +123,7 @@ export default defineHook({
166
123
  if (
167
124
  pagerUrl === undefined ||
168
125
  ctx.session.purpose === "eval" ||
169
- event.data.message === "turn interrupted"
126
+ event.data.status === "cancelled"
170
127
  ) {
171
128
  return;
172
129
  }
@@ -186,78 +143,47 @@ export default defineHook({
186
143
  });
187
144
  ```
188
145
 
189
- ### Mirror the transcript
146
+ ## Hooks vs channels vs evals
190
147
 
191
- Subscribe to `"*"` and write one file per event, skipping the
192
- `*.appended` deltas: they arrive per token, and `message.completed`
193
- carries the final text. Session scope keeps transcripts apart without a
194
- session id in the path. The mirror holds reasoning text and raw tool
195
- arguments and outputs, so pick the store accordingly, and write to your
196
- own store instead when you need cross-session queries.
148
+ All three consume the same stream, for different jobs:
197
149
 
198
- ```ts
199
- // agent/hooks/mirror.ts
200
- import { defineHook } from "@cursor/july/hooks";
201
-
202
- export default defineHook({
203
- events: {
204
- async "*"(event, ctx) {
205
- if (event.type.endsWith(".appended")) {
206
- return;
207
- }
208
- const name = String(event.index).padStart(6, "0");
209
- await ctx.host.files.write(
210
- `transcript/${name}.json`,
211
- JSON.stringify(event)
212
- );
213
- },
214
- },
215
- });
216
- ```
217
-
218
- ### Keep derived state across a replace
219
-
220
- Write it to `ctx.host.kv` under a session-prefixed key; a tool reads it
221
- back with `ctx.host.kv.get`.
150
+ | | Hooks | Channel `events` | Evals |
151
+ | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------- | --------------------------------- |
152
+ | Scope | every session of the agent | sessions the channel owns | one test turn |
153
+ | Job | observe: audit, metrics, mirrors, derived state | deliver: replies back to the channel's surface | assert: gates over the trajectory |
154
+ | Context | `ctx.host`, `ctx.artifacts`, session info | `channel.state`, `setContinuationToken`, `ctx.host`, session info | the `t` assertion helpers |
155
+ | Can affect the run | no | yes, it owns the surface | n/a |
156
+ | Authored at | `agent/hooks/*.ts` | channel config | `evals/**/*.eval.ts` |
222
157
 
223
- ```ts
224
- // agent/hooks/last-result.ts
225
- import { defineHook } from "@cursor/july/hooks";
158
+ ## Hook boundaries
226
159
 
227
- export default defineHook({
228
- events: {
229
- async "turn.completed"(event, ctx) {
230
- await ctx.host.kv.put(`last-result/${ctx.session.id}`, {
231
- at: event.at,
232
- result: event.data.result ?? null,
233
- });
234
- },
235
- },
236
- });
237
- ```
160
+ | You want to | Use instead |
161
+ | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
162
+ | Add context before the model runs | The channel's `send` message and `workspaceFiles`, `instructions.md`, skills, or `sandbox/workspace/` seed files |
163
+ | Reply on Slack, comment on a PR, or post any other delivery | The channel's `events` map, or the Slack and GitHub packs |
164
+ | Show PR progress (merge-box check, sticky banner) | `githubChannel({ progress: { commitStatus, banner } })`; see the [PR autofixer](../templates/pr-autofixer.md) |
165
+ | Block, approve, or rewrite a tool call | [`needsApproval`](./tools.md#gate-a-tool-on-human-approval) on the tool |
166
+ | Act on the final assistant text, reject it for a same-turn repair, or fail a bad turn | `defineResult` |
167
+ | Gate a change on behavior | [Evals](../evals.md) |
238
168
 
239
- ## Test and debug a hook
169
+ ## Test a hook
240
170
 
241
171
  A hook definition is a plain object, so a unit test calls
242
172
  `hook.events["turn.completed"]` directly with an event and a stub
243
173
  `HookContext`. Discovery skips `*.test.ts`, so the test can live next to
244
174
  the hook.
245
175
 
246
- At runtime:
247
-
248
- - `agent-sdk validate --dir .` reports discovery errors and the
249
- empty-handlers warning.
250
- - `agent-sdk info --dir . --json` lists the loaded hooks under
251
- `agents[].hooks`.
252
- - Send a turn with `agent-sdk dev` or `agent-sdk run --dir . --message "…"`
253
- and watch the serve log for
254
- `hook "<name>" handler for <event> threw: …`. `run` prints that log on
255
- stderr. On hosting, read it with [`agent-sdk logs`](./cli.md#logs).
176
+ | Command | What it reports |
177
+ | --- | --- |
178
+ | `agent-sdk validate --dir .` | Discovery errors and the empty-handlers warning |
179
+ | `agent-sdk info --dir . --json` | Loaded hooks under `agents[].hooks` |
180
+ | `agent-sdk run --dir . --message "…"` | Serve log on stderr, including `hook "<name>" handler for <event> threw: …` |
256
181
 
257
- ## What's next
182
+ On hosting, read the same log with [`agent-sdk logs`](./cli.md#logs).
258
183
 
259
- Continue with these pages:
184
+ ## Related
260
185
 
186
+ - [Hooks guide](../guides/hooks.md): meter usage and page on failure
261
187
  - [Sessions and streaming](./sessions.md): the event vocabulary hooks observe
262
188
  - [OpenTelemetry](../guides/opentelemetry.md): OTLP traces and metrics
263
189
  from the same event stream