@cursor/bdk 0.2.17 → 0.2.20
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 +16 -6
- package/dist/bin/agent-serve.js +7 -0
- package/dist/channels/runs/index.d.ts +4 -0
- package/dist/channels/runs/index.d.ts.map +1 -0
- package/dist/channels/runs/index.js +2 -0
- package/dist/channels/runs/runs-channel.d.ts +5 -0
- package/dist/channels/runs/runs-channel.d.ts.map +1 -0
- package/dist/channels/runs/runs-channel.js +34 -0
- package/dist/channels/runs/types.d.ts +34 -0
- package/dist/channels/runs/types.d.ts.map +1 -0
- package/dist/channels/runs/types.js +1 -0
- package/dist/channels/slack/slack-channel.d.ts +3 -2
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +9 -2
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.CUNuFTSm.js → app.BzgJFr_T.js} +4 -4
- package/dist/docs/assets/chunks/@localSearchIndexroot.gGwBYU3d.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.Dez74k0W.js → VPLocalSearchBox.Bn5QyUDM.js} +1 -1
- package/dist/docs/assets/chunks/{arc.CJ3FhK7H.js → arc.D734Gm5d.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.CfUdbHsa.js → architectureDiagram-Q4EWVU46.NX1jj-YX.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.D93LawU9.js → baseUniq.nd8dxdeO.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.Zvsd6UHP.js → blockDiagram-DXYQGD6D.DG8faTim.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.CGX5xZ9d.js → c4Diagram-AHTNJAMY.zD31AJ3b.js} +1 -1
- package/dist/docs/assets/chunks/channel.DQLJQMi3.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.CCIf0QCo.js → chunk-4BX2VUAB.BHQj6Rko.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.D_N1RPyi.js → chunk-4TB4RGXK.Cs38Yh16.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.B1oecjzx.js → chunk-55IACEB6.CFUR21JO.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.BzUNVPGX.js → chunk-EDXVE4YY.C80-Sneg.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DheI8WSO.js → chunk-FMBD7UC4.CdT1MGza.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.Bg4iL0sM.js → chunk-OYMX7WX6.BctEzab0.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.CSQjDhAD.js → chunk-QZHKN3VN.DTneeX3k.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.BDdxnPU4.js → chunk-YZCP3GAM.Cz47F_-o.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.j55aerUT.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.j55aerUT.js +1 -0
- package/dist/docs/assets/chunks/clone.XimRS84I.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.AT0weO8r.js → cose-bilkent-S5V4N54A.BPYgB-_O.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.CJ30TxV0.js → dagre-KV5264BT.Cu6hECod.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.KtE--1fW.js → diagram-5BDNPKRD.BMgp95Tz.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.BFGygSUQ.js → diagram-G4DWMVQ6.towWdhDi.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BLU-79eb.js → diagram-MMDJMWI5.D9IfOvE9.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.CdjfJdVG.js → diagram-TYMM5635.NTX57RPu.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.Dj1Iwypl.js → erDiagram-SMLLAGMA.DIQLqDqu.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.BXqj_Su2.js → flowDiagram-DWJPFMVM.DhqpItRe.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.CNfgGSst.js → ganttDiagram-T4ZO3ILL.B998R3Ps.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.2tgvFDBr.js → gitGraphDiagram-UUTBAWPF.B45nTn8-.js} +1 -1
- package/dist/docs/assets/chunks/{graph.CWHZMxx6.js → graph.DPseWzzM.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.DhLIK8m1.js → infoDiagram-42DDH7IO._GhhBBai.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.BIN11n1G.js → ishikawaDiagram-UXIWVN3A.CTUMcaMM.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.BARmNJ0n.js → journeyDiagram-VCZTEJTY.DkJBUddC.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.BrTJYFyF.js → kanban-definition-6JOO6SKY.B5Q3uwhy.js} +1 -1
- package/dist/docs/assets/chunks/{layout.CPZIIywK.js → layout.CDY13IKh.js} +1 -1
- package/dist/docs/assets/chunks/{linear.DTpmzI5S.js → linear.BPd1ql9p.js} +1 -1
- package/dist/docs/assets/chunks/{min.BBLQmXwZ.js → min.dlGuqIBP.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.5qkWJvdl.js → mindmap-definition-QFDTVHPH.Cp7zCtmb.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.-4wufv_f.js → pieDiagram-DEJITSTG.CRH034nu.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.C0jrp1-8.js → quadrantDiagram-34T5L4WZ.BspgZ-pX.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DUDpANfe.js → requirementDiagram-MS252O5E.CQZqZ0nZ.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.74Lvg6Gu.js → sankeyDiagram-XADWPNL6.DllwFU3k.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.BHDIH286.js → sequenceDiagram-FGHM5R23.B5fTXycf.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.Dr-HIuLb.js → stateDiagram-FHFEXIEX.12GQjmbD.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.Ctv5WEMu.js +1 -0
- package/dist/docs/assets/chunks/{theme.H8zSBhlM.js → theme.BgocqONV.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.GtyCaSiL.js → timeline-definition-GMOUNBTQ.DXKUL5rH.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.DLId0rxH.js → vennDiagram-DHZGUBPP.BrsjYCjp.js} +1 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.DZDndEXQ.js +162 -0
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.CI6mGYNG.js → wardleyDiagram-NUSXRM2D.C4oM69gv.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.CG1n865F.js → xychartDiagram-5P7HB3ND.qzHH9efW.js} +1 -1
- package/dist/docs/assets/{deployment.md.ajc3VM0m.js → deployment.md.D0uprX2p.js} +3 -3
- package/dist/docs/assets/{deployment.md.ajc3VM0m.lean.js → deployment.md.D0uprX2p.lean.js} +1 -1
- package/dist/docs/assets/{guides_agent-to-agent.md.Cps5NiCV.js → guides_agent-to-agent.md.CwL5cwuE.js} +6 -5
- package/dist/docs/assets/{guides_agent-to-agent.md.Cps5NiCV.lean.js → guides_agent-to-agent.md.CwL5cwuE.lean.js} +1 -1
- package/dist/docs/assets/guides_export-grokbot.md.qo5bxi4h.js +55 -0
- package/dist/docs/assets/guides_export-grokbot.md.qo5bxi4h.lean.js +1 -0
- package/dist/docs/assets/{guides_opentelemetry.md.jcPNrQbH.js → guides_opentelemetry.md.BHPm32OR.js} +3 -3
- package/dist/docs/assets/{guides_opentelemetry.md.jcPNrQbH.lean.js → guides_opentelemetry.md.BHPm32OR.lean.js} +1 -1
- package/dist/docs/assets/{index.md.CHAFTf6m.js → index.md.CAnsLl8D.js} +2 -2
- package/dist/docs/assets/{index.md.CHAFTf6m.lean.js → index.md.CAnsLl8D.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.Bt3sAfat.js → reference_cli.md.Bkrsce22.js} +7 -4
- package/dist/docs/assets/{reference_cli.md.Bt3sAfat.lean.js → reference_cli.md.Bkrsce22.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.CxbLpaaP.js → reference_connections.md.BJE2Zllp.js} +4 -4
- package/dist/docs/assets/{reference_connections.md.CxbLpaaP.lean.js → reference_connections.md.BJE2Zllp.lean.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.DbJC8mcZ.js → reference_hooks.md.CP3FENFJ.js} +1 -1
- package/dist/docs/assets/reference_memory.md.BwyJXYZe.js +4 -0
- package/dist/docs/assets/reference_memory.md.BwyJXYZe.lean.js +1 -0
- package/dist/docs/assets/{reference_skills.md.Ckddg6KX.js → reference_skills.md.C2GWh7g8.js} +3 -3
- package/dist/docs/building-with-agents.html +35 -35
- package/dist/docs/deployment.html +38 -38
- package/dist/docs/deployment.md +17 -0
- package/dist/docs/evals.html +35 -35
- package/dist/docs/guides/agent-to-agent.html +41 -40
- package/dist/docs/guides/agent-to-agent.md +34 -21
- 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/export-grokbot.html +114 -0
- package/dist/docs/guides/export-grokbot.md +239 -0
- 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 +35 -35
- package/dist/docs/guides/mcp-oauth.html +35 -35
- package/dist/docs/guides/migrate.html +36 -36
- package/dist/docs/guides/opentelemetry.html +37 -37
- package/dist/docs/guides/opentelemetry.md +19 -0
- 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 +37 -37
- package/dist/docs/index.md +3 -0
- package/dist/docs/llms-full.txt +493 -29
- package/dist/docs/llms.txt +2 -0
- package/dist/docs/quickstart.html +35 -35
- package/dist/docs/reference/agent-config.html +35 -35
- package/dist/docs/reference/artifacts.html +35 -35
- package/dist/docs/reference/channels.html +35 -35
- package/dist/docs/reference/cli.html +41 -38
- package/dist/docs/reference/cli.md +39 -1
- package/dist/docs/reference/connections.html +38 -38
- package/dist/docs/reference/connections.md +16 -6
- package/dist/docs/reference/evals.html +36 -36
- package/dist/docs/reference/extensions.html +35 -35
- package/dist/docs/reference/hooks.html +38 -38
- package/dist/docs/reference/hooks.md +2 -1
- package/dist/docs/reference/http-api.html +35 -35
- package/dist/docs/reference/instructions.html +35 -35
- package/dist/docs/reference/memory.html +63 -0
- package/dist/docs/reference/memory.md +114 -0
- 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 +38 -38
- 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/grokbot-agents.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/evals.d.ts +1 -1
- package/dist/evals.js +1 -1
- package/dist/extensions/cursor-cloud-agents/extension.d.ts +2 -2
- package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/extension.js +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts +8 -1
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/launch-agent.js +10 -1
- package/dist/internal/cli-ax.d.ts +7 -7
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +36 -15
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +0 -14
- package/dist/internal/cloud-turn-usage.d.ts +34 -0
- package/dist/internal/cloud-turn-usage.d.ts.map +1 -0
- package/dist/internal/cloud-turn-usage.js +94 -0
- package/dist/internal/continuation-channel.d.ts.map +1 -1
- package/dist/internal/continuation-channel.js +6 -0
- package/dist/internal/continuation-identity.d.ts +6 -3
- package/dist/internal/continuation-identity.d.ts.map +1 -1
- package/dist/internal/continuation-identity.js +43 -0
- package/dist/internal/estimate-cost.d.ts +55 -0
- package/dist/internal/estimate-cost.d.ts.map +1 -0
- package/dist/internal/{turn-cost.js → estimate-cost.js} +18 -26
- package/dist/internal/event-log.d.ts +2 -2
- package/dist/internal/event-log.js +2 -2
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +21 -2
- package/dist/internal/http-control-plane-session.d.ts +5 -2
- package/dist/internal/http-control-plane-session.d.ts.map +1 -1
- package/dist/internal/http-control-plane-session.js +38 -2
- package/dist/internal/init-scaffold.d.ts.map +1 -1
- package/dist/internal/init-scaffold.js +3 -4
- package/dist/internal/model-config.d.ts +7 -0
- package/dist/internal/model-config.d.ts.map +1 -0
- package/dist/internal/model-config.js +67 -0
- package/dist/internal/otel/collector.d.ts +3 -3
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +8 -21
- package/dist/internal/otel/computer-use-attrs.d.ts +13 -0
- package/dist/internal/otel/computer-use-attrs.d.ts.map +1 -0
- package/dist/internal/otel/computer-use-attrs.js +29 -0
- package/dist/internal/peer-connections.d.ts +17 -8
- package/dist/internal/peer-connections.d.ts.map +1 -1
- package/dist/internal/peer-connections.js +41 -10
- package/dist/internal/request-error-status.d.ts.map +1 -1
- package/dist/internal/request-error-status.js +4 -1
- package/dist/internal/resolved-connections.d.ts +4 -1
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +9 -4
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +16 -14
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +2 -1
- package/dist/internal/session-cost.d.ts +21 -22
- package/dist/internal/session-cost.d.ts.map +1 -1
- package/dist/internal/session-cost.js +38 -46
- package/dist/internal/session-engine.d.ts +25 -41
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +130 -122
- package/dist/internal/sessions-client.d.ts +13 -1
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +24 -0
- package/dist/internal/storage-coordinator.d.ts +9 -9
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +116 -36
- package/dist/internal/testing/factory-resource-fixtures.d.ts +16 -0
- package/dist/internal/testing/factory-resource-fixtures.d.ts.map +1 -1
- package/dist/internal/testing/factory-resource-fixtures.js +14 -0
- package/dist/internal/trajectory.d.ts +5 -6
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +1 -13
- package/dist/memory.d.ts +5 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +1 -1
- package/dist/playground/assets/cursor-icons-16-gwXtdAvu.woff2 +0 -0
- package/dist/playground/assets/index-C77_FdOx.css +1 -0
- package/dist/playground/assets/index-CvzI2lhj.js +71 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +57 -22
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +3 -0
- package/docs/deployment.md +17 -0
- package/docs/guides/agent-to-agent.md +34 -21
- package/docs/guides/export-grokbot.md +244 -0
- package/docs/guides/opentelemetry.md +19 -0
- package/docs/reference/cli.md +39 -1
- package/docs/reference/connections.md +16 -6
- package/docs/reference/hooks.md +2 -1
- package/docs/reference/memory.md +119 -0
- package/package.json +13 -5
- package/templates/agentic-owners/bot/lib/owners/matching.ts +57 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.3c56VHUt.js +0 -1
- package/dist/docs/assets/chunks/channel.S8-FFjmE.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.BB98tFjZ.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.BB98tFjZ.js +0 -1
- package/dist/docs/assets/chunks/clone.B98w8OEv.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DW_lwpZY.js +0 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.CSlECTHi.js +0 -162
- package/dist/internal/cloud-turn-cost.d.ts +0 -42
- package/dist/internal/cloud-turn-cost.d.ts.map +0 -1
- package/dist/internal/cloud-turn-cost.js +0 -120
- package/dist/internal/turn-cost.d.ts +0 -41
- package/dist/internal/turn-cost.d.ts.map +0 -1
- package/dist/playground/assets/cursor-icons-16-4RnoYH3n.woff2 +0 -0
- package/dist/playground/assets/index-7fVUOA5l.css +0 -1
- package/dist/playground/assets/index-U3TRnwAP.js +0 -71
- /package/dist/docs/assets/{reference_hooks.md.DbJC8mcZ.lean.js → reference_hooks.md.CP3FENFJ.lean.js} +0 -0
- /package/dist/docs/assets/{reference_skills.md.Ckddg6KX.lean.js → reference_skills.md.C2GWh7g8.lean.js} +0 -0
|
@@ -68,7 +68,7 @@ export class SessionEventLog {
|
|
|
68
68
|
/** Appended events whose `appendFile` has not finished. */
|
|
69
69
|
this.inflight = [];
|
|
70
70
|
/**
|
|
71
|
-
* In-process patches (cloud
|
|
71
|
+
* In-process patches (cloud usage backfill) that are not rewritten to
|
|
72
72
|
* `events.ndjson`. Applied on read.
|
|
73
73
|
*/
|
|
74
74
|
this.replacements = new Map();
|
|
@@ -174,7 +174,7 @@ export class SessionEventLog {
|
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Replace one already-recorded event in this process. Used to backfill
|
|
177
|
-
* usage
|
|
177
|
+
* usage onto historical `turn.completed` rows without rewriting
|
|
178
178
|
* `events.ndjson`. Live subscribers are not notified — patch before
|
|
179
179
|
* opening a replay stream.
|
|
180
180
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-channel.d.ts","sourceRoot":"","sources":["../../src/internal/http-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,aAAa,EACd,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"http-channel.d.ts","sourceRoot":"","sources":["../../src/internal/http-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,aAAa,EACd,MAAM,aAAa,CAAC;AAMrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAK7B,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,GAAG,WAAW,EAAE,CAgehB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GACA,QAAQ,GAAG,SAAS,CAYtB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAO,GAC/D,QAAQ,CAQV;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAErF;AAkFD,8FAA8F;AAC9F,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAc9C"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { samePrincipal } from "./auth.js";
|
|
13
13
|
import { formatContinuationToken, parseContinuationToken } from "./ids.js";
|
|
14
14
|
import { isRecord } from "./is-record.js";
|
|
15
|
+
import { InvalidModelConfigError, modelConfigForDryRun } from "./model-config.js";
|
|
15
16
|
import { isLoopbackAddress } from "./net.js";
|
|
16
17
|
import { ApprovalInterruptedError, ApprovalNotFoundError, AuthInterruptedError, AuthNotFoundError, HTTP_CHANNEL_ID, SessionAuthError, } from "./session-engine.js";
|
|
17
18
|
import { eventsUrlForSession, playgroundUrlForSession } from "./session-urls.js";
|
|
@@ -40,6 +41,15 @@ export function buildHttpChannelRoutes(args) {
|
|
|
40
41
|
if (body.asOf !== undefined && typeof body.asOf !== "string") {
|
|
41
42
|
return errorResponse(400, "invalid_request", "`asOf` must be an ISO-8601 instant with a timezone when provided.");
|
|
42
43
|
}
|
|
44
|
+
let modelConfig;
|
|
45
|
+
try {
|
|
46
|
+
modelConfig = modelConfigForDryRun(body.modelConfig, body.dryRun === true ? true : undefined);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!(error instanceof InvalidModelConfigError))
|
|
50
|
+
throw error;
|
|
51
|
+
return errorResponse(400, "invalid_request", error.message);
|
|
52
|
+
}
|
|
43
53
|
const message = await transformMessage(body.message, ctx.auth);
|
|
44
54
|
const workspaceFiles = readWorkspaceFiles(body.workspaceFiles);
|
|
45
55
|
// Per-session cloud attach (create only). Eval harness uses this to pin
|
|
@@ -51,6 +61,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
51
61
|
...(body.purpose === "eval" ? { purpose: "eval" } : {}),
|
|
52
62
|
...(body.dryRun === true ? { dryRun: true } : {}),
|
|
53
63
|
asOf: body.asOf,
|
|
64
|
+
modelConfig,
|
|
54
65
|
...(workspaceFiles === undefined ? {} : { workspaceFiles }),
|
|
55
66
|
...(cloud === undefined ? {} : { cloud }),
|
|
56
67
|
});
|
|
@@ -98,7 +109,15 @@ export function buildHttpChannelRoutes(args) {
|
|
|
98
109
|
return errorResponse(409, "stale_continuation_token", "The continuation token does not address this session's active continuation.");
|
|
99
110
|
}
|
|
100
111
|
const message = await transformMessage(body.message, ctx.auth);
|
|
101
|
-
|
|
112
|
+
let rotated;
|
|
113
|
+
try {
|
|
114
|
+
rotated = await engine.followUpHttp(sessionId, presented, message, body.modelConfig);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (!(error instanceof InvalidModelConfigError))
|
|
118
|
+
throw error;
|
|
119
|
+
return errorResponse(400, "invalid_request", error.message);
|
|
120
|
+
}
|
|
102
121
|
if (rotated === undefined) {
|
|
103
122
|
return errorResponse(409, "stale_continuation_token", "The continuation token does not address this session's active continuation.");
|
|
104
123
|
}
|
|
@@ -172,7 +191,7 @@ export function buildHttpChannelRoutes(args) {
|
|
|
172
191
|
const url = new URL(request.url);
|
|
173
192
|
const asJson = url.searchParams.get("format") === "json";
|
|
174
193
|
const snapshot = await engine.listEvents(sessionId, 0, {
|
|
175
|
-
|
|
194
|
+
backfillCloudUsage: true,
|
|
176
195
|
});
|
|
177
196
|
if (asJson) {
|
|
178
197
|
return jsonResponse({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `agent-sdk run --prod` reaches the authenticated CP start route, which
|
|
5
5
|
* delivers `agentsdk.session` to the built-in `http` channel of every v2
|
|
6
|
-
* agent. The wake is `send(message, { dryRun, asOf })`; the session id,
|
|
6
|
+
* agent. The wake is `send(message, { dryRun, asOf, modelConfig, instructions })`; the session id,
|
|
7
7
|
* when the caller resumed an explicit `ses_…`, arrives through the hosted
|
|
8
8
|
* execution (never through this payload), so authored code cannot pick
|
|
9
9
|
* one. {@link HttpChannelDefinition.onAdmit} runs against the mailbox
|
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
* hosted execution runs the case body there instead of a single turn. The
|
|
14
14
|
* case body writes every message, so it skips `onAdmit` and `onMessage`.
|
|
15
15
|
*/
|
|
16
|
-
import type { ChannelHandlerArgs, HttpChannelDefinition, SendMessageOptions } from "../types.js";
|
|
16
|
+
import type { ChannelHandlerArgs, HttpChannelDefinition, SendMessageOptions, SessionModelConfig } from "../types.js";
|
|
17
17
|
export type ControlPlaneSessionPayload = {
|
|
18
18
|
message: string;
|
|
19
19
|
dryRun?: boolean | undefined;
|
|
20
20
|
asOf?: string | undefined;
|
|
21
|
+
modelConfig?: SessionModelConfig | undefined;
|
|
22
|
+
/** Dry-run replacement for the agent's instructions.md. */
|
|
23
|
+
instructions?: string | undefined;
|
|
21
24
|
};
|
|
22
25
|
export type EvalCaseRef = {
|
|
23
26
|
runId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-control-plane-session.d.ts","sourceRoot":"","sources":["../../src/internal/http-control-plane-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"http-control-plane-session.d.ts","sourceRoot":"","sources":["../../src/internal/http-control-plane-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC7C,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAe5D,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAE/E;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,GACf;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,0BAA0B,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA0D/E;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,GACf;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAiBhE;AAeD,wBAAsB,+BAA+B,CAAC,KAAK,EAAE;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,kBAAkB,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;CAC5C,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgCpB;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAavF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `agent-sdk run --prod` reaches the authenticated CP start route, which
|
|
5
5
|
* delivers `agentsdk.session` to the built-in `http` channel of every v2
|
|
6
|
-
* agent. The wake is `send(message, { dryRun, asOf })`; the session id,
|
|
6
|
+
* agent. The wake is `send(message, { dryRun, asOf, modelConfig, instructions })`; the session id,
|
|
7
7
|
* when the caller resumed an explicit `ses_…`, arrives through the hosted
|
|
8
8
|
* execution (never through this payload), so authored code cannot pick
|
|
9
9
|
* one. {@link HttpChannelDefinition.onAdmit} runs against the mailbox
|
|
@@ -17,9 +17,12 @@ import { skipped, turnStarted } from "./channel-dispatch.js";
|
|
|
17
17
|
import { attachHostedAdmissionAdapter } from "./hosted-admission-adapter.js";
|
|
18
18
|
import { AGENT_SDK_EVAL_CASE_EVENT_TYPE, AGENT_SDK_HTTP_CHANNEL_KIND, AGENT_SDK_SESSION_EVENT_TYPE, } from "./hosted-catch-protocol.js";
|
|
19
19
|
import { isRecord } from "./is-record.js";
|
|
20
|
-
|
|
20
|
+
import { InvalidModelConfigError, modelConfigForDryRun } from "./model-config.js";
|
|
21
|
+
const PAYLOAD_KEYS = new Set(["message", "dryRun", "asOf", "modelConfig", "instructions"]);
|
|
21
22
|
const EVAL_CASE_PAYLOAD_KEYS = new Set(["runId", "caseId"]);
|
|
22
23
|
const MAX_MESSAGE_CHARS = 64 * 1024;
|
|
24
|
+
const MAX_INSTRUCTIONS_CHARS = 256 * 1024;
|
|
25
|
+
const INSTRUCTIONS_REQUIRE_DRY_RUN = "invalid argument: instructions is only allowed when dryRun is true";
|
|
23
26
|
const MAX_EVAL_ID_CHARS = 512;
|
|
24
27
|
/** Symbol-keyed so authored channels cannot forge an eval-case send. */
|
|
25
28
|
const EVAL_CASE = Symbol("agentsdk.eval-case");
|
|
@@ -45,12 +48,41 @@ export function parseControlPlaneSessionPayload(payload) {
|
|
|
45
48
|
(typeof payload.asOf !== "string" || payload.asOf.trim().length === 0)) {
|
|
46
49
|
return { ok: false, error: "payload.asOf must be a non-empty string" };
|
|
47
50
|
}
|
|
51
|
+
let modelConfig;
|
|
52
|
+
if (payload.modelConfig !== undefined) {
|
|
53
|
+
try {
|
|
54
|
+
modelConfig = modelConfigForDryRun(payload.modelConfig, payload.dryRun === true ? true : undefined);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (!(error instanceof InvalidModelConfigError))
|
|
58
|
+
throw error;
|
|
59
|
+
return { ok: false, error: error.message };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let instructions;
|
|
63
|
+
if (payload.instructions !== undefined) {
|
|
64
|
+
if (typeof payload.instructions !== "string") {
|
|
65
|
+
return { ok: false, error: "payload.instructions must be a string" };
|
|
66
|
+
}
|
|
67
|
+
instructions = payload.instructions.trim();
|
|
68
|
+
if (instructions.length === 0) {
|
|
69
|
+
return { ok: false, error: "payload.instructions must be a non-empty string" };
|
|
70
|
+
}
|
|
71
|
+
if (instructions.length > MAX_INSTRUCTIONS_CHARS) {
|
|
72
|
+
return { ok: false, error: "payload.instructions is too long" };
|
|
73
|
+
}
|
|
74
|
+
if (payload.dryRun !== true) {
|
|
75
|
+
return { ok: false, error: INSTRUCTIONS_REQUIRE_DRY_RUN };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
48
78
|
return {
|
|
49
79
|
ok: true,
|
|
50
80
|
data: {
|
|
51
81
|
message,
|
|
52
82
|
dryRun: payload.dryRun === true ? true : undefined,
|
|
53
83
|
asOf: typeof payload.asOf === "string" ? payload.asOf.trim() : undefined,
|
|
84
|
+
modelConfig,
|
|
85
|
+
instructions,
|
|
54
86
|
},
|
|
55
87
|
};
|
|
56
88
|
}
|
|
@@ -102,6 +134,8 @@ export async function dispatchHttpControlPlaneSession(input) {
|
|
|
102
134
|
sessionKey: input.mailboxContinuationKey,
|
|
103
135
|
dryRun: parsed.data.dryRun,
|
|
104
136
|
asOf: parsed.data.asOf,
|
|
137
|
+
modelConfig: parsed.data.modelConfig,
|
|
138
|
+
instructions: parsed.data.instructions,
|
|
105
139
|
host: input.args.host,
|
|
106
140
|
});
|
|
107
141
|
}
|
|
@@ -109,6 +143,8 @@ export async function dispatchHttpControlPlaneSession(input) {
|
|
|
109
143
|
const session = await input.args.send(message, {
|
|
110
144
|
dryRun: parsed.data.dryRun,
|
|
111
145
|
asOf: parsed.data.asOf,
|
|
146
|
+
modelConfig: parsed.data.modelConfig,
|
|
147
|
+
instructions: parsed.data.instructions,
|
|
112
148
|
});
|
|
113
149
|
return turnStarted(session);
|
|
114
150
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-scaffold.d.ts","sourceRoot":"","sources":["../../src/internal/init-scaffold.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAkBvE;AAED,eAAO,MAAM,SAAS,EAAE,MAOZ,CAAC;AAgBb,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAgBzD;AAcD,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"init-scaffold.d.ts","sourceRoot":"","sources":["../../src/internal/init-scaffold.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAkBvE;AAED,eAAO,MAAM,SAAS,EAAE,MAOZ,CAAC;AAgBb,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAgBzD;AAcD,eAAO,MAAM,SAAS,EAAE,MAMvB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAK7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAS3B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,WAAmB,GAAG,MAAM,CA0C/E;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAuBtF;AAWD,iEAAiE;AACjE,eAAO,MAAM,oBAAoB,EAAE,MAUlC,CAAC;AAWF,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,EACpE,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,WAAmB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -67,10 +67,9 @@ export default defineTool({
|
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
69
|
`;
|
|
70
|
-
export const MEMORY_TS = `//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// change where memories live, or delete this file to opt out.
|
|
70
|
+
export const MEMORY_TS = `// Every session and every user of this agent share one memory journal.
|
|
71
|
+
// To turn memory off, delete this file and the "## Memory" section of
|
|
72
|
+
// instructions.md.
|
|
74
73
|
import { memoryHook } from "${PACKAGE_NAME}/memory";
|
|
75
74
|
|
|
76
75
|
export default memoryHook();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SessionModelConfig } from "../types.js";
|
|
2
|
+
export declare const MODEL_CONFIG_REQUIRES_DRY_RUN = "invalid argument: modelConfig requires dryRun";
|
|
3
|
+
export declare class InvalidModelConfigError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare function modelConfigForDryRun(modelConfig: unknown, dryRun: boolean | undefined): SessionModelConfig | undefined;
|
|
7
|
+
//# sourceMappingURL=model-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/internal/model-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKtD,eAAO,MAAM,6BAA6B,kDAAkD,CAAC;AAE7F,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAyCD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,OAAO,GAAG,SAAS,GAC1B,kBAAkB,GAAG,SAAS,CAehC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isRecord } from "./is-record.js";
|
|
2
|
+
const MODEL_ID = /^[a-z0-9][a-z0-9.-]{0,127}$/;
|
|
3
|
+
const LEVELS = new Set(["low", "medium", "high", "xhigh"]);
|
|
4
|
+
export const MODEL_CONFIG_REQUIRES_DRY_RUN = "invalid argument: modelConfig requires dryRun";
|
|
5
|
+
export class InvalidModelConfigError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "InvalidModelConfigError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function invalid(message) {
|
|
12
|
+
throw new InvalidModelConfigError(message);
|
|
13
|
+
}
|
|
14
|
+
function setting(value, where) {
|
|
15
|
+
if (!isRecord(value))
|
|
16
|
+
invalid(`invalid argument: ${where}.id is not a model id`);
|
|
17
|
+
const id = value.id;
|
|
18
|
+
if (typeof id !== "string" || !MODEL_ID.test(id)) {
|
|
19
|
+
invalid(`invalid argument: ${where}.id is not a model id`);
|
|
20
|
+
}
|
|
21
|
+
const rawParams = value.params;
|
|
22
|
+
if (!Array.isArray(rawParams))
|
|
23
|
+
invalid(`invalid argument: ${where} requires params`);
|
|
24
|
+
const effortId = id.includes("gpt") ? "reasoning" : "effort";
|
|
25
|
+
const params = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const param of rawParams) {
|
|
28
|
+
if (!isRecord(param))
|
|
29
|
+
invalid(`invalid argument: ${where} param "" is not allowed`);
|
|
30
|
+
const paramId = typeof param.id === "string" ? param.id : "";
|
|
31
|
+
const paramValue = typeof param.value === "string" ? param.value : "";
|
|
32
|
+
if (paramId === "" ||
|
|
33
|
+
paramValue === "" ||
|
|
34
|
+
(paramId !== effortId && paramId !== "fast") ||
|
|
35
|
+
seen.has(paramId)) {
|
|
36
|
+
invalid(`invalid argument: ${where} param ${JSON.stringify(paramId)} is not allowed`);
|
|
37
|
+
}
|
|
38
|
+
const valueOk = paramId === "fast" ? paramValue === "true" || paramValue === "false" : LEVELS.has(paramValue);
|
|
39
|
+
if (!valueOk)
|
|
40
|
+
invalid(`invalid argument: ${where} param ${JSON.stringify(paramId)} bad value`);
|
|
41
|
+
seen.add(paramId);
|
|
42
|
+
params.push({ id: paramId, value: paramValue });
|
|
43
|
+
}
|
|
44
|
+
if (!seen.has(effortId) || !seen.has("fast")) {
|
|
45
|
+
invalid(`invalid argument: ${where} requires params ${effortId} and fast`);
|
|
46
|
+
}
|
|
47
|
+
return { id, params };
|
|
48
|
+
}
|
|
49
|
+
export function modelConfigForDryRun(modelConfig, dryRun) {
|
|
50
|
+
if (modelConfig === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
if (dryRun !== true)
|
|
53
|
+
invalid(MODEL_CONFIG_REQUIRES_DRY_RUN);
|
|
54
|
+
if (!isRecord(modelConfig)) {
|
|
55
|
+
invalid("invalid argument: modelConfig must be { model, fallbacks? }");
|
|
56
|
+
}
|
|
57
|
+
const model = setting(modelConfig.model, "modelConfig.model");
|
|
58
|
+
const fallbacks = modelConfig.fallbacks;
|
|
59
|
+
if (fallbacks === undefined)
|
|
60
|
+
return { model, fallbacks: [] };
|
|
61
|
+
if (!Array.isArray(fallbacks))
|
|
62
|
+
invalid("invalid argument: modelConfig.fallbacks must be an array");
|
|
63
|
+
return {
|
|
64
|
+
model,
|
|
65
|
+
fallbacks: fallbacks.map((item, i) => setting(item, `modelConfig.fallbacks[${i}]`)),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Maps the durable session event stream onto OTel traces / metrics / logs.
|
|
3
3
|
*
|
|
4
4
|
* Attribute names reuse Cursor enterprise wire keys where they overlap
|
|
5
|
-
* (`cursor.conversation.id`, `cursor.token.*`, `cursor.tool
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* (`cursor.conversation.id`, `cursor.token.*`, `cursor.tool.*`) so Agent SDK
|
|
6
|
+
* traces join org metrics/logs in the same collector. Agent-SDK-only fields
|
|
7
|
+
* use `agent_sdk.*`.
|
|
8
8
|
*/
|
|
9
9
|
import type { SessionEvent, SessionInfo } from "../../types.js";
|
|
10
10
|
import { type AttrValue } from "./attrs.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/internal/otel/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/internal/otel/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACzD,KAAK,IAAI,IAAI,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1E;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1E,0FAA0F;IAC1F,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IAC7D,yEAAyE;IACzE,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;IACrF,mEAAmE;IACnE,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;CAChF;AAiBD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC1B,aAAa,CA2xBf"}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* Maps the durable session event stream onto OTel traces / metrics / logs.
|
|
3
3
|
*
|
|
4
4
|
* Attribute names reuse Cursor enterprise wire keys where they overlap
|
|
5
|
-
* (`cursor.conversation.id`, `cursor.token.*`, `cursor.tool
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* (`cursor.conversation.id`, `cursor.token.*`, `cursor.tool.*`) so Agent SDK
|
|
6
|
+
* traces join org metrics/logs in the same collector. Agent-SDK-only fields
|
|
7
|
+
* use `agent_sdk.*`.
|
|
8
8
|
*/
|
|
9
9
|
import { context, ROOT_CONTEXT, SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
|
|
10
10
|
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
11
11
|
import { classifyExpectedDeliveryFailure } from "../expected-delivery-failure.js";
|
|
12
12
|
import { attrs } from "./attrs.js";
|
|
13
|
+
import { computerUseRequestAttrs, computerUseResultAttrs } from "./computer-use-attrs.js";
|
|
13
14
|
const CONTENT_MAX = 2_048;
|
|
14
15
|
export function createOtelCollector(runtime, agentName, log) {
|
|
15
16
|
const sessions = new Map();
|
|
@@ -206,6 +207,7 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
206
207
|
const status = event.data.isError ? "failure" : "success";
|
|
207
208
|
if (span !== undefined) {
|
|
208
209
|
span.setAttribute("cursor.tool.status", status);
|
|
210
|
+
span.setAttributes(attrs(computerUseResultAttrs(event.data.toolName, event.data.output)));
|
|
209
211
|
if (logOpts?.toolContent === true && event.data.output !== undefined) {
|
|
210
212
|
span.setAttribute("agent_sdk.tool_output", truncate(json(event.data.output)));
|
|
211
213
|
}
|
|
@@ -300,7 +302,6 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
300
302
|
}
|
|
301
303
|
endOpenChildren(turn, startTime);
|
|
302
304
|
const usage = event.data.usage;
|
|
303
|
-
const cost = event.data.cost;
|
|
304
305
|
if (usage !== undefined) {
|
|
305
306
|
turn.span.setAttributes(attrs({
|
|
306
307
|
"agent_sdk.usage.input_tokens": usage.inputTokens,
|
|
@@ -311,17 +312,6 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
311
312
|
}));
|
|
312
313
|
recordTokens(event.sessionId, usage);
|
|
313
314
|
}
|
|
314
|
-
if (cost !== undefined) {
|
|
315
|
-
turn.span.setAttributes(attrs({
|
|
316
|
-
"cursor.model.name": cost.model,
|
|
317
|
-
"agent_sdk.cost_usd": cost.totalUsd,
|
|
318
|
-
"agent_sdk.cost_source": cost.source,
|
|
319
|
-
}));
|
|
320
|
-
metrics?.cost.add(cost.totalUsd, join(event.sessionId, {
|
|
321
|
-
"cursor.model.name": cost.model,
|
|
322
|
-
"agent_sdk.agent": agentName,
|
|
323
|
-
}));
|
|
324
|
-
}
|
|
325
315
|
turn.span.setStatus({ code: SpanStatusCode.OK });
|
|
326
316
|
turn.span.end(startTime);
|
|
327
317
|
sessions.get(event.sessionId)?.turns.delete(event.turnId);
|
|
@@ -333,8 +323,6 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
333
323
|
...baseLog(event, session),
|
|
334
324
|
"agent_sdk.usage.input_tokens": usage?.inputTokens,
|
|
335
325
|
"agent_sdk.usage.output_tokens": usage?.outputTokens,
|
|
336
|
-
"agent_sdk.cost_usd": cost?.totalUsd,
|
|
337
|
-
"cursor.model.name": cost?.model,
|
|
338
326
|
}));
|
|
339
327
|
return;
|
|
340
328
|
}
|
|
@@ -476,6 +464,7 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
476
464
|
return trace.setSpan(context.active(), turn.span);
|
|
477
465
|
}
|
|
478
466
|
function openToolSpan(args) {
|
|
467
|
+
const computerUseAttrs = computerUseRequestAttrs(args.call.toolName, args.call.args);
|
|
479
468
|
const existing = args.turn.tools.get(args.call.callId);
|
|
480
469
|
if (existing !== undefined) {
|
|
481
470
|
// Early `runInCall` opens with callId/toolName only. Fill in
|
|
@@ -483,6 +472,7 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
483
472
|
// The OTel parent is fixed at start; `parent_call_id` still records
|
|
484
473
|
// the event-stream hierarchy for nested/subagent calls.
|
|
485
474
|
existing.setAttributes(join(args.sessionId, {
|
|
475
|
+
...computerUseAttrs,
|
|
486
476
|
"agent_sdk.parent_call_id": args.parentCallId ?? args.call.parentCallId,
|
|
487
477
|
"agent_sdk.tool_args": logOpts?.toolContent === true && args.call.args !== undefined
|
|
488
478
|
? truncate(json(args.call.args))
|
|
@@ -504,6 +494,7 @@ export function createOtelCollector(runtime, agentName, log) {
|
|
|
504
494
|
"agent_sdk.tool_args": logOpts?.toolContent === true && args.call.args !== undefined
|
|
505
495
|
? truncate(json(args.call.args))
|
|
506
496
|
: undefined,
|
|
497
|
+
...computerUseAttrs,
|
|
507
498
|
}),
|
|
508
499
|
}, parentCtxFor(args.turn, args.parentCallId ?? args.call.parentCallId));
|
|
509
500
|
args.turn.tools.set(args.call.callId, span);
|
|
@@ -668,10 +659,6 @@ function buildMetrics(meter) {
|
|
|
668
659
|
description: "Token usage by type",
|
|
669
660
|
unit: "{token}",
|
|
670
661
|
}),
|
|
671
|
-
cost: meter.createCounter("cursor.cost.usage", {
|
|
672
|
-
description: "Estimated turn cost in USD",
|
|
673
|
-
unit: "USD",
|
|
674
|
-
}),
|
|
675
662
|
};
|
|
676
663
|
}
|
|
677
664
|
function truncate(value) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-free span attributes for `computerUse` tool calls.
|
|
3
|
+
*
|
|
4
|
+
* Computer use args hold typed text and screen coordinates, so the collector
|
|
5
|
+
* exports them only under `toolContent`. These attributes keep the batch
|
|
6
|
+
* shape visible without that opt-in.
|
|
7
|
+
*/
|
|
8
|
+
import type { AttrValue } from "./attrs.js";
|
|
9
|
+
type Attrs = Record<string, AttrValue | undefined>;
|
|
10
|
+
export declare function computerUseRequestAttrs(toolName: string, args: unknown): Attrs;
|
|
11
|
+
export declare function computerUseResultAttrs(toolName: string, output: unknown): Attrs;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=computer-use-attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computer-use-attrs.d.ts","sourceRoot":"","sources":["../../../src/internal/otel/computer-use-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;AAEnD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,CAa9E;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,CAU/E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-free span attributes for `computerUse` tool calls.
|
|
3
|
+
*
|
|
4
|
+
* Computer use args hold typed text and screen coordinates, so the collector
|
|
5
|
+
* exports them only under `toolContent`. These attributes keep the batch
|
|
6
|
+
* shape visible without that opt-in.
|
|
7
|
+
*/
|
|
8
|
+
import { isRecord } from "../is-record.js";
|
|
9
|
+
export function computerUseRequestAttrs(toolName, args) {
|
|
10
|
+
if (toolName !== "computerUse" || !isRecord(args) || !Array.isArray(args.actions)) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
// The SDK adapter emits only known action types, so `type` is a fixed
|
|
14
|
+
// literal and carries no content.
|
|
15
|
+
const types = args.actions.map((action) => isRecord(action) && typeof action.type === "string" ? action.type : "other");
|
|
16
|
+
return {
|
|
17
|
+
"agent_sdk.computer.action_count": types.length,
|
|
18
|
+
"agent_sdk.computer.actions": types.join(","),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function computerUseResultAttrs(toolName, output) {
|
|
22
|
+
if (toolName !== "computerUse" || !isRecord(output)) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
"agent_sdk.computer.completed_action_count": typeof output.actionCount === "number" ? output.actionCount : undefined,
|
|
27
|
+
"agent_sdk.computer.executor_duration_ms": typeof output.durationMs === "number" ? output.durationMs : undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* server URL. Cloud-runtime turns run on a VM that cannot reach loopback,
|
|
10
10
|
* so they use the serve `publicUrl` when configured — and omit the peer
|
|
11
11
|
* (with a startup warning) when it is not.
|
|
12
|
+
*
|
|
13
|
+
* A single-agent serve has no peers mounted beside it. Given a peers URL,
|
|
14
|
+
* it resolves every peer there for both runtimes instead of omitting them.
|
|
12
15
|
*/
|
|
13
16
|
import { type AgentProject } from "../types.js";
|
|
14
17
|
import type { EngineResolvedConnection } from "./session-engine.js";
|
|
@@ -21,23 +24,19 @@ export interface PeerConnectionRef {
|
|
|
21
24
|
}
|
|
22
25
|
/** Every peer connection an agent declares, host connections included. */
|
|
23
26
|
export declare function peerConnectionRefs(project: AgentProject): PeerConnectionRef[];
|
|
24
|
-
/**
|
|
25
|
-
* Deploy slugs of every peer an agent declares, deduped and sorted.
|
|
26
|
-
* `bdk deploy` lowercases directory names into slugs, so
|
|
27
|
-
* `{ agent: "Builder" }` names the `builder` deployment.
|
|
28
|
-
*/
|
|
27
|
+
/** Deploy slugs of every peer an agent declares, deduped and sorted. */
|
|
29
28
|
export declare function peerDeploySlugs(project: AgentProject): string[];
|
|
30
29
|
/**
|
|
31
30
|
* Validate every peer MCP connection across `mounts` and return them grouped by
|
|
32
31
|
* the referencing mount's slug. Throws on references to unknown slugs and on
|
|
33
32
|
* self-references (an agent asking itself recurses forever). A single-mode
|
|
34
|
-
* serve
|
|
35
|
-
* omitted with a warning instead of failing boot.
|
|
33
|
+
* serve mounts no other agents: with a `peersUrl` its peers resolve there,
|
|
34
|
+
* and without one they are omitted with a warning instead of failing boot.
|
|
36
35
|
*/
|
|
37
36
|
export declare function collectPeerConnections(mounts: Array<{
|
|
38
37
|
slug: string;
|
|
39
38
|
project: AgentProject;
|
|
40
|
-
}>, logger: (line: string) => void): Map<string, PeerConnectionRef[]>;
|
|
39
|
+
}>, logger: (line: string) => void, peersUrl?: string): Map<string, PeerConnectionRef[]>;
|
|
41
40
|
/**
|
|
42
41
|
* Resolve validated peer refs to concrete MCP URLs once the server is
|
|
43
42
|
* listening. `serverUrl` is the loopback base (`http://127.0.0.1:<port>`);
|
|
@@ -51,4 +50,14 @@ export declare function resolvePeerConnections(args: {
|
|
|
51
50
|
publicUrl?: string;
|
|
52
51
|
authToken?: string;
|
|
53
52
|
}): EngineResolvedConnection[];
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a single-agent serve's peers against a host that serves each agent
|
|
55
|
+
* at `<peersUrl>/<slug>/v1/mcp`. Local and cloud turns share the URL. The
|
|
56
|
+
* bearer is the Cursor API key bound to this host, expanded each time a
|
|
57
|
+
* client opens, so a key bound after listen still authenticates.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveHostedPeerConnections(args: {
|
|
60
|
+
refs: PeerConnectionRef[];
|
|
61
|
+
peersUrl: string;
|
|
62
|
+
}): EngineResolvedConnection[];
|
|
54
63
|
//# sourceMappingURL=peer-connections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-connections.d.ts","sourceRoot":"","sources":["../../src/internal/peer-connections.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"peer-connections.d.ts","sourceRoot":"","sources":["../../src/internal/peer-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,YAAY,EAA6B,MAAM,aAAa,CAAC;AAE3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,EAAE,CAK7E;AAUD,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,CAG/D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,EACtD,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAyClC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,wBAAwB,EAAE,CAa7B;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,wBAAwB,EAAE,CAW7B"}
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* server URL. Cloud-runtime turns run on a VM that cannot reach loopback,
|
|
10
10
|
* so they use the serve `publicUrl` when configured — and omit the peer
|
|
11
11
|
* (with a startup warning) when it is not.
|
|
12
|
+
*
|
|
13
|
+
* A single-agent serve has no peers mounted beside it. Given a peers URL,
|
|
14
|
+
* it resolves every peer there for both runtimes instead of omitting them.
|
|
12
15
|
*/
|
|
13
16
|
import { isPeerConnectionTransport } from "../types.js";
|
|
14
17
|
import { MCP_ENDPOINT_PATH } from "./mcp-endpoint.js";
|
|
@@ -17,30 +20,40 @@ export function peerConnectionRefs(project) {
|
|
|
17
20
|
return [...project.agent.connections, ...(project.agent.hostConnections ?? [])].flatMap(({ name, transport }) => isPeerConnectionTransport(transport) ? [{ name, targetSlug: transport.agent }] : []);
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `{ agent: "Builder" }` names the `builder` deployment.
|
|
23
|
+
* The slug a deployed peer answers to. `bdk deploy` lowercases directory
|
|
24
|
+
* names into slugs, so `{ agent: "Builder" }` names the `builder` deployment.
|
|
23
25
|
*/
|
|
26
|
+
function peerDeploySlug(targetSlug) {
|
|
27
|
+
return targetSlug.toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
/** Deploy slugs of every peer an agent declares, deduped and sorted. */
|
|
24
30
|
export function peerDeploySlugs(project) {
|
|
25
|
-
const slugs = peerConnectionRefs(project).map(({ targetSlug }) => targetSlug
|
|
31
|
+
const slugs = peerConnectionRefs(project).map(({ targetSlug }) => peerDeploySlug(targetSlug));
|
|
26
32
|
return [...new Set(slugs)].sort();
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Validate every peer MCP connection across `mounts` and return them grouped by
|
|
30
36
|
* the referencing mount's slug. Throws on references to unknown slugs and on
|
|
31
37
|
* self-references (an agent asking itself recurses forever). A single-mode
|
|
32
|
-
* serve
|
|
33
|
-
* omitted with a warning instead of failing boot.
|
|
38
|
+
* serve mounts no other agents: with a `peersUrl` its peers resolve there,
|
|
39
|
+
* and without one they are omitted with a warning instead of failing boot.
|
|
34
40
|
*/
|
|
35
|
-
export function collectPeerConnections(mounts, logger) {
|
|
41
|
+
export function collectPeerConnections(mounts, logger, peersUrl) {
|
|
36
42
|
const [solo] = mounts;
|
|
37
43
|
if (mounts.length === 1 && solo?.slug === "") {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
44
|
+
const refs = peerConnectionRefs(solo.project);
|
|
45
|
+
if (refs.length === 0) {
|
|
46
|
+
return new Map();
|
|
41
47
|
}
|
|
48
|
+
if (peersUrl !== undefined) {
|
|
49
|
+
return new Map([["", refs]]);
|
|
50
|
+
}
|
|
51
|
+
logger(`[bdk] warning: agent "${solo.project.name}" has peer MCP connections (${refs.map(({ name }) => name).join(", ")}) but --mode single mounts no other agents, so they are omitted; peers resolve only in multi-agent serve.`);
|
|
42
52
|
return new Map();
|
|
43
53
|
}
|
|
54
|
+
if (peersUrl !== undefined) {
|
|
55
|
+
throw new Error("--peers-url resolves the peers of a single-agent serve (--mode single); a multi-agent serve resolves them among its mounted agents.");
|
|
56
|
+
}
|
|
44
57
|
const knownSlugs = new Set(mounts.map(({ slug }) => slug));
|
|
45
58
|
const bySlug = new Map();
|
|
46
59
|
for (const { slug, project } of mounts) {
|
|
@@ -79,6 +92,24 @@ export function resolvePeerConnections(args) {
|
|
|
79
92
|
...(headers === undefined ? {} : { headers }),
|
|
80
93
|
}));
|
|
81
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolve a single-agent serve's peers against a host that serves each agent
|
|
97
|
+
* at `<peersUrl>/<slug>/v1/mcp`. Local and cloud turns share the URL. The
|
|
98
|
+
* bearer is the Cursor API key bound to this host, expanded each time a
|
|
99
|
+
* client opens, so a key bound after listen still authenticates.
|
|
100
|
+
*/
|
|
101
|
+
export function resolveHostedPeerConnections(args) {
|
|
102
|
+
const base = trimTrailingSlash(args.peersUrl);
|
|
103
|
+
return args.refs.map((ref) => {
|
|
104
|
+
const url = `${base}/${peerDeploySlug(ref.targetSlug)}${MCP_ENDPOINT_PATH}`;
|
|
105
|
+
return {
|
|
106
|
+
name: ref.name,
|
|
107
|
+
localUrl: url,
|
|
108
|
+
cloudUrl: url,
|
|
109
|
+
headers: { authorization: "Bearer ${CURSOR_API_KEY}" },
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
82
113
|
function trimTrailingSlash(url) {
|
|
83
114
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
84
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-error-status.d.ts","sourceRoot":"","sources":["../../src/internal/request-error-status.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"request-error-status.d.ts","sourceRoot":"","sources":["../../src/internal/request-error-status.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,2BAA2B,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAkEpF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElE"}
|