typeclaw 0.47.2 → 0.48.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 (105) hide show
  1. package/package.json +1 -1
  2. package/src/agent/index.ts +1 -2
  3. package/src/agent/loop-guard.ts +71 -41
  4. package/src/agent/plugin-tools.ts +167 -50
  5. package/src/agent/system-prompt.ts +1 -1
  6. package/src/agent/turn-runner.ts +12 -2
  7. package/src/bundled-plugins/agent-browser/index.ts +0 -38
  8. package/src/bundled-plugins/agent-browser/skills/agent-browser/SKILL.md +1 -1
  9. package/src/bundled-plugins/guard/policies/non-workspace-write.ts +16 -1
  10. package/src/bundled-plugins/memory/append-tool.ts +75 -2
  11. package/src/bundled-plugins/memory/frontmatter.ts +13 -2
  12. package/src/bundled-plugins/memory/load-memory.ts +1 -1
  13. package/src/bundled-plugins/memory/memory-logger.ts +5 -1
  14. package/src/bundled-plugins/memory/secret-detector.ts +7 -0
  15. package/src/bundled-plugins/memory/vector/hybrid.ts +3 -1
  16. package/src/bundled-plugins/memory/vector/passages.ts +5 -1
  17. package/src/bundled-plugins/security/index.ts +148 -98
  18. package/src/bundled-plugins/security/policies/private-surface-read.ts +43 -28
  19. package/src/channels/adapters/discord-bot-edit.ts +3 -5
  20. package/src/channels/adapters/discord-bot-reactions.ts +4 -6
  21. package/src/channels/adapters/discord-bot-slash-commands.ts +3 -1
  22. package/src/channels/adapters/discord-bot.ts +20 -23
  23. package/src/channels/adapters/discord-edit.ts +3 -5
  24. package/src/channels/adapters/discord-reactions.ts +4 -6
  25. package/src/channels/adapters/discord.ts +1 -1
  26. package/src/channels/adapters/github/decoy-reviewer.ts +2 -1
  27. package/src/channels/adapters/github/history.ts +2 -1
  28. package/src/channels/adapters/github/inbound.ts +4 -11
  29. package/src/channels/adapters/github/index.ts +6 -9
  30. package/src/channels/adapters/github/outbound.ts +3 -6
  31. package/src/channels/adapters/github/reactions.ts +3 -2
  32. package/src/channels/adapters/github/reconcile-cooldown-store.ts +4 -6
  33. package/src/channels/adapters/github/reconcile-open-prs.ts +5 -4
  34. package/src/channels/adapters/github/recover-failed-deliveries.ts +2 -5
  35. package/src/channels/adapters/github/review-state.ts +3 -2
  36. package/src/channels/adapters/github/review-thread-resolver.ts +3 -2
  37. package/src/channels/adapters/github/webhook-register.ts +5 -8
  38. package/src/channels/adapters/instagram-channel-resolver.ts +3 -5
  39. package/src/channels/adapters/instagram.ts +1 -1
  40. package/src/channels/adapters/kakaotalk-author-resolver.ts +2 -5
  41. package/src/channels/adapters/kakaotalk-channel-resolver.ts +3 -5
  42. package/src/channels/adapters/kakaotalk-fetch-attachment.ts +2 -1
  43. package/src/channels/adapters/kakaotalk-membership.ts +2 -5
  44. package/src/channels/adapters/kakaotalk-typing.ts +1 -1
  45. package/src/channels/adapters/kakaotalk.ts +1 -1
  46. package/src/channels/adapters/line-channel-resolver.ts +3 -5
  47. package/src/channels/adapters/line.ts +1 -1
  48. package/src/channels/adapters/slack-bot-edit.ts +1 -1
  49. package/src/channels/adapters/slack-bot-reactions.ts +4 -6
  50. package/src/channels/adapters/slack-bot.ts +8 -8
  51. package/src/channels/adapters/slack-edit.ts +3 -5
  52. package/src/channels/adapters/slack-reactions.ts +4 -6
  53. package/src/channels/adapters/slack.ts +1 -1
  54. package/src/channels/adapters/teams-edit.ts +2 -5
  55. package/src/channels/adapters/teams.ts +1 -1
  56. package/src/channels/adapters/telegram-bot-edit.ts +4 -7
  57. package/src/channels/adapters/telegram-bot.ts +1 -1
  58. package/src/channels/adapters/webex-bot.ts +1 -1
  59. package/src/channels/adapters/webex-edit.ts +3 -5
  60. package/src/channels/adapters/webex.ts +1 -1
  61. package/src/channels/github-review-claim.ts +89 -4
  62. package/src/channels/github-token-bridge.ts +2 -1
  63. package/src/channels/manager.ts +478 -64
  64. package/src/channels/membership-cache.ts +2 -5
  65. package/src/channels/persistence.ts +3 -6
  66. package/src/channels/reloadable.ts +23 -6
  67. package/src/channels/router.ts +134 -56
  68. package/src/channels/tunnel-bridge.ts +2 -1
  69. package/src/channels/types.ts +6 -3
  70. package/src/cli/hostd.ts +56 -28
  71. package/src/config/config.ts +10 -0
  72. package/src/config/providers.ts +179 -0
  73. package/src/dependencies/bin-resolver.ts +88 -0
  74. package/src/dependencies/bins.ts +227 -0
  75. package/src/dependencies/index.ts +17 -0
  76. package/src/doctor/checks.ts +2 -0
  77. package/src/doctor/operational-incidents.ts +32 -0
  78. package/src/hostd/credential-rotation-apply.ts +94 -0
  79. package/src/init/models-dev.ts +17 -3
  80. package/src/init/validate-api-key.ts +26 -4
  81. package/src/operations/classify-tool-outcome.ts +151 -0
  82. package/src/operations/incidents.ts +274 -0
  83. package/src/operations/index.ts +3 -0
  84. package/src/operations/remediations.ts +41 -0
  85. package/src/reload/client.ts +8 -2
  86. package/src/reload/docker-exec-client.ts +10 -2
  87. package/src/reload/index.ts +1 -1
  88. package/src/reload/recover.ts +5 -3
  89. package/src/reload/registry.ts +5 -5
  90. package/src/reload/types.ts +9 -1
  91. package/src/run/index.ts +5 -0
  92. package/src/sandbox/dependency-bins.ts +125 -0
  93. package/src/sandbox/errors.ts +32 -0
  94. package/src/sandbox/hidden-paths.ts +4 -1
  95. package/src/sandbox/index.ts +8 -0
  96. package/src/sandbox/policy.ts +1 -1
  97. package/src/sandbox/privileged-runtime.ts +88 -7
  98. package/src/sandbox/runtime-private.ts +4 -0
  99. package/src/sandbox/writable-zones.ts +4 -4
  100. package/src/server/index.ts +7 -5
  101. package/src/shared/protocol.ts +6 -1
  102. package/typeclaw.schema.json +35 -5
  103. package/src/bundled-plugins/agent-browser/shim-install.ts +0 -179
  104. package/src/bundled-plugins/agent-browser/shim.ts +0 -108
  105. /package/src/channels/{adapters/describe-error.ts → describe-error.ts} +0 -0
@@ -1,6 +1,8 @@
1
1
  import type { AdapterId } from '@/channels/schema'
2
2
  import type { EditMessageCallback, EditMessageResult } from '@/channels/types'
3
3
 
4
+ import { describeError } from '../describe-error'
5
+
4
6
  // Both WebexClient and WebexBotClient expose the same edit primitive
5
7
  // (webex-bot delegates to webex), so one factory serves both adapters —
6
8
  // parameterized on the adapter id it guards against. Webex addresses an edit
@@ -20,7 +22,7 @@ export function createWebexEditMessageCallback(deps: {
20
22
  try {
21
23
  await deps.client.editMessage(req.messageId, req.chat, req.text)
22
24
  } catch (err) {
23
- return { ok: false, error: describe(err), code: classifyEditError(err) }
25
+ return { ok: false, error: describeError(err), code: classifyEditError(err) }
24
26
  }
25
27
  return { ok: true }
26
28
  }
@@ -41,7 +43,3 @@ function httpStatus(err: unknown): number | null {
41
43
  }
42
44
  return null
43
45
  }
44
-
45
- function describe(err: unknown): string {
46
- return err instanceof Error ? err.message : String(err)
47
- }
@@ -39,7 +39,7 @@ import type {
39
39
  } from '@/channels/types'
40
40
  import type { WebexAccountRecord } from '@/secrets/schema'
41
41
 
42
- import { describeError } from './describe-error'
42
+ 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'
@@ -94,6 +94,7 @@ const BLOCK_RESOLVE: readonly RegExp[] = [
94
94
  /\bthis resolves it\b/,
95
95
  /\b(that|this) closes it\b/,
96
96
  /\bclosing this out\b/,
97
+ /\bresolving (?:this|the) thread\b/,
97
98
  /\bconfirmed fixed\b/,
98
99
  // verify clause + a fix/resolve verb, allowing a short gap ("verified at <sha>, that fixes it").
99
100
  /\b(verified|confirmed)\b[^.!?]*\b(fix(es|ed)|resolv)/,
@@ -134,9 +135,84 @@ const WARN_POSITIVE_CLOSEOUT: readonly RegExp[] = [
134
135
  /\btampaknya (?:baik|oke)\b/, // id seems good
135
136
  ]
136
137
 
138
+ // A hold-open statement reverses neighbouring resolve-shaped prose. Blocking the
139
+ // whole reply in that case strands neither review state nor thread; it silences
140
+ // the new blocker the reply is trying to preserve (PR #1320). Keep these precise
141
+ // enough to assert unfinished work, not merely mention a blocker that was fixed.
142
+ const HOLD_OPEN: readonly RegExp[] = [
143
+ /\bkeep(?:ing)? (?:this |the )?(?:review )?thread open\b/,
144
+ /\bkeep(?:ing)? (?:this|it) open\b/,
145
+ /\bleav(?:e|ing) (?:(?:this|it) open|(?:this |the )?(?:review )?thread open)\b/,
146
+ /\bstill (?:blocks?|blocking)\b/,
147
+ /\bremaining\b[^.!?]{0,80}\bblockers?\b(?![^.!?]*\b(?:(?:is|are|was|were) (?:now )?|(?:has|have) (?:now )?been )(?:fixed|resolved|addressed)\b)/,
148
+ /\bblockers? remain(?:s|ing)?\b(?![^.!?]*\b(?:(?:is|are|was|were) (?:now )?|(?:has|have) (?:now )?been )(?:fixed|resolved|addressed)\b)/,
149
+ /\bstill (?:has|have) (?:an? )?blocking (?:issue|problem|concern)\b/,
150
+ /\bnot resolv(?:e|ed|ing)\b/,
151
+ /\b(?:can(?:not|'?t|\s+t)|unable to) resolve\b[^.!?]*\byet\b/,
152
+ /\b(?:(?:one|an?|the) )?(?:issue|problem|concern)s? remain(?:s|ing)?\b(?![^.!?]*\b(?:(?:is|are|was|were) (?:now )?|(?:has|have) (?:now )?been )(?:fixed|resolved|addressed)\b)/,
153
+ /\b(?:work|changes?|fix(?:es)?) remain(?:s|ing)?\b(?![^.!?]*\b(?:(?:is|are|was|were) (?:now )?|(?:has|have) (?:now )?been )(?:fixed|resolved|addressed)\b)/,
154
+ // es
155
+ /\b(?:dejo|dejando|mantengo|manteniendo) (?:este |el )?hilo abierto\b/,
156
+ /\b(?:todav[íi]a|a[úu]n) (?:bloquea|hay (?:un )?(?:problema|bloqueo))\b/,
157
+ /\b(?:queda|permanece) (?:un )?(?:bloqueo|problema)\b/,
158
+ // fr
159
+ /\b(?:je laisse|laissant|je garde) (?:ce |le )?fil ouvert\b/,
160
+ /\bbloque encore\b/,
161
+ /\bil reste (?:un )?(?:blocage|probl[èe]me)\b/,
162
+ // it
163
+ /\b(?:lascio|lasciando|mantengo) (?:questo |il )?(?:thread|filo) apert[oa]\b/,
164
+ /\bblocca ancora\b/,
165
+ /\brimane (?:un )?(?:blocco|problema)\b/,
166
+ // pt
167
+ /\b(?:deixo|deixando|mantenho|mantendo) (?:este |o )?(?:t[óo]pico|fio) aberto\b/,
168
+ /\bainda (?:bloqueia|h[áa] (?:um )?(?:bloqueio|problema))\b/,
169
+ /\b(?:resta|permanece) (?:um )?(?:bloqueio|problema)\b/,
170
+ // de
171
+ /\b(?:diesen |den )?thread offen (?:lassen|halten)\b/,
172
+ /\b(?:blockiert|sperrt) (?:noch|weiterhin|immer noch)\b/,
173
+ /\b(?:ein )?(?:blocker|problem) bleibt\b/,
174
+ // ru: оставляю ветку открытой / пока не могу решить / блокер или проблема остаётся
175
+ /\u043E\u0441\u0442\u0430\u0432\u043B\u044F\u044E[^.!?]*(?:\u0432\u0435\u0442\u043A\u0443|\u0442\u0435\u043C\u0443)[^.!?]*\u043E\u0442\u043A\u0440\u044B\u0442/,
176
+ /\u043F\u043E\u043A\u0430 \u043D\u0435 \u043C\u043E\u0433\u0443[^.!?]*(?:\u0440\u0435\u0448\u0438\u0442\u044C|\u0437\u0430\u043A\u0440\u044B\u0442\u044C)/,
177
+ /(?:\u0431\u043B\u043E\u043A\u0435\u0440|\u043F\u0440\u043E\u0431\u043B\u0435\u043C\u0430)[^.!?]*(?:\u043E\u0441\u0442\u0430\u0451\u0442\u0441\u044F|\u043E\u0441\u0442\u0430\u0435\u0442\u0441\u044F)/,
178
+ // ko: 스레드를 열어 둠 / 차단 문제가 남음 / 아직 해결할 수 없음
179
+ /\uC2A4\uB808\uB4DC(?:\uB97C|\uB294)?[^.!?]*(?:\uC5F4\uC5B4 \uB450|\uC5F4\uB9B0 \uCC44)/,
180
+ /(?:\uCC28\uB2E8 (?:\uBB38\uC81C|\uC774\uC288)|\uBE14\uB85C\uCEE4)[^.!?]*\uB0A8\uC544 \uC788(?:\uC5B4|\uC2B5\uB2C8\uB2E4|\uB2E4|\uB294|\uACE0|\uC9C0\uB9CC|\uC74C)/,
181
+ /\uC544\uC9C1[^.!?]*\uD574\uACB0\uD560 \uC218 \uC5C6/,
182
+ // zh: 保持线程开启 / 还不能解决 / 问题仍然存在
183
+ /\u4FDD\u6301[^.!?]*\u7EBF\u7A0B[^.!?]*\u5F00\u542F/,
184
+ /\u8FD8\u4E0D\u80FD[^.!?]*\u89E3\u51B3/,
185
+ /(?:\u95EE\u9898|\u963B\u585E)[^.!?]*\u4ECD\u7136[^.!?]*\u5B58\u5728/,
186
+ /\u4ECD\u6709[^.!?]*(?:\u95EE\u9898|\u963B\u585E)/,
187
+ // ja: スレッドを開いたまま / まだ解決できない / 問題が残っている
188
+ /\u30B9\u30EC\u30C3\u30C9[^.!?]*\u958B\u3044\u305F\u307E\u307E/,
189
+ /\u307E\u3060[^.!?]*\u89E3\u6C7A\u3067\u304D(?:\u306A\u3044|\u307E\u305B\u3093)/,
190
+ /(?:\u554F\u984C|\u30D6\u30ED\u30C3\u30AB\u30FC)[^.!?]*\u6B8B\u3063\u3066\u3044(?:\u308B|\u307E\u3059)/,
191
+ // ar: إبقاء النقاش مفتوحاً / لا يمكنني الحل بعد / لا تزال مشكلة
192
+ /\u0625\u0628\u0642\u0627\u0621[^.!?]*\u0645\u0641\u062A\u0648\u062D/,
193
+ /\u0644\u0627 \u064A\u0645\u0643\u0646\u0646\u064A[^.!?]*\u062D\u0644[^.!?]*\u0628\u0639\u062F/,
194
+ /\u0644\u0627 \u062A\u0632\u0627\u0644[^.!?]*\u0645\u0634\u0643\u0644\u0629/,
195
+ // hi: समस्या/अवरोधक अभी बाकी है / अभी हल नहीं हुआ
196
+ /(?:\u0938\u092E\u0938\u094D\u092F\u093E|\u0905\u0935\u0930\u094B\u0927\u0915)[^.!?]*\u092C\u093E\u0915\u0940 \u0939\u0948\u0902?/,
197
+ /\u0905\u092D\u0940[^.!?]*\u0939\u0932[^.!?]*\u0928\u0939\u0940\u0902/,
198
+ // tr
199
+ /\b(?:bu )?(?:konuyu|ba\u015Fl\u0131\u011F\u0131) a[çc]\u0131k (?:tutuyorum|b\u0131rak\u0131yorum)\b/,
200
+ /\bh[âa]l[âa] (?:engelliyor|bir (?:engel|sorun) var)\b/,
201
+ /\b(?:engel|sorun) devam ediyor\b/,
202
+ // vi — no \b after accented characters: JS boundaries are ASCII-only.
203
+ /gi\u1EEF lu\u1ED3ng n\u00E0y m\u1EDF/,
204
+ /v\u1EABn ch\u1EB7n/,
205
+ /v\u1EABn c\u00F2n[^.!?]*(?:v\u1EA5n \u0111\u1EC1|tr\u1EDF ng\u1EA1i)/,
206
+ // id
207
+ /\b(?:membiarkan|menjaga) utas ini tetap terbuka\b/,
208
+ /\bmasih memblokir\b/,
209
+ /\bmasalah masih ada\b/,
210
+ /\bpemblokir tersisa\b(?![^.!?]*\b(?:sudah|telah) (?:diperbaiki|diselesaikan|ditangani)\b)/,
211
+ ]
212
+
137
213
  // Negative warn phrases re-assert a block ("not done yet") instead of closing it
138
214
  // out, so they are NOT close-out attempts — the re-review guard must ignore them.
139
- const WARN_NEGATIVE: readonly RegExp[] = [/\bneeds changes\b/, /\bstill needs work\b/]
215
+ const WARN_NEGATIVE: readonly RegExp[] = [/\bneeds changes\b/, /\bstill needs work\b/, ...HOLD_OPEN]
140
216
 
141
217
  const WARN: readonly RegExp[] = [...WARN_POSITIVE_CLOSEOUT, ...WARN_NEGATIVE]
142
218
 
@@ -145,7 +221,7 @@ const WARN: readonly RegExp[] = [...WARN_POSITIVE_CLOSEOUT, ...WARN_NEGATIVE]
145
221
  // (answering a question) is the worst false-positive class, so it is checked first.
146
222
  const DEMOTE_TO_IGNORE: readonly RegExp[] = [
147
223
  /\b(haven'?t|have not|did ?n'?t|did not|not yet|never)\b[^.!?]*\b(approv|request|resolv|block|address)/,
148
- /\b(can'?t|cannot|won'?t|will not|wouldn'?t)\b[^.!?]*\b(approv|request|resolv|block|address)/,
224
+ /\b(can(?:not|'?t|\s+t)|won(?:'?t|\s+t)|will not|wouldn(?:'?t|\s+t))\b[^.!?]*\b(approv|request|resolv|block|address)/,
149
225
  /\bnot (approved|resolved|blocked|requesting|addressed)\b/,
150
226
  /\b(not|no longer|hardly|barely)\b[^.!?]*\b(lgtm|looks good|looks fine|seems fine|should be (fine|good)|looks resolved|seems resolved)\b/,
151
227
  /\b(i'?ll|i will|going to|gonna|about to|planning to)\b[^.!?]*\b(approv|review|request|resolv)/,
@@ -200,9 +276,12 @@ export function classifyReviewClaim(rawText: string): ReviewClaim {
200
276
 
201
277
  const claims = segments.map(classifySegment)
202
278
 
279
+ // Formal-verdict receipts remain load-bearing even in a mixed message; unlike
280
+ // resolve chatter, letting a fabricated APPROVE/REQUEST_CHANGES through can
281
+ // falsify GitHub state. The hold-open veto is therefore deliberately narrower.
203
282
  if (claims.includes('block-approve')) return 'block-approve'
204
283
  if (claims.includes('block-request-changes')) return 'block-request-changes'
205
- if (claims.includes('block-resolve')) return 'block-resolve'
284
+ if (claims.includes('block-resolve') && !hasHoldOpenClaim(segments)) return 'block-resolve'
206
285
  if (claims.includes('warn')) return 'warn'
207
286
  return 'ignore'
208
287
  }
@@ -213,7 +292,9 @@ export function classifyReviewClaim(rawText: string): ReviewClaim {
213
292
  // escalate just the stranding-shaped warns, not the whole warn bucket.
214
293
  export function isPositiveWarnCloseout(rawText: string): boolean {
215
294
  if (classifyReviewClaim(rawText) !== 'warn') return false
216
- return claimSegments(rawText).some((segment) => WARN_POSITIVE_CLOSEOUT.some((re) => re.test(segment)))
295
+ const segments = claimSegments(rawText)
296
+ if (hasHoldOpenClaim(segments)) return false
297
+ return segments.some((segment) => WARN_POSITIVE_CLOSEOUT.some((re) => re.test(segment)))
217
298
  }
218
299
 
219
300
  function classifySegment(text: string): ReviewClaim {
@@ -229,6 +310,10 @@ function classifySegment(text: string): ReviewClaim {
229
310
  return 'ignore'
230
311
  }
231
312
 
313
+ function hasHoldOpenClaim(segments: readonly string[]): boolean {
314
+ return segments.some((segment) => HOLD_OPEN.some((re) => re.test(segment)))
315
+ }
316
+
232
317
  function claimSegments(text: string): string[] {
233
318
  return redactQuotedAndCode(text)
234
319
  .split(/(?<=[.!?])\s+|\n+/)
@@ -1,3 +1,4 @@
1
+ import { describeError } from './describe-error'
1
2
  // Decoupled from ChannelRouter on purpose: minting a token for an arbitrary
2
3
  // bash `gh` command is adjacent to channels but is not routing, and a global
3
4
  // singleton would leak resolver state across tests. One instance is created in
@@ -34,7 +35,7 @@ export function createGithubTokenBridge(): GithubTokenBridge {
34
35
  const token = await resolver(repoSlug)
35
36
  return { kind: 'token', token }
36
37
  } catch (err) {
37
- return { kind: 'unavailable', reason: err instanceof Error ? err.message : String(err) }
38
+ return { kind: 'unavailable', reason: describeError(err) }
38
39
  }
39
40
  },
40
41
  hasAppTokenResolver: () => current !== null,