@cursor/bdk 0.2.25 → 0.2.26
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/AGENTS.md +3 -18
- package/CHANGELOG.md +3 -0
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +1 -1
- package/dist/bin/agent-serve.js +25 -21
- package/dist/channels/bitbucket/api.d.ts +2 -2
- package/dist/channels/bitbucket/api.d.ts.map +1 -1
- package/dist/channels/bitbucket/bitbucket-channel.js +1 -1
- package/dist/channels/bitbucket/bitbucket-webhook.d.ts +2 -2
- package/dist/channels/bitbucket/bitbucket-webhook.d.ts.map +1 -1
- package/dist/channels/change-monitors/change-monitors-channel.js +1 -1
- package/dist/channels/deployments/deployments-channel.js +1 -1
- package/dist/channels/github/cursor-account.d.ts +7 -0
- package/dist/channels/github/cursor-account.d.ts.map +1 -1
- package/dist/channels/github/cursor-account.js +22 -5
- package/dist/channels/github/github-channel.js +1 -1
- package/dist/channels/github/replay.d.ts +1 -1
- package/dist/channels/github/replay.d.ts.map +1 -1
- package/dist/channels/gitlab/api.d.ts +2 -2
- package/dist/channels/gitlab/api.d.ts.map +1 -1
- package/dist/channels/gitlab/gitlab-channel.js +1 -1
- package/dist/channels/issues/issues-channel.js +1 -1
- package/dist/channels/origin/api.d.ts +4 -4
- package/dist/channels/origin/api.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +1 -1
- package/dist/channels/origin/origin-webhook.d.ts +3 -3
- package/dist/channels/origin/origin-webhook.d.ts.map +1 -1
- package/dist/channels/pagerduty/pagerduty-webhook.d.ts +2 -2
- package/dist/channels/pagerduty/pagerduty-webhook.d.ts.map +1 -1
- package/dist/channels/runs/runs-channel.js +1 -1
- package/dist/channels/slack/agentic-delivery.d.ts +2 -1
- package/dist/channels/slack/agentic-delivery.d.ts.map +1 -1
- package/dist/channels/slack/agentic-delivery.js +6 -10
- package/dist/channels/slack/agentic-signals.d.ts +2 -7
- package/dist/channels/slack/agentic-signals.d.ts.map +1 -1
- package/dist/channels/slack/agentic-signals.js +4 -3
- package/dist/channels/slack/api.d.ts +1 -0
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +3 -0
- package/dist/channels/slack/constants.d.ts +2 -0
- package/dist/channels/slack/constants.d.ts.map +1 -1
- package/dist/channels/slack/constants.js +2 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +3 -2
- package/dist/channels/slack/dispatch.d.ts +9 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +3 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +24 -20
- package/dist/channels/slack/interactive.d.ts +2 -0
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +1 -0
- package/dist/channels/slack/live-delivery.d.ts +3 -0
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +5 -0
- package/dist/channels/slack/reply-options.d.ts +9 -0
- package/dist/channels/slack/reply-options.d.ts.map +1 -1
- package/dist/channels/slack/reply-options.js +31 -1
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +7 -0
- package/dist/channels/slack/stream.d.ts +5 -1
- package/dist/channels/slack/stream.d.ts.map +1 -1
- package/dist/channels/slack/types.d.ts +29 -0
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels.d.ts +1 -1
- package/dist/channels.js +1 -1
- package/dist/docs/404.html +3 -3
- package/dist/docs/assets/{app.BjS1QEI4.js → app.BITbgXMP.js} +4 -4
- package/dist/docs/assets/changelog.md.sdD6ctqK.js +1 -0
- package/dist/docs/assets/changelog.md.sdD6ctqK.lean.js +1 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.B45uCZp9.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BOuvjb5Y.js → VPLocalSearchBox.3qo4-bX9.js} +2 -2
- package/dist/docs/assets/chunks/{arc.3WR6Jf-y.js → arc.CTrZocKU.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.Dtb6Dqh6.js → architectureDiagram-Q4EWVU46.BkgIqxrv.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.BUyrgrZE.js → baseUniq.5w0JfVgo.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.BVLV_voZ.js → blockDiagram-DXYQGD6D.BVLtPjQc.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.jXJ1q70M.js → c4Diagram-AHTNJAMY.CQ7neZTW.js} +1 -1
- package/dist/docs/assets/chunks/channel.Cv2w64wj.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.zz1SMBvK.js → chunk-4BX2VUAB.D-hJ7uKM.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.CzYKuv3I.js → chunk-4TB4RGXK.RBYX5ywX.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.C7_tcJZD.js → chunk-55IACEB6.Br05HoEb.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DeTwQPVO.js → chunk-EDXVE4YY.BD_7QS60.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DhMTl7ut.js → chunk-FMBD7UC4.BOPnMabX.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.Me7f5hEp.js → chunk-OYMX7WX6.DmGIdP8i.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.D0E0Bb6g.js → chunk-QZHKN3VN.CGHmolCB.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.CdOOBFYL.js → chunk-YZCP3GAM.C_Uhs25v.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CtO2atCr.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CtO2atCr.js +1 -0
- package/dist/docs/assets/chunks/clone.hfsCtgP4.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BNbGESzN.js → cose-bilkent-S5V4N54A.DsU6xpcZ.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.zU7Lu_xJ.js → dagre-KV5264BT.BqQLDcoU.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.B9qOdE5h.js → diagram-5BDNPKRD.Cgv8uUNF.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.D8X-sf77.js → diagram-G4DWMVQ6.BXHPSXh_.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.CW7MvMlE.js → diagram-MMDJMWI5.CgJzo8f_.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.J489G0Nd.js → diagram-TYMM5635.CfiN6lgT.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.BkW7tGfs.js → erDiagram-SMLLAGMA.8n_hHzAd.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.jc9iWORD.js → flowDiagram-DWJPFMVM.B2pb1Dv_.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.B-UQfd9E.js → ganttDiagram-T4ZO3ILL.BFih4ucI.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.DFzrTSlJ.js → gitGraphDiagram-UUTBAWPF.CqZ8PTl8.js} +1 -1
- package/dist/docs/assets/chunks/{graph.C5IB6_e_.js → graph.0ufsI9gu.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.DwF0-c8L.js → infoDiagram-42DDH7IO.BkPRFww4.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.fBaTqzE7.js → ishikawaDiagram-UXIWVN3A.DCRK-cVX.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.CM8gDVJy.js → journeyDiagram-VCZTEJTY.BFyAJo33.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.YiD1p0LB.js → kanban-definition-6JOO6SKY.CmA2SoGc.js} +1 -1
- package/dist/docs/assets/chunks/{layout.6Um-DVJT.js → layout.CYY-CbMr.js} +1 -1
- package/dist/docs/assets/chunks/{linear.DcTeg4Hn.js → linear.DeeDV4Oq.js} +1 -1
- package/dist/docs/assets/chunks/{min.CIxkY8Fe.js → min.BL3XTBN2.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.D4QM_voR.js → mindmap-definition-QFDTVHPH.BcbY-G6H.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.nmB309G1.js → pieDiagram-DEJITSTG.dzDcQnPE.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.D1HtZR3C.js → quadrantDiagram-34T5L4WZ.RxR0m5iK.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.CZgQWob-.js → requirementDiagram-MS252O5E.DflaXb6Q.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.DtiBfU-P.js → sankeyDiagram-XADWPNL6.BteLKQAe.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.Cld4gDSt.js → sequenceDiagram-FGHM5R23.BD8jM8oz.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.DatP823_.js → stateDiagram-FHFEXIEX.C8SBkbPH.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.BLz7Qyo3.js +1 -0
- package/dist/docs/assets/chunks/{theme.D5jbBys7.js → theme.DiViIOLe.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.DwQLI2be.js → timeline-definition-GMOUNBTQ.D64XF5dV.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.a5yMfnsa.js → vennDiagram-DHZGUBPP.CwmeYan-.js} +1 -1
- package/dist/docs/assets/chunks/{wardley-RL74JXVD.B-FXivgT.js → wardley-RL74JXVD.DmAlXlpu.js} +1 -1
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.Dz--Opy3.js → wardleyDiagram-NUSXRM2D.5VJ2-5K0.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.Dl8w8TeT.js → xychartDiagram-5P7HB3ND.Cl6_fZVC.js} +1 -1
- package/dist/docs/assets/{guides_hooks.md.Bfj0pK91.js → guides_hooks.md.B2XfGX50.js} +7 -3
- package/dist/docs/assets/{guides_mcp-oauth.md.BM_eFC0L.js → guides_mcp-oauth.md.Cxq2TxBB.js} +3 -3
- package/dist/docs/assets/{guides_mcp-oauth.md.BM_eFC0L.lean.js → guides_mcp-oauth.md.Cxq2TxBB.lean.js} +1 -1
- package/dist/docs/assets/guides_opentelemetry.md.D4wO7_8v.js +37 -0
- package/dist/docs/assets/guides_opentelemetry.md.D4wO7_8v.lean.js +1 -0
- package/dist/docs/assets/{guides_slack.md.Bn-WupSE.js → guides_slack.md.ClIyi7FI.js} +8 -3
- package/dist/docs/assets/{guides_slack.md.Bn-WupSE.lean.js → guides_slack.md.ClIyi7FI.lean.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.IplwL25I.js → reference_agent-config.md.CGSx8COP.js} +6 -2
- package/dist/docs/assets/{reference_agent-config.md.IplwL25I.lean.js → reference_agent-config.md.CGSx8COP.lean.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.Bxaa020x.js → reference_channels.md.CNNIS6K7.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.B1jq3oGl.js → reference_hooks.md.CROr0QgC.js} +13 -7
- package/dist/docs/assets/{reference_hooks.md.B1jq3oGl.lean.js → reference_hooks.md.CROr0QgC.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.03Ryy9ca.js → reference_schedules.md.BqWnJES4.js} +3 -3
- package/dist/docs/assets/reference_sessions.md.Bi6lHttM.js +22 -0
- package/dist/docs/assets/reference_sessions.md.Bi6lHttM.lean.js +1 -0
- package/dist/docs/assets/{reference_skills.md.C2GWh7g8.js → reference_skills.md.Ckddg6KX.js} +3 -3
- package/dist/docs/assets/{reference_tools.md.-6pypsWt.js → reference_tools.md.Bo0UfT0a.js} +1 -1
- package/dist/docs/assets/{style.nMsabY-V.css → style.B9o0luvp.css} +1 -1
- package/dist/docs/building-with-agents.html +37 -37
- package/dist/docs/changelog.html +60 -0
- package/dist/docs/changelog.md +86 -0
- package/dist/docs/deployment.html +37 -37
- package/dist/docs/evals.html +37 -37
- package/dist/docs/guides/agent-to-agent.html +37 -37
- package/dist/docs/guides/bitbucket.html +37 -37
- package/dist/docs/guides/cloud-agents.html +37 -37
- package/dist/docs/guides/convert-automation.html +37 -37
- package/dist/docs/guides/export-grokbot.html +37 -37
- package/dist/docs/guides/github.html +37 -37
- package/dist/docs/guides/gitlab.html +37 -37
- package/dist/docs/guides/grokbot-agents.html +37 -37
- package/dist/docs/guides/hooks.html +45 -41
- package/dist/docs/guides/hooks.md +7 -3
- package/dist/docs/guides/improve.html +37 -37
- package/dist/docs/guides/jev.html +37 -37
- package/dist/docs/guides/mcp-oauth.html +39 -39
- package/dist/docs/guides/mcp-oauth.md +12 -0
- package/dist/docs/guides/migrate.html +37 -37
- package/dist/docs/guides/opentelemetry.html +62 -70
- package/dist/docs/guides/opentelemetry.md +149 -179
- package/dist/docs/guides/pagerduty.html +37 -37
- package/dist/docs/guides/slack.html +44 -39
- package/dist/docs/guides/slack.md +41 -0
- package/dist/docs/guides/webhooks.html +37 -37
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +37 -37
- package/dist/docs/index.html +37 -37
- package/dist/docs/llms-full.txt +385 -193
- package/dist/docs/llms.txt +2 -1
- package/dist/docs/quickstart.html +37 -37
- package/dist/docs/reference/agent-config.html +42 -38
- package/dist/docs/reference/agent-config.md +21 -1
- package/dist/docs/reference/artifacts.html +37 -37
- package/dist/docs/reference/channels.html +38 -38
- package/dist/docs/reference/channels.md +5 -1
- package/dist/docs/reference/cli.html +37 -37
- package/dist/docs/reference/connections.html +37 -37
- package/dist/docs/reference/evals.html +37 -37
- package/dist/docs/reference/extensions.html +37 -37
- package/dist/docs/reference/hooks.html +49 -43
- package/dist/docs/reference/hooks.md +10 -5
- package/dist/docs/reference/http-api.html +37 -37
- package/dist/docs/reference/instructions.html +37 -37
- package/dist/docs/reference/memory.html +37 -37
- package/dist/docs/reference/playground.html +36 -36
- package/dist/docs/reference/project-layout.html +37 -37
- package/dist/docs/reference/prompt.html +37 -37
- package/dist/docs/reference/schedules.html +40 -40
- package/dist/docs/reference/sessions.html +58 -37
- package/dist/docs/reference/sessions.md +46 -1
- package/dist/docs/reference/skills.html +40 -40
- package/dist/docs/reference/subagents.html +37 -37
- package/dist/docs/reference/tools.html +39 -39
- package/dist/docs/reference/tools.md +3 -3
- package/dist/docs/templates/agentic-owners.html +37 -37
- package/dist/docs/templates/grokbot-agents.html +37 -37
- package/dist/docs/templates/security-reviewer.html +37 -37
- package/dist/docs/templates/thermo-quality-review.html +37 -37
- package/dist/docs/templates/thermo-review.html +37 -37
- package/dist/docs/templates/triage.html +37 -37
- package/dist/docs/troubleshooting.html +36 -36
- package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/extension.js +15 -15
- package/dist/extensions/cursor-cloud-agents/lib/backend.js +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/fleet.js +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/inputs.js +1 -1
- package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.js +1 -1
- package/dist/extensions/cursor-cloud-agents/tools/launch.js +1 -1
- package/dist/extensions/cursor-cloud-agents/tools/list.js +1 -1
- package/dist/extensions/cursor-cloud-agents/tools/reply.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/extension.d.ts.map +1 -1
- package/dist/extensions/cursor-grokbot-agents/extension.js +7 -3
- package/dist/extensions/cursor-grokbot-agents/lib/backend.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/lib/contacts.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts +1 -1
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts.map +1 -1
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/tools/ask.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/tools/check.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/tools/interrupt.js +1 -1
- package/dist/extensions/cursor-grokbot-agents/tools/list.js +1 -1
- package/dist/extensions/improve/extension.js +1 -1
- package/dist/extensions/jev/extension.js +2 -2
- package/dist/extensions/jev/tools/evaluate.js +3 -3
- package/dist/extensions/slack-communication/extension.js +1 -1
- package/dist/extensions/slack-communication/tools/delete-message.js +1 -1
- package/dist/extensions/slack-communication/tools/edit-message.d.ts.map +1 -1
- package/dist/extensions/slack-communication/tools/edit-message.js +3 -6
- package/dist/extensions/slack-communication/tools/post-card.js +1 -1
- package/dist/extensions/slack-communication/tools/post-file.js +1 -1
- package/dist/extensions/slack-communication/tools/post-update.d.ts.map +1 -1
- package/dist/extensions/slack-communication/tools/post-update.js +3 -6
- package/dist/extensions/slack-communication/tools/react.js +1 -1
- package/dist/extensions/slack-communication/tools/set-status.js +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/internal/as-of.d.ts +2 -0
- package/dist/internal/as-of.d.ts.map +1 -1
- package/dist/internal/as-of.js +2 -0
- package/dist/internal/builtin-tools/reminders.js +1 -1
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +18 -10
- package/dist/internal/continuation.d.ts +3 -0
- package/dist/internal/continuation.d.ts.map +1 -0
- package/dist/internal/continuation.js +1 -0
- package/dist/internal/conversation-mirror.d.ts +5 -0
- package/dist/internal/conversation-mirror.d.ts.map +1 -1
- package/dist/internal/conversation-mirror.js +12 -1
- package/dist/internal/convert-automation/convert-workflow.js +1 -1
- package/dist/internal/convert-grokbot/answers.d.ts.map +1 -1
- package/dist/internal/convert-grokbot/answers.js +10 -8
- package/dist/internal/convert-grokbot/recipe.d.ts +1 -1
- package/dist/internal/convert-grokbot/recipe.d.ts.map +1 -1
- package/dist/internal/convert-grokbot/recipe.js +1 -1
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +2 -0
- package/dist/internal/cursor/backend-client.d.ts +8 -3
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +8 -3
- package/dist/internal/cursor/credentials.d.ts +2 -2
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +1 -1
- package/dist/internal/cursor-account-mcp-auth.d.ts +6 -2
- package/dist/internal/cursor-account-mcp-auth.d.ts.map +1 -1
- package/dist/internal/cursor-account-mcp-auth.js +15 -6
- package/dist/internal/deferred-channel-session.d.ts +5 -4
- package/dist/internal/deferred-channel-session.d.ts.map +1 -1
- package/dist/internal/deferred-channel-session.js +6 -4
- package/dist/internal/deploy-client.d.ts +5 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +3 -3
- package/dist/internal/deploy-manifest.js +2 -2
- package/dist/internal/describe-error.d.ts +2 -0
- package/dist/internal/describe-error.d.ts.map +1 -1
- package/dist/internal/describe-error.js +2 -0
- package/dist/internal/discovery/context.d.ts.map +1 -1
- package/dist/internal/discovery/context.js +1 -2
- package/dist/internal/discovery/cursor-plugin.js +8 -8
- package/dist/internal/discovery/extensions.js +15 -8
- package/dist/internal/discovery/info.d.ts +2 -2
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +6 -9
- package/dist/internal/discovery/instrumentation.d.ts +10 -0
- package/dist/internal/discovery/instrumentation.d.ts.map +1 -0
- package/dist/internal/discovery/instrumentation.js +29 -0
- package/dist/internal/discovery/modules.d.ts.map +1 -1
- package/dist/internal/discovery/modules.js +4 -4
- package/dist/internal/discovery/project-public.d.ts +16 -0
- package/dist/internal/discovery/project-public.d.ts.map +1 -0
- package/dist/internal/discovery/project-public.js +54 -0
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +13 -3
- package/dist/internal/discovery/services.d.ts +5 -4
- package/dist/internal/discovery/services.d.ts.map +1 -1
- package/dist/internal/discovery/services.js +12 -6
- package/dist/internal/event-mapper.d.ts.map +1 -1
- package/dist/internal/event-mapper.js +1 -0
- package/dist/internal/factory-resource-channel.d.ts +1 -1
- package/dist/internal/factory-resource-channel.d.ts.map +1 -1
- package/dist/internal/filesystem/nearest.d.ts +1 -0
- package/dist/internal/filesystem/nearest.d.ts.map +1 -1
- package/dist/internal/filesystem/nearest.js +1 -0
- package/dist/internal/filesystem/tools.d.ts.map +1 -1
- package/dist/internal/filesystem/tools.js +1 -1
- package/dist/internal/handleAgentServeTrigger.d.ts +10 -0
- package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -1
- package/dist/internal/handleAgentServeTrigger.js +3 -0
- package/dist/internal/hmac-secret-values.d.ts +1 -1
- package/dist/internal/hmac-secret-values.d.ts.map +1 -1
- package/dist/internal/host-otel.d.ts +1 -1
- package/dist/internal/host-otel.d.ts.map +1 -1
- package/dist/internal/host-otel.js +5 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +6 -2
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +1 -0
- package/dist/internal/ids.d.ts +8 -0
- package/dist/internal/ids.d.ts.map +1 -1
- package/dist/internal/ids.js +20 -0
- package/dist/internal/init-scaffold.js +1 -1
- package/dist/internal/interview/agent-questions.d.ts +1 -1
- package/dist/internal/interview/agent-questions.d.ts.map +1 -1
- package/dist/internal/interview/agent-questions.js +1 -1
- package/dist/internal/interview/question.d.ts +2 -2
- package/dist/internal/interview/question.d.ts.map +1 -1
- package/dist/internal/interview/question.js +2 -2
- package/dist/internal/json-schema.d.ts.map +1 -1
- package/dist/internal/json-schema.js +3 -7
- package/dist/internal/mcp-endpoint.d.ts +16 -4
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +18 -6
- package/dist/internal/mcp-host.d.ts +9 -0
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +15 -0
- package/dist/internal/otel/collector.d.ts +5 -0
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +24 -5
- package/dist/internal/otel/config.d.ts +31 -21
- package/dist/internal/otel/config.d.ts.map +1 -1
- package/dist/internal/otel/config.js +121 -140
- package/dist/internal/otel/conversation-span-processor.d.ts +9 -0
- package/dist/internal/otel/conversation-span-processor.d.ts.map +1 -0
- package/dist/internal/otel/conversation-span-processor.js +34 -0
- package/dist/internal/otel/customer.d.ts +52 -0
- package/dist/internal/otel/customer.d.ts.map +1 -0
- package/dist/internal/otel/customer.js +727 -0
- package/dist/internal/otel/runtime.d.ts +12 -16
- package/dist/internal/otel/runtime.d.ts.map +1 -1
- package/dist/internal/otel/runtime.js +30 -234
- package/dist/internal/otel-env.d.ts +6 -0
- package/dist/internal/otel-env.d.ts.map +1 -0
- package/dist/internal/otel-env.js +5 -0
- package/dist/internal/reminder-runner.d.ts +9 -4
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +12 -10
- package/dist/internal/reminder-schedule.d.ts +1 -0
- package/dist/internal/reminder-schedule.d.ts.map +1 -1
- package/dist/internal/reminder-schedule.js +1 -0
- package/dist/internal/sdk-runner.d.ts +2 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +149 -13
- package/dist/internal/server.d.ts +4 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +25 -24
- package/dist/internal/session-engine.d.ts +27 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +149 -21
- package/dist/internal/slack-provision-client.js +1 -1
- package/dist/internal/store-api-protocol.d.ts +1 -1
- package/dist/internal/store-api-protocol.d.ts.map +1 -1
- package/dist/internal/store-api-protocol.js +1 -1
- package/dist/internal/update-check.d.ts +2 -2
- package/dist/internal/update-check.d.ts.map +1 -1
- package/dist/internal/update-check.js +3 -3
- package/dist/internal/zod3-datetime.d.ts +12 -0
- package/dist/internal/zod3-datetime.d.ts.map +1 -0
- package/dist/internal/zod3-datetime.js +17 -0
- package/dist/otel-public.d.ts +2 -3
- package/dist/otel-public.d.ts.map +1 -1
- package/dist/otel-public.js +2 -2
- package/dist/otel.d.ts +3 -102
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +61 -97
- package/dist/playground/assets/index-CyPkf2y7.css +1 -0
- package/dist/playground/assets/{index-CHk6O92d.js → index-DpbzbqFY.js} +38 -38
- package/dist/playground/index.html +2 -2
- package/dist/public-deprecated.d.ts +36 -0
- package/dist/public-deprecated.d.ts.map +1 -0
- package/dist/public-deprecated.js +39 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +1 -1
- package/dist/types.d.ts +221 -90
- package/dist/types.d.ts.map +1 -1
- package/docs/changelog.md +91 -0
- package/docs/guides/hooks.md +7 -3
- package/docs/guides/mcp-oauth.md +12 -0
- package/docs/guides/opentelemetry.md +149 -184
- package/docs/guides/slack.md +41 -0
- package/docs/reference/agent-config.md +21 -1
- package/docs/reference/channels.md +5 -1
- package/docs/reference/hooks.md +10 -5
- package/docs/reference/sessions.md +46 -1
- package/docs/reference/tools.md +3 -3
- package/package.json +31 -7
- package/schemas/grokbot-answers.schema.json +11 -0
- package/skills/framework-map/SKILL.md +2 -1
- package/skills/otel/SKILL.md +28 -48
- package/templates/code-wiki/evals/wiki.eval.ts +2 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.oGqZumnJ.js +0 -1
- package/dist/docs/assets/chunks/channel.Dt4aweTm.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.DGUHZs6j.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.DGUHZs6j.js +0 -1
- package/dist/docs/assets/chunks/clone.DWf3k0Z0.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.C0571l4D.js +0 -1
- package/dist/docs/assets/guides_opentelemetry.md.DBQtp7_V.js +0 -45
- package/dist/docs/assets/guides_opentelemetry.md.DBQtp7_V.lean.js +0 -1
- package/dist/docs/assets/reference_sessions.md.C8FXuGwk.js +0 -1
- package/dist/docs/assets/reference_sessions.md.C8FXuGwk.lean.js +0 -1
- package/dist/playground/assets/index-BdMwybMt.css +0 -1
- package/templates/grokbot-agents/.gitignore +0 -4
- package/templates/security-help/.gitignore +0 -4
- /package/dist/docs/assets/{guides_hooks.md.Bfj0pK91.lean.js → guides_hooks.md.B2XfGX50.lean.js} +0 -0
- /package/dist/docs/assets/{reference_channels.md.Bxaa020x.lean.js → reference_channels.md.CNNIS6K7.lean.js} +0 -0
- /package/dist/docs/assets/{reference_schedules.md.03Ryy9ca.lean.js → reference_schedules.md.BqWnJES4.lean.js} +0 -0
- /package/dist/docs/assets/{reference_skills.md.C2GWh7g8.lean.js → reference_skills.md.Ckddg6KX.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.-6pypsWt.lean.js → reference_tools.md.Bo0UfT0a.lean.js} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{_ as e,c as t,o as i,a3 as a}from"./chunks/framework.BNw1pucY.js";const E=JSON.parse('{"title":"OpenTelemetry","description":"","frontmatter":{},"headers":[],"relativePath":"guides/opentelemetry.md","filePath":"guides/opentelemetry.md"}'),n={name:"guides/opentelemetry.md"};function d(o,s,r,h,l,p){return i(),t("div",null,[...s[0]||(s[0]=[a(`<h1 id="opentelemetry" tabindex="-1">OpenTelemetry <a class="header-anchor" href="#opentelemetry" aria-label="Permalink to "OpenTelemetry""></a></h1><p>BDK exports traces, metrics, and logs to an OTLP collector. You configure that with standard <code>OTEL_*</code> environment variables. There is no <code>defineOtel</code> or <code>register()</code> hook. <code>ctx.host.otel</code> is deprecated. It still runs for this release and logs one warning per process. Set <code>OTEL_*</code> variables and record with <code>metrics.getMeter</code> and <code>trace.getTracer</code> from <code>@opentelemetry/api</code>.</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_EXPORTER_OTLP_ENDPOINT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">https://otel.example.com</span></span>
|
|
2
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_EXPORTER_OTLP_HEADERS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Authorization=Bearer </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$OTEL_TOKEN</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"</span></span>
|
|
3
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_SERVICE_NAME</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">incident-agent</span></span>
|
|
4
|
+
<span class="line"></span>
|
|
5
|
+
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> serve</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dev</span></span></code></pre></div><p>The default protocol is OTLP/HTTP protobuf. Set <code>OTEL_EXPORTER_OTLP_PROTOCOL=http/json</code> when the collector only accepts JSON. <code>grpc</code> is not supported. BDK logs a warning and uses <code>http/protobuf</code>.</p><p>Metrics use delta temporality by default. BDK logs that default when export starts. For Grafana Cloud or Prometheus, set <code>OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE</code> to <code>cumulative</code>. Grafana Cloud rejects delta metrics.</p><p>BDK installs trace, metric, and log providers before it imports <code>bot/agent.ts</code>. A meter, tracer, or logger created at module scope binds to those providers. Exporters attach when the process has the <code>OTEL_*</code> variables. On a hosted agent that is the first request, after secrets are in the environment.</p><p>With no OTLP endpoint, BDK adds no exporters. Outbound <code>fetch</code> does not gain a <code>traceparent</code> header. The session collector stays disabled.</p><h2 id="variables" tabindex="-1">Variables <a class="header-anchor" href="#variables" aria-label="Permalink to "Variables""></a></h2><table tabindex="0"><thead><tr><th>Variable</th><th>Effect</th></tr></thead><tbody><tr><td><code>OTEL_EXPORTER_OTLP_ENDPOINT</code></td><td>Base URL. BDK appends <code>/v1/traces</code>, <code>/v1/metrics</code>, and <code>/v1/logs</code>.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_TRACES_ENDPOINT</code></td><td>Traces URL, used as written. It wins over the base URL.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_METRICS_ENDPOINT</code></td><td>Metrics URL, used as written. It wins over the base URL.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_LOGS_ENDPOINT</code></td><td>Logs URL, used as written. It wins over the base URL.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_HEADERS</code></td><td>Headers on every export. Values are URL-encoded. Read again on each export.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_PROTOCOL</code></td><td><code>http/protobuf</code> (default) or <code>http/json</code>. gRPC is not supported.</td></tr><tr><td><code>OTEL_SERVICE_NAME</code></td><td><code>service.name</code>. Default is the agent name, then <code>unknown_service:node</code>.</td></tr><tr><td><code>OTEL_RESOURCE_ATTRIBUTES</code></td><td>Resource attributes, including <code>service.namespace</code>, <code>service.version</code>, and <code>deployment.environment.name</code>.</td></tr><tr><td><code>OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE</code></td><td><code>delta</code> (default), <code>cumulative</code>, or <code>lowmemory</code>. Use <code>cumulative</code> for Grafana Cloud.</td></tr><tr><td><code>OTEL_LOGS_EXPORTER</code></td><td><code>otlp</code> turns logs on. Unset, <code>none</code>, and <code>console</code> leave OTLP logs off.</td></tr><tr><td><code>OTEL_SDK_DISABLED</code></td><td><code>true</code> turns export off.</td></tr><tr><td><code>OTEL_TRACES_EXPORTER</code></td><td><code>none</code> turns traces off.</td></tr><tr><td><code>OTEL_METRICS_EXPORTER</code></td><td><code>none</code> turns metrics off.</td></tr><tr><td><code>OTEL_LOG_USER_PROMPTS</code></td><td><code>1</code> puts prompt text on log records.</td></tr><tr><td><code>OTEL_LOG_TOOL_CONTENT</code></td><td><code>1</code> puts tool payloads on log records.</td></tr></tbody></table><h2 id="hosted-agents" tabindex="-1">Hosted agents <a class="header-anchor" href="#hosted-agents" aria-label="Permalink to "Hosted agents""></a></h2><p>Set the endpoint, headers, and service name as secrets. Add the collector host to <code>hosting.egressDomains</code>. The host is a hostname with no scheme and no path.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defineAgent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
6
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> hosting: {</span></span>
|
|
7
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> egressDomains: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"otlp-gateway-prod-us-east-0.grafana.net"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">],</span></span>
|
|
8
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> secretNames: [</span></span>
|
|
9
|
+
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "OTEL_EXPORTER_OTLP_ENDPOINT"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
10
|
+
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "OTEL_EXPORTER_OTLP_HEADERS"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
11
|
+
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "OTEL_SERVICE_NAME"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
12
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ],</span></span>
|
|
13
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
14
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>Secrets arrive with the first request that has an endpoint. That request's export uses those headers and <code>service.name</code>. A later <code>bdk secrets set</code> updates headers on the next export, including a rotated key. BDK also replaces the exporter when the URL, protocol, or signal list changes. <code>service.name</code> is fixed on the first export that attaches. Redeploy to change the service name.</p><h2 id="what-you-can-record" tabindex="-1">What you can record <a class="header-anchor" href="#what-you-can-record" aria-label="Permalink to "What you can record""></a></h2><p>Create the tracer, meter, and logger at module scope.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { metrics, trace } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@opentelemetry/api"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
15
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { logs } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@opentelemetry/api-logs"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
16
|
+
<span class="line"></span>
|
|
17
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> tracer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> trace.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getTracer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
18
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> lookups</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metrics.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMeter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">createCounter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident.lookups"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
19
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> logger</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logs.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getLogger</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><p>Record during a request, after secrets have loaded. A span or a log record that ends before the exporters attach is still exported. BDK holds up to 2048 spans and 2048 log records until the exporters attach, then sends them. BDK drops each record past that limit. A metric recorded before the first collect is included in that collect.</p><p>BDK also records HTTP spans, token counts, and tool calls on the session. Those spans carry <code>cursor.conversation.id</code>. A span you start with <code>trace.getTracer</code> during a turn or a tool call gets the same attribute from the active context. A value you set on the span stays. BDK does not overwrite it. The id stays in this process. It is not propagated.</p><p>A metric does not get <code>cursor.conversation.id</code>. Read the id and set the attribute yourself.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { metrics } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@opentelemetry/api"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
20
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { currentConversationId } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk/otel"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
21
|
+
<span class="line"></span>
|
|
22
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> lookups</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metrics.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMeter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">createCounter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident.lookups"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
23
|
+
<span class="line"></span>
|
|
24
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">lookups.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, { </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"cursor.conversation.id"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">currentConversationId</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() });</span></span></code></pre></div><p>Prompt text and tool payloads stay off log records unless logs are on (<code>OTEL_LOGS_EXPORTER=otlp</code>) and you set <code>OTEL_LOG_USER_PROMPTS</code> or <code>OTEL_LOG_TOOL_CONTENT</code>.</p><h2 id="limits" tabindex="-1">Limits <a class="header-anchor" href="#limits" aria-label="Permalink to "Limits""></a></h2><p>These are not supported yet.</p><ul><li>Custom span processors, samplers, and views.</li><li>Bringing your own OpenTelemetry SDK.</li><li>Library auto-instrumentation.</li><li>A <code>register()</code> hook. There is no ticket for it yet.</li><li><code>OTEL_TRACES_SAMPLER</code> and <code>OTEL_METRIC_EXPORT_INTERVAL</code> that arrive only with hosted secrets. BDK reads them when it builds the provider, which is before that secret load. Set them on the process, then restart. BDK logs a warning when a later value differs.</li></ul><p>Do not import your own SDK providers next to BDK's. BDK logs a warning when a module replaces a provider BDK registered. The global API then uses that module's provider. BDK shuts down a provider it created only when that provider is not the one it registered.</p><h2 id="migrating-from-serve-otel" tabindex="-1">Migrating from serve({ otel }) <a class="header-anchor" href="#migrating-from-serve-otel" aria-label="Permalink to "Migrating from serve({ otel })""></a></h2><p><code>serve({ otel })</code> is removed. Delete the option. Set the same values with <code>OTEL_*</code> variables. Delete <code>bot/otel.ts</code>, <code>agent/otel.ts</code>, and <code>bot/instrumentation.ts</code>. Do not call <code>defineOtel</code>.</p><p>BDK sends each signal to one URL. A second exporter for the same signal has no variable.</p><table tabindex="0"><thead><tr><th>Old option</th><th>Set this instead</th></tr></thead><tbody><tr><td><code>serviceName</code></td><td><code>OTEL_SERVICE_NAME</code></td></tr><tr><td><code>serviceVersion</code></td><td><code>service.version</code> in <code>OTEL_RESOURCE_ATTRIBUTES</code></td></tr><tr><td><code>resourceAttributes</code></td><td><code>OTEL_RESOURCE_ATTRIBUTES</code>. Separate pairs with commas. URL-encode each value.</td></tr><tr><td><code>exporters[].url</code></td><td><code>OTEL_EXPORTER_OTLP_ENDPOINT</code>. BDK appends <code>/v1/traces</code>, <code>/v1/metrics</code>, and <code>/v1/logs</code>.</td></tr><tr><td><code>exporters[].url</code> with <code>signals</code></td><td><code>OTEL_EXPORTER_OTLP_TRACES_ENDPOINT</code>, <code>OTEL_EXPORTER_OTLP_METRICS_ENDPOINT</code>, or <code>OTEL_EXPORTER_OTLP_LOGS_ENDPOINT</code>. BDK uses that URL as written.</td></tr><tr><td><code>exporters[].headers</code></td><td><code>OTEL_EXPORTER_OTLP_HEADERS</code>. Separate pairs with commas. URL-encode each value.</td></tr><tr><td><code>exporters[].protocol</code></td><td><code>OTEL_EXPORTER_OTLP_PROTOCOL</code>. Use <code>http/protobuf</code> or <code>http/json</code>. For one signal, use <code>OTEL_EXPORTER_OTLP_TRACES_PROTOCOL</code>, <code>OTEL_EXPORTER_OTLP_METRICS_PROTOCOL</code>, or <code>OTEL_EXPORTER_OTLP_LOGS_PROTOCOL</code>.</td></tr><tr><td><code>exporters[].signals</code></td><td>Set the signal URL above. Set <code>OTEL_TRACES_EXPORTER</code>, <code>OTEL_METRICS_EXPORTER</code>, or <code>OTEL_LOGS_EXPORTER</code> to <code>none</code> to stop that signal.</td></tr><tr><td><code>traces: false</code></td><td><code>OTEL_TRACES_EXPORTER=none</code></td></tr><tr><td><code>traces: true</code></td><td>Leave <code>OTEL_TRACES_EXPORTER</code> unset. Traces start when an endpoint is set.</td></tr><tr><td><code>traces.sampleRatio</code></td><td><code>OTEL_TRACES_SAMPLER=parentbased_traceidratio</code> and <code>OTEL_TRACES_SAMPLER_ARG</code> set to the ratio. Set both before the process starts.</td></tr><tr><td><code>metrics: false</code></td><td><code>OTEL_METRICS_EXPORTER=none</code></td></tr><tr><td><code>metrics: true</code></td><td>Leave <code>OTEL_METRICS_EXPORTER</code> unset. Metrics start when a metrics URL is set.</td></tr><tr><td><code>metrics.exportIntervalMillis</code></td><td><code>OTEL_METRIC_EXPORT_INTERVAL</code>, in milliseconds. Set it before the process starts.</td></tr><tr><td><code>logs: false</code></td><td>Leave <code>OTEL_LOGS_EXPORTER</code> unset, or set it to <code>none</code>.</td></tr><tr><td><code>logs: true</code></td><td><code>OTEL_LOGS_EXPORTER=otlp</code></td></tr><tr><td><code>logs.userPrompts</code></td><td><code>OTEL_LOGS_EXPORTER=otlp</code> and <code>OTEL_LOG_USER_PROMPTS=1</code></td></tr><tr><td><code>logs.toolContent</code></td><td><code>OTEL_LOGS_EXPORTER=otlp</code> and <code>OTEL_LOG_TOOL_CONTENT=1</code></td></tr><tr><td><code>otel: false</code></td><td>Set no endpoint, or set <code>OTEL_SDK_DISABLED=true</code>.</td></tr></tbody></table><p>Before:</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> serve</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"."</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span></span>
|
|
25
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> otel: {</span></span>
|
|
26
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> serviceName: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"incident-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
27
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> exporters: [</span></span>
|
|
28
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
|
|
29
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> url: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"https://otel.example.com"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
30
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> headers: { Authorization: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">\`Bearer \${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">process</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">env</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">OTEL_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ??</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ""}\`</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
31
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
32
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ],</span></span>
|
|
33
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
34
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>After:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_SERVICE_NAME</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">incident-agent</span></span>
|
|
35
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_EXPORTER_OTLP_ENDPOINT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">https://otel.example.com</span></span>
|
|
36
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> OTEL_EXPORTER_OTLP_HEADERS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Authorization=Bearer%20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$OTEL_TOKEN</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"</span></span>
|
|
37
|
+
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> serve</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dev</span></span></code></pre></div><p>On a hosted agent, put the same names in <code>hosting.secretNames</code>. Add the collector host to <code>hosting.egressDomains</code>. Then run:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> secrets</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> my-agent</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> OTEL_SERVICE_NAME</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> OTEL_EXPORTER_OTLP_ENDPOINT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> OTEL_EXPORTER_OTLP_HEADERS</span></span></code></pre></div>`,35)])])}const k=e(n,[["render",d]]);export{E as __pageData,k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,c as t,o as i,a3 as a}from"./chunks/framework.BNw1pucY.js";const E=JSON.parse('{"title":"OpenTelemetry","description":"","frontmatter":{},"headers":[],"relativePath":"guides/opentelemetry.md","filePath":"guides/opentelemetry.md"}'),n={name:"guides/opentelemetry.md"};function d(o,s,r,h,l,p){return i(),t("div",null,[...s[0]||(s[0]=[a("",35)])])}const k=e(n,[["render",d]]);export{E as __pageData,k as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as a,c as i,o as e,a3 as
|
|
1
|
+
import{_ as a,c as i,o as e,a3 as t}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Slack","description":"Wake your agent from mentions, DMs, and watched posts, then reply in the thread.","frontmatter":{"title":"Slack","description":"Wake your agent from mentions, DMs, and watched posts, then reply in the thread."},"headers":[],"relativePath":"guides/slack.md","filePath":"guides/slack.md"}'),n={name:"guides/slack.md"};function l(h,s,p,o,k,d){return e(),i("div",null,[...s[0]||(s[0]=[t(`<h1 id="slack-agents" tabindex="-1">Slack agents <a class="header-anchor" href="#slack-agents" aria-label="Permalink to "Slack agents""></a></h1><p>A Slack agent wakes when someone mentions it, sends it a DM, or posts in a channel it watches. From there, it keeps the conversation in one thread and can reply all at once, stream the answer live, or decide for itself when to post updates.</p><p>Run <code>bdk slack create --dir .</code>, then <code>bdk slack doctor</code>.</p><h2 id="answer-a-mention-or-dm" tabindex="-1">Answer a mention or DM <a class="header-anchor" href="#answer-a-mention-or-dm" aria-label="Permalink to "Answer a mention or DM""></a></h2><p>Mention the bot in a channel or send it a DM, and it will answer in a thread on that message. Any follow-up in the same thread continues the conversation where it left off.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// bot/channels/slack.ts</span></span>
|
|
2
2
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { slackChannel } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk/channels/slack"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
3
3
|
<span class="line"></span>
|
|
4
4
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> slackChannel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
@@ -32,7 +32,12 @@ import{_ as a,c as i,o as e,a3 as n}from"./chunks/framework.BNw1pucY.js";const c
|
|
|
32
32
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> slackChannel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
33
33
|
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // \`post-update\` writes mid-turn progress and the final reply.</span></span>
|
|
34
34
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> reply: { mode: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"agentic"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
35
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><
|
|
35
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><h3 id="show-steps-as-cards-or-as-a-checklist" tabindex="-1">Show steps as cards or as a checklist <a class="header-anchor" href="#show-steps-as-cards-or-as-a-checklist" aria-label="Permalink to "Show steps as cards or as a checklist""></a></h3><p>The agent calls <code>post-card</code> to show one step of its work, such as "Scan the repo". Each card has an <code>id</code>, a <code>title</code>, a <code>status</code>, and optional <code>details</code>. When the agent calls <code>post-card</code> again with the same <code>id</code>, Slack updates that card. The agent uses this to move a step from <code>in_progress</code> to <code>complete</code>.</p><p><code>cards</code> sets how Slack draws these steps:</p><table tabindex="0"><thead><tr><th><code>cards</code></th><th>What Slack shows</th><th>Use it when</th></tr></thead><tbody><tr><td><code>{ display: "timeline" }</code> (default)</td><td>Each step is a separate card in the thread.</td><td>The turn has one or two short steps.</td></tr><tr><td><code>{ display: "plan" }</code></td><td>All steps from one turn are in one checklist.</td><td>The turn has several steps, and readers want to see progress in one place.</td></tr></tbody></table><p>This bot shows its steps as one checklist with the title "Release check":</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> slackChannel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
36
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> reply: {</span></span>
|
|
37
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> mode: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"agentic"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
|
38
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cards: { display: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"plan"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, title: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Release check"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
39
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
40
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>Know these rules for a plan:</p><ul><li>The <code>title</code> is optional. It can have at most 256 characters.</li><li>You set the <code>title</code> in the channel configuration. The agent cannot change the title.</li><li>Each turn starts a new checklist with the same title.</li><li>The <code>pending</code> status shows a step that has not started. Use <code>pending</code> only in a plan.</li><li><code>slackChannel</code> stops at startup if <code>cards</code> is not valid. For example, a <code>title</code> with <code>display: "timeline"</code> stops startup.</li></ul><p><code>display</code> is Slack's <a href="https://docs.slack.dev/reference/methods/chat.startStream/" target="_blank" rel="noreferrer"><code>task_display_mode</code></a>, and the channel sends <code>title</code> as a <code>plan_update</code> chunk.</p><h2 id="wake-on-a-channel-post" tabindex="-1">Wake on a channel post <a class="header-anchor" href="#wake-on-a-channel-post" aria-label="Permalink to "Wake on a channel post""></a></h2><p>This example watches <code>#triage-alerts</code>, so any substantial top-level message starts a thread even when nobody mentions the bot. The length guard filters out short posts before they can start a turn.</p><p>Mentions work in any channel the bot has joined. Listening without a mention requires an explicit allowlist with at least one channel ID starting with <code>C</code> or <code>G</code> and at most 10 distinct IDs. You can add <code>#name</code> entries for readability. A lone <code>"*"</code> watches replies in every joined channel (<code>posts: "replies"</code>), but it does not wake on top-level posts. Do not mix <code>"*"</code> with channel IDs.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> slackChannel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
36
41
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> engagement: {</span></span>
|
|
37
42
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channelPosts: {</span></span>
|
|
38
43
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> allow: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"C0123ABCDEF"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#triage-alerts"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">],</span></span>
|
|
@@ -67,4 +72,4 @@ import{_ as a,c as i,o as e,a3 as n}from"./chunks/framework.BNw1pucY.js";const c
|
|
|
67
72
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">},</span></span></code></pre></div><p>Use the IDs on the hook <code>ctx</code> when handling an event, and <code>ctx.host.slack.getClient()</code> when a tool needs the Slack Web API.</p><h2 id="connect" tabindex="-1">Connect <a class="header-anchor" href="#connect" aria-label="Permalink to "Connect""></a></h2><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> login</span></span>
|
|
68
73
|
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> slack</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> create</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span></span>
|
|
69
74
|
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> slack</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> TRIAGE</span></span></code></pre></div><p>After you sign in, <code>slack create</code> opens <strong>Add Slack to this agent</strong> in the browser and writes the resulting tokens to <code>.env.local</code> without printing them. You can open the same wizard from <strong>Integrations</strong> on <a href="https://cursor.com/dashboard" target="_blank" rel="noreferrer">Deployed Agents</a>.</p><p>If Slack requires workspace-admin approval, keep <code>slack create</code> running and open the <strong>Request approval</strong> link printed by the CLI. Installing from the dashboard doesn't send that request for you. After an admin approves it, return to the dashboard's <strong>Add Slack</strong> wizard and select <strong>Retry</strong>.</p><p>If you already own the Slack app, initialize it with <code>bdk slack init --manual --dir . --name "Triage"</code> and follow the <a href="./../../skills/setup-slack/SKILL.html">Slack setup skill</a> for installation and tokens.</p><h2 id="test-locally" tabindex="-1">Test locally <a class="header-anchor" href="#test-locally" aria-label="Permalink to "Test locally""></a></h2><p>Run <code>doctor</code> first to catch missing credentials, then start the agent and send it the same mention or DM a teammate would.</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> slack</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> TRIAGE</span></span>
|
|
70
|
-
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> serve</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dev</span></span></code></pre></div><h2 id="practices" tabindex="-1">Practices <a class="header-anchor" href="#practices" aria-label="Permalink to "Practices""></a></h2><ul><li><p>If the tokens are missing, the Slack channel stays idle while the rest of <code>serve</code> starts normally.</p></li><li><p>Keep <code>channelPosts.allow</code> narrow because each qualifying post can start a model turn.</p></li><li><p>Set <code>envPrefix</code> when two Slack bots share a host so the token names do not collide.</p></li></ul><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../reference/cli.html#slack">CLI reference</a>: <code>slack create</code>, <code>doctor</code>, <code>init --manual</code></li><li><a href="./../../skills/setup-slack/SKILL.html"><code>skills/setup-slack/SKILL.md</code></a>: the companion skill for coding agents</li><li><a href="./webhooks.html">Webhooks and custom channels</a>: host prep on mention and DM handlers</li><li><a href="./../evals.html">Evals</a>: freeze a mention as a regression check</li></ul>`,
|
|
75
|
+
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bdk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> serve</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --dev</span></span></code></pre></div><h2 id="practices" tabindex="-1">Practices <a class="header-anchor" href="#practices" aria-label="Permalink to "Practices""></a></h2><ul><li><p>If the tokens are missing, the Slack channel stays idle while the rest of <code>serve</code> starts normally.</p></li><li><p>Keep <code>channelPosts.allow</code> narrow because each qualifying post can start a model turn.</p></li><li><p>Set <code>envPrefix</code> when two Slack bots share a host so the token names do not collide.</p></li></ul><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../reference/cli.html#slack">CLI reference</a>: <code>slack create</code>, <code>doctor</code>, <code>init --manual</code></li><li><a href="./../../skills/setup-slack/SKILL.html"><code>skills/setup-slack/SKILL.md</code></a>: the companion skill for coding agents</li><li><a href="./webhooks.html">Webhooks and custom channels</a>: host prep on mention and DM handlers</li><li><a href="./../evals.html">Evals</a>: freeze a mention as a regression check</li></ul>`,61)])])}const E=a(n,[["render",l]]);export{c as __pageData,E as default};
|
package/dist/docs/assets/{guides_slack.md.Bn-WupSE.lean.js → guides_slack.md.ClIyi7FI.lean.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as a,c as i,o as e,a3 as
|
|
1
|
+
import{_ as a,c as i,o as e,a3 as t}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Slack","description":"Wake your agent from mentions, DMs, and watched posts, then reply in the thread.","frontmatter":{"title":"Slack","description":"Wake your agent from mentions, DMs, and watched posts, then reply in the thread."},"headers":[],"relativePath":"guides/slack.md","filePath":"guides/slack.md"}'),n={name:"guides/slack.md"};function l(h,s,p,o,k,d){return e(),i("div",null,[...s[0]||(s[0]=[t("",61)])])}const E=a(n,[["render",l]]);export{c as __pageData,E as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,c as
|
|
1
|
+
import{_ as e,c as i,o as t,a3 as a}from"./chunks/framework.BNw1pucY.js";const k=JSON.parse('{"title":"Agent config","description":"defineAgent at bot/agent.ts: the model, local workspace, and programmatic serving.","frontmatter":{"title":"Agent config","description":"defineAgent at bot/agent.ts: the model, local workspace, and programmatic serving."},"headers":[],"relativePath":"reference/agent-config.md","filePath":"reference/agent-config.md"}'),n={name:"reference/agent-config.md"};function o(l,s,d,h,r,p){return t(),i("div",null,[...s[0]||(s[0]=[a(`<h1 id="agent-config" tabindex="-1">Agent config <a class="header-anchor" href="#agent-config" aria-label="Permalink to "Agent config""></a></h1><p><code>bot/agent.ts</code> default-exports <code>defineAgent(config)</code>: which model runs the agent and its local harness defaults. Everything is optional on the root agent.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { defineAgent } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
2
2
|
<span class="line"></span>
|
|
3
3
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defineAgent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
4
4
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model: {</span></span>
|
|
@@ -31,4 +31,8 @@ import{_ as e,c as t,o as i,a3 as a}from"./chunks/framework.BNw1pucY.js";const k
|
|
|
31
31
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span>
|
|
32
32
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">console.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">log</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">\`listening on \${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">handle</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">url</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}\`</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
33
33
|
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// handle.callTool(...), handle.dispatchSchedule("heartbeat"),</span></span>
|
|
34
|
-
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// handle.createReminder(...), handle.
|
|
34
|
+
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// handle.createReminder(...), handle.agents, await handle.close()</span></span></code></pre></div><p><code>handle.agents</code> lists each mount as <code>slug</code>, <code>url</code>, and <code>info</code>. <code>handle.project</code> is the first agent's project. It is deprecated.</p><p>Host settings match the documented <a href="./cli.html">CLI</a> <code>serve</code> flags. <code>serve()</code> also accepts <code>discovery</code> (project-loading options) and <code>mode: "single" | "multi"</code>. Pass <code>apiKey</code> or use the same Cursor credential as the CLI: <code>CURSOR_API_KEY</code>, <code>CURSOR_API_KEY_FILE</code>, <code>CURSOR_SERVICE_ACCOUNT_KEY</code>, or <code>bdk login</code>.</p><h2 id="inspect-a-project-in-tests" tabindex="-1">Inspect a project in tests <a class="header-anchor" href="#inspect-a-project-in-tests" aria-label="Permalink to "Inspect a project in tests""></a></h2><p><code>loadProject(dir)</code> reads one project and does not serve it. The result is a <code>Project</code>. The only field is <code>info</code>. That object matches the <code>GET /v1/info</code> body for the project. <code>bdk info --json</code> on a project directory prints <code>{ agents: [{ slug, ...info }] }</code>. It prints the bare object only when the single mount slug is empty.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { loadProject } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
35
|
+
<span class="line"></span>
|
|
36
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> project</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> loadProject</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"./my-agent"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
37
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">console.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">log</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(project.info.name);</span></span>
|
|
38
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">console.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">log</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(project.info.tools.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">map</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">((</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">tool</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tool.name));</span></span></code></pre></div><p><code>loadProject</code> throws <code>ProjectLoadError</code> when discovery reports an error. Pass <code>{ strict: true }</code> to throw on a warning as well. <code>error.diagnostics</code> lists the findings. Each <code>path</code> is relative to the project directory. A path outside that directory starts with <code>../</code>. <code>loadProject</code> does not take <code>importModule</code>. <code>serve</code> still accepts <code>discovery.importModule</code> for that override.</p><p><code>info.local</code> is <code>{ cwd }</code> when the project sets a cwd. The serve banner reads <code>agents[].info</code>.</p><p><code>serve</code> accepts that <code>Project</code> or a directory path.</p><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./instructions.html">Instructions</a>: the required half of a minimal agent</li><li><a href="./cli.html">CLI</a>: the <code>serve</code> flags <code>serve()</code> accepts</li><li><a href="./sessions.html">Sessions</a>: workspaces, identifiers, and turn admission</li><li><a href="./schedules.html">Schedules</a>: reminder tools opted in here</li></ul>`,48)])])}const g=e(n,[["render",o]]);export{k as __pageData,g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,c as
|
|
1
|
+
import{_ as e,c as i,o as t,a3 as a}from"./chunks/framework.BNw1pucY.js";const k=JSON.parse('{"title":"Agent config","description":"defineAgent at bot/agent.ts: the model, local workspace, and programmatic serving.","frontmatter":{"title":"Agent config","description":"defineAgent at bot/agent.ts: the model, local workspace, and programmatic serving."},"headers":[],"relativePath":"reference/agent-config.md","filePath":"reference/agent-config.md"}'),n={name:"reference/agent-config.md"};function o(l,s,d,h,r,p){return t(),i("div",null,[...s[0]||(s[0]=[a("",48)])])}const g=e(n,[["render",o]]);export{k as __pageData,g as default};
|
package/dist/docs/assets/{reference_channels.md.Bxaa020x.js → reference_channels.md.CNNIS6K7.js}
RENAMED
|
@@ -19,4 +19,4 @@ import{_ as t,c as s,o as a,a3 as n}from"./chunks/framework.BNw1pucY.js";const k
|
|
|
19
19
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
20
20
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }),</span></span>
|
|
21
21
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ],</span></span>
|
|
22
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>The route above is <code>POST /v1/channels/<id>/review</code>. Calls for the same pull request reuse one conversation because they pass the same continuation token.</p><h2 id="route-responses" tabindex="-1">Route responses <a class="header-anchor" href="#route-responses" aria-label="Permalink to "Route responses""></a></h2><p>A custom route acknowledges the caller and nothing more. On Cursor-managed hosting, the deployment answers every custom route with <code>202 Accepted</code> and an empty body as soon as the request arrives, then runs the handler. The caller never receives the handler's <code>Response</code>, so a route can't return a session ID, a computed result, or an error status. Requests rejected before the handler runs, such as a missing alias token or a failed <code>sharedSecretAuth</code> or <code>hmacSignatureAuth</code> check, still get <code>401</code>.</p><p>Deliver results through the channel's <a href="#events"><code>events</code></a> handlers, a callback to the system that sent the request, or a tool the turn calls. Local <code>serve</code> passes the handler's response through, so return <code>new Response(null, { status: 202 })</code> to keep local calls matching hosted ones.</p><h2 id="route-verbs-and-schemas" tabindex="-1">Route verbs and schemas <a class="header-anchor" href="#route-verbs-and-schemas" aria-label="Permalink to "Route verbs and schemas""></a></h2><p>Route paths must begin with <code>/</code>. The method helper determines which Zod schemas the route accepts:</p><table tabindex="0"><thead><tr><th>Helper</th><th>Schema contract</th></tr></thead><tbody><tr><td><code>GET</code></td><td><code>querySchema</code> is required</td></tr><tr><td><code>POST</code>, <code>PUT</code>, <code>PATCH</code></td><td><code>bodySchema</code> is required; <code>querySchema</code> is optional</td></tr><tr><td><code>DELETE</code></td><td>Both schemas are optional</td></tr></tbody></table><p>Plain JSON Schema objects don't type-check. Use <code>z.object({})</code> or <code>z.unknown()</code> for an open surface. The host validates the body and query before calling the handler, and an empty body is read as <code>{}</code>. A request that fails validation never reaches the handler; local <code>serve</code> answers it with <code>400</code>, while a hosted caller has already received its <code>202</code>. Declared schemas also appear in <code>GET /v1/info</code> for playground requests and slash commands.</p><h2 id="handler-arguments" tabindex="-1">Handler arguments <a class="header-anchor" href="#handler-arguments" aria-label="Permalink to "Handler arguments""></a></h2><p>Each handler receives the Fetch <code>Request</code> and a typed arguments object.</p><table tabindex="0"><thead><tr><th>Member</th><th>Contract</th></tr></thead><tbody><tr><td><code>send(message, options?)</code></td><td>Start or resume a session on this channel</td></tr><tr><td><code>getSession(sessionId)</code></td><td>Return this channel's session, or <code>null</code></td></tr><tr><td><code>receive(channel, input)</code></td><td>Hand work to another channel</td></tr><tr><td><code>callTool(name, input, options?)</code></td><td><a href="./tools.html#call-a-tool-without-a-model-turn">Call a server tool</a> without a model turn</td></tr><tr><td><code>body</code>, <code>query</code>, <code>params</code></td><td>Validated inputs and <code>:param</code> path segments</td></tr><tr><td><code>auth</code></td><td>The <code>AuthContext</code> returned by the route's auth chain</td></tr><tr><td><code>requestIp</code></td><td>The TCP peer address, or <code>null</code></td></tr><tr><td><code>host</code></td><td>Shared MCP, provider, storage, telemetry, and reminder services</td></tr><tr><td><code>waitUntil(promise)</code></td><td>Keep work running after the handler returns</td></tr><tr><td><code>sessionUrls(request, sessionId)</code></td><td>Build absolute playground and trace URLs for this mount</td></tr><tr><td><code>artifacts</code></td><td>List or tag <a href="./artifacts.html">artifacts</a>; pass <code>sessionId</code> when attributing one</td></tr></tbody></table><h3 id="send-options" tabindex="-1"><code>send</code> options <a class="header-anchor" href="#send-options" aria-label="Permalink to "\`send\` options""></a></h3><table tabindex="0"><thead><tr><th>Option</th><th>Contract</th></tr></thead><tbody><tr><td><code>continuationToken</code></td><td>Resume the session with this channel-local key, or create one when the key is new</td></tr><tr><td><code>admission</code></td><td><code>"preempt"</code> interrupts a busy turn; <code>"coalesce"</code> queues behind it. The default is <code>"preempt"</code></td></tr><tr><td><code>workspaceFiles</code></td><td>Add relative files for the next turn</td></tr><tr><td><code>workspaceDir</code></td><td>Use an absolute local working directory</td></tr><tr><td><code>auth</code></td><td>Set the session principal; defaults to the request principal</td></tr><tr><td><code>state</code></td><td>Set starting channel state for a new session</td></tr><tr><td><code>title</code></td><td>Set the display title for a new session</td></tr><tr><td><code>purpose</code></td><td>Use <code>"eval"</code> to mark a new session as regression traffic</td></tr><tr><td><code>dryRun</code></td><td>Run read tools and stub write tools for a new session</td></tr><tr><td><code>asOf</code></td><td>Freeze a new session at an ISO-8601 instant with a timezone</td></tr></tbody></table><p><code>send</code> returns a <code>ChannelSession</code>. Its <code>id</code> identifies the session, <code>continuationToken</code> contains its current channel key, and <code>isNew</code> says whether this call created it. A coalesced call also returns <code>coalesced: true</code>.</p><h2 id="events" tabindex="-1">Events <a class="header-anchor" href="#events" aria-label="Permalink to "Events""></a></h2><p>The <code>events</code> map subscribes the channel to stream events for the sessions it owns. Keys are event types from the <a href="./sessions.html#stream-events">event vocabulary</a>, or <code>"*"</code>. Each handler receives <code>(event, channel, ctx)</code>, including the session's <code>channel.state</code>, session info, and shared host services. Use these handlers to deliver progress and replies to the surface that owns the channel.</p><h2 id="session-state" tabindex="-1">Session state <a class="header-anchor" href="#session-state" aria-label="Permalink to "Session state""></a></h2><p><code>state</code> on the channel definition supplies starting JSON for each new session. A route can instead pass <code>state</code> to <code>send</code>; event handlers read and update the active value through <code>channel.state</code>.</p><h2 id="start-and-stop-a-channel" tabindex="-1">Start and stop a channel <a class="header-anchor" href="#start-and-stop-a-channel" aria-label="Permalink to "Start and stop a channel""></a></h2><p><code>onStart(args)</code> runs when the channel mounts, and <code>onStop()</code> runs when the host stops. <code>onStart</code> receives the route helpers plus these transport controls:</p><table tabindex="0"><thead><tr><th>Helper</th><th>Contract</th></tr></thead><tbody><tr><td><code>emitAssistantMessage(sessionId, text)</code></td><td>Append final assistant text without starting a model turn</td></tr><tr><td><code>hasContinuationSession(token)</code></td><td>Check whether a token maps to a session</td></tr><tr><td><code>isContinuationBusy(token)</code></td><td>Check whether a turn is active for a token</td></tr><tr><td><code>interruptContinuation(token)</code></td><td>Stop the active turn and clear queued coalesced follow-ups</td></tr></tbody></table><h2 id="auth-policies" tabindex="-1">Auth policies <a class="header-anchor" href="#auth-policies" aria-label="Permalink to "Auth policies""></a></h2><p>Every route runs the channel's <code>auth</code> array. The default is <code>[localDevStrict()]</code>. Policies may be asynchronous; the first one to return an <code>AuthContext</code> admits the request, and an all-null result returns <code>401</code>.</p><table tabindex="0"><thead><tr><th>Policy</th><th>Admits</th></tr></thead><tbody><tr><td><code>localDevStrict()</code></td><td>Direct loopback requests with a loopback hostname and no proxy-forwarding headers</td></tr><tr><td><code>localDev()</code></td><td>Direct loopback requests with no proxy-forwarding headers, without checking the hostname</td></tr><tr><td><code>loopbackOnly()</code></td><td>Any loopback TCP peer, including local relays that carry forwarding headers</td></tr><tr><td><code>bearerAuth(tokenOrVerify)</code></td><td>A matching bearer token, or a token accepted by the verifier</td></tr><tr><td><code>sharedSecretAuth({ header, secret })</code></td><td>A header matching the named environment or deployment secret</td></tr><tr><td><code>hmacSignatureAuth({ header, secret, prefix?, separator? })</code></td><td>A hex HMAC-SHA256 signature over the raw body using the named secret. With <code>separator</code>, any of several signatures in the header. A secret holding one value per line verifies under any of them (at most 32, <code>@cursor/bdk</code> 0.2.25 or later)</td></tr><tr><td><code>allowAll()</code></td><td>Every caller as an anonymous principal</td></tr><tr><td><code>publicEndpoint()</code></td><td>Every caller on this custom channel; managed hosting also exposes the route without an alias token</td></tr></tbody></table><p>Use <code>allowAll()</code> only for an intentionally public surface or one protected upstream. With <code>publicEndpoint()</code>, the handler must verify the provider's signature. The policy applies only to custom channel routes; it doesn't open the built-in session or tool API.</p><p>The resolved <code>AuthContext</code> (<code>{ authenticator, principalId, principalType, attributes? }</code>) becomes the request principal. Sessions belong to the principal that created them, and other principals receive <code>403</code> on owned routes.</p><p>Server flags interact with authored auth: <code>--bearer-token</code> swaps the default <code>localDevStrict()</code> for <code>bearerAuth(...)</code> on channels that don't author their own chain, and <code>--allow-anonymous</code> swaps it for <code>allowAll()</code>. An authored <code>auth</code> array always takes precedence.</p><h2 id="prebuilt-channels" tabindex="-1">Prebuilt channels <a class="header-anchor" href="#prebuilt-channels" aria-label="Permalink to "Prebuilt channels""></a></h2><table tabindex="0"><thead><tr><th>Import</th><th>Function</th><th>Surface</th></tr></thead><tbody><tr><td><code>@cursor/bdk/channels/slack</code></td><td><code>slackChannel()</code></td><td>Slack messages, threads, and streaming replies. See <a href="./../guides/slack.html">Slack</a></td></tr><tr><td><code>@cursor/bdk/channels/github</code></td><td><code>githubChannel()</code></td><td>GitHub and GitHub Enterprise webhooks. See <a href="./../guides/github.html">GitHub</a></td></tr><tr><td><code>@cursor/bdk/channels/gitlab</code></td><td><code>gitlabChannel()</code></td><td>GitLab.com and self-managed GitLab hooks. See <a href="./../guides/gitlab.html">GitLab</a></td></tr><tr><td><code>@cursor/bdk/channels/bitbucket</code></td><td><code>bitbucketChannel()</code></td><td>Bitbucket Cloud and Data Center hooks. See <a href="./../guides/bitbucket.html">Bitbucket</a></td></tr><tr><td><code>@cursor/bdk/channels/pagerduty</code></td><td><code>pagerdutyChannel()</code></td><td>PagerDuty v3 incident webhooks. Replies post as incident notes only with <code>deliverReplies: true</code>. See <a href="./../guides/pagerduty.html">PagerDuty</a></td></tr><tr><td><code>@cursor/bdk/channels/deployments</code></td><td><code>deploymentsChannel()</code></td><td>Deployment events filtered by source, environment, or event name</td></tr></tbody></table><p>For other platforms like Discord or Teams, use the authored <code>defineChannel</code> route form.</p><h2 id="continuation-tokens" tabindex="-1">Continuation tokens <a class="header-anchor" href="#continuation-tokens" aria-label="Permalink to "Continuation tokens""></a></h2><p>Each channel defines its continuation-token format. The same token resumes the same conversation; the built-in HTTP channel rotates its opaque token after every accepted follow-up and returns <code>409</code> for a stale token. See <a href="./sessions.html#session-identifiers">Session identifiers</a> for the full contract.</p><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../guides/webhooks.html">Webhooks</a></li><li><a href="./http-api.html">HTTP API</a></li><li><a href="./sessions.html">Sessions</a></li><li><a href="./hooks.html">Hooks</a></li></ul>`,41)])])}const u=t(i,[["render",o]]);export{k as __pageData,u as default};
|
|
22
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>The route above is <code>POST /v1/channels/<id>/review</code>. Calls for the same pull request reuse one conversation because they pass the same continuation token.</p><h2 id="route-responses" tabindex="-1">Route responses <a class="header-anchor" href="#route-responses" aria-label="Permalink to "Route responses""></a></h2><p>A custom route acknowledges the caller and nothing more. On Cursor-managed hosting, the deployment answers every custom route with <code>202 Accepted</code> and an empty body as soon as the request arrives, then runs the handler. The caller never receives the handler's <code>Response</code>, so a route can't return a session ID, a computed result, or an error status. Requests rejected before the handler runs, such as a missing alias token or a failed <code>sharedSecretAuth</code> or <code>hmacSignatureAuth</code> check, still get <code>401</code>.</p><p>Deliver results through the channel's <a href="#events"><code>events</code></a> handlers, a callback to the system that sent the request, or a tool the turn calls. Local <code>serve</code> passes the handler's response through, so return <code>new Response(null, { status: 202 })</code> to keep local calls matching hosted ones.</p><h2 id="route-verbs-and-schemas" tabindex="-1">Route verbs and schemas <a class="header-anchor" href="#route-verbs-and-schemas" aria-label="Permalink to "Route verbs and schemas""></a></h2><p>Route paths must begin with <code>/</code>. The method helper determines which Zod schemas the route accepts:</p><table tabindex="0"><thead><tr><th>Helper</th><th>Schema contract</th></tr></thead><tbody><tr><td><code>GET</code></td><td><code>querySchema</code> is required</td></tr><tr><td><code>POST</code>, <code>PUT</code>, <code>PATCH</code></td><td><code>bodySchema</code> is required; <code>querySchema</code> is optional</td></tr><tr><td><code>DELETE</code></td><td>Both schemas are optional</td></tr></tbody></table><p>Plain JSON Schema objects don't type-check. Use <code>z.object({})</code> or <code>z.unknown()</code> for an open surface. The host validates the body and query before calling the handler, and an empty body is read as <code>{}</code>. A request that fails validation never reaches the handler; local <code>serve</code> answers it with <code>400</code>, while a hosted caller has already received its <code>202</code>. Declared schemas also appear in <code>GET /v1/info</code> for playground requests and slash commands.</p><h2 id="handler-arguments" tabindex="-1">Handler arguments <a class="header-anchor" href="#handler-arguments" aria-label="Permalink to "Handler arguments""></a></h2><p>Each handler receives the Fetch <code>Request</code> and a typed arguments object.</p><table tabindex="0"><thead><tr><th>Member</th><th>Contract</th></tr></thead><tbody><tr><td><code>send(message, options?)</code></td><td>Start or resume a session on this channel</td></tr><tr><td><code>getSession(sessionId)</code></td><td>Return this channel's session, or <code>null</code></td></tr><tr><td><code>receive(channel, input)</code></td><td>Hand work to another channel</td></tr><tr><td><code>callTool(name, input, options?)</code></td><td><a href="./tools.html#call-a-tool-without-a-model-turn">Call a server tool</a> without a model turn</td></tr><tr><td><code>body</code>, <code>query</code>, <code>params</code></td><td>Validated inputs and <code>:param</code> path segments</td></tr><tr><td><code>auth</code></td><td>The <code>AuthContext</code> returned by the route's auth chain</td></tr><tr><td><code>requestIp</code></td><td>The TCP peer address, or <code>null</code></td></tr><tr><td><code>host</code></td><td>Shared MCP, provider, storage, telemetry, and reminder services</td></tr><tr><td><code>waitUntil(promise)</code></td><td>Keep work running after the handler returns</td></tr><tr><td><code>sessionUrls(request, sessionId)</code></td><td>Build absolute playground and trace URLs for this mount</td></tr><tr><td><code>artifacts</code></td><td>List or tag <a href="./artifacts.html">artifacts</a>; pass <code>sessionId</code> when attributing one</td></tr></tbody></table><h3 id="send-options" tabindex="-1"><code>send</code> options <a class="header-anchor" href="#send-options" aria-label="Permalink to "\`send\` options""></a></h3><table tabindex="0"><thead><tr><th>Option</th><th>Contract</th></tr></thead><tbody><tr><td><code>continuationToken</code></td><td>Resume the session with this channel-local key, or create one when the key is new</td></tr><tr><td><code>admission</code></td><td><code>"preempt"</code> interrupts a busy turn; <code>"coalesce"</code> queues behind it. The default is <code>"preempt"</code></td></tr><tr><td><code>workspaceFiles</code></td><td>Add relative files for the next turn</td></tr><tr><td><code>workspaceDir</code></td><td>Use an absolute local working directory</td></tr><tr><td><code>auth</code></td><td>Set the session principal; defaults to the request principal</td></tr><tr><td><code>state</code></td><td>Set starting channel state for a new session</td></tr><tr><td><code>title</code></td><td>Set the display title for a new session</td></tr><tr><td><code>purpose</code></td><td>Use <code>"eval"</code> to mark a new session as regression traffic</td></tr><tr><td><code>dryRun</code></td><td>Run read tools and stub write tools for a new session</td></tr><tr><td><code>asOf</code></td><td>Freeze a new session at an ISO-8601 instant with a timezone</td></tr><tr><td><code>deliveryId</code></td><td>Name this send on the session's events, at most 256 characters. Defaults to a fresh <code>dlv_…</code> ID</td></tr></tbody></table><p><code>send</code> returns a <code>ChannelSession</code>. Its <code>id</code> identifies the session, <code>continuationToken</code> contains its current channel key, and <code>isNew</code> says whether this call created it. A coalesced call also returns <code>coalesced: true</code>. <code>deliveryId</code> names this send on the event where the message reaches the agent; see <a href="./sessions.html#track-which-follow-up-reached-the-agent">Track which follow-up reached the agent</a>. A hosted channel's <code>send</code> returns the same ID before the session exists.</p><h2 id="events" tabindex="-1">Events <a class="header-anchor" href="#events" aria-label="Permalink to "Events""></a></h2><p>The <code>events</code> map subscribes the channel to stream events for the sessions it owns. Keys are event types from the <a href="./sessions.html#stream-events">event vocabulary</a>, or <code>"*"</code>. Each handler receives <code>(event, channel, ctx)</code>, including the session's <code>channel.state</code>, session info, and shared host services. Use these handlers to deliver progress and replies to the surface that owns the channel.</p><h2 id="session-state" tabindex="-1">Session state <a class="header-anchor" href="#session-state" aria-label="Permalink to "Session state""></a></h2><p><code>state</code> on the channel definition supplies starting JSON for each new session. A route can instead pass <code>state</code> to <code>send</code>; event handlers read and update the active value through <code>channel.state</code>.</p><h2 id="start-and-stop-a-channel" tabindex="-1">Start and stop a channel <a class="header-anchor" href="#start-and-stop-a-channel" aria-label="Permalink to "Start and stop a channel""></a></h2><p><code>onStart(args)</code> runs when the channel mounts, and <code>onStop()</code> runs when the host stops. <code>onStart</code> receives the route helpers plus these transport controls:</p><table tabindex="0"><thead><tr><th>Helper</th><th>Contract</th></tr></thead><tbody><tr><td><code>emitAssistantMessage(sessionId, text)</code></td><td>Append final assistant text without starting a model turn</td></tr><tr><td><code>hasContinuationSession(token)</code></td><td>Check whether a token maps to a session</td></tr><tr><td><code>isContinuationBusy(token)</code></td><td>Check whether a turn is active for a token</td></tr><tr><td><code>interruptContinuation(token)</code></td><td>Stop the active turn and clear queued coalesced follow-ups</td></tr></tbody></table><h2 id="auth-policies" tabindex="-1">Auth policies <a class="header-anchor" href="#auth-policies" aria-label="Permalink to "Auth policies""></a></h2><p>Every route runs the channel's <code>auth</code> array. The default is <code>[localDevStrict()]</code>. Policies may be asynchronous; the first one to return an <code>AuthContext</code> admits the request, and an all-null result returns <code>401</code>.</p><table tabindex="0"><thead><tr><th>Policy</th><th>Admits</th></tr></thead><tbody><tr><td><code>localDevStrict()</code></td><td>Direct loopback requests with a loopback hostname and no proxy-forwarding headers</td></tr><tr><td><code>localDev()</code></td><td>Direct loopback requests with no proxy-forwarding headers, without checking the hostname</td></tr><tr><td><code>loopbackOnly()</code></td><td>Any loopback TCP peer, including local relays that carry forwarding headers</td></tr><tr><td><code>bearerAuth(tokenOrVerify)</code></td><td>A matching bearer token, or a token accepted by the verifier</td></tr><tr><td><code>sharedSecretAuth({ header, secret })</code></td><td>A header matching the named environment or deployment secret</td></tr><tr><td><code>hmacSignatureAuth({ header, secret, prefix?, separator? })</code></td><td>A hex HMAC-SHA256 signature over the raw body using the named secret. With <code>separator</code>, any of several signatures in the header. A secret holding one value per line verifies under any of them (at most 32, <code>@cursor/bdk</code> 0.2.25 or later)</td></tr><tr><td><code>allowAll()</code></td><td>Every caller as an anonymous principal</td></tr><tr><td><code>publicEndpoint()</code></td><td>Every caller on this custom channel; managed hosting also exposes the route without an alias token</td></tr></tbody></table><p>Use <code>allowAll()</code> only for an intentionally public surface or one protected upstream. With <code>publicEndpoint()</code>, the handler must verify the provider's signature. The policy applies only to custom channel routes; it doesn't open the built-in session or tool API.</p><p>The resolved <code>AuthContext</code> (<code>{ authenticator, principalId, principalType, attributes? }</code>) becomes the request principal. Sessions belong to the principal that created them, and other principals receive <code>403</code> on owned routes.</p><p>Server flags interact with authored auth: <code>--bearer-token</code> swaps the default <code>localDevStrict()</code> for <code>bearerAuth(...)</code> on channels that don't author their own chain, and <code>--allow-anonymous</code> swaps it for <code>allowAll()</code>. An authored <code>auth</code> array always takes precedence.</p><h2 id="prebuilt-channels" tabindex="-1">Prebuilt channels <a class="header-anchor" href="#prebuilt-channels" aria-label="Permalink to "Prebuilt channels""></a></h2><table tabindex="0"><thead><tr><th>Import</th><th>Function</th><th>Surface</th></tr></thead><tbody><tr><td><code>@cursor/bdk/channels/slack</code></td><td><code>slackChannel()</code></td><td>Slack messages, threads, and streaming replies. See <a href="./../guides/slack.html">Slack</a></td></tr><tr><td><code>@cursor/bdk/channels/github</code></td><td><code>githubChannel()</code></td><td>GitHub and GitHub Enterprise webhooks. See <a href="./../guides/github.html">GitHub</a></td></tr><tr><td><code>@cursor/bdk/channels/gitlab</code></td><td><code>gitlabChannel()</code></td><td>GitLab.com and self-managed GitLab hooks. See <a href="./../guides/gitlab.html">GitLab</a></td></tr><tr><td><code>@cursor/bdk/channels/bitbucket</code></td><td><code>bitbucketChannel()</code></td><td>Bitbucket Cloud and Data Center hooks. See <a href="./../guides/bitbucket.html">Bitbucket</a></td></tr><tr><td><code>@cursor/bdk/channels/pagerduty</code></td><td><code>pagerdutyChannel()</code></td><td>PagerDuty v3 incident webhooks. Replies post as incident notes only with <code>deliverReplies: true</code>. See <a href="./../guides/pagerduty.html">PagerDuty</a></td></tr><tr><td><code>@cursor/bdk/channels/deployments</code></td><td><code>deploymentsChannel()</code></td><td>Deployment events filtered by source, environment, or event name</td></tr></tbody></table><p>For other platforms like Discord or Teams, use the authored <code>defineChannel</code> route form.</p><h2 id="continuation-tokens" tabindex="-1">Continuation tokens <a class="header-anchor" href="#continuation-tokens" aria-label="Permalink to "Continuation tokens""></a></h2><p>Each channel defines its continuation-token format. The same token resumes the same conversation; the built-in HTTP channel rotates its opaque token after every accepted follow-up and returns <code>409</code> for a stale token. See <a href="./sessions.html#session-identifiers">Session identifiers</a> for the full contract.</p><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../guides/webhooks.html">Webhooks</a></li><li><a href="./http-api.html">HTTP API</a></li><li><a href="./sessions.html">Sessions</a></li><li><a href="./hooks.html">Hooks</a></li></ul>`,41)])])}const u=t(i,[["render",o]]);export{k as __pageData,u as default};
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import{_ as e,c as t,o as a,a3 as i}from"./chunks/framework.BNw1pucY.js";const
|
|
1
|
+
import{_ as e,c as t,o as a,a3 as i}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Hooks","description":"Observe-only subscribers to the session event stream: audit logs, metrics, transcript mirrors, derived state.","frontmatter":{"title":"Hooks","description":"Observe-only subscribers to the session event stream: audit logs, metrics, transcript mirrors, derived state."},"headers":[],"relativePath":"reference/hooks.md","filePath":"reference/hooks.md"}'),n={name:"reference/hooks.md"};function o(d,s,h,l,r,k){return a(),t("div",null,[...s[0]||(s[0]=[i(`<h1 id="hooks" tabindex="-1">Hooks <a class="header-anchor" href="#hooks" aria-label="Permalink to "Hooks""></a></h1><p>A hook subscribes to selected session events and can run a side effect after each matching event is recorded: an audit line, a metric, a transcript copy, or derived state. Hooks run in the serving process for every session of the agent. They cannot change the turn, the prompt, or the reply; a handler that throws is logged and skipped.</p><p>Treat the event as read-only. Later subscribers see the same object. That makes hooks safe to add to a production agent, and the wrong surface for anything that must run before the model or must fail a turn; see <a href="#hook-boundaries">Hook boundaries</a>.</p><p><code>defineHook</code> is unrelated to <a href="https://cursor.com/docs/agent/hooks" target="_blank" rel="noreferrer">Cursor Agent hooks</a>, the <code>.cursor/hooks.json</code> scripts that can observe, block, or modify the agent loop. Those still run inside a local session workspace.</p><h2 id="author-a-hook" tabindex="-1">Author a hook <a class="header-anchor" href="#author-a-hook" aria-label="Permalink to "Author a hook""></a></h2><p>Author <code>bot/hooks/<name>.ts</code> with <code>defineHook</code> from <code>@cursor/bdk/hooks</code>. This one meters tokens:</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// bot/hooks/usage.ts</span></span>
|
|
2
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { metrics } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@opentelemetry/api"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
2
3
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { defineHook } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk/hooks"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
3
4
|
<span class="line"></span>
|
|
5
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> meter</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metrics.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getMeter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"acme"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
6
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> inputTokens</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> meter.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">createCounter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"acme.tokens.input"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
7
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> outputTokens</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> meter.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">createCounter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"acme.tokens.output"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
8
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> turnFailed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> meter.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">createCounter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"acme.turn.failed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
|
|
9
|
+
<span class="line"></span>
|
|
4
10
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defineHook</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
5
11
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> events: {</span></span>
|
|
6
12
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> async</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "turn.completed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">event</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">ctx</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
|
|
7
13
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (ctx.session.purpose </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">===</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "eval"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.data.usage </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">===</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> undefined</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
|
|
8
14
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
9
15
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
|
10
|
-
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#
|
|
11
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">
|
|
12
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">
|
|
16
|
+
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> usage</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.data.usage;</span></span>
|
|
17
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> inputTokens.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(usage.inputTokens);</span></span>
|
|
18
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> outputTokens.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(usage.outputTokens);</span></span>
|
|
13
19
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
14
20
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> async</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "turn.failed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">_event</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">ctx</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
|
|
15
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">
|
|
21
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> turnFailed.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, { channel: ctx.channel.id });</span></span>
|
|
16
22
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
17
23
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
18
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>Any module under <code>bot/hooks/</code>, subfolders included, is a hook named by its path without the extension: <code>bot/hooks/audit/usage.ts</code> is <code>audit/usage</code>. <code>*.test.ts</code> and <code>*.spec.ts</code> files are skipped. The default export must be <code>defineHook(...)</code>, names can't contain <code>__</code>, and an empty <code>events</code> map skips the hook with a warning; <code>bdk validate</code> reports all three. An extension mounts its hooks as <code><ns>__<name></code>, and <code>disableHook()</code> removes one (<a href="./extensions.html#adjust-a-mounted-extension">Adjust a mounted extension</a>).</p><p><code>bdk init</code> scaffolds <code>bot/hooks/memory.ts</code>, which exports <code>memoryHook()</code> from <code>@cursor/bdk/memory</code> and journals every turn for later sessions to read. Delete the file to opt out. See <a href="./memory.html">Memory</a>.</p><h2 id="events-and-payloads" tabindex="-1">Events and payloads <a class="header-anchor" href="#events-and-payloads" aria-label="Permalink to "Events and payloads""></a></h2><p>Keys are event types from the <a href="./sessions.html#stream-events">event vocabulary</a>, or <code>"*"</code> for every event. A typed key narrows <code>event.data</code>; a <code>"*"</code> handler receives the union, so switch on <code>event.type</code>. Every event carries the stream envelope <code>{ type, index, sessionId, turnId?, at, data }</code>, with <code>turnId</code> set on turn-scoped events. Skip <code>*.appended</code> deltas when you want the final text; <code>message.completed</code> already has it.</p><table tabindex="0"><thead><tr><th>Event</th><th><code>event.data</code></th></tr></thead><tbody><tr><td><code>message.received</code></td><td><code>{ text }</code></td></tr><tr><td><code>turn.completed</code></td><td><code>{ result?, usage?, cost? }</code>. <code>usage</code> has <code>inputTokens</code>, <code>outputTokens</code>, <code>cacheReadTokens</code>, <code>cacheWriteTokens</code>, and optional <code>reasoningTokens</code>. <code>cost</code> has <code>totalUsd</code> and the <code>model</code> it was priced against</td></tr><tr><td><code>turn.failed</code></td><td><code>{ message, status? }</code>. <code>status</code> is <code>"error"</code> or <code>"cancelled"</code> when present</td></tr><tr><td><code>actions.requested</code></td><td><code>{ calls: [{ callId, toolName, args?, parentCallId? }], parentCallId? }</code>. One envelope per model step once that step has listed its tools. A single tool is a batch of one. <code>parentCallId</code> marks subagent work</td></tr><tr><td><code>actions.completed</code></td><td><code>{ results: [{ callId, toolName, output?, isError, stubbed?, parentCallId? }], parentCallId? }</code>. Pair with <code>actions.requested</code>; emitted when every call in that batch has a result</td></tr><tr><td><code>action.result</code></td><td><code>{ callId, toolName, output?, isError, stubbed?, parentCallId? }</code>. Live per-call envelope for chips and spans. <code>stubbed</code> means a dry-run session answered a write without running it</td></tr><tr><td><code>action.tool_retry</code></td><td><code>{ callId, toolName, attempt, reason, connection? }</code>. A read is running again after a transient failure. <code>attempt</code> is the try about to run. <code>reason</code> is a class such as <code>transport</code> or <code>http_503</code></td></tr></tbody></table><p>The types are <code>SessionEvent</code>, <code>SessionEventType</code>, and <code>HookContext</code>, exported from <code>@cursor/bdk</code>.</p><h2 id="handler-context" tabindex="-1">Handler context <a class="header-anchor" href="#handler-context" aria-label="Permalink to "Handler context""></a></h2><table tabindex="0"><thead><tr><th>Member</th><th>What it is</th></tr></thead><tbody><tr><td><code>ctx.session</code></td><td>Read-only session info: <code>id</code>, <code>channelId</code>, <code>mode</code> (<code>chat</code> or <code>task</code>), <code>purpose</code> (<code>live</code> or <code>eval</code>), <code>auth</code>, plus <code>title</code> and <code>sdkAgentId</code> when set</td></tr><tr><td><code>ctx.agent</code></td><td><code>{ name }</code> of the agent the event belongs to</td></tr><tr><td><code>ctx.channel</code></td><td><code>{ id, continuationToken }</code>. The token is <code>null</code> when the session can't take follow-ups</td></tr><tr><td><code>ctx.host.kv</code></td><td>Durable JSON, shared by every session of the agent. Prefix keys with <code>ctx.session.id</code> for per-session state</td></tr><tr><td><code>ctx.host.files</code></td><td>Durable files, bound to this session. Pass <code>{ scope: "deployment" }</code> for agent-wide files</td></tr><tr><td><code>ctx.host.
|
|
24
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><p>Any module under <code>bot/hooks/</code>, subfolders included, is a hook named by its path without the extension: <code>bot/hooks/audit/usage.ts</code> is <code>audit/usage</code>. <code>*.test.ts</code> and <code>*.spec.ts</code> files are skipped. The default export must be <code>defineHook(...)</code>, names can't contain <code>__</code>, and an empty <code>events</code> map skips the hook with a warning; <code>bdk validate</code> reports all three. An extension mounts its hooks as <code><ns>__<name></code>, and <code>disableHook()</code> removes one (<a href="./extensions.html#adjust-a-mounted-extension">Adjust a mounted extension</a>).</p><p><code>bdk init</code> scaffolds <code>bot/hooks/memory.ts</code>, which exports <code>memoryHook()</code> from <code>@cursor/bdk/memory</code> and journals every turn for later sessions to read. Delete the file to opt out. See <a href="./memory.html">Memory</a>.</p><h2 id="events-and-payloads" tabindex="-1">Events and payloads <a class="header-anchor" href="#events-and-payloads" aria-label="Permalink to "Events and payloads""></a></h2><p>Keys are event types from the <a href="./sessions.html#stream-events">event vocabulary</a>, or <code>"*"</code> for every event. A typed key narrows <code>event.data</code>; a <code>"*"</code> handler receives the union, so switch on <code>event.type</code>. Every event carries the stream envelope <code>{ type, index, sessionId, turnId?, at, data }</code>, with <code>turnId</code> set on turn-scoped events. Skip <code>*.appended</code> deltas when you want the final text; <code>message.completed</code> already has it.</p><table tabindex="0"><thead><tr><th>Event</th><th><code>event.data</code></th></tr></thead><tbody><tr><td><code>message.received</code></td><td><code>{ text }</code></td></tr><tr><td><code>turn.completed</code></td><td><code>{ result?, usage?, cost? }</code>. <code>usage</code> has <code>inputTokens</code>, <code>outputTokens</code>, <code>cacheReadTokens</code>, <code>cacheWriteTokens</code>, and optional <code>reasoningTokens</code>. <code>cost</code> has <code>totalUsd</code> and the <code>model</code> it was priced against</td></tr><tr><td><code>turn.failed</code></td><td><code>{ message, status? }</code>. <code>status</code> is <code>"error"</code> or <code>"cancelled"</code> when present</td></tr><tr><td><code>actions.requested</code></td><td><code>{ calls: [{ callId, toolName, args?, parentCallId? }], parentCallId? }</code>. One envelope per model step once that step has listed its tools. A single tool is a batch of one. <code>parentCallId</code> marks subagent work</td></tr><tr><td><code>actions.completed</code></td><td><code>{ results: [{ callId, toolName, output?, isError, stubbed?, parentCallId? }], parentCallId? }</code>. Pair with <code>actions.requested</code>; emitted when every call in that batch has a result</td></tr><tr><td><code>action.result</code></td><td><code>{ callId, toolName, output?, isError, stubbed?, parentCallId? }</code>. Live per-call envelope for chips and spans. <code>stubbed</code> means a dry-run session answered a write without running it</td></tr><tr><td><code>action.tool_retry</code></td><td><code>{ callId, toolName, attempt, reason, connection? }</code>. A read is running again after a transient failure. <code>attempt</code> is the try about to run. <code>reason</code> is a class such as <code>transport</code> or <code>http_503</code></td></tr></tbody></table><p>The types are <code>SessionEvent</code>, <code>SessionEventType</code>, and <code>HookContext</code>, exported from <code>@cursor/bdk</code>.</p><h2 id="handler-context" tabindex="-1">Handler context <a class="header-anchor" href="#handler-context" aria-label="Permalink to "Handler context""></a></h2><table tabindex="0"><thead><tr><th>Member</th><th>What it is</th></tr></thead><tbody><tr><td><code>ctx.session</code></td><td>Read-only session info: <code>id</code>, <code>channelId</code>, <code>mode</code> (<code>chat</code> or <code>task</code>), <code>purpose</code> (<code>live</code> or <code>eval</code>), <code>auth</code>, plus <code>title</code> and <code>sdkAgentId</code> when set</td></tr><tr><td><code>ctx.agent</code></td><td><code>{ name }</code> of the agent the event belongs to</td></tr><tr><td><code>ctx.channel</code></td><td><code>{ id, continuationToken }</code>. The token is <code>null</code> when the session can't take follow-ups</td></tr><tr><td><code>ctx.host.kv</code></td><td>Durable JSON, shared by every session of the agent. Prefix keys with <code>ctx.session.id</code> for per-session state</td></tr><tr><td><code>ctx.host.files</code></td><td>Durable files, bound to this session. Pass <code>{ scope: "deployment" }</code> for agent-wide files</td></tr><tr><td><code>ctx.host.mcp</code>, <code>ctx.host.github</code>, <code>ctx.host.slack</code></td><td>The same shared clients tools get</td></tr><tr><td><code>ctx.host.reminders</code></td><td>Per-session <a href="./schedules.html#reminders">reminders</a>, the same API tools get</td></tr><tr><td><code>ctx.artifacts</code></td><td>Session-bound <a href="./artifacts.html">artifacts</a> facade: <code>tag</code> fills in <code>sessionId</code> and <code>turnId</code></td></tr><tr><td><code>ctx.stateRoot</code></td><td>Absolute path of the local state root. It resets when a hosted deployment is replaced; keep derived state in <code>kv</code> or <code>files</code></td></tr></tbody></table><h2 id="hook-dispatch" tabindex="-1">Hook dispatch <a class="header-anchor" href="#hook-dispatch" aria-label="Permalink to "Hook dispatch""></a></h2><p>A hook runs after the event is recorded. It never delays the model and never sees an event that wasn't recorded.</p><table tabindex="0"><thead><tr><th>Rule</th><th>What happens</th></tr></thead><tbody><tr><td>Same session</td><td>Events dispatch one at a time</td></tr><tr><td>Eval sessions</td><td>The same stream fires; skip metering or paging when <code>ctx.session.purpose === "eval"</code></td></tr><tr><td>Host restart</td><td>Recorded events are not replayed into hooks, so a mirror needs no dedupe</td></tr><tr><td>Slow handler</td><td>Holds the next event's handlers on that session, not the model. Keep handlers short and queue anything slow</td></tr></tbody></table><p>Read hosted secrets inside the handler, not at module scope. Give outbound calls a timeout; a stalled request holds later handlers on that session. Skip cancelled turns when paging; they record interrupted work.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// bot/hooks/page-on-failure.ts</span></span>
|
|
19
25
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { defineHook } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk/hooks"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
20
26
|
<span class="line"></span>
|
|
21
27
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defineHook</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
|
|
@@ -42,4 +48,4 @@ import{_ as e,c as t,o as a,a3 as i}from"./chunks/framework.BNw1pucY.js";const k
|
|
|
42
48
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span>
|
|
43
49
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
44
50
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
|
45
|
-
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><h2 id="hooks-vs-channels-vs-evals" tabindex="-1">Hooks vs channels vs evals <a class="header-anchor" href="#hooks-vs-channels-vs-evals" aria-label="Permalink to "Hooks vs channels vs evals""></a></h2><p>All three consume the same stream, for different jobs:</p><table tabindex="0"><thead><tr><th></th><th>Hooks</th><th>Channel <code>events</code></th><th>Evals</th></tr></thead><tbody><tr><td>Scope</td><td>every session of the agent</td><td>sessions the channel owns</td><td>one test turn</td></tr><tr><td>Job</td><td>observe: audit, metrics, mirrors, derived state</td><td>deliver: replies back to the channel's surface</td><td>assert: gates over the trajectory</td></tr><tr><td>Context</td><td><code>ctx.host</code>, <code>ctx.artifacts</code>, session info</td><td><code>channel.state</code>, <code>setContinuationToken</code>, <code>ctx.host</code>, session info</td><td>the <code>t</code> assertion helpers</td></tr><tr><td>Can affect the run</td><td>no</td><td>yes, it owns the surface</td><td>n/a</td></tr><tr><td>Authored at</td><td><code>bot/hooks/*.ts</code></td><td>channel config</td><td><code>evals/**/*.eval.ts</code></td></tr></tbody></table><h2 id="hook-boundaries" tabindex="-1">Hook boundaries <a class="header-anchor" href="#hook-boundaries" aria-label="Permalink to "Hook boundaries""></a></h2><table tabindex="0"><thead><tr><th>You want to</th><th>Use instead</th></tr></thead><tbody><tr><td>Add context before the model runs</td><td>The channel's <code>send</code> message and <code>workspaceFiles</code>, <code>instructions.md</code>, skills, or <code>sandbox/workspace/</code> seed files</td></tr><tr><td>Reply on Slack, comment on a PR, or post any other delivery</td><td>The channel's <code>events</code> map, or the Slack and GitHub packs</td></tr><tr><td>Show PR progress (merge-box check, sticky banner)</td><td><code>githubChannel({ progress: { commitStatus, banner } })</code>; see <a href="./../guides/github.html">GitHub agents</a></td></tr><tr><td>Gate a change on behavior</td><td><a href="./../evals.html">Evals</a></td></tr></tbody></table><p>To act on a turn's decision, such as a label or a ticket, have the model record it with an authored <a href="./tools.html">tool</a>. A <code>turn.completed</code> hook then reads the recorded decision and acts on it through <code>ctx.host</code>.</p><h2 id="test-a-hook" tabindex="-1">Test a hook <a class="header-anchor" href="#test-a-hook" aria-label="Permalink to "Test a hook""></a></h2><p>A hook definition is a plain object, so a unit test calls <code>hook.events["turn.completed"]</code> directly with an event and a stub <code>HookContext</code>. Discovery skips <code>*.test.ts</code>, so the test can live next to the hook.</p><table tabindex="0"><thead><tr><th>Command</th><th>What it reports</th></tr></thead><tbody><tr><td><code>bdk validate --dir .</code></td><td>Discovery errors and the empty-handlers warning</td></tr><tr><td><code>bdk info --dir . --json</code></td><td>Loaded hooks under <code>agents[].hooks</code></td></tr><tr><td><code>bdk run --dir . --message "…"</code></td><td>Serve log on stderr, including <code>hook "<name>" handler for <event> threw: …</code></td></tr></tbody></table><p>On hosting, read the same log with <a href="./cli.html#logs"><code>bdk logs</code></a>.</p><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../guides/hooks.html">Hooks guide</a>: meter usage and page on failure</li><li><a href="./sessions.html">Sessions and streaming</a>: the event vocabulary hooks observe</li><li><a href="./../guides/opentelemetry.html">OpenTelemetry</a>: OTLP traces and metrics from the same event stream</li><li><a href="./../deployment.html#observability">Deployment</a>: runtime logs and export paths</li><li><a href="./channels.html#events">Channels</a>: the delivery-side counterpart</li></ul>`,32)])])}const E=e(n,[["render",o]]);export{
|
|
51
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">});</span></span></code></pre></div><h2 id="hooks-vs-channels-vs-evals" tabindex="-1">Hooks vs channels vs evals <a class="header-anchor" href="#hooks-vs-channels-vs-evals" aria-label="Permalink to "Hooks vs channels vs evals""></a></h2><p>All three consume the same stream, for different jobs:</p><table tabindex="0"><thead><tr><th></th><th>Hooks</th><th>Channel <code>events</code></th><th>Evals</th></tr></thead><tbody><tr><td>Scope</td><td>every session of the agent</td><td>sessions the channel owns</td><td>one test turn</td></tr><tr><td>Job</td><td>observe: audit, metrics, mirrors, derived state</td><td>deliver: replies back to the channel's surface</td><td>assert: gates over the trajectory</td></tr><tr><td>Context</td><td><code>ctx.host</code>, <code>ctx.artifacts</code>, session info</td><td><code>channel.state</code>, <code>setContinuationToken</code>, <code>ctx.host</code>, session info</td><td>the <code>t</code> assertion helpers</td></tr><tr><td>Can affect the run</td><td>no</td><td>yes, it owns the surface</td><td>n/a</td></tr><tr><td>Authored at</td><td><code>bot/hooks/*.ts</code></td><td>channel config</td><td><code>evals/**/*.eval.ts</code></td></tr></tbody></table><h2 id="hook-boundaries" tabindex="-1">Hook boundaries <a class="header-anchor" href="#hook-boundaries" aria-label="Permalink to "Hook boundaries""></a></h2><table tabindex="0"><thead><tr><th>You want to</th><th>Use instead</th></tr></thead><tbody><tr><td>Add context before the model runs</td><td>The channel's <code>send</code> message and <code>workspaceFiles</code>, <code>instructions.md</code>, skills, or <code>sandbox/workspace/</code> seed files</td></tr><tr><td>Reply on Slack, comment on a PR, or post any other delivery</td><td>The channel's <code>events</code> map, or the Slack and GitHub packs</td></tr><tr><td>Show PR progress (merge-box check, sticky banner)</td><td><code>githubChannel({ progress: { commitStatus, banner } })</code>; see <a href="./../guides/github.html">GitHub agents</a></td></tr><tr><td>Gate a change on behavior</td><td><a href="./../evals.html">Evals</a></td></tr></tbody></table><p>To act on a turn's decision, such as a label or a ticket, have the model record it with an authored <a href="./tools.html">tool</a>. A <code>turn.completed</code> hook then reads the recorded decision and acts on it through <code>ctx.host</code>.</p><h2 id="test-a-hook" tabindex="-1">Test a hook <a class="header-anchor" href="#test-a-hook" aria-label="Permalink to "Test a hook""></a></h2><p>A hook definition is a plain object, so a unit test calls <code>hook.events["turn.completed"]</code> directly with an event and a stub <code>HookContext</code>. Discovery skips <code>*.test.ts</code>, so the test can live next to the hook.</p><table tabindex="0"><thead><tr><th>Command</th><th>What it reports</th></tr></thead><tbody><tr><td><code>bdk validate --dir .</code></td><td>Discovery errors and the empty-handlers warning</td></tr><tr><td><code>bdk info --dir . --json</code></td><td>Loaded hooks under <code>agents[].hooks</code></td></tr><tr><td><code>bdk run --dir . --message "…"</code></td><td>Serve log on stderr, including <code>hook "<name>" handler for <event> threw: …</code></td></tr></tbody></table><p>On hosting, read the same log with <a href="./cli.html#logs"><code>bdk logs</code></a>.</p><h2 id="related" tabindex="-1">Related <a class="header-anchor" href="#related" aria-label="Permalink to "Related""></a></h2><ul><li><a href="./../guides/hooks.html">Hooks guide</a>: meter usage and page on failure</li><li><a href="./sessions.html">Sessions and streaming</a>: the event vocabulary hooks observe</li><li><a href="./../guides/opentelemetry.html">OpenTelemetry</a>: OTLP traces and metrics from the same event stream</li><li><a href="./../deployment.html#observability">Deployment</a>: runtime logs and export paths</li><li><a href="./channels.html#events">Channels</a>: the delivery-side counterpart</li></ul>`,32)])])}const E=e(n,[["render",o]]);export{c as __pageData,E as default};
|
package/dist/docs/assets/{reference_hooks.md.B1jq3oGl.lean.js → reference_hooks.md.CROr0QgC.lean.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,c as t,o as a,a3 as i}from"./chunks/framework.BNw1pucY.js";const
|
|
1
|
+
import{_ as e,c as t,o as a,a3 as i}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Hooks","description":"Observe-only subscribers to the session event stream: audit logs, metrics, transcript mirrors, derived state.","frontmatter":{"title":"Hooks","description":"Observe-only subscribers to the session event stream: audit logs, metrics, transcript mirrors, derived state."},"headers":[],"relativePath":"reference/hooks.md","filePath":"reference/hooks.md"}'),n={name:"reference/hooks.md"};function o(d,s,h,l,r,k){return a(),t("div",null,[...s[0]||(s[0]=[i("",32)])])}const E=e(n,[["render",o]]);export{c as __pageData,E as default};
|
package/dist/docs/assets/{reference_schedules.md.03Ryy9ca.js → reference_schedules.md.BqWnJES4.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{_ as i,c as e,o as a,a3 as t}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Schedules & reminders","description":"Cron-driven runs defined at deploy time, and per-session durable wakes created at runtime.","frontmatter":{"title":"Schedules & reminders","description":"Cron-driven runs defined at deploy time, and per-session durable wakes created at runtime."},"headers":[],"relativePath":"reference/schedules.md","filePath":"reference/schedules.md"}'),n={name:"reference/schedules.md"};function h(l,s,d,r,p,o){return a(),e("div",null,[...s[0]||(s[0]=[t(`<h1 id="schedules-and-reminders" tabindex="-1">Schedules and reminders <a class="header-anchor" href="#schedules-and-reminders" aria-label="Permalink to "Schedules and reminders""></a></h1><p>An agent can act without an inbound message in two ways. A schedule is deploy-time cron: "every weekday at 09:00, summarize open incidents." A reminder is a runtime wake bound to one conversation: "re-check this PR's CI in two hours." Schedules live in the filesystem; reminders are created by running code.</p><h2 id="schedules" tabindex="-1">Schedules <a class="header-anchor" href="#schedules" aria-label="Permalink to "Schedules""></a></h2><p>Cron expressions are standard 5-field, evaluated in UTC with minute granularity.</p><h3 id="markdown-schedules" tabindex="-1">Markdown schedules <a class="header-anchor" href="#markdown-schedules" aria-label="Permalink to "Markdown schedules""></a></h3><p>A markdown file with <code>cron:</code> frontmatter is a fire-and-forget task:</p><div class="language-md vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#
|
|
2
|
-
<span class="line"><span style="--shiki-light:#
|
|
3
|
-
<span class="line"><span style="--shiki-light:#
|
|
1
|
+
import{_ as i,c as e,o as a,a3 as t}from"./chunks/framework.BNw1pucY.js";const c=JSON.parse('{"title":"Schedules & reminders","description":"Cron-driven runs defined at deploy time, and per-session durable wakes created at runtime.","frontmatter":{"title":"Schedules & reminders","description":"Cron-driven runs defined at deploy time, and per-session durable wakes created at runtime."},"headers":[],"relativePath":"reference/schedules.md","filePath":"reference/schedules.md"}'),n={name:"reference/schedules.md"};function h(l,s,d,r,p,o){return a(),e("div",null,[...s[0]||(s[0]=[t(`<h1 id="schedules-and-reminders" tabindex="-1">Schedules and reminders <a class="header-anchor" href="#schedules-and-reminders" aria-label="Permalink to "Schedules and reminders""></a></h1><p>An agent can act without an inbound message in two ways. A schedule is deploy-time cron: "every weekday at 09:00, summarize open incidents." A reminder is a runtime wake bound to one conversation: "re-check this PR's CI in two hours." Schedules live in the filesystem; reminders are created by running code.</p><h2 id="schedules" tabindex="-1">Schedules <a class="header-anchor" href="#schedules" aria-label="Permalink to "Schedules""></a></h2><p>Cron expressions are standard 5-field, evaluated in UTC with minute granularity.</p><h3 id="markdown-schedules" tabindex="-1">Markdown schedules <a class="header-anchor" href="#markdown-schedules" aria-label="Permalink to "Markdown schedules""></a></h3><p>A markdown file with <code>cron:</code> frontmatter is a fire-and-forget task:</p><div class="language-md vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">---</span></span>
|
|
2
|
+
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">cron</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"0 9 * * 1-5"</span></span>
|
|
3
|
+
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">---</span></span>
|
|
4
4
|
<span class="line"></span>
|
|
5
5
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">Pull open incidents and post a summary to the metrics endpoint.</span></span></code></pre></div><p>Each firing starts a task-mode session: the body is the prompt, the session runs to <code>session.completed</code> or <code>session.failed</code>, and it isn't followable.</p><h3 id="schedule-handlers" tabindex="-1">Schedule handlers <a class="header-anchor" href="#schedule-handlers" aria-label="Permalink to "Schedule handlers""></a></h3><p>Use <code>defineSchedule</code> with a <code>run</code> handler to call tools or hand work into a channel so its delivery events fire:</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { defineSchedule } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "@cursor/bdk/schedules"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|
|
6
6
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> webhook </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "../channels/webhook.js"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
|