@cursor/july 0.1.79 → 0.1.82

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.
Files changed (93) hide show
  1. package/AGENTS.md +0 -12
  2. package/dist/channels/github/api.d.ts.map +1 -1
  3. package/dist/channels/github/api.js +8 -1
  4. package/dist/channels/github/cursor-account.d.ts +28 -0
  5. package/dist/channels/github/cursor-account.d.ts.map +1 -1
  6. package/dist/channels/github/cursor-account.js +60 -0
  7. package/dist/channels/github/github-channel.d.ts.map +1 -1
  8. package/dist/channels/github/github-channel.js +29 -1
  9. package/dist/channels/github/types.d.ts +8 -0
  10. package/dist/channels/github/types.d.ts.map +1 -1
  11. package/dist/channels/origin/origin-channel.d.ts.map +1 -1
  12. package/dist/channels/origin/origin-channel.js +32 -10
  13. package/dist/channels/origin/types.d.ts +7 -0
  14. package/dist/channels/origin/types.d.ts.map +1 -1
  15. package/dist/channels/slack/cursor-account.d.ts.map +1 -1
  16. package/dist/channels/slack/cursor-account.js +2 -2
  17. package/dist/channels/slack/dispatch.d.ts +3 -0
  18. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  19. package/dist/channels/slack/dispatch.js +18 -18
  20. package/dist/channels/slack/interactive.d.ts +2 -0
  21. package/dist/channels/slack/interactive.d.ts.map +1 -1
  22. package/dist/channels/slack/interactive.js +4 -16
  23. package/dist/channels/slack/slack-channel.d.ts +1 -1
  24. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  25. package/dist/channels/slack/slack-channel.js +21 -10
  26. package/dist/channels/slack/types.d.ts +7 -0
  27. package/dist/channels/slack/types.d.ts.map +1 -1
  28. package/dist/channels.d.ts.map +1 -1
  29. package/dist/channels.js +4 -0
  30. package/dist/continuation.d.ts +20 -0
  31. package/dist/continuation.d.ts.map +1 -0
  32. package/dist/continuation.js +18 -0
  33. package/dist/files.d.ts +9 -3
  34. package/dist/files.d.ts.map +1 -1
  35. package/dist/files.js +9 -3
  36. package/dist/index.d.ts +5 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +4 -1
  39. package/dist/internal/continuation-channel.d.ts +29 -0
  40. package/dist/internal/continuation-channel.d.ts.map +1 -0
  41. package/dist/internal/continuation-channel.js +88 -0
  42. package/dist/internal/continuation-identity.d.ts +95 -0
  43. package/dist/internal/continuation-identity.d.ts.map +1 -0
  44. package/dist/internal/continuation-identity.js +445 -0
  45. package/dist/internal/deploy-manifest.d.ts +12 -2
  46. package/dist/internal/deploy-manifest.d.ts.map +1 -1
  47. package/dist/internal/deploy-manifest.js +15 -7
  48. package/dist/internal/discovery.d.ts.map +1 -1
  49. package/dist/internal/discovery.js +32 -5
  50. package/dist/internal/review-comments.d.ts +37 -7
  51. package/dist/internal/review-comments.d.ts.map +1 -1
  52. package/dist/internal/review-comments.js +209 -10
  53. package/dist/internal/server.d.ts.map +1 -1
  54. package/dist/internal/server.js +117 -55
  55. package/dist/internal/session-engine.d.ts +24 -0
  56. package/dist/internal/session-engine.d.ts.map +1 -1
  57. package/dist/internal/session-engine.js +104 -34
  58. package/dist/internal/session-store.d.ts.map +1 -1
  59. package/dist/internal/session-store.js +6 -0
  60. package/dist/internal/skills-sync.d.ts +25 -0
  61. package/dist/internal/skills-sync.d.ts.map +1 -0
  62. package/dist/internal/skills-sync.js +96 -0
  63. package/dist/playground/assets/{index-DJzcIeGt.css → index-ChETdG-_.css} +1 -1
  64. package/dist/playground/assets/{index-K3Sxyx0I.js → index-CkuIrhg4.js} +3 -3
  65. package/dist/playground/index.html +2 -2
  66. package/dist/types.d.ts +44 -0
  67. package/dist/types.d.ts.map +1 -1
  68. package/package.json +1 -1
  69. package/src/channels/github/api.ts +8 -0
  70. package/src/channels/github/cursor-account.ts +76 -0
  71. package/src/channels/github/github-channel.ts +52 -1
  72. package/src/channels/github/types.ts +8 -0
  73. package/src/channels/origin/origin-channel.ts +48 -10
  74. package/src/channels/origin/types.ts +7 -0
  75. package/src/channels/slack/cursor-account.ts +1 -0
  76. package/src/channels/slack/dispatch.ts +44 -2
  77. package/src/channels/slack/interactive.ts +5 -0
  78. package/src/channels/slack/slack-channel.ts +23 -2
  79. package/src/channels/slack/types.ts +7 -0
  80. package/src/channels.ts +7 -0
  81. package/src/continuation.ts +49 -0
  82. package/src/files.ts +10 -3
  83. package/src/index.ts +30 -1
  84. package/src/internal/continuation-channel.ts +129 -0
  85. package/src/internal/continuation-identity.ts +597 -0
  86. package/src/internal/deploy-manifest.ts +36 -3
  87. package/src/internal/discovery.ts +40 -2
  88. package/src/internal/review-comments.ts +257 -16
  89. package/src/internal/server.ts +146 -68
  90. package/src/internal/session-engine.ts +132 -37
  91. package/src/internal/session-store.ts +6 -0
  92. package/src/internal/skills-sync.ts +107 -0
  93. package/src/types.ts +55 -0
@@ -31,6 +31,8 @@
31
31
  import { z } from "zod";
32
32
  import { isPublicEndpointPolicy } from "../channels.js";
33
33
  import { isCursorHostedStorage } from "../storage-backends/cursor-hosted.js";
34
+ import { applyAgentContinuationDefaults, channelContinuationIdentity, handshakeChannelContinuation, } from "./continuation-channel.js";
35
+ import { CONTINUATION_SELECTORS } from "./continuation-identity.js";
34
36
  import { projectInfo } from "./discovery.js";
35
37
  import { packageVersion } from "./distribution.js";
36
38
  export const DEPLOY_MANIFEST_VERSION = 1;
@@ -39,6 +41,7 @@ export const DEPLOY_MANIFEST_VERSION = 1;
39
41
  * module-private (the package builds with isolated declarations); consumers
40
42
  * use {@link parseAgentDeployManifest} and the explicit interfaces below.
41
43
  */
44
+ const continuationIdentitySchema = z.enum(CONTINUATION_SELECTORS);
42
45
  const agentDeployManifestV1Schema = z.object({
43
46
  manifestVersion: z.literal(DEPLOY_MANIFEST_VERSION),
44
47
  generatedAtMs: z.number().int().nonnegative(),
@@ -47,11 +50,13 @@ const agentDeployManifestV1Schema = z.object({
47
50
  egressDomains: z.array(z.string().min(1)).max(64),
48
51
  publicRoutePaths: z.array(z.string().min(1)).max(64),
49
52
  frameworkStorage: z.enum(["cursor-hosted", "other", "none"]).optional(),
53
+ architecture: z.enum(["v1", "v2"]).optional(),
50
54
  channels: z
51
55
  .array(z.object({
52
56
  id: z.string().min(1).max(128),
53
57
  kind: z.string().min(1).max(32).optional(),
54
58
  eventTypes: z.array(z.string().min(1).max(64)).max(64).optional(),
59
+ continuation: continuationIdentitySchema,
55
60
  }))
56
61
  .max(64),
57
62
  }),
@@ -65,8 +70,13 @@ const agentDeployManifestV1Schema = z.object({
65
70
  export function buildAgentDeployManifest(project, options) {
66
71
  var _a;
67
72
  var _b, _c, _d;
73
+ applyAgentContinuationDefaults(project);
68
74
  const channels = project.channels.map((channel) => {
69
75
  var _a, _b, _c;
76
+ const handshake = handshakeChannelContinuation(channel);
77
+ if (!handshake.ok) {
78
+ throw new Error(handshake.error);
79
+ }
70
80
  const kind = (_a = channel.definition.meta) === null || _a === void 0 ? void 0 : _a.kind;
71
81
  const githubEvents = (_b = channel.definition.meta) === null || _b === void 0 ? void 0 : _b.githubWebhookEvents;
72
82
  const originEvents = (_c = channel.definition.meta) === null || _c === void 0 ? void 0 : _c.originWebhookEvents;
@@ -79,6 +89,7 @@ export function buildAgentDeployManifest(project, options) {
79
89
  id: channel.id,
80
90
  kind,
81
91
  eventTypes,
92
+ continuation: channelContinuationIdentity(channel.definition),
82
93
  };
83
94
  });
84
95
  // Same mapping as `july deploy` (cli-deploy.ts): channels declared public
@@ -90,16 +101,13 @@ export function buildAgentDeployManifest(project, options) {
90
101
  manifestVersion: DEPLOY_MANIFEST_VERSION,
91
102
  generatedAtMs: (_b = options === null || options === void 0 ? void 0 : options.nowMs) !== null && _b !== void 0 ? _b : Date.now(),
92
103
  cliVersion: (_c = options === null || options === void 0 ? void 0 : options.cliVersion) !== null && _c !== void 0 ? _c : packageVersion(),
93
- declarations: {
94
- egressDomains: [...((_d = (_a = project.agent.hosting) === null || _a === void 0 ? void 0 : _a.egressDomains) !== null && _d !== void 0 ? _d : [])],
95
- publicRoutePaths,
96
- frameworkStorage: project.storage === undefined
104
+ declarations: Object.assign(Object.assign({ egressDomains: [...((_d = (_a = project.agent.hosting) === null || _a === void 0 ? void 0 : _a.egressDomains) !== null && _d !== void 0 ? _d : [])], publicRoutePaths, frameworkStorage: project.storage === undefined
97
105
  ? "none"
98
106
  : isCursorHostedStorage(project.storage)
99
107
  ? "cursor-hosted"
100
- : "other",
101
- channels,
102
- },
108
+ : "other" }, (project.agent.architecture === undefined
109
+ ? {}
110
+ : { architecture: project.agent.architecture })), { channels }),
103
111
  info: projectInfo(project),
104
112
  };
105
113
  }
@@ -1 +1 @@
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,EASrB,KAAK,UAAU,EAuBhB,MAAM,aAAa,CAAC;AA+BrB,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,C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AAE,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,CA0EvB;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAElE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAOnE;AAiyBD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiB3E;AAo2BD,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,gBAAgB,CA4JnE"}
@@ -36,6 +36,7 @@ import { registerAuthoredModuleLoaders } from "./authored-loaders.js";
36
36
  import { normalizePositiveInt } from "./bounded-int.js";
37
37
  import { getDefinitionKind } from "./brand.js";
38
38
  import { artifactBuiltinTool, builtinTools, TAG_ARTIFACT_TOOL_NAME, } from "./builtin-tools/index.js";
39
+ import { applyAgentContinuationDefaults } from "./continuation-channel.js";
39
40
  import { isValidCron } from "./cron.js";
40
41
  import { parseFrontmatter } from "./frontmatter.js";
41
42
  import { isReservedSecretName, MAX_EGRESS_DOMAINS, validateEgressDomain, validateSecretName, } from "./hosting.js";
@@ -218,12 +219,18 @@ export function loadAgentProject(dir_1) {
218
219
  if (agentDir !== rootDir) {
219
220
  yield warnUnknownSlots(ctx, agentDir);
220
221
  }
222
+ const resolvedHttpChannel = httpChannelDefinition !== null && httpChannelDefinition !== void 0 ? httpChannelDefinition : httpChannel();
223
+ applyAgentContinuationDefaults({
224
+ agent,
225
+ channels,
226
+ httpChannel: resolvedHttpChannel,
227
+ });
221
228
  return {
222
229
  rootDir,
223
230
  agentDir,
224
231
  name: agent.name,
225
232
  agent,
226
- httpChannel: httpChannelDefinition !== null && httpChannelDefinition !== void 0 ? httpChannelDefinition : httpChannel(),
233
+ httpChannel: resolvedHttpChannel,
227
234
  channels,
228
235
  schedules,
229
236
  hooks,
@@ -282,6 +289,13 @@ function loadAgent(ctx, agentDir, options) {
282
289
  message: "tools is not supported on subagents (they keep the harness task-tool toolset); ignoring.",
283
290
  });
284
291
  }
292
+ if ((config === null || config === void 0 ? void 0 : config.architecture) !== undefined) {
293
+ ctx.diagnostics.push({
294
+ severity: "warning",
295
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
296
+ message: "architecture is not supported on subagents; ignoring.",
297
+ });
298
+ }
285
299
  const artifactsPath = yield findModuleFile(agentDir, "artifacts");
286
300
  if (artifactsPath !== undefined) {
287
301
  ctx.diagnostics.push({
@@ -371,6 +385,7 @@ function loadAgent(ctx, agentDir, options) {
371
385
  };
372
386
  const hosting = resolveHosting(ctx, agentDir, config === null || config === void 0 ? void 0 : config.hosting);
373
387
  const concurrency = resolveConcurrency(ctx, agentDir, config === null || config === void 0 ? void 0 : config.concurrency);
388
+ const architecture = resolveArchitecture(ctx, agentDir, config === null || config === void 0 ? void 0 : config.architecture);
374
389
  if (runtime === "cloud") {
375
390
  warnCloudRuntimeLimitations(ctx, agentDir, {
376
391
  agentTools: tools.filter((tool) => tool.execution === "agent").length,
@@ -380,20 +395,32 @@ function loadAgent(ctx, agentDir, options) {
380
395
  });
381
396
  }
382
397
  appendBuiltinTools(ctx, agentDir, tools, config === null || config === void 0 ? void 0 : config.builtinTools);
383
- return Object.assign(Object.assign({ name, description: config === null || config === void 0 ? void 0 : config.description,
398
+ return Object.assign(Object.assign(Object.assign(Object.assign({ name, description: config === null || config === void 0 ? void 0 : config.description,
384
399
  // Root agents always get a concrete model: authored value or DEFAULT_MODEL.
385
400
  model: isValidModelSetting(config === null || config === void 0 ? void 0 : config.model) ? config.model : DEFAULT_MODEL, instructions,
386
401
  runtime,
387
402
  cloud,
388
403
  local }, (allowedTools === undefined ? {} : { allowedTools })), { hosting,
389
- concurrency,
390
- tools,
404
+ concurrency }), (architecture === undefined ? {} : { architecture })), { tools,
391
405
  skills,
392
406
  connections,
393
407
  subagents,
394
408
  seedFiles });
395
409
  });
396
410
  }
411
+ function resolveArchitecture(ctx, agentDir, architecture) {
412
+ if (architecture === undefined ||
413
+ architecture === "v1" ||
414
+ architecture === "v2") {
415
+ return architecture;
416
+ }
417
+ ctx.diagnostics.push({
418
+ severity: "error",
419
+ path: displayPath(ctx, join(agentDir, "agent.ts")),
420
+ message: `architecture must be "v1" or "v2"; got ${JSON.stringify(architecture)}.`,
421
+ });
422
+ return undefined;
423
+ }
397
424
  /** Absolute harness cwd parent, or undefined when unset / blank. */
398
425
  function resolveAgentCwd(ctx, authored) {
399
426
  if (authored === undefined) {
@@ -1241,7 +1268,7 @@ function warnCloudRuntimeLimitations(ctx, agentDir, counts) {
1241
1268
  ctx.diagnostics.push({
1242
1269
  severity: "warning",
1243
1270
  path: displayPath(ctx, join(agentDir, "skills")),
1244
- message: "Authored skills are materialized into the local session workspace only; cloud agents see skills that already exist in the cloud repo.",
1271
+ message: "Authored skills reach cloud agents on hosted deployments via the deployment store's skills/ directory (native skill discovery). Cloud turns started outside hosting (dev serve/run) see only skills already in the cloud repo.",
1245
1272
  });
1246
1273
  }
1247
1274
  if (counts.seedFiles > 0) {
@@ -1,5 +1,5 @@
1
1
  import type { HostGitHubClient } from "../types.js";
2
- export type ReviewCommentPublisher = "local_gh" | "host_github";
2
+ export type ReviewCommentPublisher = "local_gh" | "host_github" | "host_origin";
3
3
  export type ReviewCommentPostResult = {
4
4
  posted: boolean;
5
5
  publisher: ReviewCommentPublisher;
@@ -48,12 +48,24 @@ export type ReviewCommentPublisherImplementation = {
48
48
  postReview: (args: ReviewCommentPostArgs) => Promise<ReviewCommentPostResult>;
49
49
  };
50
50
  /**
51
- * SCMs this module can read review comments back from. Same growth seam as
52
- * `shallow-clone.ts`'s {@link import("./shallow-clone.js").ScmProvider}:
53
- * adding GitLab/Bitbucket/Origin means a resolver case plus a reader
54
- * implementation, and nothing above this line changes.
51
+ * SCMs this module can address. Same growth seam as `shallow-clone.ts`'s
52
+ * {@link import("./shallow-clone.js").ScmProvider}: adding a forge means a
53
+ * resolver case plus a publisher (and, when the public API supports it, a
54
+ * reader / thread resolver). Callers above this line stay provider-neutral.
55
55
  */
56
- export type ScmReviewProvider = "github";
56
+ export type ScmReviewProvider = "github" | "origin";
57
+ /**
58
+ * Origin public REST client used to post PR reviews (`ctx.origin` /
59
+ * {@link import("../channels/origin/api.js").createOriginClient}). Narrower
60
+ * than the full Origin handle so tests and CLI paths can inject `request()`.
61
+ */
62
+ export type HostOriginReviewClient = {
63
+ request(input: {
64
+ method: "DELETE" | "GET" | "PATCH" | "POST" | "PUT";
65
+ path: string;
66
+ body?: unknown;
67
+ }): Promise<unknown>;
68
+ };
57
69
  /** Which SCM's PR to read review comments from. */
58
70
  export type ScmReviewTarget = {
59
71
  provider: ScmReviewProvider;
@@ -126,7 +138,7 @@ export type ResolveReviewThreadsResult = {
126
138
  export type ReviewThreadResolverImplementation = {
127
139
  resolveReviewThreadsForComments: (args: ResolveReviewThreadsArgs) => Promise<ResolveReviewThreadsResult>;
128
140
  };
129
- /** Parse a PR URL into the SCM target to read comments from. */
141
+ /** Parse a PR URL into the SCM target to read or post comments on. */
130
142
  export declare function resolveScmReviewTarget(prUrl: string): ScmReviewTarget | undefined;
131
143
  /**
132
144
  * Reader for a resolved target, mirroring Bugbot's `createPrGitProvider`
@@ -213,5 +225,23 @@ export declare function createLocalGhReviewPublisher(): ReviewCommentPublisherIm
213
225
  * cursorAccount })` is bound.
214
226
  */
215
227
  export declare function createHostGithubReviewPublisher(github: HostGitHubClient): ReviewCommentPublisherImplementation;
228
+ /**
229
+ * Pick the publisher for `prUrl`'s SCM. GitHub falls back to local `gh`
230
+ * when no host client is bound (CLI). Origin has no local CLI publisher —
231
+ * returns undefined unless an Origin REST client is provided.
232
+ */
233
+ export declare function createReviewCommentPublisher(args: {
234
+ prUrl: string;
235
+ github?: HostGitHubClient;
236
+ origin?: HostOriginReviewClient;
237
+ }): ReviewCommentPublisherImplementation | undefined;
238
+ /**
239
+ * Posts a COMMENT-verdict Origin review through the public REST API.
240
+ *
241
+ * Public Origin REST has no diff-anchored review comments (those are an
242
+ * internal CreateCommentThread RPC). Inline comments in the request are
243
+ * folded into the review body so findings still land on the PR.
244
+ */
245
+ export declare function createHostOriginReviewPublisher(origin: HostOriginReviewClient): ReviewCommentPublisherImplementation;
216
246
  export {};
217
247
  //# sourceMappingURL=review-comments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-comments.d.ts","sourceRoot":"","sources":["../../src/internal/review-comments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,aAAa,CAAC;AAEhE,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,sBAA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zB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,CAkBvD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,oCAAoC,CAMnF;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,gBAAgB,GACvB,oCAAoC,CAMtC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC,GAAG,oCAAoC,GAAG,SAAS,CAenD;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,GAC7B,oCAAoC,CAMtC"}
@@ -8,16 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { spawn } from "node:child_process";
11
- /** Parse a PR URL into the SCM target to read comments from. */
11
+ /** Parse a PR URL into the SCM target to read or post comments on. */
12
12
  export function resolveScmReviewTarget(prUrl) {
13
- const parsed = parseGithubPrUrl(prUrl);
14
- return parsed.kind === "valid"
15
- ? {
16
- provider: "github",
17
- repo: parsed.value.repo,
18
- prNumber: parsed.value.prNumber,
19
- }
20
- : undefined;
13
+ const parsed = parseReviewPrUrl(prUrl);
14
+ return parsed.kind === "valid" ? parsed.value : undefined;
21
15
  }
22
16
  /**
23
17
  * Reader for a resolved target, mirroring Bugbot's `createPrGitProvider`
@@ -30,6 +24,10 @@ export function createReviewCommentReader(args) {
30
24
  return args.github === undefined
31
25
  ? undefined
32
26
  : createHostGithubReviewCommentReader(args.github);
27
+ case "origin":
28
+ // Public Origin REST lists discussion comments, not diff-anchored
29
+ // review threads. Stay undefined until a reader can fetch by id.
30
+ return undefined;
33
31
  }
34
32
  }
35
33
  /**
@@ -42,6 +40,8 @@ export function createReviewThreadResolver(args) {
42
40
  return args.github === undefined
43
41
  ? undefined
44
42
  : createHostGithubReviewThreadResolver(args.github);
43
+ case "origin":
44
+ return undefined;
45
45
  }
46
46
  }
47
47
  /**
@@ -66,7 +66,9 @@ export function resolveReviewThreadsForComments(args) {
66
66
  github: args.github,
67
67
  });
68
68
  if (resolver === undefined) {
69
- return skippedResolve("no GitHub client bound to resolve threads");
69
+ return skippedResolve(target.provider === "github"
70
+ ? "no GitHub client bound to resolve threads"
71
+ : `no thread resolver for ${target.provider}`);
70
72
  }
71
73
  return resolver.resolveReviewThreadsForComments({
72
74
  target,
@@ -341,6 +343,43 @@ export function createHostGithubReviewPublisher(github) {
341
343
  },
342
344
  };
343
345
  }
346
+ /**
347
+ * Pick the publisher for `prUrl`'s SCM. GitHub falls back to local `gh`
348
+ * when no host client is bound (CLI). Origin has no local CLI publisher —
349
+ * returns undefined unless an Origin REST client is provided.
350
+ */
351
+ export function createReviewCommentPublisher(args) {
352
+ const target = resolveScmReviewTarget(args.prUrl);
353
+ if (target === undefined) {
354
+ return undefined;
355
+ }
356
+ switch (target.provider) {
357
+ case "github":
358
+ return args.github !== undefined
359
+ ? createHostGithubReviewPublisher(args.github)
360
+ : createLocalGhReviewPublisher();
361
+ case "origin":
362
+ return args.origin === undefined
363
+ ? undefined
364
+ : createHostOriginReviewPublisher(args.origin);
365
+ }
366
+ }
367
+ /**
368
+ * Posts a COMMENT-verdict Origin review through the public REST API.
369
+ *
370
+ * Public Origin REST has no diff-anchored review comments (those are an
371
+ * internal CreateCommentThread RPC). Inline comments in the request are
372
+ * folded into the review body so findings still land on the PR.
373
+ */
374
+ export function createHostOriginReviewPublisher(origin) {
375
+ return {
376
+ postReview(args) {
377
+ return __awaiter(this, void 0, void 0, function* () {
378
+ return postReviewViaHostOrigin(origin, args);
379
+ });
380
+ },
381
+ };
382
+ }
344
383
  function postReviewViaHostGithub(github, args) {
345
384
  return __awaiter(this, void 0, void 0, function* () {
346
385
  var _a, _b, _c;
@@ -523,6 +562,70 @@ function skippedHost(detail) {
523
562
  detail,
524
563
  };
525
564
  }
565
+ function skippedOrigin(detail) {
566
+ return {
567
+ posted: false,
568
+ publisher: "host_origin",
569
+ mode: "skipped",
570
+ inlineCommentCount: 0,
571
+ detail,
572
+ };
573
+ }
574
+ function postReviewViaHostOrigin(origin, args) {
575
+ return __awaiter(this, void 0, void 0, function* () {
576
+ var _a, _b;
577
+ const target = resolveScmReviewTarget(args.prUrl);
578
+ if (target === undefined || target.provider !== "origin") {
579
+ return skippedOrigin("host Origin publisher only supports Origin PRs");
580
+ }
581
+ const [owner, repo] = target.repo.split("/", 2);
582
+ if (owner === undefined || repo === undefined || repo === "") {
583
+ return skippedOrigin("unparseable owner/repo from PR URL");
584
+ }
585
+ try {
586
+ (_a = args.signal) === null || _a === void 0 ? void 0 : _a.throwIfAborted();
587
+ yield origin.request({
588
+ method: "POST",
589
+ path: `/v1/origin/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pulls/${target.prNumber}/reviews`,
590
+ body: {
591
+ verdict: "comment",
592
+ body: originReviewBody(args),
593
+ },
594
+ });
595
+ return {
596
+ posted: true,
597
+ publisher: "host_origin",
598
+ mode: "review_body_only",
599
+ inlineCommentCount: 0,
600
+ detail: `posted Origin review on ${target.repo}#${target.prNumber}`,
601
+ };
602
+ }
603
+ catch (error) {
604
+ if ((_b = args.signal) === null || _b === void 0 ? void 0 : _b.aborted) {
605
+ throw error;
606
+ }
607
+ return skippedOrigin(`host Origin review post failed: ${error instanceof Error ? error.message : String(error)}`);
608
+ }
609
+ });
610
+ }
611
+ /**
612
+ * Origin's public CreatePullRequestReview has a body, not inline comments.
613
+ * Fold attempted anchors into the summary so findings are not dropped.
614
+ */
615
+ function originReviewBody(args) {
616
+ if (args.comments.length === 0) {
617
+ return args.message;
618
+ }
619
+ const sections = args.comments.map((comment) => {
620
+ const location = comment.start_line !== undefined &&
621
+ comment.start_line > 0 &&
622
+ comment.start_line !== comment.line
623
+ ? `${comment.file}:${comment.start_line}-${comment.line}`
624
+ : `${comment.file}:${comment.line}`;
625
+ return `### \`${location}\`\n\n${comment.body}`;
626
+ });
627
+ return [args.message, ...sections].join("\n\n");
628
+ }
526
629
  function skippedResolve(detail) {
527
630
  return {
528
631
  requested: 0,
@@ -533,6 +636,102 @@ function skippedResolve(detail) {
533
636
  detail,
534
637
  };
535
638
  }
639
+ const ORIGIN_PR_PAGE_HOST_PATTERN = /^origin(-[a-z0-9]+)?\.cursor\.com$/i;
640
+ /**
641
+ * Provider-neutral PR URL parse. GitHub.com plus the Origin page shapes
642
+ * `parsePrTarget` in security-review-lib accepts. Duplicated here so
643
+ * agent-serve does not import that package.
644
+ */
645
+ function parseReviewPrUrl(prUrl) {
646
+ let url;
647
+ try {
648
+ url = new URL(prUrl);
649
+ }
650
+ catch (error) {
651
+ return {
652
+ kind: "invalid",
653
+ detail: `unparseable PR URL: ${error instanceof Error ? error.message : String(error)}`,
654
+ };
655
+ }
656
+ const parts = url.pathname.split("/").filter(Boolean);
657
+ const hostname = url.hostname;
658
+ if (hostname === "github.com" && parts.length >= 4 && parts[2] === "pull") {
659
+ const prNumber = Number(parts[3]);
660
+ if (Number.isInteger(prNumber) && prNumber > 0) {
661
+ return {
662
+ kind: "valid",
663
+ value: {
664
+ provider: "github",
665
+ repo: `${parts[0]}/${parts[1]}`,
666
+ prNumber,
667
+ },
668
+ };
669
+ }
670
+ }
671
+ if (ORIGIN_PR_PAGE_HOST_PATTERN.test(hostname) &&
672
+ parts.length >= 4 &&
673
+ parts[2] === "github") {
674
+ const prNumber = Number(parts[3]);
675
+ if (Number.isInteger(prNumber) && prNumber > 0) {
676
+ return {
677
+ kind: "valid",
678
+ value: {
679
+ provider: "origin",
680
+ repo: `${parts[0]}/${parts[1]}`,
681
+ prNumber,
682
+ },
683
+ };
684
+ }
685
+ }
686
+ if (/^(www\.)?cursor\.com$/i.test(hostname) &&
687
+ parts[0] === "codebase" &&
688
+ parts.length >= 5 &&
689
+ parts[3] === "pull") {
690
+ const prNumber = Number(parts[4]);
691
+ if (Number.isInteger(prNumber) && prNumber > 0) {
692
+ return {
693
+ kind: "valid",
694
+ value: {
695
+ provider: "origin",
696
+ repo: `${parts[1]}/${parts[2]}`,
697
+ prNumber,
698
+ },
699
+ };
700
+ }
701
+ }
702
+ if (hostname === "review.cursor.com" && parts[0] === "pr") {
703
+ if (parts.length >= 5 && parts[3] === "github") {
704
+ const prNumber = Number(parts[4]);
705
+ if (Number.isInteger(prNumber) && prNumber > 0) {
706
+ return {
707
+ kind: "valid",
708
+ value: {
709
+ provider: "origin",
710
+ repo: `${parts[1]}/${parts[2]}`,
711
+ prNumber,
712
+ },
713
+ };
714
+ }
715
+ }
716
+ if (parts.length >= 4) {
717
+ const prNumber = Number(parts[3]);
718
+ if (Number.isInteger(prNumber) && prNumber > 0) {
719
+ return {
720
+ kind: "valid",
721
+ value: {
722
+ provider: "origin",
723
+ repo: `${parts[1]}/${parts[2]}`,
724
+ prNumber,
725
+ },
726
+ };
727
+ }
728
+ }
729
+ }
730
+ return {
731
+ kind: "invalid",
732
+ detail: "unparseable PR URL: not a GitHub or Origin pull request",
733
+ };
734
+ }
536
735
  function parseGithubPrUrl(prUrl) {
537
736
  let url;
538
737
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuCH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAwHrB,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,CAoxB3B"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0CH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAwHrB,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,CAo0B3B"}