typeclaw 0.49.0 → 0.50.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 (442) hide show
  1. package/dist/types/agent/attention-escalation.d.ts +18 -0
  2. package/dist/types/agent/auth.d.ts +7 -0
  3. package/dist/types/agent/compaction.d.ts +8 -0
  4. package/dist/types/agent/git-nudge.d.ts +6 -0
  5. package/dist/types/agent/guard-types.d.ts +25 -0
  6. package/dist/types/agent/guards.d.ts +7 -0
  7. package/dist/types/agent/idle-compaction.d.ts +7 -0
  8. package/dist/types/agent/index.d.ts +163 -0
  9. package/dist/types/agent/live-subagents.d.ts +113 -0
  10. package/dist/types/agent/llm-replay-sanitizer.d.ts +11 -0
  11. package/dist/types/agent/loop-guard.d.ts +67 -0
  12. package/dist/types/agent/model-fallback.d.ts +29 -0
  13. package/dist/types/agent/model-overrides.d.ts +8 -0
  14. package/dist/types/agent/multimodal/index.d.ts +2 -0
  15. package/dist/types/agent/multimodal/look-at.d.ts +60 -0
  16. package/dist/types/agent/multimodal/looker.d.ts +61 -0
  17. package/dist/types/agent/multimodal/read-redirect.d.ts +6 -0
  18. package/dist/types/agent/network/response-body.d.ts +1 -0
  19. package/dist/types/agent/network/safe-http.d.ts +46 -0
  20. package/dist/types/agent/plugin-tools.d.ts +129 -0
  21. package/dist/types/agent/proactive-next-step-nudge.d.ts +2 -0
  22. package/dist/types/agent/prompt-cache-key.d.ts +3 -0
  23. package/dist/types/agent/provider-error.d.ts +23 -0
  24. package/dist/types/agent/reload-tool.d.ts +10 -0
  25. package/dist/types/agent/restart/index.d.ts +31 -0
  26. package/dist/types/agent/restart-handoff/index.d.ts +32 -0
  27. package/dist/types/agent/restart-handoff/paths.d.ts +1 -0
  28. package/dist/types/agent/retry-same-ref.d.ts +41 -0
  29. package/dist/types/agent/reviewer-activity.d.ts +3 -0
  30. package/dist/types/agent/reviewer-bash-policy.d.ts +8 -0
  31. package/dist/types/agent/self.d.ts +1 -0
  32. package/dist/types/agent/session-meta.d.ts +28 -0
  33. package/dist/types/agent/session-origin.d.ts +65 -0
  34. package/dist/types/agent/subagent-cache-keepalive.d.ts +38 -0
  35. package/dist/types/agent/subagent-completion-reminder.d.ts +29 -0
  36. package/dist/types/agent/subagent-drain.d.ts +25 -0
  37. package/dist/types/agent/subagent-session.d.ts +3 -0
  38. package/dist/types/agent/subagents.d.ts +153 -0
  39. package/dist/types/agent/system-prompt.d.ts +7 -0
  40. package/dist/types/agent/throttle-circuit.d.ts +25 -0
  41. package/dist/types/agent/todo/continuation-policy.d.ts +54 -0
  42. package/dist/types/agent/todo/continuation-state.d.ts +11 -0
  43. package/dist/types/agent/todo/continuation-wiring.d.ts +32 -0
  44. package/dist/types/agent/todo/continuation.d.ts +21 -0
  45. package/dist/types/agent/todo/scope.d.ts +6 -0
  46. package/dist/types/agent/todo/store.d.ts +16 -0
  47. package/dist/types/agent/tool-error-remediation.d.ts +1 -0
  48. package/dist/types/agent/tool-file-safety.d.ts +78 -0
  49. package/dist/types/agent/tool-not-found-nudge.d.ts +9 -0
  50. package/dist/types/agent/tool-result-budget.d.ts +15 -0
  51. package/dist/types/agent/tools/channel-disengage.d.ts +18 -0
  52. package/dist/types/agent/tools/channel-edit.d.ts +19 -0
  53. package/dist/types/agent/tools/channel-fetch-attachment.d.ts +36 -0
  54. package/dist/types/agent/tools/channel-handoff.d.ts +13 -0
  55. package/dist/types/agent/tools/channel-history-render.d.ts +3 -0
  56. package/dist/types/agent/tools/channel-history.d.ts +25 -0
  57. package/dist/types/agent/tools/channel-log.d.ts +5 -0
  58. package/dist/types/agent/tools/channel-react.d.ts +23 -0
  59. package/dist/types/agent/tools/channel-read.d.ts +27 -0
  60. package/dist/types/agent/tools/channel-reply.d.ts +47 -0
  61. package/dist/types/agent/tools/channel-send.d.ts +42 -0
  62. package/dist/types/agent/tools/channel-session-search.d.ts +10 -0
  63. package/dist/types/agent/tools/curl-impersonate.d.ts +37 -0
  64. package/dist/types/agent/tools/ddg.d.ts +18 -0
  65. package/dist/types/agent/tools/grant-role.d.ts +25 -0
  66. package/dist/types/agent/tools/keyed-semaphore.d.ts +10 -0
  67. package/dist/types/agent/tools/post-github-review.d.ts +38 -0
  68. package/dist/types/agent/tools/restart.d.ts +25 -0
  69. package/dist/types/agent/tools/runtime-notice.d.ts +3 -0
  70. package/dist/types/agent/tools/search-retry.d.ts +16 -0
  71. package/dist/types/agent/tools/skip-response.d.ts +17 -0
  72. package/dist/types/agent/tools/spawn-subagent.d.ts +77 -0
  73. package/dist/types/agent/tools/stream-snapshot.d.ts +23 -0
  74. package/dist/types/agent/tools/subagent-access.d.ts +20 -0
  75. package/dist/types/agent/tools/subagent-cancel.d.ts +23 -0
  76. package/dist/types/agent/tools/subagent-output.d.ts +50 -0
  77. package/dist/types/agent/tools/todo/index.d.ts +14 -0
  78. package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +29 -0
  79. package/dist/types/agent/tools/webfetch/fetch.d.ts +26 -0
  80. package/dist/types/agent/tools/webfetch/html-lexical.d.ts +27 -0
  81. package/dist/types/agent/tools/webfetch/index.d.ts +1 -0
  82. package/dist/types/agent/tools/webfetch/inline-style-visibility.d.ts +3 -0
  83. package/dist/types/agent/tools/webfetch/strategies/grep.d.ts +11 -0
  84. package/dist/types/agent/tools/webfetch/strategies/jq.d.ts +4 -0
  85. package/dist/types/agent/tools/webfetch/strategies/raw.d.ts +1 -0
  86. package/dist/types/agent/tools/webfetch/strategies/readability.d.ts +16 -0
  87. package/dist/types/agent/tools/webfetch/strategies/selector.d.ts +4 -0
  88. package/dist/types/agent/tools/webfetch/strategies/snapshot.d.ts +1 -0
  89. package/dist/types/agent/tools/webfetch/tool.d.ts +15 -0
  90. package/dist/types/agent/tools/webfetch/types.d.ts +32 -0
  91. package/dist/types/agent/tools/websearch.d.ts +17 -0
  92. package/dist/types/agent/tools/wikipedia.d.ts +7 -0
  93. package/dist/types/agent/tools-without-local-file-operands.d.ts +1 -0
  94. package/dist/types/agent/turn-runner.d.ts +36 -0
  95. package/dist/types/agent-messenger/config-dir.d.ts +19 -0
  96. package/dist/types/browser/dockerfile.d.ts +2 -0
  97. package/dist/types/browser/registry.d.ts +49 -0
  98. package/dist/types/bundled-plugins/bun-hygiene/policy.d.ts +18 -0
  99. package/dist/types/bundled-plugins/github-cli-auth/git-askpass.d.ts +5 -0
  100. package/dist/types/bundled-plugins/guard/keys.d.ts +6 -0
  101. package/dist/types/bundled-plugins/guard/policies/managed-config.d.ts +7 -0
  102. package/dist/types/bundled-plugins/guard/policies/memory-topics-delete.d.ts +11 -0
  103. package/dist/types/bundled-plugins/guard/policies/memory-topics-write.d.ts +7 -0
  104. package/dist/types/bundled-plugins/guard/policies/non-workspace-write.d.ts +9 -0
  105. package/dist/types/bundled-plugins/guard/policies/skill-authoring.d.ts +20 -0
  106. package/dist/types/bundled-plugins/guard/policies/uncommitted-changes.d.ts +12 -0
  107. package/dist/types/bundled-plugins/guard/policy.d.ts +11 -0
  108. package/dist/types/bundled-plugins/memory/secret-detector.d.ts +11 -0
  109. package/dist/types/bundled-plugins/memory/slug.d.ts +4 -0
  110. package/dist/types/bundled-plugins/security/permissions.d.ts +20 -0
  111. package/dist/types/bundled-plugins/security/policies/private-surface-read.d.ts +34 -0
  112. package/dist/types/bundled-plugins/security/policies/ssrf.d.ts +18 -0
  113. package/dist/types/bundled-plugins/security/policy.d.ts +4 -0
  114. package/dist/types/channels/adapter-namespace.d.ts +2 -0
  115. package/dist/types/channels/adapters/mention-hints.d.ts +12 -0
  116. package/dist/types/channels/adapters/webex-id-ref.d.ts +5 -0
  117. package/dist/types/channels/background-handoff.d.ts +56 -0
  118. package/dist/types/channels/background-obligations.d.ts +135 -0
  119. package/dist/types/channels/catch-up.d.ts +26 -0
  120. package/dist/types/channels/commands.d.ts +2 -0
  121. package/dist/types/channels/completion-claim.d.ts +20 -0
  122. package/dist/types/channels/continuation-willingness.d.ts +1 -0
  123. package/dist/types/channels/continuity-types.d.ts +75 -0
  124. package/dist/types/channels/describe-error.d.ts +1 -0
  125. package/dist/types/channels/engagement.d.ts +34 -0
  126. package/dist/types/channels/github-false-receipt.d.ts +20 -0
  127. package/dist/types/channels/github-repo.d.ts +2 -0
  128. package/dist/types/channels/github-rereview-guard.d.ts +24 -0
  129. package/dist/types/channels/github-review-check.d.ts +135 -0
  130. package/dist/types/channels/github-review-claim.d.ts +3 -0
  131. package/dist/types/channels/github-review-turn-ledger.d.ts +71 -0
  132. package/dist/types/channels/github-review-verdict-coordinator.d.ts +117 -0
  133. package/dist/types/channels/github-token-bridge.d.ts +20 -0
  134. package/dist/types/channels/github-verdict-activity.d.ts +12 -0
  135. package/dist/types/channels/inbound-journal.d.ts +272 -0
  136. package/dist/types/channels/last-alive.d.ts +3 -0
  137. package/dist/types/channels/membership-cache.d.ts +27 -0
  138. package/dist/types/channels/membership.d.ts +21 -0
  139. package/dist/types/channels/outbound-flood-filter.d.ts +7 -0
  140. package/dist/types/channels/participants.d.ts +4 -0
  141. package/dist/types/channels/persistence.d.ts +32 -0
  142. package/dist/types/channels/recovery-notice.d.ts +26 -0
  143. package/dist/types/channels/recovery-outbox.d.ts +58 -0
  144. package/dist/types/channels/router.d.ts +798 -0
  145. package/dist/types/channels/schema.d.ts +501 -0
  146. package/dist/types/channels/session-handoff.d.ts +58 -0
  147. package/dist/types/channels/session-search.d.ts +29 -0
  148. package/dist/types/channels/types.d.ts +414 -0
  149. package/dist/types/channels/waiting-reactions.d.ts +25 -0
  150. package/dist/types/cli/builtins.d.ts +2 -0
  151. package/dist/types/cli/command-meta.d.ts +9 -0
  152. package/dist/types/coding-agent/broker-body.d.ts +7 -0
  153. package/dist/types/coding-agent/broker.d.ts +22 -0
  154. package/dist/types/coding-agent/claude.d.ts +22 -0
  155. package/dist/types/coding-agent/codex.d.ts +19 -0
  156. package/dist/types/coding-agent/index.d.ts +71 -0
  157. package/dist/types/coding-agent/omo-state.d.ts +2 -0
  158. package/dist/types/coding-agent/omo-stream.d.ts +22 -0
  159. package/dist/types/coding-agent/omo.d.ts +133 -0
  160. package/dist/types/coding-agent/runner.d.ts +35 -0
  161. package/dist/types/coding-agent/tool.d.ts +27 -0
  162. package/dist/types/coding-agent/worktree.d.ts +22 -0
  163. package/dist/types/commands/index.d.ts +45 -0
  164. package/dist/types/config/config.d.ts +814 -0
  165. package/dist/types/config/index.d.ts +3 -0
  166. package/dist/types/config/model-overrides.d.ts +3 -0
  167. package/dist/types/config/providers.d.ts +1456 -0
  168. package/dist/types/config/reloadable.d.ts +9 -0
  169. package/dist/types/container/agent-operation-lock.d.ts +31 -0
  170. package/dist/types/container/build-cache.d.ts +39 -0
  171. package/dist/types/container/compose-project.d.ts +1 -0
  172. package/dist/types/container/controller.d.ts +25 -0
  173. package/dist/types/container/docker-app.d.ts +23 -0
  174. package/dist/types/container/exit-reason.d.ts +10 -0
  175. package/dist/types/container/index.d.ts +14 -0
  176. package/dist/types/container/log-archive.d.ts +68 -0
  177. package/dist/types/container/log-colors.d.ts +3 -0
  178. package/dist/types/container/log-timestamps.d.ts +9 -0
  179. package/dist/types/container/logs.d.ts +37 -0
  180. package/dist/types/container/memory-limit.d.ts +13 -0
  181. package/dist/types/container/memory-oversubscription.d.ts +20 -0
  182. package/dist/types/container/oom-events.d.ts +18 -0
  183. package/dist/types/container/port.d.ts +18 -0
  184. package/dist/types/container/require-running.d.ts +16 -0
  185. package/dist/types/container/restart.d.ts +32 -0
  186. package/dist/types/container/shared.d.ts +93 -0
  187. package/dist/types/container/shell.d.ts +35 -0
  188. package/dist/types/container/start.d.ts +144 -0
  189. package/dist/types/container/stats.d.ts +31 -0
  190. package/dist/types/container/status.d.ts +25 -0
  191. package/dist/types/container/stop.d.ts +24 -0
  192. package/dist/types/container/tool-oom-priority.d.ts +4 -0
  193. package/dist/types/container/verify-running.d.ts +49 -0
  194. package/dist/types/cron/consumer.d.ts +42 -0
  195. package/dist/types/cron/count-state.d.ts +24 -0
  196. package/dist/types/cron/index.d.ts +21 -0
  197. package/dist/types/cron/list.d.ts +33 -0
  198. package/dist/types/cron/reloadable.d.ts +11 -0
  199. package/dist/types/cron/scheduler.d.ts +51 -0
  200. package/dist/types/cron/schema.d.ts +108 -0
  201. package/dist/types/dependencies/bin-resolver.d.ts +28 -0
  202. package/dist/types/dependencies/bins.d.ts +22 -0
  203. package/dist/types/dependencies/index.d.ts +2 -0
  204. package/dist/types/git/bound-gc-config.d.ts +4 -0
  205. package/dist/types/git/hookless.d.ts +1 -0
  206. package/dist/types/git/reconcile-ignored.d.ts +13 -0
  207. package/dist/types/git/resolve-agent-git.d.ts +8 -0
  208. package/dist/types/git/resolve-identity.d.ts +10 -0
  209. package/dist/types/git/run.d.ts +24 -0
  210. package/dist/types/git/system-commit.d.ts +2 -0
  211. package/dist/types/hostd/client.d.ts +13 -0
  212. package/dist/types/hostd/models.d.ts +1 -0
  213. package/dist/types/hostd/paths.d.ts +17 -0
  214. package/dist/types/hostd/protocol.d.ts +93 -0
  215. package/dist/types/hostd/spawn.d.ts +17 -0
  216. package/dist/types/hostd/version.d.ts +18 -0
  217. package/dist/types/init/auto-upgrade.d.ts +41 -0
  218. package/dist/types/init/cli-version.d.ts +7 -0
  219. package/dist/types/init/dockerfile.d.ts +34 -0
  220. package/dist/types/init/ensure-deps.d.ts +17 -0
  221. package/dist/types/init/env-file.d.ts +3 -0
  222. package/dist/types/init/gitignore.d.ts +5 -0
  223. package/dist/types/init/local-source-stamp.d.ts +3 -0
  224. package/dist/types/init/packagejson.d.ts +7 -0
  225. package/dist/types/init/paths.d.ts +3 -0
  226. package/dist/types/init/reconcile-plugin-deps.d.ts +13 -0
  227. package/dist/types/init/run-bun-install.d.ts +16 -0
  228. package/dist/types/init/windows-dev-link.d.ts +8 -0
  229. package/dist/types/mcp/catalog.d.ts +7 -0
  230. package/dist/types/mcp/client.d.ts +58 -0
  231. package/dist/types/mcp/manager.d.ts +56 -0
  232. package/dist/types/mcp/tools.d.ts +23 -0
  233. package/dist/types/models/embedding-model.d.ts +20 -0
  234. package/dist/types/models/transformers-version.d.ts +1 -0
  235. package/dist/types/network/internal-destinations.d.ts +29 -0
  236. package/dist/types/operations/classify-tool-outcome.d.ts +35 -0
  237. package/dist/types/operations/incidents.d.ts +47 -0
  238. package/dist/types/operations/index.d.ts +3 -0
  239. package/dist/types/operations/remediations.d.ts +25 -0
  240. package/dist/types/path-safety/real-intended-path.d.ts +9 -0
  241. package/dist/types/permissions/builtins.d.ts +25 -0
  242. package/dist/types/permissions/grant.d.ts +19 -0
  243. package/dist/types/permissions/index.d.ts +6 -0
  244. package/dist/types/permissions/match-rule.d.ts +28 -0
  245. package/dist/types/permissions/permissions.d.ts +42 -0
  246. package/dist/types/permissions/resolve.d.ts +25 -0
  247. package/dist/types/permissions/schema.d.ts +14 -0
  248. package/dist/types/plugin/context.d.ts +20 -0
  249. package/dist/types/plugin/core-tool-names.d.ts +4 -0
  250. package/dist/types/plugin/define.d.ts +46 -0
  251. package/dist/types/plugin/hooks.d.ts +52 -0
  252. package/dist/types/plugin/index.d.ts +11 -0
  253. package/dist/types/plugin/load-skill.d.ts +14 -0
  254. package/dist/types/plugin/loader.d.ts +25 -0
  255. package/dist/types/plugin/manager.d.ts +42 -0
  256. package/dist/types/plugin/registry.d.ts +73 -0
  257. package/dist/types/plugin/skills.d.ts +11 -0
  258. package/dist/types/plugin/types.d.ts +336 -0
  259. package/dist/types/plugin/zod-introspect.d.ts +11 -0
  260. package/dist/types/reload/client.d.ts +11 -0
  261. package/dist/types/reload/docker-exec-client.d.ts +11 -0
  262. package/dist/types/reload/format.d.ts +2 -0
  263. package/dist/types/reload/index.d.ts +6 -0
  264. package/dist/types/reload/recover.d.ts +22 -0
  265. package/dist/types/reload/registry.d.ts +10 -0
  266. package/dist/types/reload/types.d.ts +25 -0
  267. package/dist/types/role-claim/client.d.ts +20 -0
  268. package/dist/types/role-claim/code.d.ts +4 -0
  269. package/dist/types/role-claim/controller.d.ts +59 -0
  270. package/dist/types/role-claim/index.d.ts +6 -0
  271. package/dist/types/role-claim/match-rule.d.ts +9 -0
  272. package/dist/types/role-claim/pending.d.ts +35 -0
  273. package/dist/types/role-claim/reload-after-claim.d.ts +16 -0
  274. package/dist/types/run/llm-fetch-observer.d.ts +50 -0
  275. package/dist/types/sandbox/availability.d.ts +21 -0
  276. package/dist/types/sandbox/build.d.ts +7 -0
  277. package/dist/types/sandbox/canonical-secrets.d.ts +8 -0
  278. package/dist/types/sandbox/coding-agent.d.ts +20 -0
  279. package/dist/types/sandbox/dependency-bins.d.ts +19 -0
  280. package/dist/types/sandbox/dev-source.d.ts +4 -0
  281. package/dist/types/sandbox/env-exposure.d.ts +1 -0
  282. package/dist/types/sandbox/errors.d.ts +20 -0
  283. package/dist/types/sandbox/hidden-paths.d.ts +11 -0
  284. package/dist/types/sandbox/index.d.ts +14 -0
  285. package/dist/types/sandbox/package-install.d.ts +1 -0
  286. package/dist/types/sandbox/policy.d.ts +71 -0
  287. package/dist/types/sandbox/privileged-runtime.d.ts +13 -0
  288. package/dist/types/sandbox/quote.d.ts +2 -0
  289. package/dist/types/sandbox/runtime-private.d.ts +1 -0
  290. package/dist/types/sandbox/session-tmp.d.ts +6 -0
  291. package/dist/types/sandbox/symlinks.d.ts +6 -0
  292. package/dist/types/sandbox/writable-zones.d.ts +15 -0
  293. package/dist/types/secrets/coding-agent-auth.d.ts +25 -0
  294. package/dist/types/secrets/defaults.d.ts +21 -0
  295. package/dist/types/secrets/export-github-cli-store.d.ts +22 -0
  296. package/dist/types/secrets/hydrate.d.ts +7 -0
  297. package/dist/types/secrets/index.d.ts +7 -0
  298. package/dist/types/secrets/provision-github-cli-store.d.ts +45 -0
  299. package/dist/types/secrets/refresh-provider-oauth.d.ts +22 -0
  300. package/dist/types/secrets/resolve.d.ts +14 -0
  301. package/dist/types/secrets/schema.d.ts +840 -0
  302. package/dist/types/secrets/storage.d.ts +56 -0
  303. package/dist/types/shared/host-locale.d.ts +1 -0
  304. package/dist/types/shared/index.d.ts +5 -0
  305. package/dist/types/shared/local-time.d.ts +4 -0
  306. package/dist/types/shared/platform.d.ts +2 -0
  307. package/dist/types/shared/protocol.d.ts +424 -0
  308. package/dist/types/shared/style-text.d.ts +3 -0
  309. package/dist/types/shared/wsl.d.ts +17 -0
  310. package/dist/types/stream/broker.d.ts +2 -0
  311. package/dist/types/stream/index.d.ts +2 -0
  312. package/dist/types/stream/types.d.ts +71 -0
  313. package/package.json +9 -2
  314. package/scripts/build-plugin-types.ts +105 -0
  315. package/scripts/check-plugin-sdk.ts +111 -0
  316. package/scripts/require-parallel.ts +5 -32
  317. package/src/agent/guard-types.ts +3 -0
  318. package/src/agent/guards.ts +4 -0
  319. package/src/agent/idle-compaction.ts +174 -0
  320. package/src/agent/index.ts +74 -16
  321. package/src/agent/live-subagents.ts +19 -0
  322. package/src/agent/multimodal/look-at.ts +22 -9
  323. package/src/agent/plugin-tools.ts +13 -1
  324. package/src/agent/reviewer-bash-policy.ts +41 -1
  325. package/src/agent/session-origin.ts +26 -10
  326. package/src/agent/subagent-cache-keepalive.ts +198 -0
  327. package/src/agent/subagent-session.ts +6 -0
  328. package/src/agent/subagents.ts +46 -8
  329. package/src/agent/system-prompt.ts +1 -1
  330. package/src/agent/tool-file-safety.ts +6 -1
  331. package/src/agent/tools/channel-edit.ts +20 -10
  332. package/src/agent/tools/channel-fetch-attachment.ts +12 -5
  333. package/src/agent/tools/channel-handoff.ts +72 -0
  334. package/src/agent/tools/channel-read.ts +57 -10
  335. package/src/agent/tools/channel-reply.ts +33 -26
  336. package/src/agent/tools/channel-send.ts +21 -13
  337. package/src/agent/tools/channel-session-search.ts +35 -0
  338. package/src/agent/tools/curl-impersonate.ts +11 -4
  339. package/src/agent/tools/ddg.ts +13 -5
  340. package/src/agent/tools/spawn-subagent.ts +27 -11
  341. package/src/agent/tools/stream-snapshot.ts +15 -2
  342. package/src/agent/tools/subagent-access.ts +11 -4
  343. package/src/browser/bsk-shim.mjs +74 -0
  344. package/src/browser/dockerfile.ts +84 -0
  345. package/src/browser/egress.ts +104 -0
  346. package/src/browser/managed-browser.ts +205 -0
  347. package/src/browser/registry.ts +110 -0
  348. package/src/browser/relay.ts +231 -0
  349. package/src/browser/sandbox-entry.ts +167 -0
  350. package/src/bundled-plugins/agent-browser/index.ts +2 -0
  351. package/src/bundled-plugins/browser-agent/browser-agent.ts +89 -0
  352. package/src/bundled-plugins/browser-agent/index.ts +12 -0
  353. package/src/bundled-plugins/doc-render/index.ts +0 -10
  354. package/src/bundled-plugins/doc-render/render.ts +83 -111
  355. package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +152 -257
  356. package/src/bundled-plugins/github-cli-auth/gh-command.ts +4 -0
  357. package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
  358. package/src/bundled-plugins/github-cli-auth/index.ts +75 -59
  359. package/src/bundled-plugins/managed-browser/index.ts +74 -0
  360. package/src/bundled-plugins/managed-browser/skills/browser-use/browser-use/SKILL.md +27 -0
  361. package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +28 -0
  362. package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +40 -0
  363. package/src/bundled-plugins/operator/operator.ts +1 -1
  364. package/src/bundled-plugins/qa/index.ts +11 -0
  365. package/src/bundled-plugins/qa/qa.ts +160 -0
  366. package/src/bundled-plugins/qa/skills/qa-cli.ts +50 -0
  367. package/src/bundled-plugins/qa/skills/qa-general.ts +30 -0
  368. package/src/bundled-plugins/qa/skills/qa-http.ts +39 -0
  369. package/src/bundled-plugins/qa/skills/qa-pr.ts +51 -0
  370. package/src/bundled-plugins/qa/skills/qa-web.ts +49 -0
  371. package/src/bundled-plugins/security/index.ts +53 -34
  372. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
  373. package/src/channels/adapter-namespace.ts +13 -0
  374. package/src/channels/adapters/discord-bot.ts +97 -5
  375. package/src/channels/adapters/github/index.ts +16 -0
  376. package/src/channels/adapters/github/last-alive.ts +4 -16
  377. package/src/channels/adapters/slack-attachment-download.ts +14 -3
  378. package/src/channels/adapters/slack-bot-author-resolver.ts +4 -3
  379. package/src/channels/adapters/slack-bot-channel-resolver.ts +9 -6
  380. package/src/channels/adapters/slack-bot-classify.ts +1 -0
  381. package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
  382. package/src/channels/adapters/slack-bot.ts +299 -67
  383. package/src/channels/adapters/slack-classify.ts +1 -0
  384. package/src/channels/catch-up.ts +137 -0
  385. package/src/channels/continuation-willingness.ts +2 -2
  386. package/src/channels/continuity-types.ts +1 -0
  387. package/src/channels/engagement.ts +17 -1
  388. package/src/channels/github-false-receipt.ts +3 -3
  389. package/src/channels/github-rereview-guard.ts +9 -5
  390. package/src/channels/github-token-bridge.ts +24 -0
  391. package/src/channels/last-alive.ts +34 -0
  392. package/src/channels/manager.ts +8 -1
  393. package/src/channels/router.ts +427 -136
  394. package/src/channels/session-handoff.fixture.ts +144 -0
  395. package/src/channels/session-handoff.ts +175 -0
  396. package/src/channels/session-search.ts +71 -0
  397. package/src/channels/types.ts +12 -2
  398. package/src/cli/channel.ts +2 -3
  399. package/src/cli/init.ts +2 -3
  400. package/src/cli/model.ts +132 -3
  401. package/src/coding-agent/index.ts +7 -1
  402. package/src/coding-agent/omo-stream.ts +40 -0
  403. package/src/coding-agent/runner.ts +30 -8
  404. package/src/config/config.ts +111 -22
  405. package/src/config/model-overrides.ts +59 -0
  406. package/src/config/models-mutation.ts +185 -2
  407. package/src/config/providers-mutation.ts +12 -4
  408. package/src/config/providers.ts +59 -0
  409. package/src/container/start.ts +95 -4
  410. package/src/doctor/checks.ts +8 -6
  411. package/src/hostd/daemon.ts +13 -1
  412. package/src/init/auto-upgrade.ts +7 -1
  413. package/src/init/dockerfile.ts +57 -12
  414. package/src/init/index.ts +4 -3
  415. package/src/init/local-source-stamp.ts +68 -0
  416. package/src/init/models-dev.ts +4 -0
  417. package/src/init/validate-api-key.ts +3 -0
  418. package/src/permissions/builtins.ts +7 -0
  419. package/src/permissions/permissions.ts +18 -9
  420. package/src/permissions/resolve.ts +7 -1
  421. package/src/plugin/context.ts +2 -0
  422. package/src/plugin/hooks.ts +137 -0
  423. package/src/plugin/index.ts +6 -0
  424. package/src/plugin/manager.ts +4 -0
  425. package/src/plugin/types.ts +60 -0
  426. package/src/run/bundled-plugins.ts +6 -0
  427. package/src/run/index.ts +24 -14
  428. package/src/run/llm-fetch-observer.ts +12 -15
  429. package/src/sandbox/canonical-secrets.ts +4 -0
  430. package/src/sandbox/dev-source.ts +26 -0
  431. package/src/sandbox/hidden-paths.ts +16 -2
  432. package/src/secrets/storage.ts +13 -0
  433. package/src/skills/typeclaw-channel-github/SKILL.md +8 -8
  434. package/src/skills/typeclaw-config/SKILL.md +39 -5
  435. package/src/skills/typeclaw-config/references/dockerfile.md +2 -2
  436. package/src/skills/typeclaw-github-contributing/SKILL.md +1 -1
  437. package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
  438. package/src/skills/typeclaw-permissions/SKILL.md +7 -7
  439. package/src/skills/typeclaw-troubleshooting/SKILL.md +12 -1
  440. package/typeclaw.schema.json +436 -5
  441. package/src/bundled-plugins/doc-render/templates/lib.typ +0 -339
  442. package/src/bundled-plugins/github-cli-auth/gh-store.ts +0 -733
@@ -5,6 +5,7 @@ import {
5
5
  type SlackSocketModeSlashCommandArgs,
6
6
  } from 'agent-messenger/slackbot'
7
7
 
8
+ import { CATCH_UP_CONVERSATION_LIMIT, type ListMissedInbound, type MissedInbound } from '@/channels/catch-up'
8
9
  import { DEFAULT_ATTACHMENT_MAX_BYTES, enforceAttachmentMetadataSize } from '@/channels/fetch-attachment'
9
10
  import {
10
11
  MEMBERSHIP_CACHE_TRANSIENT_TTL_MS,
@@ -15,10 +16,11 @@ import {
15
16
  type MembershipResolverResult,
16
17
  } from '@/channels/membership'
17
18
  import { deriveMembershipFromHistory } from '@/channels/membership-from-history'
18
- import type { ChannelRouter } from '@/channels/router'
19
+ import type { ChannelRouter, ExecuteCommandResult } from '@/channels/router'
19
20
  import type { ChannelAdapterConfig } from '@/channels/schema'
20
21
  import type {
21
22
  ChannelHistoryMessage,
23
+ ChannelKey,
22
24
  ChannelListEntry,
23
25
  ChannelSelfIdentityResolver,
24
26
  FetchAttachmentCallback,
@@ -39,6 +41,7 @@ import type {
39
41
  TypingTarget,
40
42
  } from '@/channels/types'
41
43
  import { chunkMarkdown } from '@/markdown'
44
+ import type { ChannelMessageObservedEvent, ChannelOutboundBeforeEvent, SlackObservedMessage } from '@/plugin'
42
45
 
43
46
  import { describeError } from '../describe-error'
44
47
  import { addSlackMentionHints } from './mention-hints'
@@ -72,6 +75,7 @@ import {
72
75
  parseThreadCommand,
73
76
  SLACK_SLASH_REPLY_FAILED,
74
77
  type ThreadCommandInput,
78
+ type SlashAckPayload,
75
79
  } from './slack-bot-slash-commands'
76
80
  import { slackTsToMillis } from './slack-bot-time'
77
81
  import { toSlackMrkdwn } from './slack-format'
@@ -104,74 +108,80 @@ export type SlackBotAdapterLoggerLike = {
104
108
  }
105
109
 
106
110
  export type SlashCommandHandlerDeps = {
107
- router: Pick<ChannelRouter, 'executeCommand'>
111
+ router: Pick<ChannelRouter, 'executeCommand'> & Partial<Pick<ChannelRouter, 'reviewOutbound' | 'hasOutboundReviewer'>>
108
112
  knownCommandNames: ReadonlySet<string>
109
113
  logger: SlackBotAdapterLoggerLike
110
114
  formatChannelTag: (workspace: string, chat: string) => Promise<string>
115
+ postSlashResponse?: (url: string, payload: SlashAckPayload) => Promise<number>
111
116
  }
112
117
 
113
- // Ack-first invariant: the handler must call args.ack() exactly once on
114
- // every path AND must do so before any slow network work (resolver calls,
115
- // post-ack logging). Slack's 3s ack deadline starts when the slash command
116
- // envelope arrives on the WebSocket; missing it shows the user
117
- // "/stop didn't respond in time". The synchronous executeCommand happy
118
- // path is fast (in-memory map lookup + abort), so ack-after-execute is
119
- // safe; everything else (formatChannelTag, post-ack logging) runs after.
120
- //
121
- // Ack failure handling: a thrown ack on the happy path is logged but does
122
- // NOT trigger the catch-all error-ack below, which would attempt a second
123
- // ack call and break the exactly-once contract.
118
+ // With a reviewer, acknowledge immediately and publish exactly one ephemeral
119
+ // response through Slack's response_url. Slow review must not consume Slack's
120
+ // three-second transport-ack budget. Without a safe response URL, fail open to
121
+ // the original immediate ack rather than losing an authorized command response.
124
122
  export function createSlashCommandHandler(
125
123
  deps: SlashCommandHandlerDeps,
126
124
  ): (args: SlackSocketModeSlashCommandArgs) => Promise<void> {
127
125
  return async ({ ack, body }) => {
126
+ const responseUrl = safeSlashResponseUrl(body.response_url)
127
+ const deferred =
128
+ deps.router.hasOutboundReviewer?.() === true &&
129
+ deps.router.reviewOutbound !== undefined &&
130
+ deps.postSlashResponse !== undefined &&
131
+ responseUrl !== undefined
132
+ const acknowledge = (text?: string) => {
133
+ try {
134
+ if (text === undefined) ack()
135
+ else ack(buildSlashAckPayload(text))
136
+ } catch {
137
+ // Ack is attempted once, even if the transport throws.
138
+ deps.logger.warn('[slack-bot] slash command ack failed')
139
+ }
140
+ }
141
+ if (deferred) acknowledge()
142
+ const reply = async (text: string, workspace: string, chat: string) => {
143
+ if (!deferred) {
144
+ acknowledge(text)
145
+ return
146
+ }
147
+ const reviewed = await reviewControlReply(deps, {
148
+ adapter: 'slack-bot',
149
+ workspace,
150
+ chat,
151
+ text,
152
+ op: 'send',
153
+ source: 'system',
154
+ outputKind: 'meta',
155
+ })
156
+ try {
157
+ const status = await deps.postSlashResponse!(responseUrl!, buildSlashAckPayload(reviewed))
158
+ if (status < 200 || status >= 300) {
159
+ deps.logger.warn(`[slack-bot] slash response failed status=${status}`)
160
+ }
161
+ } catch {
162
+ // response_url is a credential; neither it nor the HTTP error is logged.
163
+ deps.logger.warn('[slack-bot] slash response transport failed')
164
+ }
165
+ }
128
166
  const parsed = parseSlashCommand(body, deps.knownCommandNames)
129
167
  if (parsed.kind === 'ignore') {
130
168
  deps.logger.warn(`[slack-bot] slash command dropped reason=${parsed.reason} command=${body.command}`)
131
- try {
132
- ack(buildSlashAckPayload(SLACK_SLASH_REPLY_FAILED))
133
- } catch (err) {
134
- deps.logger.warn(`[slack-bot] slash command ack (drop path) failed: ${describeError(err)}`)
135
- }
169
+ await reply(SLACK_SLASH_REPLY_FAILED, body.team_id ?? '', body.channel_id ?? '')
136
170
  return
137
171
  }
138
172
  const { command } = parsed
139
-
140
- // Pre-ACK log: bare ids only (no formatChannelTag — would burn ack budget
141
- // on a slow Slack API minute via the channel-name resolver).
142
173
  deps.logger.info(
143
174
  `[slack-bot] slash /${command.name} invoker=${command.invokerId} team=${command.key.workspace} channel=${command.key.chat}`,
144
175
  )
145
-
146
- let result: Awaited<ReturnType<typeof deps.router.executeCommand>>
176
+ let result: ExecuteCommandResult
147
177
  try {
148
- result = await deps.router.executeCommand(command.key, command.name, {
149
- invokerId: command.invokerId,
150
- })
178
+ result = await deps.router.executeCommand(command.key, command.name, { invokerId: command.invokerId })
151
179
  } catch (err) {
152
180
  deps.logger.error(`[slack-bot] slash command handler failed: ${describeError(err)}`)
153
- try {
154
- ack(buildSlashAckPayload(SLACK_SLASH_REPLY_FAILED))
155
- } catch (ackErr) {
156
- deps.logger.warn(`[slack-bot] slash command error-ack failed: ${describeError(ackErr)}`)
157
- }
181
+ await reply(SLACK_SLASH_REPLY_FAILED, command.key.workspace, command.key.chat)
158
182
  return
159
183
  }
160
-
161
- const replyContent = commandResultReply(result)
162
-
163
- // Final ack on the happy path: own try/catch so a thrown ack here does
164
- // NOT cascade into the error-path ack above (which would violate the
165
- // exactly-once contract). The abort already happened server-side; only
166
- // the user-visible confirmation is lost.
167
- try {
168
- ack(buildSlashAckPayload(replyContent))
169
- } catch (err) {
170
- deps.logger.warn(`[slack-bot] slash command ack failed: ${describeError(err)}`)
171
- }
172
-
173
- // Decorative post-ack logging: resolve channel names now that the 3s
174
- // budget is no longer a concern. Best-effort.
184
+ await reply(commandResultReply(result), command.key.workspace, command.key.chat)
175
185
  try {
176
186
  const inboundTag = await deps.formatChannelTag(command.key.workspace, command.key.chat)
177
187
  deps.logger.info(`[slack-bot] slash /${command.name} result=${result.kind} ${inboundTag}`)
@@ -183,6 +193,60 @@ export function createSlashCommandHandler(
183
193
  }
184
194
  }
185
195
 
196
+ // Restart starts SIGTERM before its reply is posted; run's shutdown deadline is
197
+ // eight seconds. A slow copy editor must not consume that entire delivery window.
198
+ export const SLACK_CONTROL_REVIEW_TIMEOUT_MS = 1_000
199
+
200
+ function reviewControlReply(
201
+ deps: Pick<SlashCommandHandlerDeps, 'router' | 'logger'>,
202
+ event: ChannelOutboundBeforeEvent,
203
+ ): Promise<string> {
204
+ return new Promise((resolve) => {
205
+ let settled = false
206
+ const finish = (text: string, failure?: string) => {
207
+ if (settled) return
208
+ settled = true
209
+ clearTimeout(timer)
210
+ if (failure) {
211
+ try {
212
+ deps.logger.warn(`[slack-bot] control response review ${failure}; retaining original`)
213
+ } catch {
214
+ // Logging cannot turn review into a delivery gate.
215
+ }
216
+ }
217
+ resolve(text)
218
+ }
219
+ const timer = setTimeout(() => finish(event.text, 'timed out'), SLACK_CONTROL_REVIEW_TIMEOUT_MS)
220
+ Promise.resolve()
221
+ .then(() => deps.router.reviewOutbound!(event))
222
+ .then(
223
+ (text) => finish(text),
224
+ () => finish(event.text, 'failed'),
225
+ )
226
+ })
227
+ }
228
+
229
+ function safeSlashResponseUrl(value: unknown): string | undefined {
230
+ if (typeof value !== 'string') return undefined
231
+ try {
232
+ const url = new URL(value)
233
+ if (
234
+ url.protocol === 'https:' &&
235
+ (url.hostname === 'hooks.slack.com' || url.hostname === 'hooks.slack-gov.com') &&
236
+ url.port === '' &&
237
+ url.username === '' &&
238
+ url.password === '' &&
239
+ url.pathname.startsWith('/commands/') &&
240
+ url.search === '' &&
241
+ url.hash === ''
242
+ )
243
+ return url.href
244
+ } catch {
245
+ // Malformed transport metadata is not permission to contact another host.
246
+ }
247
+ return undefined
248
+ }
249
+
186
250
  export type ThreadCommandReplyPoster = (args: { chat: string; thread: string | null; text: string }) => Promise<void>
187
251
 
188
252
  export type ThreadCommandHandlerDeps = {
@@ -284,6 +348,11 @@ const consoleLogger: SlackBotAdapterLogger = {
284
348
  error: (m) => console.error(m),
285
349
  }
286
350
 
351
+ export type SlackMessageObserver = {
352
+ readonly active: () => boolean
353
+ readonly observe: (event: ChannelMessageObservedEvent) => void
354
+ }
355
+
287
356
  export type SlackBotAdapterOptions = {
288
357
  router: ChannelRouter
289
358
  configRef: () => ChannelAdapterConfig
@@ -295,6 +364,7 @@ export type SlackBotAdapterOptions = {
295
364
  // classifier behaves as before (no alias-driven thread anchoring), so
296
365
  // tests and ad-hoc adapter constructions stay backwards-compatible.
297
366
  selfAliasesRef?: () => readonly string[]
367
+ messageObserver?: SlackMessageObserver
298
368
  fetchImpl?: typeof fetch
299
369
  createClient?: () => SlackBotClient
300
370
  createListener?: (client: SlackBotClient, appToken: string) => SlackBotListener
@@ -430,6 +500,9 @@ type SlackRawHistoryMessage = {
430
500
  thread_ts?: string
431
501
  parent_user_id?: string
432
502
  files?: SlackFile[]
503
+ edited?: { user: string; ts: string }
504
+ reply_count?: number
505
+ latest_reply?: string
433
506
  }
434
507
 
435
508
  type SlackHistoryResponse = {
@@ -714,24 +787,9 @@ export function createSlackHistoryCallback(deps: {
714
787
  const fetchFn = deps.fetchImpl ?? fetch
715
788
  return async (args: FetchHistoryArgs): Promise<FetchHistoryResult> => {
716
789
  const limit = clampLimit(args.limit, SLACK_HISTORY_LIMIT_MAX)
717
- const endpoint = args.thread === null ? 'conversations.history' : 'conversations.replies'
718
- const body = new URLSearchParams()
719
- body.set('channel', args.chat)
720
- body.set('limit', String(limit))
721
- if (args.thread !== null) body.set('ts', args.thread)
722
- if (args.cursor !== undefined && args.cursor !== '') body.set('cursor', args.cursor)
723
-
724
790
  let raw: SlackHistoryResponse
725
791
  try {
726
- const response = await fetchFn(`${SLACK_API_BASE}/${endpoint}`, {
727
- method: 'POST',
728
- headers: {
729
- Authorization: `Bearer ${token}`,
730
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
731
- },
732
- body: body.toString(),
733
- })
734
- raw = (await response.json()) as SlackHistoryResponse
792
+ raw = await fetchSlackHistoryPage(token, fetchFn, { ...args, limit })
735
793
  } catch (err) {
736
794
  const message = describeError(err)
737
795
  logger.warn(`[slack-bot] history fetch failed: ${message}`)
@@ -775,6 +833,121 @@ export function createSlackHistoryCallback(deps: {
775
833
  }
776
834
  }
777
835
 
836
+ async function fetchSlackHistoryPage(
837
+ token: string,
838
+ fetchFn: typeof fetch,
839
+ args: FetchHistoryArgs & { since?: number },
840
+ ): Promise<SlackHistoryResponse> {
841
+ const body = new URLSearchParams({ channel: args.chat, limit: String(args.limit) })
842
+ if (args.thread !== null) body.set('ts', args.thread)
843
+ if (args.cursor) body.set('cursor', args.cursor)
844
+ if (args.since !== undefined) body.set('oldest', String(args.since / 1000))
845
+ const endpoint = args.thread === null ? 'conversations.history' : 'conversations.replies'
846
+ const response = await fetchFn(`${SLACK_API_BASE}/${endpoint}`, {
847
+ method: 'POST',
848
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' },
849
+ body: body.toString(),
850
+ })
851
+ return (await response.json()) as SlackHistoryResponse
852
+ }
853
+
854
+ export function createSlackMissedInboundCallback(deps: {
855
+ token: string
856
+ logger: SlackBotAdapterLogger
857
+ configRef: () => ChannelAdapterConfig
858
+ identity: () => { teamId: string; botUserId: string } | null
859
+ targets: () => Promise<readonly ChannelKey[]>
860
+ selfAliases: () => readonly string[]
861
+ fetchImpl?: typeof fetch
862
+ }): ListMissedInbound {
863
+ const fetchFn = deps.fetchImpl ?? fetch
864
+ const list = createSlackListCallback(deps)
865
+ const getRoot = createSlackMessageGetCallback({
866
+ token: deps.token,
867
+ logger: deps.logger,
868
+ fetchImpl: fetchFn,
869
+ botUserIdRef: () => deps.identity()?.botUserId ?? null,
870
+ })
871
+ return async (since) => {
872
+ const identity = deps.identity()
873
+ if (!identity) return []
874
+ const scopes = new Map<string, ChannelKey>()
875
+ const add = (key: ChannelKey) => scopes.set(`${key.chat}:${key.thread ?? ''}`, key)
876
+ // Persisted sessions include watched thread roots older than the history
877
+ // window. Query them directly; channel history does not include replies.
878
+ for (const key of await deps.targets()) add(key)
879
+ const channels = await list({ workspace: identity.teamId, limit: 200 })
880
+ if (!channels.ok) throw new Error(channels.error)
881
+ for (const channel of channels.entries) {
882
+ if (channel.isMember !== true && channel.kind !== 'dm' && channel.kind !== 'group') continue
883
+ add({
884
+ adapter: 'slack-bot',
885
+ workspace: channel.kind === 'dm' ? '@dm' : identity.teamId,
886
+ chat: channel.chat,
887
+ thread: null,
888
+ })
889
+ }
890
+ const result: MissedInbound[] = []
891
+ let calls = 0
892
+ // New roots discovered in history can append thread scopes to this map.
893
+ for (const key of scopes.values()) {
894
+ if (calls++ >= CATCH_UP_CONVERSATION_LIMIT) break
895
+ const page = await fetchSlackHistoryPage(deps.token, fetchFn, {
896
+ chat: key.chat,
897
+ thread: key.thread,
898
+ limit: 100,
899
+ since,
900
+ })
901
+ if (!page.ok) {
902
+ deps.logger.warn(`[slack-bot] catch-up history ${key.chat} failed: ${page.error ?? 'unknown slack error'}`)
903
+ if (page.error === 'not_in_channel' || page.error === 'channel_not_found') continue
904
+ throw new Error(page.error ?? 'Slack catch-up history unavailable')
905
+ }
906
+ const rows = page.messages ?? []
907
+ const latestTs = Math.max(0, ...rows.map((row) => slackTsToMillis(row.ts)))
908
+ let rootAuthor = key.thread === null ? undefined : rows.find((row) => row.ts === key.thread)?.user
909
+ // Replies are oldest-first: an incomplete page cannot prove the thread
910
+ // has not moved on, so skip rather than answer an obsolete message.
911
+ if (key.thread !== null && page.response_metadata?.next_cursor) {
912
+ deps.logger.info(`[slack-bot] catch-up skipped incomplete thread ${key.chat}/${key.thread}`)
913
+ continue
914
+ }
915
+ if (key.thread !== null && rows.length > 0 && rootAuthor === undefined) {
916
+ if (calls++ >= CATCH_UP_CONVERSATION_LIMIT) break
917
+ const root = await getRoot({ chat: key.chat, thread: null, messageId: key.thread })
918
+ if (!root.ok) continue
919
+ rootAuthor = root.message.authorId
920
+ }
921
+ for (const row of rows) {
922
+ if (key.thread === null && (row.reply_count ?? 0) > 0) {
923
+ add({ ...key, thread: row.ts })
924
+ }
925
+ if (slackTsToMillis(row.ts) < since) continue
926
+ const verdict = classifyInbound(
927
+ {
928
+ ...row,
929
+ type: 'message',
930
+ channel: key.chat,
931
+ channel_type: key.workspace === '@dm' ? 'im' : 'channel',
932
+ ...(key.thread !== null ? { thread_ts: key.thread, parent_user_id: row.parent_user_id ?? rootAuthor } : {}),
933
+ },
934
+ deps.configRef(),
935
+ { ...identity, selfAliases: deps.selfAliases() },
936
+ )
937
+ if (verdict.kind !== 'route') continue
938
+ result.push({
939
+ message: verdict.payload,
940
+ latestTs:
941
+ key.thread === null
942
+ ? Math.max(latestTs, row.latest_reply === undefined ? 0 : slackTsToMillis(row.latest_reply))
943
+ : latestTs,
944
+ })
945
+ }
946
+ }
947
+ return result.sort((a, b) => a.message.ts - b.message.ts)
948
+ }
949
+ }
950
+
778
951
  // Fetch one message by ts. Slack has no by-id endpoint, so we window
779
952
  // conversations.history (channel root) or conversations.replies (thread) to a
780
953
  // single ts via oldest=latest=messageId, inclusive=true, limit=1 — without the
@@ -1184,8 +1357,8 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1184
1357
  let inflightInbounds = 0
1185
1358
  let stopWaiters: Array<() => void> = []
1186
1359
 
1187
- const authorResolver = createSlackAuthorResolver({ token: options.token })
1188
- const channelResolver = createSlackChannelResolver({ token: options.token })
1360
+ const authorResolver = createSlackAuthorResolver({ token: options.token, fetchImpl })
1361
+ const channelResolver = createSlackChannelResolver({ token: options.token, fetchImpl })
1189
1362
 
1190
1363
  // Slack mentions by id (`<@U…>`), so no username form. Read live off the
1191
1364
  // closure so a reconnect re-running auth.test stays reflected; one team
@@ -1224,6 +1397,15 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1224
1397
  })
1225
1398
 
1226
1399
  const listCallback = createSlackListCallback({ token: options.token, logger })
1400
+ const missedInbound = createSlackMissedInboundCallback({
1401
+ token: options.token,
1402
+ logger,
1403
+ configRef: options.configRef,
1404
+ fetchImpl,
1405
+ identity: () => (botUserId !== null && teamId !== null ? { botUserId, teamId } : null),
1406
+ targets: () => options.router.catchUpTargets('slack-bot'),
1407
+ selfAliases: () => options.selfAliasesRef?.() ?? [],
1408
+ })
1227
1409
 
1228
1410
  const membershipResolver = createSlackMembershipResolver({
1229
1411
  token: options.token,
@@ -1263,6 +1445,18 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1263
1445
  knownCommandNames: SLACK_SLASH_COMMAND_NAMES,
1264
1446
  logger,
1265
1447
  formatChannelTag,
1448
+ postSlashResponse: async (url, payload) => {
1449
+ const response = await fetchImpl(url, {
1450
+ method: 'POST',
1451
+ redirect: 'error',
1452
+ signal: AbortSignal.timeout(5_000),
1453
+ headers: { 'Content-Type': 'application/json; charset=utf-8' },
1454
+ body: JSON.stringify(payload),
1455
+ })
1456
+ // Consume no response text: it can contain private content.
1457
+ await response.body?.cancel()
1458
+ return response.status
1459
+ },
1266
1460
  })
1267
1461
 
1268
1462
  const handleThreadCommand = createThreadCommandHandler({
@@ -1270,12 +1464,28 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1270
1464
  knownCommandNames: SLACK_SLASH_COMMAND_NAMES,
1271
1465
  logger,
1272
1466
  postReply: async ({ chat, thread, text }) => {
1467
+ const workspace = teamId ?? 'unknown'
1468
+ const reviewed = options.router.hasOutboundReviewer?.()
1469
+ ? await reviewControlReply(
1470
+ { router: options.router, logger },
1471
+ {
1472
+ adapter: 'slack-bot',
1473
+ workspace,
1474
+ chat,
1475
+ ...(thread !== null ? { thread } : {}),
1476
+ text,
1477
+ op: 'send',
1478
+ source: 'system',
1479
+ outputKind: 'meta',
1480
+ },
1481
+ )
1482
+ : text
1273
1483
  const result = await outboundCallback({
1274
1484
  adapter: 'slack-bot',
1275
- workspace: teamId ?? 'unknown',
1485
+ workspace,
1276
1486
  chat,
1277
1487
  ...(thread !== null ? { thread } : {}),
1278
- text,
1488
+ text: reviewed,
1279
1489
  })
1280
1490
  if (!result.ok) {
1281
1491
  throw new Error(result.error)
@@ -1440,20 +1650,39 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1440
1650
  new SlackBotListener(client, { appToken: options.appToken })
1441
1651
  listener.on('connected', (info) => {
1442
1652
  socketConnected = started
1653
+ if (started) void options.router.catchUp('slack-bot')
1443
1654
  logger.info(`[slack-bot] connected (app_id=${info.app_id ?? 'unknown'})`)
1444
1655
  })
1445
1656
  listener.on('disconnected', () => {
1446
1657
  socketConnected = false
1658
+ options.router.disconnectCatchUp('slack-bot')
1447
1659
  logger.warn('[slack-bot] disconnected; SDK will reconnect with backoff')
1448
1660
  })
1449
1661
  listener.on('error', (err) => {
1450
- if (recordValue(err)?.code === 'disconnect_terminal') socketConnected = false
1662
+ if (recordValue(err)?.code === 'disconnect_terminal') {
1663
+ socketConnected = false
1664
+ options.router.disconnectCatchUp('slack-bot')
1665
+ }
1451
1666
  logger.error(`[slack-bot] socket-mode error: ${describeError(err)}`)
1452
1667
  })
1453
1668
  listener.on('message', ({ ack, event }) => {
1454
1669
  // Ack first so Slack stops retrying; failure to ack causes duplicate
1455
1670
  // deliveries within seconds. Then process asynchronously.
1456
1671
  ack()
1672
+ const observer = options.messageObserver
1673
+ try {
1674
+ if (observer?.active()) {
1675
+ observer.observe({
1676
+ adapter: 'slack-bot',
1677
+ workspace: teamId,
1678
+ selfUserId: botUserId,
1679
+ receivedAt: Date.now(),
1680
+ event: event as SlackObservedMessage,
1681
+ })
1682
+ }
1683
+ } catch {
1684
+ logger.warn('[slack-bot] raw message observer dispatch failed')
1685
+ }
1457
1686
  // Cast at the SDK boundary: upstream types this event with a
1458
1687
  // `[key: string]: unknown` catchall for fields it does not
1459
1688
  // declare (parent_user_id, client_msg_id, files). The Slack
@@ -1499,6 +1728,7 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1499
1728
  options.router.registerChannelNameResolver('slack-bot', channelResolver)
1500
1729
  options.router.registerSelfIdentity('slack-bot', selfIdentityResolver)
1501
1730
  options.router.registerHistory('slack-bot', historyCallback)
1731
+ options.router.registerMissedInbound('slack-bot', missedInbound)
1502
1732
  options.router.registerMessageGet('slack-bot', messageGetCallback)
1503
1733
  options.router.registerList('slack-bot', listCallback)
1504
1734
  options.router.registerEditMessage('slack-bot', editMessageCallback)
@@ -1523,6 +1753,7 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1523
1753
  options.router.unregisterChannelNameResolver('slack-bot', channelResolver)
1524
1754
  options.router.unregisterSelfIdentity('slack-bot', selfIdentityResolver)
1525
1755
  options.router.unregisterHistory('slack-bot', historyCallback)
1756
+ options.router.unregisterMissedInbound('slack-bot', missedInbound)
1526
1757
  options.router.unregisterMessageGet('slack-bot', messageGetCallback)
1527
1758
  options.router.unregisterList('slack-bot', listCallback)
1528
1759
  options.router.unregisterEditMessage('slack-bot', editMessageCallback)
@@ -1542,6 +1773,7 @@ export function createSlackBotAdapter(options: SlackBotAdapterOptions): SlackBot
1542
1773
  if (!started) return
1543
1774
  started = false
1544
1775
  socketConnected = false
1776
+ options.router.unregisterMissedInbound('slack-bot', missedInbound)
1545
1777
  options.router.unregisterOutbound('slack-bot', outboundCallback)
1546
1778
  options.router.unregisterReaction('slack-bot', reactionCallback)
1547
1779
  options.router.unregisterRemoveReaction('slack-bot', removeReactionCallback)
@@ -143,6 +143,7 @@ function describeSlackFile(file: SlackFile, index: number): InboundAttachment {
143
143
 
144
144
  function renderPlaceholder(attachment: InboundAttachment): string {
145
145
  const parts: string[] = [`Slack attachment #${attachment.id}: ${attachment.kind}`]
146
+ parts.push(`file_id=${attachment.ref}`)
146
147
  if (attachment.mimetype !== undefined) parts.push(attachment.mimetype)
147
148
  if (attachment.filename !== undefined) parts.push(`name=${attachment.filename}`)
148
149
  return `[${parts.join(' ')}]`
@@ -0,0 +1,137 @@
1
+ import { describeError } from './describe-error'
2
+ import { readLastAlive, writeLastAlive } from './last-alive'
3
+ import type { AdapterId } from './schema'
4
+ import type { InboundMessage, RouteReceipt } from './types'
5
+
6
+ export const CHAT_CATCH_UP_MAX_AGE_MS = 15 * 60 * 1000
7
+ export const CATCH_UP_HEARTBEAT_MS = 30 * 1000
8
+ export const CATCH_UP_CONVERSATION_LIMIT = 20
9
+
10
+ export type MissedInbound = {
11
+ readonly message: InboundMessage
12
+ // Latest post in the source conversation, including self/system posts that
13
+ // classification drops. Slack's reply-routing anchor is NOT this scope.
14
+ readonly latestTs: number
15
+ }
16
+ export type ListMissedInbound = (since: number) => Promise<readonly MissedInbound[]>
17
+
18
+ export function createInboundCatchUp(options: {
19
+ agentDir: string
20
+ route: (message: InboundMessage) => Promise<RouteReceipt>
21
+ logger: { info: (message: string) => void; warn: (message: string) => void }
22
+ now?: () => number
23
+ }) {
24
+ const now = options.now ?? Date.now
25
+ // Admission dedup is durable in the router journal. Observation has no
26
+ // journal row, so retain those live receipts for the chat replay window.
27
+ const observed = new Map<string, number>()
28
+ const observationKey = (message: InboundMessage) =>
29
+ JSON.stringify([
30
+ message.adapter,
31
+ message.accountIdentity,
32
+ message.workspace,
33
+ message.chat,
34
+ message.externalMessageId,
35
+ message.authorId,
36
+ message.eventKind,
37
+ message.revision,
38
+ ])
39
+ const states = new Map<
40
+ AdapterId,
41
+ {
42
+ callback: ListMissedInbound
43
+ connected: boolean
44
+ generation: number
45
+ healthy: boolean
46
+ since: Promise<number | null>
47
+ lane: Promise<void>
48
+ }
49
+ >()
50
+
51
+ const run = (adapter: AdapterId): Promise<void> => {
52
+ const state = states.get(adapter)
53
+ if (!state) return Promise.resolve()
54
+ state.connected = true
55
+ const generation = state.generation
56
+ const active = () => states.get(adapter) === state && state.connected && state.generation === generation
57
+ const task = state.lane.then(async () => {
58
+ if (!active()) return
59
+ const at = now()
60
+ const since = (await state.since) ?? at
61
+ const items = await state.callback(Math.max(since, at - CHAT_CATCH_UP_MAX_AGE_MS))
62
+ for (const { message, latestTs } of items) {
63
+ if (!active()) return
64
+ if (message.adapter !== adapter) throw new Error('Catch-up adapter identity mismatch')
65
+ const stale = message.ts < now() - CHAT_CATCH_UP_MAX_AGE_MS || message.ts <= 0
66
+ const movedOn = latestTs > message.ts
67
+ if (message.ts < since || stale || movedOn) {
68
+ options.logger.info(
69
+ `[channels] catch-up ${adapter} dropped id=${message.externalMessageId} reason=${movedOn ? 'moved-on' : 'stale'}`,
70
+ )
71
+ continue
72
+ }
73
+ if ((observed.get(observationKey(message)) ?? 0) > now()) continue
74
+ // The live router owns durable admission dedup and engagement. Never
75
+ // mark replay as an explicit mention or manufacture a wake-up.
76
+ await options.route(message)
77
+ }
78
+ if (!active()) return
79
+ await writeLastAlive(options.agentDir, adapter, at)
80
+ state.since = Promise.resolve(at)
81
+ state.healthy = true
82
+ })
83
+ state.healthy = false
84
+ state.lane = task.catch((error: unknown) => {
85
+ options.logger.warn(`[channels] catch-up ${adapter} failed: ${describeError(error)}`)
86
+ })
87
+ return state.lane
88
+ }
89
+
90
+ // This timer only persists liveness; it never lists history or replays chat.
91
+ const heartbeat = setInterval(() => {
92
+ for (const [adapter, state] of states) {
93
+ if (!state.connected || !state.healthy) continue
94
+ state.lane = state.lane
95
+ .then(async () => {
96
+ if (states.get(adapter) !== state || !state.connected || !state.healthy) return
97
+ const at = now()
98
+ await writeLastAlive(options.agentDir, adapter, at)
99
+ state.since = Promise.resolve(at)
100
+ })
101
+ .catch((error: unknown) => {
102
+ options.logger.warn(`[channels] catch-up heartbeat ${adapter} failed: ${describeError(error)}`)
103
+ })
104
+ }
105
+ }, CATCH_UP_HEARTBEAT_MS)
106
+ heartbeat.unref?.()
107
+
108
+ return {
109
+ noteObserved(message: InboundMessage): void {
110
+ const at = now()
111
+ for (const [key, expires] of observed) if (expires <= at) observed.delete(key)
112
+ observed.set(observationKey(message), at + CHAT_CATCH_UP_MAX_AGE_MS)
113
+ },
114
+ register(adapter: AdapterId, callback: ListMissedInbound): void {
115
+ const since = readLastAlive(options.agentDir, adapter)
116
+ // Defer a read failure into the run's operator-only error boundary.
117
+ void since.catch(() => undefined)
118
+ states.set(adapter, { callback, connected: false, generation: 0, healthy: false, since, lane: Promise.resolve() })
119
+ },
120
+ unregister(adapter: AdapterId, callback: ListMissedInbound): void {
121
+ if (states.get(adapter)?.callback === callback) states.delete(adapter)
122
+ },
123
+ disconnect(adapter: AdapterId): void {
124
+ const state = states.get(adapter)
125
+ if (!state) return
126
+ state.connected = false
127
+ state.generation++
128
+ },
129
+ run,
130
+ async stop(): Promise<void> {
131
+ clearInterval(heartbeat)
132
+ const pending = [...states.values()].map((state) => state.lane)
133
+ states.clear()
134
+ await Promise.all(pending)
135
+ },
136
+ }
137
+ }