@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
|
@@ -11,25 +11,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
|
-
import { existsSync,
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
15
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
16
16
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
17
17
|
import { CLI_COMMAND_NAME, PACKAGE_NAME, packageRootDir, packageVersion, } from "./distribution.js";
|
|
18
|
+
import { applyInitReplacements, isTemplateMetaPath, loadTemplateInitSpec, posixRel, templateFileHasReplacements, } from "./init-interview.js";
|
|
18
19
|
import { makePalette, stdoutPalette, } from "./terminal-style.js";
|
|
20
|
+
const TEMPLATES = {
|
|
21
|
+
"agentic-owners": { dir: "agentic-owners" },
|
|
22
|
+
demo: { dir: "demo" },
|
|
23
|
+
"pr-autofixer": { dir: "pr-autofixer" },
|
|
24
|
+
"security-reviewer": { dir: "security-reviewer" },
|
|
25
|
+
"triage-linear": { dir: "triage", overlay: "linear" },
|
|
26
|
+
"triage-jira": { dir: "triage", overlay: "jira" },
|
|
27
|
+
};
|
|
28
|
+
function canonicalTemplateName(name) {
|
|
29
|
+
return name === "triage" ? "triage-linear" : name;
|
|
30
|
+
}
|
|
19
31
|
export function availableTemplates() {
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
return readdirSync(templatesDir, { withFileTypes: true })
|
|
23
|
-
.filter((entry) => entry.isDirectory())
|
|
24
|
-
.map((entry) => entry.name)
|
|
25
|
-
.sort();
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
if (hasErrorCode(error, "ENOENT")) {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
32
|
+
return Object.keys(TEMPLATES).sort();
|
|
33
33
|
}
|
|
34
34
|
export function resolveTemplate(name) {
|
|
35
35
|
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
@@ -38,20 +38,22 @@ export function resolveTemplate(name) {
|
|
|
38
38
|
message: "template name must match /^[a-z][a-z0-9-]*$/",
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
? "no templates ship with this build"
|
|
45
|
-
: `available: ${available.join(", ")}`;
|
|
41
|
+
const resolved = canonicalTemplateName(name);
|
|
42
|
+
const entry = TEMPLATES[resolved];
|
|
43
|
+
if (entry === undefined) {
|
|
46
44
|
return {
|
|
47
45
|
ok: false,
|
|
48
|
-
message: `unknown template "${name}" (${
|
|
46
|
+
message: `unknown template "${name}" (available: ${availableTemplates().join(", ")})`,
|
|
49
47
|
};
|
|
50
48
|
}
|
|
49
|
+
const dir = join(packageRootDir(), "templates", entry.dir);
|
|
51
50
|
return {
|
|
52
51
|
ok: true,
|
|
53
|
-
name,
|
|
54
|
-
dir
|
|
52
|
+
name: resolved,
|
|
53
|
+
dir,
|
|
54
|
+
overlayDir: entry.overlay === undefined
|
|
55
|
+
? undefined
|
|
56
|
+
: join(dir, "overlays", entry.overlay),
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
@@ -79,6 +81,11 @@ export function checkInitTarget(rootDir, template) {
|
|
|
79
81
|
if (marker === template) {
|
|
80
82
|
return { ok: true };
|
|
81
83
|
}
|
|
84
|
+
if (marker !== undefined &&
|
|
85
|
+
template !== undefined &&
|
|
86
|
+
canonicalTemplateName(marker) === canonicalTemplateName(template)) {
|
|
87
|
+
return { ok: true };
|
|
88
|
+
}
|
|
82
89
|
if (template === undefined) {
|
|
83
90
|
return {
|
|
84
91
|
ok: false,
|
|
@@ -121,7 +128,7 @@ const SCAFFOLD_EMPTY_DIRS = [
|
|
|
121
128
|
];
|
|
122
129
|
export function initProject(options) {
|
|
123
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
var _a, _b;
|
|
131
|
+
var _a, _b, _c, _d, _e;
|
|
125
132
|
const rootDir = resolve(options.dir);
|
|
126
133
|
const projectName = basename(rootDir);
|
|
127
134
|
const name = (_a = options.name) !== null && _a !== void 0 ? _a : projectName;
|
|
@@ -145,25 +152,35 @@ export function initProject(options) {
|
|
|
145
152
|
});
|
|
146
153
|
if (options.templateDir !== undefined) {
|
|
147
154
|
const templateDir = options.templateDir;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
155
|
+
const overlayDir = options.overlayDir;
|
|
156
|
+
const overlayPaths = overlayDir ? yield listTemplateFiles(overlayDir) : [];
|
|
157
|
+
const overlaySet = new Set(overlayPaths);
|
|
158
|
+
const corePaths = (yield listTemplateFiles(templateDir)).filter((rel) => !overlaySet.has(rel));
|
|
159
|
+
const templateName = (_c = options.templateName) !== null && _c !== void 0 ? _c : basename(templateDir);
|
|
160
|
+
const initSpec = (_d = options.initSpec) !== null && _d !== void 0 ? _d : (yield loadTemplateInitSpec(templateDir));
|
|
161
|
+
const answers = (_e = options.answers) !== null && _e !== void 0 ? _e : {};
|
|
162
|
+
for (const rel of corePaths) {
|
|
163
|
+
yield writeTemplateFile({
|
|
164
|
+
write,
|
|
165
|
+
sourceDir: templateDir,
|
|
166
|
+
rel,
|
|
167
|
+
projectName,
|
|
168
|
+
templateName,
|
|
169
|
+
initSpec,
|
|
170
|
+
answers,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (overlayDir !== undefined) {
|
|
174
|
+
for (const rel of overlayPaths) {
|
|
175
|
+
yield writeTemplateFile({
|
|
176
|
+
write,
|
|
177
|
+
sourceDir: overlayDir,
|
|
178
|
+
rel,
|
|
179
|
+
projectName,
|
|
180
|
+
templateName,
|
|
181
|
+
initSpec,
|
|
182
|
+
answers,
|
|
183
|
+
});
|
|
167
184
|
}
|
|
168
185
|
}
|
|
169
186
|
return {
|
|
@@ -268,6 +285,38 @@ export default memoryHook();
|
|
|
268
285
|
};
|
|
269
286
|
});
|
|
270
287
|
}
|
|
288
|
+
function listTemplateFiles(root) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
const entries = yield readdir(root, {
|
|
291
|
+
recursive: true,
|
|
292
|
+
withFileTypes: true,
|
|
293
|
+
});
|
|
294
|
+
return entries
|
|
295
|
+
.filter((entry) => entry.isFile())
|
|
296
|
+
.map((entry) => posixRel(relative(root, join(entry.parentPath, entry.name))))
|
|
297
|
+
.filter((rel) => !isTemplateMetaPath(rel))
|
|
298
|
+
.sort();
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function writeTemplateFile(input) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
const source = join(input.sourceDir, input.rel);
|
|
304
|
+
if (input.rel === "package.json") {
|
|
305
|
+
const packageJson = JSON.parse(yield readFile(source, "utf8"));
|
|
306
|
+
packageJson.name = input.projectName;
|
|
307
|
+
packageJson.dependencies[PACKAGE_NAME] = `^${packageVersion()}`;
|
|
308
|
+
packageJson.cursorAgentTemplate = input.templateName;
|
|
309
|
+
yield input.write(input.rel, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (input.initSpec !== undefined &&
|
|
313
|
+
templateFileHasReplacements(input.initSpec, input.rel)) {
|
|
314
|
+
yield input.write(input.rel, applyInitReplacements(yield readFile(source, "utf8"), input.rel, input.initSpec, input.answers));
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
yield input.write(input.rel, yield readFile(source));
|
|
318
|
+
});
|
|
319
|
+
}
|
|
271
320
|
export function isEexist(error) {
|
|
272
321
|
return hasErrorCode(error, "EEXIST");
|
|
273
322
|
}
|
|
@@ -551,7 +600,14 @@ export function printInitGuide() {
|
|
|
551
600
|
|
|
552
601
|
Scaffold a project, then open the playground:
|
|
553
602
|
npx ${PACKAGE_NAME} init ./my-agent # installs deps + links agent-sdk onto PATH
|
|
554
|
-
npx ${PACKAGE_NAME} init ./my-
|
|
603
|
+
npx ${PACKAGE_NAME} init ./my-demo --template demo # record a PR walkthrough
|
|
604
|
+
npx ${PACKAGE_NAME} init ./my-reviewer --template security-reviewer # review PRs for security bugs
|
|
605
|
+
npx ${PACKAGE_NAME} init ./my-triage --template triage-linear # comment on Linear issues
|
|
606
|
+
npx ${PACKAGE_NAME} init ./my-triage --template triage-jira # comment on Jira issues
|
|
607
|
+
npx ${PACKAGE_NAME} init ./my-owners --template agentic-owners # review PRs via owners policies
|
|
608
|
+
npx ${PACKAGE_NAME} init ./pr-autofixer --template pr-autofixer # fix PRs on a cloud VM
|
|
609
|
+
# TTY asks for GitHub repos. Scripts pass --var:
|
|
610
|
+
# --var repos=acme/widgets,acme/api
|
|
555
611
|
cd ./my-agent && agent-sdk dev # or: npx ${PACKAGE_NAME} dev
|
|
556
612
|
|
|
557
613
|
Recommended loop once the project exists (from the project directory):
|
|
@@ -42,6 +42,13 @@ interface ConnectableMcpServer {
|
|
|
42
42
|
* transport per POST, JSON response mode, spec-compliant 405 on other
|
|
43
43
|
* methods. Shared by the per-agent MCP endpoint and the Cursor account
|
|
44
44
|
* bridge so the subtle transport/error plumbing exists once.
|
|
45
|
+
*
|
|
46
|
+
* Origin MCP in `backend/server/src/origin/mcp/originMcpHttpHandler.ts`
|
|
47
|
+
* is not a 1:1 copy: it races `request.signal` so a tool that ignores abort
|
|
48
|
+
* cannot hang, while this helper has no such backstop and still leaks an
|
|
49
|
+
* unsettled promise. backend/server cannot import `@cursor/july` internals,
|
|
50
|
+
* so Origin diverges on purpose. Do not extract a shared package, and do
|
|
51
|
+
* not port the abort race here, in that stack.
|
|
45
52
|
*/
|
|
46
53
|
export declare function handleStatelessMcpRequest(args: {
|
|
47
54
|
request: Request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-endpoint.d.ts","sourceRoot":"","sources":["../../src/internal/mcp-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,EAAE,wCAAwC,EAAE,MAAM,+DAA+D,CAAC;AAOzH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EAGZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAE7B,uEAAuE;AACvE,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAUtD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvE;AAED,yEAAyE;AACzE,UAAU,oBAAoB;IAC5B,OAAO,CAAC,SAAS,EAAE,wCAAwC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"mcp-endpoint.d.ts","sourceRoot":"","sources":["../../src/internal/mcp-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,EAAE,wCAAwC,EAAE,MAAM,+DAA+D,CAAC;AAOzH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EAGZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAE7B,uEAAuE;AACvE,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAUtD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvE;AAED,yEAAyE;AACzE,UAAU,oBAAoB;IAC5B,OAAO,CAAC,SAAS,EAAE,wCAAwC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,oBAAoB,CAAC;IACxC,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyCpB;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,CAMpE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,gBAAgB,CAanB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,gBAAgB,CAyBnB"}
|
|
@@ -49,6 +49,13 @@ const DEFAULT_WAIT_SECONDS = 50;
|
|
|
49
49
|
* transport per POST, JSON response mode, spec-compliant 405 on other
|
|
50
50
|
* methods. Shared by the per-agent MCP endpoint and the Cursor account
|
|
51
51
|
* bridge so the subtle transport/error plumbing exists once.
|
|
52
|
+
*
|
|
53
|
+
* Origin MCP in `backend/server/src/origin/mcp/originMcpHttpHandler.ts`
|
|
54
|
+
* is not a 1:1 copy: it races `request.signal` so a tool that ignores abort
|
|
55
|
+
* cannot hang, while this helper has no such backstop and still leaks an
|
|
56
|
+
* unsettled promise. backend/server cannot import `@cursor/july` internals,
|
|
57
|
+
* so Origin diverges on purpose. Do not extract a shared package, and do
|
|
58
|
+
* not port the abort race here, in that stack.
|
|
52
59
|
*/
|
|
53
60
|
export function handleStatelessMcpRequest(args) {
|
|
54
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkCH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAgHrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAwBpE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAaD,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,YAAY,GAAG,0BAA+B,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAywB3B"}
|
package/dist/internal/server.js
CHANGED
|
@@ -35,8 +35,10 @@ import { Buffer } from "node:buffer";
|
|
|
35
35
|
import { once } from "node:events";
|
|
36
36
|
import { createServer, } from "node:http";
|
|
37
37
|
import { join } from "node:path";
|
|
38
|
-
import { createCursorAccountGithubTokenResolver,
|
|
38
|
+
import { createCursorAccountGithubTokenResolver, getGithubCursorAccountRuntime, parseCursorGithubRepoScope, resolveCursorGithubPermissions, resolveCursorGithubProxyUrl, } from "../channels/github/cursor-account.js";
|
|
39
39
|
import { findGitHubChannelTargets } from "../channels/github/forward.js";
|
|
40
|
+
import { getOriginCursorAccountRuntime, parseCursorOriginRepoScope, } from "../channels/origin/cursor-account.js";
|
|
41
|
+
import { findOriginChannelTargets } from "../channels/origin/origin-channel.js";
|
|
40
42
|
import { dispatchCursorSlackEnvelope, getSlackCursorAccountRuntime, } from "../channels/slack/cursor-account.js";
|
|
41
43
|
import { assertSlackCursorAgentName } from "../channels/slack/types.js";
|
|
42
44
|
import { allowAll, bearerAuth, localDevStrict } from "../channels.js";
|
|
@@ -44,13 +46,13 @@ import { CursorAccountMcpBridge, collectCursorAccountConnections, cursorAccountM
|
|
|
44
46
|
import { CursorBackendClient } from "./cursor/backend-client.js";
|
|
45
47
|
import { cursorExternalApiUrl, resolveApiKey, SIGN_IN_HINT, } from "./cursor/credentials.js";
|
|
46
48
|
import { CursorGithubCredentialProvider } from "./cursor/github-credentials.js";
|
|
47
|
-
import { CursorEventRelay, formatCursorScmDispatchOutcome, formatCursorScmEventLog, scmMetadataToGitHubPayload, } from "./cursor-event-relay.js";
|
|
49
|
+
import { CursorEventRelay, formatCursorScmDispatchOutcome, formatCursorScmEventLog, scmMetadataToGitHubPayload, scmMetadataToOriginPayload, } from "./cursor-event-relay.js";
|
|
48
50
|
import { CursorSlackRelay, createCursorSlackApiCaller, formatCursorSlackEventLog, } from "./cursor-slack-relay.js";
|
|
49
51
|
import { formatDiagnostics, hasErrorDiagnostics, projectInfo, } from "./discovery.js";
|
|
50
52
|
import { packageVersion } from "./distribution.js";
|
|
51
53
|
import { docsSiteExists, ensureDocsSiteBundle, renderDocsFile, } from "./docs-site.js";
|
|
52
54
|
import { EvalRunConflictError, EvalRunEmptyError, EvalRunNotRunningError, EvalRunStore, EvalRunUnknownError, } from "./eval-run-store.js";
|
|
53
|
-
import { collectGitHubTriggerTargets, handleAgentServeTrigger, } from "./handleAgentServeTrigger.js";
|
|
55
|
+
import { collectGitHubTriggerTargets, collectOriginTriggerTargets, handleAgentServeTrigger, } from "./handleAgentServeTrigger.js";
|
|
54
56
|
import { createHostPlatforms, warmupHostGitHubAuth } from "./host-platforms.js";
|
|
55
57
|
import { buildHttpChannelRoutes, errorResponse, jsonResponse, readJsonObject, requireSessionOwner, } from "./http-channel.js";
|
|
56
58
|
import { validateToolInput } from "./json-schema.js";
|
|
@@ -73,7 +75,7 @@ import { ReminderRunner, ReminderValidationError, UnknownReminderError, } from "
|
|
|
73
75
|
import { assertAccountConnectionsNotAnonymous, resolveMountConnections, validateMountConnectionsConfig, } from "./resolved-connections.js";
|
|
74
76
|
import { Router } from "./router.js";
|
|
75
77
|
import { ScheduleRunner, UnknownScheduleError } from "./schedule-runner.js";
|
|
76
|
-
import { CursorSdkRunner
|
|
78
|
+
import { CursorSdkRunner } from "./sdk-runner.js";
|
|
77
79
|
import { SessionAuthError, SessionBusyError, SessionEngine, ToolInputError, ToolNotDirectlyCallableError, UnknownToolError, } from "./session-engine.js";
|
|
78
80
|
import { sessionUrlsForRequest } from "./session-urls.js";
|
|
79
81
|
function memoryHealthFields(engines) {
|
|
@@ -92,9 +94,9 @@ const ARTIFACTS_LIST_MAX_LIMIT = 1000;
|
|
|
92
94
|
*/
|
|
93
95
|
export function startServer(mounts_1) {
|
|
94
96
|
return __awaiter(this, arguments, void 0, function* (mounts, options = {}) {
|
|
95
|
-
var _a, _b, _c;
|
|
96
|
-
var
|
|
97
|
-
var
|
|
97
|
+
var _a, _b, _c, _d, _e;
|
|
98
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
99
|
+
var _y;
|
|
98
100
|
if (mounts.length === 0) {
|
|
99
101
|
throw new Error("startServer requires at least one agent mount");
|
|
100
102
|
}
|
|
@@ -106,16 +108,16 @@ export function startServer(mounts_1) {
|
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
const logRing = createLogRing({ capacity: 2000 });
|
|
109
|
-
const logger = logRing.wrap((
|
|
110
|
-
const dev = (
|
|
111
|
-
const playground = (
|
|
111
|
+
const logger = logRing.wrap((_f = options.logger) !== null && _f !== void 0 ? _f : ((line) => console.log(line)));
|
|
112
|
+
const dev = (_g = options.dev) !== null && _g !== void 0 ? _g : false;
|
|
113
|
+
const playground = (_h = options.playground) !== null && _h !== void 0 ? _h : true;
|
|
112
114
|
const noControlPlane = options.noControlPlane === true;
|
|
113
|
-
const runSchedules = (
|
|
114
|
-
const runReminders = (
|
|
115
|
+
const runSchedules = (_j = options.schedules) !== null && _j !== void 0 ? _j : !dev;
|
|
116
|
+
const runReminders = (_k = options.reminders) !== null && _k !== void 0 ? _k : !dev;
|
|
115
117
|
// Identify this process to the Cursor backend as agentkit (the SDK reads
|
|
116
118
|
// this when building its client-version header) so the internal-only
|
|
117
119
|
// agentkit_enabled gate applies to every turn.
|
|
118
|
-
(
|
|
120
|
+
(_l = (_y = process.env).CURSOR_AGENTKIT_VERSION) !== null && _l !== void 0 ? _l : (_y.CURSOR_AGENTKIT_VERSION = packageVersion());
|
|
119
121
|
const authoredOtel = pickAuthoredOtel(mounts.map((m) => ({
|
|
120
122
|
slug: m.slug,
|
|
121
123
|
name: m.project.name,
|
|
@@ -131,11 +133,18 @@ export function startServer(mounts_1) {
|
|
|
131
133
|
logger("[agent-sdk] otel: agent/otel.ts present but no OTLP exporters configured (set exporters or OTEL_EXPORTER_OTLP_ENDPOINT)");
|
|
132
134
|
}
|
|
133
135
|
const cursorGithubTargets = collectCursorGithubTargets(mounts);
|
|
136
|
+
const cursorOriginTargets = collectCursorOriginTargets(mounts);
|
|
134
137
|
const cursorGithubConfig = resolveCursorGithubEventConfig({
|
|
135
138
|
configured: options.cursorEvents,
|
|
136
139
|
targets: cursorGithubTargets,
|
|
137
140
|
});
|
|
138
|
-
const
|
|
141
|
+
const cursorOriginScope = resolveCursorOriginRepoScope({
|
|
142
|
+
explicitRepos: (_m = (_b = options.cursorEvents) === null || _b === void 0 ? void 0 : _b.repos) !== null && _m !== void 0 ? _m : [],
|
|
143
|
+
targets: cursorOriginTargets,
|
|
144
|
+
});
|
|
145
|
+
const effectiveCursorEvents = (_o = cursorGithubConfig.cursorEvents) !== null && _o !== void 0 ? _o : (cursorOriginScope === undefined
|
|
146
|
+
? undefined
|
|
147
|
+
: { repos: [...cursorOriginScope.repos] });
|
|
139
148
|
// One resolution for every Cursor credential consumer (SDK runner, account
|
|
140
149
|
// MCP bridge, SCM event relay, GitHub credentials): explicit option →
|
|
141
150
|
// CURSOR_API_KEY → stored `agent-serve login`.
|
|
@@ -210,7 +219,7 @@ export function startServer(mounts_1) {
|
|
|
210
219
|
// Published installs already ship the bundle; vite may be absent there.
|
|
211
220
|
yield ensurePlaygroundBundle(logger);
|
|
212
221
|
}
|
|
213
|
-
const docsSite = (
|
|
222
|
+
const docsSite = (_p = options.docs) !== null && _p !== void 0 ? _p : true;
|
|
214
223
|
if (docsSite) {
|
|
215
224
|
// Same pattern for the documentation site at /docs.
|
|
216
225
|
yield ensureDocsSiteBundle(logger);
|
|
@@ -218,12 +227,7 @@ export function startServer(mounts_1) {
|
|
|
218
227
|
if (options.allowAnonymous === true) {
|
|
219
228
|
logger("[agent-sdk] warning: --allow-anonymous admits every HTTP caller as the same principal; use only on a trusted network (e.g. Tailscale) and prefer --bearer-token for shared hosts");
|
|
220
229
|
}
|
|
221
|
-
const
|
|
222
|
-
dev,
|
|
223
|
-
});
|
|
224
|
-
const runner = (_l = options.runner) !== null && _l !== void 0 ? _l : new CursorSdkRunner(Object.assign(Object.assign(Object.assign({}, (accountKey === undefined ? {} : { apiKey: accountKey.apiKey })), { logger }), (workspaceScanCacheTtlMs === undefined
|
|
225
|
-
? {}
|
|
226
|
-
: { workspaceScanCacheTtlMs })));
|
|
230
|
+
const runner = (_q = options.runner) !== null && _q !== void 0 ? _q : new CursorSdkRunner(Object.assign(Object.assign({}, (accountKey === undefined ? {} : { apiKey: accountKey.apiKey })), { logger }));
|
|
227
231
|
const router = new Router();
|
|
228
232
|
const runtimes = [];
|
|
229
233
|
const channelStopHooks = [];
|
|
@@ -266,7 +270,7 @@ export function startServer(mounts_1) {
|
|
|
266
270
|
}
|
|
267
271
|
for (const { slug, project } of mounts) {
|
|
268
272
|
// Each agent gets an isolated state root so their sessions never mix.
|
|
269
|
-
const baseStateRoot = (
|
|
273
|
+
const baseStateRoot = (_r = options.stateRoot) !== null && _r !== void 0 ? _r : join(project.rootDir, ".agent-serve");
|
|
270
274
|
const stateRoot = slug === "" ? baseStateRoot : join(baseStateRoot, slug);
|
|
271
275
|
const otelCollector = otelRuntime === undefined
|
|
272
276
|
? undefined
|
|
@@ -313,7 +317,7 @@ export function startServer(mounts_1) {
|
|
|
313
317
|
reminderRunner = new ReminderRunner(engine, logger, timerClient);
|
|
314
318
|
const evalRuns = new EvalRunStore(project.rootDir, logger,
|
|
315
319
|
// Playground eval history mirrors onto the defineStorage evals table.
|
|
316
|
-
(
|
|
320
|
+
(_c = engine.storage) === null || _c === void 0 ? void 0 : _c.evalRuns());
|
|
317
321
|
// Eval history restores with the same startup step as sessions (reads
|
|
318
322
|
// also hydrate lazily, but doing it here surfaces store problems at
|
|
319
323
|
// boot and makes /v1/dev/evals complete from the first request).
|
|
@@ -382,7 +386,7 @@ export function startServer(mounts_1) {
|
|
|
382
386
|
}
|
|
383
387
|
catch (error) {
|
|
384
388
|
logger(`[agent-sdk] channel "${channel.id}" onStart failed: ${error instanceof Error
|
|
385
|
-
? ((
|
|
389
|
+
? ((_s = error.stack) !== null && _s !== void 0 ? _s : error.message)
|
|
386
390
|
: String(error)}`);
|
|
387
391
|
}
|
|
388
392
|
}
|
|
@@ -460,7 +464,14 @@ export function startServer(mounts_1) {
|
|
|
460
464
|
// job (backend `/github_webhook` already verified); we only admit loopback
|
|
461
465
|
// so this route is not a public unsigned endpoint. Agents decide whether
|
|
462
466
|
// to run via their onPullRequest / onComment / … hooks.
|
|
463
|
-
const
|
|
467
|
+
const collectGitHubTargets = () => collectGitHubTriggerTargets({
|
|
468
|
+
mounts: runtimes.map((runtime) => ({
|
|
469
|
+
slug: runtime.slug,
|
|
470
|
+
channels: runtime.project.channels,
|
|
471
|
+
buildHandlerArgs: (channelId) => buildChannelHandlerArgs({ runtime, channelId }),
|
|
472
|
+
})),
|
|
473
|
+
});
|
|
474
|
+
const collectOriginTargets = () => collectOriginTriggerTargets({
|
|
464
475
|
mounts: runtimes.map((runtime) => ({
|
|
465
476
|
slug: runtime.slug,
|
|
466
477
|
channels: runtime.project.channels,
|
|
@@ -480,7 +491,7 @@ export function startServer(mounts_1) {
|
|
|
480
491
|
bodyText,
|
|
481
492
|
eventName: request.headers.get("x-github-event"),
|
|
482
493
|
deliveryId: (_b = request.headers.get("x-github-delivery")) !== null && _b !== void 0 ? _b : undefined,
|
|
483
|
-
targets:
|
|
494
|
+
targets: collectGitHubTargets(),
|
|
484
495
|
});
|
|
485
496
|
const status = result.ok ? 202 : ((_c = (_a = result.targets[0]) === null || _a === void 0 ? void 0 : _a.status) !== null && _c !== void 0 ? _c : 500);
|
|
486
497
|
return jsonResponse(result, { status });
|
|
@@ -512,19 +523,23 @@ export function startServer(mounts_1) {
|
|
|
512
523
|
// Cursor SCM events relay (opt-in: serve({ cursorEvents }) / --cursor-events).
|
|
513
524
|
const cursorEventRelay = startCursorEventRelay({
|
|
514
525
|
config: effectiveCursorEvents,
|
|
526
|
+
githubRepos: (_t = (_d = cursorGithubConfig.cursorEvents) === null || _d === void 0 ? void 0 : _d.repos) !== null && _t !== void 0 ? _t : [],
|
|
527
|
+
originRepos: (_u = cursorOriginScope === null || cursorOriginScope === void 0 ? void 0 : cursorOriginScope.repos) !== null && _u !== void 0 ? _u : [],
|
|
515
528
|
stateRoot: options.stateRoot,
|
|
516
529
|
mounts,
|
|
517
530
|
auth: cursorEventsAuth,
|
|
518
531
|
logger,
|
|
519
|
-
|
|
520
|
-
|
|
532
|
+
collectGitHubTargets,
|
|
533
|
+
collectOriginTargets,
|
|
534
|
+
cursorAccountOnly: options.cursorEvents === undefined &&
|
|
535
|
+
(cursorGithubTargets.length > 0 || cursorOriginTargets.length > 0),
|
|
521
536
|
});
|
|
522
537
|
const server = createServer((req, res) => {
|
|
523
538
|
void instrumentHttp(otelRuntime, req, res, () => handleRequest(router, req, res, logger));
|
|
524
539
|
});
|
|
525
|
-
const host = (
|
|
540
|
+
const host = (_v = options.host) !== null && _v !== void 0 ? _v : "127.0.0.1";
|
|
526
541
|
const portWasExplicit = options.port !== undefined;
|
|
527
|
-
const requestedPort = (
|
|
542
|
+
const requestedPort = (_w = options.port) !== null && _w !== void 0 ? _w : DEFAULT_SERVE_PORT;
|
|
528
543
|
let boundPort;
|
|
529
544
|
try {
|
|
530
545
|
boundPort = yield listenHttpServer({
|
|
@@ -568,7 +583,7 @@ export function startServer(mounts_1) {
|
|
|
568
583
|
runtime.project.agent.cloud !== undefined;
|
|
569
584
|
if ((hasServerTools || bridgeableNames.length > 0) && cloudCapable) {
|
|
570
585
|
const basePath = runtime.slug === "" ? "" : `/${runtime.slug}`;
|
|
571
|
-
const publicToolsUrl = (
|
|
586
|
+
const publicToolsUrl = (_x = options.cloudToolsUrl) !== null && _x !== void 0 ? _x : (options.publicUrl === undefined
|
|
572
587
|
? undefined
|
|
573
588
|
: `${options.publicUrl.replace(/\/$/, "")}${basePath}${TOOL_MCP_ENDPOINT_PATH}`);
|
|
574
589
|
if (publicToolsUrl === undefined) {
|
|
@@ -620,7 +635,7 @@ export function startServer(mounts_1) {
|
|
|
620
635
|
const handle = {
|
|
621
636
|
url,
|
|
622
637
|
port: address.port,
|
|
623
|
-
project: (
|
|
638
|
+
project: (_e = runtimes[0]) === null || _e === void 0 ? void 0 : _e.project,
|
|
624
639
|
agents,
|
|
625
640
|
dispatchSchedule: (name, slug) => {
|
|
626
641
|
var _a;
|
|
@@ -1361,40 +1376,93 @@ function requireCursorEventsAuth(config, accountKey) {
|
|
|
1361
1376
|
/**
|
|
1362
1377
|
* Opt-in Cursor SCM events relay. Credentials are already required by
|
|
1363
1378
|
* {@link requireCursorEventsAuth}; the remaining unusable configs (no repos,
|
|
1364
|
-
* no github channel) warn and leave the relay off — serve still starts.
|
|
1379
|
+
* no github/origin channel) warn and leave the relay off — serve still starts.
|
|
1380
|
+
*
|
|
1381
|
+
* GitHub and Origin subscriptions are registered independently so mirrored
|
|
1382
|
+
* `owner/name` slugs do not mix. `--cursor-events --repo` feeds GitHub
|
|
1383
|
+
* channels; Origin is subscribed only when an `originChannel({ cursorAccount })`
|
|
1384
|
+
* opted in.
|
|
1365
1385
|
*/
|
|
1366
1386
|
function startCursorEventRelay(input) {
|
|
1367
1387
|
var _a;
|
|
1368
1388
|
var _b;
|
|
1369
|
-
const { config, stateRoot, mounts, auth, logger
|
|
1389
|
+
const { config, stateRoot, mounts, auth, logger } = input;
|
|
1370
1390
|
if (config === undefined || auth === undefined) {
|
|
1371
1391
|
return undefined;
|
|
1372
1392
|
}
|
|
1373
|
-
const repos = [...new Set(config.repos.map((repo) => repo.trim()))].filter((repo) => repo.length > 0);
|
|
1374
|
-
if (repos.length === 0) {
|
|
1375
|
-
logger("[agent-sdk] cursor-events: no repos configured (pass --repo owner/name); relay disabled");
|
|
1376
|
-
return undefined;
|
|
1377
|
-
}
|
|
1378
1393
|
const githubTargets = findGitHubChannelTargets(mounts);
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
|
|
1394
|
+
const originTargets = findOriginChannelTargets(mounts);
|
|
1395
|
+
const githubEvents = [
|
|
1396
|
+
...new Set(githubTargets.flatMap((target) => target.events)),
|
|
1397
|
+
];
|
|
1398
|
+
const originEvents = [
|
|
1399
|
+
...new Set(originTargets.flatMap((target) => target.events)),
|
|
1400
|
+
];
|
|
1401
|
+
const githubRepos = [
|
|
1402
|
+
...new Set(input.githubRepos.map((repo) => repo.trim().toLowerCase())),
|
|
1403
|
+
].filter((repo) => repo.length > 0);
|
|
1404
|
+
const originRepos = [
|
|
1405
|
+
...new Set(input.originRepos.map((repo) => repo.trim().toLowerCase())),
|
|
1406
|
+
].filter((repo) => repo.length > 0);
|
|
1407
|
+
const subscriptions = [];
|
|
1408
|
+
if (githubEvents.length > 0 && githubRepos.length > 0) {
|
|
1409
|
+
for (const repo of githubRepos) {
|
|
1410
|
+
subscriptions.push({
|
|
1411
|
+
provider: "github",
|
|
1412
|
+
repo,
|
|
1413
|
+
events: githubEvents,
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
if (originEvents.length > 0 && originRepos.length > 0) {
|
|
1418
|
+
for (const repo of originRepos) {
|
|
1419
|
+
subscriptions.push({
|
|
1420
|
+
provider: "origin",
|
|
1421
|
+
repo,
|
|
1422
|
+
events: originEvents,
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
if (subscriptions.length === 0) {
|
|
1427
|
+
if (githubRepos.length === 0 && originRepos.length === 0) {
|
|
1428
|
+
logger("[agent-sdk] cursor-events: no repos configured (pass --repo owner/name); relay disabled");
|
|
1429
|
+
}
|
|
1430
|
+
else {
|
|
1431
|
+
logger("[agent-sdk] cursor-events: no mounted agent declares a github or origin channel; relay disabled");
|
|
1432
|
+
}
|
|
1382
1433
|
return undefined;
|
|
1383
1434
|
}
|
|
1384
1435
|
const baseStateRoot = stateRoot !== null && stateRoot !== void 0 ? stateRoot : join((_b = (_a = mounts[0]) === null || _a === void 0 ? void 0 : _a.project.rootDir) !== null && _b !== void 0 ? _b : process.cwd(), ".agent-serve");
|
|
1385
1436
|
const relay = new CursorEventRelay({
|
|
1386
1437
|
baseUrl: auth.baseUrl,
|
|
1387
1438
|
apiKey: auth.apiKey,
|
|
1388
|
-
|
|
1389
|
-
events,
|
|
1439
|
+
subscriptions,
|
|
1390
1440
|
stateDir: join(baseStateRoot, "cursor-events"),
|
|
1391
1441
|
logger,
|
|
1392
|
-
// Stream is compact metadata (Sand-style); stub a GitHub body from the
|
|
1393
|
-
// envelope — rich pullRequest meta when present for onPullRequest Zod.
|
|
1394
1442
|
dispatch: (event) => __awaiter(this, void 0, void 0, function* () {
|
|
1443
|
+
if (event.provider === "origin") {
|
|
1444
|
+
const targets = input.collectOriginTargets().filter((target) => {
|
|
1445
|
+
const cursorAccount = target.options.cursorAccount;
|
|
1446
|
+
if (input.cursorAccountOnly &&
|
|
1447
|
+
cursorAccount !== true &&
|
|
1448
|
+
typeof cursorAccount !== "object") {
|
|
1449
|
+
return false;
|
|
1450
|
+
}
|
|
1451
|
+
return typeof cursorAccount !== "object"
|
|
1452
|
+
? true
|
|
1453
|
+
: cursorAccount.repos.some((repo) => repo.toLowerCase() === event.repo.toLowerCase());
|
|
1454
|
+
});
|
|
1455
|
+
const result = yield handleAgentServeTrigger({
|
|
1456
|
+
type: "origin",
|
|
1457
|
+
bodyText: JSON.stringify(scmMetadataToOriginPayload(event)),
|
|
1458
|
+
targets,
|
|
1459
|
+
});
|
|
1460
|
+
logCursorScmDispatch(logger, event, result);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1395
1463
|
if (event.provider !== "github")
|
|
1396
1464
|
return;
|
|
1397
|
-
const targets =
|
|
1465
|
+
const targets = input.collectGitHubTargets().filter((target) => {
|
|
1398
1466
|
const cursorAccount = target.options.cursorAccount;
|
|
1399
1467
|
if (input.cursorAccountOnly &&
|
|
1400
1468
|
cursorAccount !== true &&
|
|
@@ -1412,20 +1480,23 @@ function startCursorEventRelay(input) {
|
|
|
1412
1480
|
deliveryId: event.deliveryId,
|
|
1413
1481
|
targets,
|
|
1414
1482
|
});
|
|
1415
|
-
|
|
1416
|
-
.map((target) => formatCursorScmDispatchOutcome(target))
|
|
1417
|
-
.join(", ");
|
|
1418
|
-
const rejected = result.targets.filter((target) => target.status >= 400);
|
|
1419
|
-
if (rejected.length > 0) {
|
|
1420
|
-
logger(`[agent-sdk] cursor-events: dropped ${formatCursorScmEventLog(event)} before hook: ${rejected.map(formatCursorScmDispatchOutcome).join(", ")}`);
|
|
1421
|
-
}
|
|
1422
|
-
logger(`[agent-sdk] cursor-events: dispatched ${formatCursorScmEventLog(event)}${outcomes === "" ? "" : ` → ${outcomes}`}`);
|
|
1483
|
+
logCursorScmDispatch(logger, event, result);
|
|
1423
1484
|
}),
|
|
1424
1485
|
});
|
|
1425
1486
|
relay.start();
|
|
1426
|
-
logger(`[agent-sdk] cursor-events: relaying ${
|
|
1487
|
+
logger(`[agent-sdk] cursor-events: relaying ${subscriptions.length} subscription(s) from ${auth.baseUrl}`);
|
|
1427
1488
|
return relay;
|
|
1428
1489
|
}
|
|
1490
|
+
function logCursorScmDispatch(logger, event, result) {
|
|
1491
|
+
const outcomes = result.targets
|
|
1492
|
+
.map((target) => formatCursorScmDispatchOutcome(target))
|
|
1493
|
+
.join(", ");
|
|
1494
|
+
const rejected = result.targets.filter((target) => target.status >= 400);
|
|
1495
|
+
if (rejected.length > 0) {
|
|
1496
|
+
logger(`[agent-sdk] cursor-events: dropped ${formatCursorScmEventLog(event)} before hook: ${rejected.map(formatCursorScmDispatchOutcome).join(", ")}`);
|
|
1497
|
+
}
|
|
1498
|
+
logger(`[agent-sdk] cursor-events: dispatched ${formatCursorScmEventLog(event)}${outcomes === "" ? "" : ` → ${outcomes}`}`);
|
|
1499
|
+
}
|
|
1429
1500
|
function collectCursorGithubTargets(mounts) {
|
|
1430
1501
|
const targets = [];
|
|
1431
1502
|
for (const mount of mounts) {
|
|
@@ -1454,13 +1525,44 @@ function resolveCursorGithubEventConfig(input) {
|
|
|
1454
1525
|
...((_b = (_a = target.accountRuntime.scope) === null || _a === void 0 ? void 0 : _a.repos) !== null && _b !== void 0 ? _b : []),
|
|
1455
1526
|
]; }),
|
|
1456
1527
|
];
|
|
1457
|
-
const permissions = resolveCursorGithubPermissions(input.targets.map((target) => { var _a; return
|
|
1528
|
+
const permissions = resolveCursorGithubPermissions(input.targets.map((target) => { var _a; var _b; return (_b = (_a = target.accountRuntime.scope) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : "pr-write"; }));
|
|
1458
1529
|
const scope = parseCursorGithubRepoScope(repos, permissions);
|
|
1459
1530
|
return {
|
|
1460
1531
|
cursorEvents: Object.assign(Object.assign({}, input.configured), { repos: [...scope.repos] }),
|
|
1461
1532
|
scope,
|
|
1462
1533
|
};
|
|
1463
1534
|
}
|
|
1535
|
+
function collectCursorOriginTargets(mounts) {
|
|
1536
|
+
const targets = [];
|
|
1537
|
+
for (const mount of mounts) {
|
|
1538
|
+
for (const channel of mount.project.channels) {
|
|
1539
|
+
const accountRuntime = getOriginCursorAccountRuntime(channel.definition);
|
|
1540
|
+
if (accountRuntime !== undefined) {
|
|
1541
|
+
targets.push({
|
|
1542
|
+
slug: mount.slug,
|
|
1543
|
+
channelId: channel.id,
|
|
1544
|
+
accountRuntime,
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return targets;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Origin cursorAccount repos. `true` takes the host's explicit `--repo`
|
|
1553
|
+
* list (not GitHub channel-declared repos). `{ repos }` is self-contained.
|
|
1554
|
+
*/
|
|
1555
|
+
function resolveCursorOriginRepoScope(input) {
|
|
1556
|
+
if (input.targets.length === 0) {
|
|
1557
|
+
return undefined;
|
|
1558
|
+
}
|
|
1559
|
+
const wantsHostRepos = input.targets.some((target) => target.accountRuntime.options.cursorAccount === true);
|
|
1560
|
+
const repos = [
|
|
1561
|
+
...(wantsHostRepos ? input.explicitRepos : []),
|
|
1562
|
+
...input.targets.flatMap((target) => { var _a; var _b; return (_b = (_a = target.accountRuntime.scope) === null || _a === void 0 ? void 0 : _a.repos) !== null && _b !== void 0 ? _b : []; }),
|
|
1563
|
+
];
|
|
1564
|
+
return parseCursorOriginRepoScope(repos);
|
|
1565
|
+
}
|
|
1464
1566
|
/**
|
|
1465
1567
|
* `weather-agent` → `WeatherAgent` (single-token Cursor Slack handle).
|
|
1466
1568
|
* Must not contain whitespace — see {@link assertSlackCursorAgentName}.
|