@cursor/july 0.1.54 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agent-serve.js +30 -23
- package/dist/channels/github/github-channel.d.ts +12 -0
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +67 -15
- package/dist/channels/github/types.d.ts +27 -1
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/origin/cursor-account.d.ts +22 -0
- package/dist/channels/origin/cursor-account.d.ts.map +1 -0
- package/dist/channels/origin/cursor-account.js +35 -0
- package/dist/channels/origin/events.d.ts +10 -0
- package/dist/channels/origin/events.d.ts.map +1 -0
- package/dist/channels/origin/events.js +27 -0
- package/dist/channels/origin/index.d.ts +29 -0
- package/dist/channels/origin/index.d.ts.map +1 -0
- package/dist/channels/origin/index.js +28 -0
- package/dist/channels/origin/origin-channel.d.ts +68 -0
- package/dist/channels/origin/origin-channel.d.ts.map +1 -0
- package/dist/channels/origin/origin-channel.js +567 -0
- package/dist/channels/origin/origin-webhook.d.ts +38 -0
- package/dist/channels/origin/origin-webhook.d.ts.map +1 -0
- package/dist/channels/origin/origin-webhook.js +151 -0
- package/dist/channels/origin/types.d.ts +152 -0
- package/dist/channels/origin/types.d.ts.map +1 -0
- package/dist/channels/origin/types.js +1 -0
- package/dist/channels/slack/doctor.d.ts +17 -1
- package/dist/channels/slack/doctor.d.ts.map +1 -1
- package/dist/channels/slack/doctor.js +186 -10
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.DAKcDclS.js → app.CW3KJh72.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BuymfBAo.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BNIaCSfG.js → VPLocalSearchBox.Bk6EWpPj.js} +1 -1
- package/dist/docs/assets/chunks/{theme.B47GzJjc.js → theme.Bz9AodBA.js} +2 -2
- package/dist/docs/assets/{example-agents_fsd.md.DPz9ezO4.js → example-agents_fsd.md.ZeGEpAw_.js} +2 -2
- package/dist/docs/assets/{example-agents_fsd.md.DPz9ezO4.lean.js → example-agents_fsd.md.ZeGEpAw_.lean.js} +1 -1
- package/dist/docs/assets/{example-agents_security-reviewer.md.Dkf1gyo6.js → example-agents_security-reviewer.md.DBL1TwtP.js} +2 -2
- package/dist/docs/assets/{example-agents_security-reviewer.md.Dkf1gyo6.lean.js → example-agents_security-reviewer.md.DBL1TwtP.lean.js} +1 -1
- package/dist/docs/assets/guides_convert-automation.md.BhMzTkE5.js +12 -0
- package/dist/docs/assets/guides_convert-automation.md.BhMzTkE5.lean.js +1 -0
- package/dist/docs/assets/{guides_github.md.B8QKtIpw.js → guides_github.md.CLLQJKRB.js} +4 -4
- package/dist/docs/assets/{guides_github.md.B8QKtIpw.lean.js → guides_github.md.CLLQJKRB.lean.js} +1 -1
- package/dist/docs/assets/index.md.DhRHS_-L.js +5 -0
- package/dist/docs/assets/{index.md.COeoSkcF.lean.js → index.md.DhRHS_-L.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.-V6J7Cl8.js → reference_cli.md.Cl14Jfo3.js} +10 -2
- package/dist/docs/assets/{reference_cli.md.-V6J7Cl8.lean.js → reference_cli.md.Cl14Jfo3.lean.js} +1 -1
- package/dist/docs/assets/scaffolding-agents.md.CrWSA0Ko.js +1 -0
- package/dist/docs/assets/{scaffolding-agents.md.mkc3B_ZW.lean.js → scaffolding-agents.md.CrWSA0Ko.lean.js} +1 -1
- package/dist/docs/assets/templates_agentic-owners.md.BkTLORaU.js +14 -0
- package/dist/docs/assets/templates_agentic-owners.md.BkTLORaU.lean.js +1 -0
- package/dist/docs/assets/templates_demo.md.Bgd6MBaZ.js +4 -0
- package/dist/docs/assets/templates_demo.md.Bgd6MBaZ.lean.js +1 -0
- package/dist/docs/assets/templates_pr-autofixer.md.DcmoeUNZ.js +8 -0
- package/dist/docs/assets/templates_pr-autofixer.md.DcmoeUNZ.lean.js +1 -0
- package/dist/docs/assets/templates_security-reviewer.md.C0yIUaYs.js +2 -0
- package/dist/docs/assets/templates_security-reviewer.md.C0yIUaYs.lean.js +1 -0
- package/dist/docs/assets/templates_triage.md.DWuQ1bZz.js +9 -0
- package/dist/docs/assets/templates_triage.md.DWuQ1bZz.lean.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +5 -5
- package/dist/docs/deployment.html +4 -4
- package/dist/docs/evals.html +4 -4
- package/dist/docs/example-agents/approval-buddy.html +4 -4
- package/dist/docs/example-agents/benny.html +4 -4
- package/dist/docs/example-agents/bugbot.html +4 -4
- package/dist/docs/example-agents/codebase-wiki.html +4 -4
- package/dist/docs/example-agents/codeowners-review.html +4 -4
- package/dist/docs/example-agents/concierge.html +4 -4
- package/dist/docs/example-agents/fsd.html +5 -5
- package/dist/docs/example-agents/index.html +4 -4
- package/dist/docs/example-agents/knowledge-base.html +4 -4
- package/dist/docs/example-agents/oncall.html +4 -4
- package/dist/docs/example-agents/security-reviewer.html +5 -5
- package/dist/docs/example-agents/slack-agent.html +4 -4
- package/dist/docs/example-agents/weather-agent.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/convert-automation.html +36 -0
- package/dist/docs/guides/github.html +7 -7
- 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 +4 -4
- 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/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 +4 -4
- package/dist/docs/reference/cli.html +14 -6
- package/dist/docs/reference/connections.html +4 -4
- 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 +4 -4
- 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 +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +4 -4
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +38 -0
- package/dist/docs/templates/demo.html +28 -0
- package/dist/docs/templates/pr-autofixer.html +32 -0
- package/dist/docs/templates/security-reviewer.html +26 -0
- package/dist/docs/templates/triage.html +14 -16
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal/cli-ax.d.ts +2 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +30 -1
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/cli-slack.d.ts +4 -0
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +46 -20
- package/dist/internal/cursor-event-relay.d.ts +59 -11
- package/dist/internal/cursor-event-relay.d.ts.map +1 -1
- package/dist/internal/cursor-event-relay.js +133 -26
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +11 -2
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/handleAgentServeTrigger.d.ts +33 -6
- package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -1
- package/dist/internal/handleAgentServeTrigger.js +97 -19
- package/dist/internal/init-interview.d.ts +67 -0
- package/dist/internal/init-interview.d.ts.map +1 -0
- package/dist/internal/init-interview.js +300 -0
- package/dist/internal/init-project.d.ts +7 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +99 -43
- package/dist/internal/mcp-endpoint.d.ts +7 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +7 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +159 -57
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +20 -21
- package/dist/internal/session-links.d.ts +14 -0
- package/dist/internal/session-links.d.ts.map +1 -0
- package/dist/internal/session-links.js +69 -0
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +1 -0
- package/dist/internal/slack-provision-client.js +1 -1
- package/dist/playground/assets/index-ClbuaLpm.css +1 -0
- package/dist/playground/assets/index-SqkR13k_.js +85 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +19 -12
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +15 -0
- package/docs/example-agents/fsd.md +3 -0
- package/docs/example-agents/security-reviewer.md +3 -0
- package/docs/guides/convert-automation.md +176 -0
- package/docs/guides/github.md +6 -2
- package/docs/reference/cli.md +36 -10
- package/docs/scaffolding-agents.md +3 -0
- package/docs/templates/agentic-owners.md +97 -0
- package/docs/templates/demo.md +84 -0
- package/docs/templates/pr-autofixer.md +136 -0
- package/docs/templates/security-reviewer.md +89 -0
- package/docs/templates/triage.md +59 -101
- package/package.json +9 -1
- package/skills/github/SKILL.md +4 -5
- package/src/bin/agent-serve.ts +13 -6
- package/src/channels/github/github-channel.ts +95 -18
- package/src/channels/github/types.ts +31 -0
- package/src/channels/origin/cursor-account.ts +64 -0
- package/src/channels/origin/events.ts +41 -0
- package/src/channels/origin/index.ts +29 -0
- package/src/channels/origin/origin-channel.ts +784 -0
- package/src/channels/origin/origin-webhook.ts +202 -0
- package/src/channels/origin/types.ts +186 -0
- package/src/channels/slack/doctor.ts +218 -5
- package/src/index.ts +3 -1
- package/src/internal/cli-ax.ts +33 -1
- package/src/internal/cli-deploy.ts +2 -2
- package/src/internal/cli-slack.ts +68 -19
- package/src/internal/cursor-event-relay.ts +193 -31
- package/src/internal/discovery.ts +15 -5
- package/src/internal/distribution.ts +1 -0
- package/src/internal/handleAgentServeTrigger.ts +129 -19
- package/src/internal/init-interview.ts +384 -0
- package/src/internal/init-project.ts +146 -46
- package/src/internal/mcp-endpoint.ts +7 -0
- package/src/internal/server.ts +188 -58
- package/src/internal/session-engine.ts +5 -21
- package/src/internal/session-links.ts +88 -0
- package/src/internal/sessions-client.ts +1 -0
- package/src/internal/slack-provision-client.ts +1 -1
- package/src/types.ts +19 -12
- package/templates/agentic-owners/README.md +73 -0
- package/templates/agentic-owners/agent/agent.ts +15 -0
- package/templates/agentic-owners/agent/channels/github.ts +85 -0
- package/templates/agentic-owners/agent/instructions.md +34 -0
- package/templates/agentic-owners/agent/lib/config.ts +13 -0
- package/templates/agentic-owners/agent/lib/github.ts +241 -0
- package/templates/agentic-owners/agent/lib/owners/README.md +50 -0
- package/templates/agentic-owners/agent/lib/owners/constants.ts +22 -0
- package/templates/agentic-owners/agent/lib/owners/decision.ts +485 -0
- package/templates/agentic-owners/agent/lib/owners/handles.ts +54 -0
- package/templates/agentic-owners/agent/lib/owners/match.ts +177 -0
- package/templates/agentic-owners/agent/lib/owners/matching.ts +95 -0
- package/templates/agentic-owners/agent/lib/owners/parse.ts +589 -0
- package/templates/agentic-owners/agent/lib/owners/policyMode.ts +65 -0
- package/templates/agentic-owners/agent/lib/owners/prompt.ts +66 -0
- package/templates/agentic-owners/agent/lib/owners/prompts/base-review.md +105 -0
- package/templates/agentic-owners/agent/lib/owners/types.ts +45 -0
- package/templates/agentic-owners/agent/lib/review.ts +777 -0
- package/templates/agentic-owners/agent/tools/record_review.ts +69 -0
- package/templates/agentic-owners/evals/evals.config.ts +5 -0
- package/templates/agentic-owners/evals/owners.eval.ts +116 -0
- package/templates/agentic-owners/package.json +20 -0
- package/templates/agentic-owners/tsconfig.json +12 -0
- package/templates/demo/README.md +33 -0
- package/templates/demo/agent/agent.ts +15 -0
- package/templates/demo/agent/channels/github.ts +50 -0
- package/templates/demo/agent/channels/queue.ts +30 -0
- package/templates/demo/agent/instructions.md +8 -0
- package/templates/demo/agent/lib/collect.ts +78 -0
- package/templates/demo/agent/tools/record_demo.ts +40 -0
- package/templates/demo/evals/demo.eval.ts +33 -0
- package/templates/demo/evals/evals.config.ts +5 -0
- package/templates/demo/package.json +18 -0
- package/templates/demo/tsconfig.json +12 -0
- package/templates/pr-autofixer/README.md +44 -0
- package/templates/pr-autofixer/agent/agent.ts +22 -0
- package/templates/pr-autofixer/agent/channels/drive.ts +40 -0
- package/templates/pr-autofixer/agent/channels/github.ts +167 -0
- package/templates/pr-autofixer/agent/channels/slack.ts +17 -0
- package/templates/pr-autofixer/agent/hooks/bind-agent.ts +19 -0
- package/templates/pr-autofixer/agent/instructions.md +83 -0
- package/templates/pr-autofixer/agent/lib/affinity.ts +33 -0
- package/templates/pr-autofixer/agent/lib/drive-schemas.ts +15 -0
- package/templates/pr-autofixer/agent/lib/drive.ts +79 -0
- package/templates/pr-autofixer/agent/lib/merge-watch.ts +123 -0
- package/templates/pr-autofixer/agent/lib/pr-state.ts +54 -0
- package/templates/pr-autofixer/agent/lib/repos.ts +19 -0
- package/templates/pr-autofixer/agent/lib/start-drive.ts +122 -0
- package/templates/pr-autofixer/agent/lib/webhook-buffer.ts +225 -0
- package/templates/pr-autofixer/agent/lib/webhook-routing.ts +231 -0
- package/templates/pr-autofixer/agent/storage.ts +7 -0
- package/templates/pr-autofixer/agent/tools/drive_pr.ts +22 -0
- package/templates/pr-autofixer/evals/coordinator.eval.ts +16 -0
- package/templates/pr-autofixer/evals/evals.config.ts +5 -0
- package/templates/pr-autofixer/init.json +25 -0
- package/templates/pr-autofixer/package.json +18 -0
- package/templates/pr-autofixer/tsconfig.json +12 -0
- package/templates/security-reviewer/README.md +31 -0
- package/templates/security-reviewer/agent/agent.ts +15 -0
- package/templates/security-reviewer/agent/channels/github.ts +46 -0
- package/templates/security-reviewer/agent/instructions.md +22 -0
- package/templates/security-reviewer/agent/lib/repos.ts +5 -0
- package/templates/security-reviewer/agent/tools/post_findings.ts +72 -0
- package/templates/security-reviewer/evals/evals.config.ts +5 -0
- package/templates/security-reviewer/evals/review.eval.ts +53 -0
- package/templates/security-reviewer/init.json +25 -0
- package/templates/security-reviewer/package.json +18 -0
- package/templates/security-reviewer/tsconfig.json +12 -0
- package/templates/triage/README.md +27 -29
- package/templates/triage/agent/agent.ts +1 -0
- package/templates/triage/agent/channels/queue.ts +47 -0
- package/templates/triage/agent/channels/webhook.ts +50 -0
- package/templates/triage/agent/instructions.md +24 -13
- package/templates/triage/agent/lib/actuate.ts +759 -0
- package/templates/triage/agent/lib/parse-queue-event.ts +168 -0
- package/templates/triage/agent/lib/tracker.ts +5 -0
- package/templates/triage/agent/lib/types.ts +52 -0
- package/templates/triage/agent/lib/verify-webhook.ts +81 -0
- package/templates/triage/agent/skills/triage-rubric.md +6 -5
- package/templates/triage/agent/tools/record_triage.ts +24 -5
- package/templates/triage/evals/triage.eval.ts +25 -3
- package/templates/triage/overlays/jira/README.md +21 -0
- package/templates/triage/overlays/jira/agent/lib/tracker.ts +8 -0
- package/templates/triage/overlays/jira/agent/mcp-connections/tracker.ts +7 -0
- package/templates/triage/overlays/linear/README.md +21 -0
- package/templates/triage/overlays/linear/agent/lib/tracker.ts +8 -0
- package/templates/triage/overlays/linear/agent/mcp-connections/tracker.ts +7 -0
- package/templates/triage/package.json +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.C4uxzYEU.js +0 -1
- package/dist/docs/assets/index.md.COeoSkcF.js +0 -5
- package/dist/docs/assets/scaffolding-agents.md.mkc3B_ZW.js +0 -1
- package/dist/docs/assets/templates_triage.md.CConZt1z.js +0 -11
- package/dist/docs/assets/templates_triage.md.CConZt1z.lean.js +0 -1
- package/dist/playground/assets/index-BHAPd9KT.js +0 -85
- package/dist/playground/assets/index-DpKH0HcT.css +0 -1
- package/templates/triage/agent/channels/intake.ts +0 -20
- package/templates/triage/agent/channels/slack.ts +0 -3
package/src/bin/agent-serve.ts
CHANGED
|
@@ -108,7 +108,7 @@ Usage:
|
|
|
108
108
|
${CLI} trajectory --events <file.ndjson> [--text]
|
|
109
109
|
${CLI} call <tool> [--input <json>] [--dir <path> | --url <baseUrl> | --prod]
|
|
110
110
|
[--session <id>] [--slug <slug>] [--team <id>]
|
|
111
|
-
${CLI} init [dir] [--template <name>] [--json]
|
|
111
|
+
${CLI} init [dir] [--template <name>] [--var id=value]... [--json]
|
|
112
112
|
${CLI} convert-automation <url> [--dir <path>] [--json]
|
|
113
113
|
${CLI} install-skills [--print] [--json]
|
|
114
114
|
${CLI} mcp --prod [--slug <slug>] [--team <id>] [--dir <path>]
|
|
@@ -198,9 +198,10 @@ Commands:
|
|
|
198
198
|
via POST /v1/tools/:toolName. --session runs it inside an
|
|
199
199
|
existing session and records it on that session's event stream.
|
|
200
200
|
init Scaffold a project (skipping existing files), npm install,
|
|
201
|
-
run login when unsigned, then print next steps.
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
run login when unsigned, then print next steps. Templates
|
|
202
|
+
with init.json interview on a TTY; --var answers without a
|
|
203
|
+
prompt. --json is machine-readable and never blocks on
|
|
204
|
+
login. No directory: print the setup guide.
|
|
204
205
|
convert-automation
|
|
205
206
|
Export a Cursor Automation into an agentkit project. <url> is
|
|
206
207
|
the dashboard URL (…/automations/<uuid> or
|
|
@@ -481,6 +482,7 @@ async function main(argv: string[]): Promise<number> {
|
|
|
481
482
|
options: {
|
|
482
483
|
dir: { type: "string", default: "." },
|
|
483
484
|
template: { type: "string" },
|
|
485
|
+
var: { type: "string", multiple: true },
|
|
484
486
|
port: { type: "string" },
|
|
485
487
|
host: { type: "string" },
|
|
486
488
|
mode: { type: "string" },
|
|
@@ -540,7 +542,7 @@ async function main(argv: string[]): Promise<number> {
|
|
|
540
542
|
org: { type: "string" },
|
|
541
543
|
"cursor-events": { type: "boolean", default: false },
|
|
542
544
|
secret: { type: "string" },
|
|
543
|
-
channel: { type: "string" },
|
|
545
|
+
channel: { type: "string", multiple: true },
|
|
544
546
|
install: { type: "boolean", default: false },
|
|
545
547
|
action: { type: "string" },
|
|
546
548
|
conclusion: { type: "string" },
|
|
@@ -594,6 +596,7 @@ async function main(argv: string[]): Promise<number> {
|
|
|
594
596
|
prefix: values.prefix,
|
|
595
597
|
noPrefix: values["no-prefix"],
|
|
596
598
|
channelPosts: values["channel-posts"],
|
|
599
|
+
channels: values.channel,
|
|
597
600
|
slackTeam: values["slack-team"],
|
|
598
601
|
prod: values.prod,
|
|
599
602
|
team: values.team,
|
|
@@ -620,7 +623,9 @@ async function main(argv: string[]): Promise<number> {
|
|
|
620
623
|
return cmdGithub(positionals[0], {
|
|
621
624
|
dir,
|
|
622
625
|
slug: values.slug,
|
|
623
|
-
channel
|
|
626
|
+
// `--channel` is repeatable for `slack doctor`; the github
|
|
627
|
+
// subcommands target a single channel, so the last one wins.
|
|
628
|
+
channel: values.channel?.at(-1),
|
|
624
629
|
host: values.host,
|
|
625
630
|
port,
|
|
626
631
|
url: values.url,
|
|
@@ -646,6 +651,7 @@ async function main(argv: string[]): Promise<number> {
|
|
|
646
651
|
dir,
|
|
647
652
|
initTarget: positionals[0],
|
|
648
653
|
template: values.template,
|
|
654
|
+
vars: values.var,
|
|
649
655
|
json: values.json,
|
|
650
656
|
});
|
|
651
657
|
}
|
|
@@ -1375,6 +1381,7 @@ function axFromOptions(
|
|
|
1375
1381
|
tags: partial.tags,
|
|
1376
1382
|
evalIds: partial.evalIds,
|
|
1377
1383
|
initTarget: partial.initTarget,
|
|
1384
|
+
vars: partial.vars,
|
|
1378
1385
|
toolName: partial.toolName,
|
|
1379
1386
|
toolInput: partial.toolInput,
|
|
1380
1387
|
url: partial.url,
|
|
@@ -136,6 +136,16 @@ const githubPullRequestPayloadSchema: z.ZodType<GitHubPullRequestPayload> =
|
|
|
136
136
|
sha: z.string().optional(),
|
|
137
137
|
}),
|
|
138
138
|
}),
|
|
139
|
+
changes: z
|
|
140
|
+
.object({
|
|
141
|
+
base: z
|
|
142
|
+
.object({
|
|
143
|
+
ref: z.object({ from: z.string().min(1).optional() }).optional(),
|
|
144
|
+
})
|
|
145
|
+
.optional(),
|
|
146
|
+
})
|
|
147
|
+
.nullable()
|
|
148
|
+
.optional(),
|
|
139
149
|
sender: senderSchema,
|
|
140
150
|
installation: installationSchema,
|
|
141
151
|
label: z
|
|
@@ -184,6 +194,32 @@ export function githubContinuationKey(ctx: GitHubParsedContext): string {
|
|
|
184
194
|
return `${kind}:${ctx.repository.fullName}#${ctx.conversation.number}`;
|
|
185
195
|
}
|
|
186
196
|
|
|
197
|
+
export interface GitHubPullRequestRef {
|
|
198
|
+
owner: string;
|
|
199
|
+
repo: string;
|
|
200
|
+
number: number;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Parse a pull-request continuation key minted by
|
|
205
|
+
* {@link githubContinuationKey} back into its repo + number. Undefined for
|
|
206
|
+
* issue keys and non-GitHub sessions — lets a server tool recover which PR
|
|
207
|
+
* its session is pinned to without trusting model-provided identifiers.
|
|
208
|
+
*/
|
|
209
|
+
export function parseGitHubPrContinuationKey(
|
|
210
|
+
key: string
|
|
211
|
+
): GitHubPullRequestRef | undefined {
|
|
212
|
+
const match = /^github-pr:([^/#\s]+)\/([^#\s]+)#(\d+)$/.exec(key);
|
|
213
|
+
if (match === null) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
owner: match[1]!,
|
|
218
|
+
repo: match[2]!,
|
|
219
|
+
number: Number(match[3]!),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
187
223
|
/** @deprecated Prefer {@link githubContinuationKey}. */
|
|
188
224
|
export function githubPullRequestContinuationKey(
|
|
189
225
|
ctx: GitHubParsedContext
|
|
@@ -338,6 +374,9 @@ export function parseGitHubPullRequestEvent(args: {
|
|
|
338
374
|
...(payload.pull_request.base.sha === undefined
|
|
339
375
|
? {}
|
|
340
376
|
: { baseSha: payload.pull_request.base.sha }),
|
|
377
|
+
...(payload.changes?.base?.ref?.from === undefined
|
|
378
|
+
? {}
|
|
379
|
+
: { baseRefChangedFrom: payload.changes.base.ref.from }),
|
|
341
380
|
draft: payload.pull_request.draft ?? false,
|
|
342
381
|
merged: payload.pull_request.merged === true,
|
|
343
382
|
...(payload.pull_request.user?.login === undefined
|
|
@@ -1469,15 +1508,34 @@ async function startTurn(input: {
|
|
|
1469
1508
|
cloud?: AgentCloudOptions;
|
|
1470
1509
|
state: GitHubChannelState;
|
|
1471
1510
|
}): Promise<Response> {
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1511
|
+
const files = input.dispatch.workspaceFiles;
|
|
1512
|
+
const lazy = typeof files === "function";
|
|
1513
|
+
|
|
1514
|
+
const sendTurn = async () => {
|
|
1515
|
+
const workspaceFiles = lazy ? await files() : files;
|
|
1516
|
+
return input.args.send(input.message, {
|
|
1517
|
+
auth: input.dispatch.auth,
|
|
1518
|
+
continuationToken: githubContinuationKey(input.ctx),
|
|
1519
|
+
title: input.dispatch.title ?? defaultGitHubTitle(input.ctx),
|
|
1520
|
+
...(input.cloud === undefined ? {} : { cloud: input.cloud }),
|
|
1521
|
+
...(workspaceFiles === undefined ? {} : { workspaceFiles }),
|
|
1522
|
+
state: input.state as unknown as JsonValue,
|
|
1523
|
+
// Resume must refresh headSha / refs without wiping sticky banner id.
|
|
1524
|
+
refreshState: input.state as unknown as JsonValue,
|
|
1525
|
+
});
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
if (lazy) {
|
|
1529
|
+
scheduleAfterAck(input.args, async () => {
|
|
1530
|
+
await sendTurn();
|
|
1531
|
+
});
|
|
1532
|
+
return Response.json(
|
|
1533
|
+
{ ok: true, dispatched: true, mode: "turn" },
|
|
1534
|
+
{ status: 202 }
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
const session = await sendTurn();
|
|
1481
1539
|
return Response.json({
|
|
1482
1540
|
ok: true,
|
|
1483
1541
|
sessionId: session.id,
|
|
@@ -1486,22 +1544,41 @@ async function startTurn(input: {
|
|
|
1486
1544
|
});
|
|
1487
1545
|
}
|
|
1488
1546
|
|
|
1489
|
-
function
|
|
1547
|
+
function reportBackgroundFailure(error: unknown): void {
|
|
1548
|
+
const detail =
|
|
1549
|
+
error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
1550
|
+
console.error(`[github] background dispatch failed: ${detail}`);
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
function scheduleAfterAck(
|
|
1490
1554
|
args: ChannelHandlerArgs,
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
//
|
|
1495
|
-
// starts (and so tests can assert scheduling without racing microtasks).
|
|
1555
|
+
work: () => void | Promise<void>
|
|
1556
|
+
): void {
|
|
1557
|
+
// Defer past the current turn so the 202 can flush before work starts
|
|
1558
|
+
// (and so tests can assert scheduling without racing microtasks).
|
|
1496
1559
|
args.waitUntil(
|
|
1497
|
-
new Promise<void>((resolve
|
|
1560
|
+
new Promise<void>((resolve) => {
|
|
1498
1561
|
setImmediate(() => {
|
|
1499
1562
|
Promise.resolve()
|
|
1500
|
-
.then(
|
|
1501
|
-
.then(
|
|
1563
|
+
.then(work)
|
|
1564
|
+
.then(
|
|
1565
|
+
() => resolve(),
|
|
1566
|
+
(error: unknown) => {
|
|
1567
|
+
reportBackgroundFailure(error);
|
|
1568
|
+
resolve();
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1502
1571
|
});
|
|
1503
1572
|
})
|
|
1504
1573
|
);
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
function acknowledgeTask(
|
|
1577
|
+
args: ChannelHandlerArgs,
|
|
1578
|
+
dispatch: GitHubTaskDispatch,
|
|
1579
|
+
extra: Record<string, unknown>
|
|
1580
|
+
): Response {
|
|
1581
|
+
scheduleAfterAck(args, dispatch.task);
|
|
1505
1582
|
return Response.json(
|
|
1506
1583
|
{ ok: true, dispatched: true, mode: "task", ...extra },
|
|
1507
1584
|
{ status: 202 }
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ChannelEventHandlers,
|
|
7
7
|
ChannelStartArgs,
|
|
8
8
|
HostContext,
|
|
9
|
+
SendMessageOptions,
|
|
9
10
|
} from "../../types.js";
|
|
10
11
|
import type { GitHubApiOptions } from "./api.js";
|
|
11
12
|
import type { GitHubHandle, GitHubThread } from "./binding.js";
|
|
@@ -165,6 +166,13 @@ export type GitHubPullRequestPayload = {
|
|
|
165
166
|
sha?: string;
|
|
166
167
|
};
|
|
167
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* Present on `edited` deliveries; `changes.base.ref.from` carries the
|
|
171
|
+
* previous base branch when the PR was retargeted.
|
|
172
|
+
*/
|
|
173
|
+
changes?: {
|
|
174
|
+
base?: { ref?: { from?: string } };
|
|
175
|
+
} | null;
|
|
168
176
|
sender?: {
|
|
169
177
|
login?: string;
|
|
170
178
|
id?: number;
|
|
@@ -186,6 +194,13 @@ export interface GitHubPullRequestEvent {
|
|
|
186
194
|
headSha: string;
|
|
187
195
|
baseRef: string;
|
|
188
196
|
baseSha?: string;
|
|
197
|
+
/**
|
|
198
|
+
* On `edited` deliveries where the PR base was retargeted, the previous
|
|
199
|
+
* base branch (`changes.base.ref.from`). Undefined for every other edit
|
|
200
|
+
* (title / body), so `action === "edited" && baseRefChangedFrom` gates
|
|
201
|
+
* base-retarget handling without waking on prose edits.
|
|
202
|
+
*/
|
|
203
|
+
baseRefChangedFrom?: string;
|
|
189
204
|
draft: boolean;
|
|
190
205
|
/** True when the PR was merged (from the webhook payload). */
|
|
191
206
|
merged: boolean;
|
|
@@ -324,6 +339,11 @@ export interface GitHubEventContext {
|
|
|
324
339
|
*/
|
|
325
340
|
export type GitHubDispatch = GitHubTurnDispatch | GitHubTaskDispatch;
|
|
326
341
|
|
|
342
|
+
/** Files seeded into the session workspace before the turn. */
|
|
343
|
+
export type GitHubWorkspaceFiles = NonNullable<
|
|
344
|
+
SendMessageOptions["workspaceFiles"]
|
|
345
|
+
>;
|
|
346
|
+
|
|
327
347
|
/** Start (or resume) a model turn for the event. */
|
|
328
348
|
export interface GitHubTurnDispatch {
|
|
329
349
|
/** Who the turn runs as. Use `defaultGitHubAuth(ctx)` to derive it from the actor. */
|
|
@@ -334,6 +354,17 @@ export interface GitHubTurnDispatch {
|
|
|
334
354
|
message?: string;
|
|
335
355
|
/** Optional session title override. */
|
|
336
356
|
title?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Seeded into the session workspace before the turn (`send`'s
|
|
359
|
+
* `workspaceFiles`). A function runs after the webhook is
|
|
360
|
+
* acknowledged (202) so fetch I/O can outlive GitHub's ~10s window.
|
|
361
|
+
*/
|
|
362
|
+
workspaceFiles?:
|
|
363
|
+
| GitHubWorkspaceFiles
|
|
364
|
+
| (() =>
|
|
365
|
+
| GitHubWorkspaceFiles
|
|
366
|
+
| undefined
|
|
367
|
+
| Promise<GitHubWorkspaceFiles | undefined>);
|
|
337
368
|
}
|
|
338
369
|
|
|
339
370
|
/**
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor-account mode for Origin channels.
|
|
3
|
+
*
|
|
4
|
+
* Origin identity is the signed-in Cursor user (no third-party OAuth). The
|
|
5
|
+
* channel declares repos at definition time; the serve host subscribes
|
|
6
|
+
* `/v0/scm-events` with `provider: "origin"` as that user. Unlike GitHub,
|
|
7
|
+
* there is no installation token to mint — outbound Origin API calls already
|
|
8
|
+
* authenticate as the Cursor principal.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { OriginChannelOptions } from "./types.js";
|
|
12
|
+
|
|
13
|
+
export const CURSOR_ORIGIN_MAX_REPOS = 20;
|
|
14
|
+
const CURSOR_ORIGIN_REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
15
|
+
|
|
16
|
+
export interface CursorOriginRepoScope {
|
|
17
|
+
repos: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface OriginCursorAccountRuntime {
|
|
21
|
+
options: OriginChannelOptions;
|
|
22
|
+
scope: CursorOriginRepoScope | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const runtimeByDefinition = new WeakMap<object, OriginCursorAccountRuntime>();
|
|
26
|
+
|
|
27
|
+
export function parseCursorOriginRepoScope(
|
|
28
|
+
values: readonly string[]
|
|
29
|
+
): CursorOriginRepoScope {
|
|
30
|
+
const repos = [
|
|
31
|
+
...new Set(values.map((repo) => repo.trim().toLowerCase()).filter(Boolean)),
|
|
32
|
+
];
|
|
33
|
+
if (repos.length === 0) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"originChannel({ cursorAccount }) requires at least one repository."
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (repos.length > CURSOR_ORIGIN_MAX_REPOS) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`originChannel({ cursorAccount }) supports at most ${CURSOR_ORIGIN_MAX_REPOS} repositories.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
for (const repo of repos) {
|
|
44
|
+
if (!CURSOR_ORIGIN_REPO_PATTERN.test(repo) || repo.includes("..")) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Invalid Origin repository "${repo}"; expected owner/repo.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { repos };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function registerOriginCursorAccountRuntime(
|
|
54
|
+
definition: object,
|
|
55
|
+
runtime: OriginCursorAccountRuntime
|
|
56
|
+
): void {
|
|
57
|
+
runtimeByDefinition.set(definition, runtime);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getOriginCursorAccountRuntime(
|
|
61
|
+
definition: object
|
|
62
|
+
): OriginCursorAccountRuntime | undefined {
|
|
63
|
+
return runtimeByDefinition.get(definition);
|
|
64
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** {@link ChannelMeta.kind} value used by {@link originChannel}. */
|
|
2
|
+
export const ORIGIN_CHANNEL_KIND = "origin";
|
|
3
|
+
|
|
4
|
+
const BASE_WEBHOOK_EVENTS: readonly string[] = [
|
|
5
|
+
"pull_request.created",
|
|
6
|
+
"pull_request.published",
|
|
7
|
+
"pull_request.head_ref.pushed",
|
|
8
|
+
"pull_request.base_ref.updated",
|
|
9
|
+
"pull_request.closed",
|
|
10
|
+
"pull_request.merged",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const COMMENT_EVENTS: readonly string[] = ["pull_request.comment.created"];
|
|
14
|
+
const REVIEW_EVENTS: readonly string[] = ["pull_request.review.submitted"];
|
|
15
|
+
|
|
16
|
+
export interface OriginWebhookEventOptions {
|
|
17
|
+
webhookEvents?: readonly string[];
|
|
18
|
+
onComment?: unknown;
|
|
19
|
+
onReview?: unknown;
|
|
20
|
+
onEvent?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function deriveOriginWebhookEvents(
|
|
24
|
+
options: OriginWebhookEventOptions
|
|
25
|
+
): string[] {
|
|
26
|
+
if (options.webhookEvents !== undefined) {
|
|
27
|
+
return [
|
|
28
|
+
...new Set(
|
|
29
|
+
options.webhookEvents.map((event) => event.trim()).filter(Boolean)
|
|
30
|
+
),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
const events: string[] = [...BASE_WEBHOOK_EVENTS];
|
|
34
|
+
if (options.onComment !== undefined) {
|
|
35
|
+
events.push(...COMMENT_EVENTS);
|
|
36
|
+
}
|
|
37
|
+
if (options.onReview !== undefined) {
|
|
38
|
+
events.push(...REVIEW_EVENTS);
|
|
39
|
+
}
|
|
40
|
+
return [...new Set(events)];
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Origin webhook channel pack for agent-serve.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { defaultOriginAuth, originChannel } from "@cursor/july/channels/origin";
|
|
6
|
+
*
|
|
7
|
+
* export default originChannel({
|
|
8
|
+
* cursorAccount: { repos: ["owner/repo"] },
|
|
9
|
+
* onPullRequest: (ctx) => ({ auth: defaultOriginAuth(ctx) }),
|
|
10
|
+
* onComment: (ctx) => ({ auth: defaultOriginAuth(ctx) }),
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Direct webhook mode verifies Standard-Webhooks v1ed signatures **and**
|
|
15
|
+
* binds `envelope.appId` to {@link OriginChannelOptions.appId} (or
|
|
16
|
+
* `AGENT_SERVE_ORIGIN_APP_ID`). v1ed alone is not channel auth — Origin
|
|
17
|
+
* signs every app's deliveries with the same JWKS. Pass
|
|
18
|
+
* `{ cursorAccount: true }` to receive events from
|
|
19
|
+
* `serve({ cursor: { events: true } })` after `/v0/scm-events`
|
|
20
|
+
* (`provider: "origin"`) already verified them. The turn principal is
|
|
21
|
+
* `origin-webhook` plus the Origin actor — not the Cursor subscriber —
|
|
22
|
+
* matching GitHub's `github-webhook` pattern.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export * from "./cursor-account.js";
|
|
26
|
+
export * from "./events.js";
|
|
27
|
+
export * from "./origin-channel.js";
|
|
28
|
+
export * from "./origin-webhook.js";
|
|
29
|
+
export * from "./types.js";
|