@cursor/july 0.1.101 → 0.1.102
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/README.md +27 -0
- package/dist/channels/slack/api.d.ts +1 -1
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +3 -1
- package/dist/channels/slack/assistant.d.ts +1 -1
- package/dist/channels/slack/assistant.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.d.ts +3 -2
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +28 -8
- package/dist/channels/slack/inbound.d.ts +8 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +28 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +2 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.BASO9Kih.js → app.CLA03RCz.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.FAqdWIXo.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DwkqxoE0.js → VPLocalSearchBox.ifxv-cJV.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CCil_13e.js → theme.DWCwM6p-.js} +2 -2
- package/dist/docs/assets/concepts.md.rPzW2HZN.js +1 -0
- package/dist/docs/assets/guides_cloud-agents.md.DumwWXba.js +9 -0
- package/dist/docs/assets/guides_cloud-agents.md.DumwWXba.lean.js +1 -0
- package/dist/docs/assets/{guides_cloud-runtime.md.CkYbjnAX.js → guides_cloud-runtime.md.BRirbRAN.js} +1 -1
- package/dist/docs/assets/index.md.Kiht7ell.js +5 -0
- package/dist/docs/assets/{index.md.Bb4k8kUm.lean.js → index.md.Kiht7ell.lean.js} +1 -1
- package/dist/docs/assets/reference_extensions.md.9WQMZe1l.js +56 -0
- package/dist/docs/assets/reference_extensions.md.9WQMZe1l.lean.js +1 -0
- package/dist/docs/assets/{reference_project-layout.md.Bv4KOtlB.js → reference_project-layout.md.CA6QP6Lw.js} +2 -2
- package/dist/docs/assets/{reference_project-layout.md.Bv4KOtlB.lean.js → reference_project-layout.md.CA6QP6Lw.lean.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.BFW9retM.js → reference_skills.md.l2ezAcaN.js} +1 -1
- package/dist/docs/assets/{reference_tools.md.CvAHsdSp.js → reference_tools.md.B1up2r9W.js} +1 -1
- package/dist/docs/assets/skills_framework-map.md.DDa4MeEW.js +1 -0
- package/dist/docs/assets/{skills_framework-map.md.BTi817yv.lean.js → skills_framework-map.md.DDa4MeEW.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +5 -5
- package/dist/docs/concepts.md +3 -3
- package/dist/docs/deployment.html +4 -4
- package/dist/docs/evals.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-agents.html +35 -0
- package/dist/docs/guides/cloud-agents.md +93 -0
- package/dist/docs/guides/cloud-runtime.html +6 -6
- package/dist/docs/guides/cloud-runtime.md +2 -0
- package/dist/docs/guides/convert-automation.html +4 -4
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +4 -4
- package/dist/docs/guides/opentelemetry.html +5 -5
- package/dist/docs/guides/slack.html +4 -4
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +6 -6
- package/dist/docs/index.md +5 -1
- package/dist/docs/llms-full.txt +321 -4
- package/dist/docs/llms.txt +2 -0
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/artifacts.html +4 -4
- package/dist/docs/reference/channels.html +5 -5
- package/dist/docs/reference/cli.html +4 -4
- package/dist/docs/reference/connections.html +4 -4
- package/dist/docs/reference/extensions.html +82 -0
- package/dist/docs/reference/extensions.md +200 -0
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +4 -4
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +6 -6
- package/dist/docs/reference/project-layout.md +3 -0
- package/dist/docs/reference/prompt.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +6 -6
- package/dist/docs/reference/skills.md +2 -0
- package/dist/docs/reference/subagents.html +5 -5
- package/dist/docs/reference/tools.html +6 -6
- package/dist/docs/reference/tools.md +2 -0
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/skills/ab.html +4 -4
- package/dist/docs/skills/create-agent.html +4 -4
- package/dist/docs/skills/debug.html +4 -4
- package/dist/docs/skills/evals.html +4 -4
- package/dist/docs/skills/framework-map.html +5 -5
- package/dist/docs/skills/framework-map.md +1 -0
- package/dist/docs/skills/github.html +4 -4
- package/dist/docs/skills/hillclimb.html +4 -4
- package/dist/docs/skills/index.html +4 -4
- package/dist/docs/skills/mcp-auth.html +4 -4
- package/dist/docs/skills/otel.html +4 -4
- package/dist/docs/skills/setup-slack.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +4 -4
- package/dist/docs/templates/agents-md.html +4 -4
- package/dist/docs/templates/code-wiki.html +4 -4
- package/dist/docs/templates/demo.html +4 -4
- package/dist/docs/templates/pr-autofixer.html +4 -4
- package/dist/docs/templates/security-help.html +4 -4
- package/dist/docs/templates/security-reviewer.html +4 -4
- package/dist/docs/templates/triage.html +4 -4
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/extensions/cursor-cloud-agents/extension.d.ts +9 -7
- package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/extension.js +9 -7
- package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts +78 -0
- package/dist/extensions/cursor-cloud-agents/lib/backend.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/lib/backend.js +286 -0
- package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts +5 -0
- package/dist/extensions/cursor-cloud-agents/lib/inputs.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/lib/inputs.js +4 -0
- package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts +8 -0
- package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/lib/transcript.js +15 -0
- package/dist/extensions/cursor-cloud-agents/skills/handoff.md +21 -7
- package/dist/extensions/cursor-cloud-agents/tools/cancel.d.ts +4 -0
- package/dist/extensions/cursor-cloud-agents/tools/cancel.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/tools/cancel.js +26 -0
- package/dist/extensions/cursor-cloud-agents/tools/dump.d.ts +4 -0
- package/dist/extensions/cursor-cloud-agents/tools/dump.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/tools/dump.js +54 -0
- package/dist/extensions/cursor-cloud-agents/tools/get.d.ts +4 -0
- package/dist/extensions/cursor-cloud-agents/tools/get.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/tools/get.js +25 -0
- package/dist/extensions/cursor-cloud-agents/tools/launch.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/tools/launch.js +14 -38
- package/dist/extensions/cursor-cloud-agents/tools/list.js +1 -1
- package/dist/extensions/cursor-cloud-agents/tools/reply.d.ts +4 -0
- package/dist/extensions/cursor-cloud-agents/tools/reply.d.ts.map +1 -0
- package/dist/extensions/cursor-cloud-agents/tools/{follow_up.js → reply.js} +12 -14
- package/dist/extensions.d.ts +38 -14
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +49 -12
- package/dist/files-backends/cursor-hosted.d.ts +0 -8
- package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/files-backends/cursor-hosted.js +1 -11
- package/dist/files.d.ts +5 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +22 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal/conversation-mirror.d.ts.map +1 -1
- package/dist/internal/conversation-mirror.js +13 -15
- package/dist/internal/cursor/backend-client.d.ts +8 -1
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +25 -9
- package/dist/internal/cursor/hosted-store-secrets.d.ts +11 -0
- package/dist/internal/cursor/hosted-store-secrets.d.ts.map +1 -1
- package/dist/internal/cursor/hosted-store-secrets.js +15 -0
- package/dist/internal/discovery/ab.d.ts +9 -0
- package/dist/internal/discovery/ab.d.ts.map +1 -0
- package/dist/internal/discovery/ab.js +101 -0
- package/dist/internal/discovery/agent-config.d.ts +35 -0
- package/dist/internal/discovery/agent-config.d.ts.map +1 -0
- package/dist/internal/discovery/agent-config.js +173 -0
- package/dist/internal/discovery/agent.d.ts +11 -0
- package/dist/internal/discovery/agent.d.ts.map +1 -0
- package/dist/internal/discovery/agent.js +306 -0
- package/dist/internal/discovery/channels.d.ts +10 -0
- package/dist/internal/discovery/channels.d.ts.map +1 -0
- package/dist/internal/discovery/channels.js +97 -0
- package/dist/internal/discovery/connections.d.ts +17 -0
- package/dist/internal/discovery/connections.d.ts.map +1 -0
- package/dist/internal/discovery/connections.js +436 -0
- package/dist/internal/discovery/context.d.ts +20 -0
- package/dist/internal/discovery/context.d.ts.map +1 -0
- package/dist/internal/discovery/context.js +30 -0
- package/dist/internal/discovery/cursor-plugin.d.ts +25 -0
- package/dist/internal/discovery/cursor-plugin.d.ts.map +1 -0
- package/dist/internal/discovery/cursor-plugin.js +570 -0
- package/dist/internal/discovery/extensions.d.ts +19 -0
- package/dist/internal/discovery/extensions.d.ts.map +1 -0
- package/dist/internal/discovery/extensions.js +238 -0
- package/dist/internal/discovery/fs.d.ts +15 -0
- package/dist/internal/discovery/fs.d.ts.map +1 -0
- package/dist/internal/discovery/fs.js +115 -0
- package/dist/internal/discovery/hooks.d.ts +7 -0
- package/dist/internal/discovery/hooks.d.ts.map +1 -0
- package/dist/internal/discovery/hooks.js +48 -0
- package/dist/internal/discovery/info.d.ts +6 -0
- package/dist/internal/discovery/info.d.ts.map +1 -0
- package/dist/internal/discovery/info.js +141 -0
- package/dist/internal/discovery/instructions.d.ts +7 -0
- package/dist/internal/discovery/instructions.d.ts.map +1 -0
- package/dist/internal/discovery/instructions.js +95 -0
- package/dist/internal/discovery/modules.d.ts +20 -0
- package/dist/internal/discovery/modules.d.ts.map +1 -0
- package/dist/internal/discovery/modules.js +101 -0
- package/dist/internal/discovery/names.d.ts +12 -0
- package/dist/internal/discovery/names.d.ts.map +1 -0
- package/dist/internal/discovery/names.js +36 -0
- package/dist/internal/discovery/project.d.ts +53 -0
- package/dist/internal/discovery/project.d.ts.map +1 -0
- package/dist/internal/discovery/project.js +239 -0
- package/dist/internal/discovery/runtime.d.ts +34 -0
- package/dist/internal/discovery/runtime.d.ts.map +1 -0
- package/dist/internal/discovery/runtime.js +98 -0
- package/dist/internal/discovery/schedules.d.ts +7 -0
- package/dist/internal/discovery/schedules.d.ts.map +1 -0
- package/dist/internal/discovery/schedules.js +97 -0
- package/dist/internal/discovery/seed-files.d.ts +7 -0
- package/dist/internal/discovery/seed-files.d.ts.map +1 -0
- package/dist/internal/discovery/seed-files.js +41 -0
- package/dist/internal/discovery/services.d.ts +17 -0
- package/dist/internal/discovery/services.d.ts.map +1 -0
- package/dist/internal/discovery/services.js +104 -0
- package/dist/internal/discovery/skills.d.ts +16 -0
- package/dist/internal/discovery/skills.d.ts.map +1 -0
- package/dist/internal/discovery/skills.js +151 -0
- package/dist/internal/discovery/subagent.d.ts +13 -0
- package/dist/internal/discovery/subagent.d.ts.map +1 -0
- package/dist/internal/discovery/subagent.js +19 -0
- package/dist/internal/discovery/tools.d.ts +18 -0
- package/dist/internal/discovery/tools.d.ts.map +1 -0
- package/dist/internal/discovery/tools.js +159 -0
- package/dist/internal/discovery.d.ts +8 -62
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +8 -2505
- package/dist/internal/framework-file-storage.js +6 -6
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +8 -7
- package/dist/internal/frontmatter.d.ts +11 -3
- package/dist/internal/frontmatter.d.ts.map +1 -1
- package/dist/internal/frontmatter.js +29 -3
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +37 -20
- package/dist/internal/otel/collector.d.ts +13 -0
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +84 -17
- package/dist/internal/otel/http.d.ts.map +1 -1
- package/dist/internal/otel/http.js +2 -10
- package/dist/internal/otel/mcp.d.ts +16 -0
- package/dist/internal/otel/mcp.d.ts.map +1 -0
- package/dist/internal/otel/mcp.js +68 -0
- package/dist/internal/otel/propagation.d.ts +6 -0
- package/dist/internal/otel/propagation.d.ts.map +1 -0
- package/dist/internal/otel/propagation.js +14 -0
- package/dist/internal/otel/runtime.d.ts.map +1 -1
- package/dist/internal/otel/runtime.js +2 -0
- package/dist/internal/session-engine.d.ts +5 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +68 -32
- package/dist/internal/session-run-log.d.ts +2 -1
- package/dist/internal/session-run-log.d.ts.map +1 -1
- package/dist/internal/session-run-log.js +13 -14
- package/dist/internal/start-log-store.d.ts +1 -1
- package/dist/internal/start-log-store.d.ts.map +1 -1
- package/dist/internal/start-log-store.js +12 -14
- package/dist/internal/storage-coordinator.d.ts +4 -1
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +15 -13
- package/dist/internal/tool-catalog.d.ts.map +1 -1
- package/dist/internal/tool-catalog.js +9 -6
- package/dist/internal/turn-cost.d.ts +14 -0
- package/dist/internal/turn-cost.d.ts.map +1 -1
- package/dist/internal/turn-cost.js +41 -9
- package/dist/internal/v2-hosting.d.ts +22 -0
- package/dist/internal/v2-hosting.d.ts.map +1 -0
- package/dist/internal/v2-hosting.js +23 -0
- package/dist/otel.d.ts +16 -0
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +26 -0
- package/dist/playground/assets/index-B6C9S9nG.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-protocol.d.ts +24 -23
- package/dist/storage-protocol.d.ts.map +1 -1
- package/dist/storage-protocol.js +68 -65
- package/dist/storage.d.ts +2 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -1
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +9 -0
- package/dist/types.d.ts +39 -3
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +5 -1
- package/docs/concepts.md +3 -3
- package/docs/guides/cloud-agents.md +98 -0
- package/docs/guides/cloud-runtime.md +2 -0
- package/docs/reference/extensions.md +205 -0
- package/docs/reference/project-layout.md +3 -0
- package/docs/reference/skills.md +2 -0
- package/docs/reference/tools.md +2 -0
- package/package.json +1 -1
- package/skills/framework-map/SKILL.md +1 -0
- package/src/channels/slack/api.ts +4 -2
- package/src/channels/slack/assistant.ts +1 -1
- package/src/channels/slack/dispatch.ts +27 -2
- package/src/channels/slack/inbound.ts +37 -0
- package/src/channels/slack/manifest.ts +2 -1
- package/src/extensions/cursor-cloud-agents/extension.ts +9 -7
- package/src/extensions/cursor-cloud-agents/lib/backend.ts +395 -0
- package/src/extensions/cursor-cloud-agents/lib/inputs.ts +5 -0
- package/src/extensions/cursor-cloud-agents/lib/transcript.ts +23 -0
- package/src/extensions/cursor-cloud-agents/skills/handoff.md +21 -7
- package/src/extensions/cursor-cloud-agents/tools/cancel.ts +19 -0
- package/src/extensions/cursor-cloud-agents/tools/dump.ts +51 -0
- package/src/extensions/cursor-cloud-agents/tools/get.ts +18 -0
- package/src/extensions/cursor-cloud-agents/tools/launch.ts +22 -42
- package/src/extensions/cursor-cloud-agents/tools/list.ts +1 -1
- package/src/extensions/cursor-cloud-agents/tools/reply.ts +34 -0
- package/src/extensions.ts +55 -12
- package/src/files-backends/cursor-hosted.ts +1 -17
- package/src/files.ts +43 -34
- package/src/index.ts +10 -1
- package/src/internal/conversation-mirror.ts +23 -18
- package/src/internal/cursor/backend-client.ts +32 -10
- package/src/internal/cursor/hosted-store-secrets.ts +27 -0
- package/src/internal/discovery/ab.ts +111 -0
- package/src/internal/discovery/agent-config.ts +222 -0
- package/src/internal/discovery/agent.ts +360 -0
- package/src/internal/discovery/channels.ts +103 -0
- package/src/internal/discovery/connections.ts +540 -0
- package/src/internal/discovery/context.ts +46 -0
- package/src/internal/discovery/cursor-plugin.ts +708 -0
- package/src/internal/discovery/extensions.ts +348 -0
- package/src/internal/discovery/fs.ts +108 -0
- package/src/internal/discovery/hooks.ts +45 -0
- package/src/internal/discovery/info.ts +179 -0
- package/src/internal/discovery/instructions.ts +113 -0
- package/src/internal/discovery/modules.ts +107 -0
- package/src/internal/discovery/names.ts +44 -0
- package/src/internal/discovery/project.ts +270 -0
- package/src/internal/discovery/runtime.ts +159 -0
- package/src/internal/discovery/schedules.ts +94 -0
- package/src/internal/discovery/seed-files.ts +37 -0
- package/src/internal/discovery/services.ts +124 -0
- package/src/internal/discovery/skills.ts +176 -0
- package/src/internal/discovery/subagent.ts +29 -0
- package/src/internal/discovery/tools.ts +182 -0
- package/src/internal/discovery.ts +20 -3081
- package/src/internal/framework-file-storage.ts +6 -6
- package/src/internal/framework-storage-selection.ts +9 -9
- package/src/internal/frontmatter.ts +36 -3
- package/src/internal/mcp-host.ts +84 -31
- package/src/internal/otel/collector.ts +125 -25
- package/src/internal/otel/http.ts +2 -12
- package/src/internal/otel/mcp.ts +69 -0
- package/src/internal/otel/propagation.ts +17 -0
- package/src/internal/otel/runtime.ts +2 -0
- package/src/internal/session-engine.ts +96 -11
- package/src/internal/session-run-log.ts +17 -16
- package/src/internal/start-log-store.ts +13 -16
- package/src/internal/storage-coordinator.ts +19 -16
- package/src/internal/tool-catalog.ts +9 -6
- package/src/internal/turn-cost.ts +47 -4
- package/src/internal/v2-hosting.ts +38 -0
- package/src/otel.ts +38 -0
- package/src/storage-protocol.ts +101 -91
- package/src/storage.ts +4 -0
- package/src/tools.ts +18 -0
- package/src/types.ts +43 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.DbFXINq2.js +0 -1
- package/dist/docs/assets/concepts.md.lwAgBIMI.js +0 -1
- package/dist/docs/assets/index.md.Bb4k8kUm.js +0 -5
- package/dist/docs/assets/skills_framework-map.md.BTi817yv.js +0 -1
- package/dist/extensions/cursor-cloud-agents/lib/cloud.d.ts +0 -30
- package/dist/extensions/cursor-cloud-agents/lib/cloud.d.ts.map +0 -1
- package/dist/extensions/cursor-cloud-agents/lib/cloud.js +0 -45
- package/dist/extensions/cursor-cloud-agents/tools/follow_up.d.ts +0 -4
- package/dist/extensions/cursor-cloud-agents/tools/follow_up.d.ts.map +0 -1
- package/dist/extensions/cursor-cloud-agents/tools/status.d.ts +0 -4
- package/dist/extensions/cursor-cloud-agents/tools/status.d.ts.map +0 -1
- package/dist/extensions/cursor-cloud-agents/tools/status.js +0 -41
- package/dist/playground/assets/index-DBQCwFp0.css +0 -1
- package/src/extensions/cursor-cloud-agents/lib/cloud.ts +0 -79
- package/src/extensions/cursor-cloud-agents/tools/follow_up.ts +0 -29
- package/src/extensions/cursor-cloud-agents/tools/status.ts +0 -39
- /package/dist/docs/assets/{concepts.md.lwAgBIMI.lean.js → concepts.md.rPzW2HZN.lean.js} +0 -0
- /package/dist/docs/assets/{guides_cloud-runtime.md.CkYbjnAX.lean.js → guides_cloud-runtime.md.BRirbRAN.lean.js} +0 -0
- /package/dist/docs/assets/{reference_skills.md.BFW9retM.lean.js → reference_skills.md.l2ezAcaN.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.CvAHsdSp.lean.js → reference_tools.md.B1up2r9W.lean.js} +0 -0
- /package/dist/playground/assets/{index-BnNN1-EK.js → index-ZqNoT8Ie.js} +0 -0
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
import type { FileSink } from "../files.js";
|
|
32
32
|
import type { StorageConfig, StorageEntry } from "../storage.js";
|
|
33
|
-
import {
|
|
33
|
+
import { AGENTSDK_STORAGE_KEY_ROOT } from "../storage-protocol.js";
|
|
34
34
|
import type { JsonValue } from "../types.js";
|
|
35
35
|
import { mapBounded } from "./bounded.js";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Key kinds (`
|
|
38
|
+
* Key kinds (`agentsdk/v1/{agent}/{kind}/…`) that live on the framework
|
|
39
39
|
* file store. Everything else stays on the KV sink.
|
|
40
40
|
*/
|
|
41
41
|
const FRAMEWORK_FILE_KINDS: ReadonlySet<string> = new Set([
|
|
@@ -52,10 +52,10 @@ const FRAMEWORK_FILE_KINDS: ReadonlySet<string> = new Set([
|
|
|
52
52
|
* kind-scoped (`…/{agent}/session/`), so a prefix routes wholly to one side.
|
|
53
53
|
*/
|
|
54
54
|
export function isFrameworkFileKey(key: string): boolean {
|
|
55
|
-
if (!key.startsWith(`${
|
|
55
|
+
if (!key.startsWith(`${AGENTSDK_STORAGE_KEY_ROOT}/`)) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
|
-
const rest = key.slice(
|
|
58
|
+
const rest = key.slice(AGENTSDK_STORAGE_KEY_ROOT.length + 1);
|
|
59
59
|
const agentEnd = rest.indexOf("/");
|
|
60
60
|
if (agentEnd === -1) {
|
|
61
61
|
return false;
|
|
@@ -153,10 +153,10 @@ export function fileSinkStorageCore(sink: FileSink): FileSinkStorageCore {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
function frameworkFileKind(key: string): string | undefined {
|
|
156
|
-
if (!key.startsWith(`${
|
|
156
|
+
if (!key.startsWith(`${AGENTSDK_STORAGE_KEY_ROOT}/`)) {
|
|
157
157
|
return undefined;
|
|
158
158
|
}
|
|
159
|
-
const rest = key.slice(
|
|
159
|
+
const rest = key.slice(AGENTSDK_STORAGE_KEY_ROOT.length + 1);
|
|
160
160
|
const agentEnd = rest.indexOf("/");
|
|
161
161
|
if (agentEnd === -1) {
|
|
162
162
|
return undefined;
|
|
@@ -42,20 +42,17 @@
|
|
|
42
42
|
* pod's filesystem.
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
import {
|
|
46
|
-
cursorFrameworkStoreSourceId,
|
|
47
|
-
cursorHostedFiles,
|
|
48
|
-
} from "../files-backends/cursor-hosted.js";
|
|
45
|
+
import { cursorHostedFiles } from "../files-backends/cursor-hosted.js";
|
|
49
46
|
import { defineStorage, type StorageDefinition } from "../storage.js";
|
|
50
47
|
import { cursorHostedStorageV2 } from "../storage-backends/cursor-hosted-v2.js";
|
|
51
48
|
import type { AgentArchitecture } from "../types.js";
|
|
52
49
|
import { resolveApiKeySync } from "./cursor/credentials.js";
|
|
53
|
-
import { AGENT_SERVE_GENERATION_ENV_VAR } from "./cursor-relay-core.js";
|
|
54
50
|
import {
|
|
55
51
|
composeFrameworkStorage,
|
|
56
52
|
fileSinkStorageCore,
|
|
57
53
|
frameworkGuardedCas,
|
|
58
54
|
} from "./framework-file-storage.js";
|
|
55
|
+
import { resolveAgentV2Hosting } from "./v2-hosting.js";
|
|
59
56
|
|
|
60
57
|
export interface FrameworkStorageSelectionInput {
|
|
61
58
|
/** `agent/storage.ts`, when the author wrote one (v1 only: discovery rejects it on v2). */
|
|
@@ -87,8 +84,11 @@ export function selectFrameworkStorageDefinition(
|
|
|
87
84
|
'defineStorage (agent/storage.ts) is not supported on architecture "v2": storage is platform-selected. Delete the file.'
|
|
88
85
|
);
|
|
89
86
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
87
|
+
const hosting = resolveAgentV2Hosting({
|
|
88
|
+
architecture: input.architecture,
|
|
89
|
+
env: input.env as NodeJS.ProcessEnv | undefined,
|
|
90
|
+
});
|
|
91
|
+
if (hosting.kind !== "cursor-managed") {
|
|
92
92
|
// Self-hosted v2: the state root is the durable copy.
|
|
93
93
|
return undefined;
|
|
94
94
|
}
|
|
@@ -98,7 +98,6 @@ export function selectFrameworkStorageDefinition(
|
|
|
98
98
|
// comes up). Follow-ups restore lazily by continuation or session id;
|
|
99
99
|
// GET /v1/sessions lists from the sink either way.
|
|
100
100
|
const policy = { restore: "off" } as const;
|
|
101
|
-
const envSnapshot = env as NodeJS.ProcessEnv;
|
|
102
101
|
// Full chain (env → bind file → stored login): frozen engines listen
|
|
103
102
|
// unsigned and bind store ids + CURSOR_API_KEY at task time, after this
|
|
104
103
|
// definition is constructed.
|
|
@@ -118,7 +117,8 @@ export function selectFrameworkStorageDefinition(
|
|
|
118
117
|
kv,
|
|
119
118
|
files: fileSinkStorageCore(
|
|
120
119
|
cursorHostedFiles({
|
|
121
|
-
resolveStoreSourceId: () =>
|
|
120
|
+
resolveStoreSourceId: () =>
|
|
121
|
+
hosting.resolveStoreIds().frameworkStoreSourceId,
|
|
122
122
|
resolveApiKey,
|
|
123
123
|
})
|
|
124
124
|
),
|
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Frontmatter parsers. Authored markdown (skill descriptions, schedule cron
|
|
3
|
+
* expressions) uses the flat `key: value` scalar subset; Cursor plugin
|
|
4
|
+
* markdown is full YAML (folded descriptions, lists).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { JSON_SCHEMA, load as parseYaml } from "js-yaml";
|
|
8
|
+
|
|
7
9
|
export interface ParsedFrontmatter {
|
|
8
10
|
data: Record<string, string>;
|
|
9
11
|
body: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
export interface ParsedYamlFrontmatter {
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
body: string;
|
|
17
|
+
/** Why the block did not parse as a YAML mapping; `data` is then empty. */
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
const FRONTMATTER_OPEN = /^---\s*$/;
|
|
22
|
+
const YAML_FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
|
|
23
|
+
|
|
24
|
+
/** YAML frontmatter with the JSON schema (no custom tags). */
|
|
25
|
+
export function parseYamlFrontmatter(source: string): ParsedYamlFrontmatter {
|
|
26
|
+
const match = YAML_FRONTMATTER.exec(source);
|
|
27
|
+
if (match === null) {
|
|
28
|
+
return { data: {}, body: source };
|
|
29
|
+
}
|
|
30
|
+
const body = match[2] ?? "";
|
|
31
|
+
let data: unknown;
|
|
32
|
+
try {
|
|
33
|
+
data = parseYaml(match[1] ?? "", { schema: JSON_SCHEMA });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
return { data: {}, body, error: message };
|
|
37
|
+
}
|
|
38
|
+
if (data === undefined || data === null) {
|
|
39
|
+
return { data: {}, body };
|
|
40
|
+
}
|
|
41
|
+
if (typeof data !== "object" || Array.isArray(data)) {
|
|
42
|
+
return { data: {}, body, error: "frontmatter is not a mapping" };
|
|
43
|
+
}
|
|
44
|
+
return { data: data as Record<string, unknown>, body };
|
|
45
|
+
}
|
|
13
46
|
|
|
14
47
|
export function parseFrontmatter(source: string): ParsedFrontmatter {
|
|
15
48
|
const lines = source.split(/\r?\n/);
|
package/src/internal/mcp-host.ts
CHANGED
|
@@ -26,6 +26,11 @@ import {
|
|
|
26
26
|
} from "../types.js";
|
|
27
27
|
import { CLI_COMMAND_NAME as CLI } from "./distribution.js";
|
|
28
28
|
import { createHostMcpOAuthProvider } from "./mcp-oauth.js";
|
|
29
|
+
import {
|
|
30
|
+
instrumentedMcpFetch,
|
|
31
|
+
mcpTraceMeta,
|
|
32
|
+
runMcpClientSpan,
|
|
33
|
+
} from "./otel/mcp.js";
|
|
29
34
|
|
|
30
35
|
export class McpNeedsAuthError extends Error {
|
|
31
36
|
readonly connection: string;
|
|
@@ -115,12 +120,16 @@ export class McpHost implements HostMcpRegistry {
|
|
|
115
120
|
|
|
116
121
|
async listTools(connectionName: string): Promise<HostMcpToolInfo[]> {
|
|
117
122
|
const connection = this.requireConnection(connectionName);
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
return runMcpClientSpan(
|
|
124
|
+
{ method: "tools/list", connection: connectionName },
|
|
125
|
+
() =>
|
|
126
|
+
this.withClient(connectionName, async (client) => {
|
|
127
|
+
const listed = await client.listTools(mcpListParams());
|
|
128
|
+
return listed.tools
|
|
129
|
+
.map(toToolInfo)
|
|
130
|
+
.filter((tool) => connectionAllowsTool(connection, tool.name));
|
|
131
|
+
})
|
|
132
|
+
);
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
/**
|
|
@@ -146,24 +155,37 @@ export class McpHost implements HostMcpRegistry {
|
|
|
146
155
|
};
|
|
147
156
|
return {
|
|
148
157
|
listTools: () =>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
runMcpClientSpan(
|
|
159
|
+
{ method: "tools/list", connection: connection.name },
|
|
160
|
+
() =>
|
|
161
|
+
withFreshClient(async (client) => {
|
|
162
|
+
const listed = await client.listTools(mcpListParams());
|
|
163
|
+
return listed.tools
|
|
164
|
+
.map(toToolInfo)
|
|
165
|
+
.filter((tool) => connectionAllowsTool(connection, tool.name));
|
|
166
|
+
})
|
|
167
|
+
),
|
|
155
168
|
callTool: (toolName, args = {}) => {
|
|
156
169
|
assertConnectionAllowsTool(connection, toolName);
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
return runMcpClientSpan(
|
|
171
|
+
{
|
|
172
|
+
method: "tools/call",
|
|
173
|
+
connection: connection.name,
|
|
174
|
+
toolName,
|
|
175
|
+
},
|
|
176
|
+
() =>
|
|
177
|
+
withFreshClient(async (client) => {
|
|
178
|
+
const result = await client.callTool({
|
|
179
|
+
name: toolName,
|
|
180
|
+
arguments: args,
|
|
181
|
+
...mcpCallMeta(),
|
|
182
|
+
});
|
|
183
|
+
return throwIfCallNeedsAuth(
|
|
184
|
+
connection.name,
|
|
185
|
+
normalizeCallResult(result)
|
|
186
|
+
);
|
|
187
|
+
})
|
|
188
|
+
);
|
|
167
189
|
},
|
|
168
190
|
};
|
|
169
191
|
}
|
|
@@ -175,13 +197,21 @@ export class McpHost implements HostMcpRegistry {
|
|
|
175
197
|
): Promise<HostMcpCallResult> {
|
|
176
198
|
const connection = this.requireConnection(connectionName);
|
|
177
199
|
assertConnectionAllowsTool(connection, toolName);
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
return runMcpClientSpan(
|
|
201
|
+
{ method: "tools/call", connection: connectionName, toolName },
|
|
202
|
+
() =>
|
|
203
|
+
this.withClient(connectionName, async (client) => {
|
|
204
|
+
const result = await client.callTool({
|
|
205
|
+
name: toolName,
|
|
206
|
+
arguments: args,
|
|
207
|
+
...mcpCallMeta(),
|
|
208
|
+
});
|
|
209
|
+
return throwIfCallNeedsAuth(
|
|
210
|
+
connectionName,
|
|
211
|
+
normalizeCallResult(result)
|
|
212
|
+
);
|
|
213
|
+
})
|
|
214
|
+
);
|
|
185
215
|
}
|
|
186
216
|
|
|
187
217
|
async dropClient(name: string): Promise<void> {
|
|
@@ -460,10 +490,33 @@ async function createTransport(
|
|
|
460
490
|
})
|
|
461
491
|
: undefined;
|
|
462
492
|
|
|
493
|
+
const fetchImpl = instrumentedMcpFetch();
|
|
494
|
+
const fetchLike = (url: string | URL, init?: RequestInit) =>
|
|
495
|
+
fetchImpl(url, init);
|
|
463
496
|
if (transport.type === "sse") {
|
|
464
|
-
return new SSEClientTransport(url, {
|
|
497
|
+
return new SSEClientTransport(url, {
|
|
498
|
+
requestInit,
|
|
499
|
+
authProvider,
|
|
500
|
+
fetch: fetchLike,
|
|
501
|
+
});
|
|
465
502
|
}
|
|
466
|
-
return new StreamableHTTPClientTransport(url, {
|
|
503
|
+
return new StreamableHTTPClientTransport(url, {
|
|
504
|
+
requestInit,
|
|
505
|
+
authProvider,
|
|
506
|
+
fetch: fetchLike,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function mcpListParams(): { _meta: { traceparent: string } } | undefined {
|
|
511
|
+
const meta = mcpTraceMeta();
|
|
512
|
+
return meta === undefined ? undefined : { _meta: meta };
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function mcpCallMeta():
|
|
516
|
+
| { _meta: { traceparent: string } }
|
|
517
|
+
| Record<string, never> {
|
|
518
|
+
const meta = mcpTraceMeta();
|
|
519
|
+
return meta === undefined ? {} : { _meta: meta };
|
|
467
520
|
}
|
|
468
521
|
|
|
469
522
|
function isOauthHttpTransport(
|
|
@@ -24,9 +24,23 @@ import type { OtelRuntime } from "./runtime.js";
|
|
|
24
24
|
|
|
25
25
|
const CONTENT_MAX = 2_048;
|
|
26
26
|
|
|
27
|
+
export interface OtelCallContext {
|
|
28
|
+
sessionId: string;
|
|
29
|
+
session: SessionInfo;
|
|
30
|
+
turnId: string;
|
|
31
|
+
callId: string;
|
|
32
|
+
toolName: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
export interface OtelCollector {
|
|
28
36
|
onEvent(event: SessionEvent, session: SessionInfo): void;
|
|
29
37
|
close(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Run `fn` under the tool span so outbound inject sees that context.
|
|
40
|
+
* Opens the session / turn / tool span if the event stream has not
|
|
41
|
+
* reached `actions.requested` yet (dispatch is async).
|
|
42
|
+
*/
|
|
43
|
+
runInCall<T>(args: OtelCallContext, fn: () => T | Promise<T>): Promise<T>;
|
|
30
44
|
/** Merge author tags onto the session; paints open spans immediately. */
|
|
31
45
|
setSessionAttributes(
|
|
32
46
|
sessionId: string,
|
|
@@ -93,6 +107,12 @@ export function createOtelCollector(
|
|
|
93
107
|
const bag = extraBySession.get(sessionId);
|
|
94
108
|
return bag === undefined ? undefined : { ...bag };
|
|
95
109
|
},
|
|
110
|
+
runInCall(args, fn) {
|
|
111
|
+
const span = ensureCallSpan(args);
|
|
112
|
+
return context.with(trace.setSpan(context.active(), span), () =>
|
|
113
|
+
Promise.resolve(fn())
|
|
114
|
+
);
|
|
115
|
+
},
|
|
96
116
|
};
|
|
97
117
|
|
|
98
118
|
function handle(event: SessionEvent, session: SessionInfo): void {
|
|
@@ -101,6 +121,9 @@ export function createOtelCollector(
|
|
|
101
121
|
|
|
102
122
|
switch (event.type) {
|
|
103
123
|
case "session.started": {
|
|
124
|
+
if (sessions.get(event.sessionId) !== undefined) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
104
127
|
openSession({
|
|
105
128
|
sessionId: event.sessionId,
|
|
106
129
|
session,
|
|
@@ -174,6 +197,15 @@ export function createOtelCollector(
|
|
|
174
197
|
if (state === undefined) {
|
|
175
198
|
return;
|
|
176
199
|
}
|
|
200
|
+
// `runInCall` can open a synthetic turn before this event is
|
|
201
|
+
// applied. Keep that entry (and its in-flight tool spans) and
|
|
202
|
+
// just mark it real so `action.result` will not auto-close it.
|
|
203
|
+
const existing = state.turns.get(event.turnId);
|
|
204
|
+
if (existing !== undefined) {
|
|
205
|
+
existing.synthetic = false;
|
|
206
|
+
existing.span.setAttribute("agent_sdk.turn_synthetic", false);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
177
209
|
openTurn({
|
|
178
210
|
state,
|
|
179
211
|
sessionId: event.sessionId,
|
|
@@ -227,32 +259,14 @@ export function createOtelCollector(
|
|
|
227
259
|
return;
|
|
228
260
|
}
|
|
229
261
|
for (const call of event.data.calls) {
|
|
230
|
-
|
|
262
|
+
openToolSpan({
|
|
231
263
|
turn,
|
|
232
|
-
event.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
startTime,
|
|
239
|
-
attributes: join(event.sessionId, {
|
|
240
|
-
"cursor.conversation.id": event.sessionId,
|
|
241
|
-
"cursor.tool.name": call.toolName,
|
|
242
|
-
"cursor.tool.kind": "builtin",
|
|
243
|
-
"agent_sdk.agent": agentName,
|
|
244
|
-
"agent_sdk.turn_id": event.turnId,
|
|
245
|
-
"agent_sdk.call_id": call.callId,
|
|
246
|
-
"agent_sdk.parent_call_id": call.parentCallId,
|
|
247
|
-
"agent_sdk.tool_args":
|
|
248
|
-
logOpts?.toolContent === true && call.args !== undefined
|
|
249
|
-
? truncate(json(call.args))
|
|
250
|
-
: undefined,
|
|
251
|
-
}),
|
|
252
|
-
},
|
|
253
|
-
parentCtx
|
|
254
|
-
);
|
|
255
|
-
turn.tools.set(call.callId, span);
|
|
264
|
+
sessionId: event.sessionId,
|
|
265
|
+
turnId: event.turnId,
|
|
266
|
+
call,
|
|
267
|
+
parentCallId: event.data.parentCallId ?? call.parentCallId,
|
|
268
|
+
startTime,
|
|
269
|
+
});
|
|
256
270
|
}
|
|
257
271
|
return;
|
|
258
272
|
}
|
|
@@ -702,6 +716,92 @@ export function createOtelCollector(
|
|
|
702
716
|
return trace.setSpan(context.active(), turn.span);
|
|
703
717
|
}
|
|
704
718
|
|
|
719
|
+
function openToolSpan(args: {
|
|
720
|
+
turn: TurnState;
|
|
721
|
+
sessionId: string;
|
|
722
|
+
turnId: string | undefined;
|
|
723
|
+
call: {
|
|
724
|
+
callId: string;
|
|
725
|
+
toolName: string;
|
|
726
|
+
args?: unknown;
|
|
727
|
+
parentCallId?: string;
|
|
728
|
+
};
|
|
729
|
+
parentCallId?: string;
|
|
730
|
+
startTime: number | undefined;
|
|
731
|
+
}): Span {
|
|
732
|
+
const existing = args.turn.tools.get(args.call.callId);
|
|
733
|
+
if (existing !== undefined) {
|
|
734
|
+
// Early `runInCall` opens with callId/toolName only. Fill in
|
|
735
|
+
// parent linkage and opt-in args when `actions.requested` arrives.
|
|
736
|
+
// The OTel parent is fixed at start; `parent_call_id` still records
|
|
737
|
+
// the event-stream hierarchy for nested/subagent calls.
|
|
738
|
+
existing.setAttributes(
|
|
739
|
+
join(args.sessionId, {
|
|
740
|
+
"agent_sdk.parent_call_id":
|
|
741
|
+
args.parentCallId ?? args.call.parentCallId,
|
|
742
|
+
"agent_sdk.tool_args":
|
|
743
|
+
logOpts?.toolContent === true && args.call.args !== undefined
|
|
744
|
+
? truncate(json(args.call.args))
|
|
745
|
+
: undefined,
|
|
746
|
+
})
|
|
747
|
+
);
|
|
748
|
+
return existing;
|
|
749
|
+
}
|
|
750
|
+
const span = runtime.tracer.startSpan(
|
|
751
|
+
"agent_sdk.tool",
|
|
752
|
+
{
|
|
753
|
+
kind: SpanKind.INTERNAL,
|
|
754
|
+
startTime: args.startTime,
|
|
755
|
+
attributes: join(args.sessionId, {
|
|
756
|
+
"cursor.conversation.id": args.sessionId,
|
|
757
|
+
"cursor.tool.name": args.call.toolName,
|
|
758
|
+
"cursor.tool.kind": "builtin",
|
|
759
|
+
"agent_sdk.agent": agentName,
|
|
760
|
+
"agent_sdk.turn_id": args.turnId,
|
|
761
|
+
"agent_sdk.call_id": args.call.callId,
|
|
762
|
+
"agent_sdk.parent_call_id": args.call.parentCallId,
|
|
763
|
+
"agent_sdk.tool_args":
|
|
764
|
+
logOpts?.toolContent === true && args.call.args !== undefined
|
|
765
|
+
? truncate(json(args.call.args))
|
|
766
|
+
: undefined,
|
|
767
|
+
}),
|
|
768
|
+
},
|
|
769
|
+
parentCtxFor(args.turn, args.parentCallId ?? args.call.parentCallId)
|
|
770
|
+
);
|
|
771
|
+
args.turn.tools.set(args.call.callId, span);
|
|
772
|
+
return span;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function ensureCallSpan(args: OtelCallContext): Span {
|
|
776
|
+
const startTime = Date.now();
|
|
777
|
+
const state =
|
|
778
|
+
sessions.get(args.sessionId) ??
|
|
779
|
+
openSession({
|
|
780
|
+
sessionId: args.sessionId,
|
|
781
|
+
session: args.session,
|
|
782
|
+
channelId: args.session.channelId,
|
|
783
|
+
startTime,
|
|
784
|
+
restored: true,
|
|
785
|
+
});
|
|
786
|
+
const turn =
|
|
787
|
+
state.turns.get(args.turnId) ??
|
|
788
|
+
openTurn({
|
|
789
|
+
state,
|
|
790
|
+
sessionId: args.sessionId,
|
|
791
|
+
turnId: args.turnId,
|
|
792
|
+
session: args.session,
|
|
793
|
+
startTime,
|
|
794
|
+
synthetic: true,
|
|
795
|
+
});
|
|
796
|
+
return openToolSpan({
|
|
797
|
+
turn,
|
|
798
|
+
sessionId: args.sessionId,
|
|
799
|
+
turnId: args.turnId,
|
|
800
|
+
call: { callId: args.callId, toolName: args.toolName },
|
|
801
|
+
startTime,
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
|
|
705
805
|
function endOpenChildren(turn: TurnState, endTime: number | undefined): void {
|
|
706
806
|
for (const span of turn.tools.values()) {
|
|
707
807
|
span.end(endTime);
|
|
@@ -11,19 +11,9 @@ import {
|
|
|
11
11
|
SpanStatusCode,
|
|
12
12
|
trace,
|
|
13
13
|
} from "@opentelemetry/api";
|
|
14
|
-
import {
|
|
14
|
+
import { ensureW3cPropagator } from "./propagation.js";
|
|
15
15
|
import type { OtelRuntime } from "./runtime.js";
|
|
16
16
|
|
|
17
|
-
let propagatorInstalled = false;
|
|
18
|
-
|
|
19
|
-
function ensurePropagator(): void {
|
|
20
|
-
if (propagatorInstalled) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
|
|
24
|
-
propagatorInstalled = true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
17
|
interface HttpSpanHandle {
|
|
28
18
|
context: Context;
|
|
29
19
|
end(statusCode: number, error?: unknown): void;
|
|
@@ -61,7 +51,7 @@ function startHttpSpan(
|
|
|
61
51
|
if (runtime === undefined || runtime.config.traces === false) {
|
|
62
52
|
return undefined;
|
|
63
53
|
}
|
|
64
|
-
|
|
54
|
+
ensureW3cPropagator();
|
|
65
55
|
const headers: Record<string, string> = {};
|
|
66
56
|
for (const [key, value] of Object.entries(req.headers)) {
|
|
67
57
|
if (typeof value === "string") {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side MCP instrumentation: W3C / Cursor HTTP inject on Streamable
|
|
3
|
+
* HTTP + SSE fetches, SEP-414 `_meta.traceparent` on JSON-RPC params, and
|
|
4
|
+
* CLIENT spans for `tools/list` / `tools/call`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { context, SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
|
+
import { formatTraceparent, injectActiveTraceContext } from "../../otel.js";
|
|
9
|
+
import { attrs } from "./attrs.js";
|
|
10
|
+
|
|
11
|
+
const TRACER = "agent_sdk";
|
|
12
|
+
|
|
13
|
+
export function instrumentedMcpFetch(base: typeof fetch = fetch): typeof fetch {
|
|
14
|
+
return (input, init) => {
|
|
15
|
+
if (input instanceof Request && init === undefined) {
|
|
16
|
+
const headers = new Headers(input.headers);
|
|
17
|
+
injectActiveTraceContext(headers);
|
|
18
|
+
return base(new Request(input, { headers }));
|
|
19
|
+
}
|
|
20
|
+
const headers = new Headers(init?.headers);
|
|
21
|
+
injectActiveTraceContext(headers);
|
|
22
|
+
return base(input, { ...init, headers });
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** SEP-414 / OTel MCP carrier for `params._meta`. */
|
|
27
|
+
export function mcpTraceMeta(): { traceparent: string } | undefined {
|
|
28
|
+
const span = trace.getSpan(context.active());
|
|
29
|
+
if (span === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const traceparent = formatTraceparent(span.spanContext());
|
|
33
|
+
if (traceparent === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return { traceparent };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function runMcpClientSpan<T>(
|
|
40
|
+
args: {
|
|
41
|
+
method: string;
|
|
42
|
+
connection: string;
|
|
43
|
+
toolName?: string;
|
|
44
|
+
},
|
|
45
|
+
fn: () => Promise<T>
|
|
46
|
+
): Promise<T> {
|
|
47
|
+
const span = trace.getTracer(TRACER).startSpan(args.method, {
|
|
48
|
+
kind: SpanKind.CLIENT,
|
|
49
|
+
attributes: attrs({
|
|
50
|
+
"rpc.system": "mcp",
|
|
51
|
+
"mcp.method.name": args.method,
|
|
52
|
+
"mcp.tool.name": args.toolName,
|
|
53
|
+
"agent_sdk.mcp.connection": args.connection,
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
return context.with(trace.setSpan(context.active(), span), async () => {
|
|
57
|
+
try {
|
|
58
|
+
return await fn();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
span.setStatus({
|
|
61
|
+
code: SpanStatusCode.ERROR,
|
|
62
|
+
message: error instanceof Error ? error.message : String(error),
|
|
63
|
+
});
|
|
64
|
+
throw error;
|
|
65
|
+
} finally {
|
|
66
|
+
span.end();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-global W3C `traceparent` propagator. Inbound HTTP extracts;
|
|
3
|
+
* outbound Factory / Cursor API calls inject.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { propagation } from "@opentelemetry/api";
|
|
7
|
+
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
8
|
+
|
|
9
|
+
let installed = false;
|
|
10
|
+
|
|
11
|
+
export function ensureW3cPropagator(): void {
|
|
12
|
+
if (installed) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
|
|
16
|
+
installed = true;
|
|
17
|
+
}
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from "@opentelemetry/semantic-conventions";
|
|
42
42
|
import type { OtelExporterConfig, OtelSignal } from "../../otel.js";
|
|
43
43
|
import { exportersForSignal, type ResolvedOtelConfig } from "./config.js";
|
|
44
|
+
import { ensureW3cPropagator } from "./propagation.js";
|
|
44
45
|
|
|
45
46
|
const INSTRUMENTATION = "agent_sdk";
|
|
46
47
|
|
|
@@ -66,6 +67,7 @@ export function createOtelRuntime(
|
|
|
66
67
|
"[agent-sdk:otel] OTEL_EXPORTER_OTLP_PROTOCOL=grpc is unsupported; using http/protobuf"
|
|
67
68
|
);
|
|
68
69
|
}
|
|
70
|
+
ensureW3cPropagator();
|
|
69
71
|
const sdk = startOtelSdk(config, log);
|
|
70
72
|
const meter =
|
|
71
73
|
config.metrics === false
|