@cursor/july 0.1.62 → 0.1.73

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 (286) hide show
  1. package/AGENTS.md +4 -5
  2. package/README.md +23 -11
  3. package/dist/bin/agent-serve.js +11 -2
  4. package/dist/channels/github/api.d.ts +2 -0
  5. package/dist/channels/github/api.d.ts.map +1 -1
  6. package/dist/channels/github/api.js +2 -1
  7. package/dist/channels/github/binding.d.ts +7 -0
  8. package/dist/channels/github/binding.d.ts.map +1 -1
  9. package/dist/channels/github/binding.js +4 -0
  10. package/dist/channels/github/checks.d.ts +99 -0
  11. package/dist/channels/github/checks.d.ts.map +1 -0
  12. package/dist/channels/github/checks.js +108 -0
  13. package/dist/channels/github/cursor-account.d.ts +4 -4
  14. package/dist/channels/github/cursor-account.d.ts.map +1 -1
  15. package/dist/channels/github/cursor-account.js +7 -5
  16. package/dist/channels/github/index.d.ts +1 -0
  17. package/dist/channels/github/index.d.ts.map +1 -1
  18. package/dist/channels/github/index.js +1 -0
  19. package/dist/channels/github/types.d.ts +8 -0
  20. package/dist/channels/github/types.d.ts.map +1 -1
  21. package/dist/channels/slack/channel-watch.d.ts +2 -1
  22. package/dist/channels/slack/channel-watch.d.ts.map +1 -1
  23. package/dist/channels/slack/channel-watch.js +7 -3
  24. package/dist/channels/slack/dispatch.d.ts +9 -0
  25. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  26. package/dist/channels/slack/dispatch.js +41 -21
  27. package/dist/channels/slack/manifest.d.ts +2 -2
  28. package/dist/channels/slack/manifest.d.ts.map +1 -1
  29. package/dist/channels/slack/manifest.js +14 -11
  30. package/dist/channels/slack/nudge-store.d.ts +16 -0
  31. package/dist/channels/slack/nudge-store.d.ts.map +1 -1
  32. package/dist/channels/slack/nudge-store.js +53 -0
  33. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  34. package/dist/channels/slack/slack-channel.js +4 -1
  35. package/dist/channels/slack/types.d.ts +24 -7
  36. package/dist/channels/slack/types.d.ts.map +1 -1
  37. package/dist/connections.d.ts +17 -5
  38. package/dist/connections.d.ts.map +1 -1
  39. package/dist/connections.js +17 -5
  40. package/dist/docs/404.html +2 -2
  41. package/dist/docs/ab.html +3 -3
  42. package/dist/docs/assets/{app.B-biogkN.js → app.CdbcFD8T.js} +1 -1
  43. package/dist/docs/assets/chunks/@localSearchIndexroot.DQad--_z.js +1 -0
  44. package/dist/docs/assets/chunks/{VPLocalSearchBox.DZqKtFZS.js → VPLocalSearchBox.D_NKImM7.js} +1 -1
  45. package/dist/docs/assets/chunks/{theme.BwC5zP2r.js → theme.CMvz7cu9.js} +2 -2
  46. package/dist/docs/assets/{concepts.md.CqOsxbMU.js → concepts.md.BXAm6G-C.js} +1 -1
  47. package/dist/docs/assets/{guides_mcp-oauth.md.C7G7IykG.js → guides_mcp-oauth.md.CzEB6RaG.js} +1 -1
  48. package/dist/docs/assets/{reference_agent-config.md.DHkkvcEZ.js → reference_agent-config.md.BZnEKfEc.js} +3 -4
  49. package/dist/docs/assets/{reference_agent-config.md.DHkkvcEZ.lean.js → reference_agent-config.md.BZnEKfEc.lean.js} +1 -1
  50. package/dist/docs/assets/{reference_connections.md.CSQiNzre.js → reference_connections.md.Cu3N-S3Q.js} +26 -9
  51. package/dist/docs/assets/reference_connections.md.Cu3N-S3Q.lean.js +1 -0
  52. package/dist/docs/assets/{reference_sessions.md.DBVFi2Sx.js → reference_sessions.md.B0DdlM-K.js} +1 -1
  53. package/dist/docs/assets/{reference_tools.md.kJfJAP2m.js → reference_tools.md.DTg_kEsx.js} +2 -2
  54. package/dist/docs/assets/{reference_tools.md.kJfJAP2m.lean.js → reference_tools.md.DTg_kEsx.lean.js} +1 -1
  55. package/dist/docs/assets/troubleshooting.md.DQ-hYuZT.js +1 -0
  56. package/dist/docs/building-with-agents.html +3 -3
  57. package/dist/docs/concepts.html +5 -5
  58. package/dist/docs/deployment.html +3 -3
  59. package/dist/docs/evals.html +3 -3
  60. package/dist/docs/example-agents/approval-buddy.html +3 -3
  61. package/dist/docs/example-agents/benny.html +3 -3
  62. package/dist/docs/example-agents/bugbot.html +3 -3
  63. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  64. package/dist/docs/example-agents/codeowners-review.html +3 -3
  65. package/dist/docs/example-agents/concierge.html +3 -3
  66. package/dist/docs/example-agents/fsd.html +3 -3
  67. package/dist/docs/example-agents/index.html +3 -3
  68. package/dist/docs/example-agents/knowledge-base.html +3 -3
  69. package/dist/docs/example-agents/oncall.html +3 -3
  70. package/dist/docs/example-agents/security-reviewer.html +3 -3
  71. package/dist/docs/example-agents/slack-agent.html +3 -3
  72. package/dist/docs/example-agents/weather-agent.html +3 -3
  73. package/dist/docs/guides/agent-to-agent.html +3 -3
  74. package/dist/docs/guides/cloud-runtime.html +3 -3
  75. package/dist/docs/guides/convert-automation.html +3 -3
  76. package/dist/docs/guides/github.html +3 -3
  77. package/dist/docs/guides/human-in-the-loop.html +3 -3
  78. package/dist/docs/guides/mcp-oauth.html +5 -5
  79. package/dist/docs/guides/opentelemetry.html +3 -3
  80. package/dist/docs/guides/slack.html +3 -3
  81. package/dist/docs/guides/webhooks.html +3 -3
  82. package/dist/docs/hashmap.json +1 -1
  83. package/dist/docs/hillclimbing.html +3 -3
  84. package/dist/docs/index.html +3 -3
  85. package/dist/docs/quickstart.html +3 -3
  86. package/dist/docs/reference/agent-config.html +5 -6
  87. package/dist/docs/reference/artifacts.html +3 -3
  88. package/dist/docs/reference/channels.html +3 -3
  89. package/dist/docs/reference/cli.html +3 -3
  90. package/dist/docs/reference/connections.html +28 -11
  91. package/dist/docs/reference/hooks.html +3 -3
  92. package/dist/docs/reference/http-api.html +3 -3
  93. package/dist/docs/reference/instructions.html +3 -3
  94. package/dist/docs/reference/playground.html +3 -3
  95. package/dist/docs/reference/project-layout.html +3 -3
  96. package/dist/docs/reference/prompt.html +3 -3
  97. package/dist/docs/reference/schedules.html +3 -3
  98. package/dist/docs/reference/sessions.html +5 -5
  99. package/dist/docs/reference/skills.html +3 -3
  100. package/dist/docs/reference/subagents.html +3 -3
  101. package/dist/docs/reference/tools.html +5 -5
  102. package/dist/docs/scaffolding-agents.html +3 -3
  103. package/dist/docs/storage.html +3 -3
  104. package/dist/docs/templates/agentic-owners.html +3 -3
  105. package/dist/docs/templates/demo.html +3 -3
  106. package/dist/docs/templates/pr-autofixer.html +3 -3
  107. package/dist/docs/templates/security-reviewer.html +3 -3
  108. package/dist/docs/templates/triage.html +3 -3
  109. package/dist/docs/troubleshooting.html +5 -5
  110. package/dist/files-backends/agent-store-presigned-url.js +1 -1
  111. package/dist/index.d.ts +2 -2
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +1 -1
  114. package/dist/internal/advertise-tools.d.ts +79 -0
  115. package/dist/internal/advertise-tools.d.ts.map +1 -0
  116. package/dist/internal/advertise-tools.js +185 -0
  117. package/dist/internal/cli-deploy.d.ts.map +1 -1
  118. package/dist/internal/cli-deploy.js +7 -1
  119. package/dist/internal/cli-manifest.d.ts +19 -0
  120. package/dist/internal/cli-manifest.d.ts.map +1 -0
  121. package/dist/internal/cli-manifest.js +49 -0
  122. package/dist/internal/cli-slack.d.ts.map +1 -1
  123. package/dist/internal/cli-slack.js +9 -1
  124. package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -1
  125. package/dist/internal/convert-automation/convert-workflow.js +2 -10
  126. package/dist/internal/cursor/account-mcp.d.ts +29 -3
  127. package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
  128. package/dist/internal/cursor/account-mcp.js +147 -67
  129. package/dist/internal/cursor/backend-client.d.ts +11 -6
  130. package/dist/internal/cursor/backend-client.d.ts.map +1 -1
  131. package/dist/internal/cursor/backend-client.js +32 -10
  132. package/dist/internal/cursor-account-mcp-auth.d.ts +11 -0
  133. package/dist/internal/cursor-account-mcp-auth.d.ts.map +1 -1
  134. package/dist/internal/cursor-account-mcp-auth.js +69 -0
  135. package/dist/internal/cursor-agent-template.d.ts +9 -0
  136. package/dist/internal/cursor-agent-template.d.ts.map +1 -0
  137. package/dist/internal/cursor-agent-template.js +37 -0
  138. package/dist/internal/deploy-client.d.ts +1 -0
  139. package/dist/internal/deploy-client.d.ts.map +1 -1
  140. package/dist/internal/deploy-client.js +18 -2
  141. package/dist/internal/deploy-manifest.d.ts +76 -0
  142. package/dist/internal/deploy-manifest.d.ts.map +1 -0
  143. package/dist/internal/deploy-manifest.js +117 -0
  144. package/dist/internal/deployment-scm-event-stream.d.ts +116 -0
  145. package/dist/internal/deployment-scm-event-stream.d.ts.map +1 -0
  146. package/dist/internal/deployment-scm-event-stream.js +474 -0
  147. package/dist/internal/discovery.d.ts.map +1 -1
  148. package/dist/internal/discovery.js +111 -10
  149. package/dist/internal/init-project.d.ts.map +1 -1
  150. package/dist/internal/init-project.js +12 -123
  151. package/dist/internal/init-scaffold.d.ts +8 -0
  152. package/dist/internal/init-scaffold.d.ts.map +1 -0
  153. package/dist/internal/init-scaffold.js +168 -0
  154. package/dist/internal/inline-stdio-mcp.d.ts +2 -0
  155. package/dist/internal/inline-stdio-mcp.d.ts.map +1 -1
  156. package/dist/internal/inline-stdio-mcp.js +10 -8
  157. package/dist/internal/json-schema.d.ts +7 -0
  158. package/dist/internal/json-schema.d.ts.map +1 -1
  159. package/dist/internal/json-schema.js +18 -3
  160. package/dist/internal/mcp-endpoint.js +7 -7
  161. package/dist/internal/mcp-host.d.ts +18 -0
  162. package/dist/internal/mcp-host.d.ts.map +1 -1
  163. package/dist/internal/mcp-host.js +43 -5
  164. package/dist/internal/mcp-oauth.d.ts +22 -0
  165. package/dist/internal/mcp-oauth.d.ts.map +1 -1
  166. package/dist/internal/mcp-oauth.js +40 -1
  167. package/dist/internal/package-inline-stdio.d.ts.map +1 -1
  168. package/dist/internal/package-inline-stdio.js +5 -5
  169. package/dist/internal/review-comments.d.ts +97 -0
  170. package/dist/internal/review-comments.d.ts.map +1 -1
  171. package/dist/internal/review-comments.js +151 -0
  172. package/dist/internal/sanitize-mcp-tool-name.d.ts +20 -0
  173. package/dist/internal/sanitize-mcp-tool-name.d.ts.map +1 -0
  174. package/dist/internal/sanitize-mcp-tool-name.js +30 -0
  175. package/dist/internal/sdk-runner.d.ts +1 -1
  176. package/dist/internal/sdk-runner.d.ts.map +1 -1
  177. package/dist/internal/sdk-runner.js +36 -13
  178. package/dist/internal/server.d.ts.map +1 -1
  179. package/dist/internal/server.js +18 -0
  180. package/dist/internal/session-engine.d.ts +66 -0
  181. package/dist/internal/session-engine.d.ts.map +1 -1
  182. package/dist/internal/session-engine.js +428 -110
  183. package/dist/internal/shallow-clone.d.ts +170 -0
  184. package/dist/internal/shallow-clone.d.ts.map +1 -0
  185. package/dist/internal/shallow-clone.js +412 -0
  186. package/dist/internal/slack-provision-client.d.ts +2 -0
  187. package/dist/internal/slack-provision-client.d.ts.map +1 -1
  188. package/dist/internal/slack-provision-client.js +1 -0
  189. package/dist/internal/terminal-style.d.ts +18 -0
  190. package/dist/internal/terminal-style.d.ts.map +1 -1
  191. package/dist/internal/terminal-style.js +46 -1
  192. package/dist/internal/turn-lease-store.d.ts +44 -0
  193. package/dist/internal/turn-lease-store.d.ts.map +1 -0
  194. package/dist/internal/turn-lease-store.js +139 -0
  195. package/dist/internal/workspace.d.ts +14 -0
  196. package/dist/internal/workspace.d.ts.map +1 -1
  197. package/dist/internal/workspace.js +33 -0
  198. package/dist/playground/assets/index-77uhu5Kr.css +1 -0
  199. package/dist/playground/assets/index-D4buox4m.js +85 -0
  200. package/dist/playground/index.html +2 -2
  201. package/dist/storage-protocol.d.ts +122 -0
  202. package/dist/storage-protocol.d.ts.map +1 -0
  203. package/dist/storage-protocol.js +173 -0
  204. package/dist/storage.d.ts +2 -72
  205. package/dist/storage.d.ts.map +1 -1
  206. package/dist/storage.js +2 -82
  207. package/dist/tools.d.ts +7 -0
  208. package/dist/tools.d.ts.map +1 -1
  209. package/dist/types.d.ts +141 -6
  210. package/dist/types.d.ts.map +1 -1
  211. package/docs/concepts.md +4 -4
  212. package/docs/guides/mcp-oauth.md +3 -1
  213. package/docs/reference/agent-config.md +11 -12
  214. package/docs/reference/connections.md +108 -10
  215. package/docs/reference/sessions.md +2 -2
  216. package/docs/reference/tools.md +14 -0
  217. package/docs/troubleshooting.md +3 -2
  218. package/package.json +7 -2
  219. package/skills/create-agent/SKILL.md +12 -9
  220. package/skills/debug/SKILL.md +2 -1
  221. package/skills/framework-map/SKILL.md +6 -6
  222. package/skills/mcp-auth/SKILL.md +8 -6
  223. package/src/bin/agent-serve.ts +12 -2
  224. package/src/channels/github/api.ts +6 -1
  225. package/src/channels/github/binding.ts +21 -0
  226. package/src/channels/github/checks.ts +179 -0
  227. package/src/channels/github/cursor-account.ts +9 -6
  228. package/src/channels/github/index.ts +1 -0
  229. package/src/channels/github/types.ts +8 -0
  230. package/src/channels/slack/channel-watch.ts +6 -3
  231. package/src/channels/slack/dispatch.ts +40 -3
  232. package/src/channels/slack/manifest.ts +9 -10
  233. package/src/channels/slack/nudge-store.ts +56 -0
  234. package/src/channels/slack/slack-channel.ts +3 -0
  235. package/src/channels/slack/types.ts +24 -7
  236. package/src/connections.ts +17 -5
  237. package/src/index.ts +5 -0
  238. package/src/internal/advertise-tools.ts +278 -0
  239. package/src/internal/cli-deploy.ts +11 -1
  240. package/src/internal/cli-manifest.ts +63 -0
  241. package/src/internal/cli-slack.ts +10 -1
  242. package/src/internal/convert-automation/convert-workflow.ts +2 -11
  243. package/src/internal/cursor/account-mcp.ts +208 -73
  244. package/src/internal/cursor/backend-client.ts +45 -11
  245. package/src/internal/cursor-account-mcp-auth.ts +83 -0
  246. package/src/internal/cursor-agent-template.ts +46 -0
  247. package/src/internal/deploy-client.ts +25 -6
  248. package/src/internal/deploy-manifest.ts +161 -0
  249. package/src/internal/deployment-scm-event-stream.ts +593 -0
  250. package/src/internal/discovery.ts +132 -3
  251. package/src/internal/init-project.ts +18 -153
  252. package/src/internal/init-scaffold.ts +176 -0
  253. package/src/internal/inline-stdio-mcp.ts +13 -0
  254. package/src/internal/json-schema.ts +24 -3
  255. package/src/internal/mcp-endpoint.ts +6 -0
  256. package/src/internal/mcp-host.ts +70 -9
  257. package/src/internal/mcp-oauth.ts +55 -1
  258. package/src/internal/package-inline-stdio.ts +5 -1
  259. package/src/internal/review-comments.ts +245 -0
  260. package/src/internal/sanitize-mcp-tool-name.ts +33 -0
  261. package/src/internal/sdk-runner.ts +50 -11
  262. package/src/internal/server.ts +19 -0
  263. package/src/internal/session-engine.ts +392 -19
  264. package/src/internal/shallow-clone.ts +595 -0
  265. package/src/internal/slack-provision-client.ts +3 -0
  266. package/src/internal/terminal-style.ts +67 -1
  267. package/src/internal/turn-lease-store.ts +147 -0
  268. package/src/internal/workspace.ts +33 -0
  269. package/src/storage-protocol.ts +247 -0
  270. package/src/storage.ts +16 -110
  271. package/src/tools.ts +7 -0
  272. package/src/types.ts +149 -7
  273. package/templates/agentic-owners/agent/agent.ts +3 -0
  274. package/templates/demo/agent/agent.ts +3 -0
  275. package/templates/pr-autofixer/agent/lib/drive-schemas.ts +4 -1
  276. package/templates/security-reviewer/agent/agent.ts +3 -0
  277. package/templates/triage/agent/agent.ts +3 -0
  278. package/dist/docs/assets/chunks/@localSearchIndexroot.5ozYNf74.js +0 -1
  279. package/dist/docs/assets/reference_connections.md.CSQiNzre.lean.js +0 -1
  280. package/dist/docs/assets/troubleshooting.md.CuVztCKs.js +0 -1
  281. package/dist/playground/assets/index-B4rcOgeP.css +0 -1
  282. package/dist/playground/assets/index-DXcY42Jv.js +0 -85
  283. /package/dist/docs/assets/{concepts.md.CqOsxbMU.lean.js → concepts.md.BXAm6G-C.lean.js} +0 -0
  284. /package/dist/docs/assets/{guides_mcp-oauth.md.C7G7IykG.lean.js → guides_mcp-oauth.md.CzEB6RaG.lean.js} +0 -0
  285. /package/dist/docs/assets/{reference_sessions.md.DBVFi2Sx.lean.js → reference_sessions.md.B0DdlM-K.lean.js} +0 -0
  286. /package/dist/docs/assets/{troubleshooting.md.CuVztCKs.lean.js → troubleshooting.md.DQ-hYuZT.lean.js} +0 -0
@@ -46,7 +46,24 @@ type ProviderArgs = {
46
46
  onRedirect?: (url: URL) => void;
47
47
  tokens?: OAuthTokens;
48
48
  clientInformation?: OAuthClientInformationFull;
49
+ /**
50
+ * True when authorize/token requests must NOT carry the RFC 8707
51
+ * `resource` indicator, read off the server's protected-resource
52
+ * metadata (`cursor_omit_resource_indicator`). Entra rejects the
53
+ * indicator with AADSTS9010010, so Microsoft 365 flows through Cursor's
54
+ * REST-as-MCP translator fail pre-auth without this.
55
+ */
56
+ omitResourceIndicator?: boolean;
49
57
  };
58
+ /**
59
+ * Reads the Cursor REST-as-MCP translator's OAuth quirk off the resource's
60
+ * RFC 9728 protected-resource metadata. Deliberately self-contained
61
+ * (`@cursor/july` publishes to public npm with no private workspace
62
+ * dependencies — see `waitForMcpOAuthCallback`): matches the translator
63
+ * path shape on any origin so local translators work, and fails to the
64
+ * default behavior (indicator kept) when the PRM is unreachable.
65
+ */
66
+ export declare function fetchOmitResourceIndicatorFromPrm(resourceUrl: string, fetchImpl?: typeof fetch): Promise<boolean>;
50
67
  export declare class HostMcpOAuthProvider implements OAuthClientProvider {
51
68
  private tokensValue;
52
69
  private clientInfo;
@@ -54,6 +71,11 @@ export declare class HostMcpOAuthProvider implements OAuthClientProvider {
54
71
  private redirect;
55
72
  private readonly meta;
56
73
  private readonly args;
74
+ /**
75
+ * Assigned only when the PRM sets `cursor_omit_resource_indicator`; left
76
+ * absent otherwise so the SDK's default resource validation applies.
77
+ */
78
+ readonly validateResourceURL: (() => Promise<URL | undefined>) | undefined;
57
79
  constructor(args: ProviderArgs);
58
80
  get redirectUrl(): string;
59
81
  get clientMetadata(): OAuthClientMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-oauth.d.ts","sourceRoot":"","sources":["../../src/internal/mcp-oauth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OA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B,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8F/B;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAsB7C"}
@@ -210,12 +210,49 @@ export class FileMcpOAuthStore {
210
210
  });
211
211
  }
212
212
  }
213
+ /**
214
+ * Reads the Cursor REST-as-MCP translator's OAuth quirk off the resource's
215
+ * RFC 9728 protected-resource metadata. Deliberately self-contained
216
+ * (`@cursor/july` publishes to public npm with no private workspace
217
+ * dependencies — see `waitForMcpOAuthCallback`): matches the translator
218
+ * path shape on any origin so local translators work, and fails to the
219
+ * default behavior (indicator kept) when the PRM is unreachable.
220
+ */
221
+ export function fetchOmitResourceIndicatorFromPrm(resourceUrl_1) {
222
+ return __awaiter(this, arguments, void 0, function* (resourceUrl, fetchImpl = fetch) {
223
+ let url;
224
+ try {
225
+ url = new URL(resourceUrl);
226
+ }
227
+ catch (_a) {
228
+ return false;
229
+ }
230
+ if (!/^\/rest-mcp\/[^/]+\/mcp\/?$/.test(url.pathname)) {
231
+ return false;
232
+ }
233
+ const prmUrl = `${url.origin}/.well-known/oauth-protected-resource${url.pathname.replace(/\/+$/, "")}`;
234
+ try {
235
+ const response = yield fetchImpl(prmUrl);
236
+ if (!response.ok) {
237
+ return false;
238
+ }
239
+ const document = (yield response.json());
240
+ return document.cursor_omit_resource_indicator === true;
241
+ }
242
+ catch (_b) {
243
+ return false;
244
+ }
245
+ });
246
+ }
213
247
  export class HostMcpOAuthProvider {
214
248
  constructor(args) {
215
249
  var _a;
216
250
  this.args = args;
217
251
  this.tokensValue = args.tokens;
218
252
  this.clientInfo = args.clientInformation;
253
+ if (args.omitResourceIndicator === true) {
254
+ this.validateResourceURL = () => __awaiter(this, void 0, void 0, function* () { return undefined; });
255
+ }
219
256
  this.meta = {
220
257
  redirect_uris: [(_a = args.redirectUrl) !== null && _a !== void 0 ? _a : MCP_OAUTH_CALLBACK_URL],
221
258
  token_endpoint_auth_method: "none",
@@ -293,9 +330,10 @@ export function createHostMcpOAuthProvider(args) {
293
330
  return __awaiter(this, void 0, void 0, function* () {
294
331
  var _a;
295
332
  const store = (_a = args.store) !== null && _a !== void 0 ? _a : new FileMcpOAuthStore();
296
- const [fileTokens, fileClient] = yield Promise.all([
333
+ const [fileTokens, fileClient, omitResourceIndicator] = yield Promise.all([
297
334
  store.loadTokens(args.identifier, args.resourceUrl),
298
335
  store.loadClientInformation(args.identifier, args.resourceUrl),
336
+ fetchOmitResourceIndicatorFromPrm(args.resourceUrl),
299
337
  ]);
300
338
  return new HostMcpOAuthProvider({
301
339
  identifier: args.identifier,
@@ -304,6 +342,7 @@ export function createHostMcpOAuthProvider(args) {
304
342
  tokens: fileTokens !== null && fileTokens !== void 0 ? fileTokens : tokensFromEnv(args.identifier),
305
343
  clientInformation: fileClient !== null && fileClient !== void 0 ? fileClient : clientIdFromEnv(args.identifier),
306
344
  onRedirect: args.onRedirect,
345
+ omitResourceIndicator,
307
346
  });
308
347
  });
309
348
  }
@@ -1 +1 @@
1
- {"version":3,"file":"package-inline-stdio.d.ts","sourceRoot":"","sources":["../../src/internal/package-inline-stdio.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EACV,mBAAmB,EACnB,2BAA2B,EAE5B,MAAM,aAAa,CAAC;AA+BrB,wBAAsB,4BAA4B,CAAC,OAAO,EAAE;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsE/B"}
1
+ {"version":3,"file":"package-inline-stdio.d.ts","sourceRoot":"","sources":["../../src/internal/package-inline-stdio.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EACV,mBAAmB,EACnB,2BAA2B,EAE5B,MAAM,aAAa,CAAC;AAmCrB,wBAAsB,4BAA4B,CAAC,OAAO,EAAE;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsE/B"}
@@ -16,7 +16,7 @@ import { createRequire } from "node:module";
16
16
  import { dirname, join } from "node:path";
17
17
  import { fileURLToPath } from "node:url";
18
18
  import * as esbuild from "esbuild";
19
- import { toolInputJsonSchema } from "./json-schema.js";
19
+ import { toolInputJsonSchema, toolOutputJsonSchema } from "./json-schema.js";
20
20
  const require = createRequire(import.meta.url);
21
21
  const CONNECTION_SPECIFIERS = new Set([
22
22
  "@anysphere/agent-serve/connections",
@@ -31,10 +31,10 @@ function sibling(basename) {
31
31
  function jsonSchemaCatalog(tools) {
32
32
  const catalog = {};
33
33
  for (const [name, tool] of Object.entries(tools)) {
34
- catalog[name] = {
35
- description: tool.description,
36
- inputSchema: toolInputJsonSchema(tool.inputSchema),
37
- };
34
+ const outputSchema = toolOutputJsonSchema(tool.outputSchema);
35
+ catalog[name] = Object.assign({ description: tool.description, inputSchema: toolInputJsonSchema(tool.inputSchema) }, (outputSchema === undefined
36
+ ? {}
37
+ : { outputSchema: outputSchema }));
38
38
  }
39
39
  return catalog;
40
40
  }
@@ -6,6 +6,20 @@ export type ReviewCommentPostResult = {
6
6
  mode: "review_with_inline_comments" | "review_body_only" | "skipped";
7
7
  inlineCommentCount: number;
8
8
  detail: string;
9
+ /**
10
+ * Ids of the inline comments this post created, when the publisher could
11
+ * read them back. Callers that later re-read a PR's comments use these as
12
+ * the provenance allowlist: a comment id we did not create is not ours,
13
+ * no matter what its body looks like. Empty when the publisher cannot
14
+ * resolve them (it never guesses).
15
+ */
16
+ postedComments?: PostedReviewComment[];
17
+ };
18
+ /** One inline comment this agent created, as the SCM assigned it. */
19
+ export type PostedReviewComment = {
20
+ id: number;
21
+ file: string;
22
+ line: number;
9
23
  };
10
24
  export type ReviewInlineComment = {
11
25
  file: string;
@@ -33,6 +47,88 @@ export type ReviewCommentsRequest = {
33
47
  export type ReviewCommentPublisherImplementation = {
34
48
  postReview: (args: ReviewCommentPostArgs) => Promise<ReviewCommentPostResult>;
35
49
  };
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.
55
+ */
56
+ export type ScmReviewProvider = "github";
57
+ /** Which SCM's PR to read review comments from. */
58
+ export type ScmReviewTarget = {
59
+ provider: ScmReviewProvider;
60
+ /** `owner/name`. */
61
+ repo: string;
62
+ prNumber: number;
63
+ };
64
+ /**
65
+ * One existing inline review comment, provider-neutral.
66
+ *
67
+ * Field names follow Bugbot's `ExistingInlineComment`
68
+ * (`backend/server/src/bugbot/review/applyBugbotPRReview.ts`), which is the
69
+ * shape its resolution judge consumes after normalizing each provider's
70
+ * `getPRComments` output — so the same review logic reads the same way here.
71
+ */
72
+ export type ExistingReviewComment = {
73
+ id: number;
74
+ file: string;
75
+ startLine: number;
76
+ endLine: number;
77
+ body: string;
78
+ };
79
+ export type GetReviewCommentsArgs = {
80
+ target: ScmReviewTarget;
81
+ /** Comment ids to fetch; ids the SCM no longer has are omitted. */
82
+ commentIds: readonly number[];
83
+ signal?: AbortSignal;
84
+ };
85
+ /**
86
+ * Read side of the review-comment seam, mirroring
87
+ * {@link ReviewCommentPublisherImplementation}. Bugbot's equivalent is
88
+ * `IGitProvider.getPRComments`.
89
+ *
90
+ * By id rather than by listing: callers only ever want comments they
91
+ * recorded creating, and a busy PR's comment list runs to thousands, where
92
+ * any page cap silently drops exactly the older comments a re-review needs.
93
+ */
94
+ export type ReviewCommentReaderImplementation = {
95
+ getReviewComments: (args: GetReviewCommentsArgs) => Promise<ExistingReviewComment[]>;
96
+ };
97
+ /** Parse a PR URL into the SCM target to read comments from. */
98
+ export declare function resolveScmReviewTarget(prUrl: string): ScmReviewTarget | undefined;
99
+ /**
100
+ * Reader for a resolved target, mirroring Bugbot's `createPrGitProvider`
101
+ * dispatch. Returns undefined when the host cannot serve that provider (no
102
+ * GitHub client bound), so callers degrade instead of throwing.
103
+ */
104
+ export declare function createReviewCommentReader(args: {
105
+ target: ScmReviewTarget;
106
+ github?: HostGitHubClient;
107
+ }): ReviewCommentReaderImplementation | undefined;
108
+ /**
109
+ * Reads inline review comments through the host GitHub client (Cursor
110
+ * account lease, App installation token, or PAT).
111
+ */
112
+ export declare function createHostGithubReviewCommentReader(github: HostGitHubClient): ReviewCommentReaderImplementation;
113
+ type GithubReviewCommentLike = {
114
+ id: number;
115
+ path: string;
116
+ body: string;
117
+ line?: number | null;
118
+ start_line?: number | null;
119
+ original_line?: number | null;
120
+ original_start_line?: number | null;
121
+ };
122
+ /**
123
+ * GitHub review comment → {@link ExistingReviewComment}.
124
+ *
125
+ * Prefers the `original_*` fields — the path/lines/commit as of the review
126
+ * the comment belongs to. `line` drifts as the PR gains commits, so a
127
+ * caller correlating a comment with the review that produced it needs the
128
+ * original position, the same fields Bugbot carries on
129
+ * `PullRequestCommentOutput`.
130
+ */
131
+ export declare function normalizeGithubReviewComment(comment: GithubReviewCommentLike): ExistingReviewComment | undefined;
36
132
  /**
37
133
  * Prepares the provider-neutral review payload used by local `gh` posting.
38
134
  */
@@ -55,4 +151,5 @@ export declare function createLocalGhReviewPublisher(): ReviewCommentPublisherIm
55
151
  * cursorAccount })` is bound.
56
152
  */
57
153
  export declare function createHostGithubReviewPublisher(github: HostGitHubClient): ReviewCommentPublisherImplementation;
154
+ export {};
58
155
  //# sourceMappingURL=review-comments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-comments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8,100 @@ 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. */
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;
21
+ }
22
+ /**
23
+ * Reader for a resolved target, mirroring Bugbot's `createPrGitProvider`
24
+ * dispatch. Returns undefined when the host cannot serve that provider (no
25
+ * GitHub client bound), so callers degrade instead of throwing.
26
+ */
27
+ export function createReviewCommentReader(args) {
28
+ switch (args.target.provider) {
29
+ case "github":
30
+ return args.github === undefined
31
+ ? undefined
32
+ : createHostGithubReviewCommentReader(args.github);
33
+ }
34
+ }
35
+ /** Cap on pages pulled per PR; GitHub serves 100 comments per page. */
36
+ const REVIEW_COMMENTS_MAX_PAGES = 5;
37
+ const REVIEW_COMMENTS_PAGE_SIZE = 100;
38
+ /**
39
+ * Reads inline review comments through the host GitHub client (Cursor
40
+ * account lease, App installation token, or PAT).
41
+ */
42
+ export function createHostGithubReviewCommentReader(github) {
43
+ return {
44
+ getReviewComments(_a) {
45
+ return __awaiter(this, arguments, void 0, function* ({ target, commentIds, signal }) {
46
+ const [owner, repo] = target.repo.split("/", 2);
47
+ if (owner === undefined || repo === undefined || repo === "") {
48
+ return [];
49
+ }
50
+ const octokit = yield github.getOctokit();
51
+ const comments = [];
52
+ for (const commentId of commentIds) {
53
+ signal === null || signal === void 0 ? void 0 : signal.throwIfAborted();
54
+ try {
55
+ const response = yield octokit.rest.pulls.getReviewComment({
56
+ owner,
57
+ repo,
58
+ comment_id: commentId,
59
+ });
60
+ const normalized = normalizeGithubReviewComment(response.data);
61
+ if (normalized !== undefined) {
62
+ comments.push(normalized);
63
+ }
64
+ }
65
+ catch (_b) {
66
+ // Deleted or otherwise unreadable: that finding simply has no
67
+ // prior text to judge, which is the same as it not being there.
68
+ }
69
+ }
70
+ return comments;
71
+ });
72
+ },
73
+ };
74
+ }
75
+ /**
76
+ * GitHub review comment → {@link ExistingReviewComment}.
77
+ *
78
+ * Prefers the `original_*` fields — the path/lines/commit as of the review
79
+ * the comment belongs to. `line` drifts as the PR gains commits, so a
80
+ * caller correlating a comment with the review that produced it needs the
81
+ * original position, the same fields Bugbot carries on
82
+ * `PullRequestCommentOutput`.
83
+ */
84
+ export function normalizeGithubReviewComment(comment) {
85
+ var _a, _b, _c;
86
+ // Take both lines from the same position set. Mixing them (original end
87
+ // line with the drifted current start line) would describe a range that
88
+ // never existed in either revision.
89
+ const original = (_a = comment.original_line) !== null && _a !== void 0 ? _a : undefined;
90
+ const endLine = (_b = original !== null && original !== void 0 ? original : comment.line) !== null && _b !== void 0 ? _b : undefined;
91
+ if (endLine === undefined || endLine === null) {
92
+ return undefined;
93
+ }
94
+ const startLine = (_c = (original === undefined
95
+ ? comment.start_line
96
+ : comment.original_start_line)) !== null && _c !== void 0 ? _c : endLine;
97
+ return {
98
+ id: comment.id,
99
+ file: comment.path,
100
+ startLine,
101
+ endLine,
102
+ body: comment.body,
103
+ };
104
+ }
11
105
  /**
12
106
  * Prepares the provider-neutral review payload used by local `gh` posting.
13
107
  */
@@ -97,6 +191,15 @@ function postReviewViaHostGithub(github, args) {
97
191
  detail: htmlUrl
98
192
  ? `posted via host GitHub: ${htmlUrl}`
99
193
  : `posted via host GitHub with ${inlineCommentCount} inline comment(s)`,
194
+ postedComments: yield readPostedComments({
195
+ octokit,
196
+ owner,
197
+ repo,
198
+ prNumber: request.prNumber,
199
+ reviewId: response.data.id,
200
+ expected: inlineCommentCount,
201
+ signal: args.signal,
202
+ }),
100
203
  };
101
204
  }
102
205
  catch (error) {
@@ -107,6 +210,54 @@ function postReviewViaHostGithub(github, args) {
107
210
  }
108
211
  });
109
212
  }
213
+ /**
214
+ * Ids of the inline comments a just-created review owns.
215
+ *
216
+ * `pulls.createReview` returns the review, not its comments, so they come
217
+ * from the review-scoped listing. Scoping to the review matters: the
218
+ * PR-wide list is ordered oldest-first and runs to thousands on a busy PR,
219
+ * so the comments we just created are the ones a page cap would drop.
220
+ * Best-effort: any failure yields an empty list, which costs the next run
221
+ * its prior findings rather than risking a wrong id. Never throws — the
222
+ * review is already posted by this point.
223
+ */
224
+ function readPostedComments(args) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ var _a;
227
+ var _b;
228
+ if (args.expected === 0) {
229
+ return [];
230
+ }
231
+ try {
232
+ const posted = [];
233
+ for (let page = 1; page <= REVIEW_COMMENTS_MAX_PAGES; page++) {
234
+ (_a = args.signal) === null || _a === void 0 ? void 0 : _a.throwIfAborted();
235
+ const response = yield args.octokit.rest.pulls.listCommentsForReview({
236
+ owner: args.owner,
237
+ repo: args.repo,
238
+ pull_number: args.prNumber,
239
+ review_id: args.reviewId,
240
+ per_page: REVIEW_COMMENTS_PAGE_SIZE,
241
+ page,
242
+ });
243
+ for (const comment of response.data) {
244
+ const line = (_b = comment.original_line) !== null && _b !== void 0 ? _b : comment.line;
245
+ if (line === null || line === undefined) {
246
+ continue;
247
+ }
248
+ posted.push({ id: comment.id, file: comment.path, line });
249
+ }
250
+ if (response.data.length < REVIEW_COMMENTS_PAGE_SIZE) {
251
+ break;
252
+ }
253
+ }
254
+ return posted;
255
+ }
256
+ catch (_c) {
257
+ return [];
258
+ }
259
+ });
260
+ }
110
261
  function postReviewViaLocalGh(args) {
111
262
  return __awaiter(this, void 0, void 0, function* () {
112
263
  var _a, _b;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * MCP tool-name sanitization shared by the Cursor-account bridge
3
+ * (`account-mcp.ts`) and advertised connections (`advertise-tools.ts`).
4
+ *
5
+ * Connector display names — and the aggregate `/v1/agent/mcp` names minted
6
+ * from them (`<serverIdentifier>-<tool>`) — can contain spaces, dots, and
7
+ * other characters that are illegal as the tool name a model sees.
8
+ *
9
+ * Character class matches `packages/agent` `normalizeMcpToolName`
10
+ * (`[^a-zA-Z0-9_-]` → `_`). Length cap and the empty fallback match the
11
+ * account bridge (MCP clients commonly enforce `^[a-zA-Z0-9_-]{1,128}$`).
12
+ * Callers that talk to the backend keep the original advertised name.
13
+ */
14
+ /** MCP clients commonly enforce `^[a-zA-Z0-9_-]{1,128}$` for tool names. */
15
+ export declare const MAX_MCP_TOOL_NAME_LENGTH = 128;
16
+ /** Connector display names can contain anything (spaces, dots, emoji). */
17
+ export declare function sanitizeMcpToolName(name: string): string;
18
+ /** `base` for the first claimant, `base_2` / `base_3` … for colliders. */
19
+ export declare function suffixMcpToolName(base: string, index: number): string;
20
+ //# sourceMappingURL=sanitize-mcp-tool-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize-mcp-tool-name.d.ts","sourceRoot":"","sources":["../../src/internal/sanitize-mcp-tool-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * MCP tool-name sanitization shared by the Cursor-account bridge
3
+ * (`account-mcp.ts`) and advertised connections (`advertise-tools.ts`).
4
+ *
5
+ * Connector display names — and the aggregate `/v1/agent/mcp` names minted
6
+ * from them (`<serverIdentifier>-<tool>`) — can contain spaces, dots, and
7
+ * other characters that are illegal as the tool name a model sees.
8
+ *
9
+ * Character class matches `packages/agent` `normalizeMcpToolName`
10
+ * (`[^a-zA-Z0-9_-]` → `_`). Length cap and the empty fallback match the
11
+ * account bridge (MCP clients commonly enforce `^[a-zA-Z0-9_-]{1,128}$`).
12
+ * Callers that talk to the backend keep the original advertised name.
13
+ */
14
+ /** MCP clients commonly enforce `^[a-zA-Z0-9_-]{1,128}$` for tool names. */
15
+ export const MAX_MCP_TOOL_NAME_LENGTH = 128;
16
+ /** Connector display names can contain anything (spaces, dots, emoji). */
17
+ export function sanitizeMcpToolName(name) {
18
+ const cleaned = name
19
+ .replace(/[^a-zA-Z0-9_-]/g, "_")
20
+ .slice(0, MAX_MCP_TOOL_NAME_LENGTH);
21
+ return cleaned === "" ? "tool" : cleaned;
22
+ }
23
+ /** `base` for the first claimant, `base_2` / `base_3` … for colliders. */
24
+ export function suffixMcpToolName(base, index) {
25
+ if (index === 0) {
26
+ return base;
27
+ }
28
+ const suffix = `_${index + 1}`;
29
+ return `${base.slice(0, MAX_MCP_TOOL_NAME_LENGTH - suffix.length)}${suffix}`;
30
+ }
@@ -24,7 +24,7 @@ export interface AgentRunner {
24
24
  * a subset of {@link RunnerTurnRequest} — anything that disagrees warms an
25
25
  * executor no turn will ask for.
26
26
  */
27
- export type RunnerPrewarmRequest = Pick<RunnerTurnRequest, "workspaceDir" | "runnerStateDir" | "sandbox" | "tools" | "mcpServers" | "subagents" | "model">;
27
+ export type RunnerPrewarmRequest = Pick<RunnerTurnRequest, "workspaceDir" | "runnerStateDir" | "sandbox" | "tools" | "mcpServers" | "perSendMcpServers" | "subagents" | "model">;
28
28
  /** Whether a workspace was actually resolved, and why not when it wasn't. */
29
29
  export type PrewarmOutcome = {
30
30
  readonly warmed: true;
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAGrB,2EAA2E;AAC3E,MAAM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back in/i.test(message);
75
75
  }
76
+ /** Cloud `wait()` copy for `stream_expired` / a missing start-state blob. */
77
+ function isStreamExpiredErrorMessage(message) {
78
+ if (message === undefined) {
79
+ return false;
80
+ }
81
+ return /run stream is no longer available|\[stream_expired\]/i.test(message);
82
+ }
83
+ function retryReason(message, isFirstTurn) {
84
+ if (isStreamExpiredErrorMessage(message)) {
85
+ return "cloud run stream expired";
86
+ }
87
+ // First-turn auth is the credential; a fresh handle cannot fix it.
88
+ if (!isFirstTurn && isAuthErrorMessage(message)) {
89
+ return "authentication failure";
90
+ }
91
+ return undefined;
92
+ }
76
93
  export class CursorSdkRunner {
77
94
  constructor(options = {}) {
78
95
  this.options = options;
@@ -96,24 +113,21 @@ export class CursorSdkRunner {
96
113
  } });
97
114
  const outcome = yield this.runTurnAttempt(tracked);
98
115
  if (outcome.status !== "error" ||
99
- !isAuthErrorMessage(outcome.errorMessage) ||
100
116
  sawUpdate ||
101
- request.isFirstTurn ||
102
117
  ((_a = request.signal) === null || _a === void 0 ? void 0 : _a.aborted) === true) {
103
118
  return outcome;
104
119
  }
105
- // The turn died on an authentication failure before producing any output
106
- // the signature of a handle whose exchanged access token expired (the
107
- // failed attempt already evicted it). Retrying once on a fresh handle is
108
- // safe here because nothing streamed and no tool ran. First turns are
109
- // excluded: their token was exchanged moments ago, so the credential
110
- // itself is the problem and a retry cannot succeed.
111
- this.log(`[agent-sdk] session ${request.sessionId}: retrying the turn on a fresh SDK agent handle after an authentication failure`);
120
+ const reason = retryReason(outcome.errorMessage, request.isFirstTurn);
121
+ if (reason === undefined) {
122
+ return outcome;
123
+ }
124
+ // Log the original error even when the retry succeeds so the expiry
125
+ // still shows up in Datadog.
126
+ this.log(`[agent-sdk] session ${request.sessionId}: ${reason}: ${outcome.errorMessage}; retrying the turn`);
112
127
  try {
113
128
  return yield this.runTurnAttempt(tracked);
114
129
  }
115
130
  catch (_b) {
116
- // The retry was best effort; report the original failure.
117
131
  return outcome;
118
132
  }
119
133
  });
@@ -132,14 +146,16 @@ export class CursorSdkRunner {
132
146
  })),
133
147
  }
134
148
  : request.prompt;
135
- const run = yield agent.send(sendMessage, Object.assign({ onDelta: (_a) => __awaiter(this, [_a], void 0, function* ({ update }) {
149
+ const run = yield agent.send(sendMessage, Object.assign(Object.assign({ onDelta: (_a) => __awaiter(this, [_a], void 0, function* ({ update }) {
136
150
  try {
137
151
  yield request.onUpdate(update);
138
152
  }
139
153
  catch (_b) {
140
154
  // Stream mapping must never reject into the SDK transport.
141
155
  }
142
- }) }, (request.runtime === "local"
156
+ }) }, (request.runtime === "local" && request.perSendMcpServers === true
157
+ ? { mcpServers: request.mcpServers }
158
+ : {})), (request.runtime === "local"
143
159
  ? {
144
160
  local: Object.assign({ customTools: request.customTools }, (request.forceExpireActiveRun === true
145
161
  ? { force: true }
@@ -168,6 +184,12 @@ export class CursorSdkRunner {
168
184
  if (request.onSdkAgentId !== undefined) {
169
185
  yield request.onSdkAgentId(agent.agentId);
170
186
  }
187
+ // Readable on the handle as soon as send resolves, long before wait().
188
+ if (request.onRequestId !== undefined &&
189
+ run.requestId !== undefined &&
190
+ run.requestId !== "") {
191
+ yield request.onRequestId(run.requestId);
192
+ }
171
193
  try {
172
194
  const result = yield run.wait();
173
195
  let outcome = toTurnOutcome(result);
@@ -287,7 +309,8 @@ export class CursorSdkRunner {
287
309
  buildSharedOptions(request) {
288
310
  var _a;
289
311
  const subagents = toAgentDefinitions(request.subagents);
290
- return Object.assign(Object.assign({ model: toModelSelection((_a = request.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL), apiKey: this.requireApiKey() }, (Object.keys(request.mcpServers).length > 0
312
+ return Object.assign(Object.assign({ model: toModelSelection((_a = request.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL), apiKey: this.requireApiKey() }, (Object.keys(request.mcpServers).length > 0 &&
313
+ request.perSendMcpServers !== true
291
314
  ? { mcpServers: request.mcpServers }
292
315
  : {})), (subagents === undefined ? {} : { agents: subagents }));
293
316
  }
@@ -1 +1 @@
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"}
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;AAkHrB,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"}