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