@cursor/july 0.1.1
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 +290 -0
- package/LICENSE.md +3 -0
- package/README.md +1233 -0
- package/dist/ab.d.ts +290 -0
- package/dist/ab.d.ts.map +1 -0
- package/dist/ab.js +386 -0
- package/dist/bin/agent-serve.d.ts +15 -0
- package/dist/bin/agent-serve.d.ts.map +1 -0
- package/dist/bin/agent-serve.js +754 -0
- package/dist/channels/github/api.d.ts +101 -0
- package/dist/channels/github/api.d.ts.map +1 -0
- package/dist/channels/github/api.js +229 -0
- package/dist/channels/github/auth.d.ts +67 -0
- package/dist/channels/github/auth.d.ts.map +1 -0
- package/dist/channels/github/auth.js +239 -0
- package/dist/channels/github/binding.d.ts +73 -0
- package/dist/channels/github/binding.d.ts.map +1 -0
- package/dist/channels/github/binding.js +114 -0
- package/dist/channels/github/defaults.d.ts +24 -0
- package/dist/channels/github/defaults.d.ts.map +1 -0
- package/dist/channels/github/defaults.js +100 -0
- package/dist/channels/github/events.d.ts +18 -0
- package/dist/channels/github/events.d.ts.map +1 -0
- package/dist/channels/github/events.js +59 -0
- package/dist/channels/github/forward.d.ts +137 -0
- package/dist/channels/github/forward.d.ts.map +1 -0
- package/dist/channels/github/forward.js +271 -0
- package/dist/channels/github/github-channel.d.ts +127 -0
- package/dist/channels/github/github-channel.d.ts.map +1 -0
- package/dist/channels/github/github-channel.js +1688 -0
- package/dist/channels/github/index.d.ts +52 -0
- package/dist/channels/github/index.d.ts.map +1 -0
- package/dist/channels/github/index.js +51 -0
- package/dist/channels/github/replay.d.ts +115 -0
- package/dist/channels/github/replay.d.ts.map +1 -0
- package/dist/channels/github/replay.js +282 -0
- package/dist/channels/github/state.d.ts +26 -0
- package/dist/channels/github/state.d.ts.map +1 -0
- package/dist/channels/github/state.js +50 -0
- package/dist/channels/github/types.d.ts +385 -0
- package/dist/channels/github/types.d.ts.map +1 -0
- package/dist/channels/github/types.js +1 -0
- package/dist/channels/slack/api.d.ts +117 -0
- package/dist/channels/slack/api.d.ts.map +1 -0
- package/dist/channels/slack/api.js +437 -0
- package/dist/channels/slack/approvals.d.ts +32 -0
- package/dist/channels/slack/approvals.d.ts.map +1 -0
- package/dist/channels/slack/approvals.js +157 -0
- package/dist/channels/slack/assistant.d.ts +23 -0
- package/dist/channels/slack/assistant.d.ts.map +1 -0
- package/dist/channels/slack/assistant.js +67 -0
- package/dist/channels/slack/auth.d.ts +40 -0
- package/dist/channels/slack/auth.d.ts.map +1 -0
- package/dist/channels/slack/auth.js +71 -0
- package/dist/channels/slack/channel-watch.d.ts +46 -0
- package/dist/channels/slack/channel-watch.d.ts.map +1 -0
- package/dist/channels/slack/channel-watch.js +180 -0
- package/dist/channels/slack/constants.d.ts +17 -0
- package/dist/channels/slack/constants.d.ts.map +1 -0
- package/dist/channels/slack/constants.js +27 -0
- package/dist/channels/slack/credentials.d.ts +35 -0
- package/dist/channels/slack/credentials.d.ts.map +1 -0
- package/dist/channels/slack/credentials.js +88 -0
- package/dist/channels/slack/cursor-account.d.ts +76 -0
- package/dist/channels/slack/cursor-account.d.ts.map +1 -0
- package/dist/channels/slack/cursor-account.js +88 -0
- package/dist/channels/slack/defaults.d.ts +32 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -0
- package/dist/channels/slack/defaults.js +380 -0
- package/dist/channels/slack/dispatch.d.ts +43 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -0
- package/dist/channels/slack/dispatch.js +185 -0
- package/dist/channels/slack/doctor.d.ts +24 -0
- package/dist/channels/slack/doctor.d.ts.map +1 -0
- package/dist/channels/slack/doctor.js +115 -0
- package/dist/channels/slack/event-id-dedupe.d.ts +10 -0
- package/dist/channels/slack/event-id-dedupe.d.ts.map +1 -0
- package/dist/channels/slack/event-id-dedupe.js +23 -0
- package/dist/channels/slack/inbound.d.ts +41 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -0
- package/dist/channels/slack/inbound.js +166 -0
- package/dist/channels/slack/index.d.ts +45 -0
- package/dist/channels/slack/index.d.ts.map +1 -0
- package/dist/channels/slack/index.js +44 -0
- package/dist/channels/slack/init.d.ts +32 -0
- package/dist/channels/slack/init.d.ts.map +1 -0
- package/dist/channels/slack/init.js +82 -0
- package/dist/channels/slack/interactive.d.ts +19 -0
- package/dist/channels/slack/interactive.d.ts.map +1 -0
- package/dist/channels/slack/interactive.js +142 -0
- package/dist/channels/slack/links.d.ts +10 -0
- package/dist/channels/slack/links.d.ts.map +1 -0
- package/dist/channels/slack/links.js +19 -0
- package/dist/channels/slack/live-delivery.d.ts +75 -0
- package/dist/channels/slack/live-delivery.d.ts.map +1 -0
- package/dist/channels/slack/live-delivery.js +143 -0
- package/dist/channels/slack/log.d.ts +25 -0
- package/dist/channels/slack/log.d.ts.map +1 -0
- package/dist/channels/slack/log.js +47 -0
- package/dist/channels/slack/manifest.d.ts +57 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -0
- package/dist/channels/slack/manifest.js +110 -0
- package/dist/channels/slack/pr-ref.d.ts +18 -0
- package/dist/channels/slack/pr-ref.d.ts.map +1 -0
- package/dist/channels/slack/pr-ref.js +36 -0
- package/dist/channels/slack/setup.d.ts +14 -0
- package/dist/channels/slack/setup.d.ts.map +1 -0
- package/dist/channels/slack/setup.js +86 -0
- package/dist/channels/slack/slack-channel.d.ts +15 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -0
- package/dist/channels/slack/slack-channel.js +281 -0
- package/dist/channels/slack/socket-mode.d.ts +26 -0
- package/dist/channels/slack/socket-mode.d.ts.map +1 -0
- package/dist/channels/slack/socket-mode.js +116 -0
- package/dist/channels/slack/stream.d.ts +26 -0
- package/dist/channels/slack/stream.d.ts.map +1 -0
- package/dist/channels/slack/stream.js +39 -0
- package/dist/channels/slack/tool-approval-events.d.ts +33 -0
- package/dist/channels/slack/tool-approval-events.d.ts.map +1 -0
- package/dist/channels/slack/tool-approval-events.js +129 -0
- package/dist/channels/slack/types.d.ts +326 -0
- package/dist/channels/slack/types.d.ts.map +1 -0
- package/dist/channels/slack/types.js +4 -0
- package/dist/channels.d.ts +116 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +294 -0
- package/dist/connections.d.ts +75 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +75 -0
- package/dist/docs/404.html +22 -0
- package/dist/docs/ab.html +87 -0
- package/dist/docs/assets/ab.md.COdXkces.js +63 -0
- package/dist/docs/assets/ab.md.COdXkces.lean.js +1 -0
- package/dist/docs/assets/app.DqfFEmJd.js +1 -0
- package/dist/docs/assets/building-with-agents.md.CJCtZCyi.js +13 -0
- package/dist/docs/assets/building-with-agents.md.CJCtZCyi.lean.js +1 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.CcVk1uKq.js +1 -0
- package/dist/docs/assets/chunks/VPLocalSearchBox.BaLEdS15.js +9 -0
- package/dist/docs/assets/chunks/framework.CAZyNGu9.js +19 -0
- package/dist/docs/assets/chunks/theme.CZRvu_0q.js +2 -0
- package/dist/docs/assets/concepts.md.Cfb9b-k1.js +4 -0
- package/dist/docs/assets/concepts.md.Cfb9b-k1.lean.js +1 -0
- package/dist/docs/assets/deployment.md.Dx1TYNk5.js +14 -0
- package/dist/docs/assets/deployment.md.Dx1TYNk5.lean.js +1 -0
- package/dist/docs/assets/evals.md.DPZ_MAnI.js +85 -0
- package/dist/docs/assets/evals.md.DPZ_MAnI.lean.js +1 -0
- package/dist/docs/assets/guides_agent-to-agent.md.CrtrsySy.js +10 -0
- package/dist/docs/assets/guides_agent-to-agent.md.CrtrsySy.lean.js +1 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CYlNMTNp.js +9 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CYlNMTNp.lean.js +1 -0
- package/dist/docs/assets/guides_github.md.DwbKhCeS.js +20 -0
- package/dist/docs/assets/guides_github.md.DwbKhCeS.lean.js +1 -0
- package/dist/docs/assets/guides_human-in-the-loop.md.Dvuctx7s.js +28 -0
- package/dist/docs/assets/guides_human-in-the-loop.md.Dvuctx7s.lean.js +1 -0
- package/dist/docs/assets/guides_slack.md.bv41fHfW.js +37 -0
- package/dist/docs/assets/guides_slack.md.bv41fHfW.lean.js +1 -0
- package/dist/docs/assets/guides_webhooks.md.hFTik3lf.js +50 -0
- package/dist/docs/assets/guides_webhooks.md.hFTik3lf.lean.js +1 -0
- package/dist/docs/assets/hillclimbing.md.DHNast08.js +4 -0
- package/dist/docs/assets/hillclimbing.md.DHNast08.lean.js +1 -0
- package/dist/docs/assets/index.md.BPKcj5AI.js +20 -0
- package/dist/docs/assets/index.md.BPKcj5AI.lean.js +1 -0
- package/dist/docs/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/dist/docs/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/dist/docs/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/dist/docs/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/dist/docs/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/dist/docs/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/dist/docs/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/dist/docs/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/dist/docs/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/dist/docs/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/dist/docs/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/dist/docs/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/dist/docs/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/dist/docs/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/dist/docs/assets/quickstart.md.tVPiGK_L.js +35 -0
- package/dist/docs/assets/quickstart.md.tVPiGK_L.lean.js +1 -0
- package/dist/docs/assets/reference_agent-config.md.Bpd7HQwf.js +34 -0
- package/dist/docs/assets/reference_agent-config.md.Bpd7HQwf.lean.js +1 -0
- package/dist/docs/assets/reference_channels.md.D7JTR03W.js +53 -0
- package/dist/docs/assets/reference_channels.md.D7JTR03W.lean.js +1 -0
- package/dist/docs/assets/reference_cli.md.DA730zCu.js +33 -0
- package/dist/docs/assets/reference_cli.md.DA730zCu.lean.js +1 -0
- package/dist/docs/assets/reference_connections.md.C3vNH_DE.js +26 -0
- package/dist/docs/assets/reference_connections.md.C3vNH_DE.lean.js +1 -0
- package/dist/docs/assets/reference_hooks.md.BCEc3MyM.js +12 -0
- package/dist/docs/assets/reference_hooks.md.BCEc3MyM.lean.js +1 -0
- package/dist/docs/assets/reference_http-api.md.DBAahtdz.js +11 -0
- package/dist/docs/assets/reference_http-api.md.DBAahtdz.lean.js +1 -0
- package/dist/docs/assets/reference_instructions.md.BC05LEQ8.js +12 -0
- package/dist/docs/assets/reference_instructions.md.BC05LEQ8.lean.js +1 -0
- package/dist/docs/assets/reference_playground.md.CPZhfYaO.js +1 -0
- package/dist/docs/assets/reference_playground.md.CPZhfYaO.lean.js +1 -0
- package/dist/docs/assets/reference_project-layout.md.Bd_CKtNS.js +31 -0
- package/dist/docs/assets/reference_project-layout.md.Bd_CKtNS.lean.js +1 -0
- package/dist/docs/assets/reference_schedules.md.D7qijxLk.js +82 -0
- package/dist/docs/assets/reference_schedules.md.D7qijxLk.lean.js +1 -0
- package/dist/docs/assets/reference_sessions.md.DdjWabnN.js +8 -0
- package/dist/docs/assets/reference_sessions.md.DdjWabnN.lean.js +1 -0
- package/dist/docs/assets/reference_skills.md.VQnlBT3Q.js +15 -0
- package/dist/docs/assets/reference_skills.md.VQnlBT3Q.lean.js +1 -0
- package/dist/docs/assets/reference_subagents.md.CIRAVcPK.js +10 -0
- package/dist/docs/assets/reference_subagents.md.CIRAVcPK.lean.js +1 -0
- package/dist/docs/assets/reference_tools.md.DF5kwlt0.js +46 -0
- package/dist/docs/assets/reference_tools.md.DF5kwlt0.lean.js +1 -0
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.js +1 -0
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.lean.js +1 -0
- package/dist/docs/assets/style.Bj-IXa5W.css +1 -0
- package/dist/docs/assets/troubleshooting.md.DkovjS7h.js +1 -0
- package/dist/docs/assets/troubleshooting.md.DkovjS7h.lean.js +1 -0
- package/dist/docs/building-with-agents.html +37 -0
- package/dist/docs/concepts.html +28 -0
- package/dist/docs/deployment.html +38 -0
- package/dist/docs/evals.html +109 -0
- package/dist/docs/guides/agent-to-agent.html +34 -0
- package/dist/docs/guides/cloud-runtime.html +33 -0
- package/dist/docs/guides/github.html +44 -0
- package/dist/docs/guides/human-in-the-loop.html +52 -0
- package/dist/docs/guides/slack.html +61 -0
- package/dist/docs/guides/webhooks.html +74 -0
- package/dist/docs/hashmap.json +1 -0
- package/dist/docs/hillclimbing.html +28 -0
- package/dist/docs/index.html +44 -0
- package/dist/docs/quickstart.html +59 -0
- package/dist/docs/reference/agent-config.html +58 -0
- package/dist/docs/reference/channels.html +77 -0
- package/dist/docs/reference/cli.html +57 -0
- package/dist/docs/reference/connections.html +50 -0
- package/dist/docs/reference/hooks.html +36 -0
- package/dist/docs/reference/http-api.html +35 -0
- package/dist/docs/reference/instructions.html +36 -0
- package/dist/docs/reference/playground.html +25 -0
- package/dist/docs/reference/project-layout.html +55 -0
- package/dist/docs/reference/schedules.html +106 -0
- package/dist/docs/reference/sessions.html +32 -0
- package/dist/docs/reference/skills.html +39 -0
- package/dist/docs/reference/subagents.html +34 -0
- package/dist/docs/reference/tools.html +70 -0
- package/dist/docs/scaffolding-agents.html +25 -0
- package/dist/docs/troubleshooting.html +25 -0
- package/dist/docs/vp-icons.css +0 -0
- package/dist/evals.d.ts +312 -0
- package/dist/evals.d.ts.map +1 -0
- package/dist/evals.js +254 -0
- package/dist/hooks.d.ts +23 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +23 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +101 -0
- package/dist/internal/ab-collector.d.ts +42 -0
- package/dist/internal/ab-collector.d.ts.map +1 -0
- package/dist/internal/ab-collector.js +153 -0
- package/dist/internal/ab-fold.d.ts +36 -0
- package/dist/internal/ab-fold.d.ts.map +1 -0
- package/dist/internal/ab-fold.js +171 -0
- package/dist/internal/ab-snapshot.d.ts +70 -0
- package/dist/internal/ab-snapshot.d.ts.map +1 -0
- package/dist/internal/ab-snapshot.js +208 -0
- package/dist/internal/approval-gate.d.ts +34 -0
- package/dist/internal/approval-gate.d.ts.map +1 -0
- package/dist/internal/approval-gate.js +85 -0
- package/dist/internal/auth.d.ts +8 -0
- package/dist/internal/auth.d.ts.map +1 -0
- package/dist/internal/auth.js +27 -0
- package/dist/internal/authored-alias-hooks.d.ts +31 -0
- package/dist/internal/authored-alias-hooks.d.ts.map +1 -0
- package/dist/internal/authored-alias-hooks.js +43 -0
- package/dist/internal/authored-loaders.d.ts +25 -0
- package/dist/internal/authored-loaders.d.ts.map +1 -0
- package/dist/internal/authored-loaders.js +129 -0
- package/dist/internal/bounded-int.d.ts +11 -0
- package/dist/internal/bounded-int.d.ts.map +1 -0
- package/dist/internal/bounded-int.js +13 -0
- package/dist/internal/brand.d.ts +6 -0
- package/dist/internal/brand.d.ts.map +1 -0
- package/dist/internal/brand.js +17 -0
- package/dist/internal/chat-client.d.ts +19 -0
- package/dist/internal/chat-client.d.ts.map +1 -0
- package/dist/internal/chat-client.js +327 -0
- package/dist/internal/cli-ax.d.ts +58 -0
- package/dist/internal/cli-ax.d.ts.map +1 -0
- package/dist/internal/cli-ax.js +345 -0
- package/dist/internal/cli-cursor.d.ts +20 -0
- package/dist/internal/cli-cursor.d.ts.map +1 -0
- package/dist/internal/cli-cursor.js +227 -0
- package/dist/internal/cli-github.d.ts +47 -0
- package/dist/internal/cli-github.d.ts.map +1 -0
- package/dist/internal/cli-github.js +644 -0
- package/dist/internal/cli-slack.d.ts +18 -0
- package/dist/internal/cli-slack.d.ts.map +1 -0
- package/dist/internal/cli-slack.js +144 -0
- package/dist/internal/cloud-merge.d.ts +23 -0
- package/dist/internal/cloud-merge.d.ts.map +1 -0
- package/dist/internal/cloud-merge.js +28 -0
- package/dist/internal/cron.d.ts +17 -0
- package/dist/internal/cron.d.ts.map +1 -0
- package/dist/internal/cron.js +60 -0
- package/dist/internal/cursor/account-mcp.d.ts +95 -0
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -0
- package/dist/internal/cursor/account-mcp.js +342 -0
- package/dist/internal/cursor/backend-client.d.ts +118 -0
- package/dist/internal/cursor/backend-client.d.ts.map +1 -0
- package/dist/internal/cursor/backend-client.js +477 -0
- package/dist/internal/cursor/credentials.d.ts +112 -0
- package/dist/internal/cursor/credentials.d.ts.map +1 -0
- package/dist/internal/cursor/credentials.js +329 -0
- package/dist/internal/cursor-event-relay.d.ts +111 -0
- package/dist/internal/cursor-event-relay.d.ts.map +1 -0
- package/dist/internal/cursor-event-relay.js +181 -0
- package/dist/internal/cursor-relay-core.d.ts +113 -0
- package/dist/internal/cursor-relay-core.d.ts.map +1 -0
- package/dist/internal/cursor-relay-core.js +364 -0
- package/dist/internal/cursor-slack-relay.d.ts +94 -0
- package/dist/internal/cursor-slack-relay.d.ts.map +1 -0
- package/dist/internal/cursor-slack-relay.js +171 -0
- package/dist/internal/describe-error.d.ts +3 -0
- package/dist/internal/describe-error.d.ts.map +1 -0
- package/dist/internal/describe-error.js +4 -0
- package/dist/internal/dev-mode.d.ts +13 -0
- package/dist/internal/dev-mode.d.ts.map +1 -0
- package/dist/internal/dev-mode.js +17 -0
- package/dist/internal/discovery.d.ts +55 -0
- package/dist/internal/discovery.d.ts.map +1 -0
- package/dist/internal/discovery.js +1427 -0
- package/dist/internal/distribution.d.ts +47 -0
- package/dist/internal/distribution.d.ts.map +1 -0
- package/dist/internal/distribution.js +82 -0
- package/dist/internal/docs-site.d.ts +28 -0
- package/dist/internal/docs-site.d.ts.map +1 -0
- package/dist/internal/docs-site.js +169 -0
- package/dist/internal/duration.d.ts +8 -0
- package/dist/internal/duration.d.ts.map +1 -0
- package/dist/internal/duration.js +35 -0
- package/dist/internal/eval-run-store.d.ts +81 -0
- package/dist/internal/eval-run-store.d.ts.map +1 -0
- package/dist/internal/eval-run-store.js +396 -0
- package/dist/internal/eval-runner.d.ts +76 -0
- package/dist/internal/eval-runner.d.ts.map +1 -0
- package/dist/internal/eval-runner.js +336 -0
- package/dist/internal/event-log.d.ts +51 -0
- package/dist/internal/event-log.d.ts.map +1 -0
- package/dist/internal/event-log.js +167 -0
- package/dist/internal/event-mapper.d.ts +46 -0
- package/dist/internal/event-mapper.d.ts.map +1 -0
- package/dist/internal/event-mapper.js +226 -0
- package/dist/internal/frontmatter.d.ts +12 -0
- package/dist/internal/frontmatter.d.ts.map +1 -0
- package/dist/internal/frontmatter.js +61 -0
- package/dist/internal/github-fanout.d.ts +32 -0
- package/dist/internal/github-fanout.d.ts.map +1 -0
- package/dist/internal/github-fanout.js +122 -0
- package/dist/internal/handleAgentServeTrigger.d.ts +59 -0
- package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -0
- package/dist/internal/handleAgentServeTrigger.js +115 -0
- package/dist/internal/host-platforms.d.ts +40 -0
- package/dist/internal/host-platforms.d.ts.map +1 -0
- package/dist/internal/host-platforms.js +113 -0
- package/dist/internal/http-channel.d.ts +54 -0
- package/dist/internal/http-channel.d.ts.map +1 -0
- package/dist/internal/http-channel.js +382 -0
- package/dist/internal/ids.d.ts +19 -0
- package/dist/internal/ids.d.ts.map +1 -0
- package/dist/internal/ids.js +34 -0
- package/dist/internal/init-project.d.ts +22 -0
- package/dist/internal/init-project.d.ts.map +1 -0
- package/dist/internal/init-project.js +125 -0
- package/dist/internal/json-dir-store.d.ts +32 -0
- package/dist/internal/json-dir-store.d.ts.map +1 -0
- package/dist/internal/json-dir-store.js +100 -0
- package/dist/internal/json-schema.d.ts +18 -0
- package/dist/internal/json-schema.d.ts.map +1 -0
- package/dist/internal/json-schema.js +53 -0
- package/dist/internal/log-ring.d.ts +23 -0
- package/dist/internal/log-ring.d.ts.map +1 -0
- package/dist/internal/log-ring.js +42 -0
- package/dist/internal/map-pool.d.ts +6 -0
- package/dist/internal/map-pool.d.ts.map +1 -0
- package/dist/internal/map-pool.js +41 -0
- package/dist/internal/mcp-endpoint.d.ts +59 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -0
- package/dist/internal/mcp-endpoint.js +355 -0
- package/dist/internal/mcp-host.d.ts +28 -0
- package/dist/internal/mcp-host.d.ts.map +1 -0
- package/dist/internal/mcp-host.js +162 -0
- package/dist/internal/net.d.ts +5 -0
- package/dist/internal/net.d.ts.map +1 -0
- package/dist/internal/net.js +30 -0
- package/dist/internal/peer-connections.d.ts +44 -0
- package/dist/internal/peer-connections.d.ts.map +1 -0
- package/dist/internal/peer-connections.js +67 -0
- package/dist/internal/playground/static.d.ts +35 -0
- package/dist/internal/playground/static.d.ts.map +1 -0
- package/dist/internal/playground/static.js +162 -0
- package/dist/internal/playground/toolchain.d.ts +57 -0
- package/dist/internal/playground/toolchain.d.ts.map +1 -0
- package/dist/internal/playground/toolchain.js +226 -0
- package/dist/internal/reminder-runner.d.ts +62 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -0
- package/dist/internal/reminder-runner.js +582 -0
- package/dist/internal/reminder-schedule.d.ts +22 -0
- package/dist/internal/reminder-schedule.d.ts.map +1 -0
- package/dist/internal/reminder-schedule.js +82 -0
- package/dist/internal/reminder-store.d.ts +58 -0
- package/dist/internal/reminder-store.d.ts.map +1 -0
- package/dist/internal/reminder-store.js +106 -0
- package/dist/internal/resolved-connections.d.ts +41 -0
- package/dist/internal/resolved-connections.d.ts.map +1 -0
- package/dist/internal/resolved-connections.js +73 -0
- package/dist/internal/review-comments.d.ts +50 -0
- package/dist/internal/review-comments.d.ts.map +1 -0
- package/dist/internal/review-comments.js +194 -0
- package/dist/internal/router.d.ts +33 -0
- package/dist/internal/router.d.ts.map +1 -0
- package/dist/internal/router.js +93 -0
- package/dist/internal/run-client.d.ts +49 -0
- package/dist/internal/run-client.d.ts.map +1 -0
- package/dist/internal/run-client.js +208 -0
- package/dist/internal/schedule-runner.d.ts +31 -0
- package/dist/internal/schedule-runner.d.ts.map +1 -0
- package/dist/internal/schedule-runner.js +126 -0
- package/dist/internal/sdk-runner.d.ts +41 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -0
- package/dist/internal/sdk-runner.js +221 -0
- package/dist/internal/server.d.ts +25 -0
- package/dist/internal/server.d.ts.map +1 -0
- package/dist/internal/server.js +1374 -0
- package/dist/internal/session-engine.d.ts +287 -0
- package/dist/internal/session-engine.d.ts.map +1 -0
- package/dist/internal/session-engine.js +1377 -0
- package/dist/internal/session-store.d.ts +29 -0
- package/dist/internal/session-store.d.ts.map +1 -0
- package/dist/internal/session-store.js +140 -0
- package/dist/internal/session-urls.d.ts +10 -0
- package/dist/internal/session-urls.d.ts.map +1 -0
- package/dist/internal/session-urls.js +25 -0
- package/dist/internal/stream-progress.d.ts +14 -0
- package/dist/internal/stream-progress.d.ts.map +1 -0
- package/dist/internal/stream-progress.js +195 -0
- package/dist/internal/tool-result.d.ts +20 -0
- package/dist/internal/tool-result.d.ts.map +1 -0
- package/dist/internal/tool-result.js +45 -0
- package/dist/internal/trajectory.d.ts +56 -0
- package/dist/internal/trajectory.d.ts.map +1 -0
- package/dist/internal/trajectory.js +248 -0
- package/dist/internal/workspace.d.ts +42 -0
- package/dist/internal/workspace.d.ts.map +1 -0
- package/dist/internal/workspace.js +199 -0
- package/dist/playground/assets/cursor-icons-outline-oY2V_mvK.woff2 +0 -0
- package/dist/playground/assets/index-1K-hG-7p.css +1 -0
- package/dist/playground/assets/index-FlWjhg3x.js +79 -0
- package/dist/playground/index.html +17 -0
- package/dist/reminders.d.ts +23 -0
- package/dist/reminders.d.ts.map +1 -0
- package/dist/reminders.js +22 -0
- package/dist/schedules.d.ts +23 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/schedules.js +26 -0
- package/dist/skills.d.ts +22 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +22 -0
- package/dist/tools.d.ts +92 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +68 -0
- package/dist/types.d.ts +1609 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/docs/README.md +174 -0
- package/docs/ab.md +355 -0
- package/docs/building-with-agents.md +129 -0
- package/docs/concepts.md +177 -0
- package/docs/deployment.md +218 -0
- package/docs/evals.md +383 -0
- package/docs/guides/agent-to-agent.md +118 -0
- package/docs/guides/cloud-runtime.md +122 -0
- package/docs/guides/github.md +172 -0
- package/docs/guides/human-in-the-loop.md +131 -0
- package/docs/guides/slack.md +245 -0
- package/docs/guides/webhooks.md +201 -0
- package/docs/hillclimbing.md +93 -0
- package/docs/quickstart.md +183 -0
- package/docs/reference/agent-config.md +154 -0
- package/docs/reference/channels.md +206 -0
- package/docs/reference/cli.md +257 -0
- package/docs/reference/connections.md +137 -0
- package/docs/reference/hooks.md +74 -0
- package/docs/reference/http-api.md +219 -0
- package/docs/reference/instructions.md +77 -0
- package/docs/reference/playground.md +67 -0
- package/docs/reference/project-layout.md +119 -0
- package/docs/reference/schedules.md +220 -0
- package/docs/reference/sessions.md +165 -0
- package/docs/reference/skills.md +79 -0
- package/docs/reference/subagents.md +74 -0
- package/docs/reference/tools.md +203 -0
- package/docs/scaffolding-agents.md +113 -0
- package/docs/troubleshooting.md +95 -0
- package/package.json +185 -0
- package/skills/ab/SKILL.md +139 -0
- package/skills/create-agent/SKILL.md +219 -0
- package/skills/debug/SKILL.md +71 -0
- package/skills/evals/SKILL.md +217 -0
- package/skills/framework-map/SKILL.md +142 -0
- package/skills/github/SKILL.md +144 -0
- package/skills/hillclimb/SKILL.md +162 -0
- package/skills/setup-slack/SKILL.md +180 -0
- package/src/ab.ts +675 -0
- package/src/bin/agent-serve.ts +949 -0
- package/src/channels/github/api.ts +374 -0
- package/src/channels/github/auth.ts +275 -0
- package/src/channels/github/binding.ts +223 -0
- package/src/channels/github/defaults.ts +111 -0
- package/src/channels/github/events.ts +72 -0
- package/src/channels/github/forward.ts +381 -0
- package/src/channels/github/github-channel.ts +2270 -0
- package/src/channels/github/index.ts +52 -0
- package/src/channels/github/replay.ts +387 -0
- package/src/channels/github/state.ts +95 -0
- package/src/channels/github/types.ts +490 -0
- package/src/channels/slack/api.ts +580 -0
- package/src/channels/slack/approvals.ts +198 -0
- package/src/channels/slack/assistant.ts +76 -0
- package/src/channels/slack/auth.ts +112 -0
- package/src/channels/slack/channel-watch.ts +219 -0
- package/src/channels/slack/constants.ts +30 -0
- package/src/channels/slack/credentials.ts +90 -0
- package/src/channels/slack/cursor-account.ts +166 -0
- package/src/channels/slack/defaults.ts +450 -0
- package/src/channels/slack/dispatch.ts +293 -0
- package/src/channels/slack/doctor.ts +135 -0
- package/src/channels/slack/event-id-dedupe.ts +30 -0
- package/src/channels/slack/inbound.ts +219 -0
- package/src/channels/slack/index.ts +45 -0
- package/src/channels/slack/init.ts +133 -0
- package/src/channels/slack/interactive.ts +194 -0
- package/src/channels/slack/links.ts +23 -0
- package/src/channels/slack/live-delivery.ts +201 -0
- package/src/channels/slack/log.ts +83 -0
- package/src/channels/slack/manifest.ts +179 -0
- package/src/channels/slack/pr-ref.ts +50 -0
- package/src/channels/slack/setup.ts +97 -0
- package/src/channels/slack/slack-channel.ts +374 -0
- package/src/channels/slack/socket-mode.ts +154 -0
- package/src/channels/slack/stream.ts +63 -0
- package/src/channels/slack/tool-approval-events.ts +136 -0
- package/src/channels/slack/types.ts +349 -0
- package/src/channels.ts +385 -0
- package/src/connections.ts +89 -0
- package/src/evals.ts +501 -0
- package/src/hooks.ts +33 -0
- package/src/index.ts +184 -0
- package/src/internal/ab-collector.ts +210 -0
- package/src/internal/ab-fold.ts +228 -0
- package/src/internal/ab-snapshot.ts +335 -0
- package/src/internal/approval-gate.ts +115 -0
- package/src/internal/auth.ts +39 -0
- package/src/internal/authored-alias-hooks.ts +69 -0
- package/src/internal/authored-loaders.ts +138 -0
- package/src/internal/bounded-int.ts +27 -0
- package/src/internal/brand.ts +29 -0
- package/src/internal/chat-client.ts +407 -0
- package/src/internal/cli-ax.ts +474 -0
- package/src/internal/cli-cursor.ts +275 -0
- package/src/internal/cli-github.ts +849 -0
- package/src/internal/cli-slack.ts +175 -0
- package/src/internal/cloud-merge.ts +41 -0
- package/src/internal/cron.ts +78 -0
- package/src/internal/cursor/account-mcp.ts +472 -0
- package/src/internal/cursor/backend-client.ts +614 -0
- package/src/internal/cursor/credentials.ts +401 -0
- package/src/internal/cursor-event-relay.ts +281 -0
- package/src/internal/cursor-relay-core.ts +444 -0
- package/src/internal/cursor-slack-relay.ts +242 -0
- package/src/internal/describe-error.ts +4 -0
- package/src/internal/dev-mode.ts +20 -0
- package/src/internal/discovery.ts +1709 -0
- package/src/internal/distribution.ts +97 -0
- package/src/internal/docs-site.ts +191 -0
- package/src/internal/duration.ts +39 -0
- package/src/internal/eval-run-store.ts +519 -0
- package/src/internal/eval-runner.ts +522 -0
- package/src/internal/event-log.ts +175 -0
- package/src/internal/event-mapper.ts +272 -0
- package/src/internal/frontmatter.ts +77 -0
- package/src/internal/github-fanout.ts +159 -0
- package/src/internal/handleAgentServeTrigger.ts +156 -0
- package/src/internal/host-platforms.ts +144 -0
- package/src/internal/http-channel.ts +546 -0
- package/src/internal/ids.ts +44 -0
- package/src/internal/init-project.ts +165 -0
- package/src/internal/json-dir-store.ts +109 -0
- package/src/internal/json-schema.ts +69 -0
- package/src/internal/log-ring.ts +59 -0
- package/src/internal/map-pool.ts +32 -0
- package/src/internal/mcp-endpoint.ts +518 -0
- package/src/internal/mcp-host.ts +211 -0
- package/src/internal/net.ts +31 -0
- package/src/internal/peer-connections.ts +100 -0
- package/src/internal/playground/static.ts +189 -0
- package/src/internal/playground/toolchain.ts +277 -0
- package/src/internal/reminder-runner.ts +756 -0
- package/src/internal/reminder-schedule.ts +106 -0
- package/src/internal/reminder-store.ts +145 -0
- package/src/internal/resolved-connections.ts +145 -0
- package/src/internal/review-comments.ts +268 -0
- package/src/internal/router.ts +145 -0
- package/src/internal/run-client.ts +320 -0
- package/src/internal/schedule-runner.ts +161 -0
- package/src/internal/sdk-runner.ts +315 -0
- package/src/internal/server.ts +1737 -0
- package/src/internal/session-engine.ts +1810 -0
- package/src/internal/session-store.ts +147 -0
- package/src/internal/session-urls.ts +40 -0
- package/src/internal/stream-progress.ts +254 -0
- package/src/internal/tool-result.ts +54 -0
- package/src/internal/trajectory.ts +306 -0
- package/src/internal/workspace.ts +223 -0
- package/src/reminders.ts +35 -0
- package/src/schedules.ts +37 -0
- package/src/skills.ts +27 -0
- package/src/tools.ts +127 -0
- package/src/types.ts +1848 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor account credentials for the agent-serve host.
|
|
3
|
+
*
|
|
4
|
+
* Exactly one kind of secret exists at runtime: a **personal Cursor user API
|
|
5
|
+
* key**. Two ways to obtain it, one code path after that:
|
|
6
|
+
*
|
|
7
|
+
* - `agent-serve login` runs the same PKCE browser flow as `cursor-agent`
|
|
8
|
+
* and Sand, then uses the short-lived session once to mint a named,
|
|
9
|
+
* dashboard-revocable user API key — only the key is stored.
|
|
10
|
+
* - `CURSOR_API_KEY` (or `serve({ apiKey })`) wins over the stored key, so
|
|
11
|
+
* CI and hosted deployments stay env-driven.
|
|
12
|
+
*
|
|
13
|
+
* There is deliberately no session-token storage, refresh-token rotation, or
|
|
14
|
+
* cross-tool credential sharing here: short-lived access tokens are minted
|
|
15
|
+
* on demand from the API key (see `backend-client.ts`).
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
27
|
+
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
28
|
+
import { homedir } from "node:os";
|
|
29
|
+
import { dirname, join } from "node:path";
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
import { CLI_COMMAND_NAME } from "../distribution.js";
|
|
32
|
+
export const DEFAULT_CURSOR_BACKEND_URL = "https://api2.cursor.sh";
|
|
33
|
+
const DEFAULT_CURSOR_WEBSITE_URL = "https://cursor.com";
|
|
34
|
+
/** Backend API base URL (`CURSOR_API_BASE_URL` override for local dev). */
|
|
35
|
+
export function cursorBackendUrl() {
|
|
36
|
+
var _a;
|
|
37
|
+
return trimTrailingSlash((_a = process.env.CURSOR_API_BASE_URL) !== null && _a !== void 0 ? _a : DEFAULT_CURSOR_BACKEND_URL);
|
|
38
|
+
}
|
|
39
|
+
/** Website base URL for the login deep link (`CURSOR_WEBSITE_URL` override). */
|
|
40
|
+
export function cursorWebsiteUrl() {
|
|
41
|
+
var _a;
|
|
42
|
+
return trimTrailingSlash((_a = process.env.CURSOR_WEBSITE_URL) !== null && _a !== void 0 ? _a : DEFAULT_CURSOR_WEBSITE_URL);
|
|
43
|
+
}
|
|
44
|
+
function trimTrailingSlash(url) {
|
|
45
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
46
|
+
}
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Stored credential (one file, one secret)
|
|
49
|
+
// ============================================================================
|
|
50
|
+
const storedCredentialsSchema = z.object({
|
|
51
|
+
/** Backend the key was minted against; keys never cross backends. */
|
|
52
|
+
backendUrl: z.string(),
|
|
53
|
+
apiKey: z.string().min(1),
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* `~/.config/agent-serve/credentials.json` (0600), honoring
|
|
57
|
+
* `XDG_CONFIG_HOME`. `AGENT_SERVE_CONFIG_DIR` pins the directory outright
|
|
58
|
+
* (tests, containers).
|
|
59
|
+
*/
|
|
60
|
+
export function credentialsFilePath() {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const configDir = (_a = process.env.AGENT_SERVE_CONFIG_DIR) !== null && _a !== void 0 ? _a : join((_b = process.env.XDG_CONFIG_HOME) !== null && _b !== void 0 ? _b : join(homedir(), ".config"), "agent-serve");
|
|
63
|
+
return join(configDir, "credentials.json");
|
|
64
|
+
}
|
|
65
|
+
export function readStoredCredentials() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
let raw;
|
|
68
|
+
try {
|
|
69
|
+
raw = yield readFile(credentialsFilePath(), "utf8");
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = JSON.parse(raw);
|
|
77
|
+
}
|
|
78
|
+
catch (_b) {
|
|
79
|
+
// Corrupt file — treat as signed out; login rewrites it.
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const credentials = storedCredentialsSchema.safeParse(parsed);
|
|
83
|
+
if (!credentials.success) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
backendUrl: trimTrailingSlash(credentials.data.backendUrl),
|
|
88
|
+
apiKey: credentials.data.apiKey,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export function writeStoredCredentials(credentials) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const path = credentialsFilePath();
|
|
95
|
+
yield mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
96
|
+
yield writeFile(path, `${JSON.stringify(credentials, null, 2)}\n`, {
|
|
97
|
+
mode: 0o600,
|
|
98
|
+
});
|
|
99
|
+
// writeFile mode only applies on create; clamp pre-existing files too.
|
|
100
|
+
yield chmod(path, 0o600);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function clearStoredCredentials() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
try {
|
|
106
|
+
yield rm(credentialsFilePath());
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (_a) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolve the account API key for `backendUrl` (defaults to the active
|
|
116
|
+
* backend): explicit option → `CURSOR_API_KEY` → stored login. A stored key
|
|
117
|
+
* minted against a different backend is ignored rather than sent to the
|
|
118
|
+
* wrong host.
|
|
119
|
+
*/
|
|
120
|
+
export function resolveApiKey(options) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var _a;
|
|
123
|
+
const backendUrl = (_a = options === null || options === void 0 ? void 0 : options.backendUrl) !== null && _a !== void 0 ? _a : cursorBackendUrl();
|
|
124
|
+
if ((options === null || options === void 0 ? void 0 : options.apiKey) !== undefined && options.apiKey.trim() !== "") {
|
|
125
|
+
return { apiKey: options.apiKey.trim(), source: "option", backendUrl };
|
|
126
|
+
}
|
|
127
|
+
const envKey = process.env.CURSOR_API_KEY;
|
|
128
|
+
if (envKey !== undefined && envKey.trim() !== "") {
|
|
129
|
+
return { apiKey: envKey.trim(), source: "env", backendUrl };
|
|
130
|
+
}
|
|
131
|
+
const stored = yield readStoredCredentials();
|
|
132
|
+
if (stored !== undefined && stored.backendUrl === backendUrl) {
|
|
133
|
+
return { apiKey: stored.apiKey, source: "login", backendUrl };
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/** One-line hint for "no credentials" errors, shared across surfaces. */
|
|
139
|
+
export const SIGN_IN_HINT = `Run \`${CLI_COMMAND_NAME} login\` (or set CURSOR_API_KEY / pass serve({ apiKey })).`;
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// PKCE browser login (mirrors cursor-agent / Sand)
|
|
142
|
+
// ============================================================================
|
|
143
|
+
const loginPollResponseSchema = z.object({ accessToken: z.string() });
|
|
144
|
+
/**
|
|
145
|
+
* Build the `/loginDeepControl` deep link and its PKCE material. The portal
|
|
146
|
+
* completes the login and the backend holds the resulting session until
|
|
147
|
+
* {@link pollForLoginTokens} picks it up with the verifier.
|
|
148
|
+
*/
|
|
149
|
+
export function startBrowserLogin() {
|
|
150
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
151
|
+
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
152
|
+
const uuid = randomUUID();
|
|
153
|
+
const url = new URL("/loginDeepControl", `${cursorWebsiteUrl()}/`);
|
|
154
|
+
url.searchParams.set("challenge", challenge);
|
|
155
|
+
url.searchParams.set("uuid", uuid);
|
|
156
|
+
url.searchParams.set("mode", "login");
|
|
157
|
+
url.searchParams.set("redirectTarget", "cli");
|
|
158
|
+
return { loginUrl: url.toString(), uuid, verifier };
|
|
159
|
+
}
|
|
160
|
+
/** Backend pending-login 404 body from `respondToPollLogin` ("still waiting"). */
|
|
161
|
+
const POLL_PENDING_BODY = "Not found";
|
|
162
|
+
/**
|
|
163
|
+
* Poll `/auth/poll` until the browser login completes.
|
|
164
|
+
*
|
|
165
|
+
* **POST, with the verifier in the JSON body.** The verifier is redeemable:
|
|
166
|
+
* anyone holding it (plus the uuid) can complete the login and mint a durable
|
|
167
|
+
* user API key, so it must not reach a URL — not the backend's access log, not
|
|
168
|
+
* a proxy's request log, not a terminal. `POST /auth/poll` exists for exactly
|
|
169
|
+
* this reason.
|
|
170
|
+
*
|
|
171
|
+
* A backend that predates that route answers POST with a route-not-found 404.
|
|
172
|
+
* Those get one sticky fallback to `GET /auth/poll?uuid=…&verifier=…` — the
|
|
173
|
+
* shape the vscode client and Sand already use — so the login still works
|
|
174
|
+
* while the backend catches up. The fallback puts the verifier in the query
|
|
175
|
+
* string, which is the exposure POST was added to remove, so it warns; it
|
|
176
|
+
* disappears on its own once the backend serves POST.
|
|
177
|
+
*/
|
|
178
|
+
export function pollForLoginTokens(args) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
var _a;
|
|
181
|
+
var _b, _c, _d;
|
|
182
|
+
const backendUrl = trimTrailingSlash((_b = args.backendUrl) !== null && _b !== void 0 ? _b : cursorBackendUrl());
|
|
183
|
+
const fetchImpl = (_c = args.fetchImpl) !== null && _c !== void 0 ? _c : fetch;
|
|
184
|
+
const redact = (text) => truncate(redactVerifier(text, args.verifier));
|
|
185
|
+
const postUrl = `${backendUrl}/auth/poll`;
|
|
186
|
+
// Only built if the backend leaves us no choice (see the doc comment).
|
|
187
|
+
const getUrl = () => {
|
|
188
|
+
const url = new URL("/auth/poll", `${backendUrl}/`);
|
|
189
|
+
url.searchParams.set("uuid", args.uuid);
|
|
190
|
+
url.searchParams.set("verifier", args.verifier);
|
|
191
|
+
return url.toString();
|
|
192
|
+
};
|
|
193
|
+
const maxAttempts = (_d = args.maxAttempts) !== null && _d !== void 0 ? _d : 150;
|
|
194
|
+
let useGet = false;
|
|
195
|
+
let consecutiveErrors = 0;
|
|
196
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
197
|
+
if (isAborted(args.signal)) {
|
|
198
|
+
return { status: "cancelled" };
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
const response = useGet
|
|
202
|
+
? yield fetchImpl(getUrl(), Object.assign({ method: "GET", headers: { accept: "application/json" } }, (args.signal === undefined ? {} : { signal: args.signal })))
|
|
203
|
+
: yield fetchImpl(postUrl, Object.assign({ method: "POST", headers: {
|
|
204
|
+
accept: "application/json",
|
|
205
|
+
"content-type": "application/json",
|
|
206
|
+
}, body: JSON.stringify({ uuid: args.uuid, verifier: args.verifier }) }, (args.signal === undefined ? {} : { signal: args.signal })));
|
|
207
|
+
if (response.status === 404) {
|
|
208
|
+
const body = (yield response.text()).trim();
|
|
209
|
+
if (!useGet && body !== POLL_PENDING_BODY) {
|
|
210
|
+
// Any 404 on POST that is not the pending marker means this backend
|
|
211
|
+
// has no POST route. Retry the same attempt over GET rather than
|
|
212
|
+
// guessing at body shapes; GET's handling below is deliberately
|
|
213
|
+
// lenient, so an unrecognized body cannot strand the login.
|
|
214
|
+
useGet = true;
|
|
215
|
+
(_a = args.logger) === null || _a === void 0 ? void 0 : _a.call(args, `${backendUrl} has no POST /auth/poll; falling back to GET, which puts the single-use login verifier in the request URL (and the backend's access log). It will use POST once the backend deploys that route.`);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (useGet && isRouteNotFoundBody(body)) {
|
|
219
|
+
// Neither verb is served — polling harder cannot fix that.
|
|
220
|
+
return {
|
|
221
|
+
status: "failed",
|
|
222
|
+
message: `${backendUrl} serves neither POST nor GET /auth/poll (404: ${redact(body)})`,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// Pending: the browser sign-in has not landed yet. On GET this is
|
|
226
|
+
// deliberately lenient — treating an unrecognized 404 body as fatal is
|
|
227
|
+
// what made an earlier poll die on its first attempt and call it a
|
|
228
|
+
// timeout.
|
|
229
|
+
consecutiveErrors = 0;
|
|
230
|
+
}
|
|
231
|
+
else if (!response.ok) {
|
|
232
|
+
consecutiveErrors++;
|
|
233
|
+
if (consecutiveErrors >= 3) {
|
|
234
|
+
return {
|
|
235
|
+
status: "failed",
|
|
236
|
+
message: `${backendUrl}/auth/poll kept failing (${response.status}: ${redact((yield response.text()).trim())})`,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const body = loginPollResponseSchema.safeParse(yield response.json());
|
|
242
|
+
if (body.success && body.data.accessToken !== "") {
|
|
243
|
+
return { status: "signed_in", accessToken: body.data.accessToken };
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
status: "failed",
|
|
247
|
+
message: `${backendUrl}/auth/poll returned 200 without an accessToken`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
if (isAborted(args.signal)) {
|
|
253
|
+
return { status: "cancelled" };
|
|
254
|
+
}
|
|
255
|
+
consecutiveErrors++;
|
|
256
|
+
if (consecutiveErrors >= 3) {
|
|
257
|
+
return {
|
|
258
|
+
status: "failed",
|
|
259
|
+
message: `could not reach ${backendUrl}/auth/poll (${redact(error instanceof Error ? error.message : String(error))})`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
yield sleep(Math.min(1000 * Math.pow(1.2, attempt), 10000), args.signal);
|
|
264
|
+
}
|
|
265
|
+
return { status: "timed_out" };
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Fastify's route-not-found envelope: `{"message":"Route GET:/auth/poll not
|
|
270
|
+
* found",…}`. Distinct from the backend's pending marker ({@link
|
|
271
|
+
* POLL_PENDING_BODY}), and the only 404 shape on the GET path that is fatal.
|
|
272
|
+
*/
|
|
273
|
+
function isRouteNotFoundBody(body) {
|
|
274
|
+
if (!body.startsWith("{")) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const parsed = JSON.parse(body);
|
|
279
|
+
return (typeof parsed.message === "string" &&
|
|
280
|
+
/^Route \w+:/.test(parsed.message) &&
|
|
281
|
+
parsed.message.includes("not found"));
|
|
282
|
+
}
|
|
283
|
+
catch (_a) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Keep the verifier out of anything user-visible. Fastify's 404 body echoes the
|
|
289
|
+
* whole request URL — `Route GET:/auth/poll?uuid=…&verifier=… not found` — so
|
|
290
|
+
* echoing a poll response verbatim would print a redeemable secret into the
|
|
291
|
+
* terminal, CI logs, and pasted bug reports.
|
|
292
|
+
*/
|
|
293
|
+
function redactVerifier(text, verifier) {
|
|
294
|
+
if (verifier === "") {
|
|
295
|
+
return text;
|
|
296
|
+
}
|
|
297
|
+
let redacted = text.split(verifier).join("[verifier redacted]");
|
|
298
|
+
const encoded = encodeURIComponent(verifier);
|
|
299
|
+
if (encoded !== verifier) {
|
|
300
|
+
redacted = redacted.split(encoded).join("[verifier redacted]");
|
|
301
|
+
}
|
|
302
|
+
return redacted;
|
|
303
|
+
}
|
|
304
|
+
function truncate(value, max = 200) {
|
|
305
|
+
return value.length <= max ? value : `${value.slice(0, max)}…`;
|
|
306
|
+
}
|
|
307
|
+
// Reads the abort flag through a call boundary so repeated checks across an
|
|
308
|
+
// `await` aren't collapsed by control-flow narrowing (the signal is mutated
|
|
309
|
+
// by another task, so `aborted` really can flip mid-loop).
|
|
310
|
+
function isAborted(signal) {
|
|
311
|
+
return (signal === null || signal === void 0 ? void 0 : signal.aborted) === true;
|
|
312
|
+
}
|
|
313
|
+
function sleep(ms, signal) {
|
|
314
|
+
return new Promise((resolve) => {
|
|
315
|
+
if ((signal === null || signal === void 0 ? void 0 : signal.aborted) === true) {
|
|
316
|
+
resolve();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const timer = setTimeout(() => {
|
|
320
|
+
signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", onAbort);
|
|
321
|
+
resolve();
|
|
322
|
+
}, ms);
|
|
323
|
+
const onAbort = () => {
|
|
324
|
+
clearTimeout(timer);
|
|
325
|
+
resolve();
|
|
326
|
+
};
|
|
327
|
+
signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
|
|
328
|
+
});
|
|
329
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulls `/v0/scm-events` into agent-serve: register repos+events, long-poll
|
|
3
|
+
* with a durable offset under `<stateDir>/offset.json`. Registration-gated
|
|
4
|
+
* so consumption never starts unsubscribed. Shared streams: durable
|
|
5
|
+
* consumer id + repo/event filtering skip sibling deliveries.
|
|
6
|
+
*
|
|
7
|
+
* The long-poll lifecycle (consumer id, registration-gated consume loop,
|
|
8
|
+
* anchor/offset/backoff) lives in the shared {@link CursorRelayCore}; this
|
|
9
|
+
* module is the GitHub adapter over it. {@link RelayOffsetStore} and
|
|
10
|
+
* {@link compareStreamOffsets} are re-exported for stability.
|
|
11
|
+
*/
|
|
12
|
+
import { RelayOffsetStore } from "./cursor-relay-core.js";
|
|
13
|
+
export { RelayOffsetStore };
|
|
14
|
+
/** PR snapshot from scm-events compact metadata (Sand-style; no raw body). */
|
|
15
|
+
export type CursorScmPullRequestMeta = {
|
|
16
|
+
number: number;
|
|
17
|
+
url: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
body?: string | null;
|
|
20
|
+
draft?: boolean;
|
|
21
|
+
authorLogin?: string;
|
|
22
|
+
headRef?: string;
|
|
23
|
+
headSha?: string;
|
|
24
|
+
baseRef?: string;
|
|
25
|
+
baseSha?: string;
|
|
26
|
+
};
|
|
27
|
+
/** One event delivered by `GET /v0/scm-events` (metadata only). */
|
|
28
|
+
export interface CursorScmEvent {
|
|
29
|
+
offset: string;
|
|
30
|
+
provider: string;
|
|
31
|
+
eventName: string;
|
|
32
|
+
deliveryId?: string;
|
|
33
|
+
repo: string;
|
|
34
|
+
receivedAtMs: number;
|
|
35
|
+
/** Webhook `action` when present. */
|
|
36
|
+
action?: string;
|
|
37
|
+
/** PR number when the delivery is PR-scoped. */
|
|
38
|
+
prNumber?: number;
|
|
39
|
+
/** Canonical PR URL when known. */
|
|
40
|
+
prUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Richer PR snapshot when the backend saw `body.pull_request`. Enough to
|
|
43
|
+
* stub a Zod-valid GitHub `pull_request` webhook body.
|
|
44
|
+
*/
|
|
45
|
+
pullRequest?: CursorScmPullRequestMeta;
|
|
46
|
+
/** GitHub-side event time from the payload, when present. */
|
|
47
|
+
occurredAtMs?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface CursorEventRelayOptions {
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
apiKey: string;
|
|
52
|
+
repos: readonly string[];
|
|
53
|
+
events: readonly string[];
|
|
54
|
+
stateDir: string;
|
|
55
|
+
/** Called for each matching event; failures are logged, not retried. */
|
|
56
|
+
dispatch: (event: CursorScmEvent) => Promise<void>;
|
|
57
|
+
logger: (line: string) => void;
|
|
58
|
+
/** Test seam. Defaults to global fetch. */
|
|
59
|
+
fetchImpl?: typeof fetch;
|
|
60
|
+
/** Test seam: override long-poll wait (default 25s). */
|
|
61
|
+
pollWaitMs?: number;
|
|
62
|
+
}
|
|
63
|
+
/** Human-readable cursor-events log fragment: event, repo/PR, times, delivery. */
|
|
64
|
+
export declare function formatCursorScmEventLog(event: {
|
|
65
|
+
eventName: string;
|
|
66
|
+
repo: string;
|
|
67
|
+
action?: string;
|
|
68
|
+
prNumber?: number;
|
|
69
|
+
prUrl?: string;
|
|
70
|
+
receivedAtMs: number;
|
|
71
|
+
occurredAtMs?: number;
|
|
72
|
+
deliveryId?: string;
|
|
73
|
+
}): string;
|
|
74
|
+
/**
|
|
75
|
+
* Minimal GitHub webhook body from an SCM-events metadata envelope.
|
|
76
|
+
* When `pullRequest` has title + head/base refs+shas, emits a Zod-valid
|
|
77
|
+
* `pull_request` object for `onPullRequest`; otherwise identity-only stubs.
|
|
78
|
+
*/
|
|
79
|
+
export declare function scmMetadataToGitHubPayload(event: {
|
|
80
|
+
repo: string;
|
|
81
|
+
action?: string;
|
|
82
|
+
prNumber?: number;
|
|
83
|
+
prUrl?: string;
|
|
84
|
+
pullRequest?: CursorScmPullRequestMeta;
|
|
85
|
+
}): Record<string, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* GitHub SCM-events relay: a thin {@link CursorRelayCore} adapter. Consumers
|
|
88
|
+
* keep the same `new CursorEventRelay(options).start()/.stop()` surface.
|
|
89
|
+
*/
|
|
90
|
+
export declare class CursorEventRelay {
|
|
91
|
+
private readonly options;
|
|
92
|
+
private readonly core;
|
|
93
|
+
/**
|
|
94
|
+
* Normalized repos the server confirmed for THIS consumer. The stream is
|
|
95
|
+
* shared with sibling consumers of the same principal, so only events for
|
|
96
|
+
* these repos may dispatch.
|
|
97
|
+
*/
|
|
98
|
+
private subscribedRepos;
|
|
99
|
+
private readonly loggedSkippedRepos;
|
|
100
|
+
constructor(options: CursorEventRelayOptions);
|
|
101
|
+
/**
|
|
102
|
+
* Whether an event from the shared stream belongs to THIS consumer: the
|
|
103
|
+
* repo must be one the server confirmed for us and the event kind one the
|
|
104
|
+
* mounted channels declared. Anything else came from a sibling consumer's
|
|
105
|
+
* subscription and must not fire this host's hooks.
|
|
106
|
+
*/
|
|
107
|
+
private shouldDispatch;
|
|
108
|
+
start(): void;
|
|
109
|
+
stop(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=cursor-event-relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-event-relay.d.ts","sourceRoot":"","sources":["../../src/internal/cursor-event-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGL,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,8EAA8E;AAC9E,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AASD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAgBT;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoE1B;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAUf,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkC;IACvD;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqB;IAExD,YAA6B,OAAO,EAAE,uBAAuB,EAkD5D;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAatB,KAAK,IAAI,IAAI,CAEZ;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;CACF"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulls `/v0/scm-events` into agent-serve: register repos+events, long-poll
|
|
3
|
+
* with a durable offset under `<stateDir>/offset.json`. Registration-gated
|
|
4
|
+
* so consumption never starts unsubscribed. Shared streams: durable
|
|
5
|
+
* consumer id + repo/event filtering skip sibling deliveries.
|
|
6
|
+
*
|
|
7
|
+
* The long-poll lifecycle (consumer id, registration-gated consume loop,
|
|
8
|
+
* anchor/offset/backoff) lives in the shared {@link CursorRelayCore}; this
|
|
9
|
+
* module is the GitHub adapter over it. {@link RelayOffsetStore} and
|
|
10
|
+
* {@link compareStreamOffsets} are re-exported for stability.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { CursorRelayCore, RelayOffsetStore, } from "./cursor-relay-core.js";
|
|
22
|
+
export { RelayOffsetStore };
|
|
23
|
+
/** Human-readable cursor-events log fragment: event, repo/PR, times, delivery. */
|
|
24
|
+
export function formatCursorScmEventLog(event) {
|
|
25
|
+
var _a;
|
|
26
|
+
const action = event.action !== undefined && event.action !== "" ? `.${event.action}` : "";
|
|
27
|
+
const pr = event.prUrl !== undefined
|
|
28
|
+
? event.prUrl
|
|
29
|
+
: event.prNumber !== undefined
|
|
30
|
+
? `${event.repo}#${event.prNumber}`
|
|
31
|
+
: event.repo;
|
|
32
|
+
const received = new Date(event.receivedAtMs).toISOString();
|
|
33
|
+
const occurred = event.occurredAtMs !== undefined
|
|
34
|
+
? ` occurred=${new Date(event.occurredAtMs).toISOString()}`
|
|
35
|
+
: "";
|
|
36
|
+
const delivery = (_a = event.deliveryId) !== null && _a !== void 0 ? _a : "no delivery id";
|
|
37
|
+
return `${event.eventName}${action} on ${pr} received=${received}${occurred} (${delivery})`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Minimal GitHub webhook body from an SCM-events metadata envelope.
|
|
41
|
+
* When `pullRequest` has title + head/base refs+shas, emits a Zod-valid
|
|
42
|
+
* `pull_request` object for `onPullRequest`; otherwise identity-only stubs.
|
|
43
|
+
*/
|
|
44
|
+
export function scmMetadataToGitHubPayload(event) {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const slash = event.repo.indexOf("/");
|
|
47
|
+
const owner = slash === -1 ? "" : event.repo.slice(0, slash);
|
|
48
|
+
const name = slash === -1 ? event.repo : event.repo.slice(slash + 1);
|
|
49
|
+
const repoUrl = `https://github.com/${event.repo}`;
|
|
50
|
+
const prMeta = event.pullRequest;
|
|
51
|
+
const prNumber = (_a = prMeta === null || prMeta === void 0 ? void 0 : prMeta.number) !== null && _a !== void 0 ? _a : event.prNumber;
|
|
52
|
+
const prUrl = (_c = (_b = prMeta === null || prMeta === void 0 ? void 0 : prMeta.url) !== null && _b !== void 0 ? _b : event.prUrl) !== null && _c !== void 0 ? _c : (prNumber !== undefined ? `${repoUrl}/pull/${prNumber}` : undefined);
|
|
53
|
+
const payload = {
|
|
54
|
+
repository: {
|
|
55
|
+
full_name: event.repo,
|
|
56
|
+
name,
|
|
57
|
+
html_url: repoUrl,
|
|
58
|
+
owner: { login: owner },
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
payload.action = event.action;
|
|
62
|
+
const title = prMeta === null || prMeta === void 0 ? void 0 : prMeta.title;
|
|
63
|
+
const headRef = prMeta === null || prMeta === void 0 ? void 0 : prMeta.headRef;
|
|
64
|
+
const headSha = prMeta === null || prMeta === void 0 ? void 0 : prMeta.headSha;
|
|
65
|
+
const baseRef = prMeta === null || prMeta === void 0 ? void 0 : prMeta.baseRef;
|
|
66
|
+
const canStubTypedPr = prNumber !== undefined &&
|
|
67
|
+
prUrl !== undefined &&
|
|
68
|
+
title !== undefined &&
|
|
69
|
+
headRef !== undefined &&
|
|
70
|
+
headSha !== undefined &&
|
|
71
|
+
baseRef !== undefined;
|
|
72
|
+
if (canStubTypedPr) {
|
|
73
|
+
const pullRequest = {
|
|
74
|
+
number: prNumber,
|
|
75
|
+
html_url: prUrl,
|
|
76
|
+
title,
|
|
77
|
+
body: prMeta === null || prMeta === void 0 ? void 0 : prMeta.body,
|
|
78
|
+
draft: prMeta === null || prMeta === void 0 ? void 0 : prMeta.draft,
|
|
79
|
+
head: { ref: headRef, sha: headSha },
|
|
80
|
+
base: { ref: baseRef, sha: prMeta === null || prMeta === void 0 ? void 0 : prMeta.baseSha },
|
|
81
|
+
};
|
|
82
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.authorLogin) !== undefined) {
|
|
83
|
+
pullRequest.user = { login: prMeta.authorLogin };
|
|
84
|
+
}
|
|
85
|
+
payload.pull_request = pullRequest;
|
|
86
|
+
payload.issue = {
|
|
87
|
+
number: prNumber,
|
|
88
|
+
html_url: prUrl,
|
|
89
|
+
pull_request: {},
|
|
90
|
+
};
|
|
91
|
+
return payload;
|
|
92
|
+
}
|
|
93
|
+
if (prNumber !== undefined) {
|
|
94
|
+
payload.pull_request = {
|
|
95
|
+
number: prNumber,
|
|
96
|
+
html_url: prUrl !== null && prUrl !== void 0 ? prUrl : `${repoUrl}/pull/${prNumber}`,
|
|
97
|
+
};
|
|
98
|
+
payload.issue = {
|
|
99
|
+
number: prNumber,
|
|
100
|
+
html_url: prUrl !== null && prUrl !== void 0 ? prUrl : `${repoUrl}/pull/${prNumber}`,
|
|
101
|
+
pull_request: {},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return payload;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* GitHub SCM-events relay: a thin {@link CursorRelayCore} adapter. Consumers
|
|
108
|
+
* keep the same `new CursorEventRelay(options).start()/.stop()` surface.
|
|
109
|
+
*/
|
|
110
|
+
export class CursorEventRelay {
|
|
111
|
+
constructor(options) {
|
|
112
|
+
this.options = options;
|
|
113
|
+
/**
|
|
114
|
+
* Normalized repos the server confirmed for THIS consumer. The stream is
|
|
115
|
+
* shared with sibling consumers of the same principal, so only events for
|
|
116
|
+
* these repos may dispatch.
|
|
117
|
+
*/
|
|
118
|
+
this.subscribedRepos = new Set();
|
|
119
|
+
this.loggedSkippedRepos = new Set();
|
|
120
|
+
const adapter = {
|
|
121
|
+
logPrefix: "cursor-events",
|
|
122
|
+
subscribePath: "/v0/scm-events/subscriptions",
|
|
123
|
+
pollPath: "/v0/scm-events",
|
|
124
|
+
buildRegistrationBody: (consumerId) => ({
|
|
125
|
+
consumerId,
|
|
126
|
+
subscriptions: this.options.repos.map((repo) => ({
|
|
127
|
+
provider: "github",
|
|
128
|
+
repo,
|
|
129
|
+
events: [...this.options.events],
|
|
130
|
+
})),
|
|
131
|
+
}),
|
|
132
|
+
applyRegistrationResponse: (json) => {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const result = json;
|
|
135
|
+
const statuses = (_a = result.repos) !== null && _a !== void 0 ? _a : [];
|
|
136
|
+
this.subscribedRepos = new Set(statuses
|
|
137
|
+
.filter((status) => status.isSubscribed)
|
|
138
|
+
.map((status) => status.repo));
|
|
139
|
+
const lines = [];
|
|
140
|
+
for (const status of statuses.filter((s) => !s.isSubscribed)) {
|
|
141
|
+
lines.push(`not subscribed to ${status.repo}: ${(_b = status.detail) !== null && _b !== void 0 ? _b : "unknown reason"}`);
|
|
142
|
+
}
|
|
143
|
+
if (this.subscribedRepos.size > 0) {
|
|
144
|
+
lines.push(`subscribed to ${[...this.subscribedRepos].join(", ")} for events: ${this.options.events.join(", ")}`);
|
|
145
|
+
}
|
|
146
|
+
return lines;
|
|
147
|
+
},
|
|
148
|
+
shouldDispatch: (event) => this.shouldDispatch(event),
|
|
149
|
+
dispatch: (event) => this.options.dispatch(event),
|
|
150
|
+
};
|
|
151
|
+
this.core = new CursorRelayCore(Object.assign(Object.assign({ baseUrl: options.baseUrl, apiKey: options.apiKey, stateDir: options.stateDir, adapter, logger: options.logger }, (options.fetchImpl === undefined
|
|
152
|
+
? {}
|
|
153
|
+
: { fetchImpl: options.fetchImpl })), (options.pollWaitMs === undefined
|
|
154
|
+
? {}
|
|
155
|
+
: { pollWaitMs: options.pollWaitMs })));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Whether an event from the shared stream belongs to THIS consumer: the
|
|
159
|
+
* repo must be one the server confirmed for us and the event kind one the
|
|
160
|
+
* mounted channels declared. Anything else came from a sibling consumer's
|
|
161
|
+
* subscription and must not fire this host's hooks.
|
|
162
|
+
*/
|
|
163
|
+
shouldDispatch(event) {
|
|
164
|
+
if (!this.subscribedRepos.has(event.repo)) {
|
|
165
|
+
if (!this.loggedSkippedRepos.has(event.repo)) {
|
|
166
|
+
this.loggedSkippedRepos.add(event.repo);
|
|
167
|
+
this.options.logger(`[agent-serve] cursor-events: skipping events for ${event.repo}: not in this host's subscription (another consumer of this API key likely subscribed it)`);
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
return this.options.events.includes(event.eventName);
|
|
172
|
+
}
|
|
173
|
+
start() {
|
|
174
|
+
this.core.start();
|
|
175
|
+
}
|
|
176
|
+
stop() {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
yield this.core.stop();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|