@cursor/july 0.1.25 → 0.1.27

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 (288) hide show
  1. package/dist/ab.d.ts +6 -0
  2. package/dist/ab.d.ts.map +1 -1
  3. package/dist/ab.js +1 -0
  4. package/dist/artifacts.d.ts +34 -0
  5. package/dist/artifacts.d.ts.map +1 -0
  6. package/dist/artifacts.js +57 -0
  7. package/dist/bin/agent-serve.js +31 -9
  8. package/dist/channels/github/github-channel.d.ts +1 -1
  9. package/dist/channels/github/github-channel.d.ts.map +1 -1
  10. package/dist/channels/github/github-channel.js +14 -1
  11. package/dist/channels/github/types.d.ts +6 -1
  12. package/dist/channels/github/types.d.ts.map +1 -1
  13. package/dist/channels/slack/api.d.ts +2 -1
  14. package/dist/channels/slack/api.d.ts.map +1 -1
  15. package/dist/channels/slack/api.js +1 -0
  16. package/dist/channels/slack/cursor-account.d.ts +2 -1
  17. package/dist/channels/slack/cursor-account.d.ts.map +1 -1
  18. package/dist/channels/slack/cursor-account.js +1 -1
  19. package/dist/channels/slack/dispatch.d.ts +4 -1
  20. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  21. package/dist/channels/slack/dispatch.js +3 -3
  22. package/dist/channels/slack/interactive.d.ts +2 -1
  23. package/dist/channels/slack/interactive.d.ts.map +1 -1
  24. package/dist/channels/slack/interactive.js +1 -0
  25. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  26. package/dist/channels/slack/slack-channel.js +4 -3
  27. package/dist/channels/slack/types.d.ts +6 -1
  28. package/dist/channels/slack/types.d.ts.map +1 -1
  29. package/dist/docs/404.html +1 -1
  30. package/dist/docs/ab.html +2 -2
  31. package/dist/docs/assets/{app.DYcC9FY-.js → app.BICLoJYF.js} +1 -1
  32. package/dist/docs/assets/chunks/@localSearchIndexroot.CQJytDwU.js +1 -0
  33. package/dist/docs/assets/chunks/{VPLocalSearchBox.o4N_knTV.js → VPLocalSearchBox.wN4Ko9dT.js} +1 -1
  34. package/dist/docs/assets/chunks/{theme.DQ-njyo0.js → theme.dnnTE-Co.js} +2 -2
  35. package/dist/docs/building-with-agents.html +2 -2
  36. package/dist/docs/concepts.html +2 -2
  37. package/dist/docs/deployment.html +2 -2
  38. package/dist/docs/evals.html +2 -2
  39. package/dist/docs/example-agents/approval-buddy.html +2 -2
  40. package/dist/docs/example-agents/benny.html +2 -2
  41. package/dist/docs/example-agents/bugbot.html +2 -2
  42. package/dist/docs/example-agents/codebase-wiki.html +2 -2
  43. package/dist/docs/example-agents/codeowners-review.html +2 -2
  44. package/dist/docs/example-agents/concierge.html +2 -2
  45. package/dist/docs/example-agents/fsd.html +2 -2
  46. package/dist/docs/example-agents/index.html +2 -2
  47. package/dist/docs/example-agents/knowledge-base.html +2 -2
  48. package/dist/docs/example-agents/oncall.html +2 -2
  49. package/dist/docs/example-agents/security-reviewer.html +2 -2
  50. package/dist/docs/example-agents/slack-agent.html +2 -2
  51. package/dist/docs/example-agents/weather-agent.html +2 -2
  52. package/dist/docs/guides/agent-to-agent.html +2 -2
  53. package/dist/docs/guides/cloud-runtime.html +2 -2
  54. package/dist/docs/guides/github.html +2 -2
  55. package/dist/docs/guides/human-in-the-loop.html +2 -2
  56. package/dist/docs/guides/mcp-oauth.html +2 -2
  57. package/dist/docs/guides/slack.html +2 -2
  58. package/dist/docs/guides/webhooks.html +2 -2
  59. package/dist/docs/hillclimbing.html +2 -2
  60. package/dist/docs/index.html +2 -2
  61. package/dist/docs/quickstart.html +2 -2
  62. package/dist/docs/reference/agent-config.html +2 -2
  63. package/dist/docs/reference/channels.html +2 -2
  64. package/dist/docs/reference/cli.html +2 -2
  65. package/dist/docs/reference/connections.html +2 -2
  66. package/dist/docs/reference/hooks.html +2 -2
  67. package/dist/docs/reference/http-api.html +2 -2
  68. package/dist/docs/reference/instructions.html +2 -2
  69. package/dist/docs/reference/playground.html +2 -2
  70. package/dist/docs/reference/project-layout.html +2 -2
  71. package/dist/docs/reference/prompt.html +2 -2
  72. package/dist/docs/reference/schedules.html +2 -2
  73. package/dist/docs/reference/sessions.html +2 -2
  74. package/dist/docs/reference/skills.html +2 -2
  75. package/dist/docs/reference/subagents.html +2 -2
  76. package/dist/docs/reference/tools.html +2 -2
  77. package/dist/docs/scaffolding-agents.html +2 -2
  78. package/dist/docs/storage.html +2 -2
  79. package/dist/docs/troubleshooting.html +2 -2
  80. package/dist/evals/assertions.d.ts +10 -1
  81. package/dist/evals/assertions.d.ts.map +1 -1
  82. package/dist/evals/assertions.js +12 -0
  83. package/dist/evals.d.ts +1 -1
  84. package/dist/evals.d.ts.map +1 -1
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +1 -0
  88. package/dist/internal/ab-fold.d.ts.map +1 -1
  89. package/dist/internal/ab-fold.js +4 -0
  90. package/dist/internal/ab-snapshot.d.ts.map +1 -1
  91. package/dist/internal/ab-snapshot.js +1 -0
  92. package/dist/internal/artifacts-store.d.ts +45 -0
  93. package/dist/internal/artifacts-store.d.ts.map +1 -0
  94. package/dist/internal/artifacts-store.js +250 -0
  95. package/dist/internal/builtin-tools/artifacts.d.ts +10 -0
  96. package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -0
  97. package/dist/internal/builtin-tools/artifacts.js +73 -0
  98. package/dist/internal/builtin-tools/index.d.ts +8 -1
  99. package/dist/internal/builtin-tools/index.d.ts.map +1 -1
  100. package/dist/internal/builtin-tools/index.js +15 -0
  101. package/dist/internal/cli-ax.d.ts +11 -0
  102. package/dist/internal/cli-ax.d.ts.map +1 -1
  103. package/dist/internal/cli-ax.js +80 -0
  104. package/dist/internal/cli-slack.d.ts.map +1 -1
  105. package/dist/internal/cli-slack.js +14 -6
  106. package/dist/internal/discovery.d.ts.map +1 -1
  107. package/dist/internal/discovery.js +83 -2
  108. package/dist/internal/distribution.d.ts.map +1 -1
  109. package/dist/internal/distribution.js +1 -0
  110. package/dist/internal/model-pricing.d.ts +49 -0
  111. package/dist/internal/model-pricing.d.ts.map +1 -0
  112. package/dist/internal/model-pricing.js +377 -0
  113. package/dist/internal/reminder-runner.d.ts.map +1 -1
  114. package/dist/internal/reminder-runner.js +1 -0
  115. package/dist/internal/schedule-runner.d.ts.map +1 -1
  116. package/dist/internal/schedule-runner.js +1 -0
  117. package/dist/internal/sdk-runner.d.ts.map +1 -1
  118. package/dist/internal/sdk-runner.js +9 -1
  119. package/dist/internal/server.d.ts.map +1 -1
  120. package/dist/internal/server.js +39 -0
  121. package/dist/internal/session-cost.d.ts +49 -0
  122. package/dist/internal/session-cost.d.ts.map +1 -0
  123. package/dist/internal/session-cost.js +175 -0
  124. package/dist/internal/session-engine.d.ts +35 -1
  125. package/dist/internal/session-engine.d.ts.map +1 -1
  126. package/dist/internal/session-engine.js +128 -7
  127. package/dist/internal/storage-coordinator.d.ts +15 -0
  128. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  129. package/dist/internal/storage-coordinator.js +52 -0
  130. package/dist/internal/trajectory.d.ts +9 -1
  131. package/dist/internal/trajectory.d.ts.map +1 -1
  132. package/dist/internal/trajectory.js +32 -5
  133. package/dist/playground/assets/index-BDCeW4uc.js +86 -0
  134. package/dist/playground/assets/index-Bul1WfrB.css +1 -0
  135. package/dist/playground/index.html +2 -2
  136. package/dist/storage.d.ts +4 -0
  137. package/dist/storage.d.ts.map +1 -1
  138. package/dist/storage.js +4 -0
  139. package/dist/types.d.ts +164 -1
  140. package/dist/types.d.ts.map +1 -1
  141. package/package.json +26 -26
  142. package/src/ab.ts +7 -0
  143. package/src/bin/agent-serve.ts +30 -2
  144. package/src/channels/github/github-channel.ts +19 -2
  145. package/src/channels/github/types.ts +6 -0
  146. package/src/channels/slack/api.ts +3 -1
  147. package/src/channels/slack/cursor-account.ts +3 -1
  148. package/src/channels/slack/dispatch.ts +12 -1
  149. package/src/channels/slack/interactive.ts +3 -0
  150. package/src/channels/slack/slack-channel.ts +6 -0
  151. package/src/channels/slack/types.ts +6 -0
  152. package/src/internal/ab-fold.ts +4 -0
  153. package/src/internal/ab-snapshot.ts +1 -0
  154. package/src/internal/cli-ax.ts +95 -0
  155. package/src/internal/model-pricing.ts +426 -0
  156. package/src/internal/reminder-runner.ts +1 -0
  157. package/src/internal/schedule-runner.ts +1 -0
  158. package/src/internal/sdk-runner.ts +10 -2
  159. package/src/internal/server.ts +2 -0
  160. package/src/internal/session-cost.ts +231 -0
  161. package/src/internal/session-engine.ts +32 -1
  162. package/src/internal/trajectory.ts +45 -3
  163. package/src/types.ts +42 -2
  164. package/dist/channels/github/instrument.d.ts +0 -20
  165. package/dist/channels/github/instrument.d.ts.map +0 -1
  166. package/dist/docs/assets/chunks/@localSearchIndexroot.BQTzJjR_.js +0 -1
  167. package/dist/internal/json-dir-store.d.ts +0 -32
  168. package/dist/internal/json-dir-store.d.ts.map +0 -1
  169. package/dist/internal/json-dir-store.js +0 -100
  170. package/dist/playground/assets/index-CjOQ4hN9.css +0 -1
  171. package/dist/playground/assets/index-DqXdAFGa.js +0 -85
  172. package/src/bin/agent-serve.version.test.ts +0 -64
  173. package/src/channels/github/api.test.ts +0 -64
  174. package/src/channels/github/auth.test.ts +0 -105
  175. package/src/channels/github/cursor-account.test.ts +0 -204
  176. package/src/channels/github/forward.test.ts +0 -457
  177. package/src/channels/github/github.test.ts +0 -943
  178. package/src/channels/github/replay.test.ts +0 -179
  179. package/src/channels/slack/api.post-message.test.ts +0 -148
  180. package/src/channels/slack/approvals.test.ts +0 -328
  181. package/src/channels/slack/block-actions.test.ts +0 -452
  182. package/src/channels/slack/bot-mentions.test.ts +0 -267
  183. package/src/channels/slack/channel-watch.test.ts +0 -363
  184. package/src/channels/slack/cursor-account.test.ts +0 -253
  185. package/src/channels/slack/defaults.final-post.test.ts +0 -182
  186. package/src/channels/slack/dispatch.test.ts +0 -795
  187. package/src/channels/slack/eval-directive.test.ts +0 -273
  188. package/src/channels/slack/message-body.test.ts +0 -54
  189. package/src/channels/slack/nudge-store.test.ts +0 -143
  190. package/src/channels/slack/slack.test.ts +0 -391
  191. package/src/channels/slack/stop.test.ts +0 -23
  192. package/src/channels/slack/thread-context.test.ts +0 -202
  193. package/src/evals/assertions.test.ts +0 -617
  194. package/src/evals/expect.test.ts +0 -144
  195. package/src/evals/judge.test.ts +0 -181
  196. package/src/evals/loaders.test.ts +0 -132
  197. package/src/evals/matchers.test.ts +0 -95
  198. package/src/evals/reporters.test.ts +0 -303
  199. package/src/evals/run-facts.test.ts +0 -259
  200. package/src/internal/ab-snapshot.test.ts +0 -325
  201. package/src/internal/approval-gate.test.ts +0 -49
  202. package/src/internal/approvals.integration.test.ts +0 -383
  203. package/src/internal/artifacts-store.test.ts +0 -283
  204. package/src/internal/authored-loaders.test.ts +0 -31
  205. package/src/internal/builtin-tools/artifacts.test.ts +0 -247
  206. package/src/internal/builtin-tools/reminders.test.ts +0 -201
  207. package/src/internal/channel-route-schema.test.ts +0 -294
  208. package/src/internal/chat-attach.test.ts +0 -262
  209. package/src/internal/cli-deploy.test.ts +0 -1991
  210. package/src/internal/cli-docs.test.ts +0 -161
  211. package/src/internal/cli-mcp.test.ts +0 -789
  212. package/src/internal/cli-skills.test.ts +0 -133
  213. package/src/internal/cli-slack.test.ts +0 -1654
  214. package/src/internal/cloud-merge.test.ts +0 -74
  215. package/src/internal/cron.test.ts +0 -22
  216. package/src/internal/cursor/account-mcp.test.ts +0 -807
  217. package/src/internal/cursor/backend-client.test.ts +0 -591
  218. package/src/internal/cursor/credentials.test.ts +0 -351
  219. package/src/internal/cursor/github-credentials.test.ts +0 -136
  220. package/src/internal/cursor-account-mcp-auth.test.ts +0 -310
  221. package/src/internal/cursor-account.integration.test.ts +0 -441
  222. package/src/internal/cursor-event-relay.test.ts +0 -746
  223. package/src/internal/cursor-github-credentials.integration.test.ts +0 -271
  224. package/src/internal/cursor-slack-relay.test.ts +0 -525
  225. package/src/internal/deploy-source.test.ts +0 -111
  226. package/src/internal/discovery.artifact-tool.test.ts +0 -136
  227. package/src/internal/discovery.artifacts.test.ts +0 -119
  228. package/src/internal/discovery.builtin-tools.test.ts +0 -94
  229. package/src/internal/discovery.concurrency.test.ts +0 -60
  230. package/src/internal/discovery.cursor-account.test.ts +0 -133
  231. package/src/internal/discovery.cwd.test.ts +0 -83
  232. package/src/internal/discovery.hosting.test.ts +0 -80
  233. package/src/internal/discovery.identity.test.ts +0 -44
  234. package/src/internal/docs-site.test.ts +0 -66
  235. package/src/internal/duration.test.ts +0 -29
  236. package/src/internal/eval-judge-model.test.ts +0 -187
  237. package/src/internal/eval-run-store.cancel.test.ts +0 -142
  238. package/src/internal/eval-run-store.storage.test.ts +0 -211
  239. package/src/internal/eval-runner.http.test.ts +0 -403
  240. package/src/internal/eval-runner.run.test.ts +0 -928
  241. package/src/internal/evals-client.test.ts +0 -307
  242. package/src/internal/event-mapper.test.ts +0 -243
  243. package/src/internal/github-fanout.test.ts +0 -213
  244. package/src/internal/handleAgentServeTrigger.test.ts +0 -185
  245. package/src/internal/host-kv.test.ts +0 -82
  246. package/src/internal/host-platforms.test.ts +0 -126
  247. package/src/internal/http-channel.test.ts +0 -402
  248. package/src/internal/init-project.test.ts +0 -270
  249. package/src/internal/install-cursor-skills.test.ts +0 -262
  250. package/src/internal/local-env.test.ts +0 -120
  251. package/src/internal/log-ring.test.ts +0 -31
  252. package/src/internal/logs-client.test.ts +0 -350
  253. package/src/internal/mcp-endpoint.test.ts +0 -436
  254. package/src/internal/mcp-host.test.ts +0 -298
  255. package/src/internal/mcp-oauth.test.ts +0 -148
  256. package/src/internal/net.test.ts +0 -17
  257. package/src/internal/peer-connections.test.ts +0 -128
  258. package/src/internal/peer-mcp.integration.test.ts +0 -289
  259. package/src/internal/playground/toolchain.test.ts +0 -53
  260. package/src/internal/playground-cli.test.ts +0 -187
  261. package/src/internal/playground-proxy.test.ts +0 -376
  262. package/src/internal/prompt-context.integration.test.ts +0 -232
  263. package/src/internal/prompt-context.test.ts +0 -127
  264. package/src/internal/reminder-runner.test.ts +0 -390
  265. package/src/internal/reminder-store.test.ts +0 -53
  266. package/src/internal/request-headers.test.ts +0 -27
  267. package/src/internal/resolve-prod-target.test.ts +0 -787
  268. package/src/internal/resolved-connections.test.ts +0 -295
  269. package/src/internal/router.test.ts +0 -57
  270. package/src/internal/sdk-runner.test.ts +0 -290
  271. package/src/internal/server.artifacts.test.ts +0 -303
  272. package/src/internal/session-engine.artifacts.test.ts +0 -243
  273. package/src/internal/session-engine.coalesce.test.ts +0 -169
  274. package/src/internal/session-engine.concurrency.test.ts +0 -250
  275. package/src/internal/session-engine.host-oauth-mcp.test.ts +0 -110
  276. package/src/internal/session-engine.interrupt.test.ts +0 -577
  277. package/src/internal/session-engine.storage.test.ts +0 -547
  278. package/src/internal/session-urls.test.ts +0 -28
  279. package/src/internal/sessions-client.test.ts +0 -518
  280. package/src/internal/storage-coordinator.test.ts +0 -517
  281. package/src/internal/tool-call.test.ts +0 -458
  282. package/src/internal/tool-result.test.ts +0 -52
  283. package/src/internal/trajectory.approvals.test.ts +0 -83
  284. package/src/internal/trajectory.subagents.test.ts +0 -198
  285. package/src/internal/turn-governor.test.ts +0 -137
  286. package/src/internal/update-check.test.ts +0 -485
  287. package/src/internal/workspace.test.ts +0 -207
  288. package/src/storage-backends/cursor-hosted.test.ts +0 -121
@@ -1,943 +0,0 @@
1
- import { createHmac } from "node:crypto";
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { scmMetadataToGitHubPayload } from "../../internal/cursor-event-relay.js";
4
- import type {
5
- ChannelHandlerArgs,
6
- ChannelRouteHandler,
7
- ChannelSession,
8
- SendMessageFn,
9
- } from "../../types.js";
10
- import { formatGitHubOutboundComment } from "./binding.js";
11
- import {
12
- clearGitHubAuthCaches,
13
- defaultGitHubAuth,
14
- defaultGitHubPullRequestMessage,
15
- defaultOnComment,
16
- type GitHubEventContext,
17
- type GitHubRawEvent,
18
- githubChannel,
19
- githubPullRequestContinuationKey,
20
- isGitHubAppBotAuthor,
21
- parseGitHubPullRequestEvent,
22
- shouldDispatchGitHubComment,
23
- verifyGitHubWebhookSignature,
24
- } from "./index.js";
25
-
26
- describe("parseGitHubPullRequestEvent", () => {
27
- it("normalizes a GitHub pull_request payload", () => {
28
- const parsed = parseGitHubPullRequestEvent({
29
- deliveryId: "delivery-1",
30
- payload: pullRequestPayload(),
31
- });
32
-
33
- expect(parsed).toEqual({
34
- ctx: {
35
- deliveryId: "delivery-1",
36
- eventName: "pull_request",
37
- repository: {
38
- fullName: "acme/widgets",
39
- url: "https://github.com/acme/widgets",
40
- owner: "acme",
41
- name: "widgets",
42
- },
43
- conversation: {
44
- kind: "pull_request",
45
- number: 42,
46
- url: "https://github.com/acme/widgets/pull/42",
47
- },
48
- senderLogin: "sender",
49
- sender: { login: "sender" },
50
- },
51
- pullRequest: {
52
- action: "opened",
53
- number: 42,
54
- url: "https://github.com/acme/widgets/pull/42",
55
- title: "Add widgets",
56
- body: "PR body",
57
- headRef: "feature/widgets",
58
- headSha: "abc123",
59
- baseRef: "main",
60
- draft: false,
61
- merged: false,
62
- authorLogin: "octocat",
63
- },
64
- });
65
- });
66
-
67
- it("rejects malformed payloads", () => {
68
- expect(
69
- parseGitHubPullRequestEvent({
70
- payload: { action: "opened" },
71
- })
72
- ).toBeNull();
73
- });
74
- });
75
-
76
- describe("GitHub pull request prompt helpers", () => {
77
- it("builds stable continuation keys and context-rich messages", () => {
78
- const parsed = parseGitHubPullRequestEvent({
79
- payload: pullRequestPayload(),
80
- });
81
- expect(parsed).not.toBeNull();
82
- if (parsed === null) {
83
- return;
84
- }
85
-
86
- expect(githubPullRequestContinuationKey(parsed.ctx)).toBe(
87
- "github-pr:acme/widgets#42"
88
- );
89
- const message = defaultGitHubPullRequestMessage(
90
- parsed.ctx,
91
- parsed.pullRequest
92
- );
93
- expect(message).toContain("GitHub pull request trigger: acme/widgets#42");
94
- expect(message).toContain("Head: feature/widgets (abc123)");
95
- });
96
-
97
- it("derives the turn auth from the delivery actor", () => {
98
- const parsed = parseGitHubPullRequestEvent({
99
- payload: pullRequestPayload(),
100
- });
101
- expect(parsed).not.toBeNull();
102
- if (parsed === null) {
103
- return;
104
- }
105
-
106
- expect(defaultGitHubAuth(parsed.ctx)).toEqual({
107
- authenticator: "github-webhook",
108
- principalId: "sender",
109
- principalType: "user",
110
- attributes: expect.objectContaining({ repository: "acme/widgets" }),
111
- });
112
- });
113
- });
114
-
115
- describe("defaultOnComment / mention gate", () => {
116
- it("dispatches only when the bot is @mentioned", () => {
117
- expect(
118
- shouldDispatchGitHubComment({
119
- body: "hey @my-agent please look",
120
- botName: "my-agent",
121
- })
122
- ).toBe(true);
123
- expect(
124
- shouldDispatchGitHubComment({
125
- body: "no mention here",
126
- botName: "my-agent",
127
- })
128
- ).toBe(false);
129
- expect(
130
- shouldDispatchGitHubComment({
131
- body: "@my-agent hi",
132
- botName: undefined,
133
- })
134
- ).toBe(false);
135
- });
136
-
137
- it("ignores comments from the GitHub App bot actor", () => {
138
- expect(
139
- shouldDispatchGitHubComment({
140
- body: "hey @my-agent please look",
141
- author: { login: "my-agent[bot]", type: "Bot" },
142
- botName: "my-agent",
143
- })
144
- ).toBe(false);
145
- expect(
146
- isGitHubAppBotAuthor({ login: "my-agent[bot]", type: "Bot" }, "my-agent")
147
- ).toBe(true);
148
- });
149
-
150
- it("returns auth when mentioned", () => {
151
- const ctx = {
152
- eventName: "issue_comment",
153
- repository: {
154
- fullName: "acme/widgets",
155
- url: "https://github.com/acme/widgets",
156
- owner: "acme",
157
- name: "widgets",
158
- },
159
- conversation: {
160
- kind: "pull_request" as const,
161
- number: 42,
162
- url: "https://github.com/acme/widgets/pull/42",
163
- },
164
- senderLogin: "sender",
165
- };
166
- expect(
167
- defaultOnComment(
168
- ctx,
169
- {
170
- id: 1,
171
- body: "@my-agent triage this",
172
- url: "https://github.com/acme/widgets/issues/42#issuecomment-1",
173
- htmlUrl: "https://github.com/acme/widgets/issues/42#issuecomment-1",
174
- },
175
- { botName: "my-agent" }
176
- )
177
- ).toEqual({ auth: defaultGitHubAuth(ctx) });
178
- });
179
- });
180
-
181
- describe("verifyGitHubWebhookSignature", () => {
182
- it("accepts a valid sha256 signature", async () => {
183
- const body = JSON.stringify(pullRequestPayload());
184
- const signature = `sha256=${createHmac("sha256", "secret")
185
- .update(body)
186
- .digest("hex")}`;
187
-
188
- await expect(
189
- verifyGitHubWebhookSignature({
190
- body,
191
- signatureHeader: signature,
192
- secret: "secret",
193
- })
194
- ).resolves.toBe("verified");
195
- });
196
-
197
- it("rejects mismatched signatures", async () => {
198
- await expect(
199
- verifyGitHubWebhookSignature({
200
- body: "{}",
201
- signatureHeader: "sha256=bad",
202
- secret: "secret",
203
- })
204
- ).resolves.toBe("mismatch");
205
- });
206
- });
207
-
208
- describe("githubChannel", () => {
209
- let priorWebhookSecret: string | undefined;
210
-
211
- beforeEach(() => {
212
- priorWebhookSecret = process.env.GITHUB_WEBHOOK_SECRET;
213
- delete process.env.GITHUB_WEBHOOK_SECRET;
214
- });
215
-
216
- afterEach(() => {
217
- if (priorWebhookSecret === undefined) {
218
- delete process.env.GITHUB_WEBHOOK_SECRET;
219
- } else {
220
- process.env.GITHUB_WEBHOOK_SECRET = priorWebhookSecret;
221
- }
222
- });
223
-
224
- it("dispatches default review triggers as the delivery actor", async () => {
225
- const body = JSON.stringify(pullRequestPayload());
226
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
227
- const response = await routeHandler(
228
- githubChannel({
229
- auth: [],
230
- cloud: true,
231
- })
232
- )(
233
- new Request("http://127.0.0.1:3000/v1/channels/github", {
234
- method: "POST",
235
- headers: {
236
- "x-github-event": "pull_request",
237
- "x-github-delivery": "delivery-1",
238
- "content-type": "application/json",
239
- },
240
- body,
241
- }),
242
- handlerArgs(send)
243
- );
244
-
245
- await expect(response.json()).resolves.toEqual({
246
- ok: true,
247
- sessionId: "session-1",
248
- isNew: true,
249
- continuationToken: "github-pr:acme/widgets#42",
250
- });
251
- expect(send).toHaveBeenCalledExactlyOnceWith(
252
- expect.stringContaining("GitHub pull request trigger: acme/widgets#42"),
253
- expect.objectContaining({
254
- auth: expect.objectContaining({
255
- authenticator: "github-webhook",
256
- principalId: "sender",
257
- principalType: "user",
258
- }),
259
- continuationToken: "github-pr:acme/widgets#42",
260
- title: "GitHub acme/widgets#42",
261
- cloud: {
262
- repos: [
263
- {
264
- url: "https://github.com/acme/widgets",
265
- prUrl: "https://github.com/acme/widgets/pull/42",
266
- startingRef: "abc123",
267
- },
268
- ],
269
- },
270
- })
271
- );
272
- });
273
-
274
- it("ignores actions outside the default gate without starting a session", async () => {
275
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
276
- const response = await routeHandler(githubChannel({ auth: [] }))(
277
- new Request("http://127.0.0.1:3000/v1/channels/github", {
278
- method: "POST",
279
- headers: { "x-github-event": "pull_request" },
280
- body: JSON.stringify(pullRequestPayload({ action: "closed" })),
281
- }),
282
- handlerArgs(send)
283
- );
284
-
285
- await expect(response.json()).resolves.toEqual({
286
- ok: true,
287
- skipped: true,
288
- reason: "not_dispatched",
289
- action: "closed",
290
- });
291
- expect(send).not.toHaveBeenCalled();
292
- });
293
-
294
- it("replaces the default gate with the onPullRequest hook", async () => {
295
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
296
- const handler = routeHandler(
297
- githubChannel({
298
- auth: [],
299
- onPullRequest: (ctx, pr) =>
300
- pr.action === "synchronize"
301
- ? { auth: defaultGitHubAuth(ctx), context: ["Focus on the diff."] }
302
- : null,
303
- })
304
- );
305
-
306
- const ignored = await handler(
307
- new Request("http://127.0.0.1:3000/v1/channels/github", {
308
- method: "POST",
309
- headers: { "x-github-event": "pull_request" },
310
- body: JSON.stringify(pullRequestPayload({ action: "opened" })),
311
- }),
312
- handlerArgs(send)
313
- );
314
- await expect(ignored.json()).resolves.toEqual({
315
- ok: true,
316
- skipped: true,
317
- reason: "not_dispatched",
318
- action: "opened",
319
- });
320
- expect(send).not.toHaveBeenCalled();
321
-
322
- const dispatched = await handler(
323
- new Request("http://127.0.0.1:3000/v1/channels/github", {
324
- method: "POST",
325
- headers: { "x-github-event": "pull_request" },
326
- body: JSON.stringify(pullRequestPayload({ action: "synchronize" })),
327
- }),
328
- handlerArgs(send)
329
- );
330
- await expect(dispatched.json()).resolves.toMatchObject({ ok: true });
331
- expect(send).toHaveBeenCalledExactlyOnceWith(
332
- expect.stringContaining("Focus on the diff."),
333
- expect.anything()
334
- );
335
- });
336
-
337
- it("dispatches @mention issue comments via the default onComment gate", async () => {
338
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
339
- const response = await routeHandler(
340
- githubChannel({
341
- auth: [],
342
- botName: "my-agent",
343
- })
344
- )(
345
- new Request("http://127.0.0.1:3000/v1/channels/github", {
346
- method: "POST",
347
- headers: {
348
- "x-github-event": "issue_comment",
349
- "x-github-delivery": "delivery-comment",
350
- },
351
- body: JSON.stringify(issueCommentPayload("@my-agent please triage")),
352
- }),
353
- handlerArgs(send)
354
- );
355
-
356
- await expect(response.json()).resolves.toMatchObject({ ok: true });
357
- expect(send).toHaveBeenCalledExactlyOnceWith(
358
- "please triage",
359
- expect.objectContaining({
360
- continuationToken: "github-pr:acme/widgets#42",
361
- auth: expect.objectContaining({ principalId: "sender" }),
362
- })
363
- );
364
- });
365
-
366
- it("dispatches relay-stubbed issue_comment payloads (scm-events metadata)", async () => {
367
- // Regression guard for the /v0/scm-events comment gap: a metadata-only
368
- // envelope with a comment snapshot must clear the issue_comment Zod
369
- // schema and dispatch, without a payload round-trip to GitHub.
370
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
371
- const response = await routeHandler(
372
- githubChannel({ auth: [], botName: "my-agent" })
373
- )(
374
- new Request("http://127.0.0.1:3000/v1/channels/github", {
375
- method: "POST",
376
- headers: {
377
- "x-github-event": "issue_comment",
378
- "x-github-delivery": "delivery-relay-comment",
379
- },
380
- body: JSON.stringify(
381
- scmMetadataToGitHubPayload({
382
- repo: "acme/widgets",
383
- action: "created",
384
- prNumber: 42,
385
- prUrl: "https://github.com/acme/widgets/pull/42",
386
- comment: {
387
- id: 7,
388
- body: "@my-agent please triage",
389
- htmlUrl: "https://github.com/acme/widgets/pull/42#issuecomment-7",
390
- authorLogin: "sender",
391
- },
392
- })
393
- ),
394
- }),
395
- handlerArgs(send)
396
- );
397
-
398
- await expect(response.json()).resolves.toMatchObject({ ok: true });
399
- expect(send).toHaveBeenCalledExactlyOnceWith(
400
- "please triage",
401
- expect.objectContaining({
402
- continuationToken: "github-pr:acme/widgets#42",
403
- auth: expect.objectContaining({ principalId: "sender" }),
404
- })
405
- );
406
- });
407
-
408
- it("skips relay-stubbed comments from the agent's own bot (self/bot-loop gate)", async () => {
409
- // Regression guard: the relay stub must carry user.type through so
410
- // isGitHubAppBotAuthor keeps failing CLOSED for the agent's own
411
- // comments on the scm-events path. Without it, a bot comment that
412
- // @mentions the agent would wake it again (self-wake loop).
413
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
414
- const response = await routeHandler(
415
- githubChannel({ auth: [], botName: "my-agent" })
416
- )(
417
- new Request("http://127.0.0.1:3000/v1/channels/github", {
418
- method: "POST",
419
- headers: {
420
- "x-github-event": "issue_comment",
421
- "x-github-delivery": "delivery-relay-bot-comment",
422
- },
423
- body: JSON.stringify(
424
- scmMetadataToGitHubPayload({
425
- repo: "acme/widgets",
426
- action: "created",
427
- prNumber: 42,
428
- prUrl: "https://github.com/acme/widgets/pull/42",
429
- comment: {
430
- id: 8,
431
- body: "@my-agent looks done to me",
432
- htmlUrl: "https://github.com/acme/widgets/pull/42#issuecomment-8",
433
- authorLogin: "my-agent[bot]",
434
- authorType: "Bot",
435
- },
436
- })
437
- ),
438
- }),
439
- handlerArgs(send)
440
- );
441
-
442
- await expect(response.json()).resolves.toEqual({
443
- ok: true,
444
- skipped: true,
445
- reason: "ignored_comment",
446
- });
447
- expect(send).not.toHaveBeenCalled();
448
- });
449
-
450
- it("skips issue comments without an @mention", async () => {
451
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
452
- const response = await routeHandler(
453
- githubChannel({ auth: [], botName: "my-agent" })
454
- )(
455
- new Request("http://127.0.0.1:3000/v1/channels/github", {
456
- method: "POST",
457
- headers: { "x-github-event": "issue_comment" },
458
- body: JSON.stringify(issueCommentPayload("no bot here")),
459
- }),
460
- handlerArgs(send)
461
- );
462
- await expect(response.json()).resolves.toEqual({
463
- ok: true,
464
- skipped: true,
465
- reason: "not_dispatched",
466
- });
467
- expect(send).not.toHaveBeenCalled();
468
- });
469
-
470
- it("dispatches failed check_suite via onCheckSuite when a PR is attached", async () => {
471
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
472
- const response = await routeHandler(
473
- githubChannel({
474
- auth: [],
475
- onCheckSuite: (ctx, suite) =>
476
- suite.action === "completed" &&
477
- suite.conclusion === "failure" &&
478
- suite.app.slug === "github-actions" &&
479
- suite.pullRequests.length > 0
480
- ? {
481
- auth: defaultGitHubAuth(ctx),
482
- context: [
483
- `Triage failed check suite ${suite.checkSuiteId} at ${suite.headSha}.`,
484
- ],
485
- }
486
- : null,
487
- })
488
- )(
489
- new Request("http://127.0.0.1:3000/v1/channels/github", {
490
- method: "POST",
491
- headers: { "x-github-event": "check_suite" },
492
- body: JSON.stringify(checkSuitePayload()),
493
- }),
494
- handlerArgs(send)
495
- );
496
-
497
- await expect(response.json()).resolves.toMatchObject({ ok: true });
498
- expect(send).toHaveBeenCalledExactlyOnceWith(
499
- expect.stringContaining("Triage failed check suite 99 at deadbeef"),
500
- expect.objectContaining({
501
- continuationToken: "github-pr:acme/widgets#42",
502
- })
503
- );
504
- });
505
-
506
- it("requires a valid signature when a webhook secret is configured", async () => {
507
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
508
- const response = await routeHandler(
509
- githubChannel({
510
- credentials: { webhookSecret: "secret" },
511
- })
512
- )(
513
- new Request("http://127.0.0.1:3000/v1/channels/github", {
514
- method: "POST",
515
- headers: { "x-github-event": "pull_request" },
516
- body: JSON.stringify(pullRequestPayload()),
517
- }),
518
- handlerArgs(send)
519
- );
520
-
521
- expect(response.status).toBe(401);
522
- await expect(response.json()).resolves.toEqual({
523
- ok: false,
524
- error: "missing_signature",
525
- });
526
- expect(send).not.toHaveBeenCalled();
527
- });
528
-
529
- it("returns 202 and schedules waitUntil for task dispatch", async () => {
530
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
531
- const waitUntil = vi.fn();
532
- const task = vi.fn(async () => {});
533
- const response = await routeHandler(
534
- githubChannel({
535
- auth: [],
536
- onPullRequest: async () => ({ task }),
537
- })
538
- )(
539
- new Request("http://127.0.0.1:3000/v1/channels/github", {
540
- method: "POST",
541
- headers: { "x-github-event": "pull_request" },
542
- body: JSON.stringify(pullRequestPayload()),
543
- }),
544
- { ...handlerArgs(send), waitUntil }
545
- );
546
-
547
- expect(response.status).toBe(202);
548
- await expect(response.json()).resolves.toEqual({
549
- ok: true,
550
- dispatched: true,
551
- mode: "task",
552
- action: "opened",
553
- prUrl: "https://github.com/acme/widgets/pull/42",
554
- headSha: "abc123",
555
- });
556
- expect(waitUntil).toHaveBeenCalledTimes(1);
557
- expect(task).not.toHaveBeenCalled();
558
- expect(send).not.toHaveBeenCalled();
559
-
560
- const scheduled = waitUntil.mock.calls[0]?.[0] as Promise<unknown>;
561
- await scheduled;
562
- expect(task).toHaveBeenCalledTimes(1);
563
- });
564
-
565
- it("exposes ctx.github and ctx.thread to inbound hooks", async () => {
566
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
567
- let captured: GitHubEventContext | undefined;
568
- await routeHandler(
569
- githubChannel({
570
- auth: [],
571
- onPullRequest: (ctx, pr) => {
572
- captured = ctx;
573
- return pr.action === "opened"
574
- ? { auth: defaultGitHubAuth(ctx) }
575
- : null;
576
- },
577
- })
578
- )(
579
- new Request("http://127.0.0.1:3000/v1/channels/github", {
580
- method: "POST",
581
- headers: { "x-github-event": "pull_request" },
582
- body: JSON.stringify(pullRequestPayload()),
583
- }),
584
- handlerArgs(send)
585
- );
586
-
587
- expect(captured).toBeDefined();
588
- expect(typeof captured?.github.request).toBe("function");
589
- expect(typeof captured?.github.createStatus).toBe("function");
590
- expect(typeof captured?.github.getOctokit).toBe("function");
591
- expect(typeof captured?.thread.post).toBe("function");
592
- expect(captured?.thread.kind).toBe("pull_request");
593
- expect(captured?.github.repository.fullName).toBe("acme/widgets");
594
- });
595
-
596
- it("runs onStatus task dispatch with ctx.github.createStatus", async () => {
597
- clearGitHubAuthCaches();
598
- const fetchMock = vi.fn(
599
- async () => new Response(JSON.stringify({}), { status: 201 })
600
- );
601
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
602
- const waitUntil = vi.fn();
603
- const response = await routeHandler(
604
- githubChannel({
605
- auth: [],
606
- credentials: { token: "test-token" },
607
- api: { fetch: fetchMock as unknown as typeof fetch },
608
- onStatus: (ctx, status) =>
609
- status.state === "failure"
610
- ? {
611
- task: async () => {
612
- await ctx.github.createStatus({
613
- sha: status.sha,
614
- state: "pending",
615
- context: "agent/triage",
616
- });
617
- },
618
- }
619
- : null,
620
- })
621
- )(
622
- new Request("http://127.0.0.1:3000/v1/channels/github", {
623
- method: "POST",
624
- headers: { "x-github-event": "status" },
625
- body: JSON.stringify(statusPayload()),
626
- }),
627
- { ...handlerArgs(send), waitUntil }
628
- );
629
-
630
- expect(response.status).toBe(202);
631
- await expect(response.json()).resolves.toMatchObject({
632
- ok: true,
633
- dispatched: true,
634
- mode: "task",
635
- event: "status",
636
- state: "failure",
637
- sha: "deadbeef",
638
- });
639
- expect(send).not.toHaveBeenCalled();
640
-
641
- const scheduled = waitUntil.mock.calls[0]?.[0] as Promise<unknown>;
642
- await scheduled;
643
- expect(fetchMock).toHaveBeenCalledOnce();
644
- const call = fetchMock.mock.calls[0];
645
- expect(call).toBeDefined();
646
- const [url, init] = call as unknown as [unknown, RequestInit | undefined];
647
- expect(String(url)).toContain("/repos/acme/widgets/statuses/deadbeef");
648
- expect(init?.method).toBe("POST");
649
- });
650
-
651
- it("dispatches unknown events through onEvent", async () => {
652
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
653
- let capturedEvent: GitHubRawEvent | undefined;
654
- const response = await routeHandler(
655
- githubChannel({
656
- auth: [],
657
- onEvent: (ctx, event) => {
658
- capturedEvent = event;
659
- return event.eventName === "label"
660
- ? { auth: defaultGitHubAuth(ctx) }
661
- : null;
662
- },
663
- })
664
- )(
665
- new Request("http://127.0.0.1:3000/v1/channels/github", {
666
- method: "POST",
667
- headers: {
668
- "x-github-event": "label",
669
- "x-github-delivery": "delivery-label",
670
- },
671
- body: JSON.stringify(labelPayload()),
672
- }),
673
- handlerArgs(send)
674
- );
675
-
676
- await expect(response.json()).resolves.toMatchObject({ ok: true });
677
- expect(capturedEvent?.eventName).toBe("label");
678
- expect(capturedEvent?.action).toBe("created");
679
- expect(send).toHaveBeenCalledExactlyOnceWith(
680
- expect.stringContaining("GitHub label event"),
681
- expect.objectContaining({
682
- continuationToken: "github-issue:acme/widgets#42",
683
- })
684
- );
685
- });
686
-
687
- it("schedules task dispatch for unanchored check_suite events", async () => {
688
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
689
- const waitUntil = vi.fn();
690
- const task = vi.fn(async () => {});
691
- const response = await routeHandler(
692
- githubChannel({
693
- auth: [],
694
- onCheckSuite: async () => ({ task }),
695
- })
696
- )(
697
- new Request("http://127.0.0.1:3000/v1/channels/github", {
698
- method: "POST",
699
- headers: { "x-github-event": "check_suite" },
700
- body: JSON.stringify({
701
- ...checkSuitePayload(),
702
- check_suite: {
703
- ...(checkSuitePayload().check_suite as Record<string, unknown>),
704
- pull_requests: [],
705
- },
706
- }),
707
- }),
708
- { ...handlerArgs(send), waitUntil }
709
- );
710
-
711
- expect(response.status).toBe(202);
712
- await expect(response.json()).resolves.toMatchObject({
713
- ok: true,
714
- dispatched: true,
715
- mode: "task",
716
- event: "check_suite",
717
- });
718
- expect(send).not.toHaveBeenCalled();
719
- const scheduled = waitUntil.mock.calls[0]?.[0] as Promise<unknown>;
720
- await scheduled;
721
- expect(task).toHaveBeenCalledTimes(1);
722
- });
723
-
724
- it("ignores outbound comments stamped with the agent marker", async () => {
725
- const send = vi.fn<SendMessageFn>(async () => fakeSession());
726
- const response = await routeHandler(
727
- githubChannel({
728
- auth: [],
729
- botName: "my-agent",
730
- })
731
- )(
732
- new Request("http://127.0.0.1:3000/v1/channels/github", {
733
- method: "POST",
734
- headers: { "x-github-event": "issue_comment" },
735
- body: JSON.stringify(
736
- issueCommentPayload(
737
- formatGitHubOutboundComment("Thanks @my-agent for the help!")
738
- )
739
- ),
740
- }),
741
- handlerArgs(send)
742
- );
743
-
744
- await expect(response.json()).resolves.toEqual({
745
- ok: true,
746
- skipped: true,
747
- reason: "ignored_comment",
748
- });
749
- expect(send).not.toHaveBeenCalled();
750
- });
751
- });
752
-
753
- function routeHandler(
754
- channel: ReturnType<typeof githubChannel>
755
- ): ChannelRouteHandler {
756
- const route = channel.routes?.[0];
757
- if (route === undefined) {
758
- throw new Error("expected github channel route");
759
- }
760
- return route.handler;
761
- }
762
-
763
- function handlerArgs(send: SendMessageFn): ChannelHandlerArgs {
764
- return {
765
- params: {},
766
- requestIp: "127.0.0.1",
767
- auth: null,
768
- host: {
769
- mcp: {
770
- names: () => [],
771
- listTools: async () => [],
772
- callTool: async () => ({ content: [] }),
773
- },
774
- github: {
775
- getOctokit: async () => {
776
- throw new Error("github client not configured in test");
777
- },
778
- },
779
- slack: {
780
- getClient: async () => {
781
- throw new Error("slack client not configured in test");
782
- },
783
- },
784
- kv: {
785
- get: async () => undefined,
786
- put: async () => {},
787
- delete: async () => {},
788
- },
789
- },
790
- artifacts: {
791
- tag: async () => {
792
- throw new Error("artifacts not configured in test");
793
- },
794
- list: async () => [],
795
- },
796
- send,
797
- getSession: async () => null,
798
- receive: async () => fakeSession(),
799
- callTool: async (toolName) => ({
800
- toolName,
801
- callId: "call-1",
802
- isError: false,
803
- result: null,
804
- durationMs: 0,
805
- }),
806
- waitUntil: () => {},
807
- sessionUrls: (_request, sessionId) => ({
808
- playgroundUrl: `http://127.0.0.1:3000/playground?sessionId=${sessionId}`,
809
- traceUrl: `http://127.0.0.1:3000/v1/session/${sessionId}/events`,
810
- }),
811
- };
812
- }
813
-
814
- function fakeSession(): ChannelSession {
815
- return {
816
- id: "session-1",
817
- isNew: true,
818
- continuationToken: "github-pr:acme/widgets#42",
819
- info: {
820
- id: "session-1",
821
- channelId: "github",
822
- mode: "chat",
823
- auth: null,
824
- sdkAgentId: undefined,
825
- title: "GitHub acme/widgets#42",
826
- },
827
- getEventStream: async () => new ReadableStream<Uint8Array>(),
828
- waitForCompletion: async () => ({ status: "finished", result: "done" }),
829
- setContinuationToken: async () => {},
830
- };
831
- }
832
-
833
- function pullRequestPayload(
834
- overrides: { action?: string } = {}
835
- ): Record<string, unknown> {
836
- return {
837
- action: overrides.action ?? "opened",
838
- repository: {
839
- full_name: "acme/widgets",
840
- html_url: "https://github.com/acme/widgets",
841
- },
842
- pull_request: {
843
- number: 42,
844
- html_url: "https://github.com/acme/widgets/pull/42",
845
- title: "Add widgets",
846
- body: "PR body",
847
- draft: false,
848
- user: { login: "octocat" },
849
- head: {
850
- ref: "feature/widgets",
851
- sha: "abc123",
852
- },
853
- base: {
854
- ref: "main",
855
- },
856
- },
857
- sender: { login: "sender" },
858
- };
859
- }
860
-
861
- function issueCommentPayload(body: string): Record<string, unknown> {
862
- return {
863
- action: "created",
864
- repository: {
865
- full_name: "acme/widgets",
866
- html_url: "https://github.com/acme/widgets",
867
- },
868
- issue: {
869
- number: 42,
870
- html_url: "https://github.com/acme/widgets/pull/42",
871
- pull_request: {},
872
- },
873
- comment: {
874
- id: 7,
875
- body,
876
- html_url: "https://github.com/acme/widgets/pull/42#issuecomment-7",
877
- url: "https://api.github.com/repos/acme/widgets/issues/comments/7",
878
- user: { login: "sender", type: "User" },
879
- },
880
- sender: { login: "sender", type: "User" },
881
- };
882
- }
883
-
884
- function statusPayload(): Record<string, unknown> {
885
- return {
886
- state: "failure",
887
- sha: "deadbeef",
888
- context: "ci/build",
889
- description: "Build failed",
890
- target_url: "https://ci.example.com/build/1",
891
- name: "acme/widgets",
892
- branches: [{ name: "main", commit: { sha: "deadbeef" } }],
893
- commit: {
894
- sha: "deadbeef",
895
- html_url: "https://github.com/acme/widgets/commit/deadbeef",
896
- },
897
- repository: {
898
- full_name: "acme/widgets",
899
- html_url: "https://github.com/acme/widgets",
900
- },
901
- sender: { login: "ci-bot", type: "Bot" },
902
- };
903
- }
904
-
905
- function labelPayload(): Record<string, unknown> {
906
- return {
907
- action: "created",
908
- label: { name: "bug", color: "ff0000" },
909
- repository: {
910
- full_name: "acme/widgets",
911
- html_url: "https://github.com/acme/widgets",
912
- },
913
- issue: {
914
- number: 42,
915
- html_url: "https://github.com/acme/widgets/issues/42",
916
- },
917
- sender: { login: "sender", type: "User" },
918
- };
919
- }
920
-
921
- function checkSuitePayload(): Record<string, unknown> {
922
- return {
923
- action: "completed",
924
- repository: {
925
- full_name: "acme/widgets",
926
- html_url: "https://github.com/acme/widgets",
927
- },
928
- check_suite: {
929
- id: 99,
930
- head_sha: "deadbeef",
931
- status: "completed",
932
- conclusion: "failure",
933
- app: { slug: "github-actions", name: "GitHub Actions" },
934
- pull_requests: [
935
- {
936
- number: 42,
937
- html_url: "https://github.com/acme/widgets/pull/42",
938
- },
939
- ],
940
- },
941
- sender: { login: "github-actions[bot]", type: "Bot" },
942
- };
943
- }