typeclaw 0.48.6 → 0.48.8

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 (105) hide show
  1. package/auth.schema.json +15 -1
  2. package/package.json +1 -1
  3. package/secrets.schema.json +15 -1
  4. package/src/agent/guard-types.ts +25 -0
  5. package/src/agent/guards.ts +102 -0
  6. package/src/agent/index.ts +33 -3
  7. package/src/agent/live-subagents.ts +14 -0
  8. package/src/agent/multimodal/read-redirect.ts +8 -9
  9. package/src/agent/plugin-tools.ts +283 -148
  10. package/src/agent/provider-error.ts +6 -1
  11. package/src/agent/reload-tool.ts +12 -5
  12. package/src/agent/retry-same-ref.ts +95 -36
  13. package/src/agent/session-origin.ts +13 -1
  14. package/src/agent/system-prompt.ts +14 -3
  15. package/src/agent/todo/continuation-policy.ts +3 -4
  16. package/src/agent/tool-file-safety.ts +36 -13
  17. package/src/agent/tools/channel-reply.ts +39 -2
  18. package/src/agent/tools/channel-send.ts +45 -2
  19. package/src/agent/tools/post-github-review.ts +31 -13
  20. package/src/agent/tools/spawn-subagent.ts +15 -0
  21. package/src/agent/tools/webfetch/inline-style-visibility.ts +2 -2
  22. package/src/agent/tools/webfetch/strategies/readability.ts +109 -10
  23. package/src/agent/turn-runner.ts +23 -19
  24. package/src/bundled-plugins/backup/git-auth.ts +7 -4
  25. package/src/bundled-plugins/backup/subagents.ts +1 -1
  26. package/src/bundled-plugins/bun-hygiene/README.md +23 -20
  27. package/src/bundled-plugins/bun-hygiene/index.ts +1 -7
  28. package/src/bundled-plugins/bun-hygiene/policy.ts +111 -35
  29. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +44 -2
  30. package/src/bundled-plugins/github-cli-auth/gh-store.ts +733 -0
  31. package/src/bundled-plugins/github-cli-auth/git-askpass.ts +25 -0
  32. package/src/bundled-plugins/github-cli-auth/git-command.ts +231 -30
  33. package/src/bundled-plugins/github-cli-auth/git-credential-env.ts +151 -0
  34. package/src/bundled-plugins/github-cli-auth/index.ts +249 -42
  35. package/src/bundled-plugins/github-cli-auth/review-recorder.ts +5 -0
  36. package/src/bundled-plugins/guard/index.ts +2 -25
  37. package/src/bundled-plugins/guard/keys.ts +8 -0
  38. package/src/bundled-plugins/guard/policies/non-workspace-write.ts +7 -8
  39. package/src/bundled-plugins/guard/policy.ts +1 -7
  40. package/src/bundled-plugins/security/policies/git-exfil.ts +22 -30
  41. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +2 -4
  42. package/src/bundled-plugins/security/policies/private-surface-read.ts +8 -6
  43. package/src/bundled-plugins/security/policies/secret-exfil-bash.ts +2 -5
  44. package/src/bundled-plugins/security/policies/secret-exfil-read.ts +2 -4
  45. package/src/bundled-plugins/security/policies/session-search-secrets.ts +2 -4
  46. package/src/bundled-plugins/security/policies/system-prompt-leak.ts +2 -4
  47. package/src/bundled-plugins/security/policy.ts +0 -8
  48. package/src/channels/adapters/discord-bot-slash-commands.ts +22 -0
  49. package/src/channels/adapters/discord-bot.ts +2 -1
  50. package/src/channels/adapters/discord-classify.ts +16 -4
  51. package/src/channels/adapters/discord.ts +20 -8
  52. package/src/channels/adapters/github/dedup.ts +37 -8
  53. package/src/channels/adapters/github/inbound.ts +241 -46
  54. package/src/channels/adapters/github/review-state.ts +13 -9
  55. package/src/channels/adapters/github/review-thread-resolver.ts +52 -20
  56. package/src/channels/adapters/slack-classify.ts +40 -5
  57. package/src/channels/adapters/slack.ts +3 -9
  58. package/src/channels/adapters/webex-bot-classify.ts +4 -33
  59. package/src/channels/adapters/webex-bot.ts +2 -4
  60. package/src/channels/adapters/webex-classify.ts +4 -33
  61. package/src/channels/adapters/webex-format.ts +36 -0
  62. package/src/channels/adapters/webex.ts +2 -4
  63. package/src/channels/continuation-willingness.ts +64 -39
  64. package/src/channels/github-rereview-guard.ts +20 -0
  65. package/src/channels/github-review-turn-ledger.ts +11 -1
  66. package/src/channels/github-review-verdict-coordinator.ts +475 -41
  67. package/src/channels/github-verdict-activity.ts +14 -5
  68. package/src/channels/persistence.ts +89 -5
  69. package/src/channels/router.ts +1223 -225
  70. package/src/channels/types.ts +21 -5
  71. package/src/cli/compose-stats.ts +6 -7
  72. package/src/cli/compose-status.ts +6 -7
  73. package/src/cli/compose-usage.ts +6 -7
  74. package/src/cli/stats.ts +6 -7
  75. package/src/cli/status.ts +7 -8
  76. package/src/cli/ui.ts +4 -4
  77. package/src/container/start.ts +41 -1
  78. package/src/cron/consumer.ts +30 -9
  79. package/src/cron/scheduler.ts +24 -9
  80. package/src/doctor/channel-checks.ts +64 -0
  81. package/src/doctor/report.ts +8 -8
  82. package/src/dreams/render.ts +2 -2
  83. package/src/init/dockerfile.ts +8 -1
  84. package/src/inspect/render.ts +2 -2
  85. package/src/path-safety/real-intended-path.ts +14 -1
  86. package/src/permissions/permissions.ts +10 -2
  87. package/src/permissions/resolve.ts +8 -2
  88. package/src/plugin/core-tool-names.ts +15 -0
  89. package/src/plugin/hooks.ts +37 -3
  90. package/src/plugin/registry.ts +7 -3
  91. package/src/run/index.ts +35 -15
  92. package/src/sandbox/build.ts +19 -3
  93. package/src/sandbox/policy.ts +1 -0
  94. package/src/secrets/export-github-cli-store.ts +158 -0
  95. package/src/secrets/index.ts +19 -1
  96. package/src/secrets/provision-github-cli-store.ts +322 -0
  97. package/src/secrets/schema.ts +13 -7
  98. package/src/secrets/storage.ts +30 -0
  99. package/src/shared/index.ts +2 -0
  100. package/src/shared/style-text.ts +13 -0
  101. package/src/skills/typeclaw-channel-github/SKILL.md +24 -12
  102. package/src/skills/typeclaw-config/SKILL.md +3 -1
  103. package/src/skills/typeclaw-github-contributing/SKILL.md +6 -2
  104. package/src/skills/typeclaw-permissions/SKILL.md +11 -22
  105. package/src/usage/report.ts +3 -3
@@ -1,14 +1,16 @@
1
- import type { SlackRTMMessageEvent } from 'agent-messenger/slack'
1
+ import type { SlackFile, SlackRTMMessageEvent } from 'agent-messenger/slack'
2
2
 
3
3
  import { matchesAnyAlias } from '@/channels/engagement'
4
4
  import type { ChannelAdapterConfig } from '@/channels/schema'
5
- import type { InboundMessage } from '@/channels/types'
5
+ import type { InboundAttachment, InboundMessage } from '@/channels/types'
6
6
 
7
7
  import { slackTsToMillis } from './slack-bot-time'
8
8
  import { encodeSlackReactionRef } from './slack-reactions'
9
9
 
10
10
  export type SlackInboundMessageEvent = SlackRTMMessageEvent & {
11
11
  channel_type?: string
12
+ // Modern RTM file messages are subtype-less but retain the `files` array.
13
+ files?: SlackFile[]
12
14
  is_mpim?: boolean
13
15
  }
14
16
 
@@ -35,10 +37,11 @@ export function classifyInbound(
35
37
  if (context.selfUserId !== null && event.user === context.selfUserId) return { kind: 'drop', reason: 'self_author' }
36
38
  if (event.user === undefined || event.user === '') return { kind: 'drop', reason: 'no_user' }
37
39
  if (!isRouteableSlackMessageSubtype(event.subtype)) return { kind: 'drop', reason: 'slack_system_message' }
38
- if ((event.text ?? '') === '') return { kind: 'drop', reason: 'empty_text' }
40
+ const rawText = event.text ?? ''
41
+ const { text, attachments } = splitSlackFiles(rawText, event.files)
42
+ if (text === '') return { kind: 'drop', reason: 'empty_text' }
39
43
  if (context.selfUserId === null) return { kind: 'drop', reason: 'pre_connect' }
40
44
 
41
- const rawText = event.text ?? ''
42
45
  const conversationType = classifyConversation(event, context.conversationType)
43
46
  const isDm = conversationType === 'im'
44
47
  const workspace = isDm ? '@dm' : context.teamId
@@ -57,7 +60,8 @@ export function classifyInbound(
57
60
  chat: event.channel,
58
61
  thread,
59
62
  ...(thread !== null ? { room: { kind: 'thread' as const } } : {}),
60
- text: rawText,
63
+ text,
64
+ ...(attachments.length > 0 ? { attachments } : {}),
61
65
  externalMessageId: event.ts,
62
66
  reactionRef: encodeSlackReactionRef({ channel: event.channel, ts: event.ts }),
63
67
  authorId: event.user,
@@ -91,6 +95,37 @@ export function isRouteableSlackMessageSubtype(subtype: string | undefined): boo
91
95
  return subtype === undefined || subtype === 'me_message'
92
96
  }
93
97
 
98
+ // Live inbound and REST history share the same attachment rendering contract.
99
+ // Registering the ref
100
+ // without also baking a `#N` placeholder into the text is not enough: the
101
+ // agent has no way to learn the id exists, so look_at_channel_attachment stays
102
+ // unreachable in practice.
103
+ export function splitSlackFiles(text: string, files: readonly SlackFile[] | undefined): SplitSlackFiles {
104
+ const attachments = (files ?? []).map(describeSlackFile)
105
+ if (attachments.length === 0) return { text, attachments: [] }
106
+ const summary = attachments.map(renderPlaceholder).join('\n')
107
+ return { text: text === '' ? summary : `${text}\n${summary}`, attachments }
108
+ }
109
+
110
+ type SplitSlackFiles = { text: string; attachments: InboundAttachment[] }
111
+
112
+ function describeSlackFile(file: SlackFile, index: number): InboundAttachment {
113
+ return {
114
+ id: index + 1,
115
+ kind: 'file',
116
+ ref: file.id,
117
+ filename: file.name,
118
+ mimetype: file.mimetype,
119
+ }
120
+ }
121
+
122
+ function renderPlaceholder(attachment: InboundAttachment): string {
123
+ const parts: string[] = [`Slack attachment #${attachment.id}: ${attachment.kind}`]
124
+ if (attachment.mimetype !== undefined) parts.push(attachment.mimetype)
125
+ if (attachment.filename !== undefined) parts.push(`name=${attachment.filename}`)
126
+ return `[${parts.join(' ')}]`
127
+ }
128
+
94
129
  const MENTION_PATTERN = /<@([UW][A-Z0-9]+)(?:\|[^>]*)?>/g
95
130
  const GROUP_MENTION_PATTERN = /<!(?:here|channel|everyone)(?:\|[^>]*)?>/
96
131
 
@@ -38,7 +38,7 @@ import { downloadSlackAttachment, type SlackAttachmentFetch } from './slack-atta
38
38
  import { createSlackAuthorResolver } from './slack-author-resolver'
39
39
  import { slackTsToMillis } from './slack-bot-time'
40
40
  import { createSlackChannelResolver } from './slack-channel-resolver'
41
- import { classifyInbound, type InboundDropReason, type SlackConversationType } from './slack-classify'
41
+ import { classifyInbound, type InboundDropReason, type SlackConversationType, splitSlackFiles } from './slack-classify'
42
42
  import { createSlackUserEditMessageCallback } from './slack-edit'
43
43
  import { createSlackReactionCallback, createSlackRemoveReactionCallback } from './slack-reactions'
44
44
 
@@ -461,18 +461,12 @@ async function defaultReadFile(path: string): Promise<Buffer> {
461
461
  }
462
462
 
463
463
  function mapSlackHistoryMessage(msg: SlackMessage): ChannelHistoryMessage {
464
- const attachments = (msg.files ?? []).map((file, index) => ({
465
- id: index + 1,
466
- kind: 'file' as const,
467
- ref: file.id,
468
- filename: file.name,
469
- mimetype: file.mimetype,
470
- }))
464
+ const { text, attachments } = splitSlackFiles(msg.text, msg.files)
471
465
  return {
472
466
  externalMessageId: msg.ts,
473
467
  authorId: msg.user ?? msg.username ?? 'unknown',
474
468
  authorName: msg.username ?? msg.user ?? 'unknown',
475
- text: msg.text,
469
+ text,
476
470
  ts: slackTsToMillis(msg.ts),
477
471
  isBot: false,
478
472
  replyToBotMessageId: null,
@@ -2,7 +2,9 @@ import type { WebexBotListenerEventMap } from 'agent-messenger/webexbot'
2
2
 
3
3
  import { matchesAnyAlias } from '@/channels/engagement'
4
4
  import type { ChannelAdapterConfig } from '@/channels/schema'
5
- import type { InboundAttachment, InboundMessage } from '@/channels/types'
5
+ import type { InboundMessage } from '@/channels/types'
6
+
7
+ import { splitWebexFiles } from './webex-format'
6
8
 
7
9
  export type WebexInboundMessage = WebexBotListenerEventMap['message_created'][0]
8
10
 
@@ -27,7 +29,7 @@ export function classifyInbound(
27
29
  return { kind: 'drop', reason: 'self_author' }
28
30
  }
29
31
 
30
- const { text, attachments } = splitInbound(event)
32
+ const { text, attachments } = splitWebexFiles(event.text, event.files)
31
33
  if (text === '') return { kind: 'drop', reason: 'empty_content' }
32
34
 
33
35
  if (botPersonRef === null) {
@@ -78,34 +80,3 @@ function isSelfAuthor(event: WebexInboundMessage, botPersonRef: string | null, b
78
80
  }
79
81
  return false
80
82
  }
81
-
82
- type SplitInbound = { text: string; attachments: InboundAttachment[] }
83
-
84
- function splitInbound(event: WebexInboundMessage): SplitInbound {
85
- const attachments = event.files.map((ref, index) => ({
86
- id: index + 1,
87
- kind: 'file' as const,
88
- ref,
89
- filename: filenameFromUrl(ref) ?? `webex-file-${index + 1}`,
90
- }))
91
- if (attachments.length === 0) return { text: event.text, attachments: [] }
92
- const summary = attachments.map(renderPlaceholder).join('\n')
93
- const text = event.text === '' ? summary : `${event.text}\n${summary}`
94
- return { text, attachments }
95
- }
96
-
97
- function filenameFromUrl(ref: string): string | null {
98
- try {
99
- const url = new URL(ref)
100
- const name = url.pathname.split('/').filter(Boolean).pop()
101
- return name === undefined || name === '' ? null : name
102
- } catch {
103
- return null
104
- }
105
- }
106
-
107
- function renderPlaceholder(attachment: InboundAttachment): string {
108
- const parts: string[] = [`Webex attachment #${attachment.id}: ${attachment.kind}`]
109
- if (attachment.filename !== undefined) parts.push(`name=${attachment.filename}`)
110
- return `[${parts.join(' ')}]`
111
- }
@@ -39,7 +39,7 @@ import { createWebexChannelNameResolver } from './webex-bot-channel-resolver'
39
39
  import { classifyInbound, type InboundDropReason, type WebexInboundMessage } from './webex-bot-classify'
40
40
  import { enrichWebexMessageReference } from './webex-bot-reference'
41
41
  import { createWebexEditMessageCallback } from './webex-edit'
42
- import { resolveWebexBodyText } from './webex-format'
42
+ import { resolveWebexBodyText, splitWebexFiles } from './webex-format'
43
43
  import { createWebexPrefetchLimiter, isWebexRateLimitError, type WebexPrefetchLimiter } from './webex-prefetch-limiter'
44
44
 
45
45
  export type WebexBotAdapterLogger = {
@@ -462,9 +462,7 @@ export function createWebexBotAdapter(options: WebexBotAdapterOptions): WebexBot
462
462
  }
463
463
 
464
464
  function mapWebexHistoryMessage(msg: WebexMessage, botPersonId: string | null): ChannelHistoryMessage {
465
- const attachments = (msg.files ?? []).map((ref, index) => ({ id: index + 1, kind: 'file' as const, ref }))
466
- const body = resolveWebexBodyText(msg)
467
- const text = attachments.length === 0 ? body : body === '' ? '[Webex attachment]' : `${body}\n[Webex attachment]`
465
+ const { text, attachments } = splitWebexFiles(resolveWebexBodyText(msg), msg.files)
468
466
  const ts = Date.parse(msg.created)
469
467
  return {
470
468
  externalMessageId: msg.ref,
@@ -3,7 +3,9 @@ import type { WebexListenerEventMap } from 'agent-messenger/webex'
3
3
 
4
4
  import { matchesAnyAlias } from '@/channels/engagement'
5
5
  import type { ChannelAdapterConfig } from '@/channels/schema'
6
- import type { InboundAttachment, InboundMessage } from '@/channels/types'
6
+ import type { InboundMessage } from '@/channels/types'
7
+
8
+ import { splitWebexFiles } from './webex-format'
7
9
 
8
10
  export type WebexInboundMessage = WebexListenerEventMap['message_created'][0]
9
11
 
@@ -33,7 +35,7 @@ export function classifyInbound(
33
35
  return { kind: 'drop', reason: 'self_author' }
34
36
  }
35
37
 
36
- const { text, attachments } = splitInbound(event)
38
+ const { text, attachments } = splitWebexFiles(event.text, event.files)
37
39
  if (text === '') return { kind: 'drop', reason: 'empty_content' }
38
40
 
39
41
  if (botPersonRef === null) {
@@ -86,34 +88,3 @@ function isSelfAuthor(event: WebexInboundMessage, botPersonRef: string | null, b
86
88
  }
87
89
  return false
88
90
  }
89
-
90
- type SplitInbound = { text: string; attachments: InboundAttachment[] }
91
-
92
- function splitInbound(event: WebexInboundMessage): SplitInbound {
93
- const attachments = event.files.map((ref: string, index: number) => ({
94
- id: index + 1,
95
- kind: 'file' as const,
96
- ref,
97
- filename: filenameFromUrl(ref) ?? `webex-file-${index + 1}`,
98
- }))
99
- if (attachments.length === 0) return { text: event.text, attachments: [] }
100
- const summary = attachments.map(renderPlaceholder).join('\n')
101
- const text = event.text === '' ? summary : `${event.text}\n${summary}`
102
- return { text, attachments }
103
- }
104
-
105
- function filenameFromUrl(ref: string): string | null {
106
- try {
107
- const url = new URL(ref)
108
- const name = url.pathname.split('/').filter(Boolean).pop()
109
- return name === undefined || name === '' ? null : name
110
- } catch {
111
- return null
112
- }
113
- }
114
-
115
- function renderPlaceholder(attachment: InboundAttachment): string {
116
- const parts: string[] = [`Webex attachment #${attachment.id}: ${attachment.kind}`]
117
- if (attachment.filename !== undefined) parts.push(`name=${attachment.filename}`)
118
- return `[${parts.join(' ')}]`
119
- }
@@ -1,5 +1,7 @@
1
1
  import type { WebexMessage } from 'agent-messenger/webex'
2
2
 
3
+ import type { InboundAttachment } from '@/channels/types'
4
+
3
5
  // Webex's E2E (internal conversation) path renders agent markdown as an HTML
4
6
  // `content` field that some clients display verbatim, so messages sent with
5
7
  // `markdown: true` leak literal `<br/>` and `&apos;`. typeclaw sends plain text
@@ -15,6 +17,40 @@ export function resolveWebexBodyText(msg: Pick<WebexMessage, 'text' | 'markdown'
15
17
  return ''
16
18
  }
17
19
 
20
+ // Shared by both Webex classifiers and both Webex history mappers so a file
21
+ // carries the same `#N` in every surface the agent can read. History used to
22
+ // emit a single un-numbered `[Webex attachment]` regardless of file count,
23
+ // which registered refs the agent could never name in
24
+ // look_at_channel_attachment.
25
+ export function splitWebexFiles(text: string, files: readonly string[] | undefined): SplitWebexFiles {
26
+ const attachments = (files ?? []).map(describeWebexFile)
27
+ if (attachments.length === 0) return { text, attachments: [] }
28
+ const summary = attachments.map(renderPlaceholder).join('\n')
29
+ return { text: text === '' ? summary : `${text}\n${summary}`, attachments }
30
+ }
31
+
32
+ type SplitWebexFiles = { text: string; attachments: InboundAttachment[] }
33
+
34
+ function describeWebexFile(ref: string, index: number): InboundAttachment {
35
+ return { id: index + 1, kind: 'file', ref, filename: filenameFromUrl(ref) ?? `webex-file-${index + 1}` }
36
+ }
37
+
38
+ function filenameFromUrl(ref: string): string | null {
39
+ try {
40
+ const url = new URL(ref)
41
+ const name = url.pathname.split('/').filter(Boolean).pop()
42
+ return name === undefined || name === '' ? null : name
43
+ } catch {
44
+ return null
45
+ }
46
+ }
47
+
48
+ function renderPlaceholder(attachment: InboundAttachment): string {
49
+ const parts: string[] = [`Webex attachment #${attachment.id}: ${attachment.kind}`]
50
+ if (attachment.filename !== undefined) parts.push(`name=${attachment.filename}`)
51
+ return `[${parts.join(' ')}]`
52
+ }
53
+
18
54
  export function normalizeWebexHtmlFallbackText(value: string): string {
19
55
  const withBreaks = value
20
56
  .replace(/<br\s*\/?>/gi, '\n')
@@ -43,7 +43,7 @@ import { describeError } from '../describe-error'
43
43
  import { createWebexChannelNameResolver } from './webex-channel-resolver'
44
44
  import { classifyInbound, type InboundDropReason, type WebexInboundMessage } from './webex-classify'
45
45
  import { createWebexEditMessageCallback } from './webex-edit'
46
- import { resolveWebexBodyText } from './webex-format'
46
+ import { resolveWebexBodyText, splitWebexFiles } from './webex-format'
47
47
  import { createWebexPrefetchLimiter, isWebexRateLimitError, type WebexPrefetchLimiter } from './webex-prefetch-limiter'
48
48
  import { enrichWebexMessageReference } from './webex-reference'
49
49
 
@@ -534,9 +534,7 @@ function mapWebexHistoryMessage(
534
534
  botPersonId: string | null,
535
535
  authorById: ReadonlyMap<string, string>,
536
536
  ): ChannelHistoryMessage {
537
- const attachments = (msg.files ?? []).map((ref, index) => ({ id: index + 1, kind: 'file' as const, ref }))
538
- const body = resolveWebexBodyText(msg)
539
- const text = attachments.length === 0 ? body : body === '' ? '[Webex attachment]' : `${body}\n[Webex attachment]`
537
+ const { text, attachments } = splitWebexFiles(resolveWebexBodyText(msg), msg.files)
540
538
  const ts = Date.parse(msg.created)
541
539
  return {
542
540
  externalMessageId: msg.ref,
@@ -104,47 +104,33 @@ const EN_PHRASES: readonly string[] = [
104
104
  'gimme a sec',
105
105
  ]
106
106
 
107
- // Korean: the -겠습니다/-겠어요 and -ㄹ게(요) verb endings are first-person
107
+ // Korean: the -겠습니다/-겠어요 and -(으)ㄹ게(요) verb endings are first-person
108
108
  // volitional — they cannot address the listener, so they are safe self-direction
109
- // anchors. The -겠습니다/-겠어요 form is matched by MORPHEME_PATTERNS below (it
110
- // generalizes across all action verbs), so only the -ㄹ게 forms and stall idioms
111
- // are enumerated here. Each entry is the CASUAL (banmal) -게 base; the polite -게요
112
- // / -게여 forms match too because the substring pass tests `includes` (볼게 ⊂
113
- // 볼게요). Enumerating the casual base is deliberate over a broad `[ㄹ-final]게`
114
- // morpheme regex: that would also fire on the adverbial -게 of adjective stems
115
- // (힘들게 "hard-ly", 멀게 "far-ly", 길게 "long-ly"), violating the file's
116
- // prefer-false-negatives bias. Bare adverb+noun fragments ("바로 확인", "계속 확인")
117
- // are still excluded: without the -게 volitional they match other-directed requests
109
+ // anchors. BOTH are matched by MORPHEME_PATTERNS below, stem-anchored to the same
110
+ // action/auxiliary stems, so they generalize across every verb built on them. No
111
+ // -게 form is enumerated here at all: an entry in this table would SHORT-CIRCUIT
112
+ // the morpheme pass, because the substring pass returns before it runs, and the
113
+ // negation / question / quotative guards that make the morpheme pass safe would
114
+ // never execute. A table entry 처리할게 is what made 제가 처리할게요? report
115
+ // willingness despite the question guard. Only the stall idioms — which have no
116
+ // verb to negate or question — remain.
117
+ //
118
+ // The stem anchor is what keeps this narrow. A broad `[ㄹ-final]게` regex was
119
+ // rejected: it fires on the adverbial -게 of adjective stems (힘들게 "hard-ly",
120
+ // 멀게 "far-ly", 길게 "long-ly"), on the noun 별게 ("별게 아니에요" = "it's nothing"),
121
+ // and on the -게 되다/만들다 construction (알게 되었습니다 = "I came to know") — none
122
+ // of which promise work. Requiring the -게 be sentence-final does NOT rescue it,
123
+ // because every one of those confusables is followed by a SPACE, so a lookahead
124
+ // cannot see past it. Worse, an open-class rule also admits genuine volitionals
125
+ // that mean the OPPOSITE of continuation (여기서 마칠게요 "I'll stop here", 이제
126
+ // 쉴게요 "I'll rest now"), violating the file's prefer-false-negatives bias.
127
+ //
128
+ // Bare adverb+noun fragments ("바로 확인", "계속 확인") are still excluded: without
129
+ // the -게 volitional they match other-directed requests
118
130
  // ("바로 확인 부탁드려요" = "please check") and descriptive progressives ("계속 확인
119
131
  // 중입니다" = "I'm still checking"). The persona speaking banmal ("확인해볼게!") was
120
132
  // the production miss that closed a Discord turn in silence.
121
- const KO_PHRASES: readonly string[] = [
122
- '확인해볼게',
123
- '확인해 볼게',
124
- '확인할게',
125
- '계속 진행할게',
126
- '계속할게',
127
- '살펴볼게',
128
- '볼게',
129
- '검토할게',
130
- '검토해볼게',
131
- '조회해볼게',
132
- '찾아볼게',
133
- '알아볼게',
134
- '처리할게',
135
- '알려드릴게',
136
- // Action/config verb -게 forms (the -겠습니다 siblings are covered by the
137
- // morpheme regex; these are the casual/casual-polite variants chat models emit).
138
- '업데이트할게',
139
- '수정할게',
140
- '설정할게',
141
- '반영할게',
142
- '적용할게',
143
- '추가할게',
144
- '생성할게',
145
- '잠시만요',
146
- '잠깐만요',
147
- ]
133
+ const KO_PHRASES: readonly string[] = ['잠시만요', '잠깐만요']
148
134
 
149
135
  // The remaining languages mirror the precision-first selection above: every
150
136
  // entry pairs a FIRST-PERSON future/volitional anchor with a work verb
@@ -697,6 +683,25 @@ const MORPHEME_PATTERNS: readonly RegExp[] = [
697
683
  // Listener-directed conjecture takes the honorific 시 (피곤하시겠어요 → 시겠, not
698
684
  // 하겠), so it is excluded too.
699
685
  /(?:하|보|두|놓)겠(?:습니다|어요)/,
686
+ // Korean first-person volitional -(으)ㄹ게(요): the same stems as -겠 above plus the
687
+ // humble auxiliary 드리 (알려드릴게요), carrying the ㄹ that marks the ending
688
+ // (하 → 할게, 보 → 볼게, 두 → 둘게, 놓 → 놓을게, 드리 → 드릴게; consonant-final 놓 takes
689
+ // the -을게 allomorph). This is what generalizes across the
690
+ // open X하다 class the tables cannot enumerate — 배포할게요/롤백할게요/머지할게요 all
691
+ // reduce to 할게. The ㄹ is load-bearing for precision, not just morphology: the
692
+ // adverbial -게 attaches to a BARE stem (착하게 "kindly", never 착할게), so 할게/볼게
693
+ // have no adjective reading at all, and the 여기서 마칠게요 ("I'll stop here") class of
694
+ // non-work volitionals never reaches these stems. The (?![??]) lookahead drops the
695
+ // permission-seeking question form (제가 처리할게요? "shall I handle it?"), mirroring
696
+ // the Japanese question guard below; a question awaits the user rather than
697
+ // committing to act. The quotative lookahead drops reported speech
698
+ // ("확인할게요"라고 했습니다 = "they said they'd check"), where the promise is someone
699
+ // else's — an optional closing quote may sit between the ending and 라고.
700
+ // The (?![요여용]) is load-bearing: without it the optional particle group
701
+ // backtracks to empty and the guards below inspect the 요 instead of what follows
702
+ // it, so 배포할게요? would slip through. Forcing the particle to be consumed when
703
+ // present is JS's substitute for a possessive quantifier.
704
+ /(?:할|볼|둘|놓을|드릴)게(?:요|여|용)?(?![요여용])(?![??])(?!["'”』]?\s*라(?:고|며|는|던))/,
700
705
  // Turkish first-person-singular future "-acağım/-eceğim" ("I will VERB").
701
706
  // Vowel harmony yields exactly these two suffixes; the y-buffer
702
707
  // ("bekleyeceğim") leaves the suffix intact.
@@ -720,6 +725,25 @@ const MORPHEME_PATTERNS: readonly RegExp[] = [
720
725
  const JA_VOLITIONAL_IDIOMS = /お願い(?:いた)?します|失礼します/g
721
726
  const JA_VOLITIONAL = /します(?![か??])|してみます(?![か??])/
722
727
 
728
+ // Korean short negation 안/못 inverts the promise: 배포 안 할게요 is a commitment NOT
729
+ // to deploy. Both Korean morpheme families are affected (안 할게요 and 안 하겠습니다),
730
+ // so negated spans are stripped before the morpheme pass rather than guarded inside
731
+ // each pattern — the same strip-then-test shape JA_VOLITIONAL_IDIOMS uses above.
732
+ //
733
+ // The negator must be its OWN token. Two lookbehind/shape constraints enforce that,
734
+ // and both are load-bearing in opposite directions: (?<![가-힣]) rejects a 안 that ends
735
+ // a word (방안/제안 확인할게요 = "I'll check the plan/proposal"), while requiring a space
736
+ // before the {0,6} verb window rejects a 안 that merely STARTS one (안내해드릴게요 =
737
+ // "I'll guide you", 안전하게 배포할게요 = "I'll deploy safely"). Without the space the
738
+ // window swallows 내해 and suppresses a real promise. The no-space branch stays for the
739
+ // attached spelling 안할게요.
740
+ //
741
+ // The {0,6} window spans the verb the negator scopes over, which may be several
742
+ // syllables (안 업데이트할게요), but cannot cross a space, so a negator in an earlier
743
+ // clause never reaches a later promise (배포는 안 하고 확인만 할게요 stays willing).
744
+ // Long negation -지 않을게요 needs no entry: 않을게 is not one of the stems.
745
+ const KO_NEGATED_VOLITIONAL = /(?<![가-힣])(?:안|못)(?:\s+[가-힣]{0,6})?(?:(?:할|볼|둘|놓을|드릴)게|(?:하|보|두|놓)겠)/g
746
+
723
747
  // Reply texts shorter than this are almost always a complete final answer
724
748
  // ("네", "ok", "done") where a partial match would be noise. The shortest
725
749
  // legitimate intent phrases ("on it now", "확인할게요") clear this floor.
@@ -730,6 +754,7 @@ export function detectContinuationWillingness(text: string): boolean {
730
754
  const normalized = normalize(text)
731
755
  if (normalized.length < MIN_LENGTH) return false
732
756
  if (ALL_PHRASES.some((phrase) => normalized.includes(phrase))) return true
733
- if (MORPHEME_PATTERNS.some((pattern) => pattern.test(normalized))) return true
734
- return JA_VOLITIONAL.test(normalized.replace(JA_VOLITIONAL_IDIOMS, ''))
757
+ const affirmed = normalized.replace(KO_NEGATED_VOLITIONAL, ' ')
758
+ if (MORPHEME_PATTERNS.some((pattern) => pattern.test(affirmed))) return true
759
+ return JA_VOLITIONAL.test(affirmed.replace(JA_VOLITIONAL_IDIOMS, ''))
735
760
  }
@@ -1,4 +1,6 @@
1
1
  import { classifyReviewClaim, isPositiveWarnCloseout } from './github-review-claim'
2
+ import { isGithubReviewRoundComplete } from './github-review-verdict-coordinator'
3
+ import type { GithubReviewFollowupRound } from './types'
2
4
  import type { ReviewStateResult } from './types'
3
5
 
4
6
  // The re-review stranding guard. A bot that resolves a review thread (or posts a
@@ -23,6 +25,7 @@ export type RereviewGuardInput = {
23
25
  moreWorkThisTurn: boolean
24
26
  getReviewState: (req: { adapter: 'github'; workspace: string; chat: string }) => Promise<ReviewStateResult>
25
27
  workspace: string
28
+ round?: GithubReviewFollowupRound
26
29
  }
27
30
 
28
31
  export type RereviewGuardDecision = { block: false } | { block: true; reason: string }
@@ -38,6 +41,7 @@ export async function evaluateRereviewGuard(input: RereviewGuardInput): Promise<
38
41
  // text-claim path fires regardless (caught by isCloseoutAttempt below).
39
42
  if (!isCloseoutAttempt(input)) return ALLOW
40
43
 
44
+ const round = matchingRound(input)
41
45
  const state = await input.getReviewState({ adapter: 'github', workspace: input.workspace, chat: input.chat })
42
46
 
43
47
  // Fail closed: an unverifiable review state is treated as a live block, so the
@@ -50,9 +54,25 @@ export async function evaluateRereviewGuard(input: RereviewGuardInput): Promise<
50
54
  return ALLOW
51
55
  }
52
56
 
57
+ // Resolving a thread cannot create a conflicting formal verdict, so carrier
58
+ // eligibility is the wrong operand to deny here. The sticky-block check below
59
+ // covers the real stranding risk from authoritative GitHub state and therefore
60
+ // self-corrects when an external actor clears the block; local round state does not.
61
+ if (round !== null && isGithubReviewRoundComplete(round) && input.wantsResolve && input.thread !== null) {
62
+ return ALLOW
63
+ }
64
+
53
65
  return { block: true, reason: state.approve ? STICKY_BLOCK_APPROVE_ENABLED : STICKY_BLOCK_APPROVE_DISABLED }
54
66
  }
55
67
 
68
+ function matchingRound(input: RereviewGuardInput): GithubReviewFollowupRound | null {
69
+ const round = input.round
70
+ if (round === undefined) return null
71
+ const match = /^pr:(\d+)$/.exec(input.chat)
72
+ if (match === null || Number(match[1]) !== round.prNumber || input.workspace !== round.workspace) return null
73
+ return round
74
+ }
75
+
56
76
  // Trigger when the model asks to resolve a thread (only meaningful with a
57
77
  // thread), OR when its reply reads as a close-out/verdict claim — the latter
58
78
  // strands the block whether or not it sits in a thread, so it fires for any PR
@@ -7,12 +7,13 @@
7
7
  // turn start, so a claim must be backed by an action in the SAME turn.
8
8
 
9
9
  export type ReviewVerdict = 'APPROVE' | 'REQUEST_CHANGES'
10
+ export type ReviewRoundOutcome = ReviewVerdict | 'DISMISSED'
10
11
 
11
12
  export type ReviewObserver = (args: {
12
13
  sessionId: string
13
14
  workspace: string
14
15
  prNumber: number
15
- verdict: ReviewVerdict
16
+ verdict: ReviewRoundOutcome
16
17
  }) => void
17
18
 
18
19
  // A formal review LANDED this turn, of ANY state — the two decisive verdicts PLUS
@@ -104,6 +105,15 @@ export function recordReview(args: {
104
105
  })
105
106
  }
106
107
 
108
+ export function recordVerifiedDismissal(args: { sessionId: string; workspace: string; prNumber: number }): void {
109
+ if (reviewObserver === null) return
110
+ try {
111
+ reviewObserver({ ...args, verdict: 'DISMISSED' })
112
+ } catch {
113
+ // A broken round wakeup must not turn a verified GitHub mutation into a tool failure.
114
+ }
115
+ }
116
+
107
117
  export function recordReviewOutput(args: {
108
118
  sessionId: string
109
119
  workspace: string