@grok/agent-sdk 0.5.0 → 0.7.0
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 +40 -0
- package/dist/channels/github/forward.d.ts +5 -0
- package/dist/channels/github/forward.d.ts.map +1 -1
- package/dist/channels/github/forward.js +6 -3
- package/dist/channels/slack/api.d.ts +18 -0
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +31 -0
- package/dist/channels/slack/approvals.d.ts +19 -2
- package/dist/channels/slack/approvals.d.ts.map +1 -1
- package/dist/channels/slack/approvals.js +90 -19
- package/dist/channels/slack/attachments.d.ts +7 -2
- package/dist/channels/slack/attachments.d.ts.map +1 -1
- package/dist/channels/slack/attachments.js +318 -156
- package/dist/channels/slack/connect-card.d.ts +16 -0
- package/dist/channels/slack/connect-card.d.ts.map +1 -0
- package/dist/channels/slack/connect-card.js +31 -0
- package/dist/channels/slack/credentials.d.ts +10 -2
- package/dist/channels/slack/credentials.d.ts.map +1 -1
- package/dist/channels/slack/credentials.js +17 -15
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +18 -9
- package/dist/channels/slack/dispatch.d.ts +1 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +19 -3
- package/dist/channels/slack/inbound.d.ts +8 -2
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +25 -4
- package/dist/channels/slack/index.d.ts +3 -2
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +3 -2
- package/dist/channels/slack/init.d.ts.map +1 -1
- package/dist/channels/slack/init.js +2 -1
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +2 -15
- package/dist/channels/slack/mentions.d.ts +28 -0
- package/dist/channels/slack/mentions.d.ts.map +1 -0
- package/dist/channels/slack/mentions.js +178 -0
- package/dist/channels/slack/setup.js +1 -1
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +46 -3
- package/dist/channels/slack/stop.d.ts.map +1 -1
- package/dist/channels/slack/stop.js +7 -1
- package/dist/channels/slack/thread-context.d.ts +3 -0
- package/dist/channels/slack/thread-context.d.ts.map +1 -1
- package/dist/channels/slack/thread-context.js +17 -7
- package/dist/channels/slack/tool-approval-events.d.ts.map +1 -1
- package/dist/channels/slack/tool-approval-events.js +55 -2
- package/dist/channels/slack/types.d.ts +2 -0
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels/teams/activity.d.ts +33 -0
- package/dist/channels/teams/activity.d.ts.map +1 -0
- package/dist/channels/teams/activity.js +213 -0
- package/dist/channels/teams/auth.d.ts +25 -0
- package/dist/channels/teams/auth.d.ts.map +1 -0
- package/dist/channels/teams/auth.js +55 -0
- package/dist/channels/teams/bot-framework-auth.d.ts +33 -0
- package/dist/channels/teams/bot-framework-auth.d.ts.map +1 -0
- package/dist/channels/teams/bot-framework-auth.js +154 -0
- package/dist/channels/teams/cards.d.ts +23 -0
- package/dist/channels/teams/cards.d.ts.map +1 -0
- package/dist/channels/teams/cards.js +107 -0
- package/dist/channels/teams/connector.d.ts +48 -0
- package/dist/channels/teams/connector.d.ts.map +1 -0
- package/dist/channels/teams/connector.js +159 -0
- package/dist/channels/teams/credentials.d.ts +65 -0
- package/dist/channels/teams/credentials.d.ts.map +1 -0
- package/dist/channels/teams/credentials.js +84 -0
- package/dist/channels/teams/delivery.d.ts +14 -0
- package/dist/channels/teams/delivery.d.ts.map +1 -0
- package/dist/channels/teams/delivery.js +169 -0
- package/dist/channels/teams/dispatch.d.ts +45 -0
- package/dist/channels/teams/dispatch.d.ts.map +1 -0
- package/dist/channels/teams/dispatch.js +402 -0
- package/dist/channels/teams/engagement.d.ts +32 -0
- package/dist/channels/teams/engagement.d.ts.map +1 -0
- package/dist/channels/teams/engagement.js +120 -0
- package/dist/channels/teams/index.d.ts +21 -0
- package/dist/channels/teams/index.d.ts.map +1 -0
- package/dist/channels/teams/index.js +19 -0
- package/dist/channels/teams/marks.d.ts +19 -0
- package/dist/channels/teams/marks.d.ts.map +1 -0
- package/dist/channels/teams/marks.js +96 -0
- package/dist/channels/teams/senders.d.ts +27 -0
- package/dist/channels/teams/senders.d.ts.map +1 -0
- package/dist/channels/teams/senders.js +72 -0
- package/dist/channels/teams/teams-channel.d.ts +43 -0
- package/dist/channels/teams/teams-channel.d.ts.map +1 -0
- package/dist/channels/teams/teams-channel.js +278 -0
- package/dist/channels/teams/text.d.ts +7 -0
- package/dist/channels/teams/text.d.ts.map +1 -0
- package/dist/channels/teams/text.js +63 -0
- package/dist/channels/teams/types.d.ts +306 -0
- package/dist/channels/teams/types.d.ts.map +1 -0
- package/dist/channels/teams/types.js +1 -0
- package/dist/channels.d.ts +31 -0
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +37 -0
- package/dist/connections.d.ts +1 -1
- package/dist/connections.d.ts.map +1 -1
- package/dist/docs/404.html +3 -3
- package/dist/docs/assets/{app.CYdjweqP.js → app.Ch-048af.js} +4 -4
- package/dist/docs/assets/changelog.md.SoN0MK7o.js +1 -0
- package/dist/docs/assets/{changelog.md.BMrJ5WxW.lean.js → changelog.md.SoN0MK7o.lean.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BdYoBKxY.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.CRATKS9J.js → VPLocalSearchBox.D7BIa9Su.js} +2 -2
- package/dist/docs/assets/chunks/{arc.BxM78ISR.js → arc.BIzu7OVF.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.Bi6MuKaU.js → architectureDiagram-Q4EWVU46.DNznI0Sn.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.L47qqpDG.js → baseUniq.B4y6Y5eG.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.kHFF2FK5.js → blockDiagram-DXYQGD6D.BudnBsgw.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.BTW85ll3.js → c4Diagram-AHTNJAMY._bB00GdB.js} +1 -1
- package/dist/docs/assets/chunks/channel.CgxlmuBS.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.Bbh3_48g.js → chunk-4BX2VUAB.CRftnUwS.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.WeAmK3fK.js → chunk-4TB4RGXK.CSx1x2Ob.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.DTdUiVHf.js → chunk-55IACEB6.KkLHAAbH.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.n5XzANDz.js → chunk-EDXVE4YY.DDeKCCtX.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.D51eewCb.js → chunk-FMBD7UC4.DrLlsD9m.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.BrY0U7ZV.js → chunk-OYMX7WX6.DeVYOGcT.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.B0OA4aFV.js → chunk-QZHKN3VN.Cz4_bS6p.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.Djt3Mjft.js → chunk-YZCP3GAM.CwrYtDVo.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.DWroREP-.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.DWroREP-.js +1 -0
- package/dist/docs/assets/chunks/clone.F824-PNx.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.DiMcA6Q8.js → cose-bilkent-S5V4N54A.3d8hflz6.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.BGqI4vrS.js → dagre-KV5264BT.BVEgjiPg.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.bDqFuMoH.js → diagram-5BDNPKRD.j7dZpUK_.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Y0sxaXRU.js → diagram-G4DWMVQ6.4flIgIon.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.Bg43b0yi.js → diagram-MMDJMWI5.BlJiFh-S.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.DCfVasEC.js → diagram-TYMM5635.DHAOHEyM.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.C72GaD16.js → erDiagram-SMLLAGMA.DkmyG7xK.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.DxRQj7pP.js → flowDiagram-DWJPFMVM.L_WiaAU6.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DiLZy5Q4.js → ganttDiagram-T4ZO3ILL.CT6kOI2a.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.DL8XkRvh.js → gitGraphDiagram-UUTBAWPF.D8CRlLqh.js} +1 -1
- package/dist/docs/assets/chunks/{graph.3Xub80xJ.js → graph.CdOyJvsX.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.O3lGaspu.js → infoDiagram-42DDH7IO.DcmXeSos.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.w-pCiQzn.js → ishikawaDiagram-UXIWVN3A.BBjY4mxr.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.Cg_oBs9j.js → journeyDiagram-VCZTEJTY.BrXteAB6.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.BpfMGPwn.js → kanban-definition-6JOO6SKY.OlHsUJVV.js} +1 -1
- package/dist/docs/assets/chunks/{layout.CtwXs__p.js → layout.DDwvoQlY.js} +1 -1
- package/dist/docs/assets/chunks/{linear.NmCskOrP.js → linear.BRXPDWj3.js} +1 -1
- package/dist/docs/assets/chunks/{min.DpQtsLKs.js → min.3YwC0t3o.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.B-P-aKVp.js → mindmap-definition-QFDTVHPH.mPHnT2lN.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BfjjqK7j.js → pieDiagram-DEJITSTG.DEK2--em.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.BTzHo53F.js → quadrantDiagram-34T5L4WZ.NCdRAOzK.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DIT2FIKr.js → requirementDiagram-MS252O5E.DLAocFWZ.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.NK1wCsgt.js → sankeyDiagram-XADWPNL6.afIOqpyT.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.D9oElkvo.js → sequenceDiagram-FGHM5R23.DXBjvkkE.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.IPksnixH.js → stateDiagram-FHFEXIEX.B_SGgvgs.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.OKAy5Bz7.js +1 -0
- package/dist/docs/assets/chunks/{theme.CgKu7tr3.js → theme.bNyH5NPA.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.CuAtJapY.js → timeline-definition-GMOUNBTQ.CE6S1iSb.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.B87nNW9E.js → vennDiagram-DHZGUBPP.Blk7wb8V.js} +1 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.DQqE3WF8.js +162 -0
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.BELjSq8w.js → wardleyDiagram-NUSXRM2D.MUEQyRnz.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.5zN5ZGsz.js → xychartDiagram-5P7HB3ND.DnJA2aXp.js} +1 -1
- package/dist/docs/assets/{deployment.md.DJtuDVLh.js → deployment.md.N9S5KC5R.js} +2 -2
- package/dist/docs/assets/{deployment.md.DJtuDVLh.lean.js → deployment.md.N9S5KC5R.lean.js} +1 -1
- package/dist/docs/assets/guides_cloud-agents.md.BdWqmUGb.js +14 -0
- package/dist/docs/assets/{guides_cloud-agents.md.CiXAW6on.lean.js → guides_cloud-agents.md.BdWqmUGb.lean.js} +1 -1
- package/dist/docs/assets/guides_teams.md.7Lz2sbqB.js +50 -0
- package/dist/docs/assets/guides_teams.md.7Lz2sbqB.lean.js +1 -0
- package/dist/docs/assets/{reference_channels.md.CPWOpdsC.js → reference_channels.md.CRvqgU0n.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.DHm6DmYk.js → reference_cli.md.NS6U5a-7.js} +14 -4
- package/dist/docs/assets/{reference_cli.md.DHm6DmYk.lean.js → reference_cli.md.NS6U5a-7.lean.js} +1 -1
- package/dist/docs/assets/{reference_limits.md.CbdtFr4T.js → reference_limits.md.CW9PTdxr.js} +3 -3
- package/dist/docs/assets/{reference_limits.md.CbdtFr4T.lean.js → reference_limits.md.CW9PTdxr.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.RhQ9ZLo1.js → reference_schedules.md.Dd8_d0WG.js} +3 -3
- package/dist/docs/assets/{reference_sessions.md.NXVQt9mP.js → reference_sessions.md.CoCyQLEz.js} +2 -2
- package/dist/docs/assets/{reference_sessions.md.NXVQt9mP.lean.js → reference_sessions.md.CoCyQLEz.lean.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.DzCPNPkG.js → reference_skills.md.SFRZDC41.js} +4 -4
- package/dist/docs/assets/{reference_skills.md.DzCPNPkG.lean.js → reference_skills.md.SFRZDC41.lean.js} +1 -1
- package/dist/docs/assets/{style.DK0YX1WL.css → style.B7zPxANR.css} +1 -1
- package/dist/docs/assets/troubleshooting.md.CsQTleto.js +3 -0
- package/dist/docs/assets/{troubleshooting.md.DfKKvW1R.lean.js → troubleshooting.md.CsQTleto.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +37 -37
- package/dist/docs/changelog.html +37 -37
- package/dist/docs/changelog.md +51 -0
- package/dist/docs/deployment.html +39 -39
- package/dist/docs/deployment.md +10 -0
- 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 +43 -38
- package/dist/docs/guides/cloud-agents.md +47 -0
- package/dist/docs/guides/convert-automation.html +37 -37
- package/dist/docs/guides/github.html +37 -37
- package/dist/docs/guides/gitlab.html +37 -37
- package/dist/docs/guides/improve.html +37 -37
- package/dist/docs/guides/jev.html +37 -37
- package/dist/docs/guides/mcp-oauth.html +37 -37
- package/dist/docs/guides/migrate.html +37 -37
- package/dist/docs/guides/opentelemetry.html +37 -37
- package/dist/docs/guides/pagerduty.html +37 -37
- package/dist/docs/guides/slack.html +37 -37
- package/dist/docs/guides/teams.html +109 -0
- package/dist/docs/guides/teams.md +384 -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 +652 -4
- package/dist/docs/llms.txt +1 -0
- package/dist/docs/quickstart.html +37 -37
- package/dist/docs/reference/access.html +36 -36
- package/dist/docs/reference/agent-config.html +37 -37
- package/dist/docs/reference/artifacts.html +37 -37
- package/dist/docs/reference/channels.html +38 -38
- package/dist/docs/reference/channels.md +1 -0
- package/dist/docs/reference/cli.html +50 -40
- package/dist/docs/reference/cli.md +116 -0
- 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 +37 -37
- package/dist/docs/reference/http-api.html +37 -37
- package/dist/docs/reference/instructions.html +37 -37
- package/dist/docs/reference/limits.html +39 -39
- package/dist/docs/reference/limits.md +4 -4
- 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/schedules.html +40 -40
- package/dist/docs/reference/sessions.html +38 -38
- package/dist/docs/reference/sessions.md +13 -0
- package/dist/docs/reference/skills.html +40 -40
- package/dist/docs/reference/subagents.html +37 -37
- package/dist/docs/reference/tools.html +37 -37
- package/dist/docs/templates/agentic-owners.html +37 -37
- package/dist/docs/templates/reviews.html +37 -37
- package/dist/docs/troubleshooting.html +38 -38
- package/dist/docs/troubleshooting.md +21 -0
- package/dist/evals/run-facts.d.ts.map +1 -1
- package/dist/evals/run-facts.js +4 -0
- package/dist/extensions/cursor-cloud-agents/channels/cursor-cloud-agents.d.ts +12 -0
- package/dist/extensions/cursor-cloud-agents/channels/cursor-cloud-agents.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/channels/cursor-cloud-agents.js +42 -0
- package/dist/extensions/cursor-cloud-agents/extension.d.ts +10 -7
- package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/extension.js +3 -2
- package/dist/extensions/cursor-cloud-agents/lib/agent-id.d.ts +5 -0
- package/dist/extensions/cursor-cloud-agents/lib/agent-id.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/lib/agent-id.js +10 -0
- package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts +57 -3
- package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/backend.js +150 -35
- package/dist/extensions/cursor-cloud-agents/lib/fleet.d.ts +32 -4
- package/dist/extensions/cursor-cloud-agents/lib/fleet.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/fleet.js +93 -7
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts +24 -7
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.js +158 -25
- package/dist/extensions/cursor-cloud-agents/lib/stop-signal.d.ts +18 -0
- package/dist/extensions/cursor-cloud-agents/lib/stop-signal.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/lib/stop-signal.js +27 -0
- package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/transcript.js +2 -3
- package/dist/extensions/cursor-cloud-agents/lib/watch.d.ts +26 -12
- package/dist/extensions/cursor-cloud-agents/lib/watch.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/watch.js +115 -46
- package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.d.ts +16 -5
- package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/reminders/cloud-agent-stop-watch.js +76 -20
- package/dist/extensions/cursor-cloud-agents/skills/handoff.md +2 -2
- package/dist/extensions/cursor-cloud-agents/tools/get.js +2 -2
- package/dist/extensions/cursor-cloud-agents/tools/launch.js +1 -1
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +18 -3
- package/dist/files-backends/agent-store-presigned-url.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/approval-gate.d.ts +6 -1
- package/dist/internal/approval-gate.d.ts.map +1 -1
- package/dist/internal/approval-gate.js +13 -2
- package/dist/internal/authored-loaders.js +1 -1
- package/dist/internal/channel-architecture.d.ts.map +1 -1
- package/dist/internal/channel-architecture.js +3 -1
- package/dist/internal/cli/commands/channels.d.ts +9 -3
- package/dist/internal/cli/commands/channels.d.ts.map +1 -1
- package/dist/internal/cli/commands/channels.js +193 -4
- package/dist/internal/cli/commands/index.d.ts.map +1 -1
- package/dist/internal/cli/commands/index.js +6 -1
- package/dist/internal/cli/commands/serve.d.ts.map +1 -1
- package/dist/internal/cli/commands/serve.js +25 -5
- package/dist/internal/cli/dispatch.d.ts.map +1 -1
- package/dist/internal/cli/dispatch.js +22 -8
- package/dist/internal/cli/flags.d.ts +14 -0
- package/dist/internal/cli/flags.d.ts.map +1 -1
- package/dist/internal/cli/flags.js +14 -0
- package/dist/internal/cli/help.d.ts.map +1 -1
- package/dist/internal/cli/help.js +3 -1
- package/dist/internal/cli-cursor.js +2 -2
- package/dist/internal/cli-deploy.d.ts +1 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +31 -8
- package/dist/internal/cli-mcp.d.ts.map +1 -1
- package/dist/internal/cli-mcp.js +5 -3
- package/dist/internal/cli-teams-doctor.d.ts +39 -0
- package/dist/internal/cli-teams-doctor.d.ts.map +1 -0
- package/dist/internal/cli-teams-doctor.js +508 -0
- package/dist/internal/cli-teams-forward.d.ts +84 -0
- package/dist/internal/cli-teams-forward.d.ts.map +1 -0
- package/dist/internal/cli-teams-forward.js +386 -0
- package/dist/internal/cli-teams-package.d.ts +26 -0
- package/dist/internal/cli-teams-package.d.ts.map +1 -0
- package/dist/internal/cli-teams-package.js +123 -0
- package/dist/internal/cli-teams.d.ts +15 -0
- package/dist/internal/cli-teams.d.ts.map +1 -0
- package/dist/internal/cli-teams.js +253 -0
- package/dist/internal/connect-click.d.ts +12 -0
- package/dist/internal/connect-click.d.ts.map +1 -0
- package/dist/internal/connect-click.js +22 -0
- package/dist/internal/continuation-channel.d.ts +5 -1
- package/dist/internal/continuation-channel.d.ts.map +1 -1
- package/dist/internal/continuation-channel.js +34 -0
- package/dist/internal/continuation-identity.d.ts +7 -4
- package/dist/internal/continuation-identity.d.ts.map +1 -1
- package/dist/internal/continuation-identity.js +66 -1
- package/dist/internal/convert-automation/convert-workflow.js +2 -2
- package/dist/internal/credential-env-names.d.ts +36 -0
- package/dist/internal/credential-env-names.d.ts.map +1 -0
- package/dist/internal/credential-env-names.js +68 -0
- package/dist/internal/cursor/account-mcp.d.ts +67 -9
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +206 -25
- package/dist/internal/cursor/backend-client.d.ts +10 -1
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +19 -7
- package/dist/internal/cursor/cloud-agent-identity.d.ts +81 -0
- package/dist/internal/cursor/cloud-agent-identity.d.ts.map +1 -0
- package/dist/internal/cursor/cloud-agent-identity.js +224 -0
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +3 -1
- package/dist/internal/cursor-account-mcp-auth.d.ts +1 -0
- package/dist/internal/cursor-account-mcp-auth.d.ts.map +1 -1
- package/dist/internal/cursor-account-mcp-auth.js +2 -1
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +34 -2
- package/dist/internal/deploy-manifest.d.ts +51 -3
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +96 -7
- package/dist/internal/discovery/agent-config.d.ts.map +1 -1
- package/dist/internal/discovery/agent-config.js +6 -1
- package/dist/internal/discovery/connections.d.ts.map +1 -1
- package/dist/internal/discovery/connections.js +53 -0
- package/dist/internal/discovery/extensions.d.ts.map +1 -1
- package/dist/internal/discovery/extensions.js +2 -0
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +4 -0
- package/dist/internal/env-file.d.ts +1 -0
- package/dist/internal/env-file.d.ts.map +1 -1
- package/dist/internal/env-file.js +18 -17
- package/dist/internal/env-prefix.d.ts +11 -0
- package/dist/internal/env-prefix.d.ts.map +1 -0
- package/dist/internal/env-prefix.js +23 -0
- package/dist/internal/event-id-dedupe.d.ts +12 -0
- package/dist/internal/event-id-dedupe.d.ts.map +1 -0
- package/dist/{channels/slack → internal}/event-id-dedupe.js +7 -4
- package/dist/internal/event-mapper.d.ts +7 -2
- package/dist/internal/event-mapper.d.ts.map +1 -1
- package/dist/internal/event-mapper.js +7 -0
- package/dist/internal/expected-delivery-failure.d.ts.map +1 -1
- package/dist/internal/expected-delivery-failure.js +3 -0
- package/dist/internal/extension-namespace.d.ts +9 -0
- package/dist/internal/extension-namespace.d.ts.map +1 -0
- package/dist/internal/extension-namespace.js +14 -0
- package/dist/internal/guid.d.ts +2 -0
- package/dist/internal/guid.d.ts.map +1 -0
- package/dist/internal/guid.js +4 -0
- package/dist/internal/host-kv-cas.d.ts +13 -0
- package/dist/internal/host-kv-cas.d.ts.map +1 -0
- package/dist/internal/host-kv-cas.js +8 -0
- package/dist/internal/host-kv.d.ts +4 -1
- package/dist/internal/host-kv.d.ts.map +1 -1
- package/dist/internal/host-kv.js +15 -2
- package/dist/internal/hosted-catch-protocol.d.ts +5 -0
- package/dist/internal/hosted-catch-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-catch-protocol.js +5 -0
- package/dist/internal/hosted-catch.d.ts +2 -0
- package/dist/internal/hosted-catch.d.ts.map +1 -1
- package/dist/internal/hosted-catch.js +6 -1
- package/dist/internal/hosted-delivery-protocol.d.ts +6 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +71 -1
- package/dist/internal/hosted-delivery.d.ts +5 -2
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +36 -12
- package/dist/internal/hosted-execution-latency.d.ts +3 -0
- package/dist/internal/hosted-execution-latency.d.ts.map +1 -1
- package/dist/internal/hosted-execution-latency.js +11 -0
- package/dist/internal/hosted-session-fixture.js +1 -1
- package/dist/internal/hosting.d.ts +5 -0
- package/dist/internal/hosting.d.ts.map +1 -1
- package/dist/internal/hosting.js +7 -1
- package/dist/internal/install-cursor-skills.d.ts +6 -7
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +15 -9
- 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 +4 -3
- package/dist/internal/local-control-plane.d.ts.map +1 -1
- package/dist/internal/local-control-plane.js +24 -0
- package/dist/internal/mcp-allowlist-in-use.d.ts +23 -0
- package/dist/internal/mcp-allowlist-in-use.d.ts.map +1 -0
- package/dist/internal/mcp-allowlist-in-use.js +93 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +8 -10
- package/dist/internal/mcp-host.d.ts +19 -1
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +67 -3
- package/dist/internal/mcp-oauth.d.ts.map +1 -1
- package/dist/internal/mcp-oauth.js +5 -7
- package/dist/internal/oidcAudiences.d.ts +22 -0
- package/dist/internal/oidcAudiences.d.ts.map +1 -0
- package/dist/internal/oidcAudiences.js +35 -0
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +2 -0
- package/dist/internal/platform-timers.d.ts +2 -0
- package/dist/internal/platform-timers.d.ts.map +1 -1
- package/dist/internal/platform-timers.js +14 -0
- package/dist/internal/private-file.d.ts +32 -1
- package/dist/internal/private-file.d.ts.map +1 -1
- package/dist/internal/private-file.js +209 -7
- package/dist/internal/redact-values.d.ts +3 -0
- package/dist/internal/redact-values.d.ts.map +1 -0
- package/dist/internal/redact-values.js +19 -0
- package/dist/internal/reminder-control-plane-protocol.d.ts +7 -1
- package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -1
- package/dist/internal/reminder-followup-error.d.ts +23 -0
- package/dist/internal/reminder-followup-error.d.ts.map +1 -0
- package/dist/internal/reminder-followup-error.js +12 -0
- package/dist/internal/reminder-runner.d.ts +15 -1
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +95 -21
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +23 -3
- package/dist/internal/run-client.js +2 -1
- package/dist/internal/run-program.d.ts +31 -0
- package/dist/internal/run-program.d.ts.map +1 -0
- package/dist/internal/run-program.js +150 -0
- package/dist/internal/sdk-runner.d.ts +29 -3
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +304 -38
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +53 -8
- package/dist/internal/session-credential.d.ts +14 -0
- package/dist/internal/session-credential.d.ts.map +1 -0
- package/dist/internal/session-credential.js +25 -0
- package/dist/internal/session-engine.d.ts +137 -5
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +606 -92
- package/dist/internal/storage-coordinator.d.ts +3 -1
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +13 -0
- package/dist/internal/storage-roles.d.ts +9 -1
- package/dist/internal/storage-roles.d.ts.map +1 -1
- package/dist/internal/tcp-address.d.ts +3 -1
- package/dist/internal/tcp-address.d.ts.map +1 -1
- package/dist/internal/tcp-address.js +6 -0
- package/dist/internal/teams-channel-profile.d.ts +41 -0
- package/dist/internal/teams-channel-profile.d.ts.map +1 -0
- package/dist/internal/teams-channel-profile.js +91 -0
- package/dist/internal/teams-devtunnel.d.ts +55 -0
- package/dist/internal/teams-devtunnel.d.ts.map +1 -0
- package/dist/internal/teams-devtunnel.js +205 -0
- package/dist/internal/teams-tunnel-proxy.d.ts +17 -0
- package/dist/internal/teams-tunnel-proxy.d.ts.map +1 -0
- package/dist/internal/teams-tunnel-proxy.js +100 -0
- package/dist/internal/testing/conversation-identity-vectors.d.ts +7 -1
- package/dist/internal/testing/conversation-identity-vectors.d.ts.map +1 -1
- package/dist/internal/testing/conversation-identity-vectors.js +67 -0
- package/dist/internal/testing/hosted-http.d.ts +15 -0
- package/dist/internal/testing/hosted-http.d.ts.map +1 -0
- package/dist/internal/testing/hosted-http.js +86 -0
- package/dist/internal/testing/teams-activity-fixtures.d.ts +28 -0
- package/dist/internal/testing/teams-activity-fixtures.d.ts.map +1 -0
- package/dist/internal/testing/teams-activity-fixtures.js +236 -0
- package/dist/internal/testing/teams-doctor-fixtures.d.ts +76 -0
- package/dist/internal/testing/teams-doctor-fixtures.d.ts.map +1 -0
- package/dist/internal/testing/teams-doctor-fixtures.js +216 -0
- package/dist/internal/tunnel-process.d.ts +29 -0
- package/dist/internal/tunnel-process.d.ts.map +1 -0
- package/dist/internal/tunnel-process.js +105 -0
- package/dist/internal/turn-context.d.ts +28 -0
- package/dist/internal/turn-context.d.ts.map +1 -0
- package/dist/internal/turn-context.js +1 -0
- package/dist/oidc-token.d.ts +127 -0
- package/dist/oidc-token.d.ts.map +1 -0
- package/dist/oidc-token.js +221 -0
- package/dist/playground/assets/index-BaBSZXki.css +1 -0
- package/dist/playground/assets/index-BkAF8YlO.js +62 -0
- package/dist/playground/index.html +2 -2
- package/dist/teams-app-package.d.ts +78 -0
- package/dist/teams-app-package.d.ts.map +1 -0
- package/dist/teams-app-package.js +204 -0
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/types.d.ts +278 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/changelog.md +51 -0
- package/docs/deployment.md +10 -0
- package/docs/guides/cloud-agents.md +47 -0
- package/docs/guides/teams.md +389 -0
- package/docs/reference/channels.md +1 -0
- package/docs/reference/cli.md +116 -0
- package/docs/reference/limits.md +4 -4
- package/docs/reference/sessions.md +13 -0
- package/docs/troubleshooting.md +21 -0
- package/package.json +21 -46
- package/skills/create-agent/SKILL.md +17 -4
- package/skills/debug/SKILL.md +1 -0
- package/skills/deploy/SKILL.md +1 -1
- package/skills/framework-map/SKILL.md +1 -0
- package/skills/setup-teams/SKILL.md +141 -0
- package/templates/agentic-owners/bot/lib/owners/parse.ts +1 -0
- package/dist/channels/slack/event-id-dedupe.d.ts +0 -10
- package/dist/channels/slack/event-id-dedupe.d.ts.map +0 -1
- package/dist/docs/assets/changelog.md.BMrJ5WxW.js +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.dUaE1f8e.js +0 -1
- package/dist/docs/assets/chunks/channel.ljJtQtBi.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.BZ3Uc-XU.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.BZ3Uc-XU.js +0 -1
- package/dist/docs/assets/chunks/clone.BDtbEo69.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CbhzVsQE.js +0 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.BFIVMaoi.js +0 -162
- package/dist/docs/assets/guides_cloud-agents.md.CiXAW6on.js +0 -9
- package/dist/docs/assets/troubleshooting.md.DfKKvW1R.js +0 -3
- package/dist/playground/assets/index-D0-FHg1x.css +0 -1
- package/dist/playground/assets/index-D5SLKUy6.js +0 -62
- /package/dist/docs/assets/{reference_channels.md.CPWOpdsC.lean.js → reference_channels.md.CRvqgU0n.lean.js} +0 -0
- /package/dist/docs/assets/{reference_schedules.md.RhQ9ZLo1.lean.js → reference_schedules.md.Dd8_d0WG.lean.js} +0 -0
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* settings; cloud agents use Cursor cloud (`bc-…` ids) with optional
|
|
6
6
|
* `cloud` options from `defineAgent`.
|
|
7
7
|
*/
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
8
9
|
import { mkdir } from "node:fs/promises";
|
|
9
|
-
import { Agent, Cursor, createAgentPlatform, } from "@cursor/sdk";
|
|
10
|
+
import { Agent, ConfigurationError, Cursor, createAgentPlatform, NetworkError, } from "@cursor/sdk";
|
|
10
11
|
import { SqliteLocalAgentStore } from "@cursor/sdk/sqlite";
|
|
11
12
|
import { DEFAULT_MODEL, } from "../types.js";
|
|
12
13
|
import { mapSdkTokenUsage, usageTokenSum } from "./cloud-turn-usage.js";
|
|
@@ -169,6 +170,20 @@ function mcpServersField(servers) {
|
|
|
169
170
|
}
|
|
170
171
|
return { mcpServers: servers };
|
|
171
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* `onMcpAuthRequest` is newer than the pinned SDK's `LocalSendOptions`, so it
|
|
175
|
+
* is added after the type check. An SDK without it ignores the key.
|
|
176
|
+
*/
|
|
177
|
+
function withMcpAuthRequest(local, onMcpAuthRequest) {
|
|
178
|
+
if (onMcpAuthRequest === undefined) {
|
|
179
|
+
return local;
|
|
180
|
+
}
|
|
181
|
+
const withHook = {
|
|
182
|
+
...local,
|
|
183
|
+
onMcpAuthRequest,
|
|
184
|
+
};
|
|
185
|
+
return withHook;
|
|
186
|
+
}
|
|
172
187
|
function errorCodeOf(error) {
|
|
173
188
|
if (!isRecord(error) || typeof error.code !== "string") {
|
|
174
189
|
return undefined;
|
|
@@ -213,6 +228,11 @@ function modelAttemptRequest(request, model, attempt) {
|
|
|
213
228
|
sdkAgentId: persistedId,
|
|
214
229
|
};
|
|
215
230
|
}
|
|
231
|
+
// Typed apart from `LocalAgentOptions` so the option compiles against an SDK
|
|
232
|
+
// release that predates it, which ignores the field.
|
|
233
|
+
function hostMcpBridgeOption(urls) {
|
|
234
|
+
return urls === undefined ? {} : { hostMcpBridgeUrls: [...urls] };
|
|
235
|
+
}
|
|
216
236
|
export class CursorSdkRunner {
|
|
217
237
|
constructor(options = {}) {
|
|
218
238
|
this.options = options;
|
|
@@ -274,6 +294,7 @@ export class CursorSdkRunner {
|
|
|
274
294
|
async runTurnWithTransportRetry(request, onStreamed) {
|
|
275
295
|
let sawUpdate = false;
|
|
276
296
|
let mintedSdkAgentId;
|
|
297
|
+
let startedCloudRunId;
|
|
277
298
|
const tracked = {
|
|
278
299
|
...request,
|
|
279
300
|
onUpdate: (update) => {
|
|
@@ -287,8 +308,26 @@ export class CursorSdkRunner {
|
|
|
287
308
|
mintedSdkAgentId = sdkAgentId;
|
|
288
309
|
await request.onSdkAgentId?.(sdkAgentId);
|
|
289
310
|
},
|
|
311
|
+
onCloudRunStarted: async (run) => {
|
|
312
|
+
startedCloudRunId = run.runId;
|
|
313
|
+
await request.onCloudRunStarted?.(run);
|
|
314
|
+
},
|
|
290
315
|
};
|
|
291
|
-
|
|
316
|
+
// A retry continues from the adopted agent and its run, not from the
|
|
317
|
+
// create that found them.
|
|
318
|
+
let attempted = tracked;
|
|
319
|
+
let outcome;
|
|
320
|
+
try {
|
|
321
|
+
outcome = await this.runTurnAttempt(tracked);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
const adopted = await this.adoptDeliveryCloudAgent(tracked, error);
|
|
325
|
+
if (adopted === undefined) {
|
|
326
|
+
throw error;
|
|
327
|
+
}
|
|
328
|
+
attempted = adopted;
|
|
329
|
+
outcome = await this.runTurnAttempt(adopted);
|
|
330
|
+
}
|
|
292
331
|
if (outcome.status !== "error" || sawUpdate || request.signal?.aborted === true) {
|
|
293
332
|
return outcome;
|
|
294
333
|
}
|
|
@@ -301,9 +340,14 @@ export class CursorSdkRunner {
|
|
|
301
340
|
this.log(`[bdk] session ${request.sessionId}: ${reason}: ${outcome.errorMessage}; retrying the turn`);
|
|
302
341
|
// The failed attempt already minted this cloud agent; resuming it is what
|
|
303
342
|
// keeps one trigger from leaving two `bc-…` agents behind.
|
|
304
|
-
const
|
|
305
|
-
? { ...
|
|
306
|
-
:
|
|
343
|
+
const resumed = mintedSdkAgentId !== undefined && isServerMintedCloudAgentId(mintedSdkAgentId)
|
|
344
|
+
? { ...attempted, sdkAgentId: mintedSdkAgentId }
|
|
345
|
+
: attempted;
|
|
346
|
+
// A reattached turn that sent again has a newer run of its own; waiting on
|
|
347
|
+
// the older one again would see it ended and send a third time.
|
|
348
|
+
const retried = attempted.reattachCloudRunId === undefined || startedCloudRunId === undefined
|
|
349
|
+
? resumed
|
|
350
|
+
: { ...resumed, reattachCloudRunId: startedCloudRunId };
|
|
307
351
|
try {
|
|
308
352
|
return await this.runTurnAttempt(retried);
|
|
309
353
|
}
|
|
@@ -344,34 +388,45 @@ export class CursorSdkRunner {
|
|
|
344
388
|
: request.prompt;
|
|
345
389
|
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- ConnectionTransport is the engine's view of the SDK mcpServers map
|
|
346
390
|
const sendMcpServers = request.mcpServers;
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
391
|
+
const reattachRunId = request.runtime === "cloud" ? request.reattachCloudRunId : undefined;
|
|
392
|
+
if (reattachRunId !== undefined) {
|
|
393
|
+
this.log(`[bdk] session ${request.sessionId}: waiting on cloud run ${reattachRunId} of ${agent.agentId}, which this delivery already started`);
|
|
394
|
+
}
|
|
395
|
+
const run = reattachRunId !== undefined
|
|
396
|
+
? await Agent.getRun(reattachRunId, {
|
|
397
|
+
runtime: "cloud",
|
|
398
|
+
agentId: agent.agentId,
|
|
399
|
+
apiKey: this.requireApiKey(),
|
|
400
|
+
})
|
|
401
|
+
: await agent.send(sendMessage, {
|
|
402
|
+
onDelta: async ({ update }) => {
|
|
403
|
+
try {
|
|
404
|
+
await request.onUpdate(update);
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
// Stream mapping must never reject into the SDK transport.
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
// The SDK builds this send's MCP session from exactly this set, so
|
|
411
|
+
// a turn always runs on the headers the engine evaluated for it —
|
|
412
|
+
// never on the ones a previous turn opened the cached handle with.
|
|
413
|
+
...mcpServersField(request.runtime === "local" && request.perSendMcpServers === true
|
|
414
|
+
? sendMcpServers
|
|
415
|
+
: undefined),
|
|
416
|
+
local: request.runtime === "local"
|
|
417
|
+
? withMcpAuthRequest({
|
|
418
|
+
customTools: request.customTools,
|
|
419
|
+
// The session's tree for this turn; a cached agent handle
|
|
420
|
+
// still carries the tree it was opened with.
|
|
421
|
+
fs: request.fs,
|
|
422
|
+
// Follow-up turns expire any run still marked active on the
|
|
423
|
+
// agent (a preempted or crash-wedged run) so this send is not
|
|
424
|
+
// rejected with "already has active run".
|
|
425
|
+
...(request.forceExpireActiveRun === true ? { force: true } : {}),
|
|
426
|
+
}, request.onMcpAuthRequest)
|
|
427
|
+
: undefined,
|
|
428
|
+
});
|
|
429
|
+
const replay = reattachRunId === undefined ? undefined : collectCloudRunUpdates(run);
|
|
375
430
|
// A follow-up can preempt this turn: cancelling tears down execution and
|
|
376
431
|
// marks the SDK run terminal so the next send is admitted cleanly. The
|
|
377
432
|
// signal may already be aborted if the preempt landed while send() was
|
|
@@ -394,6 +449,12 @@ export class CursorSdkRunner {
|
|
|
394
449
|
if (request.onSdkAgentId !== undefined) {
|
|
395
450
|
await request.onSdkAgentId(agent.agentId);
|
|
396
451
|
}
|
|
452
|
+
if (request.runtime === "cloud" &&
|
|
453
|
+
reattachRunId === undefined &&
|
|
454
|
+
run.id !== "" &&
|
|
455
|
+
request.onCloudRunStarted !== undefined) {
|
|
456
|
+
await request.onCloudRunStarted({ sdkAgentId: agent.agentId, runId: run.id });
|
|
457
|
+
}
|
|
397
458
|
// Readable on the handle as soon as send resolves, long before wait().
|
|
398
459
|
if (request.onRequestId !== undefined &&
|
|
399
460
|
run.requestId !== undefined &&
|
|
@@ -402,8 +463,36 @@ export class CursorSdkRunner {
|
|
|
402
463
|
}
|
|
403
464
|
this.activeRuns.set(request.sessionId, run);
|
|
404
465
|
try {
|
|
405
|
-
|
|
466
|
+
let result = await run.wait();
|
|
467
|
+
const replayed = (await replay) ?? [];
|
|
406
468
|
let outcome = toTurnOutcome(result);
|
|
469
|
+
const aborted = () => signal?.aborted === true;
|
|
470
|
+
if (reattachRunId !== undefined && outcome.status !== "finished" && !aborted()) {
|
|
471
|
+
// A `wait()` error can come from the client (an expired stream, an
|
|
472
|
+
// auth failure) while the run goes on, so only the backend's status
|
|
473
|
+
// decides between the run's result and a second send.
|
|
474
|
+
const settled = await this.fetchCloudRun(agent.agentId, reattachRunId);
|
|
475
|
+
const next = decideNext(settled?.status);
|
|
476
|
+
if (next === "done" && settled !== undefined && settled.status !== "running") {
|
|
477
|
+
result = {
|
|
478
|
+
id: settled.id,
|
|
479
|
+
status: settled.status,
|
|
480
|
+
result: settled.result,
|
|
481
|
+
usage: settled.usage,
|
|
482
|
+
};
|
|
483
|
+
outcome = toTurnOutcome(result);
|
|
484
|
+
}
|
|
485
|
+
else if (next === "resend" && !aborted()) {
|
|
486
|
+
this.log(`[bdk] session ${request.sessionId}: cloud run ${reattachRunId} ended in error; sending the turn again`);
|
|
487
|
+
return await this.runTurnOnAgent({ ...request, reattachCloudRunId: undefined }, agentPromise);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
// Only a finished result keeps the replayed events. On a failed wait
|
|
491
|
+
// they would mark the turn as streamed, which stops the transport
|
|
492
|
+
// retry from waiting on the same run, and a later retry replays them.
|
|
493
|
+
if (outcome.status === "finished") {
|
|
494
|
+
await deliverUpdates(replayed, request.onUpdate);
|
|
495
|
+
}
|
|
407
496
|
if (outcome.status === "error") {
|
|
408
497
|
// An error result usually means the handle's transport is poisoned
|
|
409
498
|
// — most often a cached access token that aged past its 60-minute
|
|
@@ -451,17 +540,72 @@ export class CursorSdkRunner {
|
|
|
451
540
|
throw error;
|
|
452
541
|
}
|
|
453
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* The turn that continues on the cloud agent an earlier attempt at this
|
|
545
|
+
* delivery created, when creating it again was refused because its id is
|
|
546
|
+
* taken. Undefined for any other failure, or when the agent has no run.
|
|
547
|
+
*/
|
|
548
|
+
async adoptDeliveryCloudAgent(request, error) {
|
|
549
|
+
const agentId = deliveryCloudAgentId(request);
|
|
550
|
+
if (agentId === undefined || !isAgentIdConflictError(error)) {
|
|
551
|
+
return undefined;
|
|
552
|
+
}
|
|
553
|
+
let runs;
|
|
554
|
+
try {
|
|
555
|
+
runs = await Agent.listRuns(agentId, {
|
|
556
|
+
runtime: "cloud",
|
|
557
|
+
apiKey: this.requireApiKey(),
|
|
558
|
+
limit: 1,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (lookupError) {
|
|
562
|
+
this.log(`[bdk] session ${request.sessionId}: cloud agent ${agentId} already exists for this delivery (${describeError(error)}); reading its runs failed`);
|
|
563
|
+
throw lookupError;
|
|
564
|
+
}
|
|
565
|
+
const latest = runs.items[0];
|
|
566
|
+
if (latest === undefined) {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
this.log(`[bdk] session ${request.sessionId}: cloud agent ${agentId} already exists for this delivery; its run ${latest.id} is ${latest.status}`);
|
|
570
|
+
if (decideNext(latest.status) === "resend") {
|
|
571
|
+
return { ...request, sdkAgentId: agentId, reattachCloudRunId: undefined };
|
|
572
|
+
}
|
|
573
|
+
// Recorded like a run this attempt started, so a later attempt waits on
|
|
574
|
+
// it instead of sending. A finished or cancelled run is reattached too:
|
|
575
|
+
// waiting on it returns how it ended and replays its events.
|
|
576
|
+
await request.onCloudRunStarted?.({ sdkAgentId: agentId, runId: latest.id });
|
|
577
|
+
return { ...request, sdkAgentId: agentId, reattachCloudRunId: latest.id };
|
|
578
|
+
}
|
|
579
|
+
/** The cloud run as the backend reports it now, or undefined when the lookup fails. */
|
|
580
|
+
async fetchCloudRun(agentId, runId) {
|
|
581
|
+
try {
|
|
582
|
+
return await Agent.getRun(runId, {
|
|
583
|
+
runtime: "cloud",
|
|
584
|
+
agentId,
|
|
585
|
+
apiKey: this.requireApiKey(),
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
catch {
|
|
589
|
+
return undefined;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
454
592
|
async steer(request) {
|
|
455
593
|
const run = this.activeRuns.get(request.sessionId);
|
|
456
594
|
if (run?.steer === undefined) {
|
|
457
595
|
return "revert_to_followup";
|
|
458
596
|
}
|
|
459
597
|
try {
|
|
460
|
-
|
|
598
|
+
const outcome = await run.steer(request.text);
|
|
599
|
+
return typeof outcome === "string" ? outcome : "complete_delivered";
|
|
461
600
|
}
|
|
462
601
|
catch (error) {
|
|
463
602
|
this.log(`[bdk] session ${request.sessionId}: steer failed: ${describeError(error)}`);
|
|
464
|
-
|
|
603
|
+
// The SDK marks a network error or 5xx on the steer request itself not retryable, since the
|
|
604
|
+
// server may have taken the message; resending could deliver it twice. Every other failure,
|
|
605
|
+
// including one before the request was sent, means the turn never got it.
|
|
606
|
+
return error instanceof NetworkError && !error.isRetryable
|
|
607
|
+
? "complete_delivered"
|
|
608
|
+
: "revert_to_followup";
|
|
465
609
|
}
|
|
466
610
|
}
|
|
467
611
|
/**
|
|
@@ -635,6 +779,7 @@ export class CursorSdkRunner {
|
|
|
635
779
|
// `fs` again, so it rides create and resume alike.
|
|
636
780
|
fs: request.fs,
|
|
637
781
|
reportedWorkspacePath: request.reportedWorkspacePath,
|
|
782
|
+
...hostMcpBridgeOption(request.hostMcpBridgeUrls),
|
|
638
783
|
},
|
|
639
784
|
};
|
|
640
785
|
}
|
|
@@ -769,6 +914,7 @@ export class CursorSdkRunner {
|
|
|
769
914
|
...shared,
|
|
770
915
|
cloud,
|
|
771
916
|
};
|
|
917
|
+
const deliveryAgentId = deliveryCloudAgentId(request);
|
|
772
918
|
const sdkAgentId = request.sdkAgentId?.trim();
|
|
773
919
|
if (sdkAgentId !== undefined && sdkAgentId !== "") {
|
|
774
920
|
// A server-minted `bc-…` id always resumes — including on the first
|
|
@@ -786,7 +932,7 @@ export class CursorSdkRunner {
|
|
|
786
932
|
}
|
|
787
933
|
}
|
|
788
934
|
if (request.isFirstTurn) {
|
|
789
|
-
return Agent.create(options);
|
|
935
|
+
return Agent.create({ ...options, agentId: deliveryAgentId });
|
|
790
936
|
}
|
|
791
937
|
// A cloud session past its first turn should carry the bound agent id
|
|
792
938
|
// (the engine persists it via onSdkAgentId as soon as create() reports
|
|
@@ -796,7 +942,7 @@ export class CursorSdkRunner {
|
|
|
796
942
|
// host-replacement path above: a fresh conversation beats failing this
|
|
797
943
|
// thread forever, and the new id binds to the session for later resumes.
|
|
798
944
|
this.log(`[bdk] cloud session ${request.sessionId} has no bound cloud agent; creating a fresh one`);
|
|
799
|
-
return Agent.create(options);
|
|
945
|
+
return Agent.create({ ...options, agentId: deliveryAgentId });
|
|
800
946
|
}
|
|
801
947
|
resolveStore(request) {
|
|
802
948
|
return this.options.store !== undefined
|
|
@@ -835,6 +981,60 @@ export class CursorSdkRunner {
|
|
|
835
981
|
return storePromise;
|
|
836
982
|
}
|
|
837
983
|
}
|
|
984
|
+
/**
|
|
985
|
+
* What a retried delivery does with the cloud run an earlier attempt started,
|
|
986
|
+
* given the run's status on the backend: wait on it again, send the turn
|
|
987
|
+
* again, or take how it ended. Only a run that failed is sent again; a
|
|
988
|
+
* cancelled run stays cancelled. An unknown status, including a failed lookup,
|
|
989
|
+
* waits again rather than risk running the turn twice.
|
|
990
|
+
*/
|
|
991
|
+
export function decideNext(status) {
|
|
992
|
+
if (status === "error") {
|
|
993
|
+
return "resend";
|
|
994
|
+
}
|
|
995
|
+
if (status === "finished" || status === "cancelled") {
|
|
996
|
+
return "done";
|
|
997
|
+
}
|
|
998
|
+
return "reattach";
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* The `bc-<uuid>` cloud agent id for one model attempt at a hosted delivery.
|
|
1002
|
+
* A retry of the attempt gets the same id; a fallback model gets its own
|
|
1003
|
+
* agent, since a run on an agent keeps that agent's model.
|
|
1004
|
+
*/
|
|
1005
|
+
export function cloudAgentIdForDelivery(platformDeliveryId, model) {
|
|
1006
|
+
const hex = createHash("sha256")
|
|
1007
|
+
.update(JSON.stringify([
|
|
1008
|
+
"agent-serve-delivery",
|
|
1009
|
+
platformDeliveryId,
|
|
1010
|
+
toModelSelection(model ?? DEFAULT_MODEL),
|
|
1011
|
+
]))
|
|
1012
|
+
.digest("hex");
|
|
1013
|
+
// RFC 9562 version 8 (custom) and variant bits.
|
|
1014
|
+
const variant = ((Number.parseInt(hex.charAt(16), 16) & 0x3) | 0x8).toString(16);
|
|
1015
|
+
return `bc-${hex.slice(0, 8)}-${hex.slice(8, 12)}-8${hex.slice(13, 16)}-${variant}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* The id a cloud turn creates its agent under when it answers a hosted
|
|
1019
|
+
* delivery: every attempt on one model names the same agent, so a retry that
|
|
1020
|
+
* finds it taken continues on it. Undefined when the turn already names an
|
|
1021
|
+
* agent, or sets envVars, which the API only accepts with an id it mints.
|
|
1022
|
+
*/
|
|
1023
|
+
function deliveryCloudAgentId(request) {
|
|
1024
|
+
const envVars = request.cloud?.envVars;
|
|
1025
|
+
if (request.runtime !== "cloud" ||
|
|
1026
|
+
request.platformDeliveryId === undefined ||
|
|
1027
|
+
(request.sdkAgentId?.trim() ?? "") !== "" ||
|
|
1028
|
+
(envVars !== undefined && Object.keys(envVars).length > 0)) {
|
|
1029
|
+
return undefined;
|
|
1030
|
+
}
|
|
1031
|
+
return cloudAgentIdForDelivery(request.platformDeliveryId, request.model);
|
|
1032
|
+
}
|
|
1033
|
+
function isAgentIdConflictError(error) {
|
|
1034
|
+
return (error instanceof ConfigurationError &&
|
|
1035
|
+
error.status === 409 &&
|
|
1036
|
+
error.code === "agent_id_conflict");
|
|
1037
|
+
}
|
|
838
1038
|
/** Cloud agent ids minted by the server are `bc-…`; those always resume. */
|
|
839
1039
|
export function isServerMintedCloudAgentId(id) {
|
|
840
1040
|
return id.startsWith("bc-");
|
|
@@ -940,6 +1140,72 @@ function toAgentDefinitions(subagents) {
|
|
|
940
1140
|
}
|
|
941
1141
|
return definitions;
|
|
942
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* A reattached cloud run's messages as turn updates, the ones `send`'s
|
|
1145
|
+
* `onDelta` gives a run this host started. A fetched run takes no `onDelta`,
|
|
1146
|
+
* but its stream replays the run's persisted events and then follows it. The
|
|
1147
|
+
* updates are collected rather than delivered, because a run that ends
|
|
1148
|
+
* cancelled or failed is sent again and its events must not join that turn.
|
|
1149
|
+
*/
|
|
1150
|
+
async function collectCloudRunUpdates(run) {
|
|
1151
|
+
const updates = [];
|
|
1152
|
+
try {
|
|
1153
|
+
for await (const message of run.stream()) {
|
|
1154
|
+
updates.push(...cloudRunMessageUpdates(message));
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
catch {
|
|
1158
|
+
// The turn's outcome comes from `wait()`, which reports a failed stream.
|
|
1159
|
+
}
|
|
1160
|
+
return updates;
|
|
1161
|
+
}
|
|
1162
|
+
async function deliverUpdates(updates, onUpdate) {
|
|
1163
|
+
for (const update of updates) {
|
|
1164
|
+
try {
|
|
1165
|
+
await onUpdate(update);
|
|
1166
|
+
}
|
|
1167
|
+
catch {
|
|
1168
|
+
// Stream mapping must never reject into the SDK transport.
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function cloudRunMessageUpdates(message) {
|
|
1173
|
+
switch (message.type) {
|
|
1174
|
+
case "assistant": {
|
|
1175
|
+
const text = message.message.content
|
|
1176
|
+
.filter((block) => block.type === "text")
|
|
1177
|
+
.map((block) => block.text)
|
|
1178
|
+
.join("");
|
|
1179
|
+
return text === "" ? [] : [{ type: "text-delta", text }];
|
|
1180
|
+
}
|
|
1181
|
+
case "thinking":
|
|
1182
|
+
if (message.thinking_duration_ms !== undefined && message.text === "") {
|
|
1183
|
+
return [{ type: "thinking-completed", thinkingDurationMs: message.thinking_duration_ms }];
|
|
1184
|
+
}
|
|
1185
|
+
return [{ type: "thinking-delta", text: message.text }];
|
|
1186
|
+
case "tool_call": {
|
|
1187
|
+
if (message.status === "running") {
|
|
1188
|
+
return [];
|
|
1189
|
+
}
|
|
1190
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the stream names a tool by a free string, not a generated ToolCall kind
|
|
1191
|
+
const toolCall = {
|
|
1192
|
+
type: message.name,
|
|
1193
|
+
args: message.args,
|
|
1194
|
+
result: message.result,
|
|
1195
|
+
truncated: message.truncated,
|
|
1196
|
+
};
|
|
1197
|
+
// The engine pairs each result with its start, and the stream carries
|
|
1198
|
+
// only the finished call.
|
|
1199
|
+
const ids = { callId: message.call_id, modelCallId: message.call_id };
|
|
1200
|
+
return [
|
|
1201
|
+
{ type: "tool-call-started", ...ids, toolCall },
|
|
1202
|
+
{ type: "tool-call-completed", ...ids, toolCall },
|
|
1203
|
+
];
|
|
1204
|
+
}
|
|
1205
|
+
default:
|
|
1206
|
+
return [];
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
943
1209
|
function toTurnOutcome(result) {
|
|
944
1210
|
const usage = result.usage === undefined
|
|
945
1211
|
? undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AA6CpF,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAUhB,YAAY,EACb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AA6CpF,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAUhB,YAAY,EACb,MAAM,aAAa,CAAC;AAoGrB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AA+CpE,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAUpE,OAAO,EAEL,wBAAwB,EAEzB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAsB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAW/E;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAuCD,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,yEAAyE;IACzE,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;IAC5D,wEAAwE;IACxE,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IACvD;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2FAA2F;IAC3F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,YAAY,GAAG,0BAA+B,GACtD,OAAO,CAAC,gBAAgB,CAAC,CA0oC3B;AA8oDD,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,cAAc,EACnB,MAAM,SAAQ,GACb,OAAO,CAAC,IAAI,CAAC,CAkDf"}
|
package/dist/internal/server.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
8
8
|
import { once } from "node:events";
|
|
9
9
|
import { createServer } from "node:http";
|
|
10
|
-
import { tcpAddress } from "./tcp-address.js";
|
|
10
|
+
import { serveOrigin, tcpAddress } from "./tcp-address.js";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
import { CURSOR_BITBUCKET_REPOS_HEADER, } from "../channels/bitbucket/api.js";
|
|
13
13
|
import { getBitbucketCursorAccountRuntime, resolveCursorBitbucketProxyUrl, } from "../channels/bitbucket/cursor-account.js";
|
|
@@ -27,7 +27,7 @@ import { ARTIFACTS_PAGE_DEFAULT_LIMIT, ARTIFACTS_PAGE_MAX_LIMIT, InvalidArtifact
|
|
|
27
27
|
import { browserOriginGuardOptionsForPublicUrl, isTrustedBrowserMutation, } from "./browser-origin-guard.js";
|
|
28
28
|
import { invokeChannelRoute } from "./channel-route-dispatch.js";
|
|
29
29
|
import { selectConversationMirror } from "./conversation-mirror.js";
|
|
30
|
-
import { CursorAccountMcpBridge, collectCursorAccountConnections, cursorAccountMcpPath, } from "./cursor/account-mcp.js";
|
|
30
|
+
import { CursorAccountMcpBridge, collectCursorAccountConnections, cursorAccountMcpPath, cursorAccountSignInDiscovery, cursorAccountSignInIssuerPath, cursorAccountSignInPath, } from "./cursor/account-mcp.js";
|
|
31
31
|
import { CursorBackendClient } from "./cursor/backend-client.js";
|
|
32
32
|
import { cursorBackendUrl, cursorExternalApiUrl, resolveApiKey, resolveApiKeySync, SIGN_IN_HINT, } from "./cursor/credentials.js";
|
|
33
33
|
import { CursorGithubCredentialProvider } from "./cursor/github-credentials.js";
|
|
@@ -495,6 +495,24 @@ export async function startServer(mounts, options = {}) {
|
|
|
495
495
|
// Cloud turns reach the bridge through the serve publicUrl; without
|
|
496
496
|
// one, the bridge admits loopback callers only.
|
|
497
497
|
allowRemoteCallers: options.publicUrl !== undefined,
|
|
498
|
+
turnContextFor: (sessionId) => {
|
|
499
|
+
for (const runtime of runtimes) {
|
|
500
|
+
const turn = runtime.engine.turnContextFor(sessionId);
|
|
501
|
+
if (turn !== undefined) {
|
|
502
|
+
return turn;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return undefined;
|
|
506
|
+
},
|
|
507
|
+
turnSessionKeyFor: (sessionId) => {
|
|
508
|
+
for (const runtime of runtimes) {
|
|
509
|
+
const key = runtime.engine.turnSessionKeyFor(sessionId);
|
|
510
|
+
if (key !== undefined) {
|
|
511
|
+
return key;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return undefined;
|
|
515
|
+
},
|
|
498
516
|
});
|
|
499
517
|
}
|
|
500
518
|
for (const { slug, project } of mounts) {
|
|
@@ -529,7 +547,9 @@ export async function startServer(mounts, options = {}) {
|
|
|
529
547
|
// that takes seconds, and a deployment coming online should absorb it
|
|
530
548
|
// rather than whoever sends the first message. No-op unless the agent
|
|
531
549
|
// pins `local.workspaceDir`.
|
|
532
|
-
|
|
550
|
+
if (!accountRefsBySlug.has(slug)) {
|
|
551
|
+
void engine.prewarmSharedWorkspace();
|
|
552
|
+
}
|
|
533
553
|
if (!githubAuthWarmed) {
|
|
534
554
|
// Soft GitHub auth check before channel onStart (which may call
|
|
535
555
|
// host.github). Missing auth is a warning only — serve still starts.
|
|
@@ -597,6 +617,10 @@ export async function startServer(mounts, options = {}) {
|
|
|
597
617
|
cancelForContinuation: (token, reason) => reminderRunner.cancelForContinuation(token, reason),
|
|
598
618
|
rekeyContinuation: (channelId, oldToken, newToken) => reminderRunner.rekeyContinuation(channelId, oldToken, newToken),
|
|
599
619
|
dispatch: (id) => reminderRunner.dispatch(id),
|
|
620
|
+
fireNow: (id) => reminderRunner.fireNow(id),
|
|
621
|
+
createRequest: useReminderCpProtocol
|
|
622
|
+
? (input) => reminderRunner.createRequest(input)
|
|
623
|
+
: undefined,
|
|
600
624
|
});
|
|
601
625
|
engine.setEvals({
|
|
602
626
|
list: () => evalRuns.list(),
|
|
@@ -898,8 +922,7 @@ export async function startServer(mounts, options = {}) {
|
|
|
898
922
|
throw error;
|
|
899
923
|
}
|
|
900
924
|
const address = tcpAddress(server);
|
|
901
|
-
const
|
|
902
|
-
const url = `http://${displayHost}:${boundPort}`;
|
|
925
|
+
const url = serveOrigin(host, boundPort);
|
|
903
926
|
const oauthOrigin = (options.publicUrl ?? url).replace(/\/$/, "");
|
|
904
927
|
// Resolve peer + Cursor account MCP connections now that the listen port is
|
|
905
928
|
// known (see resolved-connections.ts for the URL/runtime rules).
|
|
@@ -923,16 +946,23 @@ export async function startServer(mounts, options = {}) {
|
|
|
923
946
|
if (resolved.length > 0) {
|
|
924
947
|
runtime.engine.setResolvedConnections(resolved);
|
|
925
948
|
}
|
|
949
|
+
if (accountRefs !== undefined) {
|
|
950
|
+
void runtime.engine.prewarmSharedWorkspace();
|
|
951
|
+
}
|
|
926
952
|
const oauthBase = runtime.slug === "" ? "" : `/${runtime.slug}`;
|
|
927
953
|
runtime.engine.setMcpOauthCallbackUrl(mcpOauthServeCallbackUrl(oauthOrigin, oauthBase));
|
|
928
954
|
if (accountBridge !== undefined && accountRefs !== undefined) {
|
|
929
955
|
const bridge = accountBridge;
|
|
930
|
-
runtime.engine.setCursorAccountAuthProbe(async (connection) => {
|
|
956
|
+
runtime.engine.setCursorAccountAuthProbe(async (connection, sessionId) => {
|
|
931
957
|
const ref = accountRefs.find((entry) => entry.name === connection);
|
|
932
958
|
if (ref === undefined) {
|
|
933
959
|
return undefined;
|
|
934
960
|
}
|
|
935
|
-
return await bridge.probeAuthUrl(ref);
|
|
961
|
+
return await bridge.probeAuthUrl(ref, sessionId);
|
|
962
|
+
});
|
|
963
|
+
runtime.engine.setIndividualConnectedCheck(async (connection, sessionId) => {
|
|
964
|
+
const ref = accountRefs.find((entry) => entry.name === connection);
|
|
965
|
+
return ref !== undefined && (await bridge.individualConnected(ref, sessionId));
|
|
936
966
|
});
|
|
937
967
|
}
|
|
938
968
|
const hasServerTools = runtime.project.agent.tools.some((tool) => tool.execution === "server");
|
|
@@ -1137,6 +1167,19 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
1137
1167
|
return bridge.handle(request, ref, appendSlackQuietHint);
|
|
1138
1168
|
},
|
|
1139
1169
|
});
|
|
1170
|
+
for (const pattern of [
|
|
1171
|
+
cursorAccountSignInPath(":connection"),
|
|
1172
|
+
cursorAccountSignInIssuerPath(":connection"),
|
|
1173
|
+
]) {
|
|
1174
|
+
router.add({
|
|
1175
|
+
method: "GET",
|
|
1176
|
+
pattern: `${base}${pattern}`,
|
|
1177
|
+
auth: [bridge.signInDiscoveryPolicy()],
|
|
1178
|
+
handler: (request, ctx) => refByName.get(ctx.params.connection ?? "")?.credentials === "individual"
|
|
1179
|
+
? cursorAccountSignInDiscovery(request)
|
|
1180
|
+
: errorResponse(404, "not_found", "No sign-in for this connection."),
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1140
1183
|
}
|
|
1141
1184
|
const defaultAuth = args.authToken !== undefined
|
|
1142
1185
|
? [bearerAuth(args.authToken)]
|
|
@@ -1171,10 +1214,11 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
1171
1214
|
// The built-in http channel is not in `project.channels`; the control
|
|
1172
1215
|
// plane's session start (`agentsdk.session`) is delivered to it.
|
|
1173
1216
|
channels: [...project.channels, { id: HTTP_CHANNEL_ID, definition: project.httpChannel }],
|
|
1174
|
-
buildHandlerArgs: (channelId, hostedSessionId) => buildChannelHandlerArgs({
|
|
1217
|
+
buildHandlerArgs: (channelId, hostedSessionId, execution) => buildChannelHandlerArgs({
|
|
1175
1218
|
runtime,
|
|
1176
1219
|
channelId,
|
|
1177
1220
|
hostedSessionId,
|
|
1221
|
+
platformDeliveryId: execution?.platformDeliveryId,
|
|
1178
1222
|
}),
|
|
1179
1223
|
fireReminder: (reminderId, fireCount) => reminderRunner.dispatch(reminderId, { expectedFireCount: fireCount }),
|
|
1180
1224
|
executeReminderDescriptor: async (descriptor) => {
|
|
@@ -2341,6 +2385,7 @@ function buildChannelHandlerArgs(input) {
|
|
|
2341
2385
|
...sendOptions,
|
|
2342
2386
|
auth: sendOptions.auth !== undefined ? sendOptions.auth : auth,
|
|
2343
2387
|
hostedSessionId: input.hostedSessionId,
|
|
2388
|
+
platformDeliveryId: input.platformDeliveryId,
|
|
2344
2389
|
}),
|
|
2345
2390
|
getSession: (sessionId) => runtime.engine.getChannelSession(channelId, sessionId),
|
|
2346
2391
|
receive: (target, inputReceive) => runtime.engine.receive(target, inputReceive),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session credentials under a per-boot key that is never sent. Holding
|
|
3
|
+
* one session's credential, or any secret the serve host hands out, mints no
|
|
4
|
+
* other session's.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SessionCredentials {
|
|
7
|
+
private readonly key;
|
|
8
|
+
for(sessionId: string): string;
|
|
9
|
+
/** Whether `presented` is the credential of `sessionId`. */
|
|
10
|
+
verifies(sessionId: string | null, presented: string | null | undefined): sessionId is string;
|
|
11
|
+
}
|
|
12
|
+
/** Query parameter carrying a session's credential to the tool MCP endpoint. */
|
|
13
|
+
export declare const TOOL_SESSION_CREDENTIAL_PARAM = "agentkitSessionCredential";
|
|
14
|
+
//# sourceMappingURL=session-credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-credential.d.ts","sourceRoot":"","sources":["../../src/internal/session-credential.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmB;IAEvC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7B;IAED,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,IAAI,MAAM,CAO5F;CACF;AAED,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Per-session credentials under a per-boot key that is never sent. Holding
|
|
4
|
+
* one session's credential, or any secret the serve host hands out, mints no
|
|
5
|
+
* other session's.
|
|
6
|
+
*/
|
|
7
|
+
export class SessionCredentials {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.key = randomBytes(32);
|
|
10
|
+
}
|
|
11
|
+
for(sessionId) {
|
|
12
|
+
return createHmac("sha256", this.key).update(sessionId).digest("hex");
|
|
13
|
+
}
|
|
14
|
+
/** Whether `presented` is the credential of `sessionId`. */
|
|
15
|
+
verifies(sessionId, presented) {
|
|
16
|
+
if (sessionId === null || sessionId === "" || presented === null || presented === undefined) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const given = Buffer.from(presented);
|
|
20
|
+
const expected = Buffer.from(this.for(sessionId));
|
|
21
|
+
return given.length === expected.length && timingSafeEqual(given, expected);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Query parameter carrying a session's credential to the tool MCP endpoint. */
|
|
25
|
+
export const TOOL_SESSION_CREDENTIAL_PARAM = "agentkitSessionCredential";
|