@cursor/july 0.1.20 → 0.1.21

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 (212) hide show
  1. package/dist/bin/agent-serve.js +0 -0
  2. package/dist/channels/github/instrument.d.ts +20 -0
  3. package/dist/channels/github/instrument.d.ts.map +1 -0
  4. package/dist/channels/slack/api.d.ts +2 -0
  5. package/dist/channels/slack/api.d.ts.map +1 -1
  6. package/dist/channels/slack/api.js +3 -0
  7. package/dist/channels/slack/bot-mentions.d.ts +106 -0
  8. package/dist/channels/slack/bot-mentions.d.ts.map +1 -0
  9. package/dist/channels/slack/bot-mentions.js +243 -0
  10. package/dist/channels/slack/dispatch.d.ts +6 -0
  11. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  12. package/dist/channels/slack/dispatch.js +24 -3
  13. package/dist/channels/slack/inbound.d.ts +10 -1
  14. package/dist/channels/slack/inbound.d.ts.map +1 -1
  15. package/dist/channels/slack/inbound.js +12 -4
  16. package/dist/channels/slack/index.d.ts +1 -0
  17. package/dist/channels/slack/index.d.ts.map +1 -1
  18. package/dist/channels/slack/index.js +1 -0
  19. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  20. package/dist/channels/slack/slack-channel.js +61 -22
  21. package/dist/channels/slack/types.d.ts +58 -0
  22. package/dist/channels/slack/types.d.ts.map +1 -1
  23. package/dist/docs/404.html +1 -1
  24. package/dist/docs/ab.html +2 -2
  25. package/dist/docs/assets/{app.T-5ImnM3.js → app.jDxLzWv4.js} +1 -1
  26. package/dist/docs/assets/chunks/@localSearchIndexroot.DoJHJjqF.js +1 -0
  27. package/dist/docs/assets/chunks/{VPLocalSearchBox.OMGMWH6H.js → VPLocalSearchBox.Y6bDR1-a.js} +1 -1
  28. package/dist/docs/assets/chunks/{theme.DLg4yB4D.js → theme.CLazCWlJ.js} +2 -2
  29. package/dist/docs/building-with-agents.html +2 -2
  30. package/dist/docs/concepts.html +2 -2
  31. package/dist/docs/deployment.html +2 -2
  32. package/dist/docs/evals.html +2 -2
  33. package/dist/docs/example-agents/approval-buddy.html +2 -2
  34. package/dist/docs/example-agents/benny.html +2 -2
  35. package/dist/docs/example-agents/bugbot.html +2 -2
  36. package/dist/docs/example-agents/codebase-wiki.html +2 -2
  37. package/dist/docs/example-agents/codeowners-review.html +2 -2
  38. package/dist/docs/example-agents/concierge.html +2 -2
  39. package/dist/docs/example-agents/fsd.html +2 -2
  40. package/dist/docs/example-agents/index.html +2 -2
  41. package/dist/docs/example-agents/knowledge-base.html +2 -2
  42. package/dist/docs/example-agents/oncall.html +2 -2
  43. package/dist/docs/example-agents/security-reviewer.html +2 -2
  44. package/dist/docs/example-agents/slack-agent.html +2 -2
  45. package/dist/docs/example-agents/weather-agent.html +2 -2
  46. package/dist/docs/guides/agent-to-agent.html +2 -2
  47. package/dist/docs/guides/cloud-runtime.html +2 -2
  48. package/dist/docs/guides/github.html +2 -2
  49. package/dist/docs/guides/human-in-the-loop.html +2 -2
  50. package/dist/docs/guides/mcp-oauth.html +2 -2
  51. package/dist/docs/guides/slack.html +2 -2
  52. package/dist/docs/guides/webhooks.html +2 -2
  53. package/dist/docs/hillclimbing.html +2 -2
  54. package/dist/docs/index.html +2 -2
  55. package/dist/docs/quickstart.html +2 -2
  56. package/dist/docs/reference/agent-config.html +2 -2
  57. package/dist/docs/reference/channels.html +2 -2
  58. package/dist/docs/reference/cli.html +2 -2
  59. package/dist/docs/reference/connections.html +2 -2
  60. package/dist/docs/reference/hooks.html +2 -2
  61. package/dist/docs/reference/http-api.html +2 -2
  62. package/dist/docs/reference/instructions.html +2 -2
  63. package/dist/docs/reference/playground.html +2 -2
  64. package/dist/docs/reference/project-layout.html +2 -2
  65. package/dist/docs/reference/prompt.html +2 -2
  66. package/dist/docs/reference/schedules.html +2 -2
  67. package/dist/docs/reference/sessions.html +2 -2
  68. package/dist/docs/reference/skills.html +2 -2
  69. package/dist/docs/reference/subagents.html +2 -2
  70. package/dist/docs/reference/tools.html +2 -2
  71. package/dist/docs/scaffolding-agents.html +2 -2
  72. package/dist/docs/storage.html +2 -2
  73. package/dist/docs/troubleshooting.html +2 -2
  74. package/dist/internal/json-dir-store.d.ts +32 -0
  75. package/dist/internal/json-dir-store.d.ts.map +1 -0
  76. package/dist/internal/json-dir-store.js +100 -0
  77. package/dist/internal/resolved-connections.d.ts +1 -1
  78. package/dist/internal/resolved-connections.d.ts.map +1 -1
  79. package/dist/internal/resolved-connections.js +10 -0
  80. package/dist/internal/session-engine.d.ts +4 -1
  81. package/dist/internal/session-engine.d.ts.map +1 -1
  82. package/dist/internal/session-engine.js +13 -2
  83. package/dist/playground/assets/index-CjOQ4hN9.css +1 -0
  84. package/dist/playground/assets/index-dshZQJCp.js +85 -0
  85. package/dist/playground/index.html +2 -2
  86. package/dist/types.d.ts +7 -0
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js +9 -0
  89. package/package.json +24 -24
  90. package/src/bin/agent-serve.version.test.ts +62 -0
  91. package/src/channels/github/api.test.ts +64 -0
  92. package/src/channels/github/auth.test.ts +105 -0
  93. package/src/channels/github/cursor-account.test.ts +204 -0
  94. package/src/channels/github/forward.test.ts +457 -0
  95. package/src/channels/github/github.test.ts +937 -0
  96. package/src/channels/github/replay.test.ts +179 -0
  97. package/src/channels/slack/api.post-message.test.ts +148 -0
  98. package/src/channels/slack/api.ts +5 -0
  99. package/src/channels/slack/approvals.test.ts +328 -0
  100. package/src/channels/slack/block-actions.test.ts +452 -0
  101. package/src/channels/slack/bot-mentions.test.ts +217 -0
  102. package/src/channels/slack/bot-mentions.ts +315 -0
  103. package/src/channels/slack/channel-watch.test.ts +363 -0
  104. package/src/channels/slack/cursor-account.test.ts +253 -0
  105. package/src/channels/slack/defaults.final-post.test.ts +182 -0
  106. package/src/channels/slack/dispatch.test.ts +795 -0
  107. package/src/channels/slack/dispatch.ts +27 -1
  108. package/src/channels/slack/eval-directive.test.ts +273 -0
  109. package/src/channels/slack/inbound.ts +25 -4
  110. package/src/channels/slack/index.ts +1 -0
  111. package/src/channels/slack/message-body.test.ts +54 -0
  112. package/src/channels/slack/nudge-store.test.ts +143 -0
  113. package/src/channels/slack/slack-channel.ts +66 -8
  114. package/src/channels/slack/slack.test.ts +391 -0
  115. package/src/channels/slack/stop.test.ts +23 -0
  116. package/src/channels/slack/thread-context.test.ts +202 -0
  117. package/src/channels/slack/types.ts +60 -0
  118. package/src/evals/assertions.test.ts +580 -0
  119. package/src/evals/expect.test.ts +144 -0
  120. package/src/evals/judge.test.ts +181 -0
  121. package/src/evals/loaders.test.ts +132 -0
  122. package/src/evals/matchers.test.ts +95 -0
  123. package/src/evals/reporters.test.ts +303 -0
  124. package/src/evals/run-facts.test.ts +259 -0
  125. package/src/internal/ab-snapshot.test.ts +325 -0
  126. package/src/internal/approval-gate.test.ts +49 -0
  127. package/src/internal/approvals.integration.test.ts +383 -0
  128. package/src/internal/authored-loaders.test.ts +31 -0
  129. package/src/internal/builtin-tools/reminders.test.ts +201 -0
  130. package/src/internal/channel-route-schema.test.ts +294 -0
  131. package/src/internal/chat-attach.test.ts +262 -0
  132. package/src/internal/cli-deploy.test.ts +1991 -0
  133. package/src/internal/cli-mcp.test.ts +789 -0
  134. package/src/internal/cli-skills.test.ts +133 -0
  135. package/src/internal/cli-slack.test.ts +1647 -0
  136. package/src/internal/cloud-merge.test.ts +74 -0
  137. package/src/internal/cron.test.ts +22 -0
  138. package/src/internal/cursor/account-mcp.test.ts +807 -0
  139. package/src/internal/cursor/backend-client.test.ts +591 -0
  140. package/src/internal/cursor/credentials.test.ts +351 -0
  141. package/src/internal/cursor/github-credentials.test.ts +136 -0
  142. package/src/internal/cursor-account-mcp-auth.test.ts +310 -0
  143. package/src/internal/cursor-account.integration.test.ts +441 -0
  144. package/src/internal/cursor-event-relay.test.ts +746 -0
  145. package/src/internal/cursor-github-credentials.integration.test.ts +271 -0
  146. package/src/internal/cursor-slack-relay.test.ts +525 -0
  147. package/src/internal/deploy-source.test.ts +111 -0
  148. package/src/internal/discovery.builtin-tools.test.ts +94 -0
  149. package/src/internal/discovery.concurrency.test.ts +60 -0
  150. package/src/internal/discovery.cursor-account.test.ts +133 -0
  151. package/src/internal/discovery.cwd.test.ts +83 -0
  152. package/src/internal/discovery.hosting.test.ts +80 -0
  153. package/src/internal/discovery.identity.test.ts +44 -0
  154. package/src/internal/docs-site.test.ts +66 -0
  155. package/src/internal/duration.test.ts +29 -0
  156. package/src/internal/eval-judge-model.test.ts +187 -0
  157. package/src/internal/eval-run-store.cancel.test.ts +142 -0
  158. package/src/internal/eval-run-store.storage.test.ts +211 -0
  159. package/src/internal/eval-runner.http.test.ts +403 -0
  160. package/src/internal/eval-runner.run.test.ts +928 -0
  161. package/src/internal/evals-client.test.ts +307 -0
  162. package/src/internal/event-mapper.test.ts +243 -0
  163. package/src/internal/github-fanout.test.ts +213 -0
  164. package/src/internal/handleAgentServeTrigger.test.ts +179 -0
  165. package/src/internal/host-kv.test.ts +82 -0
  166. package/src/internal/host-platforms.test.ts +126 -0
  167. package/src/internal/http-channel.test.ts +402 -0
  168. package/src/internal/init-project.test.ts +269 -0
  169. package/src/internal/install-cursor-skills.test.ts +262 -0
  170. package/src/internal/local-env.test.ts +100 -0
  171. package/src/internal/log-ring.test.ts +31 -0
  172. package/src/internal/logs-client.test.ts +350 -0
  173. package/src/internal/mcp-endpoint.test.ts +436 -0
  174. package/src/internal/mcp-host.test.ts +298 -0
  175. package/src/internal/mcp-oauth.test.ts +148 -0
  176. package/src/internal/net.test.ts +17 -0
  177. package/src/internal/peer-connections.test.ts +128 -0
  178. package/src/internal/peer-mcp.integration.test.ts +289 -0
  179. package/src/internal/playground/toolchain.test.ts +53 -0
  180. package/src/internal/playground-cli.test.ts +187 -0
  181. package/src/internal/playground-proxy.test.ts +376 -0
  182. package/src/internal/prompt-context.integration.test.ts +232 -0
  183. package/src/internal/prompt-context.test.ts +127 -0
  184. package/src/internal/reminder-runner.test.ts +390 -0
  185. package/src/internal/reminder-store.test.ts +53 -0
  186. package/src/internal/request-headers.test.ts +27 -0
  187. package/src/internal/resolve-prod-target.test.ts +787 -0
  188. package/src/internal/resolved-connections.test.ts +295 -0
  189. package/src/internal/resolved-connections.ts +18 -1
  190. package/src/internal/router.test.ts +57 -0
  191. package/src/internal/sdk-runner.test.ts +290 -0
  192. package/src/internal/session-engine.coalesce.test.ts +169 -0
  193. package/src/internal/session-engine.concurrency.test.ts +250 -0
  194. package/src/internal/session-engine.host-oauth-mcp.test.ts +110 -0
  195. package/src/internal/session-engine.interrupt.test.ts +577 -0
  196. package/src/internal/session-engine.storage.test.ts +547 -0
  197. package/src/internal/session-engine.ts +15 -1
  198. package/src/internal/session-urls.test.ts +28 -0
  199. package/src/internal/sessions-client.test.ts +518 -0
  200. package/src/internal/storage-coordinator.test.ts +517 -0
  201. package/src/internal/tool-call.test.ts +458 -0
  202. package/src/internal/tool-result.test.ts +52 -0
  203. package/src/internal/trajectory.approvals.test.ts +83 -0
  204. package/src/internal/trajectory.subagents.test.ts +198 -0
  205. package/src/internal/turn-governor.test.ts +137 -0
  206. package/src/internal/update-check.test.ts +485 -0
  207. package/src/internal/workspace.test.ts +81 -0
  208. package/src/storage-backends/cursor-hosted.test.ts +121 -0
  209. package/src/types.ts +12 -0
  210. package/dist/docs/assets/chunks/@localSearchIndexroot.CvejISXF.js +0 -1
  211. package/dist/playground/assets/index-CidizGZv.css +0 -1
  212. package/dist/playground/assets/index-CuiAKZaP.js +0 -85
@@ -0,0 +1,271 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import { getGithubCursorAccountRuntime } from "../channels/github/cursor-account.js";
6
+ import { githubChannel } from "../channels/github/github-channel.js";
7
+ import { httpChannel } from "../channels.js";
8
+ import type {
9
+ AgentProject,
10
+ AgentServeHandle,
11
+ ChannelDefinition,
12
+ } from "../types.js";
13
+ import type { AgentRunner } from "./sdk-runner.js";
14
+ import { startServer } from "./server.js";
15
+
16
+ interface RecordedRequest {
17
+ method: string;
18
+ url: string;
19
+ body?: unknown;
20
+ authorization?: string;
21
+ }
22
+
23
+ describe("serve with cursor-account GitHub channels", () => {
24
+ const savedEnv: Record<string, string | undefined> = {};
25
+ const requests: RecordedRequest[] = [];
26
+ let stateRoot: string | undefined;
27
+ let handle: AgentServeHandle | undefined;
28
+
29
+ const runner: AgentRunner = {
30
+ async runTurn() {
31
+ return { status: "finished", result: "unused" };
32
+ },
33
+ };
34
+
35
+ function fixture(
36
+ cursorAccount: true | { repos: readonly string[] } = {
37
+ repos: ["acme/widgets", "acme/tools"],
38
+ }
39
+ ): AgentProject {
40
+ return {
41
+ rootDir: "/tmp/cursor-github-fixture",
42
+ agentDir: "/tmp/cursor-github-fixture/agent",
43
+ name: "github-fixture",
44
+ agent: {
45
+ name: "github-fixture",
46
+ runtime: "local",
47
+ tools: [],
48
+ skills: [],
49
+ connections: [],
50
+ subagents: [],
51
+ seedFiles: [],
52
+ },
53
+ httpChannel: httpChannel(),
54
+ channels: [
55
+ {
56
+ id: "github",
57
+ definition: githubChannel({
58
+ cursorAccount,
59
+ }) as unknown as ChannelDefinition,
60
+ },
61
+ ],
62
+ schedules: [],
63
+ hooks: [],
64
+ abs: [],
65
+ diagnostics: [],
66
+ };
67
+ }
68
+
69
+ beforeEach(() => {
70
+ requests.length = 0;
71
+ for (const key of [
72
+ "AGENT_SERVE_CONFIG_DIR",
73
+ "CURSOR_API_BASE_URL",
74
+ "CURSOR_API_KEY",
75
+ "GH_TOKEN",
76
+ ]) {
77
+ savedEnv[key] = process.env[key];
78
+ delete process.env[key];
79
+ }
80
+ process.env.AGENT_SERVE_CONFIG_DIR = "/nonexistent-agent-serve-config";
81
+ vi.stubGlobal(
82
+ "fetch",
83
+ async (input: RequestInfo | URL, init?: RequestInit) => {
84
+ const url = String(input);
85
+ const headers = new Headers(init?.headers);
86
+ const authorization = headers.get("authorization");
87
+ const body =
88
+ typeof init?.body === "string"
89
+ ? (JSON.parse(init.body) as unknown)
90
+ : undefined;
91
+ requests.push({
92
+ method: init?.method ?? "GET",
93
+ url,
94
+ ...(body === undefined ? {} : { body }),
95
+ ...(authorization === null ? {} : { authorization }),
96
+ });
97
+ if (url.endsWith("/v0/scm-events/github-token")) {
98
+ return Response.json({
99
+ token: "ghs_cursor_account",
100
+ expiresAt: new Date(Date.now() + 45 * 60_000).toISOString(),
101
+ });
102
+ }
103
+ if (url.includes("/v0/scm-events/subscriptions")) {
104
+ const subscriptions =
105
+ (
106
+ body as
107
+ | {
108
+ subscriptions?: Array<{
109
+ provider: string;
110
+ repo: string;
111
+ }>;
112
+ }
113
+ | undefined
114
+ )?.subscriptions ?? [];
115
+ return Response.json({
116
+ repos: subscriptions.map((subscription) => ({
117
+ ...subscription,
118
+ isSubscribed: true,
119
+ })),
120
+ });
121
+ }
122
+ return Response.json({
123
+ events: [],
124
+ nextOffset: "",
125
+ gapDetected: false,
126
+ });
127
+ }
128
+ );
129
+ });
130
+
131
+ afterEach(async () => {
132
+ await handle?.close();
133
+ handle = undefined;
134
+ if (stateRoot !== undefined) {
135
+ await rm(stateRoot, { recursive: true, force: true });
136
+ stateRoot = undefined;
137
+ }
138
+ vi.unstubAllGlobals();
139
+ for (const [key, value] of Object.entries(savedEnv)) {
140
+ if (value === undefined) {
141
+ delete process.env[key];
142
+ } else {
143
+ process.env[key] = value;
144
+ }
145
+ }
146
+ });
147
+
148
+ it("requires the host to be signed in to Cursor", async () => {
149
+ stateRoot = await mkdtemp(join(tmpdir(), "agent-serve-cursor-github-"));
150
+ await expect(
151
+ startServer([{ slug: "", project: fixture() }], {
152
+ port: 0,
153
+ stateRoot,
154
+ playground: false,
155
+ runner,
156
+ })
157
+ ).rejects.toThrow(
158
+ /cursor-events[\s\S]*signed-in Cursor[\s\S]*agentkit login/
159
+ );
160
+ });
161
+
162
+ it("mints one credential covering every selected repository", async () => {
163
+ stateRoot = await mkdtemp(join(tmpdir(), "agent-serve-cursor-github-"));
164
+ process.env.CURSOR_API_KEY = "crsr_account";
165
+ process.env.CURSOR_API_BASE_URL = "https://backend.example";
166
+ const project = fixture();
167
+ const logs: string[] = [];
168
+
169
+ handle = await startServer([{ slug: "", project }], {
170
+ port: 0,
171
+ stateRoot,
172
+ playground: false,
173
+ runner,
174
+ logger: (line) => logs.push(line),
175
+ });
176
+
177
+ const tokenRequest = requests.find((request) =>
178
+ request.url.endsWith("/v0/scm-events/github-token")
179
+ );
180
+ expect(tokenRequest).toMatchObject({
181
+ method: "POST",
182
+ body: {
183
+ repos: ["acme/widgets", "acme/tools"],
184
+ permissions: "pr-write",
185
+ },
186
+ authorization: "Bearer crsr_account",
187
+ });
188
+ expect(process.env.GH_TOKEN).toBe("ghs_cursor_account");
189
+ const definition = project.channels[0]?.definition;
190
+ if (definition === undefined) {
191
+ throw new Error("GitHub fixture channel is missing.");
192
+ }
193
+ const accountRuntime = getGithubCursorAccountRuntime(definition);
194
+ await expect(accountRuntime?.credentials.getToken()).resolves.toBe(
195
+ "ghs_cursor_account"
196
+ );
197
+ expect(
198
+ logs.some((line) =>
199
+ line.includes("Cursor account repo-scoped credential")
200
+ )
201
+ ).toBe(true);
202
+ });
203
+
204
+ it("does not expose signed-in GitHub access through anonymous serving", async () => {
205
+ stateRoot = await mkdtemp(join(tmpdir(), "agent-serve-cursor-github-"));
206
+ process.env.CURSOR_API_KEY = "crsr_account";
207
+ process.env.CURSOR_API_BASE_URL = "https://backend.example";
208
+
209
+ await expect(
210
+ startServer([{ slug: "", project: fixture() }], {
211
+ port: 0,
212
+ stateRoot,
213
+ playground: false,
214
+ runner,
215
+ allowAnonymous: true,
216
+ })
217
+ ).rejects.toThrow(/cannot be served with --allow-anonymous/);
218
+ });
219
+
220
+ it("serves anonymously when allowAnonymousCursorGithub opts in", async () => {
221
+ stateRoot = await mkdtemp(join(tmpdir(), "agent-serve-cursor-github-"));
222
+ process.env.CURSOR_API_KEY = "crsr_account";
223
+ process.env.CURSOR_API_BASE_URL = "https://backend.example";
224
+ const logs: string[] = [];
225
+
226
+ handle = await startServer([{ slug: "", project: fixture() }], {
227
+ port: 0,
228
+ stateRoot,
229
+ playground: false,
230
+ runner,
231
+ allowAnonymous: true,
232
+ allowAnonymousCursorGithub: true,
233
+ logger: (line) => logs.push(line),
234
+ });
235
+
236
+ expect(
237
+ requests.find((request) =>
238
+ request.url.endsWith("/v0/scm-events/github-token")
239
+ )
240
+ ).toBeDefined();
241
+ expect(
242
+ logs.some((line) => line.includes("--allow-anonymous-cursor-github"))
243
+ ).toBe(true);
244
+ });
245
+
246
+ it("accepts repository scope from serve options with cursorAccount true", async () => {
247
+ stateRoot = await mkdtemp(join(tmpdir(), "agent-serve-cursor-github-"));
248
+ process.env.CURSOR_API_BASE_URL = "https://backend.example";
249
+
250
+ handle = await startServer([{ slug: "", project: fixture(true) }], {
251
+ port: 0,
252
+ stateRoot,
253
+ playground: false,
254
+ runner,
255
+ cursorEvents: {
256
+ repos: ["acme/widgets"],
257
+ apiKey: "crsr_nested",
258
+ baseUrl: "https://backend.example",
259
+ },
260
+ });
261
+
262
+ expect(
263
+ requests.find((request) =>
264
+ request.url.endsWith("/v0/scm-events/github-token")
265
+ )
266
+ ).toMatchObject({
267
+ body: { repos: ["acme/widgets"] },
268
+ authorization: "Bearer crsr_nested",
269
+ });
270
+ });
271
+ });