@cursor/bdk 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agent-serve.js +9 -1
- package/dist/channels/slack/attachments.d.ts +2 -1
- package/dist/channels/slack/attachments.d.ts.map +1 -1
- package/dist/channels/slack/attachments.js +19 -9
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +26 -24
- package/dist/channels/slack/thread-context.d.ts +21 -11
- package/dist/channels/slack/thread-context.d.ts.map +1 -1
- package/dist/channels/slack/thread-context.js +75 -27
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.BOIHhrKi.js → app.4kQ8Db_q.js} +4 -4
- package/dist/docs/assets/chunks/@localSearchIndexroot.CvuAJ0My.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.D49zVZqM.js → VPLocalSearchBox.DY1RwB8Q.js} +1 -1
- package/dist/docs/assets/chunks/{arc.hmjb-sc4.js → arc.CxE_fSPK.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.CxEI1KqM.js → architectureDiagram-Q4EWVU46.CPX426ui.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.DHHvBWoV.js → baseUniq.CB52JrKG.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.DnXW-3bu.js → blockDiagram-DXYQGD6D.J0cNaQCL.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.e-47O2jM.js → c4Diagram-AHTNJAMY.DJn3vEGT.js} +1 -1
- package/dist/docs/assets/chunks/channel.BoNycAoN.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.3ry4pYXB.js → chunk-4BX2VUAB.Dao618F6.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.DGIZFRx6.js → chunk-4TB4RGXK.QW8Rhjai.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.DKBnqg9U.js → chunk-55IACEB6.DfRLLKF_.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.BIU8Ue5k.js → chunk-EDXVE4YY.CIV2ApKQ.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DP-TFhjI.js → chunk-FMBD7UC4.BEheSuxp.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.Ux0OYj5v.js → chunk-OYMX7WX6.CUN88ENB.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.BzHMwYox.js → chunk-QZHKN3VN.CgqCs8b_.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.D4OGAsSP.js → chunk-YZCP3GAM.iCH0nnTJ.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.C4x07Gkj.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.C4x07Gkj.js +1 -0
- package/dist/docs/assets/chunks/clone.Db22cH_-.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.Jq_7BUNx.js → cose-bilkent-S5V4N54A.BLcUxhWE.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.Di-skR2x.js → dagre-KV5264BT.Ep7LofOm.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.DeREHIdH.js → diagram-5BDNPKRD.Bzf4GSQ4.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.C7Kcqxro.js → diagram-G4DWMVQ6.DD6Jh-eM.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BK3eohyo.js → diagram-MMDJMWI5.oOIl8bWd.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.C6TyymXT.js → diagram-TYMM5635.DHs85Ade.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.DYGG-gGx.js → erDiagram-SMLLAGMA.BIb5ghCk.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.C9nBcSV4.js → flowDiagram-DWJPFMVM.DV4paY9k.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.wAg_ymsp.js → ganttDiagram-T4ZO3ILL.AyEKA6_v.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.B87j9Oeg.js → gitGraphDiagram-UUTBAWPF.BltiCDFo.js} +1 -1
- package/dist/docs/assets/chunks/{graph.CuFMj31w.js → graph.DzuEYGdC.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.P_mLGumP.js → infoDiagram-42DDH7IO.BV2l981J.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DyuL_MsT.js → ishikawaDiagram-UXIWVN3A.BA4Izf-m.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.CtP09IoJ.js → journeyDiagram-VCZTEJTY.DjaFbFS3.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.BoeSYPZo.js → kanban-definition-6JOO6SKY.CfTFieDs.js} +1 -1
- package/dist/docs/assets/chunks/{layout.B0lMMtNo.js → layout.DzfWqTBV.js} +1 -1
- package/dist/docs/assets/chunks/{linear.HxRBiAFX.js → linear.BO6mpulV.js} +1 -1
- package/dist/docs/assets/chunks/{min.BGlFFHwS.js → min.BGgTadgT.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.JyLBD9M8.js → mindmap-definition-QFDTVHPH.DPuIXVWY.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.DnSmNZF8.js → pieDiagram-DEJITSTG.BOnl3bBg.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.CUCnbfCa.js → quadrantDiagram-34T5L4WZ.DNB6Ckdc.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.py0IVUn5.js → requirementDiagram-MS252O5E.D5-Qo7vb.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.Bkc-HWYp.js → sankeyDiagram-XADWPNL6.8t65cesf.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.Dqn8Mlv2.js → sequenceDiagram-FGHM5R23.CaG07BdS.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.JikkoQUU.js → stateDiagram-FHFEXIEX.TKOweTB6.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CuqmyQc4.js +1 -0
- package/dist/docs/assets/chunks/{theme.b6HQ6zG_.js → theme.Dx-JhpTB.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.BvpSXiBj.js → timeline-definition-GMOUNBTQ.fE53zQ2s.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.CU7MVnZx.js → vennDiagram-DHZGUBPP.DJsZZaJg.js} +1 -1
- package/dist/docs/assets/chunks/{wardley-RL74JXVD.BKwC4ctG.js → wardley-RL74JXVD.844kyrjl.js} +1 -1
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.BfaF6Uhe.js → wardleyDiagram-NUSXRM2D.CMZ-Ru_t.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.Bg5dcpj4.js → xychartDiagram-5P7HB3ND.XXrhBc7a.js} +1 -1
- package/dist/docs/assets/{deployment.md.BJ8i7Q6p.js → deployment.md.UhnJIMr-.js} +2 -2
- package/dist/docs/assets/{deployment.md.BJ8i7Q6p.lean.js → deployment.md.UhnJIMr-.lean.js} +1 -1
- package/dist/docs/assets/{guides_jev.md.BNDm14Gy.js → guides_jev.md.CRcgmjDb.js} +2 -2
- package/dist/docs/assets/{guides_jev.md.BNDm14Gy.lean.js → guides_jev.md.CRcgmjDb.lean.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.DzGI777n.js → reference_agent-config.md.Cj5uBKp4.js} +1 -1
- package/dist/docs/assets/{reference_extensions.md.CPPrkWlJ.js → reference_extensions.md.pa2tN-e4.js} +4 -3
- package/dist/docs/assets/{reference_extensions.md.CPPrkWlJ.lean.js → reference_extensions.md.pa2tN-e4.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +35 -35
- package/dist/docs/deployment.html +37 -37
- package/dist/docs/deployment.md +4 -1
- package/dist/docs/evals.html +35 -35
- package/dist/docs/guides/agent-to-agent.html +35 -35
- package/dist/docs/guides/bitbucket.html +35 -35
- package/dist/docs/guides/cloud-agents.html +35 -35
- package/dist/docs/guides/convert-automation.html +35 -35
- package/dist/docs/guides/github.html +35 -35
- package/dist/docs/guides/gitlab.html +35 -35
- package/dist/docs/guides/grokbot-agents.html +35 -35
- package/dist/docs/guides/hooks.html +35 -35
- package/dist/docs/guides/improve.html +35 -35
- package/dist/docs/guides/jev.html +37 -37
- package/dist/docs/guides/jev.md +7 -0
- package/dist/docs/guides/mcp-oauth.html +35 -35
- package/dist/docs/guides/opentelemetry.html +35 -35
- package/dist/docs/guides/slack.html +35 -35
- package/dist/docs/guides/webhooks.html +35 -35
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +35 -35
- package/dist/docs/index.html +35 -35
- package/dist/docs/llms-full.txt +25 -2
- package/dist/docs/quickstart.html +35 -35
- package/dist/docs/reference/agent-config.html +37 -37
- package/dist/docs/reference/agent-config.md +1 -1
- package/dist/docs/reference/artifacts.html +35 -35
- package/dist/docs/reference/channels.html +35 -35
- package/dist/docs/reference/cli.html +35 -35
- package/dist/docs/reference/connections.html +35 -35
- package/dist/docs/reference/evals.html +35 -35
- package/dist/docs/reference/extensions.html +39 -38
- package/dist/docs/reference/extensions.md +13 -0
- package/dist/docs/reference/hooks.html +35 -35
- package/dist/docs/reference/http-api.html +35 -35
- package/dist/docs/reference/instructions.html +35 -35
- package/dist/docs/reference/playground.html +35 -35
- package/dist/docs/reference/project-layout.html +35 -35
- package/dist/docs/reference/prompt.html +35 -35
- package/dist/docs/reference/schedules.html +35 -35
- package/dist/docs/reference/sessions.html +35 -35
- package/dist/docs/reference/skills.html +35 -35
- package/dist/docs/reference/subagents.html +35 -35
- package/dist/docs/reference/tools.html +35 -35
- package/dist/docs/templates/agentic-owners.html +35 -35
- package/dist/docs/templates/security-reviewer.html +35 -35
- package/dist/docs/templates/thermo-quality-review.html +35 -35
- package/dist/docs/templates/thermo-review.html +35 -35
- package/dist/docs/templates/triage.html +35 -35
- package/dist/docs/troubleshooting.html +35 -35
- package/dist/extensions/jev/extension.d.ts +3 -0
- package/dist/extensions/jev/extension.d.ts.map +1 -1
- package/dist/extensions/jev/extension.js +10 -1
- package/dist/extensions/jev/lib/evaluate.d.ts +4 -0
- package/dist/extensions/jev/lib/evaluate.d.ts.map +1 -1
- package/dist/extensions/jev/lib/evaluate.js +6 -2
- package/dist/extensions.d.ts +4 -2
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +5 -2
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +19 -5
- package/dist/internal/discovery/agent-config.d.ts +6 -5
- package/dist/internal/discovery/agent-config.d.ts.map +1 -1
- package/dist/internal/discovery/agent-config.js +29 -28
- package/dist/internal/discovery/agent.js +1 -1
- package/dist/internal/discovery/extensions.d.ts.map +1 -1
- package/dist/internal/discovery/extensions.js +12 -0
- package/dist/internal/hosting.d.ts +8 -0
- package/dist/internal/hosting.d.ts.map +1 -1
- package/dist/internal/hosting.js +24 -0
- package/dist/types.d.ts +18 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/deployment.md +4 -1
- package/docs/guides/jev.md +7 -0
- package/docs/reference/agent-config.md +1 -1
- package/docs/reference/extensions.md +13 -0
- package/package.json +1 -9
- package/dist/docs/assets/chunks/@localSearchIndexroot.D5L-b34G.js +0 -1
- package/dist/docs/assets/chunks/channel.BbOGaJQP.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.Db58HCb1.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.Db58HCb1.js +0 -1
- package/dist/docs/assets/chunks/clone.Co4MBflG.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CMsKhrW0.js +0 -1
- package/src/artifacts.ts +0 -68
- package/src/bin/agent-serve.ts +0 -1854
- package/src/channels/bitbucket/api.ts +0 -891
- package/src/channels/bitbucket/binding.ts +0 -417
- package/src/channels/bitbucket/bitbucket-channel.ts +0 -162
- package/src/channels/bitbucket/bitbucket-webhook.ts +0 -519
- package/src/channels/bitbucket/checks.ts +0 -146
- package/src/channels/bitbucket/cursor-account.ts +0 -106
- package/src/channels/bitbucket/defaults.ts +0 -100
- package/src/channels/bitbucket/events.ts +0 -74
- package/src/channels/bitbucket/index.ts +0 -51
- package/src/channels/bitbucket/replay.ts +0 -421
- package/src/channels/bitbucket/state.ts +0 -59
- package/src/channels/bitbucket/types.ts +0 -261
- package/src/channels/change-monitors/change-monitors-channel.ts +0 -63
- package/src/channels/change-monitors/index.ts +0 -8
- package/src/channels/change-monitors/types.ts +0 -42
- package/src/channels/checks.ts +0 -185
- package/src/channels/deployments/deployments-channel.ts +0 -224
- package/src/channels/deployments/index.ts +0 -25
- package/src/channels/deployments/types.ts +0 -92
- package/src/channels/github/api.ts +0 -526
- package/src/channels/github/auth.ts +0 -293
- package/src/channels/github/binding.ts +0 -233
- package/src/channels/github/checks.ts +0 -145
- package/src/channels/github/cursor-account.ts +0 -303
- package/src/channels/github/defaults.ts +0 -168
- package/src/channels/github/events.ts +0 -67
- package/src/channels/github/forward.ts +0 -359
- package/src/channels/github/github-channel.ts +0 -2334
- package/src/channels/github/index.ts +0 -54
- package/src/channels/github/progress.ts +0 -365
- package/src/channels/github/replay.ts +0 -372
- package/src/channels/github/state.ts +0 -124
- package/src/channels/github/types.ts +0 -590
- package/src/channels/gitlab/api.ts +0 -329
- package/src/channels/gitlab/binding.ts +0 -231
- package/src/channels/gitlab/checks.ts +0 -228
- package/src/channels/gitlab/cursor-account.ts +0 -105
- package/src/channels/gitlab/defaults.ts +0 -80
- package/src/channels/gitlab/events.ts +0 -37
- package/src/channels/gitlab/gitlab-channel.ts +0 -160
- package/src/channels/gitlab/gitlab-webhook.ts +0 -509
- package/src/channels/gitlab/index.ts +0 -44
- package/src/channels/gitlab/replay.ts +0 -328
- package/src/channels/gitlab/state.ts +0 -55
- package/src/channels/gitlab/types.ts +0 -247
- package/src/channels/issues/index.ts +0 -9
- package/src/channels/issues/issues-channel.ts +0 -45
- package/src/channels/issues/types.ts +0 -38
- package/src/channels/origin/api.ts +0 -507
- package/src/channels/origin/binding.ts +0 -114
- package/src/channels/origin/checks.ts +0 -250
- package/src/channels/origin/cursor-account.ts +0 -58
- package/src/channels/origin/defaults.ts +0 -140
- package/src/channels/origin/events.ts +0 -35
- package/src/channels/origin/index.ts +0 -35
- package/src/channels/origin/origin-channel.ts +0 -815
- package/src/channels/origin/origin-webhook.ts +0 -296
- package/src/channels/origin/reactions.ts +0 -72
- package/src/channels/origin/state.ts +0 -54
- package/src/channels/origin/types.ts +0 -295
- package/src/channels/slack/agentic-delivery.ts +0 -634
- package/src/channels/slack/agentic-posted.ts +0 -135
- package/src/channels/slack/agentic-signals.ts +0 -231
- package/src/channels/slack/api.ts +0 -761
- package/src/channels/slack/approvals.ts +0 -279
- package/src/channels/slack/assistant.ts +0 -76
- package/src/channels/slack/attachments.ts +0 -596
- package/src/channels/slack/auth.ts +0 -127
- package/src/channels/slack/blocks.ts +0 -131
- package/src/channels/slack/bot-mentions.ts +0 -318
- package/src/channels/slack/channel-watch.ts +0 -314
- package/src/channels/slack/cli-project.ts +0 -249
- package/src/channels/slack/code-fences.ts +0 -171
- package/src/channels/slack/constants.ts +0 -38
- package/src/channels/slack/credentials.ts +0 -88
- package/src/channels/slack/defaults.ts +0 -714
- package/src/channels/slack/dispatch.ts +0 -1060
- package/src/channels/slack/doctor.ts +0 -338
- package/src/channels/slack/eval-directive.ts +0 -306
- package/src/channels/slack/event-id-dedupe.ts +0 -30
- package/src/channels/slack/external-policy.ts +0 -75
- package/src/channels/slack/footer.ts +0 -106
- package/src/channels/slack/inbound.ts +0 -416
- package/src/channels/slack/index.ts +0 -53
- package/src/channels/slack/init.ts +0 -169
- package/src/channels/slack/interactive.ts +0 -406
- package/src/channels/slack/links.ts +0 -23
- package/src/channels/slack/live-delivery.ts +0 -489
- package/src/channels/slack/log.ts +0 -70
- package/src/channels/slack/manifest.ts +0 -240
- package/src/channels/slack/message-body.ts +0 -82
- package/src/channels/slack/nudge-carrier.ts +0 -224
- package/src/channels/slack/nudge-store.ts +0 -334
- package/src/channels/slack/paint-start.ts +0 -93
- package/src/channels/slack/placeholder.ts +0 -358
- package/src/channels/slack/pr-ref.ts +0 -74
- package/src/channels/slack/progress-delivery.ts +0 -138
- package/src/channels/slack/reasoning-card.ts +0 -125
- package/src/channels/slack/reasoning-chip.ts +0 -41
- package/src/channels/slack/recording-sink.ts +0 -167
- package/src/channels/slack/redact.ts +0 -6
- package/src/channels/slack/reply-options.ts +0 -279
- package/src/channels/slack/setup.ts +0 -125
- package/src/channels/slack/slack-channel.ts +0 -744
- package/src/channels/slack/socket-mode.ts +0 -140
- package/src/channels/slack/stop.ts +0 -25
- package/src/channels/slack/stream.ts +0 -66
- package/src/channels/slack/thread-context.ts +0 -485
- package/src/channels/slack/tool-approval-events.ts +0 -233
- package/src/channels/slack/tool-cards.ts +0 -198
- package/src/channels/slack/tool-chip.ts +0 -34
- package/src/channels/slack/types.ts +0 -787
- package/src/channels/slack/upload.ts +0 -137
- package/src/channels.ts +0 -543
- package/src/connections.ts +0 -153
- package/src/dashboard-session-url.ts +0 -30
- package/src/evals/assertions.ts +0 -688
- package/src/evals/expect.ts +0 -250
- package/src/evals/judge.ts +0 -329
- package/src/evals/loaders.ts +0 -111
- package/src/evals/matchers.ts +0 -223
- package/src/evals/reporters.ts +0 -257
- package/src/evals/results.ts +0 -130
- package/src/evals/run-facts.ts +0 -306
- package/src/evals.ts +0 -709
- package/src/extensions/cursor-cloud-agents/extension.ts +0 -131
- package/src/extensions/cursor-cloud-agents/lib/backend.ts +0 -386
- package/src/extensions/cursor-cloud-agents/lib/channels.ts +0 -11
- package/src/extensions/cursor-cloud-agents/lib/fleet.ts +0 -98
- package/src/extensions/cursor-cloud-agents/lib/inputs.ts +0 -5
- package/src/extensions/cursor-cloud-agents/lib/repos.ts +0 -80
- package/src/extensions/cursor-cloud-agents/lib/transcript.ts +0 -19
- package/src/extensions/cursor-cloud-agents/skills/handoff.md +0 -37
- package/src/extensions/cursor-cloud-agents/tools/cancel.ts +0 -21
- package/src/extensions/cursor-cloud-agents/tools/dump.ts +0 -47
- package/src/extensions/cursor-cloud-agents/tools/get.ts +0 -18
- package/src/extensions/cursor-cloud-agents/tools/launch.ts +0 -62
- package/src/extensions/cursor-cloud-agents/tools/list.ts +0 -31
- package/src/extensions/cursor-cloud-agents/tools/reply.ts +0 -36
- package/src/extensions/cursor-grokbot-agents/extension.ts +0 -132
- package/src/extensions/cursor-grokbot-agents/lib/agents.ts +0 -42
- package/src/extensions/cursor-grokbot-agents/lib/backend.ts +0 -208
- package/src/extensions/cursor-grokbot-agents/lib/contacts.ts +0 -74
- package/src/extensions/cursor-grokbot-agents/lib/conversation.ts +0 -260
- package/src/extensions/cursor-grokbot-agents/lib/inputs.ts +0 -21
- package/src/extensions/cursor-grokbot-agents/lib/lock.ts +0 -26
- package/src/extensions/cursor-grokbot-agents/skills/consult.md +0 -40
- package/src/extensions/cursor-grokbot-agents/tools/ask.ts +0 -32
- package/src/extensions/cursor-grokbot-agents/tools/check.ts +0 -25
- package/src/extensions/cursor-grokbot-agents/tools/interrupt.ts +0 -17
- package/src/extensions/cursor-grokbot-agents/tools/list.ts +0 -26
- package/src/extensions/improve/extension.ts +0 -69
- package/src/extensions/improve/skills/yourself.ts +0 -50
- package/src/extensions/jev/extension.ts +0 -95
- package/src/extensions/jev/lib/evaluate.ts +0 -266
- package/src/extensions/jev/skills/gated-write.md +0 -25
- package/src/extensions/jev/skills/questions.md +0 -33
- package/src/extensions/jev/tools/evaluate.ts +0 -82
- package/src/extensions/slack-communication/evals/harness.ts +0 -705
- package/src/extensions/slack-communication/evals/slack-communication.eval.ts +0 -830
- package/src/extensions/slack-communication/evals/slack-placeholder.eval.ts +0 -172
- package/src/extensions/slack-communication/extension.ts +0 -44
- package/src/extensions/slack-communication/skills/slack-voice.ts +0 -56
- package/src/extensions/slack-communication/tools/delete-message.ts +0 -33
- package/src/extensions/slack-communication/tools/edit-message.ts +0 -42
- package/src/extensions/slack-communication/tools/post-card.ts +0 -28
- package/src/extensions/slack-communication/tools/post-file.ts +0 -82
- package/src/extensions/slack-communication/tools/post-update.ts +0 -40
- package/src/extensions/slack-communication/tools/react.ts +0 -30
- package/src/extensions/slack-communication/tools/set-status.ts +0 -21
- package/src/extensions.ts +0 -179
- package/src/files-backends/agent-store-presigned-url.ts +0 -11
- package/src/files-backends/cursor-hosted.ts +0 -1212
- package/src/files-backends/local-fs.ts +0 -163
- package/src/files.ts +0 -293
- package/src/filesystem.ts +0 -2005
- package/src/hooks.ts +0 -30
- package/src/index.ts +0 -259
- package/src/internal/advertise-tools.ts +0 -370
- package/src/internal/approval-gate.ts +0 -103
- package/src/internal/artifacts-store.ts +0 -836
- package/src/internal/as-of.ts +0 -257
- package/src/internal/auth.ts +0 -46
- package/src/internal/authored-alias-hooks.ts +0 -138
- package/src/internal/authored-loaders.ts +0 -188
- package/src/internal/bounded-int.ts +0 -24
- package/src/internal/bounded.ts +0 -25
- package/src/internal/brand.ts +0 -28
- package/src/internal/browser-origin-guard.ts +0 -67
- package/src/internal/builtin-tools/artifacts.ts +0 -62
- package/src/internal/builtin-tools/index.ts +0 -53
- package/src/internal/builtin-tools/reminders.ts +0 -145
- package/src/internal/channel-dispatch.ts +0 -129
- package/src/internal/channel-route-dispatch.ts +0 -58
- package/src/internal/channel-state.ts +0 -83
- package/src/internal/chat-client.ts +0 -594
- package/src/internal/cli-ax.ts +0 -2318
- package/src/internal/cli-bitbucket.ts +0 -438
- package/src/internal/cli-convert-automation.ts +0 -335
- package/src/internal/cli-cursor.ts +0 -282
- package/src/internal/cli-deploy.ts +0 -2519
- package/src/internal/cli-docs.ts +0 -192
- package/src/internal/cli-github.ts +0 -806
- package/src/internal/cli-gitlab.ts +0 -452
- package/src/internal/cli-images.ts +0 -672
- package/src/internal/cli-manifest.ts +0 -56
- package/src/internal/cli-mcp-oauth.ts +0 -396
- package/src/internal/cli-mcp.ts +0 -808
- package/src/internal/cli-skills.ts +0 -98
- package/src/internal/cli-slack-manual.ts +0 -418
- package/src/internal/cli-slack.ts +0 -874
- package/src/internal/cloud-merge.ts +0 -51
- package/src/internal/cloud-turn-cost.ts +0 -159
- package/src/internal/connection-env.ts +0 -106
- package/src/internal/continuation-channel.ts +0 -233
- package/src/internal/continuation-identity.ts +0 -935
- package/src/internal/conversation-mirror.ts +0 -423
- package/src/internal/convert-automation/convert-workflow.ts +0 -1377
- package/src/internal/convert-automation/slug.ts +0 -29
- package/src/internal/convert-automation/types.ts +0 -212
- package/src/internal/cron.ts +0 -76
- package/src/internal/cursor/account-mcp.ts +0 -692
- package/src/internal/cursor/backend-client.ts +0 -984
- package/src/internal/cursor/bound-secret-file.ts +0 -101
- package/src/internal/cursor/credentials.ts +0 -560
- package/src/internal/cursor/cursor-api-transport.ts +0 -65
- package/src/internal/cursor/github-credentials.ts +0 -228
- package/src/internal/cursor/hosted-bound-secrets.ts +0 -71
- package/src/internal/cursor/hosted-deployment-secrets.ts +0 -100
- package/src/internal/cursor/hosted-store-secrets.ts +0 -152
- package/src/internal/cursor/session-token.ts +0 -111
- package/src/internal/cursor/store-api-client.ts +0 -323
- package/src/internal/cursor-account-mcp-auth.ts +0 -303
- package/src/internal/cursor-agent-template.ts +0 -50
- package/src/internal/cursor-deployment-relay.ts +0 -315
- package/src/internal/cursor-event-relay.ts +0 -675
- package/src/internal/cursor-relay-core.ts +0 -563
- package/src/internal/deferred-channel-session.ts +0 -61
- package/src/internal/deploy-client.ts +0 -1574
- package/src/internal/deploy-manifest.ts +0 -361
- package/src/internal/deploy-source.ts +0 -144
- package/src/internal/describe-error.ts +0 -32
- package/src/internal/dev-mode.ts +0 -20
- package/src/internal/discovery/agent-config.ts +0 -288
- package/src/internal/discovery/agent.ts +0 -381
- package/src/internal/discovery/channels.ts +0 -100
- package/src/internal/discovery/connections.ts +0 -516
- package/src/internal/discovery/context.ts +0 -38
- package/src/internal/discovery/cursor-plugin.ts +0 -628
- package/src/internal/discovery/extension-overlay.ts +0 -247
- package/src/internal/discovery/extensions.ts +0 -490
- package/src/internal/discovery/fs.ts +0 -103
- package/src/internal/discovery/hooks.ts +0 -63
- package/src/internal/discovery/info.ts +0 -174
- package/src/internal/discovery/instructions.ts +0 -98
- package/src/internal/discovery/modules.ts +0 -107
- package/src/internal/discovery/names.ts +0 -45
- package/src/internal/discovery/project.ts +0 -319
- package/src/internal/discovery/reminders.ts +0 -65
- package/src/internal/discovery/runtime.ts +0 -158
- package/src/internal/discovery/schedules.ts +0 -120
- package/src/internal/discovery/seed-files.ts +0 -34
- package/src/internal/discovery/services.ts +0 -151
- package/src/internal/discovery/skills.ts +0 -174
- package/src/internal/discovery/subagent.ts +0 -138
- package/src/internal/discovery/tools.ts +0 -170
- package/src/internal/discovery.ts +0 -27
- package/src/internal/distribution.ts +0 -126
- package/src/internal/docs-site.ts +0 -248
- package/src/internal/duration.ts +0 -37
- package/src/internal/env-file.ts +0 -83
- package/src/internal/eval-judge-model.ts +0 -142
- package/src/internal/eval-run-store.ts +0 -585
- package/src/internal/eval-runner.ts +0 -823
- package/src/internal/evals-client.ts +0 -475
- package/src/internal/event-log.ts +0 -342
- package/src/internal/event-mapper.ts +0 -811
- package/src/internal/expected-delivery-failure.ts +0 -34
- package/src/internal/factory-resource-channel.ts +0 -103
- package/src/internal/filesystem/errors.ts +0 -207
- package/src/internal/filesystem/format.ts +0 -253
- package/src/internal/filesystem/merge.ts +0 -192
- package/src/internal/filesystem/nearest.ts +0 -112
- package/src/internal/filesystem/scratch.ts +0 -239
- package/src/internal/filesystem/sdk-schemas.ts +0 -204
- package/src/internal/filesystem/tools.ts +0 -804
- package/src/internal/filesystem/walk.ts +0 -366
- package/src/internal/fixtures/units-server.ts +0 -52
- package/src/internal/framework-file-storage.ts +0 -357
- package/src/internal/framework-storage-selection.ts +0 -156
- package/src/internal/frontmatter.ts +0 -108
- package/src/internal/github-fanout.ts +0 -144
- package/src/internal/guest-network.ts +0 -391
- package/src/internal/handleAgentServeTrigger.ts +0 -286
- package/src/internal/host-files.ts +0 -341
- package/src/internal/host-kv.ts +0 -81
- package/src/internal/host-otel.ts +0 -231
- package/src/internal/host-platforms.ts +0 -170
- package/src/internal/hosted-admission-adapter.ts +0 -47
- package/src/internal/hosted-admission-context.ts +0 -37
- package/src/internal/hosted-catch-protocol.ts +0 -112
- package/src/internal/hosted-catch.ts +0 -179
- package/src/internal/hosted-delivery-protocol.ts +0 -824
- package/src/internal/hosted-delivery.ts +0 -1410
- package/src/internal/hosted-execution-diag.ts +0 -291
- package/src/internal/hosted-execution-flush.ts +0 -136
- package/src/internal/hosted-execution-latency.ts +0 -301
- package/src/internal/hosted-managed-automation.ts +0 -116
- package/src/internal/hosting.ts +0 -114
- package/src/internal/http-channel-define.ts +0 -25
- package/src/internal/http-channel.ts +0 -669
- package/src/internal/http-control-plane-session.ts +0 -110
- package/src/internal/ids.ts +0 -39
- package/src/internal/incoming-headers-to-fetch.ts +0 -45
- package/src/internal/init-interview.ts +0 -360
- package/src/internal/init-project.ts +0 -711
- package/src/internal/init-scaffold.ts +0 -182
- package/src/internal/inline-stdio-define-stub.ts +0 -4
- package/src/internal/inline-stdio-mcp.ts +0 -230
- package/src/internal/install-cursor-skills.ts +0 -604
- package/src/internal/is-record.ts +0 -3
- package/src/internal/json-schema.ts +0 -95
- package/src/internal/legacy-command-guard.ts +0 -66
- package/src/internal/listen-port.ts +0 -85
- package/src/internal/local-control-plane.ts +0 -442
- package/src/internal/local-env.ts +0 -59
- package/src/internal/local-ingress.ts +0 -90
- package/src/internal/log-ring.ts +0 -59
- package/src/internal/logs-client.ts +0 -477
- package/src/internal/map-pool.ts +0 -39
- package/src/internal/mcp-endpoint.ts +0 -747
- package/src/internal/mcp-host.ts +0 -509
- package/src/internal/mcp-oauth-on-demand.ts +0 -337
- package/src/internal/mcp-oauth-persist.ts +0 -118
- package/src/internal/mcp-oauth.ts +0 -549
- package/src/internal/net.ts +0 -29
- package/src/internal/open-browser.ts +0 -41
- package/src/internal/otel/attrs.ts +0 -16
- package/src/internal/otel/collector.ts +0 -937
- package/src/internal/otel/config.ts +0 -287
- package/src/internal/otel/http.ts +0 -122
- package/src/internal/otel/mcp.ts +0 -56
- package/src/internal/otel/propagation.ts +0 -17
- package/src/internal/otel/runtime.ts +0 -441
- package/src/internal/package-inline-stdio.ts +0 -114
- package/src/internal/peer-connections.ts +0 -96
- package/src/internal/platform-schedule-sync.ts +0 -75
- package/src/internal/platform-timers.ts +0 -365
- package/src/internal/playground/static.ts +0 -278
- package/src/internal/playground/toolchain.ts +0 -270
- package/src/internal/playground-proxy.ts +0 -564
- package/src/internal/process-memory-telemetry.ts +0 -334
- package/src/internal/project-layout.ts +0 -31
- package/src/internal/prompt-context.ts +0 -116
- package/src/internal/reminder-control-plane-protocol.ts +0 -482
- package/src/internal/reminder-runner.ts +0 -1559
- package/src/internal/reminder-schedule.ts +0 -104
- package/src/internal/reminder-store.ts +0 -176
- package/src/internal/request-error-status.ts +0 -95
- package/src/internal/request-headers.ts +0 -21
- package/src/internal/resolve-prod-target.ts +0 -334
- package/src/internal/resolved-connections.ts +0 -190
- package/src/internal/router.ts +0 -143
- package/src/internal/run-client.ts +0 -354
- package/src/internal/runtime-dispatch-runner.ts +0 -50
- package/src/internal/sanitize-mcp-tool-name.ts +0 -31
- package/src/internal/schedule-runner.ts +0 -154
- package/src/internal/scm/pr-url.ts +0 -245
- package/src/internal/sdk-runner.ts +0 -959
- package/src/internal/serve-restart.ts +0 -113
- package/src/internal/server.ts +0 -3147
- package/src/internal/session-cost.ts +0 -208
- package/src/internal/session-engine.ts +0 -5622
- package/src/internal/session-links.ts +0 -84
- package/src/internal/session-run-log.ts +0 -535
- package/src/internal/session-store.ts +0 -307
- package/src/internal/session-urls.ts +0 -32
- package/src/internal/sessions-client.ts +0 -239
- package/src/internal/skill-catalog.ts +0 -66
- package/src/internal/skills-sync.ts +0 -55
- package/src/internal/slack-provision-client.ts +0 -544
- package/src/internal/slack-thread-key.ts +0 -11
- package/src/internal/sleep.ts +0 -3
- package/src/internal/start-log-store.ts +0 -164
- package/src/internal/steering.ts +0 -17
- package/src/internal/storage-coordinator.ts +0 -800
- package/src/internal/storage-roles.ts +0 -86
- package/src/internal/storage.ts +0 -1
- package/src/internal/store-api-protocol.ts +0 -205
- package/src/internal/store-mirror.ts +0 -73
- package/src/internal/stream-progress.ts +0 -294
- package/src/internal/terminal-style.ts +0 -133
- package/src/internal/testing/factory-resource-fixtures.ts +0 -84
- package/src/internal/testing/scm-continuation-fixtures.ts +0 -285
- package/src/internal/tool-catalog.ts +0 -104
- package/src/internal/tool-policy.ts +0 -222
- package/src/internal/tool-result.ts +0 -50
- package/src/internal/trajectory.ts +0 -418
- package/src/internal/turn-cost.ts +0 -136
- package/src/internal/turn-governor.ts +0 -145
- package/src/internal/turn-lease-store.ts +0 -144
- package/src/internal/turn-outbox.ts +0 -77
- package/src/internal/update-check.ts +0 -517
- package/src/internal/v2-hosting.ts +0 -52
- package/src/internal/workspace-sync.ts +0 -114
- package/src/internal/workspace.ts +0 -505
- package/src/kv/memory-kv.ts +0 -94
- package/src/kv.ts +0 -18
- package/src/memory.ts +0 -487
- package/src/otel-public.ts +0 -24
- package/src/otel.ts +0 -320
- package/src/prompt.ts +0 -80
- package/src/reminders.ts +0 -65
- package/src/schedules.ts +0 -31
- package/src/skills.ts +0 -27
- package/src/storage-backends/cursor-hosted-v2.ts +0 -204
- package/src/storage-backends/cursor-hosted.ts +0 -388
- package/src/storage-backends/file-kv.ts +0 -276
- package/src/storage-protocol.ts +0 -261
- package/src/storage.ts +0 -408
- package/src/tools.ts +0 -166
- package/src/types.ts +0 -3776
- /package/dist/docs/assets/{reference_agent-config.md.DzGI777n.lean.js → reference_agent-config.md.Cj5uBKp4.lean.js} +0 -0
|
@@ -1,815 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { allowAll, defineChannel, localDevStrict, loopbackOnly, POST } from "../../channels.js";
|
|
3
|
-
import {
|
|
4
|
-
acknowledgeTask,
|
|
5
|
-
isTaskDispatch,
|
|
6
|
-
skipped,
|
|
7
|
-
turnStarted,
|
|
8
|
-
withPropagatingBackgroundErrors,
|
|
9
|
-
} from "../../internal/channel-dispatch.js";
|
|
10
|
-
import { continuationSource, normalizeIdentity } from "../../internal/continuation-identity.js";
|
|
11
|
-
import { isDevMode } from "../../internal/dev-mode.js";
|
|
12
|
-
import { attachHostedAdmissionAdapter } from "../../internal/hosted-admission-adapter.js";
|
|
13
|
-
import { bindLocalIngressSend } from "../../internal/local-ingress.js";
|
|
14
|
-
import type {
|
|
15
|
-
AgentCloudOptions,
|
|
16
|
-
AuthContext,
|
|
17
|
-
ChannelDefinition,
|
|
18
|
-
ChannelEventHandlers,
|
|
19
|
-
ChannelHandlerArgs,
|
|
20
|
-
JsonValue,
|
|
21
|
-
} from "../../types.js";
|
|
22
|
-
import { buildOriginBinding } from "./binding.js";
|
|
23
|
-
import {
|
|
24
|
-
parseCursorOriginRepoScope,
|
|
25
|
-
registerOriginCursorAccountRuntime,
|
|
26
|
-
} from "./cursor-account.js";
|
|
27
|
-
import { buildDefaultOriginEvents } from "./defaults.js";
|
|
28
|
-
import { deriveOriginWebhookEvents, ORIGIN_CHANNEL_KIND } from "./events.js";
|
|
29
|
-
import {
|
|
30
|
-
DEFAULT_ORIGIN_API_BASE_URL,
|
|
31
|
-
OriginJwksUnavailableError,
|
|
32
|
-
type OriginWebhookHeaders,
|
|
33
|
-
verifyOriginWebhook,
|
|
34
|
-
} from "./origin-webhook.js";
|
|
35
|
-
import {
|
|
36
|
-
emptyOriginChannelState,
|
|
37
|
-
type OriginChannelState,
|
|
38
|
-
originChannelStateForEvent,
|
|
39
|
-
} from "./state.js";
|
|
40
|
-
import type {
|
|
41
|
-
OriginActor,
|
|
42
|
-
OriginChannelOptions,
|
|
43
|
-
OriginComment,
|
|
44
|
-
OriginDispatch,
|
|
45
|
-
OriginEventContext,
|
|
46
|
-
OriginPullRequestEvent,
|
|
47
|
-
OriginRepositoryRef,
|
|
48
|
-
OriginReview,
|
|
49
|
-
OriginTurnDispatch,
|
|
50
|
-
OriginWebhookEnvelope,
|
|
51
|
-
} from "./types.js";
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Default dispatch gate when no `onPullRequest` hook is declared: the common
|
|
55
|
-
* review triggers start a turn as the delivery's actor.
|
|
56
|
-
*/
|
|
57
|
-
const DEFAULT_PULL_REQUEST_TYPES: ReadonlySet<string> = new Set([
|
|
58
|
-
"pull_request.created",
|
|
59
|
-
"pull_request.published",
|
|
60
|
-
"pull_request.head_ref.pushed",
|
|
61
|
-
"pull_request.base_ref.updated",
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
65
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
66
|
-
? (value as Record<string, unknown>)
|
|
67
|
-
: undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function asNonEmptyString(value: unknown): string | undefined {
|
|
71
|
-
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function asPositiveInt(value: unknown): number | undefined {
|
|
75
|
-
if (typeof value === "number" && Number.isInteger(value) && value > 0) {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
if (typeof value === "string" && /^[1-9]\d*$/.test(value)) {
|
|
79
|
-
return Number(value);
|
|
80
|
-
}
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function asBoolean(value: unknown): boolean | undefined {
|
|
85
|
-
return typeof value === "boolean" ? value : undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function originActor(value: unknown): OriginActor | undefined {
|
|
89
|
-
const record = asRecord(value);
|
|
90
|
-
if (record === undefined) return undefined;
|
|
91
|
-
|
|
92
|
-
const nestedActors = [
|
|
93
|
-
["user", asRecord(record.user)],
|
|
94
|
-
["app", asRecord(record.app)],
|
|
95
|
-
["service_account", asRecord(record.serviceAccount)],
|
|
96
|
-
] as const;
|
|
97
|
-
for (const [kind, actor] of nestedActors) {
|
|
98
|
-
const id = asNonEmptyString(actor?.id);
|
|
99
|
-
if (id !== undefined) {
|
|
100
|
-
return { id, kind };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const id = asNonEmptyString(record.id);
|
|
105
|
-
if (id === undefined) return undefined;
|
|
106
|
-
const kind = asNonEmptyString(record.kind);
|
|
107
|
-
return kind === undefined ? { id } : { id, kind };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function originHeaders(request: Request): OriginWebhookHeaders {
|
|
111
|
-
return {
|
|
112
|
-
"webhook-id": request.headers.get("webhook-id") ?? undefined,
|
|
113
|
-
"webhook-timestamp": request.headers.get("webhook-timestamp") ?? undefined,
|
|
114
|
-
"webhook-signature": request.headers.get("webhook-signature") ?? undefined,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function skipOriginVerify(): boolean {
|
|
119
|
-
return process.env.AGENT_SERVE_ORIGIN_SKIP_VERIFY?.trim() === "1";
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Direct Origin HTTP deliveries verify v1ed. `--dev` and
|
|
124
|
-
* `AGENT_SERVE_ORIGIN_SKIP_VERIFY=1` skip that so local fixtures work, matching
|
|
125
|
-
* GitHub's unsigned loopback posture when no webhook secret is set.
|
|
126
|
-
*/
|
|
127
|
-
function shouldSkipOriginVerify(): boolean {
|
|
128
|
-
return skipOriginVerify() || isDevMode();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function asIdList(value: string | readonly string[] | undefined): string[] {
|
|
132
|
-
if (value === undefined) return [];
|
|
133
|
-
const items = typeof value === "string" ? [value] : [...value];
|
|
134
|
-
return [...new Set(items.map(id => id.trim()).filter(Boolean))];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** `AGENT_SERVE_ORIGIN_APP_ID` fallback for {@link OriginChannelOptions.appId}. */
|
|
138
|
-
export function envOriginAppId(): string | undefined {
|
|
139
|
-
const value = process.env.AGENT_SERVE_ORIGIN_APP_ID?.trim();
|
|
140
|
-
return value === undefined || value === "" ? undefined : value;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function configuredOriginAppIds(options: OriginChannelOptions): readonly string[] {
|
|
144
|
-
const fromOptions = asIdList(options.appId);
|
|
145
|
-
if (fromOptions.length > 0) return fromOptions;
|
|
146
|
-
const fromEnv = envOriginAppId();
|
|
147
|
-
return fromEnv === undefined ? [] : [fromEnv];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function configuredOriginInstallationIds(options: OriginChannelOptions): readonly string[] {
|
|
151
|
-
return asIdList(options.installationId);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Repo allowlist for HTTP and trigger fan-out. `undefined` means no extra
|
|
156
|
-
* repo gate (the bound Origin app's installations still bound what Origin
|
|
157
|
-
* will send).
|
|
158
|
-
*/
|
|
159
|
-
function configuredOriginRepoAllowlist(
|
|
160
|
-
options: OriginChannelOptions,
|
|
161
|
-
): ReadonlySet<string> | undefined {
|
|
162
|
-
const repos: string[] = [];
|
|
163
|
-
if (options.repos !== undefined) {
|
|
164
|
-
repos.push(...parseCursorOriginRepoScope(options.repos).repos);
|
|
165
|
-
}
|
|
166
|
-
if (typeof options.cursorAccount === "object") {
|
|
167
|
-
repos.push(...parseCursorOriginRepoScope(options.cursorAccount.repos).repos);
|
|
168
|
-
}
|
|
169
|
-
return repos.length === 0 ? undefined : new Set(repos);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* v1ed proves Origin signed the body. Channel auth is the signed
|
|
174
|
-
* `envelope.appId` matching this channel's configured Origin app (the GitHub
|
|
175
|
-
* webhook-secret analogue). Cursor-internal documents the same gap.
|
|
176
|
-
*/
|
|
177
|
-
function originHttpBindingError(
|
|
178
|
-
options: OriginChannelOptions,
|
|
179
|
-
envelope: OriginWebhookEnvelope,
|
|
180
|
-
): string | undefined {
|
|
181
|
-
const allowedApps = configuredOriginAppIds(options);
|
|
182
|
-
if (allowedApps.length === 0) {
|
|
183
|
-
return "unbound_origin_app";
|
|
184
|
-
}
|
|
185
|
-
const deliveredAppId = envelope.appId?.trim();
|
|
186
|
-
if (deliveredAppId === undefined || deliveredAppId === "") {
|
|
187
|
-
return "invalid_app";
|
|
188
|
-
}
|
|
189
|
-
if (!allowedApps.includes(deliveredAppId)) {
|
|
190
|
-
return "invalid_app";
|
|
191
|
-
}
|
|
192
|
-
const allowedInstalls = configuredOriginInstallationIds(options);
|
|
193
|
-
if (allowedInstalls.length === 0) {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
const deliveredInstallationId = envelope.installationId?.trim();
|
|
197
|
-
if (
|
|
198
|
-
deliveredInstallationId === undefined ||
|
|
199
|
-
deliveredInstallationId === "" ||
|
|
200
|
-
!allowedInstalls.includes(deliveredInstallationId)
|
|
201
|
-
) {
|
|
202
|
-
return "invalid_installation";
|
|
203
|
-
}
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function resolveApiBaseUrl(options: OriginChannelOptions): string {
|
|
208
|
-
const authored =
|
|
209
|
-
typeof options.apiBaseUrl === "function" ? options.apiBaseUrl() : options.apiBaseUrl;
|
|
210
|
-
const trimmed = authored?.trim();
|
|
211
|
-
return trimmed === undefined || trimmed === "" ? DEFAULT_ORIGIN_API_BASE_URL : trimmed;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const originEnvelopeSchema: z.ZodType<OriginWebhookEnvelope> = z.object({
|
|
215
|
-
deliveryId: z.string().optional(),
|
|
216
|
-
appId: z.string().optional(),
|
|
217
|
-
installationId: z.string().optional(),
|
|
218
|
-
sender: z
|
|
219
|
-
.object({
|
|
220
|
-
id: z.string().min(1),
|
|
221
|
-
kind: z.string().optional(),
|
|
222
|
-
})
|
|
223
|
-
.optional(),
|
|
224
|
-
event: z.object({
|
|
225
|
-
id: z.string().optional(),
|
|
226
|
-
type: z.string().min(1),
|
|
227
|
-
eventTime: z.string().optional(),
|
|
228
|
-
payload: z.unknown().optional(),
|
|
229
|
-
}),
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
export function parseOriginWebhookEnvelope(payload: unknown): OriginWebhookEnvelope | null {
|
|
233
|
-
const parsed = originEnvelopeSchema.safeParse(payload);
|
|
234
|
-
return parsed.success ? parsed.data : null;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function originRepoFromPayload(payload: Record<string, unknown>): OriginRepositoryRef | undefined {
|
|
238
|
-
const repository =
|
|
239
|
-
asRecord(payload.repository) ?? asRecord(asRecord(payload.pullRequest)?.repository);
|
|
240
|
-
const owner = asNonEmptyString(asRecord(repository?.owner)?.slug);
|
|
241
|
-
const name = asNonEmptyString(repository?.name);
|
|
242
|
-
if (owner === undefined || name === undefined) return undefined;
|
|
243
|
-
return { owner, name, fullName: `${owner}/${name}` };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function originPrUrl(repository: OriginRepositoryRef, number: number, explicit?: string): string {
|
|
247
|
-
return (
|
|
248
|
-
explicit ?? `https://cursor.com/codebase/${repository.owner}/${repository.name}/pull/${number}`
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function originSender(
|
|
253
|
-
envelope: OriginWebhookEnvelope,
|
|
254
|
-
payload: Record<string, unknown>,
|
|
255
|
-
): OriginActor | undefined {
|
|
256
|
-
return (
|
|
257
|
-
envelope.sender ??
|
|
258
|
-
originActor(payload.actor) ??
|
|
259
|
-
originActor(payload.pusher) ??
|
|
260
|
-
originActor(asRecord(payload.review)?.author) ??
|
|
261
|
-
originActor(asRecord(payload.comment)?.author) ??
|
|
262
|
-
originActor(asRecord(payload.pullRequest)?.author)
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export function parseOriginPullRequestEvent(input: { envelope: OriginWebhookEnvelope }): {
|
|
267
|
-
ctx: Omit<OriginEventContext, "host" | "artifacts" | "origin">;
|
|
268
|
-
pullRequest: OriginPullRequestEvent;
|
|
269
|
-
payload: Record<string, unknown>;
|
|
270
|
-
} | null {
|
|
271
|
-
const payload = asRecord(input.envelope.event.payload) ?? {};
|
|
272
|
-
const repository = originRepoFromPayload(payload);
|
|
273
|
-
const pullRequest = asRecord(payload.pullRequest);
|
|
274
|
-
const number = asPositiveInt(pullRequest?.number);
|
|
275
|
-
if (repository === undefined || number === undefined) {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
const eventType = input.envelope.event.type;
|
|
279
|
-
const url = originPrUrl(repository, number, asNonEmptyString(pullRequest?.url));
|
|
280
|
-
const head = asRecord(pullRequest?.head);
|
|
281
|
-
const base = asRecord(pullRequest?.base);
|
|
282
|
-
const version = asRecord(pullRequest?.version);
|
|
283
|
-
const author = originActor(pullRequest?.author);
|
|
284
|
-
return {
|
|
285
|
-
payload,
|
|
286
|
-
ctx: {
|
|
287
|
-
deliveryId: input.envelope.deliveryId,
|
|
288
|
-
eventType,
|
|
289
|
-
eventTime: input.envelope.event.eventTime,
|
|
290
|
-
installationId: input.envelope.installationId,
|
|
291
|
-
repository,
|
|
292
|
-
pullRequestNumber: number,
|
|
293
|
-
pullRequestUrl: url,
|
|
294
|
-
pullRequestAuthor: author,
|
|
295
|
-
payload,
|
|
296
|
-
sender: originSender(input.envelope, payload),
|
|
297
|
-
},
|
|
298
|
-
pullRequest: {
|
|
299
|
-
type: eventType,
|
|
300
|
-
number,
|
|
301
|
-
url,
|
|
302
|
-
title: asNonEmptyString(pullRequest?.title),
|
|
303
|
-
body:
|
|
304
|
-
pullRequest?.body === null
|
|
305
|
-
? null
|
|
306
|
-
: (asNonEmptyString(pullRequest?.body) ??
|
|
307
|
-
(typeof pullRequest?.body === "string" ? pullRequest.body : undefined)),
|
|
308
|
-
draft: asBoolean(pullRequest?.draft),
|
|
309
|
-
merged: eventType === "pull_request.merged" || asBoolean(pullRequest?.merged),
|
|
310
|
-
authorId: author?.id,
|
|
311
|
-
headRef: asNonEmptyString(head?.ref),
|
|
312
|
-
headSha: asNonEmptyString(head?.sha) ?? asNonEmptyString(version?.headSha),
|
|
313
|
-
baseRef: asNonEmptyString(base?.ref),
|
|
314
|
-
baseSha: asNonEmptyString(base?.sha) ?? asNonEmptyString(version?.baseSha),
|
|
315
|
-
},
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Derive the turn's auth from the actor that triggered the delivery — the
|
|
321
|
-
* standard `{ auth: defaultOriginAuth(ctx) }` dispatch from an inbound hook.
|
|
322
|
-
* The subscriber's Cursor identity is not the turn principal (same pattern
|
|
323
|
-
* as {@link defaultGitHubAuth}).
|
|
324
|
-
*/
|
|
325
|
-
export function defaultOriginAuth(
|
|
326
|
-
ctx: Omit<OriginEventContext, "host" | "artifacts" | "origin">,
|
|
327
|
-
): AuthContext {
|
|
328
|
-
const senderId = ctx.sender?.id;
|
|
329
|
-
const senderKind = ctx.sender?.kind;
|
|
330
|
-
return {
|
|
331
|
-
authenticator: "origin-webhook",
|
|
332
|
-
principalId: senderId ?? "origin",
|
|
333
|
-
principalType: senderKind === "app" || senderKind === "service_account" ? "service" : "user",
|
|
334
|
-
attributes: {
|
|
335
|
-
conversation_kind: "pull_request",
|
|
336
|
-
repository: ctx.repository.fullName,
|
|
337
|
-
...(ctx.deliveryId === undefined ? {} : { delivery_id: ctx.deliveryId }),
|
|
338
|
-
...(senderId === undefined ? {} : { subject: senderId }),
|
|
339
|
-
...(senderKind === undefined ? {} : { user_type: senderKind }),
|
|
340
|
-
issuer: `origin:${ctx.repository.owner}`,
|
|
341
|
-
},
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function originContinuationKey(
|
|
346
|
-
ctx: Pick<OriginEventContext, "repository" | "pullRequestNumber">,
|
|
347
|
-
): string {
|
|
348
|
-
return `origin-pr:${ctx.repository.fullName}#${ctx.pullRequestNumber}`;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/** Payload shape local/hosted CP extract expects (`fullName` + number). */
|
|
352
|
-
export function originIngressExtractPayload(envelope: OriginWebhookEnvelope): unknown {
|
|
353
|
-
const parsed = parseOriginPullRequestEvent({ envelope });
|
|
354
|
-
if (parsed === null) {
|
|
355
|
-
return envelope.event.payload;
|
|
356
|
-
}
|
|
357
|
-
return {
|
|
358
|
-
pullRequest: { number: parsed.ctx.pullRequestNumber },
|
|
359
|
-
repository: { fullName: parsed.ctx.repository.fullName },
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export function defaultOriginTitle(
|
|
364
|
-
ctx: Pick<OriginEventContext, "repository" | "pullRequestNumber">,
|
|
365
|
-
): string {
|
|
366
|
-
return `Origin ${ctx.repository.fullName}#${ctx.pullRequestNumber}`;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export function defaultOriginPullRequestMessage(
|
|
370
|
-
ctx: Omit<OriginEventContext, "host" | "artifacts" | "origin">,
|
|
371
|
-
pullRequest: OriginPullRequestEvent,
|
|
372
|
-
): string {
|
|
373
|
-
const head =
|
|
374
|
-
pullRequest.headRef !== undefined && pullRequest.headSha !== undefined
|
|
375
|
-
? `Head: ${pullRequest.headRef} (${pullRequest.headSha})`
|
|
376
|
-
: undefined;
|
|
377
|
-
return [
|
|
378
|
-
`Origin pull request trigger: ${ctx.repository.fullName}#${pullRequest.number}`,
|
|
379
|
-
`Event: ${pullRequest.type}`,
|
|
380
|
-
`URL: ${pullRequest.url}`,
|
|
381
|
-
...(pullRequest.title === undefined ? [] : [`Title: ${pullRequest.title}`]),
|
|
382
|
-
...(head === undefined ? [] : [head]),
|
|
383
|
-
"Handle this pull request event.",
|
|
384
|
-
].join("\n");
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export function defaultOriginPullRequestDispatch(
|
|
388
|
-
ctx: Omit<OriginEventContext, "host" | "artifacts" | "origin">,
|
|
389
|
-
pullRequest: OriginPullRequestEvent,
|
|
390
|
-
): OriginTurnDispatch | null {
|
|
391
|
-
if (!DEFAULT_PULL_REQUEST_TYPES.has(pullRequest.type)) {
|
|
392
|
-
return null;
|
|
393
|
-
}
|
|
394
|
-
return { auth: defaultOriginAuth(ctx) };
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function enrichEventContext(input: {
|
|
398
|
-
ctx: Omit<OriginEventContext, "host" | "artifacts" | "origin">;
|
|
399
|
-
args: ChannelHandlerArgs;
|
|
400
|
-
options: OriginChannelOptions;
|
|
401
|
-
}): OriginEventContext {
|
|
402
|
-
return {
|
|
403
|
-
...input.ctx,
|
|
404
|
-
host: input.args.host,
|
|
405
|
-
artifacts: input.args.artifacts,
|
|
406
|
-
send: input.args.send,
|
|
407
|
-
origin: buildOriginBinding({
|
|
408
|
-
repository: input.ctx.repository,
|
|
409
|
-
installationId: input.ctx.installationId,
|
|
410
|
-
executionId: input.ctx.deliveryId,
|
|
411
|
-
cursorAccount:
|
|
412
|
-
input.options.cursorAccount !== undefined && input.options.cursorAccount !== false,
|
|
413
|
-
app: input.options.app,
|
|
414
|
-
}),
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
async function startTurn(input: {
|
|
419
|
-
options: OriginChannelOptions;
|
|
420
|
-
args: ChannelHandlerArgs;
|
|
421
|
-
ctx: OriginEventContext;
|
|
422
|
-
message: string;
|
|
423
|
-
dispatch: OriginTurnDispatch;
|
|
424
|
-
cloud?: AgentCloudOptions;
|
|
425
|
-
state: OriginChannelState;
|
|
426
|
-
}): Promise<Response> {
|
|
427
|
-
const source = continuationSource(input.options.continuation, "origin");
|
|
428
|
-
const cloud = input.dispatch.cloud ?? input.cloud;
|
|
429
|
-
const state = { ...input.dispatch.state, ...input.state };
|
|
430
|
-
const session = await input.args.send(input.message, {
|
|
431
|
-
auth: input.dispatch.auth,
|
|
432
|
-
...(source === "engine" ? { continuationToken: originContinuationKey(input.ctx) } : {}),
|
|
433
|
-
title: input.dispatch.title ?? defaultOriginTitle(input.ctx),
|
|
434
|
-
cloud,
|
|
435
|
-
state: state as unknown as JsonValue,
|
|
436
|
-
// Resume must refresh the triggering comment / delivery identifiers so
|
|
437
|
-
// reply delivery targets the latest wake, not the session's first.
|
|
438
|
-
refreshState: state as unknown as JsonValue,
|
|
439
|
-
});
|
|
440
|
-
return turnStarted(session);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
async function resolveCloudOptions(
|
|
444
|
-
cloud: OriginChannelOptions["cloud"],
|
|
445
|
-
ctx: OriginEventContext,
|
|
446
|
-
pullRequest: OriginPullRequestEvent,
|
|
447
|
-
): Promise<AgentCloudOptions | undefined> {
|
|
448
|
-
if (cloud === undefined || cloud === false) {
|
|
449
|
-
return undefined;
|
|
450
|
-
}
|
|
451
|
-
if (cloud === true) {
|
|
452
|
-
return {
|
|
453
|
-
repos: [
|
|
454
|
-
{
|
|
455
|
-
url: `https://cursor.com/codebase/${ctx.repository.fullName}`,
|
|
456
|
-
prUrl: pullRequest.url,
|
|
457
|
-
startingRef: pullRequest.headSha,
|
|
458
|
-
},
|
|
459
|
-
],
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
if (typeof cloud === "function") {
|
|
463
|
-
return await cloud(ctx, pullRequest);
|
|
464
|
-
}
|
|
465
|
-
return cloud;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
async function applyDispatch(input: {
|
|
469
|
-
options: OriginChannelOptions;
|
|
470
|
-
args: ChannelHandlerArgs;
|
|
471
|
-
ctx: OriginEventContext;
|
|
472
|
-
dispatch: OriginDispatch | null;
|
|
473
|
-
extra: Record<string, unknown>;
|
|
474
|
-
message: string;
|
|
475
|
-
cloud?: AgentCloudOptions;
|
|
476
|
-
/** Comment id that woke this dispatch (comment events only). */
|
|
477
|
-
triggeringCommentId?: string;
|
|
478
|
-
}): Promise<Response> {
|
|
479
|
-
if (input.dispatch === null) {
|
|
480
|
-
return skipped("not_dispatched", input.extra);
|
|
481
|
-
}
|
|
482
|
-
if (isTaskDispatch(input.dispatch)) {
|
|
483
|
-
return acknowledgeTask(input.args, ORIGIN_CHANNEL_KIND, input.dispatch, input.extra);
|
|
484
|
-
}
|
|
485
|
-
const message = [input.dispatch.message ?? input.message, ...(input.dispatch.context ?? [])].join(
|
|
486
|
-
"\n",
|
|
487
|
-
);
|
|
488
|
-
return startTurn({
|
|
489
|
-
options: input.options,
|
|
490
|
-
args: input.args,
|
|
491
|
-
ctx: input.ctx,
|
|
492
|
-
message,
|
|
493
|
-
dispatch: input.dispatch,
|
|
494
|
-
cloud: input.cloud,
|
|
495
|
-
state: originChannelStateForEvent({
|
|
496
|
-
repository: input.ctx.repository,
|
|
497
|
-
pullRequestNumber: input.ctx.pullRequestNumber,
|
|
498
|
-
installationId: input.ctx.installationId,
|
|
499
|
-
deliveryId: input.ctx.deliveryId,
|
|
500
|
-
eventType: input.ctx.eventType,
|
|
501
|
-
triggeringCommentId: input.triggeringCommentId,
|
|
502
|
-
}),
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Run the authored hooks for one Origin delivery and `send()` the turn.
|
|
508
|
-
* Callers own delivery auth: the HTTP route verifies v1ed and binds the app
|
|
509
|
-
* id; trigger fan-out and hosted admission arrive verified. The v2 mailbox
|
|
510
|
-
* is stamped upstream (local CP or hosted ingress), never here.
|
|
511
|
-
*/
|
|
512
|
-
export async function dispatchOriginWebhook(input: {
|
|
513
|
-
options: OriginChannelOptions;
|
|
514
|
-
envelope: OriginWebhookEnvelope;
|
|
515
|
-
args: ChannelHandlerArgs;
|
|
516
|
-
}): Promise<Response> {
|
|
517
|
-
const eventType = input.envelope.event.type;
|
|
518
|
-
const parsed = parseOriginPullRequestEvent({ envelope: input.envelope });
|
|
519
|
-
if (parsed === null) {
|
|
520
|
-
return Response.json({ ok: false, error: "invalid_origin_payload" }, { status: 400 });
|
|
521
|
-
}
|
|
522
|
-
const args = input.args;
|
|
523
|
-
const ctx = enrichEventContext({
|
|
524
|
-
ctx: parsed.ctx,
|
|
525
|
-
args,
|
|
526
|
-
options: input.options,
|
|
527
|
-
});
|
|
528
|
-
const { pullRequest, payload } = parsed;
|
|
529
|
-
const repoAllowlist = configuredOriginRepoAllowlist(input.options);
|
|
530
|
-
if (repoAllowlist !== undefined && !repoAllowlist.has(ctx.repository.fullName.toLowerCase())) {
|
|
531
|
-
return skipped("repo_not_allowed", { repo: ctx.repository.fullName });
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (eventType.startsWith("pull_request.comment.")) {
|
|
535
|
-
if (input.options.onComment === undefined) {
|
|
536
|
-
return skipped("no_handler", { event: eventType });
|
|
537
|
-
}
|
|
538
|
-
const commentRecord = asRecord(payload.comment);
|
|
539
|
-
const commentId = asNonEmptyString(commentRecord?.id);
|
|
540
|
-
const commentBody = typeof commentRecord?.body === "string" ? commentRecord.body : undefined;
|
|
541
|
-
if (commentId === undefined || commentBody === undefined) {
|
|
542
|
-
return Response.json({ ok: false, error: "invalid_origin_comment_payload" }, { status: 400 });
|
|
543
|
-
}
|
|
544
|
-
const comment: OriginComment = {
|
|
545
|
-
id: commentId,
|
|
546
|
-
body: commentBody,
|
|
547
|
-
author: originActor(commentRecord?.author),
|
|
548
|
-
};
|
|
549
|
-
const dispatch = await input.options.onComment(ctx, comment);
|
|
550
|
-
return applyDispatch({
|
|
551
|
-
options: input.options,
|
|
552
|
-
args,
|
|
553
|
-
ctx,
|
|
554
|
-
dispatch,
|
|
555
|
-
extra: { event: eventType },
|
|
556
|
-
message:
|
|
557
|
-
commentBody.trim() === ""
|
|
558
|
-
? `Origin comment on ${ctx.repository.fullName}#${ctx.pullRequestNumber}`
|
|
559
|
-
: commentBody.trim(),
|
|
560
|
-
triggeringCommentId: commentId,
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (eventType.startsWith("pull_request.review.")) {
|
|
565
|
-
if (input.options.onReview === undefined) {
|
|
566
|
-
return skipped("no_handler", { event: eventType });
|
|
567
|
-
}
|
|
568
|
-
const reviewRecord = asRecord(payload.review) ?? {};
|
|
569
|
-
const review: OriginReview = {
|
|
570
|
-
id: asNonEmptyString(reviewRecord.id),
|
|
571
|
-
verdict: asNonEmptyString(reviewRecord.verdict),
|
|
572
|
-
author: originActor(reviewRecord.author),
|
|
573
|
-
};
|
|
574
|
-
const dispatch = await input.options.onReview(ctx, review);
|
|
575
|
-
return applyDispatch({
|
|
576
|
-
options: input.options,
|
|
577
|
-
args,
|
|
578
|
-
ctx,
|
|
579
|
-
dispatch,
|
|
580
|
-
extra: { event: eventType },
|
|
581
|
-
message: `Origin review on ${ctx.repository.fullName}#${ctx.pullRequestNumber}`,
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
if (eventType.startsWith("pull_request.")) {
|
|
586
|
-
const dispatch =
|
|
587
|
-
input.options.onPullRequest === undefined
|
|
588
|
-
? defaultOriginPullRequestDispatch(ctx, pullRequest)
|
|
589
|
-
: await input.options.onPullRequest(ctx, pullRequest);
|
|
590
|
-
const cloud = await resolveCloudOptions(input.options.cloud, ctx, pullRequest);
|
|
591
|
-
return applyDispatch({
|
|
592
|
-
options: input.options,
|
|
593
|
-
args,
|
|
594
|
-
ctx,
|
|
595
|
-
dispatch,
|
|
596
|
-
extra: { event: eventType },
|
|
597
|
-
message: defaultOriginPullRequestMessage(ctx, pullRequest),
|
|
598
|
-
cloud,
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (input.options.onEvent !== undefined) {
|
|
603
|
-
const dispatch = await input.options.onEvent(ctx, {
|
|
604
|
-
eventType,
|
|
605
|
-
payload,
|
|
606
|
-
});
|
|
607
|
-
return applyDispatch({
|
|
608
|
-
options: input.options,
|
|
609
|
-
args,
|
|
610
|
-
ctx,
|
|
611
|
-
dispatch,
|
|
612
|
-
extra: { event: eventType },
|
|
613
|
-
message: `Origin ${eventType} event`,
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
return skipped("unsupported_event", { event: eventType });
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* HTTP entry for a single agent's Origin channel: optional v1ed verify, then
|
|
622
|
-
* app-id bind, then {@link dispatchOriginWebhook}.
|
|
623
|
-
*/
|
|
624
|
-
export async function handleOriginWebhookRequest(input: {
|
|
625
|
-
options: OriginChannelOptions;
|
|
626
|
-
request: Request;
|
|
627
|
-
args: ChannelHandlerArgs;
|
|
628
|
-
/** When true, skip v1ed even though Origin HTTP deliveries are signed. */
|
|
629
|
-
skipSignatureVerification?: boolean;
|
|
630
|
-
}): Promise<Response> {
|
|
631
|
-
const bodyText = await input.request.text();
|
|
632
|
-
const requireHttpBinding =
|
|
633
|
-
input.skipSignatureVerification !== true && shouldSkipOriginVerify() !== true;
|
|
634
|
-
if (requireHttpBinding) {
|
|
635
|
-
try {
|
|
636
|
-
await verifyOriginWebhook(bodyText, originHeaders(input.request), {
|
|
637
|
-
apiBaseUrl: resolveApiBaseUrl(input.options),
|
|
638
|
-
});
|
|
639
|
-
} catch (error) {
|
|
640
|
-
// A JWKS outage means the delivery was never checked: answer 503 so
|
|
641
|
-
// Origin's delivery worker retries. Only a real signature mismatch
|
|
642
|
-
// is the terminal 401.
|
|
643
|
-
if (error instanceof OriginJwksUnavailableError) {
|
|
644
|
-
return Response.json(
|
|
645
|
-
{ ok: false, error: "signature_verification_unavailable" },
|
|
646
|
-
{ status: 503 },
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
return Response.json({ ok: false, error: "invalid_signature" }, { status: 401 });
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
let payload: unknown;
|
|
654
|
-
try {
|
|
655
|
-
payload = JSON.parse(bodyText) as unknown;
|
|
656
|
-
} catch {
|
|
657
|
-
return Response.json({ ok: false, error: "invalid_json" }, { status: 400 });
|
|
658
|
-
}
|
|
659
|
-
const envelope = parseOriginWebhookEnvelope(payload);
|
|
660
|
-
if (envelope === null) {
|
|
661
|
-
return Response.json({ ok: false, error: "invalid_origin_payload" }, { status: 400 });
|
|
662
|
-
}
|
|
663
|
-
if (requireHttpBinding) {
|
|
664
|
-
const bindingError = originHttpBindingError(input.options, envelope);
|
|
665
|
-
if (bindingError !== undefined) {
|
|
666
|
-
return Response.json({ ok: false, error: bindingError }, { status: 401 });
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return dispatchOriginWebhook({
|
|
670
|
-
options: input.options,
|
|
671
|
-
envelope,
|
|
672
|
-
args: bindLocalIngressSend(input.args, {
|
|
673
|
-
identity: input.options.continuation,
|
|
674
|
-
kind: "origin",
|
|
675
|
-
eventType: envelope.event.type,
|
|
676
|
-
payload: originIngressExtractPayload(envelope),
|
|
677
|
-
}),
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
const originChannelOptionsByDefinition = new WeakMap<object, OriginChannelOptions>();
|
|
682
|
-
|
|
683
|
-
export function getOriginChannelOptions(definition: object): OriginChannelOptions | undefined {
|
|
684
|
-
return originChannelOptionsByDefinition.get(definition);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
export function originChannel(
|
|
688
|
-
options: OriginChannelOptions = {},
|
|
689
|
-
): ChannelDefinition<OriginChannelState> {
|
|
690
|
-
const usesCursorAccount =
|
|
691
|
-
options.cursorAccount === true || typeof options.cursorAccount === "object";
|
|
692
|
-
const cursorScope =
|
|
693
|
-
typeof options.cursorAccount === "object"
|
|
694
|
-
? parseCursorOriginRepoScope(options.cursorAccount.repos)
|
|
695
|
-
: undefined;
|
|
696
|
-
if (options.repos !== undefined) {
|
|
697
|
-
parseCursorOriginRepoScope(options.repos);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const routePath = options.path ?? "/";
|
|
701
|
-
// v1ed + configured app id is the request auth (allowAll), matching GitHub
|
|
702
|
-
// HMAC + webhookSecret. Without an app id, prod stays loopback-strict so a
|
|
703
|
-
// reachable URL cannot be driven by any Origin-signed delivery. `--dev`
|
|
704
|
-
// / skip-verify admits loopback only.
|
|
705
|
-
const auth = options.auth ?? [
|
|
706
|
-
(request, info) =>
|
|
707
|
-
(shouldSkipOriginVerify()
|
|
708
|
-
? loopbackOnly()
|
|
709
|
-
: configuredOriginAppIds(options).length > 0
|
|
710
|
-
? allowAll()
|
|
711
|
-
: localDevStrict())(request, info),
|
|
712
|
-
];
|
|
713
|
-
|
|
714
|
-
const channelOptions: OriginChannelOptions = {
|
|
715
|
-
...options,
|
|
716
|
-
};
|
|
717
|
-
if (channelOptions.continuation !== undefined) {
|
|
718
|
-
channelOptions.continuation = normalizeIdentity(channelOptions.continuation, "origin");
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
const events: ChannelEventHandlers<OriginChannelState> = {
|
|
722
|
-
...buildDefaultOriginEvents({
|
|
723
|
-
cursorAccount: channelOptions.cursorAccount,
|
|
724
|
-
app: channelOptions.app,
|
|
725
|
-
deliverReplies: channelOptions.deliverReplies,
|
|
726
|
-
}),
|
|
727
|
-
...options.events,
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
const definition = defineChannel({
|
|
731
|
-
auth,
|
|
732
|
-
state: emptyOriginChannelState(),
|
|
733
|
-
events,
|
|
734
|
-
onStart: options.onStart,
|
|
735
|
-
onStop: options.onStop,
|
|
736
|
-
meta: {
|
|
737
|
-
kind: ORIGIN_CHANNEL_KIND,
|
|
738
|
-
originWebhookEvents: deriveOriginWebhookEvents(channelOptions),
|
|
739
|
-
},
|
|
740
|
-
routes: [
|
|
741
|
-
POST(routePath, {
|
|
742
|
-
bodySchema: z.unknown(),
|
|
743
|
-
description: "Origin webhook ingress",
|
|
744
|
-
handler: async (request, args) =>
|
|
745
|
-
handleOriginWebhookRequest({
|
|
746
|
-
options: channelOptions,
|
|
747
|
-
request,
|
|
748
|
-
args,
|
|
749
|
-
}),
|
|
750
|
-
}),
|
|
751
|
-
],
|
|
752
|
-
});
|
|
753
|
-
originChannelOptionsByDefinition.set(definition, channelOptions);
|
|
754
|
-
attachHostedAdmissionAdapter(definition, {
|
|
755
|
-
kind: ORIGIN_CHANNEL_KIND,
|
|
756
|
-
prepareArgs: withPropagatingBackgroundErrors,
|
|
757
|
-
dispatch: async ({ payload, args }) => {
|
|
758
|
-
const envelope = parseOriginWebhookEnvelope(payload);
|
|
759
|
-
if (envelope === null) {
|
|
760
|
-
return Response.json({ ok: false, error: "invalid_origin_payload" }, { status: 400 });
|
|
761
|
-
}
|
|
762
|
-
return dispatchOriginWebhook({
|
|
763
|
-
options: channelOptions,
|
|
764
|
-
envelope,
|
|
765
|
-
args,
|
|
766
|
-
});
|
|
767
|
-
},
|
|
768
|
-
});
|
|
769
|
-
if (usesCursorAccount) {
|
|
770
|
-
registerOriginCursorAccountRuntime(definition, {
|
|
771
|
-
options: channelOptions,
|
|
772
|
-
scope: cursorScope,
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
return definition;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/** Minimal mount shape shared by `serve` / trigger fan-out. */
|
|
779
|
-
export interface OriginAgentMountLike {
|
|
780
|
-
slug: string;
|
|
781
|
-
project: {
|
|
782
|
-
channels: Array<{
|
|
783
|
-
id: string;
|
|
784
|
-
definition: {
|
|
785
|
-
meta?: { kind?: string; originWebhookEvents?: readonly string[] };
|
|
786
|
-
};
|
|
787
|
-
}>;
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
export interface OriginChannelTarget {
|
|
792
|
-
slug: string;
|
|
793
|
-
channelId: string;
|
|
794
|
-
events: string[];
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
export function findOriginChannelTargets(
|
|
798
|
-
mounts: ReadonlyArray<OriginAgentMountLike>,
|
|
799
|
-
): OriginChannelTarget[] {
|
|
800
|
-
const targets: OriginChannelTarget[] = [];
|
|
801
|
-
for (const { slug, project } of mounts) {
|
|
802
|
-
for (const channel of project.channels) {
|
|
803
|
-
const meta = channel.definition.meta;
|
|
804
|
-
if (meta?.kind !== ORIGIN_CHANNEL_KIND) {
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
targets.push({
|
|
808
|
-
slug,
|
|
809
|
-
channelId: channel.id,
|
|
810
|
-
events: [...(meta.originWebhookEvents ?? [])],
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
return targets;
|
|
815
|
-
}
|