typeclaw 0.43.1 → 0.45.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 (86) hide show
  1. package/README.md +1 -1
  2. package/auth.schema.json +92 -0
  3. package/package.json +7 -6
  4. package/secrets.schema.json +92 -0
  5. package/src/agent/index.ts +25 -2
  6. package/src/agent/model-fallback.ts +59 -40
  7. package/src/agent/multimodal/look-at.ts +29 -10
  8. package/src/agent/plugin-tools.ts +9 -4
  9. package/src/agent/provider-error.ts +71 -18
  10. package/src/agent/retry-same-ref.ts +139 -0
  11. package/src/agent/session-origin.ts +1 -0
  12. package/src/agent/subagents.ts +6 -2
  13. package/src/agent/tools/channel-edit.ts +144 -0
  14. package/src/agent/tools/channel-fetch-attachment.ts +51 -8
  15. package/src/agent/tools/channel-reply.ts +41 -18
  16. package/src/agent/tools/channel-send.ts +82 -13
  17. package/src/agent/tools/curl-impersonate.ts +40 -1
  18. package/src/agent/tools/webfetch/fetch.ts +86 -3
  19. package/src/agent/tools/webfetch/tool.ts +26 -3
  20. package/src/agent/tools/webfetch/types.ts +8 -0
  21. package/src/agent/turn-runner.ts +65 -36
  22. package/src/bundled-plugins/agent-browser/skills/agent-browser/SKILL.md +28 -11
  23. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +101 -1
  24. package/src/bundled-plugins/github-cli-auth/review-recorder.ts +44 -3
  25. package/src/bundled-plugins/guard/policies/managed-config.ts +20 -4
  26. package/src/bundled-plugins/memory/README.md +9 -9
  27. package/src/bundled-plugins/memory/index.ts +40 -9
  28. package/src/bundled-plugins/reviewer/skills/code-review.ts +22 -2
  29. package/src/channels/adapters/discord-bot-edit.ts +49 -0
  30. package/src/channels/adapters/discord-bot.ts +5 -0
  31. package/src/channels/adapters/discord-edit.ts +51 -0
  32. package/src/channels/adapters/discord.ts +4 -0
  33. package/src/channels/adapters/github/inbound.ts +20 -14
  34. package/src/channels/adapters/github/review-thread-resolver.ts +38 -4
  35. package/src/channels/adapters/slack-bot-edit.ts +58 -0
  36. package/src/channels/adapters/slack-bot.ts +18 -6
  37. package/src/channels/adapters/slack-edit.ts +47 -0
  38. package/src/channels/adapters/slack.ts +5 -0
  39. package/src/channels/adapters/teams-classify.ts +144 -0
  40. package/src/channels/adapters/teams-edit.ts +61 -0
  41. package/src/channels/adapters/teams-id-token.ts +112 -0
  42. package/src/channels/adapters/teams-key.ts +32 -0
  43. package/src/channels/adapters/teams.ts +523 -0
  44. package/src/channels/adapters/telegram-bot-edit.ts +51 -0
  45. package/src/channels/adapters/telegram-bot.ts +5 -0
  46. package/src/channels/adapters/webex-bot.ts +5 -0
  47. package/src/channels/adapters/webex-edit.ts +47 -0
  48. package/src/channels/adapters/webex.ts +5 -0
  49. package/src/channels/continuation-willingness.ts +227 -35
  50. package/src/channels/github-review-turn-ledger.ts +43 -0
  51. package/src/channels/index.ts +1 -1
  52. package/src/channels/manager.ts +54 -1
  53. package/src/channels/router.ts +482 -53
  54. package/src/channels/schema.ts +33 -0
  55. package/src/channels/types.ts +36 -0
  56. package/src/cli/channel.ts +92 -4
  57. package/src/cli/hostd.ts +41 -0
  58. package/src/cli/init.ts +58 -1
  59. package/src/config/channels-mutation.ts +9 -1
  60. package/src/cron/index.ts +16 -4
  61. package/src/cron/reloadable.ts +25 -7
  62. package/src/cron/scheduler.ts +4 -0
  63. package/src/cron/schema.ts +143 -35
  64. package/src/doctor/channel-checks.ts +27 -0
  65. package/src/hostd/daemon.ts +23 -3
  66. package/src/hostd/protocol.ts +2 -0
  67. package/src/hostd/teams-renewal-manager.ts +212 -0
  68. package/src/init/checkpoint.ts +1 -1
  69. package/src/init/index.ts +68 -1
  70. package/src/init/run-owner-claim.ts +1 -0
  71. package/src/init/teams-auth.ts +111 -0
  72. package/src/inspect/label.ts +4 -0
  73. package/src/permissions/match-rule.ts +11 -1
  74. package/src/permissions/resolve.ts +1 -0
  75. package/src/role-claim/match-rule.ts +2 -1
  76. package/src/run/index.ts +35 -8
  77. package/src/run/llm-fetch-observer.ts +27 -5
  78. package/src/sandbox/build.ts +12 -0
  79. package/src/sandbox/policy.ts +13 -0
  80. package/src/sandbox/writable-zones.ts +46 -10
  81. package/src/secrets/schema.ts +32 -0
  82. package/src/secrets/teams-renewal.ts +229 -0
  83. package/src/secrets/teams-store.ts +108 -0
  84. package/src/server/command-runner.ts +2 -1
  85. package/src/server/index.ts +2 -1
  86. package/typeclaw.schema.json +163 -3
@@ -0,0 +1,47 @@
1
+ import type { AdapterId } from '@/channels/schema'
2
+ import type { EditMessageCallback, EditMessageResult } from '@/channels/types'
3
+
4
+ // Both WebexClient and WebexBotClient expose the same edit primitive
5
+ // (webex-bot delegates to webex), so one factory serves both adapters —
6
+ // parameterized on the adapter id it guards against. Webex addresses an edit
7
+ // by (messageId, roomId): the router's `chat` IS the roomId.
8
+ type WebexEditClient = {
9
+ editMessage: (messageId: string, roomId: string, text: string, options?: { markdown?: boolean }) => Promise<unknown>
10
+ }
11
+
12
+ export function createWebexEditMessageCallback(deps: {
13
+ adapter: Extract<AdapterId, 'webex' | 'webex-bot'>
14
+ client: WebexEditClient
15
+ }): EditMessageCallback {
16
+ return async (req): Promise<EditMessageResult> => {
17
+ if (req.adapter !== deps.adapter) {
18
+ return { ok: false, error: `unknown adapter: ${req.adapter}`, code: 'not-supported' }
19
+ }
20
+ try {
21
+ await deps.client.editMessage(req.messageId, req.chat, req.text)
22
+ } catch (err) {
23
+ return { ok: false, error: describe(err), code: classifyEditError(err) }
24
+ }
25
+ return { ok: true }
26
+ }
27
+ }
28
+
29
+ // Webex REST returns 404 for a gone/foreign message id and 403 when the token
30
+ // can't edit the target; anything else is treated as a soft not-found miss.
31
+ function classifyEditError(err: unknown): NonNullable<(EditMessageResult & { ok: false })['code']> {
32
+ const status = httpStatus(err)
33
+ if (status === 403 || status === 401) return 'permission-denied'
34
+ return 'not-found'
35
+ }
36
+
37
+ function httpStatus(err: unknown): number | null {
38
+ if (typeof err === 'object' && err !== null && 'status' in err) {
39
+ const status = (err as { status: unknown }).status
40
+ if (typeof status === 'number') return status
41
+ }
42
+ return null
43
+ }
44
+
45
+ function describe(err: unknown): string {
46
+ return err instanceof Error ? err.message : String(err)
47
+ }
@@ -37,6 +37,7 @@ import type { WebexAccountRecord } from '@/secrets/schema'
37
37
  import { describeError } from './describe-error'
38
38
  import { createWebexChannelNameResolver } from './webex-channel-resolver'
39
39
  import { classifyInbound, type InboundDropReason, type WebexInboundMessage } from './webex-classify'
40
+ import { createWebexEditMessageCallback } from './webex-edit'
40
41
  import { resolveWebexBodyText } from './webex-format'
41
42
  import { createWebexPrefetchLimiter, isWebexRateLimitError, type WebexPrefetchLimiter } from './webex-prefetch-limiter'
42
43
  import { enrichWebexMessageReference } from './webex-reference'
@@ -365,6 +366,7 @@ export function createWebexAdapter(options: WebexAdapterOptions): WebexAdapter {
365
366
  const outboundCallback = createOutboundCallback({ client, logger, formatChannelTag })
366
367
  const typingCallback = createTypingCallback({ client, logger, formatChannelTag })
367
368
  const fetchAttachmentCallback = createFetchAttachmentCallback({ tokenRef: () => currentToken, logger, fetchImpl })
369
+ const editMessageCallback = createWebexEditMessageCallback({ adapter: 'webex', client })
368
370
 
369
371
  const handleMessage = async (event: WebexInboundMessage): Promise<void> => {
370
372
  inflightInbounds++
@@ -457,6 +459,7 @@ export function createWebexAdapter(options: WebexAdapterOptions): WebexAdapter {
457
459
  options.router.registerHistory('webex', historyCallback)
458
460
  options.router.registerFetchAttachment('webex', fetchAttachmentCallback)
459
461
  options.router.registerMembership('webex', membershipResolver)
462
+ options.router.registerEditMessage('webex', editMessageCallback)
460
463
 
461
464
  const rollbackStart = (reason: string, cause: Error): never => {
462
465
  options.router.unregisterOutbound('webex', outboundCallback)
@@ -467,6 +470,7 @@ export function createWebexAdapter(options: WebexAdapterOptions): WebexAdapter {
467
470
  options.router.unregisterHistory('webex', historyCallback)
468
471
  options.router.unregisterFetchAttachment('webex', fetchAttachmentCallback)
469
472
  options.router.unregisterMembership('webex', membershipResolver)
473
+ options.router.unregisterEditMessage('webex', editMessageCallback)
470
474
  listener?.stop()
471
475
  listener = null
472
476
  botPerson = null
@@ -501,6 +505,7 @@ export function createWebexAdapter(options: WebexAdapterOptions): WebexAdapter {
501
505
  options.router.unregisterHistory('webex', historyCallback)
502
506
  options.router.unregisterFetchAttachment('webex', fetchAttachmentCallback)
503
507
  options.router.unregisterMembership('webex', membershipResolver)
508
+ options.router.unregisterEditMessage('webex', editMessageCallback)
504
509
  listener?.stop()
505
510
  listener = null
506
511
  connected = false
@@ -91,45 +91,57 @@ const EN_PHRASES: readonly string[] = [
91
91
  'let me add',
92
92
  'let me create',
93
93
  'let me handle',
94
+ // Casual/contracted acks chat models emit. "imma"/"ima"/"gonna" are the
95
+ // spoken-future contractions; in an assistant reply "gonna VERB" is self-directed
96
+ // (a rival "you're gonna" is other-directed and never a willingness signal here).
97
+ 'lemme dig',
98
+ 'imma check',
99
+ 'gonna check',
100
+ 'gonna look',
101
+ 'ima look',
102
+ 'let me go check',
103
+ 'let me peek',
104
+ 'gimme a sec',
94
105
  ]
95
106
 
96
- // Korean: the -겠습니다/-겠어요 and -ㄹ게요 verb endings are first-person
107
+ // Korean: the -겠습니다/-겠어요 and -ㄹ게(요) verb endings are first-person
97
108
  // volitional — they cannot address the listener, so they are safe self-direction
98
109
  // anchors. The -겠습니다/-겠어요 form is matched by MORPHEME_PATTERNS below (it
99
- // generalizes across all action verbs), so only the -게요/-게여 forms and stall
100
- // idioms are enumerated here. Bare adverb+noun fragments ("바로 확인", "계속 확인",
101
- // "곧 알려") are deliberately NOT listed: without the volitional ending they match
102
- // other-directed requests ("바로 확인 부탁드려요" = "please check") and descriptive
103
- // progressives ("계속 확인 중입니다" = "I'm still checking") — the exact false
104
- // positives the design forbids. Their volitional forms are caught by the morpheme
105
- // regex regardless.
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
118
+ // ("바로 확인 부탁드려요" = "please check") and descriptive progressives ("계속 확인
119
+ // 중입니다" = "I'm still checking"). The persona speaking banmal ("확인해볼게!") was
120
+ // the production miss that closed a Discord turn in silence.
106
121
  const KO_PHRASES: readonly string[] = [
107
- '확인해볼게요',
108
- '확인해 볼게요',
109
- '확인할게요',
110
- '확인할게여',
111
- '계속 진행할게요',
112
- '계속할게요',
113
- '바로 볼게요',
114
- '살펴볼게요',
115
- '볼게요',
116
- '볼게여',
117
- '검토할게요',
118
- '검토해볼게요',
119
- '조회해볼게요',
120
- '찾아볼게요',
121
- '알아볼게요',
122
- '처리할게요',
123
- '알려드릴게요',
124
- // Action/config verb -게요 forms (the -겠습니다 siblings are covered by the
125
- // morpheme regex; these are the casual-polite variants chat models also emit).
126
- '업데이트할게요',
127
- '수정할게요',
128
- '설정할게요',
129
- '반영할게요',
130
- '적용할게요',
131
- '추가할게요',
132
- '생성할게요',
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
+ '생성할게',
133
145
  '잠시만요',
134
146
  '잠깐만요',
135
147
  ]
@@ -181,6 +193,21 @@ const ES_PHRASES: readonly string[] = [
181
193
  'voy a aplicar',
182
194
  'déjame actualizar',
183
195
  'déjame corregir',
196
+ // Casual register: "déjame ver/checar" (the colloquial twins of the déjame-forms
197
+ // above), and "ya lo"/"ahora mismo" + bare present, whose temporal anchor pins the
198
+ // present-as-future so it can't read as the descriptive "reviso [cada mañana]".
199
+ // "checar" is the LatAm colloquial for "revisar".
200
+ 'déjame ver',
201
+ 'déjame checar',
202
+ 'ya lo reviso',
203
+ 'lo reviso ya',
204
+ 'ya lo checo',
205
+ 'lo checo ya',
206
+ 'me pongo a revisar',
207
+ 'ahora mismo reviso',
208
+ 'voy a darle un vistazo',
209
+ 'reviso y te digo',
210
+ 'lo checo enseguida',
184
211
  ]
185
212
 
186
213
  // French: "je vais" + work verb; "laisse-moi" idioms.
@@ -213,6 +240,17 @@ const FR_PHRASES: readonly string[] = [
213
240
  'je vais appliquer',
214
241
  'laisse-moi corriger',
215
242
  'laisse-moi mettre à jour',
243
+ // Casual: the "check" anglicism (not a native French word, so zero descriptive
244
+ // ambiguity), "laisse-moi voir" (colloquial twin of laisse-moi vérifier),
245
+ // present+"rapidement" (the adverb forces future intent), and "je m'en charge"
246
+ // ("I'll take charge of it"). Bare "je regarde"/"je vérifie" are deliberately
247
+ // omitted — present tense alone reads as descriptive "I'm looking [right now]".
248
+ 'je check ça',
249
+ 'laisse-moi voir',
250
+ 'je vais checker',
251
+ 'je regarde rapidement',
252
+ 'je vérifie rapidement',
253
+ "je m'en charge",
216
254
  ]
217
255
 
218
256
  // Italian: "vado a" / "fammi" + work verb; "controllo subito" idioms.
@@ -242,6 +280,16 @@ const IT_PHRASES: readonly string[] = [
242
280
  'vado ad applicare',
243
281
  'fammi aggiornare',
244
282
  'fammi correggere',
283
+ // Casual: "fammi vedere" (colloquial twin of fammi controllare), present+"subito"/
284
+ // "adesso" (temporal anchor forces future), "vado a vedere", and "ci guardo io"
285
+ // (the "io" makes it emphatically self-directed). Bare "controllo"/"guardo" are
286
+ // omitted — present alone reads descriptive ("guardo la TV" = I'm watching TV).
287
+ 'fammi vedere',
288
+ 'vedo subito',
289
+ 'vado a vedere',
290
+ 'ci guardo io',
291
+ 'controllo adesso',
292
+ 'verifico adesso',
245
293
  ]
246
294
 
247
295
  // Portuguese: "vou" + work verb; "deixa eu" idioms.
@@ -272,6 +320,18 @@ const PT_PHRASES: readonly string[] = [
272
320
  'vou aplicar',
273
321
  'deixa eu atualizar',
274
322
  'deixa eu corrigir',
323
+ // Casual (BR-leaning): "vou ver" (the most common informal ack), "deixa eu ver/
324
+ // checar" and "deixa que eu vejo" (colloquial "let me"), "deixa comigo" ("leave it
325
+ // to me"), and "já vou ver"/"já dou uma olhada"/"...agora" (the já/agora temporal
326
+ // anchor forces future). "checar" is the BR colloquial for "verificar".
327
+ 'vou ver',
328
+ 'deixa eu ver',
329
+ 'deixa eu checar',
330
+ 'deixa comigo',
331
+ 'já vou ver',
332
+ 'verifico agora',
333
+ 'deixa que eu vejo',
334
+ 'já dou uma olhada',
275
335
  ]
276
336
 
277
337
  // German: "ich werde" / "lass mich" + work verb; "ich schaue gleich" idioms.
@@ -306,6 +366,22 @@ const DE_PHRASES: readonly string[] = [
306
366
  'ich werde anwenden',
307
367
  'lass mich aktualisieren',
308
368
  'lass mich korrigieren',
369
+ // Casual: present-as-future with the "mal"/"kurz"/"nach" particles ("ich schau
370
+ // mal", "ich guck nach"), the V2-inverted "schau ich mir" (word order flags 1sg),
371
+ // the Germanized "ich check das", and the take-responsibility forms ("ich kümmere
372
+ // mich", "das übernehm ich", "ich nehm das"). Bare "ich schau" is omitted — it also
373
+ // fits "ich schau dir zu" (I'm watching you), which is not a work promise.
374
+ 'ich schau mal',
375
+ 'ich guck mal',
376
+ 'ich schau nach',
377
+ 'ich guck nach',
378
+ 'schau ich mir',
379
+ 'ich kümmere mich',
380
+ 'ich check das',
381
+ 'das übernehm ich',
382
+ 'ich nehm das',
383
+ 'ich geh das checken',
384
+ 'ich schau kurz',
309
385
  ]
310
386
 
311
387
  // Russian: first-person-future verbs (проверю/посмотрю/продолжу) — the -ю/-у
@@ -333,6 +409,24 @@ const RU_PHRASES: readonly string[] = [
333
409
  'я применю',
334
410
  'сейчас обновлю',
335
411
  'сейчас исправлю',
412
+ // Colloquial: "щас" is the ubiquitous informal spelling of "сейчас"; "гляну" is
413
+ // bare 1sg perfective of глянуть — morphologically locked to "I will" (2sg is
414
+ // глянешь, 3sg глянет), so it's self-directed even without a pronoun. All entries
415
+ // pair a 1sg-perfective verb (гляну/посмотрю/проверю/разберусь/сделаю/поправлю)
416
+ // with щас/сейчас/дай, none of which can read as descriptive or other-directed.
417
+ 'гляну',
418
+ 'щас гляну',
419
+ 'сейчас гляну',
420
+ 'щас посмотрю',
421
+ 'щас проверю',
422
+ 'дай гляну',
423
+ 'дай посмотреть',
424
+ 'сейчас разберусь',
425
+ 'щас разберусь',
426
+ 'сейчас сделаю',
427
+ 'щас сделаю',
428
+ 'сейчас поправлю',
429
+ 'щас поправлю',
336
430
  ]
337
431
 
338
432
  // Chinese: 我会/我来/我再 + work verb. Full multi-character intent phrases only;
@@ -370,6 +464,17 @@ const ZH_PHRASES: readonly string[] = [
370
464
  '我马上更新',
371
465
  '让我更新',
372
466
  '让我改一下',
467
+ // Casual/spoken: 去+verb (我去看下/我去核实) and 来+verb (我来处理/我来瞧瞧) mark quick
468
+ // self-initiated action. Entries are ≥4 chars ending in a volitional suffix. The
469
+ // 2-char 我看/我查 are omitted (descriptive 我看你说的对 = "I see you're right"), and
470
+ // the 3-char reduplications 我看看/我查查 are omitted too: they fall under MIN_LENGTH
471
+ // as standalone acks, and embedded they risk the past-narrative 我看看了 ("I glanced").
472
+ '我去看下',
473
+ '我来处理',
474
+ '我搜一下',
475
+ '我确认下',
476
+ '我去核实',
477
+ '我来瞧瞧',
373
478
  ]
374
479
 
375
480
  // Japanese: handled by the JA_VOLITIONAL morpheme check below (-します/-いたします/
@@ -383,6 +488,24 @@ const JA_PHRASES: readonly string[] = [
383
488
  '続けます',
384
489
  '少々お待ちください',
385
490
  'ちょっと待ってください',
491
+ // Casual plain form (タメ口), particle-anchored. Bare dictionary forms (見る/確認する)
492
+ // are the SAME as descriptive present and far too ambiguous, so each entry pins a
493
+ // work verb to a self-commitment sentence-final particle: 〜ね (volitional), 〜わ
494
+ // (soft assertion), or the 〜とく/〜てくる/〜てみる auxiliaries that already imply
495
+ // "I'll take care of / go do / try". 〜よ is excluded (it can be merely informational).
496
+ '確認するね',
497
+ '調べるね',
498
+ '見てみるね',
499
+ '確認しとくね',
500
+ '調べとくね',
501
+ 'チェックしとくね',
502
+ '見とくね',
503
+ '見てみるわ',
504
+ '調べてみるね',
505
+ '確認してみるね',
506
+ '見てくるね',
507
+ '調べてくるね',
508
+ 'すぐ見るね',
386
509
  ]
387
510
 
388
511
  // Arabic: future particle سـ prefixed first-person verb (سأتحقق = "I will
@@ -408,12 +531,45 @@ const AR_PHRASES: readonly string[] = [
408
531
  'سأصلح',
409
532
  'سأنشئ',
410
533
  'سأضيف',
534
+ // Colloquial dialects: explicit future markers راح/رح (Gulf/Levantine) and هـ
535
+ // (Egyptian) + verb, plus خليني ("let me") and بدي ("I want to", Levantine
536
+ // volitional). Bare بشوف is omitted — بـ+imperfect is present-habitual in some
537
+ // dialects, so it can read descriptive. شيك only appears prefixed (هاشيك/راح أشيك)
538
+ // so it can't collide with the noun شيك ("cheque").
539
+ 'راح أشوف',
540
+ 'رح أشوف',
541
+ 'هشوف',
542
+ 'هأشوف',
543
+ 'خليني أشوف',
544
+ 'رح أتأكد',
545
+ 'هاشيك',
546
+ 'راح أشيك',
547
+ 'رح أتحقق',
548
+ 'بدي أشوف',
549
+ 'هجيب المعلومة',
550
+ 'راح أراجع',
411
551
  ]
412
552
 
413
553
  // Hindi: first-person-future is the -ūṅgā/-ūṅgī suffix, matched by
414
554
  // MORPHEME_PATTERNS below (it covers all X-करना compounds). Only the stall idiom
415
555
  // is enumerated here.
416
- const HI_PHRASES: readonly string[] = ['एक मिनट रुकिए']
556
+ // Casual Hindi uses the habitual present (देखता हूँ) for immediate intent, but only
557
+ // with an immediacy anchor (अभी "now", जरा "just") or the completive ले, which mark
558
+ // volition; bare देखता हूँ / करता हूँ are omitted (descriptive "I'm looking / I do").
559
+ // Both genders (-ता/-ती) are listed since the ending marks speaker gender. The formal
560
+ // -ऊँगा future is already covered by MORPHEME_PATTERNS. एक मिनट रुकिए is the stall idiom.
561
+ const HI_PHRASES: readonly string[] = [
562
+ 'एक मिनट रुकिए',
563
+ 'अभी देखता हूँ',
564
+ 'देख लेता हूँ',
565
+ 'मैं देख लेता हूँ',
566
+ 'अभी चेक करता हूँ',
567
+ 'चेक कर लेता हूँ',
568
+ 'अभी देख लेता हूँ',
569
+ 'जरा देखता हूँ',
570
+ 'देख लेती हूँ',
571
+ 'चेक कर लेती हूँ',
572
+ ]
417
573
 
418
574
  // Turkish: first-person-future "-eceğim/-acağım" is matched by MORPHEME_PATTERNS
419
575
  // below. The present-progressive ("ediyorum" = "I'm checking now"), optative
@@ -428,6 +584,16 @@ const TR_PHRASES: readonly string[] = [
428
584
  'hemen bakıyorum',
429
585
  'bir saniye',
430
586
  'bir dakika',
587
+ // Casual: the -eyim/-ayım optative ("let me VERB") is the safest volition anchor
588
+ // (bakayım/edeyim/atayım/inceleyeyim); the -ır/-ar aorist (bakarım) is only added
589
+ // with hemen/şimdi to force future over habitual. -yor present-continuous
590
+ // (bakıyorum) is NOT extended — it's descriptive "I'm looking [now]". baksana is
591
+ // excluded (imperative "look!", other-directed).
592
+ 'şuna bakayım',
593
+ 'bir inceleyeyim',
594
+ 'bir göz atayım',
595
+ 'şimdi bakayım',
596
+ 'hemen bakarım',
431
597
  ]
432
598
 
433
599
  // Vietnamese: "tôi sẽ" / "để tôi" (I will / let me) + work verb.
@@ -449,6 +615,16 @@ const VI_PHRASES: readonly string[] = [
449
615
  'tôi sẽ thêm',
450
616
  'để tôi cập nhật',
451
617
  'để tôi sửa',
618
+ // Casual/Southern: "coi" is the Southern colloquial for "xem" (look); "thử" (try)
619
+ // is a strong volition marker, so coi/xem/kiểm tra + thử are safe. Bare "để coi" is
620
+ // omitted — it can mean "let's see [what happens]" (观望), not a work promise.
621
+ 'coi thử',
622
+ 'để tôi coi',
623
+ 'xem thử',
624
+ 'tôi coi thử',
625
+ 'kiểm tra thử',
626
+ 'coi một lúc',
627
+ 'để tôi coi thử',
452
628
  ]
453
629
 
454
630
  // Indonesian: "saya akan" / "biar saya" (I will / let me) + work verb.
@@ -473,6 +649,22 @@ const ID_PHRASES: readonly string[] = [
473
649
  'saya akan tambah',
474
650
  'biar saya perbaiki',
475
651
  'biar saya perbarui',
652
+ // Casual/spoken: "coba" (let/try) leads a volitional; "dulu"/"aja"/"sekarang" anchor
653
+ // the bare present as imminent ("saya cek dulu" = "I'll check first"). "liat" is the
654
+ // casual "lihat". Bare "saya cek"/"saya liat" are omitted (present/past ambiguous),
655
+ // and the Javanese "tak" prefix is excluded (3-char substring collides with takut
656
+ // "afraid", menata "arrange").
657
+ 'coba saya cek',
658
+ 'saya cek dulu',
659
+ 'liat dulu',
660
+ 'saya liat dulu',
661
+ 'coba saya liat',
662
+ 'saya cek aja',
663
+ 'liat dulu ya',
664
+ 'saya cek sekarang',
665
+ 'saya bantu cek',
666
+ 'saya usahakan cek',
667
+ 'liat sebentar',
476
668
  ]
477
669
 
478
670
  const ALL_PHRASES: readonly string[] = [
@@ -15,6 +15,21 @@ export type ReviewObserver = (args: {
15
15
  verdict: ReviewVerdict
16
16
  }) => void
17
17
 
18
+ // A formal review LANDED this turn, of ANY state — the two decisive verdicts PLUS
19
+ // a non-decisive COMMENT. This signal ONLY tells the channel router "the agent
20
+ // already delivered output via the GitHub review API this turn" so an empty
21
+ // completion afterward doesn't fire the empty-turn fallback. It is deliberately
22
+ // NOT stored in the false-receipt ledger (`reviewsByPr`): a COMMENT carries no
23
+ // verdict-claim risk and must never satisfy `hasReview()`.
24
+ export type ReviewOutputState = ReviewVerdict | 'COMMENT'
25
+
26
+ export type ReviewOutputObserver = (args: {
27
+ sessionId: string
28
+ workspace: string
29
+ prNumber: number
30
+ state: ReviewOutputState
31
+ }) => void
32
+
18
33
  type PrKey = string
19
34
  type ThreadKey = string
20
35
 
@@ -28,13 +43,19 @@ const resolvedThreads = new Set<ThreadKey>()
28
43
  // stays the single seam where "a formal verdict happened" is known across the
29
44
  // plugin/channels boundary, which is why it owns this hook.
30
45
  let reviewObserver: ReviewObserver | null = null
46
+ let reviewOutputObserver: ReviewOutputObserver | null = null
31
47
 
32
48
  export function setReviewObserver(observer: ReviewObserver | null): void {
33
49
  reviewObserver = observer
34
50
  }
35
51
 
52
+ export function setReviewOutputObserver(observer: ReviewOutputObserver | null): void {
53
+ reviewOutputObserver = observer
54
+ }
55
+
36
56
  export function __resetReviewObserverForTest(): void {
37
57
  reviewObserver = null
58
+ reviewOutputObserver = null
38
59
  }
39
60
 
40
61
  function prKey(sessionId: string, workspace: string, prNumber: number): PrKey {
@@ -73,6 +94,28 @@ export function recordReview(args: {
73
94
  // swallow: a broken broadcast must not break verdict bookkeeping
74
95
  }
75
96
  }
97
+ // A decisive verdict IS review output too — fan it to the output observer so the
98
+ // router's empty-turn guard sees it without a second detection path.
99
+ recordReviewOutput({
100
+ sessionId: args.sessionId,
101
+ workspace: args.workspace,
102
+ prNumber: args.prNumber,
103
+ state: args.verdict,
104
+ })
105
+ }
106
+
107
+ export function recordReviewOutput(args: {
108
+ sessionId: string
109
+ workspace: string
110
+ prNumber: number
111
+ state: ReviewOutputState
112
+ }): void {
113
+ if (reviewOutputObserver === null) return
114
+ try {
115
+ reviewOutputObserver(args)
116
+ } catch {
117
+ // swallow: a broken router notification must not break review bookkeeping
118
+ }
76
119
  }
77
120
 
78
121
  export function hasReview(args: {
@@ -20,7 +20,7 @@ export {
20
20
  type PrVerdictActivityBridge,
21
21
  type PrVerdictActivityBridgeOptions,
22
22
  } from './pr-verdict-activity-bridge'
23
- export { setReviewObserver } from './github-review-turn-ledger'
23
+ export { setReviewObserver, setReviewOutputObserver, type ReviewOutputState } from './github-review-turn-ledger'
24
24
  export {
25
25
  createSubagentCompletionBridge,
26
26
  type SubagentCompletionBridge,
@@ -10,6 +10,7 @@ import { SecretsLineCredentialStore } from '@/secrets/line-store'
10
10
  import type { RuntimeSecretsProvider } from '@/secrets/secrets-provider'
11
11
  import { SecretsSlackCredentialStore } from '@/secrets/slack-store'
12
12
  import { SecretsBackend } from '@/secrets/storage'
13
+ import { SecretsTeamsCredentialStore } from '@/secrets/teams-store'
13
14
  import { SecretsWebexCredentialStore } from '@/secrets/webex-store'
14
15
  import type { Stream } from '@/stream'
15
16
 
@@ -21,6 +22,7 @@ import { createKakaotalkAdapter, type KakaotalkAdapter } from './adapters/kakaot
21
22
  import { createLineAdapter, type LineAdapter } from './adapters/line'
22
23
  import { createSlackAdapter, type SlackAdapter } from './adapters/slack'
23
24
  import { createSlackBotAdapter, type SlackBotAdapter } from './adapters/slack-bot'
25
+ import { createTeamsAdapter, type TeamsAdapter } from './adapters/teams'
24
26
  import { createTelegramBotAdapter, type TelegramBotAdapter } from './adapters/telegram-bot'
25
27
  import { createWebexAdapter, type WebexAdapter } from './adapters/webex'
26
28
  import { createWebexBotAdapter, type WebexBotAdapter } from './adapters/webex-bot'
@@ -90,6 +92,7 @@ export type ChannelManagerOptions = {
90
92
  createLineAdapter?: typeof createLineAdapter
91
93
  createSlackAdapter?: typeof createSlackBotAdapter
92
94
  createSlackUserAdapter?: typeof createSlackAdapter
95
+ createTeamsAdapter?: typeof createTeamsAdapter
93
96
  createTelegramAdapter?: typeof createTelegramBotAdapter
94
97
  createWebexAdapter?: typeof createWebexAdapter
95
98
  createWebexBotAdapter?: typeof createWebexBotAdapter
@@ -161,6 +164,7 @@ type AnyAdapter =
161
164
  | KakaotalkAdapter
162
165
  | SlackAdapter
163
166
  | SlackBotAdapter
167
+ | TeamsAdapter
164
168
  | TelegramBotAdapter
165
169
  | WebexAdapter
166
170
  | WebexBotAdapter
@@ -205,6 +209,7 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
205
209
  const createLine = options.createLineAdapter ?? createLineAdapter
206
210
  const createSlackBot = options.createSlackAdapter ?? createSlackBotAdapter
207
211
  const createSlackUser = options.createSlackUserAdapter ?? createSlackAdapter
212
+ const createTeams = options.createTeamsAdapter ?? createTeamsAdapter
208
213
  const createTelegramAdapter = options.createTelegramAdapter ?? createTelegramBotAdapter
209
214
  const createWebex = options.createWebexAdapter ?? createWebexAdapter
210
215
  const createWebexBot = options.createWebexBotAdapter ?? createWebexBotAdapter
@@ -235,6 +240,7 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
235
240
  if (name === 'instagram') return buildInstagramSignature(options.agentDir)
236
241
  if (name === 'kakaotalk') return buildKakaotalkSignature(options.agentDir)
237
242
  if (name === 'webex') return buildWebexSignature(options.agentDir)
243
+ if (name === 'teams') return buildTeamsSignature(options.agentDir)
238
244
  if (name === 'slack') return buildSlackSignature(options.agentDir)
239
245
  if (name === 'discord') return buildDiscordSignature(options.agentDir)
240
246
  if (name === 'github') return buildGithubSignature(options.agentDir)
@@ -343,6 +349,17 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
343
349
  credentialsStore,
344
350
  })
345
351
  }
352
+ if (name === 'teams') {
353
+ const credentialsStore = createContainerTeamsCredentialStore(options.agentDir, options.secretsProvider ?? null)
354
+ if (credentialsStore === null) return null
355
+ return createTeams({
356
+ router,
357
+ configRef: () => options.channelsConfigRef()[name] ?? cfg,
358
+ logger,
359
+ selfAliasesRef: () => router.getSelfAliases(),
360
+ credentialsStore,
361
+ })
362
+ }
346
363
  if (name === 'github') {
347
364
  const secrets = readGithubSecrets(options.agentDir)
348
365
  if (secrets === null) return null
@@ -562,6 +579,7 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
562
579
  name === 'line' ||
563
580
  name === 'instagram' ||
564
581
  name === 'webex' ||
582
+ name === 'teams' ||
565
583
  name === 'slack' ||
566
584
  name === 'discord'
567
585
  ? 'credential rotation'
@@ -580,7 +598,7 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
580
598
  // secrets.json#channels.<adapter>, not in env, so they go through
581
599
  // structured-block signatures instead.
582
600
  const TOKEN_ENV: Record<
583
- Exclude<AdapterId, 'kakaotalk' | 'line' | 'instagram' | 'github' | 'webex' | 'slack' | 'discord'>,
601
+ Exclude<AdapterId, 'kakaotalk' | 'line' | 'instagram' | 'github' | 'webex' | 'teams' | 'slack' | 'discord'>,
584
602
  readonly string[]
585
603
  > = {
586
604
  'discord-bot': ['DISCORD_BOT_TOKEN'],
@@ -673,6 +691,32 @@ function buildWebexSignature(agentDir: string): { signature: string; missing: st
673
691
  }
674
692
  }
675
693
 
694
+ function createContainerTeamsCredentialStore(
695
+ agentDir: string,
696
+ secretsProvider: RuntimeSecretsProvider | null,
697
+ ): SecretsTeamsCredentialStore | null {
698
+ if (secretsProvider === null) return null
699
+ return new SecretsTeamsCredentialStore({
700
+ mode: 'container',
701
+ secretsPath: join(agentDir, 'secrets.json'),
702
+ hostProvider: secretsProvider,
703
+ })
704
+ }
705
+
706
+ function buildTeamsSignature(agentDir: string): { signature: string; missing: string[] } {
707
+ const path = join(agentDir, 'secrets.json')
708
+ try {
709
+ const block = new SecretsBackend(path).tryReadChannelsSync()?.teams
710
+ if (!isTeamsCredentialBlock(block)) {
711
+ return { signature: '', missing: ['secrets.json#channels.teams'] }
712
+ }
713
+ const digest = createHash('sha256').update(JSON.stringify(block)).digest('hex')
714
+ return { signature: `secrets.json#channels.teams@sha256:${digest}`, missing: [] }
715
+ } catch (err) {
716
+ return { signature: '', missing: [`secrets.json#channels.teams (${describe(err)})`] }
717
+ }
718
+ }
719
+
676
720
  function createContainerKakaoCredentialStore(
677
721
  agentDir: string,
678
722
  secretsProvider: RuntimeSecretsProvider | null,
@@ -831,6 +875,15 @@ function isWebexCredentialBlock(value: unknown): value is { accounts: Record<str
831
875
  )
832
876
  }
833
877
 
878
+ function isTeamsCredentialBlock(value: unknown): value is { accounts: Record<string, unknown> } {
879
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
880
+ if (!('accounts' in value)) return false
881
+ const accounts = value.accounts
882
+ return (
883
+ typeof accounts === 'object' && accounts !== null && !Array.isArray(accounts) && Object.keys(accounts).length > 0
884
+ )
885
+ }
886
+
834
887
  function describe(err: unknown): string {
835
888
  return err instanceof Error ? err.message : String(err)
836
889
  }