typeclaw 0.48.12 → 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.
- package/package.json +6 -3
- package/scripts/dump-system-prompt.ts +52 -110
- package/src/agent/attention-escalation.ts +8 -5
- package/src/agent/auth-reloadable.ts +2 -3
- package/src/agent/auth.ts +59 -79
- package/src/agent/compaction.ts +2 -2
- package/src/agent/index.ts +173 -85
- package/src/agent/live-sessions.ts +2 -2
- package/src/agent/live-subagents.ts +1 -0
- package/src/agent/llm-replay-sanitizer.ts +1 -1
- package/src/agent/model-overrides.ts +1 -1
- package/src/agent/multimodal/look-at.ts +3 -3
- package/src/agent/multimodal/read-redirect.ts +1 -1
- package/src/agent/plugin-tools.ts +76 -39
- package/src/agent/prompt-cache-key.ts +42 -0
- package/src/agent/provider-error.ts +179 -10
- package/src/agent/reload-tool.ts +1 -1
- package/src/agent/restart-handoff/index.ts +7 -14
- package/src/agent/reviewer-activity.ts +68 -0
- package/src/agent/session-origin.ts +33 -0
- package/src/agent/subagents.ts +14 -2
- package/src/agent/system-prompt.ts +68 -202
- package/src/agent/todo/continuation-policy.ts +12 -4
- package/src/agent/tool-error-remediation.ts +1 -1
- package/src/agent/tool-file-safety.ts +113 -14
- package/src/agent/tool-not-found-nudge.ts +1 -1
- package/src/agent/tool-result-budget.ts +2 -2
- package/src/agent/tools/channel-disengage.ts +2 -2
- package/src/agent/tools/channel-edit.ts +2 -2
- package/src/agent/tools/channel-fetch-attachment.ts +2 -2
- package/src/agent/tools/channel-history-render.ts +2 -1
- package/src/agent/tools/channel-history.ts +2 -2
- package/src/agent/tools/channel-react.ts +2 -2
- package/src/agent/tools/channel-read.ts +2 -2
- package/src/agent/tools/channel-reply.ts +25 -7
- package/src/agent/tools/channel-send.ts +51 -9
- package/src/agent/tools/curl-impersonate.ts +11 -2
- package/src/agent/tools/grant-role.ts +2 -2
- package/src/agent/tools/post-github-review.ts +79 -17
- package/src/agent/tools/restart.ts +2 -2
- package/src/agent/tools/skip-response.ts +4 -4
- package/src/agent/tools/spawn-subagent.ts +165 -14
- package/src/agent/tools/stream-snapshot.ts +2 -2
- package/src/agent/tools/subagent-cancel.ts +2 -2
- package/src/agent/tools/subagent-output.ts +10 -2
- package/src/agent/tools/todo/index.ts +2 -2
- package/src/agent/tools/webfetch/tool.ts +2 -2
- package/src/agent/tools/websearch.ts +2 -2
- package/src/bundled-plugins/backup/README.md +10 -9
- package/src/bundled-plugins/backup/runner.ts +140 -58
- package/src/bundled-plugins/backup/subagents.ts +58 -26
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +34 -2
- package/src/bundled-plugins/github-cli-auth/granted-push.ts +135 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +83 -11
- package/src/bundled-plugins/github-cli-auth/review-account.ts +23 -0
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -2
- package/src/bundled-plugins/github-cli-auth/review-recorder.ts +45 -7
- package/src/bundled-plugins/operator/operator.ts +15 -4
- package/src/bundled-plugins/reviewer/skills/code-review.ts +1 -1
- package/src/bundled-plugins/security/index.ts +50 -2
- package/src/bundled-plugins/security/policies/git-exfil.ts +24 -12
- package/src/channels/adapters/discord-bot-reactions.ts +18 -0
- package/src/channels/adapters/discord-bot.ts +122 -67
- package/src/channels/adapters/discord-reactions.ts +18 -0
- package/src/channels/adapters/discord.ts +114 -8
- package/src/channels/adapters/github/inbound.ts +103 -8
- package/src/channels/adapters/github/index.ts +251 -19
- package/src/channels/adapters/github/last-alive.ts +27 -0
- package/src/channels/adapters/github/outbound.ts +54 -18
- package/src/channels/adapters/github/pending-review-store.ts +141 -0
- package/src/channels/adapters/github/permission-guidance.ts +1 -0
- package/src/channels/adapters/github/reactions.ts +100 -0
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +197 -67
- package/src/channels/adapters/github/reconcile-open-prs.ts +418 -33
- package/src/channels/adapters/github/recovery.ts +106 -0
- package/src/channels/adapters/github/review-check.ts +510 -0
- package/src/channels/adapters/github/review-submitter.ts +34 -2
- package/src/channels/adapters/instagram.ts +32 -14
- package/src/channels/adapters/kakaotalk.ts +22 -7
- package/src/channels/adapters/line.ts +18 -3
- package/src/channels/adapters/outbound-account.ts +20 -0
- package/src/channels/adapters/own-reactions.ts +66 -0
- package/src/channels/adapters/recovery-correlation.ts +214 -0
- package/src/channels/adapters/slack-bot-classify.ts +18 -11
- package/src/channels/adapters/slack-bot-dedupe.ts +111 -28
- package/src/channels/adapters/slack-bot-reactions.ts +18 -0
- package/src/channels/adapters/slack-bot.ts +125 -57
- package/src/channels/adapters/slack-classify.ts +25 -4
- package/src/channels/adapters/slack-inbound-revision.ts +96 -0
- package/src/channels/adapters/slack-reactions.ts +18 -0
- package/src/channels/adapters/slack-thread-ts.ts +6 -0
- package/src/channels/adapters/slack.ts +48 -3
- package/src/channels/adapters/teams.ts +14 -4
- package/src/channels/adapters/telegram-bot.ts +56 -10
- package/src/channels/adapters/webex-bot.ts +12 -2
- package/src/channels/adapters/webex.ts +12 -2
- package/src/channels/background-handoff.ts +434 -0
- package/src/channels/background-obligations.ts +893 -0
- package/src/channels/continuity-types.ts +271 -0
- package/src/channels/github-review-check.ts +598 -0
- package/src/channels/github-review-turn-ledger.ts +102 -28
- package/src/channels/github-review-verdict-coordinator.ts +96 -13
- package/src/channels/github-token-bridge.ts +11 -5
- package/src/channels/inbound-journal.ts +1738 -0
- package/src/channels/index.ts +6 -1
- package/src/channels/manager.ts +17 -7
- package/src/channels/recovery-dispatcher.ts +264 -0
- package/src/channels/recovery-notice.ts +94 -0
- package/src/channels/recovery-outbox.ts +459 -0
- package/src/channels/router.ts +2582 -633
- package/src/channels/schema.ts +8 -1
- package/src/channels/subagent-completion-bridge.ts +17 -14
- package/src/channels/types.ts +121 -16
- package/src/channels/waiting-reactions.ts +664 -0
- package/src/cli/compose.ts +7 -4
- package/src/cli/hostd.ts +49 -3
- package/src/cli/inspect.ts +11 -14
- package/src/cli/model.ts +7 -5
- package/src/cli/oauth-callbacks.ts +38 -23
- package/src/coding-agent/broker-body.ts +38 -0
- package/src/coding-agent/broker.ts +290 -0
- package/src/coding-agent/claude.ts +95 -0
- package/src/coding-agent/codex.ts +104 -0
- package/src/coding-agent/index.ts +506 -0
- package/src/coding-agent/omo-state.ts +69 -0
- package/src/coding-agent/omo-stream.ts +98 -0
- package/src/coding-agent/omo.ts +192 -0
- package/src/coding-agent/runner.ts +263 -0
- package/src/coding-agent/tool.ts +62 -0
- package/src/coding-agent/worktree.ts +355 -0
- package/src/compose/restart.ts +10 -3
- package/src/compose/start.ts +20 -3
- package/src/config/config.ts +70 -26
- package/src/config/providers.ts +278 -50
- package/src/container/exit-reason.ts +44 -0
- package/src/container/index.ts +5 -0
- package/src/container/log-archive.ts +51 -13
- package/src/container/memory-limit.ts +1 -1
- package/src/container/memory-oversubscription.ts +36 -6
- package/src/container/oom-events.ts +86 -0
- package/src/container/restart.ts +2 -0
- package/src/container/shared.ts +8 -1
- package/src/container/start.ts +25 -13
- package/src/container/stop.ts +6 -2
- package/src/container/tool-oom-priority.ts +32 -0
- package/src/cron/consumer.ts +10 -4
- package/src/cron/reloadable.ts +23 -2
- package/src/doctor/checks.ts +14 -2
- package/src/hostd/daemon.ts +20 -10
- package/src/hostd/spawn.ts +106 -5
- package/src/hostd/version.ts +20 -0
- package/src/hostd/watchdog.ts +241 -0
- package/src/init/dockerfile.ts +57 -592
- package/src/init/index.ts +6 -7
- package/src/init/oauth-login.ts +57 -17
- package/src/inspect/transcript-view.ts +6 -3
- package/src/mcp/client.ts +3 -1
- package/src/operations/classify-tool-outcome.ts +45 -1
- package/src/operations/incidents.ts +10 -5
- package/src/plugin/core-tool-names.ts +1 -1
- package/src/plugin/define.ts +1 -0
- package/src/plugin/index.ts +1 -0
- package/src/plugin/types.ts +6 -1
- package/src/run/background-handoff-boot.ts +86 -0
- package/src/run/channel-session-factory.ts +5 -4
- package/src/run/index.ts +93 -93
- package/src/run/resource-sample.ts +19 -0
- package/src/sandbox/build.ts +4 -0
- package/src/sandbox/coding-agent.ts +214 -0
- package/src/sandbox/policy.ts +1 -0
- package/src/sandbox/runtime-private.ts +4 -1
- package/src/secrets/coding-agent-auth.ts +97 -0
- package/src/secrets/index.ts +0 -16
- package/src/secrets/refresh-provider-oauth.ts +30 -76
- package/src/secrets/schema.ts +3 -4
- package/src/secrets/storage.ts +133 -234
- package/src/server/command-runner.ts +6 -2
- package/src/server/index.ts +102 -41
- package/src/sessions/index.ts +1 -1
- package/src/skills/typeclaw-channel-github/SKILL.md +7 -5
- package/src/skills/typeclaw-claude-code/SKILL.md +25 -260
- package/src/skills/typeclaw-claude-code/references/auth-flow.md +7 -23
- package/src/skills/typeclaw-claude-code/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-claude-code/references/results-and-worktrees.md +13 -0
- package/src/skills/typeclaw-codex-cli/SKILL.md +35 -270
- package/src/skills/typeclaw-codex-cli/references/auth-flow.md +13 -20
- package/src/skills/typeclaw-codex-cli/references/headless-sessions.md +26 -0
- package/src/skills/typeclaw-codex-cli/references/results-and-worktrees.md +28 -0
- package/src/skills/typeclaw-config/SKILL.md +24 -24
- package/src/skills/typeclaw-config/references/dockerfile.md +14 -13
- package/src/skills/typeclaw-cron/SKILL.md +1 -1
- package/src/skills/typeclaw-github-contributing/SKILL.md +2 -2
- package/src/skills/typeclaw-memory/SKILL.md +3 -3
- package/src/skills/typeclaw-omo-cli/SKILL.md +52 -0
- package/src/skills/typeclaw-omo-cli/references/auth-flow.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/results-and-worktrees.md +23 -0
- package/src/skills/typeclaw-plugins/SKILL.md +20 -20
- package/src/skills/typeclaw-skills/SKILL.md +19 -2
- package/src/skills/typeclaw-troubleshooting/SKILL.md +15 -2
- package/src/tui/index.ts +5 -3
- package/src/tui/theme.ts +1 -1
- package/typeclaw.schema.json +44 -2
- package/src/agent/adaptive-thinking-compat.ts +0 -79
- package/src/secrets/claude-credentials-json.ts +0 -129
- package/src/secrets/codex-auth-json.ts +0 -102
- package/src/secrets/export-claude-credentials-file.ts +0 -270
- package/src/secrets/export-codex-auth-file.ts +0 -250
- package/src/secrets/oauth-xai.ts +0 -348
- package/src/skills/typeclaw-claude-code/references/stop-hook.md +0 -101
- package/src/skills/typeclaw-claude-code/references/tmux-driving.md +0 -243
- package/src/skills/typeclaw-codex-cli/references/stop-hook.md +0 -92
- 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 {
|
|
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) =>
|
|
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
|
-
|
|
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 {
|