typeclaw 0.49.0 → 0.51.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 (502) 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/bash-sandbox-env.d.ts +15 -0
  4. package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
  5. package/dist/types/agent/bash-sandbox.d.ts +94 -0
  6. package/dist/types/agent/compaction.d.ts +8 -0
  7. package/dist/types/agent/git-nudge.d.ts +6 -0
  8. package/dist/types/agent/guard-types.d.ts +25 -0
  9. package/dist/types/agent/guards.d.ts +7 -0
  10. package/dist/types/agent/idle-compaction.d.ts +8 -0
  11. package/dist/types/agent/index.d.ts +151 -0
  12. package/dist/types/agent/live-subagents.d.ts +113 -0
  13. package/dist/types/agent/llm-replay-sanitizer.d.ts +11 -0
  14. package/dist/types/agent/loop-guard.d.ts +67 -0
  15. package/dist/types/agent/model-fallback.d.ts +29 -0
  16. package/dist/types/agent/model-overrides.d.ts +8 -0
  17. package/dist/types/agent/multimodal/index.d.ts +2 -0
  18. package/dist/types/agent/multimodal/look-at.d.ts +60 -0
  19. package/dist/types/agent/multimodal/looker.d.ts +61 -0
  20. package/dist/types/agent/multimodal/read-redirect.d.ts +6 -0
  21. package/dist/types/agent/network/response-body.d.ts +1 -0
  22. package/dist/types/agent/network/safe-http.d.ts +46 -0
  23. package/dist/types/agent/output-allowance.d.ts +4 -0
  24. package/dist/types/agent/plugin-tools.d.ts +58 -0
  25. package/dist/types/agent/proactive-next-step-nudge.d.ts +2 -0
  26. package/dist/types/agent/prompt-cache-key.d.ts +3 -0
  27. package/dist/types/agent/provider-error.d.ts +23 -0
  28. package/dist/types/agent/reload-tool.d.ts +10 -0
  29. package/dist/types/agent/restart/index.d.ts +31 -0
  30. package/dist/types/agent/restart-handoff/index.d.ts +32 -0
  31. package/dist/types/agent/restart-handoff/paths.d.ts +1 -0
  32. package/dist/types/agent/retry-same-ref.d.ts +41 -0
  33. package/dist/types/agent/reviewer-activity.d.ts +3 -0
  34. package/dist/types/agent/reviewer-bash-policy.d.ts +8 -0
  35. package/dist/types/agent/self.d.ts +1 -0
  36. package/dist/types/agent/session-meta.d.ts +28 -0
  37. package/dist/types/agent/session-origin.d.ts +65 -0
  38. package/dist/types/agent/subagent-cache-keepalive.d.ts +38 -0
  39. package/dist/types/agent/subagent-completion-reminder.d.ts +29 -0
  40. package/dist/types/agent/subagent-drain.d.ts +25 -0
  41. package/dist/types/agent/subagent-session.d.ts +3 -0
  42. package/dist/types/agent/subagents.d.ts +153 -0
  43. package/dist/types/agent/system-prompt-composition.d.ts +17 -0
  44. package/dist/types/agent/system-prompt.d.ts +7 -0
  45. package/dist/types/agent/throttle-circuit.d.ts +25 -0
  46. package/dist/types/agent/todo/continuation-policy.d.ts +54 -0
  47. package/dist/types/agent/todo/continuation-state.d.ts +11 -0
  48. package/dist/types/agent/todo/continuation-wiring.d.ts +32 -0
  49. package/dist/types/agent/todo/continuation.d.ts +21 -0
  50. package/dist/types/agent/todo/scope.d.ts +6 -0
  51. package/dist/types/agent/todo/store.d.ts +16 -0
  52. package/dist/types/agent/tool-error-remediation.d.ts +1 -0
  53. package/dist/types/agent/tool-file-safety.d.ts +78 -0
  54. package/dist/types/agent/tool-not-found-nudge.d.ts +9 -0
  55. package/dist/types/agent/tool-result-budget.d.ts +15 -0
  56. package/dist/types/agent/tools/channel-disengage.d.ts +18 -0
  57. package/dist/types/agent/tools/channel-edit.d.ts +19 -0
  58. package/dist/types/agent/tools/channel-fetch-attachment.d.ts +36 -0
  59. package/dist/types/agent/tools/channel-handoff.d.ts +13 -0
  60. package/dist/types/agent/tools/channel-history-render.d.ts +3 -0
  61. package/dist/types/agent/tools/channel-history.d.ts +25 -0
  62. package/dist/types/agent/tools/channel-log.d.ts +5 -0
  63. package/dist/types/agent/tools/channel-react.d.ts +23 -0
  64. package/dist/types/agent/tools/channel-read.d.ts +27 -0
  65. package/dist/types/agent/tools/channel-reply.d.ts +47 -0
  66. package/dist/types/agent/tools/channel-send.d.ts +42 -0
  67. package/dist/types/agent/tools/channel-session-search.d.ts +10 -0
  68. package/dist/types/agent/tools/curl-impersonate.d.ts +37 -0
  69. package/dist/types/agent/tools/ddg.d.ts +27 -0
  70. package/dist/types/agent/tools/grant-role.d.ts +25 -0
  71. package/dist/types/agent/tools/keyed-semaphore.d.ts +10 -0
  72. package/dist/types/agent/tools/post-github-review.d.ts +38 -0
  73. package/dist/types/agent/tools/restart.d.ts +25 -0
  74. package/dist/types/agent/tools/runtime-notice.d.ts +3 -0
  75. package/dist/types/agent/tools/search-retry.d.ts +16 -0
  76. package/dist/types/agent/tools/skip-response.d.ts +17 -0
  77. package/dist/types/agent/tools/spawn-subagent.d.ts +77 -0
  78. package/dist/types/agent/tools/stream-snapshot.d.ts +23 -0
  79. package/dist/types/agent/tools/subagent-access.d.ts +20 -0
  80. package/dist/types/agent/tools/subagent-cancel.d.ts +23 -0
  81. package/dist/types/agent/tools/subagent-output.d.ts +50 -0
  82. package/dist/types/agent/tools/todo/index.d.ts +14 -0
  83. package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +29 -0
  84. package/dist/types/agent/tools/webfetch/fetch.d.ts +26 -0
  85. package/dist/types/agent/tools/webfetch/html-lexical.d.ts +27 -0
  86. package/dist/types/agent/tools/webfetch/index.d.ts +1 -0
  87. package/dist/types/agent/tools/webfetch/inline-style-visibility.d.ts +3 -0
  88. package/dist/types/agent/tools/webfetch/strategies/grep.d.ts +11 -0
  89. package/dist/types/agent/tools/webfetch/strategies/jq.d.ts +4 -0
  90. package/dist/types/agent/tools/webfetch/strategies/raw.d.ts +1 -0
  91. package/dist/types/agent/tools/webfetch/strategies/readability.d.ts +16 -0
  92. package/dist/types/agent/tools/webfetch/strategies/selector.d.ts +4 -0
  93. package/dist/types/agent/tools/webfetch/strategies/snapshot.d.ts +1 -0
  94. package/dist/types/agent/tools/webfetch/tool.d.ts +15 -0
  95. package/dist/types/agent/tools/webfetch/types.d.ts +32 -0
  96. package/dist/types/agent/tools/websearch.d.ts +17 -0
  97. package/dist/types/agent/tools/wikipedia.d.ts +7 -0
  98. package/dist/types/agent/tools-without-local-file-operands.d.ts +1 -0
  99. package/dist/types/agent/turn-runner.d.ts +36 -0
  100. package/dist/types/agent-messenger/config-dir.d.ts +19 -0
  101. package/dist/types/browser/dockerfile.d.ts +2 -0
  102. package/dist/types/browser/registry.d.ts +49 -0
  103. package/dist/types/bundled-plugins/bun-hygiene/policy.d.ts +18 -0
  104. package/dist/types/bundled-plugins/github-cli-auth/git-askpass.d.ts +5 -0
  105. package/dist/types/bundled-plugins/guard/keys.d.ts +6 -0
  106. package/dist/types/bundled-plugins/guard/policies/managed-config.d.ts +7 -0
  107. package/dist/types/bundled-plugins/guard/policies/memory-topics-delete.d.ts +11 -0
  108. package/dist/types/bundled-plugins/guard/policies/memory-topics-write.d.ts +7 -0
  109. package/dist/types/bundled-plugins/guard/policies/non-workspace-write.d.ts +9 -0
  110. package/dist/types/bundled-plugins/guard/policies/skill-authoring.d.ts +20 -0
  111. package/dist/types/bundled-plugins/guard/policies/uncommitted-changes.d.ts +12 -0
  112. package/dist/types/bundled-plugins/guard/policy.d.ts +11 -0
  113. package/dist/types/bundled-plugins/memory/secret-detector.d.ts +11 -0
  114. package/dist/types/bundled-plugins/memory/slug.d.ts +4 -0
  115. package/dist/types/bundled-plugins/security/permissions.d.ts +20 -0
  116. package/dist/types/bundled-plugins/security/policies/private-surface-read.d.ts +34 -0
  117. package/dist/types/bundled-plugins/security/policies/ssrf.d.ts +18 -0
  118. package/dist/types/bundled-plugins/security/policy.d.ts +4 -0
  119. package/dist/types/channels/adapter-namespace.d.ts +2 -0
  120. package/dist/types/channels/adapters/mention-hints.d.ts +12 -0
  121. package/dist/types/channels/adapters/webex-id-ref.d.ts +5 -0
  122. package/dist/types/channels/background-handoff.d.ts +56 -0
  123. package/dist/types/channels/background-obligations.d.ts +135 -0
  124. package/dist/types/channels/catch-up.d.ts +26 -0
  125. package/dist/types/channels/commands.d.ts +2 -0
  126. package/dist/types/channels/completion-claim.d.ts +20 -0
  127. package/dist/types/channels/continuation-willingness.d.ts +1 -0
  128. package/dist/types/channels/continuity-types.d.ts +75 -0
  129. package/dist/types/channels/describe-error.d.ts +1 -0
  130. package/dist/types/channels/engagement.d.ts +34 -0
  131. package/dist/types/channels/github-false-receipt.d.ts +20 -0
  132. package/dist/types/channels/github-repo.d.ts +2 -0
  133. package/dist/types/channels/github-rereview-guard.d.ts +24 -0
  134. package/dist/types/channels/github-review-check.d.ts +135 -0
  135. package/dist/types/channels/github-review-claim.d.ts +3 -0
  136. package/dist/types/channels/github-review-turn-ledger.d.ts +71 -0
  137. package/dist/types/channels/github-review-verdict-coordinator.d.ts +117 -0
  138. package/dist/types/channels/github-token-bridge.d.ts +20 -0
  139. package/dist/types/channels/github-verdict-activity.d.ts +12 -0
  140. package/dist/types/channels/inbound-journal.d.ts +272 -0
  141. package/dist/types/channels/last-alive.d.ts +3 -0
  142. package/dist/types/channels/membership-cache.d.ts +27 -0
  143. package/dist/types/channels/membership.d.ts +21 -0
  144. package/dist/types/channels/outbound-flood-filter.d.ts +7 -0
  145. package/dist/types/channels/participants.d.ts +4 -0
  146. package/dist/types/channels/persistence.d.ts +32 -0
  147. package/dist/types/channels/recovery-notice.d.ts +26 -0
  148. package/dist/types/channels/recovery-outbox.d.ts +58 -0
  149. package/dist/types/channels/router.d.ts +760 -0
  150. package/dist/types/channels/schema.d.ts +501 -0
  151. package/dist/types/channels/session-handoff.d.ts +58 -0
  152. package/dist/types/channels/session-search.d.ts +29 -0
  153. package/dist/types/channels/types.d.ts +414 -0
  154. package/dist/types/channels/waiting-reactions.d.ts +25 -0
  155. package/dist/types/cli/builtins.d.ts +2 -0
  156. package/dist/types/cli/command-meta.d.ts +9 -0
  157. package/dist/types/coding-agent/broker-body.d.ts +7 -0
  158. package/dist/types/coding-agent/broker.d.ts +22 -0
  159. package/dist/types/coding-agent/claude.d.ts +22 -0
  160. package/dist/types/coding-agent/codex.d.ts +19 -0
  161. package/dist/types/coding-agent/index.d.ts +71 -0
  162. package/dist/types/coding-agent/omo-state.d.ts +2 -0
  163. package/dist/types/coding-agent/omo-stream.d.ts +22 -0
  164. package/dist/types/coding-agent/omo.d.ts +133 -0
  165. package/dist/types/coding-agent/runner.d.ts +35 -0
  166. package/dist/types/coding-agent/tool.d.ts +27 -0
  167. package/dist/types/coding-agent/worktree.d.ts +22 -0
  168. package/dist/types/commands/index.d.ts +45 -0
  169. package/dist/types/config/config.d.ts +827 -0
  170. package/dist/types/config/index.d.ts +3 -0
  171. package/dist/types/config/model-overrides.d.ts +3 -0
  172. package/dist/types/config/providers.d.ts +1458 -0
  173. package/dist/types/config/reloadable.d.ts +9 -0
  174. package/dist/types/container/agent-operation-lock.d.ts +31 -0
  175. package/dist/types/container/build-cache.d.ts +39 -0
  176. package/dist/types/container/compose-project.d.ts +1 -0
  177. package/dist/types/container/controller.d.ts +25 -0
  178. package/dist/types/container/docker-app.d.ts +23 -0
  179. package/dist/types/container/exit-reason.d.ts +10 -0
  180. package/dist/types/container/index.d.ts +14 -0
  181. package/dist/types/container/log-archive.d.ts +68 -0
  182. package/dist/types/container/log-colors.d.ts +3 -0
  183. package/dist/types/container/log-timestamps.d.ts +9 -0
  184. package/dist/types/container/logs.d.ts +37 -0
  185. package/dist/types/container/memory-limit.d.ts +13 -0
  186. package/dist/types/container/memory-oversubscription.d.ts +20 -0
  187. package/dist/types/container/oom-events.d.ts +18 -0
  188. package/dist/types/container/port.d.ts +18 -0
  189. package/dist/types/container/require-running.d.ts +16 -0
  190. package/dist/types/container/restart.d.ts +32 -0
  191. package/dist/types/container/shared.d.ts +93 -0
  192. package/dist/types/container/shell.d.ts +35 -0
  193. package/dist/types/container/start.d.ts +145 -0
  194. package/dist/types/container/stats.d.ts +31 -0
  195. package/dist/types/container/status.d.ts +25 -0
  196. package/dist/types/container/stop.d.ts +24 -0
  197. package/dist/types/container/tool-oom-priority.d.ts +4 -0
  198. package/dist/types/container/verify-running.d.ts +49 -0
  199. package/dist/types/cron/consumer.d.ts +42 -0
  200. package/dist/types/cron/count-state.d.ts +24 -0
  201. package/dist/types/cron/index.d.ts +21 -0
  202. package/dist/types/cron/list.d.ts +33 -0
  203. package/dist/types/cron/reloadable.d.ts +11 -0
  204. package/dist/types/cron/scheduler.d.ts +51 -0
  205. package/dist/types/cron/schema.d.ts +108 -0
  206. package/dist/types/dependencies/bin-resolver.d.ts +28 -0
  207. package/dist/types/dependencies/bins.d.ts +22 -0
  208. package/dist/types/dependencies/index.d.ts +2 -0
  209. package/dist/types/eval/cell.d.ts +26 -0
  210. package/dist/types/eval/config.d.ts +19 -0
  211. package/dist/types/eval/dispatch.d.ts +7 -0
  212. package/dist/types/eval/kernel.d.ts +28 -0
  213. package/dist/types/eval/process.d.ts +23 -0
  214. package/dist/types/eval/protocol.d.ts +34 -0
  215. package/dist/types/eval/sandbox.d.ts +10 -0
  216. package/dist/types/eval/tool.d.ts +17 -0
  217. package/dist/types/eval/wire.d.ts +33 -0
  218. package/dist/types/git/bound-gc-config.d.ts +4 -0
  219. package/dist/types/git/hookless.d.ts +1 -0
  220. package/dist/types/git/reconcile-ignored.d.ts +13 -0
  221. package/dist/types/git/resolve-agent-git.d.ts +8 -0
  222. package/dist/types/git/resolve-identity.d.ts +10 -0
  223. package/dist/types/git/run.d.ts +24 -0
  224. package/dist/types/git/system-commit.d.ts +2 -0
  225. package/dist/types/hostd/client.d.ts +13 -0
  226. package/dist/types/hostd/models.d.ts +1 -0
  227. package/dist/types/hostd/paths.d.ts +17 -0
  228. package/dist/types/hostd/protocol.d.ts +93 -0
  229. package/dist/types/hostd/spawn.d.ts +17 -0
  230. package/dist/types/hostd/version.d.ts +18 -0
  231. package/dist/types/init/auto-upgrade.d.ts +41 -0
  232. package/dist/types/init/cli-version.d.ts +7 -0
  233. package/dist/types/init/dockerfile.d.ts +34 -0
  234. package/dist/types/init/ensure-deps.d.ts +17 -0
  235. package/dist/types/init/env-file.d.ts +3 -0
  236. package/dist/types/init/gitignore.d.ts +5 -0
  237. package/dist/types/init/local-source-stamp.d.ts +3 -0
  238. package/dist/types/init/packagejson.d.ts +7 -0
  239. package/dist/types/init/paths.d.ts +3 -0
  240. package/dist/types/init/reconcile-plugin-deps.d.ts +13 -0
  241. package/dist/types/init/run-bun-install.d.ts +16 -0
  242. package/dist/types/init/windows-dev-link.d.ts +8 -0
  243. package/dist/types/mcp/catalog.d.ts +7 -0
  244. package/dist/types/mcp/client.d.ts +58 -0
  245. package/dist/types/mcp/manager.d.ts +56 -0
  246. package/dist/types/mcp/tools.d.ts +23 -0
  247. package/dist/types/models/embedding-model.d.ts +20 -0
  248. package/dist/types/models/transformers-version.d.ts +1 -0
  249. package/dist/types/network/internal-destinations.d.ts +29 -0
  250. package/dist/types/operations/classify-tool-outcome.d.ts +35 -0
  251. package/dist/types/operations/incidents.d.ts +47 -0
  252. package/dist/types/operations/index.d.ts +3 -0
  253. package/dist/types/operations/remediations.d.ts +25 -0
  254. package/dist/types/path-safety/real-intended-path.d.ts +9 -0
  255. package/dist/types/permissions/builtins.d.ts +25 -0
  256. package/dist/types/permissions/grant.d.ts +19 -0
  257. package/dist/types/permissions/index.d.ts +6 -0
  258. package/dist/types/permissions/match-rule.d.ts +28 -0
  259. package/dist/types/permissions/permissions.d.ts +42 -0
  260. package/dist/types/permissions/resolve.d.ts +25 -0
  261. package/dist/types/permissions/schema.d.ts +14 -0
  262. package/dist/types/plugin/context.d.ts +20 -0
  263. package/dist/types/plugin/core-tool-names.d.ts +4 -0
  264. package/dist/types/plugin/define.d.ts +46 -0
  265. package/dist/types/plugin/hooks.d.ts +52 -0
  266. package/dist/types/plugin/index.d.ts +11 -0
  267. package/dist/types/plugin/load-skill.d.ts +14 -0
  268. package/dist/types/plugin/loader.d.ts +25 -0
  269. package/dist/types/plugin/manager.d.ts +42 -0
  270. package/dist/types/plugin/registry.d.ts +73 -0
  271. package/dist/types/plugin/skills.d.ts +11 -0
  272. package/dist/types/plugin/types.d.ts +336 -0
  273. package/dist/types/plugin/zod-introspect.d.ts +11 -0
  274. package/dist/types/reload/client.d.ts +11 -0
  275. package/dist/types/reload/docker-exec-client.d.ts +11 -0
  276. package/dist/types/reload/format.d.ts +2 -0
  277. package/dist/types/reload/index.d.ts +6 -0
  278. package/dist/types/reload/recover.d.ts +22 -0
  279. package/dist/types/reload/registry.d.ts +10 -0
  280. package/dist/types/reload/types.d.ts +25 -0
  281. package/dist/types/role-claim/client.d.ts +20 -0
  282. package/dist/types/role-claim/code.d.ts +4 -0
  283. package/dist/types/role-claim/controller.d.ts +59 -0
  284. package/dist/types/role-claim/index.d.ts +6 -0
  285. package/dist/types/role-claim/match-rule.d.ts +9 -0
  286. package/dist/types/role-claim/pending.d.ts +35 -0
  287. package/dist/types/role-claim/reload-after-claim.d.ts +16 -0
  288. package/dist/types/run/llm-fetch-observer.d.ts +50 -0
  289. package/dist/types/sandbox/availability.d.ts +21 -0
  290. package/dist/types/sandbox/build.d.ts +7 -0
  291. package/dist/types/sandbox/canonical-secrets.d.ts +8 -0
  292. package/dist/types/sandbox/coding-agent.d.ts +20 -0
  293. package/dist/types/sandbox/dependency-bins.d.ts +19 -0
  294. package/dist/types/sandbox/dev-source.d.ts +4 -0
  295. package/dist/types/sandbox/env-exposure.d.ts +3 -0
  296. package/dist/types/sandbox/errors.d.ts +20 -0
  297. package/dist/types/sandbox/hidden-paths.d.ts +11 -0
  298. package/dist/types/sandbox/index.d.ts +14 -0
  299. package/dist/types/sandbox/package-install.d.ts +1 -0
  300. package/dist/types/sandbox/policy.d.ts +71 -0
  301. package/dist/types/sandbox/privileged-runtime.d.ts +13 -0
  302. package/dist/types/sandbox/quote.d.ts +2 -0
  303. package/dist/types/sandbox/runtime-private.d.ts +1 -0
  304. package/dist/types/sandbox/session-tmp.d.ts +6 -0
  305. package/dist/types/sandbox/symlinks.d.ts +6 -0
  306. package/dist/types/sandbox/writable-zones.d.ts +15 -0
  307. package/dist/types/secrets/coding-agent-auth.d.ts +25 -0
  308. package/dist/types/secrets/defaults.d.ts +21 -0
  309. package/dist/types/secrets/export-github-cli-store.d.ts +22 -0
  310. package/dist/types/secrets/hydrate.d.ts +7 -0
  311. package/dist/types/secrets/index.d.ts +7 -0
  312. package/dist/types/secrets/provision-github-cli-store.d.ts +45 -0
  313. package/dist/types/secrets/refresh-provider-oauth.d.ts +22 -0
  314. package/dist/types/secrets/resolve.d.ts +14 -0
  315. package/dist/types/secrets/schema.d.ts +840 -0
  316. package/dist/types/secrets/storage.d.ts +56 -0
  317. package/dist/types/shared/host-locale.d.ts +1 -0
  318. package/dist/types/shared/index.d.ts +5 -0
  319. package/dist/types/shared/local-time.d.ts +4 -0
  320. package/dist/types/shared/platform.d.ts +2 -0
  321. package/dist/types/shared/protocol.d.ts +424 -0
  322. package/dist/types/shared/style-text.d.ts +3 -0
  323. package/dist/types/shared/wsl.d.ts +17 -0
  324. package/dist/types/stream/broker.d.ts +2 -0
  325. package/dist/types/stream/index.d.ts +2 -0
  326. package/dist/types/stream/types.d.ts +71 -0
  327. package/package.json +13 -6
  328. package/scripts/build-plugin-types.ts +105 -0
  329. package/scripts/check-plugin-sdk.ts +111 -0
  330. package/scripts/require-parallel.ts +5 -32
  331. package/src/agent/bash-sandbox-env.ts +104 -0
  332. package/src/agent/bash-sandbox-proc.ts +70 -0
  333. package/src/agent/bash-sandbox.ts +225 -0
  334. package/src/agent/compaction.ts +22 -10
  335. package/src/agent/guard-types.ts +3 -0
  336. package/src/agent/guards.ts +4 -0
  337. package/src/agent/idle-compaction.ts +178 -0
  338. package/src/agent/index.ts +139 -172
  339. package/src/agent/live-subagents.ts +19 -0
  340. package/src/agent/multimodal/look-at.ts +22 -9
  341. package/src/agent/output-allowance.ts +7 -0
  342. package/src/agent/plugin-tools.ts +39 -377
  343. package/src/agent/reviewer-bash-policy.ts +41 -1
  344. package/src/agent/session-origin.ts +28 -11
  345. package/src/agent/subagent-cache-keepalive.ts +198 -0
  346. package/src/agent/subagent-completion-reminder.ts +2 -2
  347. package/src/agent/subagent-session.ts +6 -0
  348. package/src/agent/subagents.ts +46 -8
  349. package/src/agent/system-prompt-composition.ts +141 -0
  350. package/src/agent/system-prompt.ts +5 -5
  351. package/src/agent/todo/scope.ts +1 -1
  352. package/src/agent/tool-file-safety.ts +6 -1
  353. package/src/agent/tools/channel-edit.ts +20 -10
  354. package/src/agent/tools/channel-fetch-attachment.ts +12 -5
  355. package/src/agent/tools/channel-handoff.ts +72 -0
  356. package/src/agent/tools/channel-read.ts +57 -10
  357. package/src/agent/tools/channel-reply.ts +33 -26
  358. package/src/agent/tools/channel-send.ts +21 -13
  359. package/src/agent/tools/channel-session-search.ts +35 -0
  360. package/src/agent/tools/curl-impersonate.ts +11 -4
  361. package/src/agent/tools/ddg.ts +84 -16
  362. package/src/agent/tools/spawn-subagent.ts +27 -11
  363. package/src/agent/tools/stream-snapshot.ts +15 -2
  364. package/src/agent/tools/subagent-access.ts +11 -4
  365. package/src/agent/tools-without-local-file-operands.ts +4 -0
  366. package/src/browser/bsk-shim.mjs +74 -0
  367. package/src/browser/dockerfile.ts +84 -0
  368. package/src/browser/egress.ts +104 -0
  369. package/src/browser/fill-secret.ts +307 -0
  370. package/src/browser/managed-browser.ts +205 -0
  371. package/src/browser/registry.ts +110 -0
  372. package/src/browser/relay.ts +231 -0
  373. package/src/browser/sandbox-entry.ts +167 -0
  374. package/src/bundled-plugins/agent-browser/index.ts +2 -0
  375. package/src/bundled-plugins/browser-agent/browser-agent.ts +89 -0
  376. package/src/bundled-plugins/browser-agent/index.ts +12 -0
  377. package/src/bundled-plugins/doc-render/index.ts +0 -10
  378. package/src/bundled-plugins/doc-render/render.ts +83 -111
  379. package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +152 -257
  380. package/src/bundled-plugins/explorer/explorer.ts +1 -1
  381. package/src/bundled-plugins/github-cli-auth/gh-command.ts +4 -0
  382. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
  383. package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
  384. package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
  385. package/src/bundled-plugins/github-cli-auth/index.ts +85 -60
  386. package/src/bundled-plugins/managed-browser/index.ts +179 -0
  387. package/src/bundled-plugins/managed-browser/skills/browser-use/browser-use/SKILL.md +27 -0
  388. package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +28 -0
  389. package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +40 -0
  390. package/src/bundled-plugins/memory/dreaming.ts +4 -1
  391. package/src/bundled-plugins/memory/load-memory.ts +2 -4
  392. package/src/bundled-plugins/memory/memory-logger.ts +74 -2
  393. package/src/bundled-plugins/memory/transcript-preload.ts +103 -0
  394. package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
  395. package/src/bundled-plugins/operator/operator.ts +1 -1
  396. package/src/bundled-plugins/qa/index.ts +11 -0
  397. package/src/bundled-plugins/qa/qa.ts +160 -0
  398. package/src/bundled-plugins/qa/skills/qa-cli.ts +50 -0
  399. package/src/bundled-plugins/qa/skills/qa-general.ts +30 -0
  400. package/src/bundled-plugins/qa/skills/qa-http.ts +39 -0
  401. package/src/bundled-plugins/qa/skills/qa-pr.ts +51 -0
  402. package/src/bundled-plugins/qa/skills/qa-web.ts +49 -0
  403. package/src/bundled-plugins/security/index.ts +53 -34
  404. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
  405. package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
  406. package/src/channels/adapter-namespace.ts +13 -0
  407. package/src/channels/adapters/discord-bot-reference.ts +5 -4
  408. package/src/channels/adapters/discord-bot.ts +98 -5
  409. package/src/channels/adapters/discord-classify.ts +8 -3
  410. package/src/channels/adapters/discord.ts +29 -0
  411. package/src/channels/adapters/github/index.ts +16 -0
  412. package/src/channels/adapters/github/last-alive.ts +4 -16
  413. package/src/channels/adapters/slack-attachment-download.ts +14 -3
  414. package/src/channels/adapters/slack-bot-author-resolver.ts +4 -3
  415. package/src/channels/adapters/slack-bot-channel-resolver.ts +9 -6
  416. package/src/channels/adapters/slack-bot-classify.ts +1 -0
  417. package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
  418. package/src/channels/adapters/slack-bot.ts +299 -67
  419. package/src/channels/adapters/slack-classify.ts +1 -0
  420. package/src/channels/catch-up.ts +137 -0
  421. package/src/channels/continuation-willingness.ts +2 -2
  422. package/src/channels/continuity-types.ts +1 -0
  423. package/src/channels/engagement.ts +17 -1
  424. package/src/channels/github-false-receipt.ts +3 -3
  425. package/src/channels/github-rereview-guard.ts +9 -5
  426. package/src/channels/github-review-check.ts +5 -1
  427. package/src/channels/github-review-verdict-coordinator.ts +68 -2
  428. package/src/channels/github-token-bridge.ts +24 -0
  429. package/src/channels/last-alive.ts +34 -0
  430. package/src/channels/manager.ts +8 -1
  431. package/src/channels/router.ts +515 -243
  432. package/src/channels/session-handoff.fixture.ts +144 -0
  433. package/src/channels/session-handoff.ts +175 -0
  434. package/src/channels/session-search.ts +71 -0
  435. package/src/channels/subagent-completion-bridge.ts +3 -2
  436. package/src/channels/types.ts +12 -2
  437. package/src/cli/channel.ts +2 -3
  438. package/src/cli/hostd.ts +3 -0
  439. package/src/cli/init.ts +2 -3
  440. package/src/cli/model.ts +132 -3
  441. package/src/coding-agent/index.ts +7 -1
  442. package/src/coding-agent/omo-stream.ts +40 -0
  443. package/src/coding-agent/runner.ts +30 -8
  444. package/src/config/config.ts +126 -22
  445. package/src/config/model-overrides.ts +59 -0
  446. package/src/config/models-mutation.ts +185 -2
  447. package/src/config/providers-mutation.ts +12 -4
  448. package/src/config/providers.ts +69 -4
  449. package/src/container/start.ts +132 -5
  450. package/src/doctor/checks.ts +33 -22
  451. package/src/doctor/index.ts +48 -12
  452. package/src/doctor/operational-incidents.ts +16 -1
  453. package/src/doctor/plugin-bridge.ts +14 -1
  454. package/src/doctor/stage.ts +14 -0
  455. package/src/doctor/types.ts +6 -0
  456. package/src/eval/cell.ts +93 -0
  457. package/src/eval/config.ts +32 -0
  458. package/src/eval/dispatch.ts +67 -0
  459. package/src/eval/entry.ts +261 -0
  460. package/src/eval/kernel.ts +154 -0
  461. package/src/eval/process.ts +113 -0
  462. package/src/eval/protocol.ts +26 -0
  463. package/src/eval/redeclare.ts +174 -0
  464. package/src/eval/sandbox.ts +114 -0
  465. package/src/eval/tool.ts +98 -0
  466. package/src/eval/wire.ts +93 -0
  467. package/src/hostd/daemon.ts +13 -1
  468. package/src/init/auto-upgrade.ts +7 -1
  469. package/src/init/dockerfile.ts +57 -12
  470. package/src/init/index.ts +4 -3
  471. package/src/init/local-source-stamp.ts +68 -0
  472. package/src/init/models-dev.ts +4 -0
  473. package/src/init/validate-api-key.ts +3 -0
  474. package/src/operations/classify-tool-outcome.ts +1 -1
  475. package/src/permissions/builtins.ts +7 -0
  476. package/src/permissions/permissions.ts +18 -9
  477. package/src/permissions/resolve.ts +7 -1
  478. package/src/plugin/context.ts +2 -0
  479. package/src/plugin/core-tool-names.ts +6 -1
  480. package/src/plugin/hooks.ts +137 -0
  481. package/src/plugin/index.ts +6 -0
  482. package/src/plugin/manager.ts +4 -0
  483. package/src/plugin/types.ts +60 -0
  484. package/src/run/bundled-plugins.ts +6 -0
  485. package/src/run/index.ts +24 -14
  486. package/src/run/llm-fetch-observer.ts +12 -15
  487. package/src/sandbox/canonical-secrets.ts +4 -0
  488. package/src/sandbox/dev-source.ts +26 -0
  489. package/src/sandbox/env-exposure.ts +20 -0
  490. package/src/sandbox/hidden-paths.ts +16 -2
  491. package/src/secrets/storage.ts +13 -0
  492. package/src/server/index.ts +46 -11
  493. package/src/skills/typeclaw-channel-github/SKILL.md +8 -8
  494. package/src/skills/typeclaw-config/SKILL.md +57 -5
  495. package/src/skills/typeclaw-config/references/dockerfile.md +2 -2
  496. package/src/skills/typeclaw-github-contributing/SKILL.md +1 -1
  497. package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
  498. package/src/skills/typeclaw-permissions/SKILL.md +7 -7
  499. package/src/skills/typeclaw-troubleshooting/SKILL.md +12 -1
  500. package/typeclaw.schema.json +488 -5
  501. package/src/bundled-plugins/doc-render/templates/lib.typ +0 -339
  502. package/src/bundled-plugins/github-cli-auth/gh-store.ts +0 -733
@@ -0,0 +1,174 @@
1
+ // Kernel-child helper, so it must stay dependency-free (see entry.ts).
2
+ //
3
+ // Models habitually reuse names like `const [a, b] = ...` across cells, and a
4
+ // REPL keeps top-level lexical bindings, so a later cell fails with "Can't
5
+ // create duplicate variable". A var cannot shadow an existing const either, so
6
+ // every cell's top-level const/let becomes var before it runs. Nested scopes
7
+ // keep their block semantics.
8
+ //
9
+ // The scan also reports top-level binding names: a top-level declaration of a
10
+ // helper like `tool` shadows it for the rest of the session, so the kernel
11
+ // refuses those cells. Initializers are skipped and collection resumes at each
12
+ // declarator comma; destructuring keys or defaults may be over-reported, which
13
+ // is acceptable for a refusal that only asks the model to rename.
14
+ const REGEX_PRECEDERS = new Set('(,=:[!&|?{};+-*%<>~^'.split(''))
15
+ const REGEX_KEYWORDS = new Set(['return', 'typeof', 'await', 'yield', 'case', 'in', 'of', 'void', 'delete', 'new'])
16
+ const CONTROL_HEADERS = new Set(['if', 'while', 'for', 'with'])
17
+
18
+ export function topLevelDeclarationsToVar(code: string): string {
19
+ return rewriteCell(code).code
20
+ }
21
+
22
+ export function rewriteCell(code: string): { code: string; declared: string[] } {
23
+ const declared: string[] = []
24
+ // A top-level declaration runs until `;` or a line end not following a comma;
25
+ // binding names are read until each declarator's `=`.
26
+ let inDeclaration = false
27
+ let collecting = false
28
+ let out = ''
29
+ let depth = 0
30
+ // Brace depths at which an open `${` returns to its enclosing template.
31
+ const templates: number[] = []
32
+ // Whether each open `(` is a control header: `/` after `if (x)` starts a
33
+ // regex, while `/` after a call like `f(x)` is division.
34
+ const parens: boolean[] = []
35
+ let previous = ''
36
+ let word = ''
37
+ let i = 0
38
+ const isIdent = (c: string | undefined) => c !== undefined && /[\p{L}\p{N}_$]/u.test(c)
39
+
40
+ const readTemplate = () => {
41
+ while (i < code.length) {
42
+ const c = code[i]
43
+ if (c === '\\') {
44
+ out += code.slice(i, i + 2)
45
+ i += 2
46
+ continue
47
+ }
48
+ if (c === '`') {
49
+ out += c
50
+ i += 1
51
+ return
52
+ }
53
+ if (c === '$' && code[i + 1] === '{') {
54
+ out += '${'
55
+ i += 2
56
+ templates.push(depth)
57
+ depth += 1
58
+ return
59
+ }
60
+ out += c
61
+ i += 1
62
+ }
63
+ }
64
+
65
+ while (i < code.length) {
66
+ const c = code[i] as string
67
+ const next = code[i + 1]
68
+ if (c === '/' && next === '/') {
69
+ const end = code.indexOf('\n', i)
70
+ const stop = end === -1 ? code.length : end
71
+ out += code.slice(i, stop)
72
+ i = stop
73
+ continue
74
+ }
75
+ if (c === '/' && next === '*') {
76
+ const end = code.indexOf('*/', i + 2)
77
+ const stop = end === -1 ? code.length : end + 2
78
+ out += code.slice(i, stop)
79
+ i = stop
80
+ continue
81
+ }
82
+ if (c === '"' || c === "'") {
83
+ let j = i + 1
84
+ while (j < code.length && code[j] !== c && code[j] !== '\n') j += code[j] === '\\' ? 2 : 1
85
+ out += code.slice(i, j + 1)
86
+ i = j + 1
87
+ previous = c
88
+ word = ''
89
+ continue
90
+ }
91
+ if (c === '`') {
92
+ out += c
93
+ i += 1
94
+ readTemplate()
95
+ previous = '`'
96
+ word = ''
97
+ continue
98
+ }
99
+ if (c === '/' && (previous === '' || REGEX_PRECEDERS.has(previous) || REGEX_KEYWORDS.has(word))) {
100
+ let j = i + 1
101
+ let inClass = false
102
+ while (j < code.length && code[j] !== '\n') {
103
+ if (code[j] === '\\') j += 1
104
+ else if (code[j] === '[') inClass = true
105
+ else if (code[j] === ']') inClass = false
106
+ else if (code[j] === '/' && !inClass) break
107
+ j += 1
108
+ }
109
+ j += 1
110
+ while (isIdent(code[j])) j += 1
111
+ out += code.slice(i, j)
112
+ i = j
113
+ previous = '/'
114
+ word = ''
115
+ continue
116
+ }
117
+ if (isIdent(c)) {
118
+ let j = i
119
+ while (isIdent(code[j])) j += 1
120
+ const token = code.slice(i, j)
121
+ const declaration =
122
+ depth === 0 &&
123
+ (token === 'const' || token === 'let' || token === 'var') &&
124
+ code[i - 1] !== '.' &&
125
+ /^\s*[[{\p{L}_$]/u.test(code.slice(j))
126
+ if (declaration) {
127
+ out += 'var'
128
+ inDeclaration = true
129
+ collecting = true
130
+ } else {
131
+ if (collecting) declared.push(token)
132
+ out += token
133
+ }
134
+ i = j
135
+ previous = token.at(-1) as string
136
+ word = token
137
+ continue
138
+ }
139
+ if (c === '(') parens.push(CONTROL_HEADERS.has(word))
140
+ if (c === '(' || c === '[' || c === '{') depth += 1
141
+ if (c === ')' && parens.pop() === true) {
142
+ depth -= 1
143
+ out += c
144
+ i += 1
145
+ previous = ';'
146
+ word = ''
147
+ continue
148
+ }
149
+ if (c === ')' || c === ']' || c === '}') {
150
+ depth -= 1
151
+ if (c === '}' && templates.at(-1) === depth) {
152
+ templates.pop()
153
+ out += c
154
+ i += 1
155
+ readTemplate()
156
+ previous = '`'
157
+ word = ''
158
+ continue
159
+ }
160
+ }
161
+ if (inDeclaration && depth === 0) {
162
+ if (c === '=') collecting = false
163
+ else if (c === ',') collecting = true
164
+ else if (c === ';' || (c === '\n' && previous !== ',')) inDeclaration = collecting = false
165
+ }
166
+ out += c
167
+ i += 1
168
+ if (!/\s/.test(c)) {
169
+ previous = c
170
+ word = ''
171
+ }
172
+ }
173
+ return { code: out, declared }
174
+ }
@@ -0,0 +1,114 @@
1
+ import { createHash } from 'node:crypto'
2
+ import { stat } from 'node:fs/promises'
3
+ import { dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ import { prepareBashSandbox } from '@/agent/bash-sandbox'
7
+ import type { SessionOrigin } from '@/agent/session-origin'
8
+ import type { PermissionService } from '@/permissions/permissions'
9
+ import { shellQuote } from '@/sandbox/quote'
10
+
11
+ import { EvalKernel } from './kernel'
12
+
13
+ // Retained bindings survive while the principal and audience are unchanged.
14
+ // A channel origin also carries conversational state (participant counters,
15
+ // timestamps, the reaction target, the review round, display names) that
16
+ // changes on every inbound message without changing authority, so it must not
17
+ // reset the kernel.
18
+ export function authorityOrigin(origin: SessionOrigin | undefined): unknown {
19
+ if (origin === undefined) return undefined
20
+ switch (origin.kind) {
21
+ case 'channel': {
22
+ const {
23
+ participants: _participants,
24
+ membership: _membership,
25
+ reactionRef: _reactionRef,
26
+ githubReviewRound: _githubReviewRound,
27
+ workspaceName: _workspaceName,
28
+ chatName: _chatName,
29
+ parentChatName: _parentChatName,
30
+ ...authority
31
+ } = origin
32
+ return authority
33
+ }
34
+ case 'subagent':
35
+ return { ...origin, spawnedByOrigin: authorityOrigin(origin.spawnedByOrigin) }
36
+ default:
37
+ return origin
38
+ }
39
+ }
40
+
41
+ export function createSandboxedEvalKernel(options: {
42
+ readonly agentDir: string
43
+ readonly sessionId: string
44
+ readonly permissions: PermissionService
45
+ readonly getOrigin: () => SessionOrigin | undefined
46
+ }): EvalKernel {
47
+ return new EvalKernel(async () => {
48
+ const origin = options.getOrigin()
49
+ const entry = fileURLToPath(new URL('./entry.ts', import.meta.url))
50
+ const prepared = await prepareBashSandbox({
51
+ command: `exec ${shellQuote(process.execPath)} --no-install ${shellQuote(entry)}`,
52
+ agentDir: options.agentDir,
53
+ sessionId: options.sessionId,
54
+ permissions: options.permissions,
55
+ origin,
56
+ // The bridge uses stdio, never a reachable loopback server. Network work
57
+ // goes through tool.bash/web_fetch with their normal guards.
58
+ network: 'none',
59
+ })
60
+ try {
61
+ await prepared.verify()
62
+ const policy = prepared.policy
63
+ const paths = new Set([
64
+ ...prepared.withheld.paths.dirs,
65
+ ...prepared.withheld.paths.files,
66
+ ...(policy.protected?.dirs ?? []),
67
+ ...(policy.protected?.files ?? []),
68
+ ...(policy.writable?.dirs ?? []),
69
+ ...(policy.writable?.files ?? []),
70
+ ...(policy.mounts ?? []).flatMap((mount) => ('source' in mount ? [mount.source] : [])),
71
+ ])
72
+ // File bind mounts pin identities, not names. An atomic replacement can
73
+ // leave a persistent process with a detached mask or protection. Include
74
+ // ancestors too: moving a directory can retain its children's inodes.
75
+ for (const path of paths) {
76
+ let parent = dirname(path)
77
+ while (!paths.has(parent)) {
78
+ paths.add(parent)
79
+ const next = dirname(parent)
80
+ if (next === parent) break
81
+ parent = next
82
+ }
83
+ }
84
+ const identities = await Promise.all(
85
+ [...paths].sort().map(async (path) => {
86
+ const identity = await stat(path, { bigint: true })
87
+ return [path, String(identity.dev), String(identity.ino)]
88
+ }),
89
+ )
90
+ return {
91
+ command: prepared.commandString,
92
+ cwd: options.agentDir,
93
+ env: prepared.spawnEnv,
94
+ // Includes the live principal, even when two principals have the same
95
+ // role. Never share retained values across a channel author change.
96
+ fingerprint: createHash('sha256')
97
+ .update(
98
+ JSON.stringify({
99
+ origin: authorityOrigin(origin),
100
+ role: options.permissions.describe(origin),
101
+ command: prepared.commandString,
102
+ env: prepared.spawnEnv,
103
+ identities,
104
+ }),
105
+ )
106
+ .digest('hex'),
107
+ cleanup: prepared.cleanup,
108
+ }
109
+ } catch (error) {
110
+ await prepared.cleanup()
111
+ throw error
112
+ }
113
+ })
114
+ }
@@ -0,0 +1,98 @@
1
+ import { defineTool, type ToolDefinition } from '@earendil-works/pi-coding-agent'
2
+ import { Type } from 'typebox'
3
+ import type { z } from 'zod'
4
+
5
+ import type { WrapSystemToolOptions } from '@/agent/plugin-tools'
6
+ import { wrapSystemTool } from '@/agent/plugin-tools'
7
+ import { wrapToolDefinitionWithBudget, type BudgetState, type ToolResultBudget } from '@/agent/tool-result-budget'
8
+ import { noopPermissionService } from '@/permissions/permissions'
9
+
10
+ import { evalEnabledForSession, type evalConfigSchema } from './config'
11
+ import { createEvalDispatch } from './dispatch'
12
+ import { EVAL_LIMITS, EvalError } from './protocol'
13
+ import { createSandboxedEvalKernel } from './sandbox'
14
+
15
+ export const EVAL_PROMPT_HINT =
16
+ 'Use eval to keep large tool output out of your context: fetch, filter or compute in the cell, and print only the answer; unprinted data never reaches you. ' +
17
+ 'It also runs steps where the next call depends on the last result in one call: ' +
18
+ "const root = 'src'; const hits = await tool.grep({ pattern: 'openDoor', path: root }); " +
19
+ "const files = [...new Set(text(hits).split('\\n').filter((l) => l.includes(':')).map((l) => root + '/' + l.split(':')[0]))].slice(0, 5); " +
20
+ 'const bodies = await parallel(files.map((f) => () => tool.read({ path: f }))); ' +
21
+ 'for (const [i, b] of bodies.entries()) print(files[i], text(b, 1500)). ' +
22
+ 'Independent reads alone do not need eval; call those tools directly. ' +
23
+ "text(result, maxChars) extracts a tool result's text; never print whole result objects. " +
24
+ 'JavaScript bindings persist in this session until idle expiry, authority changes, or kernel failure. ' +
25
+ 'Only printed/displayed output is returned. Await all work; no background cells, install helpers, or Python cells.'
26
+
27
+ export function registerEvalTool(options: {
28
+ readonly settings: z.infer<typeof evalConfigSchema>
29
+ readonly tools: ToolDefinition[]
30
+ readonly activeNames: string[]
31
+ readonly getActiveNames: () => readonly string[]
32
+ readonly wrappers: WrapSystemToolOptions
33
+ readonly budget?: ToolResultBudget
34
+ readonly budgetState?: BudgetState
35
+ }): { dispose(): Promise<void> } | undefined {
36
+ const eligible = () =>
37
+ evalEnabledForSession({
38
+ settings: options.settings,
39
+ origin: options.wrappers.getOrigin?.(),
40
+ tools: options.getActiveNames(),
41
+ bashPolicy: options.wrappers.bashPolicy,
42
+ })
43
+ if (!eligible()) return undefined
44
+ const kernel = createSandboxedEvalKernel({
45
+ agentDir: options.wrappers.agentDir,
46
+ sessionId: options.wrappers.sessionId,
47
+ permissions: options.wrappers.permissions ?? noopPermissionService,
48
+ getOrigin: () => options.wrappers.getOrigin?.(),
49
+ })
50
+ const tool = wrapSystemTool(
51
+ defineTool({
52
+ name: 'eval',
53
+ label: 'eval',
54
+ description:
55
+ 'Run a foreground JavaScript cell in a persistent, bash-sandboxed Bun kernel. ' +
56
+ 'Use await tool.read/grep/find/ls/bash/write/edit/web_search/web_fetch with their normal arguments, ' +
57
+ "parallel(thunks) (up to 8 workers), print/display(value), and text(result, maxChars = 2000) to extract a result's text. " +
58
+ 'Tool calls return the normal content/details object; print selected text, not whole results. ' +
59
+ 'A failed tool call rejects; wrap risky calls in try/catch so one failure does not discard a batch. ' +
60
+ 'tool.grep patterns are ripgrep regex: escape ( ) [ ] and . as \\\\(, lookaround is unsupported, and literal:true matches plain text. ' +
61
+ 'Only active tools are callable; recursion, orchestration, posting, role changes and MCP dispatch are refused. ' +
62
+ '30s default, 60s hard maximum; timeout kills the kernel. Output is capped at 64 KiB / 1000 lines. ' +
63
+ 'No background cells, package installation helpers or Python. Use await import(...) for modules.',
64
+ parameters: Type.Object({
65
+ code: Type.String({ maxLength: EVAL_LIMITS.codeBytes }),
66
+ timeoutMs: Type.Optional(Type.Integer({ minimum: 1, maximum: EVAL_LIMITS.maxTimeoutMs })),
67
+ }),
68
+ async execute(_id, args, signal, _onUpdate, context) {
69
+ if (!eligible()) {
70
+ await kernel.dispose()
71
+ throw new EvalError('refused', 'eval requires active, unrestricted bash in an enabled origin')
72
+ }
73
+ const result = await kernel.run(args.code, {
74
+ signal,
75
+ timeoutMs: args.timeoutMs,
76
+ dispatch: createEvalDispatch({
77
+ tools: options.tools,
78
+ getActiveNames: options.getActiveNames,
79
+ context,
80
+ }),
81
+ })
82
+ if (result.isError) throw new EvalError('closed', result.text)
83
+ return {
84
+ content: [{ type: 'text', text: result.text || '(no output)' }],
85
+ details: { truncated: result.truncated, restarted: result.restarted },
86
+ }
87
+ },
88
+ }),
89
+ options.wrappers,
90
+ )
91
+ options.tools.push(
92
+ options.budget && options.budgetState
93
+ ? wrapToolDefinitionWithBudget(tool, options.budget, options.budgetState)
94
+ : tool,
95
+ )
96
+ options.activeNames.push('eval')
97
+ return { dispose: () => kernel.dispose() }
98
+ }
@@ -0,0 +1,93 @@
1
+ import type { HostFrame, KernelFrame } from './protocol'
2
+
3
+ export const EVAL_LIMITS = {
4
+ codeBytes: 64 * 1024,
5
+ frameBytes: 1024 * 1024,
6
+ outputBytes: 64 * 1024,
7
+ outputLines: 1000,
8
+ outputWarnBytes: 16 * 1024,
9
+ timeoutMs: 30_000,
10
+ maxTimeoutMs: 60_000,
11
+ idleMs: 5 * 60_000,
12
+ calls: 128,
13
+ concurrency: 8,
14
+ } as const
15
+
16
+ export const FRAME_PREFIX = '@typeclaw-eval '
17
+ export class EvalError extends Error {
18
+ override readonly name = 'EvalError'
19
+ constructor(
20
+ readonly kind: 'protocol' | 'closed' | 'timeout' | 'busy' | 'refused' | 'cell',
21
+ message: string,
22
+ ) {
23
+ super(message)
24
+ }
25
+ }
26
+
27
+ export function assertNever(value: never): never {
28
+ throw new EvalError('protocol', `unexpected eval frame: ${String(value)}`)
29
+ }
30
+
31
+ export function encodeFrame(frame: HostFrame | KernelFrame): string {
32
+ const line = FRAME_PREFIX + JSON.stringify(frame) + '\n'
33
+ if (Buffer.byteLength(line) > EVAL_LIMITS.frameBytes) {
34
+ throw new EvalError('protocol', 'eval bridge frame exceeds its byte limit')
35
+ }
36
+ return line
37
+ }
38
+
39
+ // Both complete lines and an unterminated flood are bounded before JSON.parse.
40
+ export class FrameLines {
41
+ private pending = Buffer.alloc(0)
42
+
43
+ push(chunk: Uint8Array): string[] {
44
+ const bytes = Buffer.concat([this.pending, chunk])
45
+ const lines: string[] = []
46
+ let start = 0
47
+ let end = bytes.indexOf(10)
48
+ while (end !== -1) {
49
+ if (end - start > EVAL_LIMITS.frameBytes) throw new EvalError('protocol', 'eval bridge line is too large')
50
+ lines.push(bytes.subarray(start, end).toString('utf8'))
51
+ start = end + 1
52
+ end = bytes.indexOf(10, start)
53
+ }
54
+ if (bytes.length - start > EVAL_LIMITS.frameBytes) {
55
+ throw new EvalError('protocol', 'eval bridge unterminated line is too large')
56
+ }
57
+ this.pending = Buffer.from(bytes.subarray(start))
58
+ return lines
59
+ }
60
+ }
61
+
62
+ const FILTER_ADVICE = 'filter in the cell and print only what you need'
63
+
64
+ export class CellOutput {
65
+ private text = ''
66
+ private bytes = 0
67
+ private lines = 0
68
+ truncated = false
69
+
70
+ append(text: string): void {
71
+ if (this.truncated) return
72
+ for (const character of text) {
73
+ const size = Buffer.byteLength(character)
74
+ if (this.bytes + size > EVAL_LIMITS.outputBytes || this.lines >= EVAL_LIMITS.outputLines) {
75
+ this.truncated = true
76
+ return
77
+ }
78
+ this.text += character
79
+ this.bytes += size
80
+ if (character === '\n') this.lines += 1
81
+ }
82
+ }
83
+
84
+ render(): string {
85
+ // Everything printed lands in the model's context; past the warning size
86
+ // the cell is no longer saving tokens over a direct tool call.
87
+ if (this.truncated) return `${this.text}\n[eval output truncated: limit reached; ${FILTER_ADVICE}]\n`
88
+ if (this.bytes > EVAL_LIMITS.outputWarnBytes) {
89
+ return `${this.text}\n[eval printed ${Math.round(this.bytes / 1024)} KB; ${FILTER_ADVICE}]\n`
90
+ }
91
+ return this.text
92
+ }
93
+ }
@@ -238,7 +238,14 @@ async function restorePersistedRegistrations(
238
238
  log({ kind: 'registration-skipped', containerName: expectedName, reason: 'container not running' })
239
239
  continue
240
240
  }
241
- await apply(parsed)
241
+ // One registration whose revival throws (e.g. portbroker.start) must not
242
+ // abort the loop: restoreComplete would reject and every gated RPC would
243
+ // fail until the daemon is respawned.
244
+ try {
245
+ await apply(parsed)
246
+ } catch (error) {
247
+ log({ kind: 'registration-skipped', containerName: expectedName, reason: stringifyError(error) })
248
+ }
242
249
  }
243
250
  }
244
251
 
@@ -443,6 +450,11 @@ export async function startDaemon(opts: DaemonOptions = {}): Promise<Daemon> {
443
450
  void handleFatalAuthFailure(payload.containerName, brokerToken, reason)
444
451
  },
445
452
  })
453
+ } else if (opts.portbroker && brokerTokens.delete(payload.containerName)) {
454
+ // A re-register without broker fields must retire the previous broker;
455
+ // otherwise its stale token could later match a fatal-auth callback and
456
+ // tear down this live registration.
457
+ await withCleanupTimeout(opts.portbroker.stop(payload.containerName, 'deregistered'), cleanupStepTimeoutMs)
446
458
  }
447
459
  if (opts.kakaoRenewal) {
448
460
  opts.kakaoRenewal.start({ containerName: payload.containerName, cwd: payload.cwd })
@@ -141,8 +141,14 @@ export function outcomeForcesInstall(outcome: AutoUpgradeOutcome): boolean {
141
141
  // (file deps don't "update"), NOT the `bun update --latest` path above — and it
142
142
  // skips version verification, since a local install's version is whatever the
143
143
  // checkout declares. start.ts ORs this into its ensureDeps force flag.
144
+ //
145
+ // Leaving a local spec for a registry range needs the same force: `bun update
146
+ // --latest` rewrites bun.lock but keeps the local copy in node_modules when its
147
+ // version already satisfies the range, so the agent would keep running the
148
+ // checkout's code.
144
149
  export function outcomeRequiresForceInstall(outcome: AutoUpgradeOutcome): boolean {
145
- return outcome.kind === 'relinked-to-local'
150
+ if (outcome.kind === 'relinked-to-local') return true
151
+ return outcome.kind === 'spec-rewritten' && (outcome.from.startsWith('file:') || outcome.from.startsWith('link:'))
146
152
  }
147
153
 
148
154
  // The version we expect to find in node_modules/typeclaw after the
@@ -1,4 +1,6 @@
1
1
  import { CONTAINER_AGENT_MESSENGER_CONFIG_DIR } from '@/agent-messenger/config-dir'
2
+ import { renderBrowserLayers } from '@/browser/dockerfile'
3
+ import type { BrowserConfig } from '@/browser/registry'
2
4
  import { ASKPASS_SCRIPT, TYPECLAW_GIT_ASKPASS_PATH } from '@/bundled-plugins/github-cli-auth/git-askpass'
3
5
  import { CLAUDE_CODE_VERSION } from '@/coding-agent/claude'
4
6
  import { CODEX_CLI_VERSION } from '@/coding-agent/codex'
@@ -12,6 +14,8 @@ import { GHCR_BASE_IMAGE_REPO } from './cli-version'
12
14
  export const DOCKERFILE = 'Dockerfile'
13
15
 
14
16
  export type BuildDockerfileOptions = {
17
+ // `typeclaw.json#browser`; omitted = the default agent-browser-only image.
18
+ browser?: BrowserConfig
15
19
  // Null or omitted = emit the full inline heavy stack (dev mode, tests).
16
20
  baseImageVersion?: string | null
17
21
  // Host-locale decision for `cjkFonts: 'auto'`. Callers that have a host
@@ -784,6 +788,7 @@ export function buildDockerfile(
784
788
  const claudeCodeLayer = renderClaudeCodeInstallLayer(config.claudeCode)
785
789
  const codexCliLayer = renderCodexCliInstallLayer(config.codexCli, buildKit)
786
790
  const omoCliLayer = renderOmoCliInstallLayer(config.omoCli)
791
+ const browserLayers = renderBrowserLayers(options.browser ?? { engines: ['agent-browser'], extensions: [] })
787
792
  const fromAndHeavyLayers =
788
793
  baseImageVersion !== null
789
794
  ? renderVersionedHead(
@@ -794,6 +799,7 @@ export function buildDockerfile(
794
799
  claudeCodeLayer,
795
800
  codexCliLayer,
796
801
  omoCliLayer,
802
+ browserLayers,
797
803
  buildKit,
798
804
  )
799
805
  : renderInlineHead(
@@ -803,6 +809,7 @@ export function buildDockerfile(
803
809
  claudeCodeLayer,
804
810
  codexCliLayer,
805
811
  omoCliLayer,
812
+ browserLayers,
806
813
  buildKit,
807
814
  )
808
815
 
@@ -857,6 +864,7 @@ function renderVersionedHead(
857
864
  claudeCodeLayer: string,
858
865
  codexCliLayer: string,
859
866
  omoCliLayer: string,
867
+ browserLayers: string,
860
868
  buildKit: boolean,
861
869
  ): string {
862
870
  const toggleAptLayer = toggleAptArgs.length === 0 ? '' : `${renderToggleAptInstallLayer(toggleAptArgs, buildKit)}\n\n`
@@ -870,7 +878,7 @@ WORKDIR /agent
870
878
 
871
879
  ARG TARGETARCH
872
880
 
873
- ${ghKeyringLayer}${toggleAptLayer}${cloudflaredBlock}${claudeCodeBlock}${codexCliBlock}${omoCliBlock}${renderEntrypointShimLayer()}
881
+ ${ghKeyringLayer}${toggleAptLayer}${cloudflaredBlock}${claudeCodeBlock}${codexCliBlock}${omoCliBlock}${browserLayers}${renderEntrypointShimLayer()}
874
882
  ${renderGitAskPassLayer()}
875
883
 
876
884
  ${LAYER_TRANSFORMERS_INSTALL}
@@ -889,6 +897,7 @@ function renderInlineHead(
889
897
  claudeCodeLayer: string,
890
898
  codexCliLayer: string,
891
899
  omoCliLayer: string,
900
+ browserLayers: string,
892
901
  buildKit: boolean,
893
902
  ): string {
894
903
  const baselineAndToggleArgs = [...BASELINE_APT_PACKAGES, ...toggleAptArgs]
@@ -936,7 +945,7 @@ ${LAYER_4_5_AGENT_BROWSER_HEADED_WRAPPER}
936
945
 
937
946
  ${renderChromeForTestingLayer()}
938
947
 
939
- ${cloudflaredBlock}${claudeCodeBlock}${codexCliBlock}${omoCliBlock}${renderEntrypointShimLayer()}
948
+ ${cloudflaredBlock}${claudeCodeBlock}${codexCliBlock}${omoCliBlock}${browserLayers}${renderEntrypointShimLayer()}
940
949
  ${renderGitAskPassLayer()}
941
950
 
942
951
  ${LAYER_TRANSFORMERS_INSTALL}
@@ -1085,18 +1094,50 @@ RUN ARCH_TARBALL="$(if [ "$TARGETARCH" = "arm64" ]; then echo aarch64-linux-gnu;
1085
1094
  && rm curl-impersonate.tar.gz \\
1086
1095
  && /usr/local/bin/curl_${CURL_IMPERSONATE_PROFILE} --version > /dev/null`
1087
1096
 
1088
- const LAYER_3_AGENT_BROWSER_ARM64_CONFIG = `# Layer 3 (stable, arm64 only): point agent-browser at the apt-installed
1089
- # chromium. Independent of the npm install below so it stays cached across
1097
+ // Everything agent-browser needs at runtime lives under /usr: the model's
1098
+ // bwrap sandbox binds /usr but not /root, and its PATH has no `node`.
1099
+ const AGENT_BROWSER_ROOT = '/usr/local/lib/typeclaw-agent-browser'
1100
+ const AGENT_BROWSER_PACKAGE = `${AGENT_BROWSER_ROOT}/install/global/node_modules/agent-browser`
1101
+ // Stable browser path for both arches: a launcher that execs the real
1102
+ // browser, linked at AGENT_BROWSER_CHROME_BIN (apt chromium on arm64, Chrome
1103
+ // for Testing on amd64 in Layer 5).
1104
+ const AGENT_BROWSER_CHROME = `${AGENT_BROWSER_ROOT}/chrome`
1105
+ const AGENT_BROWSER_CHROME_BIN = `${AGENT_BROWSER_ROOT}/chrome-bin`
1106
+
1107
+ // The launcher adds --no-sandbox because Chromium's own sandbox cannot start
1108
+ // inside the model's bwrap sandbox: with the default proc-bind strategy /proc
1109
+ // is read-only, so Chromium's user-namespace sandbox cannot write
1110
+ // /proc/self/uid_map, and there is no setuid chrome-sandbox. agent-browser
1111
+ // only auto-adds --no-sandbox when it detects root or a container
1112
+ // (/.dockerenv, /proc/1/cgroup), and none of that is visible inside bwrap.
1113
+ // bwrap stays the isolation boundary for the browser. The flag lives in the
1114
+ // launcher, not AGENT_BROWSER_ARGS, because a CLI --args replaces that env
1115
+ // value wholesale and would silently drop it.
1116
+ const LAYER_3_AGENT_BROWSER_ARM64_CONFIG = `# Layer 3 (stable): point agent-browser at a browser launcher visible inside
1117
+ # the sandbox. arm64 links the apt chromium; amd64 links Chrome for Testing in
1118
+ # Layer 5. Independent of the npm install below so it stays cached across
1090
1119
  # agent-browser version bumps.
1091
- RUN if [ "$TARGETARCH" = "arm64" ]; then \\
1092
- mkdir -p /root/.agent-browser \\
1093
- && printf '%s\\n' '{"executablePath":"/usr/bin/chromium"}' > /root/.agent-browser/config.json; \\
1120
+ RUN mkdir -p ${AGENT_BROWSER_ROOT} \\
1121
+ && printf '%s\\n' '#!/bin/sh' 'exec ${AGENT_BROWSER_CHROME_BIN} --no-sandbox "$@"' > ${AGENT_BROWSER_CHROME} \\
1122
+ && chmod 0755 ${AGENT_BROWSER_CHROME} \\
1123
+ && if [ "$TARGETARCH" = "arm64" ]; then \\
1124
+ ln -sf /usr/bin/chromium ${AGENT_BROWSER_CHROME_BIN}; \\
1094
1125
  fi`
1095
1126
 
1127
+ // Layer 4: the npm tarball ships the native binaries without the exec bit and
1128
+ // the JS launcher chmods them on first run, which fails on the read-only /usr
1129
+ // inside the sandbox, so set it at build time. The launcher runs under bun
1130
+ // because the image's `node` fallback is outside the sandbox PATH, and it
1131
+ // defaults the browser path itself because the sandbox clears image ENV.
1132
+ // An inherited AGENT_BROWSER_EXECUTABLE_PATH (operator .env) still wins.
1096
1133
  const renderAgentBrowserInstallLayer = (buildKit: boolean): string =>
1097
- `# Layer 4 (volatile): install agent-browser globally so it survives the
1098
- # runtime bind-mount over /agent/node_modules.
1099
- RUN ${bunCacheMount(buildKit)}bun install -g agent-browser@^0.33.0`
1134
+ `# Layer 4 (volatile): install agent-browser under /usr so it survives the
1135
+ # runtime bind-mount over /agent/node_modules and stays visible in bwrap.
1136
+ RUN ${bunCacheMount(buildKit)}BUN_INSTALL=${AGENT_BROWSER_ROOT} BUN_INSTALL_BIN=${AGENT_BROWSER_ROOT}/bin BUN_INSTALL_CACHE_DIR=/root/.bun/install/cache bun install -g agent-browser@^0.39.1 \\
1137
+ && chmod 0755 ${AGENT_BROWSER_PACKAGE}/bin/agent-browser-linux-* \\
1138
+ && printf '%s\\n' '#!/bin/sh' ': "\${AGENT_BROWSER_EXECUTABLE_PATH:=${AGENT_BROWSER_CHROME}}"' 'export AGENT_BROWSER_EXECUTABLE_PATH' 'exec /usr/local/bin/bun ${AGENT_BROWSER_PACKAGE}/bin/agent-browser.js "$@"' > /usr/local/bin/agent-browser \\
1139
+ && chmod 0755 /usr/local/bin/agent-browser \\
1140
+ && agent-browser --version > /dev/null`
1100
1141
 
1101
1142
  // Layer 4.5: shim the agent-browser binary with a wrapper that calls
1102
1143
  // \`agent-browser close\` before \`open\`/\`goto\`/\`navigate\` when headed
@@ -1219,7 +1260,8 @@ exec env _TYPECLAW_AGENT_BROWSER_HEADED_HANDLED=1 "$real" "$@"
1219
1260
  TYPECLAW_AGENT_BROWSER_WRAPPER_EOF`
1220
1261
 
1221
1262
  // Layer 5: download the pinned Chrome for Testing build into
1222
- // ~/.agent-browser/browsers/. NO cache mount on that path because the
1263
+ // $HOME/.agent-browser/browsers/, with HOME pointed under /usr so the
1264
+ // sandbox can see it, then link it to the stable path. NO cache mount on that path because the
1223
1265
  // runtime needs the binary in the image, and no apt cache mount either
1224
1266
  // because nothing in this layer runs apt.
1225
1267
  //
@@ -1233,7 +1275,10 @@ TYPECLAW_AGENT_BROWSER_WRAPPER_EOF`
1233
1275
  const renderChromeForTestingLayer = (): string =>
1234
1276
  `# Layer 5 (heavy, amd64 only): Chrome for Testing download.
1235
1277
  RUN if [ "$TARGETARCH" != "arm64" ]; then \\
1236
- agent-browser install; \\
1278
+ HOME=${AGENT_BROWSER_ROOT} agent-browser install \\
1279
+ && chrome="$(find ${AGENT_BROWSER_ROOT}/.agent-browser/browsers -type f -name chrome -perm -u+x | head -n 1)" \\
1280
+ && [ -n "$chrome" ] \\
1281
+ && ln -sf "$chrome" ${AGENT_BROWSER_CHROME_BIN}; \\
1237
1282
  fi`
1238
1283
 
1239
1284
  function renderOmoCliInstallLayer(enabled: boolean): string {