typeclaw 0.48.13 → 0.49.0

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 (176) hide show
  1. package/package.json +5 -5
  2. package/scripts/dump-system-prompt.ts +52 -110
  3. package/src/agent/index.ts +144 -72
  4. package/src/agent/live-sessions.ts +2 -2
  5. package/src/agent/live-subagents.ts +1 -0
  6. package/src/agent/plugin-tools.ts +53 -11
  7. package/src/agent/prompt-cache-key.ts +42 -0
  8. package/src/agent/provider-error.ts +179 -10
  9. package/src/agent/restart-handoff/index.ts +7 -14
  10. package/src/agent/reviewer-activity.ts +68 -0
  11. package/src/agent/session-origin.ts +33 -0
  12. package/src/agent/subagents.ts +13 -1
  13. package/src/agent/system-prompt.ts +68 -202
  14. package/src/agent/todo/continuation-policy.ts +12 -4
  15. package/src/agent/tool-file-safety.ts +113 -14
  16. package/src/agent/tool-not-found-nudge.ts +1 -1
  17. package/src/agent/tools/channel-history-render.ts +2 -1
  18. package/src/agent/tools/channel-reply.ts +23 -5
  19. package/src/agent/tools/channel-send.ts +49 -7
  20. package/src/agent/tools/curl-impersonate.ts +11 -2
  21. package/src/agent/tools/post-github-review.ts +77 -15
  22. package/src/agent/tools/skip-response.ts +2 -2
  23. package/src/agent/tools/spawn-subagent.ts +163 -12
  24. package/src/agent/tools/subagent-output.ts +8 -0
  25. package/src/bundled-plugins/backup/README.md +10 -9
  26. package/src/bundled-plugins/backup/runner.ts +140 -58
  27. package/src/bundled-plugins/backup/subagents.ts +58 -26
  28. package/src/bundled-plugins/github-cli-auth/gh-command.ts +34 -2
  29. package/src/bundled-plugins/github-cli-auth/granted-push.ts +135 -0
  30. package/src/bundled-plugins/github-cli-auth/index.ts +83 -11
  31. package/src/bundled-plugins/github-cli-auth/review-account.ts +23 -0
  32. package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -2
  33. package/src/bundled-plugins/github-cli-auth/review-recorder.ts +45 -7
  34. package/src/bundled-plugins/operator/operator.ts +15 -4
  35. package/src/bundled-plugins/reviewer/skills/code-review.ts +1 -1
  36. package/src/bundled-plugins/security/index.ts +50 -2
  37. package/src/bundled-plugins/security/policies/git-exfil.ts +24 -12
  38. package/src/channels/adapters/discord-bot-reactions.ts +18 -0
  39. package/src/channels/adapters/discord-bot.ts +122 -67
  40. package/src/channels/adapters/discord-reactions.ts +18 -0
  41. package/src/channels/adapters/discord.ts +114 -8
  42. package/src/channels/adapters/github/inbound.ts +103 -8
  43. package/src/channels/adapters/github/index.ts +251 -19
  44. package/src/channels/adapters/github/last-alive.ts +27 -0
  45. package/src/channels/adapters/github/outbound.ts +54 -18
  46. package/src/channels/adapters/github/pending-review-store.ts +141 -0
  47. package/src/channels/adapters/github/permission-guidance.ts +1 -0
  48. package/src/channels/adapters/github/reactions.ts +100 -0
  49. package/src/channels/adapters/github/reconcile-cooldown-store.ts +197 -67
  50. package/src/channels/adapters/github/reconcile-open-prs.ts +418 -33
  51. package/src/channels/adapters/github/recovery.ts +106 -0
  52. package/src/channels/adapters/github/review-check.ts +510 -0
  53. package/src/channels/adapters/github/review-submitter.ts +34 -2
  54. package/src/channels/adapters/instagram.ts +32 -14
  55. package/src/channels/adapters/kakaotalk.ts +22 -7
  56. package/src/channels/adapters/line.ts +18 -3
  57. package/src/channels/adapters/outbound-account.ts +20 -0
  58. package/src/channels/adapters/own-reactions.ts +66 -0
  59. package/src/channels/adapters/recovery-correlation.ts +214 -0
  60. package/src/channels/adapters/slack-bot-classify.ts +18 -11
  61. package/src/channels/adapters/slack-bot-dedupe.ts +111 -28
  62. package/src/channels/adapters/slack-bot-reactions.ts +18 -0
  63. package/src/channels/adapters/slack-bot.ts +125 -57
  64. package/src/channels/adapters/slack-classify.ts +25 -4
  65. package/src/channels/adapters/slack-inbound-revision.ts +96 -0
  66. package/src/channels/adapters/slack-reactions.ts +18 -0
  67. package/src/channels/adapters/slack-thread-ts.ts +6 -0
  68. package/src/channels/adapters/slack.ts +48 -3
  69. package/src/channels/adapters/teams.ts +14 -4
  70. package/src/channels/adapters/telegram-bot.ts +56 -10
  71. package/src/channels/adapters/webex-bot.ts +12 -2
  72. package/src/channels/adapters/webex.ts +12 -2
  73. package/src/channels/background-handoff.ts +434 -0
  74. package/src/channels/background-obligations.ts +893 -0
  75. package/src/channels/continuity-types.ts +271 -0
  76. package/src/channels/github-review-check.ts +598 -0
  77. package/src/channels/github-review-turn-ledger.ts +102 -28
  78. package/src/channels/github-review-verdict-coordinator.ts +72 -12
  79. package/src/channels/github-token-bridge.ts +11 -5
  80. package/src/channels/inbound-journal.ts +1738 -0
  81. package/src/channels/index.ts +6 -1
  82. package/src/channels/manager.ts +17 -7
  83. package/src/channels/recovery-dispatcher.ts +264 -0
  84. package/src/channels/recovery-notice.ts +94 -0
  85. package/src/channels/recovery-outbox.ts +459 -0
  86. package/src/channels/router.ts +2539 -615
  87. package/src/channels/schema.ts +8 -1
  88. package/src/channels/subagent-completion-bridge.ts +17 -14
  89. package/src/channels/types.ts +121 -16
  90. package/src/channels/waiting-reactions.ts +664 -0
  91. package/src/cli/compose.ts +7 -4
  92. package/src/cli/hostd.ts +49 -3
  93. package/src/cli/inspect.ts +11 -14
  94. package/src/coding-agent/broker-body.ts +38 -0
  95. package/src/coding-agent/broker.ts +290 -0
  96. package/src/coding-agent/claude.ts +95 -0
  97. package/src/coding-agent/codex.ts +104 -0
  98. package/src/coding-agent/index.ts +506 -0
  99. package/src/coding-agent/omo-state.ts +69 -0
  100. package/src/coding-agent/omo-stream.ts +98 -0
  101. package/src/coding-agent/omo.ts +192 -0
  102. package/src/coding-agent/runner.ts +263 -0
  103. package/src/coding-agent/tool.ts +62 -0
  104. package/src/coding-agent/worktree.ts +355 -0
  105. package/src/compose/restart.ts +10 -3
  106. package/src/compose/start.ts +20 -3
  107. package/src/config/config.ts +10 -3
  108. package/src/config/providers.ts +12 -9
  109. package/src/container/exit-reason.ts +44 -0
  110. package/src/container/index.ts +5 -0
  111. package/src/container/log-archive.ts +51 -13
  112. package/src/container/memory-limit.ts +1 -1
  113. package/src/container/memory-oversubscription.ts +36 -6
  114. package/src/container/oom-events.ts +86 -0
  115. package/src/container/restart.ts +2 -0
  116. package/src/container/shared.ts +8 -1
  117. package/src/container/start.ts +25 -13
  118. package/src/container/stop.ts +6 -2
  119. package/src/container/tool-oom-priority.ts +32 -0
  120. package/src/cron/consumer.ts +10 -4
  121. package/src/cron/reloadable.ts +23 -2
  122. package/src/doctor/checks.ts +14 -2
  123. package/src/hostd/daemon.ts +20 -10
  124. package/src/hostd/spawn.ts +106 -5
  125. package/src/hostd/version.ts +20 -0
  126. package/src/hostd/watchdog.ts +241 -0
  127. package/src/init/dockerfile.ts +57 -592
  128. package/src/init/index.ts +2 -3
  129. package/src/mcp/client.ts +3 -1
  130. package/src/operations/classify-tool-outcome.ts +45 -1
  131. package/src/operations/incidents.ts +10 -5
  132. package/src/plugin/core-tool-names.ts +1 -1
  133. package/src/plugin/define.ts +1 -0
  134. package/src/plugin/index.ts +1 -0
  135. package/src/plugin/types.ts +6 -1
  136. package/src/run/background-handoff-boot.ts +86 -0
  137. package/src/run/index.ts +83 -83
  138. package/src/run/resource-sample.ts +19 -0
  139. package/src/sandbox/build.ts +4 -0
  140. package/src/sandbox/coding-agent.ts +214 -0
  141. package/src/sandbox/policy.ts +1 -0
  142. package/src/sandbox/runtime-private.ts +4 -1
  143. package/src/secrets/coding-agent-auth.ts +97 -0
  144. package/src/secrets/index.ts +0 -16
  145. package/src/server/command-runner.ts +6 -2
  146. package/src/server/index.ts +101 -40
  147. package/src/skills/typeclaw-channel-github/SKILL.md +7 -5
  148. package/src/skills/typeclaw-claude-code/SKILL.md +25 -260
  149. package/src/skills/typeclaw-claude-code/references/auth-flow.md +7 -23
  150. package/src/skills/typeclaw-claude-code/references/headless-sessions.md +11 -0
  151. package/src/skills/typeclaw-claude-code/references/results-and-worktrees.md +13 -0
  152. package/src/skills/typeclaw-codex-cli/SKILL.md +35 -270
  153. package/src/skills/typeclaw-codex-cli/references/auth-flow.md +13 -20
  154. package/src/skills/typeclaw-codex-cli/references/headless-sessions.md +26 -0
  155. package/src/skills/typeclaw-codex-cli/references/results-and-worktrees.md +28 -0
  156. package/src/skills/typeclaw-config/SKILL.md +21 -21
  157. package/src/skills/typeclaw-config/references/dockerfile.md +14 -13
  158. package/src/skills/typeclaw-cron/SKILL.md +1 -1
  159. package/src/skills/typeclaw-github-contributing/SKILL.md +2 -2
  160. package/src/skills/typeclaw-memory/SKILL.md +3 -3
  161. package/src/skills/typeclaw-omo-cli/SKILL.md +52 -0
  162. package/src/skills/typeclaw-omo-cli/references/auth-flow.md +11 -0
  163. package/src/skills/typeclaw-omo-cli/references/headless-sessions.md +11 -0
  164. package/src/skills/typeclaw-omo-cli/references/results-and-worktrees.md +23 -0
  165. package/src/skills/typeclaw-plugins/SKILL.md +15 -15
  166. package/src/skills/typeclaw-skills/SKILL.md +19 -2
  167. package/src/skills/typeclaw-troubleshooting/SKILL.md +15 -2
  168. package/typeclaw.schema.json +12 -1
  169. package/src/secrets/claude-credentials-json.ts +0 -129
  170. package/src/secrets/codex-auth-json.ts +0 -102
  171. package/src/secrets/export-claude-credentials-file.ts +0 -270
  172. package/src/secrets/export-codex-auth-file.ts +0 -250
  173. package/src/skills/typeclaw-claude-code/references/stop-hook.md +0 -101
  174. package/src/skills/typeclaw-claude-code/references/tmux-driving.md +0 -243
  175. package/src/skills/typeclaw-codex-cli/references/stop-hook.md +0 -92
  176. package/src/skills/typeclaw-codex-cli/references/tmux-driving.md +0 -239
@@ -1,8 +1,14 @@
1
1
  import { createHmac, randomUUID, timingSafeEqual } from 'node:crypto'
2
2
 
3
+ import { githubReviewChecks } from '@/channels/github-review-check'
3
4
  import { registerOrJoinReplyReviewRound } from '@/channels/github-review-verdict-coordinator'
4
5
  import type { GithubReviewOn } from '@/channels/schema'
5
- import type { GithubReviewFollowupRound, GithubReviewThreadCloseout, InboundMessage } from '@/channels/types'
6
+ import type {
7
+ GithubReviewFollowupRound,
8
+ GithubReviewThreadCloseout,
9
+ InboundMessage,
10
+ RouteReceipt,
11
+ } from '@/channels/types'
6
12
 
7
13
  import { describeError } from '../../describe-error'
8
14
  import type { GithubAuthContext } from './auth'
@@ -38,7 +44,7 @@ export type GithubWebhookHandlerOptions = {
38
44
  // eventAllowlist (the outer "process this webhook?" gate) — this is the inner
39
45
  // "does an admitted pull_request event become a review-trigger inbound?" gate.
40
46
  reviewOn?: () => GithubReviewOn
41
- route: (message: InboundMessage) => void
47
+ route: (message: InboundMessage) => Promise<RouteReceipt>
42
48
  logger: GithubInboundLogger
43
49
  // Optional: resolves whether the bot is a member of the given team. When
44
50
  // omitted, team-reviewer requests are silently dropped (the v1 fallback
@@ -63,6 +69,8 @@ export type GithubWebhookHandlerOptions = {
63
69
  | { kind: 'no-live-session' }
64
70
  >
65
71
  clearReconcileCooldown?: (workspace: string, prId: number) => Promise<'cleared' | 'not-initialized'>
72
+ clearPendingReview?: (workspace: string, prNumber: number) => Promise<void>
73
+ reviewSubmitted?: (review: { repo: string; prNumber: number; headSha: string; submittedAt: number }) => Promise<void>
66
74
  }
67
75
 
68
76
  export const GITHUB_REVIEW_STATE_UNKNOWN_TTL_MS = 2 * 60_000
@@ -107,6 +115,31 @@ export async function processVerifiedGithubDelivery(
107
115
  ): Promise<void> {
108
116
  const { event, delivery, payload } = input
109
117
  const action = readString(payload, 'action')
118
+ // Completion bookkeeping is independent of the conversational event allowlist.
119
+ // In particular, self-authored reviews are deliberately never routed.
120
+ const repository = readRepository(payload)
121
+ const pr = readRecord(payload.pull_request)
122
+ const prNumber = readNumber(pr, 'number')
123
+ if (repository !== null && prNumber !== null) {
124
+ const repo = `${repository.owner}/${repository.name}`
125
+ if (event === 'pull_request' && action === 'closed') {
126
+ await options.clearPendingReview?.(repo, prNumber)
127
+ }
128
+ if (event === 'pull_request_review' && action === 'submitted') {
129
+ const review = readRecord(payload.review)
130
+ const reviewer = readUser(review?.user)
131
+ const headSha = readString(review, 'commit_id')
132
+ const submittedAt = Date.parse(readString(review, 'submitted_at') ?? '')
133
+ if (
134
+ reviewer !== null &&
135
+ isSelfAuthor(reviewer, options.selfId(), options.selfLogin()) &&
136
+ headSha !== null &&
137
+ Number.isFinite(submittedAt)
138
+ ) {
139
+ await options.reviewSubmitted?.({ repo, prNumber, headSha, submittedAt })
140
+ }
141
+ }
142
+ }
110
143
  const eventAllowed = isGithubEventAllowed(options.allowlist(), event, action)
111
144
  let staleRecoveredDraft = false
112
145
  if (input.recovered === true && eventAllowed && event === 'pull_request' && action === 'converted_to_draft') {
@@ -153,7 +186,9 @@ export async function processVerifiedGithubDelivery(
153
186
  return
154
187
  }
155
188
  const workspace = `${repository.owner}/${repository.name}`
189
+ await options.clearPendingReview?.(workspace, prNumber)
156
190
  invalidateGithubReviewSubmission(workspace, prNumber)
191
+ void githubReviewChecks.cancelPullRequest(workspace, prNumber, 'the pull request was converted to draft')
157
192
  scheduleDraftAbort({ workspace, prNumber, prId: readNumber(pr, 'id'), options })
158
193
  return
159
194
  }
@@ -178,7 +213,7 @@ export async function processVerifiedGithubDelivery(
178
213
  // session when an obligation is outstanding. Returning here also keeps
179
214
  // synchronize out of the generic awareness-only fallthrough below.
180
215
  if (isSynchronize) {
181
- scheduleReviewFollowup({ payload, selfLogin, options })
216
+ scheduleReviewFollowup({ payload, selfId, selfLogin, options })
182
217
  return
183
218
  }
184
219
 
@@ -192,6 +227,12 @@ export async function processVerifiedGithubDelivery(
192
227
  ...(reviewCommentParent !== null ? { reviewCommentParent } : {}),
193
228
  })
194
229
  if (classified === null) return
230
+ if (event === 'pull_request' && action === 'review_request_removed') {
231
+ const prNumber = readNumber(readRecord(payload.pull_request), 'number')
232
+ if (prNumber !== null) {
233
+ void githubReviewChecks.cancelPullRequest(classified.workspace, prNumber, 'the review request was removed')
234
+ }
235
+ }
195
236
 
196
237
  const routed =
197
238
  replyReviewRound?.kind === 'round'
@@ -206,7 +247,23 @@ export async function processVerifiedGithubDelivery(
206
247
  }
207
248
  : classified
208
249
 
209
- options.route(withApprovalPolicy(routed, options.allowApprove?.() ?? true))
250
+ // GitHub transport acknowledgment is not a durable admission receipt.
251
+ void Promise.resolve()
252
+ .then(() =>
253
+ options.route(
254
+ withApprovalPolicy(
255
+ {
256
+ ...routed,
257
+ receiptId: delivery,
258
+ accountIdentity: selfId === null ? undefined : `github:${selfId}`,
259
+ },
260
+ options.allowApprove?.() ?? true,
261
+ ),
262
+ ),
263
+ )
264
+ .catch((error: unknown) => {
265
+ options.logger.error(`[github] route failed: ${describeError(error)}`)
266
+ })
210
267
  }
211
268
 
212
269
  export const PR_APPROVAL_DISABLED_NOTE =
@@ -433,10 +490,11 @@ function reviewFollowupDedup(options: GithubWebhookHandlerOptions): ReviewFollow
433
490
 
434
491
  function scheduleReviewFollowup(input: {
435
492
  payload: Record<string, unknown>
493
+ selfId: string | null
436
494
  selfLogin: string | null
437
495
  options: GithubWebhookHandlerOptions
438
496
  }): void {
439
- const { payload, selfLogin, options } = input
497
+ const { payload, selfId, selfLogin, options } = input
440
498
  if (selfLogin === null) return
441
499
  const authToken = options.authToken
442
500
  if (authToken === undefined) return
@@ -511,16 +569,18 @@ function scheduleReviewFollowup(input: {
511
569
  if (threads.threads.length === 0) {
512
570
  if (selfBlocking) {
513
571
  const round = buildReviewRound(repository, pullNumber, headSha, null, generateReviewRoundId)
514
- options.route(
572
+ await options.route(
515
573
  withApprovalPolicy(
516
574
  buildReviewFollowupInbound({
517
575
  repository,
518
576
  pullNumber,
519
577
  headSha,
578
+ prId: readNumber(pr, 'id') ?? pullNumber,
520
579
  thread: null,
521
580
  selfBlocking: true,
522
581
  round,
523
582
  title: readString(pr, 'title'),
583
+ accountIdentity: selfId === null ? undefined : `github:${selfId}`,
524
584
  }),
525
585
  options.allowApprove?.() ?? true,
526
586
  true,
@@ -545,16 +605,18 @@ function scheduleReviewFollowup(input: {
545
605
  // sibling PR session by injectPrVerdictActivity, while asking all of them
546
606
  // to submit it would recreate a cross-session verdict race.
547
607
  const carriesBlockingObligation = selfBlocking && index === 0
548
- options.route(
608
+ await options.route(
549
609
  withApprovalPolicy(
550
610
  buildReviewFollowupInbound({
551
611
  repository,
552
612
  pullNumber,
553
613
  headSha,
614
+ prId: readNumber(pr, 'id') ?? pullNumber,
554
615
  thread,
555
616
  selfBlocking: carriesBlockingObligation,
556
617
  ...(round !== undefined ? { round } : {}),
557
618
  title: readString(pr, 'title'),
619
+ accountIdentity: selfId === null ? undefined : `github:${selfId}`,
558
620
  }),
559
621
  options.allowApprove?.() ?? true,
560
622
  carriesBlockingObligation,
@@ -593,10 +655,12 @@ function buildReviewFollowupInbound(input: {
593
655
  repository: { owner: string; name: string }
594
656
  pullNumber: number
595
657
  headSha: string
658
+ prId: number
596
659
  thread: UnresolvedSelfReviewThread | null
597
660
  selfBlocking: boolean
598
661
  round?: GithubReviewFollowupRound
599
662
  title: string | null
663
+ accountIdentity?: string
600
664
  }): InboundMessage {
601
665
  const { repository, pullNumber, headSha, thread, selfBlocking, round, title } = input
602
666
  const titleSegment = title !== null && title.trim() !== '' ? `: "${title}"` : ''
@@ -610,8 +674,14 @@ function buildReviewFollowupInbound(input: {
610
674
  chat: `pr:${pullNumber}`,
611
675
  thread: thread === null ? null : String(thread.rootCommentId),
612
676
  ...(round !== undefined ? { githubReviewRound: round } : {}),
677
+ ...(selfBlocking ? { githubPendingReview: { prId: input.prId, headSha, kind: 'rereview' as const } } : {}),
613
678
  text,
614
679
  externalMessageId: `pr-${pullNumber}-recheck-${headSha}${thread === null ? '' : `-thread-${thread.rootCommentId}`}`,
680
+ eventKind: 'pull_request:synchronize:review-followup',
681
+ // Verdict coordination round IDs are attempt-local. Durable admission uses
682
+ // the platform head revision, stable across partial retries and redelivery.
683
+ revision: headSha,
684
+ accountIdentity: input.accountIdentity,
615
685
  authorId: 'github-system',
616
686
  authorName: 'github',
617
687
  authorIsBot: false,
@@ -641,7 +711,7 @@ function buildReviewRound(
641
711
  }
642
712
  }
643
713
 
644
- function followupInstruction(thread: UnresolvedSelfReviewThread | null, selfBlocking: boolean): string {
714
+ export function followupInstruction(thread: UnresolvedSelfReviewThread | null, selfBlocking: boolean): string {
645
715
  const threadPart =
646
716
  thread !== null
647
717
  ? `This session is scoped to one unresolved review thread you authored. Check whether the new commits ` +
@@ -679,6 +749,22 @@ export async function verifySignature(body: string, secret: string, sigHeader: s
679
749
  return timingSafeEqual(a, b)
680
750
  }
681
751
 
752
+ function githubEventRevision(payload: Record<string, unknown>): string {
753
+ const subject =
754
+ readRecord(payload.comment) ??
755
+ readRecord(payload.review) ??
756
+ readRecord(payload.pull_request) ??
757
+ readRecord(payload.issue) ??
758
+ readRecord(payload.discussion)
759
+ const head = readRecord(readRecord(payload.pull_request)?.head)
760
+ const reviewer = readRecord(payload.requested_reviewer) ?? readRecord(payload.requested_team)
761
+ return JSON.stringify([
762
+ readString(subject, 'updated_at') ?? readString(subject, 'submitted_at') ?? readString(subject, 'created_at'),
763
+ readString(head, 'sha'),
764
+ readNumber(reviewer, 'id'),
765
+ ])
766
+ }
767
+
682
768
  export function classifyGithubInbound(
683
769
  event: string,
684
770
  payload: Record<string, unknown>,
@@ -696,6 +782,8 @@ export function classifyGithubInbound(
696
782
  const base = {
697
783
  adapter: 'github' as const,
698
784
  workspace: `${repository.owner}/${repository.name}`,
785
+ eventKind: `${event}:${readString(payload, 'action') ?? 'event'}`,
786
+ revision: githubEventRevision(payload),
699
787
  isDm: false,
700
788
  mentionsOthers: false,
701
789
  replyToOtherMessageId: null,
@@ -1073,6 +1161,7 @@ function classifyReviewRequest(input: ReviewRequestInput): InboundMessage | null
1073
1161
  thread: null,
1074
1162
  text,
1075
1163
  externalMessageId,
1164
+ ...(action === 'review_requested' ? pendingReviewMetadata(pr, prId) : {}),
1076
1165
  authorId: String(sender.id),
1077
1166
  authorName: sender.login,
1078
1167
  authorIsBot: sender.type === 'Bot',
@@ -1120,6 +1209,7 @@ function classifyOpenedReviewTrigger(input: OpenedReviewTriggerInput): InboundMe
1120
1209
  thread: null,
1121
1210
  text,
1122
1211
  externalMessageId,
1212
+ ...pendingReviewMetadata(pr, prId),
1123
1213
  authorId: String(sender.id),
1124
1214
  authorName: sender.login,
1125
1215
  authorIsBot: sender.type === 'Bot',
@@ -1129,6 +1219,11 @@ function classifyOpenedReviewTrigger(input: OpenedReviewTriggerInput): InboundMe
1129
1219
  }
1130
1220
  }
1131
1221
 
1222
+ function pendingReviewMetadata(pr: Record<string, unknown>, prId: number): Pick<InboundMessage, 'githubPendingReview'> {
1223
+ const headSha = readString(readRecord(pr.head), 'sha')
1224
+ return headSha === null ? {} : { githubPendingReview: { prId, headSha, kind: 'review' } }
1225
+ }
1226
+
1132
1227
  export type GithubReviewerTeam = { slug: string; id: number; org: string | null }
1133
1228
 
1134
1229
  export function readReviewerTeam(value: unknown): GithubReviewerTeam | null {