@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,441 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process-level OTel SDK (OTLP HTTP exporters for traces / metrics / logs).
|
|
3
|
-
*
|
|
4
|
-
* Refuses to install a second global Tracer/Meter/Logger provider when one
|
|
5
|
-
* already owns the process (CLI, extension host, etc.). Spans still use
|
|
6
|
-
* `trace.getTracer()` so they nest under an existing parent when present.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Histogram, Meter, Tracer } from "@opentelemetry/api";
|
|
10
|
-
import { DiagLogLevel, diag, metrics, trace } from "@opentelemetry/api";
|
|
11
|
-
import type { Logger as OtelLogger } from "@opentelemetry/api-logs";
|
|
12
|
-
import { logs } from "@opentelemetry/api-logs";
|
|
13
|
-
import { type ExportResult, ExportResultCode } from "@opentelemetry/core";
|
|
14
|
-
import { OTLPLogExporter as OTLPLogExporterHttp } from "@opentelemetry/exporter-logs-otlp-http";
|
|
15
|
-
import { OTLPLogExporter as OTLPLogExporterProto } from "@opentelemetry/exporter-logs-otlp-proto";
|
|
16
|
-
import { OTLPMetricExporter as OTLPMetricExporterHttp } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
17
|
-
import { OTLPMetricExporter as OTLPMetricExporterProto } from "@opentelemetry/exporter-metrics-otlp-proto";
|
|
18
|
-
import { OTLPTraceExporter as OTLPTraceExporterHttp } from "@opentelemetry/exporter-trace-otlp-http";
|
|
19
|
-
import { OTLPTraceExporter as OTLPTraceExporterProto } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
20
|
-
import { type Resource, resourceFromAttributes } from "@opentelemetry/resources";
|
|
21
|
-
import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
|
|
22
|
-
import {
|
|
23
|
-
AggregationTemporality,
|
|
24
|
-
MeterProvider,
|
|
25
|
-
PeriodicExportingMetricReader,
|
|
26
|
-
} from "@opentelemetry/sdk-metrics";
|
|
27
|
-
import type { ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
28
|
-
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
29
|
-
import {
|
|
30
|
-
BatchSpanProcessor,
|
|
31
|
-
NodeTracerProvider,
|
|
32
|
-
ParentBasedSampler,
|
|
33
|
-
TraceIdRatioBasedSampler,
|
|
34
|
-
} from "@opentelemetry/sdk-trace-node";
|
|
35
|
-
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
|
36
|
-
import {
|
|
37
|
-
installOutboundFetchInstrumentation,
|
|
38
|
-
type OtelExporterConfig,
|
|
39
|
-
type OtelSignal,
|
|
40
|
-
} from "../../otel.js";
|
|
41
|
-
import { exportersForSignal, type ResolvedOtelConfig } from "./config.js";
|
|
42
|
-
import { ensureW3cPropagator } from "./propagation.js";
|
|
43
|
-
|
|
44
|
-
const INSTRUMENTATION = "agent_sdk";
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Hosted v2 pods may be frozen or destroyed as soon as the HTTP reply
|
|
48
|
-
* lands. Bound the exporter wait so a slow collector cannot hold the
|
|
49
|
-
* delivery (OTLP BatchSpanProcessor defaults to 30s).
|
|
50
|
-
*/
|
|
51
|
-
export const OTEL_FORCE_FLUSH_TIMEOUT_MS = 1_000;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* First hosted OTLP POST may include a cold TLS handshake to Datadog.
|
|
55
|
-
* Bound separately from {@link OTEL_FORCE_FLUSH_TIMEOUT_MS} so the
|
|
56
|
-
* queued turn/tool batch is not abandoned after 1s.
|
|
57
|
-
*/
|
|
58
|
-
export const OTEL_DEFERRED_EXPORT_TIMEOUT_MS = 5_000;
|
|
59
|
-
|
|
60
|
-
/** Drop oldest finished spans when no collector has drained the buffer. */
|
|
61
|
-
export const OTEL_IN_MEMORY_SPAN_LIMIT = 2_048;
|
|
62
|
-
|
|
63
|
-
export interface OtelRuntime {
|
|
64
|
-
config: ResolvedOtelConfig;
|
|
65
|
-
tracer: Tracer;
|
|
66
|
-
meter: Meter | undefined;
|
|
67
|
-
logger: OtelLogger | undefined;
|
|
68
|
-
httpDuration: Histogram | undefined;
|
|
69
|
-
forceFlush: () => Promise<void>;
|
|
70
|
-
shutdown: () => Promise<void>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface CreateOtelRuntimeOptions {
|
|
74
|
-
/**
|
|
75
|
-
* Re-resolve exporters at flush (hosted v2 binds deployment secrets
|
|
76
|
-
* after bake). When bake had no OTLP exporters, finished spans sit
|
|
77
|
-
* in memory until this returns destinations.
|
|
78
|
-
*/
|
|
79
|
-
resolveExport?: () => ResolvedOtelConfig;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function createOtelRuntime(
|
|
83
|
-
config: ResolvedOtelConfig,
|
|
84
|
-
log: (line: string) => void,
|
|
85
|
-
options?: CreateOtelRuntimeOptions,
|
|
86
|
-
): OtelRuntime | undefined {
|
|
87
|
-
if (!config.enabled) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
if (config.traces !== false) {
|
|
91
|
-
installOutboundFetchInstrumentation();
|
|
92
|
-
}
|
|
93
|
-
const proto = process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim().toLowerCase();
|
|
94
|
-
if (proto === "grpc") {
|
|
95
|
-
log("[agent-sdk:otel] OTEL_EXPORTER_OTLP_PROTOCOL=grpc is unsupported; using http/protobuf");
|
|
96
|
-
}
|
|
97
|
-
ensureW3cPropagator();
|
|
98
|
-
const sdk = startOtelSdk(config, log, options?.resolveExport);
|
|
99
|
-
const meter =
|
|
100
|
-
config.metrics === false ? undefined : metrics.getMeterProvider().getMeter(INSTRUMENTATION);
|
|
101
|
-
return {
|
|
102
|
-
config,
|
|
103
|
-
tracer: trace.getTracer(INSTRUMENTATION),
|
|
104
|
-
meter,
|
|
105
|
-
logger: config.logs === false ? undefined : logs.getLogger(INSTRUMENTATION),
|
|
106
|
-
httpDuration:
|
|
107
|
-
meter === undefined
|
|
108
|
-
? undefined
|
|
109
|
-
: meter.createHistogram("agent_sdk.http.duration", {
|
|
110
|
-
description: "HTTP request duration",
|
|
111
|
-
unit: "ms",
|
|
112
|
-
}),
|
|
113
|
-
forceFlush: sdk.forceFlush,
|
|
114
|
-
shutdown: sdk.shutdown,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export async function forceFlushOtelRuntime(runtime: OtelRuntime | undefined): Promise<void> {
|
|
119
|
-
await runtime?.forceFlush();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export async function shutdownOtelRuntime(runtime: OtelRuntime | undefined): Promise<void> {
|
|
123
|
-
await runtime?.shutdown();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export async function raceOtelForceFlush(
|
|
127
|
-
work: Promise<unknown>,
|
|
128
|
-
log: (line: string) => void,
|
|
129
|
-
timeoutMs: number = OTEL_FORCE_FLUSH_TIMEOUT_MS,
|
|
130
|
-
): Promise<void> {
|
|
131
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
132
|
-
const timeout = new Promise<"timeout">(resolve => {
|
|
133
|
-
timer = setTimeout(() => resolve("timeout"), timeoutMs);
|
|
134
|
-
});
|
|
135
|
-
const result = await Promise.race([
|
|
136
|
-
work.then(() => "done" as const).catch(() => "done" as const),
|
|
137
|
-
timeout,
|
|
138
|
-
]);
|
|
139
|
-
if (timer !== undefined) {
|
|
140
|
-
clearTimeout(timer);
|
|
141
|
-
}
|
|
142
|
-
if (result === "timeout") {
|
|
143
|
-
log(`[agent-sdk:otel] forceFlush exceeded ${timeoutMs}ms; continuing`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function startOtelSdk(
|
|
148
|
-
config: ResolvedOtelConfig,
|
|
149
|
-
logger: (line: string) => void,
|
|
150
|
-
resolveExport?: () => ResolvedOtelConfig,
|
|
151
|
-
): {
|
|
152
|
-
forceFlush: () => Promise<void>;
|
|
153
|
-
shutdown: () => Promise<void>;
|
|
154
|
-
} {
|
|
155
|
-
diag.setLogger(
|
|
156
|
-
{
|
|
157
|
-
verbose: m => logger(`[agent-sdk:otel] ${m}`),
|
|
158
|
-
debug: m => logger(`[agent-sdk:otel] ${m}`),
|
|
159
|
-
info: m => logger(`[agent-sdk:otel] ${m}`),
|
|
160
|
-
warn: m => logger(`[agent-sdk:otel] warn: ${m}`),
|
|
161
|
-
error: m => logger(`[agent-sdk:otel] error: ${m}`),
|
|
162
|
-
},
|
|
163
|
-
DiagLogLevel.ERROR,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const resource = buildResource(config);
|
|
167
|
-
let tracerProvider: NodeTracerProvider | undefined;
|
|
168
|
-
let meterProvider: MeterProvider | undefined;
|
|
169
|
-
let loggerProvider: LoggerProvider | undefined;
|
|
170
|
-
let memoryExporter: BoundedMemorySpanExporter | undefined;
|
|
171
|
-
|
|
172
|
-
const traceOpts = config.traces;
|
|
173
|
-
if (traceOpts !== false) {
|
|
174
|
-
const exporters = exportersForSignal(config.exporters, "traces");
|
|
175
|
-
if (hasRealTracerProvider()) {
|
|
176
|
-
logger(
|
|
177
|
-
"[agent-sdk:otel] TracerProvider already registered; reusing global (Agent SDK OTLP exporters not attached)",
|
|
178
|
-
);
|
|
179
|
-
} else {
|
|
180
|
-
const spanProcessors: SpanProcessor[] = [];
|
|
181
|
-
if (exporters.length > 0) {
|
|
182
|
-
for (const exporter of exporters) {
|
|
183
|
-
spanProcessors.push(
|
|
184
|
-
new BatchSpanProcessor(
|
|
185
|
-
createTraceExporter(exporter, signalUrl(exporter.url, "traces")),
|
|
186
|
-
),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
memoryExporter = new BoundedMemorySpanExporter(OTEL_IN_MEMORY_SPAN_LIMIT);
|
|
191
|
-
spanProcessors.push(new SimpleSpanProcessor(memoryExporter));
|
|
192
|
-
}
|
|
193
|
-
tracerProvider = new NodeTracerProvider({
|
|
194
|
-
resource,
|
|
195
|
-
spanProcessors,
|
|
196
|
-
sampler: new ParentBasedSampler({
|
|
197
|
-
root: new TraceIdRatioBasedSampler(traceOpts.sampleRatio ?? 1),
|
|
198
|
-
}),
|
|
199
|
-
});
|
|
200
|
-
tracerProvider.register();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const metricOpts = config.metrics;
|
|
205
|
-
if (metricOpts !== false) {
|
|
206
|
-
const exporters = exportersForSignal(config.exporters, "metrics");
|
|
207
|
-
if (exporters.length > 0) {
|
|
208
|
-
const exportIntervalMillis = metricOpts.exportIntervalMillis ?? 10_000;
|
|
209
|
-
const provider = new MeterProvider({
|
|
210
|
-
resource,
|
|
211
|
-
readers: exporters.map(
|
|
212
|
-
exporter =>
|
|
213
|
-
new PeriodicExportingMetricReader({
|
|
214
|
-
exporter: createMetricExporter(exporter, signalUrl(exporter.url, "metrics")),
|
|
215
|
-
exportIntervalMillis,
|
|
216
|
-
}),
|
|
217
|
-
),
|
|
218
|
-
});
|
|
219
|
-
if (metrics.setGlobalMeterProvider(provider)) {
|
|
220
|
-
meterProvider = provider;
|
|
221
|
-
} else {
|
|
222
|
-
logger(
|
|
223
|
-
"[agent-sdk:otel] MeterProvider already registered; reusing global (Agent SDK OTLP exporters not attached)",
|
|
224
|
-
);
|
|
225
|
-
void provider.shutdown();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (config.logs !== false) {
|
|
231
|
-
const exporters = exportersForSignal(config.exporters, "logs");
|
|
232
|
-
if (exporters.length > 0) {
|
|
233
|
-
const provider = new LoggerProvider({
|
|
234
|
-
resource,
|
|
235
|
-
processors: exporters.map(
|
|
236
|
-
exporter =>
|
|
237
|
-
new BatchLogRecordProcessor(
|
|
238
|
-
createLogExporter(exporter, signalUrl(exporter.url, "logs")),
|
|
239
|
-
),
|
|
240
|
-
),
|
|
241
|
-
});
|
|
242
|
-
// api-logs returns the active provider (ours on success, existing otherwise).
|
|
243
|
-
if (logs.setGlobalLoggerProvider(provider) === provider) {
|
|
244
|
-
loggerProvider = provider;
|
|
245
|
-
} else {
|
|
246
|
-
logger(
|
|
247
|
-
"[agent-sdk:otel] LoggerProvider already registered; reusing global (Agent SDK OTLP exporters not attached)",
|
|
248
|
-
);
|
|
249
|
-
void provider.shutdown();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (memoryExporter === undefined) {
|
|
255
|
-
logger(
|
|
256
|
-
`[agent-sdk] otel enabled service=${config.serviceName} exporters=${config.exporters.length} traces=${config.traces !== false} metrics=${config.metrics !== false} logs=${config.logs !== false}`,
|
|
257
|
-
);
|
|
258
|
-
} else {
|
|
259
|
-
logger(
|
|
260
|
-
`[agent-sdk] otel recording service=${config.serviceName} (export on flush when OTLP exporters resolve)`,
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const flushDeferred = async (): Promise<void> => {
|
|
265
|
-
if (memoryExporter === undefined) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
const spans = memoryExporter.getFinishedSpans();
|
|
269
|
-
if (spans.length === 0) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const exportConfig = resolveExport?.() ?? config;
|
|
273
|
-
const destinations = exportersForSignal(exportConfig.exporters, "traces");
|
|
274
|
-
if (destinations.length === 0) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
// Spans already carry the bake-time Resource. Hosted v2 binds
|
|
278
|
-
// deployment secrets after bake, so env / service extras on
|
|
279
|
-
// exportConfig must replace that Resource on the wire.
|
|
280
|
-
const ok = await exportQueuedSpans(spans, destinations, logger, buildResource(exportConfig));
|
|
281
|
-
if (ok) {
|
|
282
|
-
memoryExporter.reset();
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
return {
|
|
287
|
-
forceFlush: async () => {
|
|
288
|
-
await Promise.allSettled([
|
|
289
|
-
raceOtelForceFlush(
|
|
290
|
-
Promise.allSettled([
|
|
291
|
-
tracerProvider?.forceFlush(),
|
|
292
|
-
meterProvider?.forceFlush(),
|
|
293
|
-
loggerProvider?.forceFlush(),
|
|
294
|
-
]),
|
|
295
|
-
logger,
|
|
296
|
-
),
|
|
297
|
-
raceOtelForceFlush(flushDeferred(), logger, OTEL_DEFERRED_EXPORT_TIMEOUT_MS),
|
|
298
|
-
]);
|
|
299
|
-
},
|
|
300
|
-
shutdown: async () => {
|
|
301
|
-
await flushDeferred();
|
|
302
|
-
await Promise.allSettled([
|
|
303
|
-
tracerProvider?.shutdown(),
|
|
304
|
-
meterProvider?.shutdown(),
|
|
305
|
-
loggerProvider?.shutdown(),
|
|
306
|
-
]);
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function withExportResource(span: ReadableSpan, resource: Resource): ReadableSpan {
|
|
312
|
-
return new Proxy(span, {
|
|
313
|
-
get(target, prop, receiver) {
|
|
314
|
-
if (prop === "resource") {
|
|
315
|
-
return resource;
|
|
316
|
-
}
|
|
317
|
-
return Reflect.get(target, prop, receiver);
|
|
318
|
-
},
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
async function exportQueuedSpans(
|
|
323
|
-
spans: ReadableSpan[],
|
|
324
|
-
destinations: readonly OtelExporterConfig[],
|
|
325
|
-
logger: (line: string) => void,
|
|
326
|
-
resource: Resource,
|
|
327
|
-
): Promise<boolean> {
|
|
328
|
-
const payload = spans.map(span => withExportResource(span, resource));
|
|
329
|
-
const exporters: SpanExporter[] = destinations.map(destination =>
|
|
330
|
-
createTraceExporter(destination, signalUrl(destination.url, "traces")),
|
|
331
|
-
);
|
|
332
|
-
try {
|
|
333
|
-
const results = await Promise.all(
|
|
334
|
-
exporters.map(
|
|
335
|
-
exporter =>
|
|
336
|
-
new Promise<boolean>(resolve => {
|
|
337
|
-
exporter.export(payload, (result: ExportResult) => {
|
|
338
|
-
resolve(result.code === ExportResultCode.SUCCESS);
|
|
339
|
-
});
|
|
340
|
-
}),
|
|
341
|
-
),
|
|
342
|
-
);
|
|
343
|
-
return results.every(ok => ok);
|
|
344
|
-
} catch (error) {
|
|
345
|
-
logger(
|
|
346
|
-
`[agent-sdk:otel] deferred export failed: ${
|
|
347
|
-
error instanceof Error ? error.message : String(error)
|
|
348
|
-
}`,
|
|
349
|
-
);
|
|
350
|
-
return false;
|
|
351
|
-
} finally {
|
|
352
|
-
await Promise.allSettled(exporters.map(exporter => exporter.shutdown()));
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function buildResource(config: ResolvedOtelConfig): Resource {
|
|
357
|
-
// Align with Cursor enterprise wire resource attrs where they overlap so
|
|
358
|
-
// Agent SDK traces join org metrics/logs in the same collector.
|
|
359
|
-
const resourceAttrs: Record<string, string> = {
|
|
360
|
-
[ATTR_SERVICE_NAME]: config.serviceName,
|
|
361
|
-
"telemetry.sdk.language": "nodejs",
|
|
362
|
-
"cursor.surface": "unspecified",
|
|
363
|
-
"cursor.entrypoint": "sdk_ts",
|
|
364
|
-
"agent_sdk.framework": "@cursor/bdk",
|
|
365
|
-
...config.resourceAttributes,
|
|
366
|
-
};
|
|
367
|
-
if (config.serviceVersion !== undefined) {
|
|
368
|
-
resourceAttrs[ATTR_SERVICE_VERSION] = config.serviceVersion;
|
|
369
|
-
}
|
|
370
|
-
return resourceFromAttributes(resourceAttrs);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function signalUrl(base: string, signal: OtelSignal): string {
|
|
374
|
-
return `${base.replace(/\/$/, "")}/v1/${signal}`;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/** True when a non-noop TracerProvider already owns the process. */
|
|
378
|
-
function hasRealTracerProvider(): boolean {
|
|
379
|
-
const provider = trace.getTracerProvider() as {
|
|
380
|
-
getDelegate?: () => { constructor: { name: string } };
|
|
381
|
-
};
|
|
382
|
-
const delegate = provider.getDelegate?.();
|
|
383
|
-
return delegate !== undefined && delegate.constructor.name !== "NoopTracerProvider";
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function isProtobuf(exporter: OtelExporterConfig): boolean {
|
|
387
|
-
return exporter.protocol !== "http/json";
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function createTraceExporter(exporter: OtelExporterConfig, url: string) {
|
|
391
|
-
const opts = { url, headers: exporter.headers };
|
|
392
|
-
return isProtobuf(exporter) ? new OTLPTraceExporterProto(opts) : new OTLPTraceExporterHttp(opts);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function createMetricExporter(exporter: OtelExporterConfig, url: string) {
|
|
396
|
-
const opts = {
|
|
397
|
-
url,
|
|
398
|
-
headers: exporter.headers,
|
|
399
|
-
temporalityPreference: AggregationTemporality.DELTA,
|
|
400
|
-
};
|
|
401
|
-
return isProtobuf(exporter)
|
|
402
|
-
? new OTLPMetricExporterProto(opts)
|
|
403
|
-
: new OTLPMetricExporterHttp(opts);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function createLogExporter(exporter: OtelExporterConfig, url: string) {
|
|
407
|
-
const opts = { url, headers: exporter.headers };
|
|
408
|
-
return isProtobuf(exporter) ? new OTLPLogExporterProto(opts) : new OTLPLogExporterHttp(opts);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/** In-memory finished-span queue with a hard cap (oldest dropped). */
|
|
412
|
-
class BoundedMemorySpanExporter implements SpanExporter {
|
|
413
|
-
private spans: ReadableSpan[] = [];
|
|
414
|
-
|
|
415
|
-
constructor(private readonly limit: number) {}
|
|
416
|
-
|
|
417
|
-
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {
|
|
418
|
-
this.spans.push(...spans);
|
|
419
|
-
if (this.spans.length > this.limit) {
|
|
420
|
-
this.spans.splice(0, this.spans.length - this.limit);
|
|
421
|
-
}
|
|
422
|
-
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
getFinishedSpans(): ReadableSpan[] {
|
|
426
|
-
return this.spans.slice();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
reset(): void {
|
|
430
|
-
this.spans = [];
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
shutdown(): Promise<void> {
|
|
434
|
-
this.reset();
|
|
435
|
-
return Promise.resolve();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
forceFlush(): Promise<void> {
|
|
439
|
-
return Promise.resolve();
|
|
440
|
-
}
|
|
441
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package `defineConnection({ tools })` into a `node -e` stdio transport a
|
|
3
|
-
* repo-less cloud VM can spawn.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
import { createRequire } from "node:module";
|
|
8
|
-
import { dirname, join } from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
import * as esbuild from "esbuild";
|
|
11
|
-
import type {
|
|
12
|
-
ConnectionTransport,
|
|
13
|
-
InlineStdioConnectionConfig,
|
|
14
|
-
JsonSchemaObject,
|
|
15
|
-
} from "../types.js";
|
|
16
|
-
import type { InlineStdioCatalogEntry } from "./inline-stdio-mcp.js";
|
|
17
|
-
import { toolInputJsonSchema, toolOutputJsonSchema } from "./json-schema.js";
|
|
18
|
-
|
|
19
|
-
const require = createRequire(import.meta.url);
|
|
20
|
-
|
|
21
|
-
function sibling(basename: string): string {
|
|
22
|
-
const dir = fileURLToPath(new URL(".", import.meta.url));
|
|
23
|
-
const ts = join(dir, `${basename}.ts`);
|
|
24
|
-
return existsSync(ts) ? ts : join(dir, `${basename}.js`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function jsonSchemaCatalog(
|
|
28
|
-
tools: InlineStdioConnectionConfig["tools"],
|
|
29
|
-
): Record<string, InlineStdioCatalogEntry> {
|
|
30
|
-
const catalog: Record<string, InlineStdioCatalogEntry> = {};
|
|
31
|
-
for (const [name, tool] of Object.entries(tools)) {
|
|
32
|
-
const outputSchema = toolOutputJsonSchema(tool.outputSchema);
|
|
33
|
-
catalog[name] = {
|
|
34
|
-
description: tool.description,
|
|
35
|
-
inputSchema: toolInputJsonSchema(tool.inputSchema) as JsonSchemaObject,
|
|
36
|
-
...(outputSchema === undefined ? {} : { outputSchema: outputSchema as JsonSchemaObject }),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return catalog;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function packageInlineStdioConnection(options: {
|
|
43
|
-
name: string;
|
|
44
|
-
entryPath: string;
|
|
45
|
-
tools: InlineStdioConnectionConfig["tools"];
|
|
46
|
-
absWorkingDir: string;
|
|
47
|
-
}): Promise<ConnectionTransport> {
|
|
48
|
-
const runtimePath = sibling("inline-stdio-mcp");
|
|
49
|
-
const stubPath = sibling("inline-stdio-define-stub");
|
|
50
|
-
const catalog = jsonSchemaCatalog(options.tools);
|
|
51
|
-
const result = await esbuild.build({
|
|
52
|
-
entryPoints: ["inline-stdio-entry"],
|
|
53
|
-
bundle: true,
|
|
54
|
-
write: false,
|
|
55
|
-
platform: "node",
|
|
56
|
-
format: "esm",
|
|
57
|
-
target: "node22",
|
|
58
|
-
minify: true,
|
|
59
|
-
legalComments: "none",
|
|
60
|
-
absWorkingDir: options.absWorkingDir,
|
|
61
|
-
alias: {
|
|
62
|
-
zod: require.resolve("zod"),
|
|
63
|
-
},
|
|
64
|
-
plugins: [
|
|
65
|
-
{
|
|
66
|
-
name: "inline-stdio-entry",
|
|
67
|
-
setup(build) {
|
|
68
|
-
build.onResolve({ filter: /^inline-stdio-entry$/ }, () => ({
|
|
69
|
-
path: "inline-stdio-entry",
|
|
70
|
-
namespace: "inline-stdio",
|
|
71
|
-
}));
|
|
72
|
-
build.onLoad({ filter: /.*/, namespace: "inline-stdio" }, () => ({
|
|
73
|
-
contents: `import definition from ${JSON.stringify(options.entryPath)};
|
|
74
|
-
import { serveInlineStdioMcp } from ${JSON.stringify(runtimePath)};
|
|
75
|
-
serveInlineStdioMcp(
|
|
76
|
-
${JSON.stringify(options.name)},
|
|
77
|
-
definition,
|
|
78
|
-
${JSON.stringify(catalog)}
|
|
79
|
-
);
|
|
80
|
-
`,
|
|
81
|
-
resolveDir: dirname(options.entryPath),
|
|
82
|
-
loader: "ts",
|
|
83
|
-
}));
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "inline-stdio-connection-stub",
|
|
88
|
-
setup(build) {
|
|
89
|
-
build.onResolve({ filter: /^@cursor\/(?:bdk|july)\/connections$/ }, () => ({
|
|
90
|
-
path: stubPath,
|
|
91
|
-
}));
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const file = result.outputFiles?.[0];
|
|
98
|
-
if (file === undefined) {
|
|
99
|
-
throw new Error(
|
|
100
|
-
`Failed to package inline stdio MCP connection "${options.name}": esbuild produced no output.`,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
const source = file.text.replace(/^#!.*\r?\n/, "");
|
|
104
|
-
if (source.trim() === "") {
|
|
105
|
-
throw new Error(
|
|
106
|
-
`Failed to package inline stdio MCP connection "${options.name}": empty bundle.`,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
type: "stdio",
|
|
111
|
-
command: "node",
|
|
112
|
-
args: ["--input-type=module", "-e", source],
|
|
113
|
-
};
|
|
114
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Peer MCP connections: `defineConnection({ agent: "<slug>" })` addresses
|
|
3
|
-
* another agent mounted on the same serve host. Discovery keeps the
|
|
4
|
-
* transport symbolic (the target slug); the server resolves it to that
|
|
5
|
-
* agent's MCP endpoint (`/<slug>/v1/mcp`) once mounts and the listen
|
|
6
|
-
* address are known.
|
|
7
|
-
*
|
|
8
|
-
* Local-runtime turns (and host-side `ctx.host.mcp` calls) use the loopback
|
|
9
|
-
* server URL. Cloud-runtime turns run on a VM that cannot reach loopback,
|
|
10
|
-
* so they use the serve `publicUrl` when configured — and omit the peer
|
|
11
|
-
* (with a startup warning) when it is not.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { type AgentProject, isPeerConnectionTransport } from "../types.js";
|
|
15
|
-
import { MCP_ENDPOINT_PATH } from "./mcp-endpoint.js";
|
|
16
|
-
import type { EngineResolvedConnection } from "./session-engine.js";
|
|
17
|
-
|
|
18
|
-
/** A validated peer reference: MCP connection name → target mount slug. */
|
|
19
|
-
export interface PeerConnectionRef {
|
|
20
|
-
/** Connection (MCP server) name — the filename under `agent/mcp-connections/`. */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Slug of the peer agent mount this connection targets. */
|
|
23
|
-
targetSlug: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Validate every peer MCP connection across `mounts` and return them grouped by
|
|
28
|
-
* the referencing mount's slug. Throws on references to unknown slugs and on
|
|
29
|
-
* self-references (an agent asking itself recurses forever).
|
|
30
|
-
*/
|
|
31
|
-
export function collectPeerConnections(
|
|
32
|
-
mounts: Array<{ slug: string; project: AgentProject }>,
|
|
33
|
-
): Map<string, PeerConnectionRef[]> {
|
|
34
|
-
const knownSlugs = new Set(mounts.map(({ slug }) => slug).filter(slug => slug !== ""));
|
|
35
|
-
const bySlug = new Map<string, PeerConnectionRef[]>();
|
|
36
|
-
for (const { slug, project } of mounts) {
|
|
37
|
-
const refs: PeerConnectionRef[] = [];
|
|
38
|
-
for (const connection of [
|
|
39
|
-
...project.agent.connections,
|
|
40
|
-
...(project.agent.hostConnections ?? []),
|
|
41
|
-
]) {
|
|
42
|
-
if (!isPeerConnectionTransport(connection.transport)) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const targetSlug = connection.transport.agent;
|
|
46
|
-
const label = slug === "" ? project.name : slug;
|
|
47
|
-
if (targetSlug === slug) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Agent "${label}" connection "${connection.name}" references itself (agent: "${targetSlug}"); an agent cannot be its own peer.`,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (!knownSlugs.has(targetSlug)) {
|
|
53
|
-
const available = [...knownSlugs].sort().join(", ") || "(none)";
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Agent "${label}" connection "${connection.name}" references unknown peer agent "${targetSlug}". Mounted agents: ${available}. Peers require multi-agent serve (each agent mounted under its directory-name slug).`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
refs.push({ name: connection.name, targetSlug });
|
|
59
|
-
}
|
|
60
|
-
if (refs.length > 0) {
|
|
61
|
-
bySlug.set(slug, refs);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return bySlug;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Resolve validated peer refs to concrete MCP URLs once the server is
|
|
69
|
-
* listening. `serverUrl` is the loopback base (`http://127.0.0.1:<port>`);
|
|
70
|
-
* `publicUrl` (when configured) is the externally reachable base used for
|
|
71
|
-
* cloud-runtime turns. When the host requires a bearer token, it is attached
|
|
72
|
-
* so peer calls pass the target agent's auth chain.
|
|
73
|
-
*/
|
|
74
|
-
export function resolvePeerConnections(args: {
|
|
75
|
-
refs: PeerConnectionRef[];
|
|
76
|
-
serverUrl: string;
|
|
77
|
-
publicUrl?: string;
|
|
78
|
-
authToken?: string;
|
|
79
|
-
}): EngineResolvedConnection[] {
|
|
80
|
-
const serverBase = trimTrailingSlash(args.serverUrl);
|
|
81
|
-
const publicBase = args.publicUrl === undefined ? undefined : trimTrailingSlash(args.publicUrl);
|
|
82
|
-
const headers =
|
|
83
|
-
args.authToken === undefined ? undefined : { authorization: `Bearer ${args.authToken}` };
|
|
84
|
-
return args.refs.map(ref => ({
|
|
85
|
-
name: ref.name,
|
|
86
|
-
localUrl: `${serverBase}/${ref.targetSlug}${MCP_ENDPOINT_PATH}`,
|
|
87
|
-
...(publicBase === undefined
|
|
88
|
-
? {}
|
|
89
|
-
: { cloudUrl: `${publicBase}/${ref.targetSlug}${MCP_ENDPOINT_PATH}` }),
|
|
90
|
-
...(headers === undefined ? {} : { headers }),
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function trimTrailingSlash(url: string): string {
|
|
95
|
-
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
96
|
-
}
|