@cursor/july 0.1.55 → 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.CVQxhV85.js → app.CW3KJh72.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BuymfBAo.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.QAPzJjql.js → VPLocalSearchBox.Bk6EWpPj.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CSxTCOFu.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.D_CCfG8R.js → reference_cli.md.Cl14Jfo3.js} +8 -2
- package/dist/docs/assets/{reference_cli.md.D_CCfG8R.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/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 +12 -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 +5 -5
- 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 +20 -0
- package/dist/internal/cli-slack.d.ts +2 -0
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +11 -2
- 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 +4 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +40 -16
- 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/playground/assets/index-ClbuaLpm.css +1 -0
- package/dist/playground/assets/{index-0oqXUkrR.js → index-SqkR13k_.js} +39 -39
- 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 +34 -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/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 +23 -0
- package/src/internal/cli-slack.ts +11 -1
- 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 +70 -15
- 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/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/dist/docs/assets/chunks/@localSearchIndexroot.BFpWSo6D.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/playground/assets/index-tHCjJxv4.css +0 -1
|
@@ -100,6 +100,12 @@ export interface CursorScmEvent {
|
|
|
100
100
|
* Zod-valid `issue_comment` / `pull_request_review_comment` webhook body.
|
|
101
101
|
*/
|
|
102
102
|
comment?: CursorScmCommentMeta;
|
|
103
|
+
/**
|
|
104
|
+
* Origin comment snapshot. Ids are Origin string ids, not GitHub integers.
|
|
105
|
+
*/
|
|
106
|
+
originComment?: CursorScmOriginCommentMeta;
|
|
107
|
+
/** Origin actor (author / pusher / commenter) when present. */
|
|
108
|
+
originActor?: CursorScmOriginActorMeta;
|
|
103
109
|
/** `check_run` snapshot; enough to stub `onCheckRun`. */
|
|
104
110
|
checkRun?: CursorScmCheckRunMeta;
|
|
105
111
|
/** `check_suite` snapshot; enough to stub `onCheckSuite`. */
|
|
@@ -109,11 +115,35 @@ export interface CursorScmEvent {
|
|
|
109
115
|
/** GitHub-side event time from the payload, when present. */
|
|
110
116
|
occurredAtMs?: number;
|
|
111
117
|
}
|
|
118
|
+
export type CursorScmOriginActorMeta = {
|
|
119
|
+
id: string;
|
|
120
|
+
kind?: string;
|
|
121
|
+
};
|
|
122
|
+
export type CursorScmOriginCommentMeta = {
|
|
123
|
+
id: string;
|
|
124
|
+
body?: string;
|
|
125
|
+
author?: CursorScmOriginActorMeta;
|
|
126
|
+
};
|
|
127
|
+
export type CursorScmProvider = "github" | "origin";
|
|
128
|
+
export interface CursorScmSubscription {
|
|
129
|
+
provider: CursorScmProvider;
|
|
130
|
+
repo: string;
|
|
131
|
+
events: readonly string[];
|
|
132
|
+
}
|
|
112
133
|
export interface CursorEventRelayOptions {
|
|
113
134
|
baseUrl: string;
|
|
114
135
|
apiKey: string;
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
/**
|
|
137
|
+
* GitHub-only shorthand. Ignored when {@link subscriptions} is set.
|
|
138
|
+
* Existing `--cursor-events --repo` hosts keep passing these.
|
|
139
|
+
*/
|
|
140
|
+
repos?: readonly string[];
|
|
141
|
+
events?: readonly string[];
|
|
142
|
+
/**
|
|
143
|
+
* Mixed GitHub + Origin registrations. Provider is part of the
|
|
144
|
+
* subscription key: mirrored `owner/name` slugs must not collide.
|
|
145
|
+
*/
|
|
146
|
+
subscriptions?: readonly CursorScmSubscription[];
|
|
117
147
|
stateDir: string;
|
|
118
148
|
/**
|
|
119
149
|
* Called for each matching event; failures retry a bounded number of
|
|
@@ -164,25 +194,43 @@ export declare function scmMetadataToGitHubPayload(event: {
|
|
|
164
194
|
workflowRun?: CursorScmWorkflowRunMeta;
|
|
165
195
|
}): Record<string, unknown>;
|
|
166
196
|
/**
|
|
167
|
-
*
|
|
197
|
+
* Origin webhook envelope from an SCM-events metadata record. One parser
|
|
198
|
+
* handles both live Origin deliveries and this stub: `{ deliveryId, event }`.
|
|
199
|
+
*/
|
|
200
|
+
export declare function scmMetadataToOriginPayload(event: {
|
|
201
|
+
repo: string;
|
|
202
|
+
eventName: string;
|
|
203
|
+
deliveryId?: string;
|
|
204
|
+
action?: string;
|
|
205
|
+
prNumber?: number;
|
|
206
|
+
prUrl?: string;
|
|
207
|
+
pullRequest?: CursorScmPullRequestMeta;
|
|
208
|
+
originComment?: CursorScmOriginCommentMeta;
|
|
209
|
+
originActor?: CursorScmOriginActorMeta;
|
|
210
|
+
occurredAtMs?: number;
|
|
211
|
+
}): Record<string, unknown>;
|
|
212
|
+
export declare function resolveCursorScmSubscriptions(options: Pick<CursorEventRelayOptions, "repos" | "events" | "subscriptions">): CursorScmSubscription[];
|
|
213
|
+
/**
|
|
214
|
+
* SCM-events relay: a thin {@link CursorRelayCore} adapter. Consumers
|
|
168
215
|
* keep the same `new CursorEventRelay(options).start()/.stop()` surface.
|
|
169
216
|
*/
|
|
170
217
|
export declare class CursorEventRelay {
|
|
171
218
|
private readonly options;
|
|
172
219
|
private readonly core;
|
|
220
|
+
private readonly subscriptions;
|
|
173
221
|
/**
|
|
174
|
-
*
|
|
175
|
-
* shared with sibling consumers
|
|
176
|
-
*
|
|
222
|
+
* Confirmed `provider:repo` keys for THIS consumer, with the event kinds
|
|
223
|
+
* requested for each. The stream is shared with sibling consumers, so
|
|
224
|
+
* GitHub and Origin deliveries for the same owner/name must not mix.
|
|
177
225
|
*/
|
|
178
|
-
private
|
|
179
|
-
private readonly
|
|
226
|
+
private subscribedEvents;
|
|
227
|
+
private readonly loggedSkippedKeys;
|
|
180
228
|
constructor(options: CursorEventRelayOptions);
|
|
181
229
|
/**
|
|
182
230
|
* Whether an event from the shared stream belongs to THIS consumer: the
|
|
183
|
-
* repo must be one the server confirmed for us and the event kind
|
|
184
|
-
*
|
|
185
|
-
*
|
|
231
|
+
* provider+repo must be one the server confirmed for us and the event kind
|
|
232
|
+
* one that subscription declared. GitHub and Origin share owner/name slugs
|
|
233
|
+
* on mirrors, so the provider is part of the key.
|
|
186
234
|
*/
|
|
187
235
|
private shouldDispatch;
|
|
188
236
|
start(): void;
|
|
@@ -1 +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;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,IA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B,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoE1B;AAUD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC,GAC3E,qBAAqB,EAAE,CAczB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAWf,OAAO,CAAC,QAAQ,CAAC,OAAO;IAVpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkC;IACvD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0B;IACxD;;;;OAIG;IACH,OAAO,CAAC,gBAAgB,CAA0C;IAClE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IAEvD,YAA6B,OAAO,EAAE,uBAAuB,EAsE5D;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAetB,KAAK,IAAI,IAAI,CAEZ;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;CACF"}
|
|
@@ -238,29 +238,125 @@ function stubGitHubWorkflowRun(meta, pullRequests) {
|
|
|
238
238
|
return object;
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
|
-
*
|
|
241
|
+
* Origin webhook envelope from an SCM-events metadata record. One parser
|
|
242
|
+
* handles both live Origin deliveries and this stub: `{ deliveryId, event }`.
|
|
243
|
+
*/
|
|
244
|
+
export function scmMetadataToOriginPayload(event) {
|
|
245
|
+
var _a, _b, _c;
|
|
246
|
+
const slash = event.repo.indexOf("/");
|
|
247
|
+
const owner = slash === -1 ? "" : event.repo.slice(0, slash);
|
|
248
|
+
const name = slash === -1 ? event.repo : event.repo.slice(slash + 1);
|
|
249
|
+
const prMeta = event.pullRequest;
|
|
250
|
+
const prNumber = (_a = prMeta === null || prMeta === void 0 ? void 0 : prMeta.number) !== null && _a !== void 0 ? _a : event.prNumber;
|
|
251
|
+
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
|
|
252
|
+
? `https://cursor.com/codebase/${owner}/${name}/pull/${prNumber}`
|
|
253
|
+
: undefined);
|
|
254
|
+
const payload = {
|
|
255
|
+
repository: {
|
|
256
|
+
name,
|
|
257
|
+
owner: { slug: owner },
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
if (prNumber !== undefined) {
|
|
261
|
+
const pullRequest = {
|
|
262
|
+
number: prNumber,
|
|
263
|
+
url: prUrl,
|
|
264
|
+
};
|
|
265
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.title) !== undefined)
|
|
266
|
+
pullRequest.title = prMeta.title;
|
|
267
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.body) !== undefined)
|
|
268
|
+
pullRequest.body = prMeta.body;
|
|
269
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.draft) !== undefined)
|
|
270
|
+
pullRequest.draft = prMeta.draft;
|
|
271
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.merged) !== undefined)
|
|
272
|
+
pullRequest.merged = prMeta.merged;
|
|
273
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.headRef) !== undefined || (prMeta === null || prMeta === void 0 ? void 0 : prMeta.headSha) !== undefined) {
|
|
274
|
+
pullRequest.head = {
|
|
275
|
+
ref: prMeta.headRef,
|
|
276
|
+
sha: prMeta.headSha,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.baseRef) !== undefined || (prMeta === null || prMeta === void 0 ? void 0 : prMeta.baseSha) !== undefined) {
|
|
280
|
+
pullRequest.base = {
|
|
281
|
+
ref: prMeta.baseRef,
|
|
282
|
+
sha: prMeta.baseSha,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
if ((prMeta === null || prMeta === void 0 ? void 0 : prMeta.authorLogin) !== undefined) {
|
|
286
|
+
pullRequest.author = { id: prMeta.authorLogin };
|
|
287
|
+
}
|
|
288
|
+
payload.pullRequest = pullRequest;
|
|
289
|
+
}
|
|
290
|
+
const commentMeta = event.originComment;
|
|
291
|
+
if (commentMeta !== undefined) {
|
|
292
|
+
const comment = { id: commentMeta.id };
|
|
293
|
+
if (commentMeta.body !== undefined)
|
|
294
|
+
comment.body = commentMeta.body;
|
|
295
|
+
if (commentMeta.author !== undefined)
|
|
296
|
+
comment.author = commentMeta.author;
|
|
297
|
+
payload.comment = comment;
|
|
298
|
+
}
|
|
299
|
+
if (event.originActor !== undefined) {
|
|
300
|
+
payload.actor = event.originActor;
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
deliveryId: event.deliveryId,
|
|
304
|
+
event: Object.assign(Object.assign({ type: event.eventName }, (event.occurredAtMs === undefined
|
|
305
|
+
? {}
|
|
306
|
+
: { eventTime: new Date(event.occurredAtMs).toISOString() })), { payload }),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function subscriptionKey(provider, repo) {
|
|
310
|
+
return `${provider}:${repo.toLowerCase()}`;
|
|
311
|
+
}
|
|
312
|
+
function subscriptionLabel(provider, repo) {
|
|
313
|
+
return provider === "github" ? repo : `${provider}:${repo}`;
|
|
314
|
+
}
|
|
315
|
+
export function resolveCursorScmSubscriptions(options) {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
if (options.subscriptions !== undefined) {
|
|
318
|
+
return options.subscriptions.map((subscription) => ({
|
|
319
|
+
provider: subscription.provider,
|
|
320
|
+
repo: subscription.repo.trim().toLowerCase(),
|
|
321
|
+
events: [...subscription.events],
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
const events = [...((_a = options.events) !== null && _a !== void 0 ? _a : [])];
|
|
325
|
+
return ((_b = options.repos) !== null && _b !== void 0 ? _b : []).map((repo) => ({
|
|
326
|
+
provider: "github",
|
|
327
|
+
repo: repo.trim().toLowerCase(),
|
|
328
|
+
events,
|
|
329
|
+
}));
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* SCM-events relay: a thin {@link CursorRelayCore} adapter. Consumers
|
|
242
333
|
* keep the same `new CursorEventRelay(options).start()/.stop()` surface.
|
|
243
334
|
*/
|
|
244
335
|
export class CursorEventRelay {
|
|
245
336
|
constructor(options) {
|
|
246
337
|
this.options = options;
|
|
247
338
|
/**
|
|
248
|
-
*
|
|
249
|
-
* shared with sibling consumers
|
|
250
|
-
*
|
|
339
|
+
* Confirmed `provider:repo` keys for THIS consumer, with the event kinds
|
|
340
|
+
* requested for each. The stream is shared with sibling consumers, so
|
|
341
|
+
* GitHub and Origin deliveries for the same owner/name must not mix.
|
|
251
342
|
*/
|
|
252
|
-
this.
|
|
253
|
-
this.
|
|
343
|
+
this.subscribedEvents = new Map();
|
|
344
|
+
this.loggedSkippedKeys = new Set();
|
|
345
|
+
this.subscriptions = resolveCursorScmSubscriptions(options);
|
|
346
|
+
const requestedEvents = new Map(this.subscriptions.map((subscription) => [
|
|
347
|
+
subscriptionKey(subscription.provider, subscription.repo),
|
|
348
|
+
new Set(subscription.events),
|
|
349
|
+
]));
|
|
254
350
|
const adapter = {
|
|
255
351
|
logPrefix: "cursor-events",
|
|
256
352
|
subscribePath: "/v0/scm-events/subscriptions",
|
|
257
353
|
pollPath: "/v0/scm-events",
|
|
258
354
|
buildRegistrationBody: (consumerId) => ({
|
|
259
355
|
consumerId,
|
|
260
|
-
subscriptions: this.
|
|
261
|
-
provider:
|
|
262
|
-
repo,
|
|
263
|
-
events: [...
|
|
356
|
+
subscriptions: this.subscriptions.map((subscription) => ({
|
|
357
|
+
provider: subscription.provider,
|
|
358
|
+
repo: subscription.repo,
|
|
359
|
+
events: [...subscription.events],
|
|
264
360
|
})),
|
|
265
361
|
}),
|
|
266
362
|
// Empty subscriptions drop this consumer's registration on clean stop
|
|
@@ -270,18 +366,27 @@ export class CursorEventRelay {
|
|
|
270
366
|
subscriptions: [],
|
|
271
367
|
}),
|
|
272
368
|
applyRegistrationResponse: (json) => {
|
|
273
|
-
var _a, _b;
|
|
369
|
+
var _a, _b, _c;
|
|
274
370
|
const result = json;
|
|
275
371
|
const statuses = (_a = result.repos) !== null && _a !== void 0 ? _a : [];
|
|
276
|
-
this.
|
|
277
|
-
.filter((status) => status.isSubscribed)
|
|
278
|
-
.map((status) => status.repo));
|
|
372
|
+
this.subscribedEvents = new Map();
|
|
279
373
|
const lines = [];
|
|
280
|
-
|
|
281
|
-
|
|
374
|
+
const confirmed = [];
|
|
375
|
+
for (const status of statuses) {
|
|
376
|
+
const provider = status.provider || "github";
|
|
377
|
+
const key = subscriptionKey(provider, status.repo);
|
|
378
|
+
if (!status.isSubscribed) {
|
|
379
|
+
lines.push(`not subscribed to ${subscriptionLabel(provider, status.repo)}: ${(_b = status.detail) !== null && _b !== void 0 ? _b : "unknown reason"}`);
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
this.subscribedEvents.set(key, (_c = requestedEvents.get(key)) !== null && _c !== void 0 ? _c : new Set());
|
|
383
|
+
confirmed.push(subscriptionLabel(provider, status.repo));
|
|
282
384
|
}
|
|
283
|
-
if (
|
|
284
|
-
|
|
385
|
+
if (confirmed.length > 0) {
|
|
386
|
+
const eventKinds = [
|
|
387
|
+
...new Set(this.subscriptions.flatMap((s) => [...s.events])),
|
|
388
|
+
];
|
|
389
|
+
lines.push(`subscribed to ${confirmed.join(", ")} for events: ${eventKinds.join(", ")}`);
|
|
285
390
|
}
|
|
286
391
|
return lines;
|
|
287
392
|
},
|
|
@@ -296,19 +401,21 @@ export class CursorEventRelay {
|
|
|
296
401
|
}
|
|
297
402
|
/**
|
|
298
403
|
* Whether an event from the shared stream belongs to THIS consumer: the
|
|
299
|
-
* repo must be one the server confirmed for us and the event kind
|
|
300
|
-
*
|
|
301
|
-
*
|
|
404
|
+
* provider+repo must be one the server confirmed for us and the event kind
|
|
405
|
+
* one that subscription declared. GitHub and Origin share owner/name slugs
|
|
406
|
+
* on mirrors, so the provider is part of the key.
|
|
302
407
|
*/
|
|
303
408
|
shouldDispatch(event) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
409
|
+
const key = subscriptionKey(event.provider || "github", event.repo);
|
|
410
|
+
const events = this.subscribedEvents.get(key);
|
|
411
|
+
if (events === undefined) {
|
|
412
|
+
if (!this.loggedSkippedKeys.has(key)) {
|
|
413
|
+
this.loggedSkippedKeys.add(key);
|
|
414
|
+
this.options.logger(`[agent-sdk] cursor-events: skipping events for ${subscriptionLabel(event.provider || "github", event.repo)}: not in this host's subscription (another consumer of this API key likely subscribed it)`);
|
|
308
415
|
}
|
|
309
416
|
return false;
|
|
310
417
|
}
|
|
311
|
-
return
|
|
418
|
+
return events.has(event.eventName);
|
|
312
419
|
}
|
|
313
420
|
start() {
|
|
314
421
|
this.core.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/internal/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/internal/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAUrB,KAAK,UAAU,EAuBhB,MAAM,aAAa,CAAC;AA2BrB,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3E;AAmBD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASrE;AAED,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,EAAE,CAAC,CA2B1B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC,CA6BzD;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAAuB,GAAG;IACjC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CACtB,GACL,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC,CAgBzD;AAWD,iFAAiF;AACjF,eAAO,MAAM,cAAc,EAAE,GAAG,CAAC,MAAM,CAIrC,CAAC;AAEH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,YAAY,CAAC,CAmEvB;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAElE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAOnE;AAmuBD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiB3E;AAgyBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,gBAAgB,CA2JnE"}
|
|
@@ -27,11 +27,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
};
|
|
28
28
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
29
29
|
import { basename, extname, isAbsolute, join, relative, resolve, } from "node:path";
|
|
30
|
+
import { pathToFileURL } from "node:url";
|
|
30
31
|
import { resolveABMaxPlaygroundSessions } from "../ab.js";
|
|
31
32
|
import { resolveArtifactsMax } from "../artifacts.js";
|
|
32
33
|
import { httpChannel } from "../channels.js";
|
|
33
34
|
import { cursorAccountServersHasMixedWildcard, DEFAULT_MODEL, isInlineStdioConnection, MAX_RUNNING_TURNS_LIMIT, normalizeCursorAccountServers, toPublicCloudInfo, } from "../types.js";
|
|
34
|
-
import {
|
|
35
|
+
import { registerAuthoredModuleLoaders } from "./authored-loaders.js";
|
|
35
36
|
import { normalizePositiveInt } from "./bounded-int.js";
|
|
36
37
|
import { getDefinitionKind } from "./brand.js";
|
|
37
38
|
import { artifactBuiltinTool, builtinTools, TAG_ARTIFACT_TOOL_NAME, } from "./builtin-tools/index.js";
|
|
@@ -45,6 +46,11 @@ import { withIdentityPreamble } from "./workspace.js";
|
|
|
45
46
|
const MODULE_EXTENSIONS = new Set([".ts", ".mts", ".js", ".mjs"]);
|
|
46
47
|
const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
47
48
|
const SKILL_DESCRIPTION_FALLBACK = (name) => `Instructions for the ${name} skill.`;
|
|
49
|
+
function defaultImportModule(absolutePath) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return (yield import(pathToFileURL(absolutePath).href));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
48
54
|
/**
|
|
49
55
|
* True when `dir` looks like an agent project root: it has a nested `agent/`
|
|
50
56
|
* directory, or flat-layout markers (`agent.ts` / `instructions.md`) directly
|
|
@@ -193,7 +199,7 @@ export function loadAgentProject(dir_1) {
|
|
|
193
199
|
const ctx = {
|
|
194
200
|
rootDir,
|
|
195
201
|
diagnostics,
|
|
196
|
-
importModule: (_a = options.importModule) !== null && _a !== void 0 ? _a :
|
|
202
|
+
importModule: (_a = options.importModule) !== null && _a !== void 0 ? _a : defaultImportModule,
|
|
197
203
|
};
|
|
198
204
|
const name = (_b = (yield readPackageName(rootDir))) !== null && _b !== void 0 ? _b : basename(rootDir);
|
|
199
205
|
const agent = yield loadAgent(ctx, agentDir, {
|
|
@@ -1638,6 +1644,9 @@ export function projectInfo(project) {
|
|
|
1638
1644
|
if ((meta === null || meta === void 0 ? void 0 : meta.githubWebhookEvents) !== undefined) {
|
|
1639
1645
|
info.githubWebhookEvents = meta.githubWebhookEvents;
|
|
1640
1646
|
}
|
|
1647
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.originWebhookEvents) !== undefined) {
|
|
1648
|
+
info.originWebhookEvents = meta.originWebhookEvents;
|
|
1649
|
+
}
|
|
1641
1650
|
if ((meta === null || meta === void 0 ? void 0 : meta.slackChannelPosts) !== undefined) {
|
|
1642
1651
|
info.slackChannelPosts = meta.slackChannelPosts;
|
|
1643
1652
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../src/internal/distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,sEAAsE;AACtE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,UAAU,EAAE,MAA2B,CAAC;AACrD,eAAO,MAAM,gBAAgB,EAAE,MAAiC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAA+B,CAAC;AAc/D;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../src/internal/distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,sEAAsE;AACtE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,UAAU,EAAE,MAA2B,CAAC;AACrD,eAAO,MAAM,gBAAgB,EAAE,MAAiC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAA+B,CAAC;AAc/D;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CA2BzC,CAAC"}
|
|
@@ -80,6 +80,7 @@ export const AUTHORING_ENTRY_FILES = [
|
|
|
80
80
|
["channels", "channels.js"],
|
|
81
81
|
["channels/slack", "channels/slack/index.js"],
|
|
82
82
|
["channels/github", "channels/github/index.js"],
|
|
83
|
+
["channels/origin", "channels/origin/index.js"],
|
|
83
84
|
["skills", "skills.js"],
|
|
84
85
|
["schedules", "schedules.js"],
|
|
85
86
|
["reminders", "reminders.js"],
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified entry for dispatching agent-serve triggers from an external ingress
|
|
3
|
-
* (e.g. the Cursor backend GitHub webhook).
|
|
4
|
-
* `handleAutomationTrigger
|
|
3
|
+
* (e.g. the Cursor backend GitHub webhook or Origin cursor-internal tap).
|
|
4
|
+
* Mirrors Automations' `handleAutomationTrigger`.
|
|
5
5
|
*
|
|
6
6
|
* Callers must authenticate the delivery before invoking this (the backend
|
|
7
|
-
* verifies GitHub HMAC at `/github_webhook`
|
|
8
|
-
*
|
|
7
|
+
* verifies GitHub HMAC at `/github_webhook` and Origin v1ed at the
|
|
8
|
+
* cursor-internal app). This fan-out does not re-check signatures — same
|
|
9
|
+
* trust model as Bugbot after `verifyGithubRequest`.
|
|
9
10
|
*
|
|
10
11
|
* Each agent's `onPullRequest` / `onComment` / … hooks decide whether to run.
|
|
11
12
|
*/
|
|
12
13
|
import type { GitHubChannelOptions } from "../channels/github/types.js";
|
|
14
|
+
import type { OriginChannelOptions } from "../channels/origin/types.js";
|
|
13
15
|
import type { ChannelHandlerArgs } from "../types.js";
|
|
14
16
|
export interface AgentServeGitHubTriggerTarget {
|
|
15
17
|
/** Agent mount slug (empty string in single-agent mode). */
|
|
@@ -27,7 +29,18 @@ export interface AgentServeGitHubTriggerEvent {
|
|
|
27
29
|
deliveryId?: string;
|
|
28
30
|
targets: AgentServeGitHubTriggerTarget[];
|
|
29
31
|
}
|
|
30
|
-
export
|
|
32
|
+
export interface AgentServeOriginTriggerTarget {
|
|
33
|
+
slug: string;
|
|
34
|
+
options: OriginChannelOptions;
|
|
35
|
+
args: ChannelHandlerArgs;
|
|
36
|
+
}
|
|
37
|
+
export interface AgentServeOriginTriggerEvent {
|
|
38
|
+
type: "origin";
|
|
39
|
+
/** Origin envelope JSON (signature already verified by the caller). */
|
|
40
|
+
bodyText: string;
|
|
41
|
+
targets: AgentServeOriginTriggerTarget[];
|
|
42
|
+
}
|
|
43
|
+
export type AgentServeTriggerEvent = AgentServeGitHubTriggerEvent | AgentServeOriginTriggerEvent;
|
|
31
44
|
export interface AgentServeTriggerTargetResult {
|
|
32
45
|
slug: string;
|
|
33
46
|
status: number;
|
|
@@ -53,7 +66,21 @@ export declare function collectGitHubTriggerTargets(input: {
|
|
|
53
66
|
}>;
|
|
54
67
|
}): AgentServeGitHubTriggerTarget[];
|
|
55
68
|
/**
|
|
56
|
-
*
|
|
69
|
+
* Build fan-out targets from mounted agent projects that export an origin
|
|
70
|
+
* channel created via {@link originChannel}.
|
|
71
|
+
*/
|
|
72
|
+
export declare function collectOriginTriggerTargets(input: {
|
|
73
|
+
mounts: Array<{
|
|
74
|
+
slug: string;
|
|
75
|
+
channels: Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
definition: object;
|
|
78
|
+
}>;
|
|
79
|
+
buildHandlerArgs: (channelId: string) => ChannelHandlerArgs;
|
|
80
|
+
}>;
|
|
81
|
+
}): AgentServeOriginTriggerTarget[];
|
|
82
|
+
/**
|
|
83
|
+
* Dispatch an agent-serve trigger. GitHub and Origin webhook fan-out.
|
|
57
84
|
*/
|
|
58
85
|
export declare function handleAgentServeTrigger(event: AgentServeTriggerEvent): Promise<AgentServeTriggerResult>;
|
|
59
86
|
//# sourceMappingURL=handleAgentServeTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleAgentServeTrigger.d.ts","sourceRoot":"","sources":["../../src/internal/handleAgentServeTrigger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"handleAgentServeTrigger.d.ts","sourceRoot":"","sources":["../../src/internal/handleAgentServeTrigger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,6BAA6B;IAC5C,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,EAAE,oBA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BlC;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACpD,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,kBAAkB,CAAC;KAC7D,CAAC,CAAC;CACJ,GAAG,6BAA6B,EAAE,CAgBlC;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CAalC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified entry for dispatching agent-serve triggers from an external ingress
|
|
3
|
-
* (e.g. the Cursor backend GitHub webhook).
|
|
4
|
-
* `handleAutomationTrigger
|
|
3
|
+
* (e.g. the Cursor backend GitHub webhook or Origin cursor-internal tap).
|
|
4
|
+
* Mirrors Automations' `handleAutomationTrigger`.
|
|
5
5
|
*
|
|
6
6
|
* Callers must authenticate the delivery before invoking this (the backend
|
|
7
|
-
* verifies GitHub HMAC at `/github_webhook`
|
|
8
|
-
*
|
|
7
|
+
* verifies GitHub HMAC at `/github_webhook` and Origin v1ed at the
|
|
8
|
+
* cursor-internal app). This fan-out does not re-check signatures — same
|
|
9
|
+
* trust model as Bugbot after `verifyGithubRequest`.
|
|
9
10
|
*
|
|
10
11
|
* Each agent's `onPullRequest` / `onComment` / … hooks decide whether to run.
|
|
11
12
|
*/
|
|
@@ -19,6 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
20
|
});
|
|
20
21
|
};
|
|
21
22
|
import { dispatchGitHubWebhook, getGitHubChannelOptions, } from "../channels/github/github-channel.js";
|
|
23
|
+
import { dispatchOriginWebhook, getOriginChannelOptions, parseOriginWebhookEnvelope, } from "../channels/origin/origin-channel.js";
|
|
22
24
|
/**
|
|
23
25
|
* Build fan-out targets from mounted agent projects that export a github
|
|
24
26
|
* channel created via {@link githubChannel}.
|
|
@@ -41,16 +43,38 @@ export function collectGitHubTriggerTargets(input) {
|
|
|
41
43
|
return targets;
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
46
|
+
* Build fan-out targets from mounted agent projects that export an origin
|
|
47
|
+
* channel created via {@link originChannel}.
|
|
48
|
+
*/
|
|
49
|
+
export function collectOriginTriggerTargets(input) {
|
|
50
|
+
const targets = [];
|
|
51
|
+
for (const mount of input.mounts) {
|
|
52
|
+
for (const channel of mount.channels) {
|
|
53
|
+
const options = getOriginChannelOptions(channel.definition);
|
|
54
|
+
if (options === undefined) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
targets.push({
|
|
58
|
+
slug: mount.slug,
|
|
59
|
+
options,
|
|
60
|
+
args: mount.buildHandlerArgs(channel.id),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return targets;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Dispatch an agent-serve trigger. GitHub and Origin webhook fan-out.
|
|
45
68
|
*/
|
|
46
69
|
export function handleAgentServeTrigger(event) {
|
|
47
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
71
|
switch (event.type) {
|
|
49
|
-
// TODO: Add support for other event types (e.g. Linear, Slack, etc.).
|
|
50
72
|
case "github":
|
|
51
73
|
return handleAgentServeGitHubTrigger(event);
|
|
74
|
+
case "origin":
|
|
75
|
+
return handleAgentServeOriginTrigger(event);
|
|
52
76
|
default: {
|
|
53
|
-
const _ = event
|
|
77
|
+
const _ = event;
|
|
54
78
|
throw new Error(`handleAgentServeTrigger: unknown event type: ${String(_)}`);
|
|
55
79
|
}
|
|
56
80
|
}
|
|
@@ -91,18 +115,7 @@ function handleAgentServeGitHubTrigger(event) {
|
|
|
91
115
|
deliveryId: event.deliveryId,
|
|
92
116
|
args: target.args,
|
|
93
117
|
});
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
body = yield response.json();
|
|
97
|
-
}
|
|
98
|
-
catch (_b) {
|
|
99
|
-
body = { ok: false, error: "invalid_response_json" };
|
|
100
|
-
}
|
|
101
|
-
targets.push({
|
|
102
|
-
slug: target.slug,
|
|
103
|
-
status: response.status,
|
|
104
|
-
body,
|
|
105
|
-
});
|
|
118
|
+
targets.push(yield triggerTargetResult(target.slug, response));
|
|
106
119
|
}
|
|
107
120
|
return {
|
|
108
121
|
ok: true,
|
|
@@ -111,3 +124,68 @@ function handleAgentServeGitHubTrigger(event) {
|
|
|
111
124
|
};
|
|
112
125
|
});
|
|
113
126
|
}
|
|
127
|
+
function handleAgentServeOriginTrigger(event) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
let payload;
|
|
130
|
+
try {
|
|
131
|
+
payload = JSON.parse(event.bodyText);
|
|
132
|
+
}
|
|
133
|
+
catch (_a) {
|
|
134
|
+
return {
|
|
135
|
+
ok: false,
|
|
136
|
+
event: null,
|
|
137
|
+
targets: [
|
|
138
|
+
{
|
|
139
|
+
slug: "",
|
|
140
|
+
status: 400,
|
|
141
|
+
body: { ok: false, error: "invalid_json" },
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const envelope = parseOriginWebhookEnvelope(payload);
|
|
147
|
+
if (envelope === null) {
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
event: null,
|
|
151
|
+
targets: [
|
|
152
|
+
{
|
|
153
|
+
slug: "",
|
|
154
|
+
status: 400,
|
|
155
|
+
body: { ok: false, error: "invalid_origin_payload" },
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const targets = [];
|
|
161
|
+
for (const target of event.targets) {
|
|
162
|
+
const response = yield dispatchOriginWebhook({
|
|
163
|
+
options: target.options,
|
|
164
|
+
envelope,
|
|
165
|
+
args: target.args,
|
|
166
|
+
});
|
|
167
|
+
targets.push(yield triggerTargetResult(target.slug, response));
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
event: envelope.event.type,
|
|
172
|
+
targets,
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function triggerTargetResult(slug, response) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
let body;
|
|
179
|
+
try {
|
|
180
|
+
body = yield response.json();
|
|
181
|
+
}
|
|
182
|
+
catch (_a) {
|
|
183
|
+
body = { ok: false, error: "invalid_response_json" };
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
slug,
|
|
187
|
+
status: response.status,
|
|
188
|
+
body,
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
}
|