@alumbwe/anvil 1.0.20 → 1.0.22

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 (328) hide show
  1. package/package.json +74 -70
  2. package/src/agents/bundled-agents.generated.ts +4 -4
  3. package/src/chat.tsx +1703 -1698
  4. package/src/cli-args.ts +134 -134
  5. package/src/components/status-bar.tsx +331 -313
  6. package/src/hooks/helpers/send-message.ts +663 -654
  7. package/src/hooks/use-send-message.ts +806 -773
  8. package/src/index.tsx +473 -473
  9. package/src/state/chat-store.ts +553 -544
  10. package/src/utils/create-run-config.ts +121 -121
  11. package/src/utils/format-compact-number.ts +37 -0
  12. package/vendor/@anvil/common/package.json +27 -0
  13. package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +846 -0
  14. package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +101 -0
  15. package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +1408 -0
  16. package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +258 -0
  17. package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +48 -0
  18. package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +282 -0
  19. package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +526 -0
  20. package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +68 -0
  21. package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +132 -0
  22. package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +422 -0
  23. package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +167 -0
  24. package/vendor/@anvil/common/src/__tests__/env-process.test.ts +145 -0
  25. package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +234 -0
  26. package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +379 -0
  27. package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +807 -0
  28. package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +154 -0
  29. package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +246 -0
  30. package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +77 -0
  31. package/vendor/@anvil/common/src/__tests__/model-config.test.ts +89 -0
  32. package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +298 -0
  33. package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +116 -0
  34. package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +167 -0
  35. package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +132 -0
  36. package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +72 -0
  37. package/vendor/@anvil/common/src/__tests__/user-state.test.ts +30 -0
  38. package/vendor/@anvil/common/src/actions.ts +215 -0
  39. package/vendor/@anvil/common/src/analytics-core.ts +69 -0
  40. package/vendor/@anvil/common/src/analytics.ts +93 -0
  41. package/vendor/@anvil/common/src/api-keys/constants.ts +26 -0
  42. package/vendor/@anvil/common/src/browser-actions.ts +413 -0
  43. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +63 -0
  44. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +246 -0
  45. package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +106 -0
  46. package/vendor/@anvil/common/src/constants/agents.ts +99 -0
  47. package/vendor/@anvil/common/src/constants/analytics-events.ts +435 -0
  48. package/vendor/@anvil/common/src/constants/anthropic.ts +73 -0
  49. package/vendor/@anvil/common/src/constants/anvil-data-use.ts +81 -0
  50. package/vendor/@anvil/common/src/constants/anvil-errors.ts +7 -0
  51. package/vendor/@anvil/common/src/constants/anvil-gemini-thinker.ts +21 -0
  52. package/vendor/@anvil/common/src/constants/anvil-model-ids.ts +11 -0
  53. package/vendor/@anvil/common/src/constants/anvil-models.ts +2130 -0
  54. package/vendor/@anvil/common/src/constants/anvil-onboarding-gate.ts +55 -0
  55. package/vendor/@anvil/common/src/constants/anvil-onboarding.ts +307 -0
  56. package/vendor/@anvil/common/src/constants/anvil-referral-tiers.ts +87 -0
  57. package/vendor/@anvil/common/src/constants/anvil-signup-block.ts +68 -0
  58. package/vendor/@anvil/common/src/constants/anvil-spend-ceilings.ts +450 -0
  59. package/vendor/@anvil/common/src/constants/anvil-trust.ts +976 -0
  60. package/vendor/@anvil/common/src/constants/auth.ts +18 -0
  61. package/vendor/@anvil/common/src/constants/byok.ts +2 -0
  62. package/vendor/@anvil/common/src/constants/cf-worker-signals.ts +132 -0
  63. package/vendor/@anvil/common/src/constants/composio.ts +34 -0
  64. package/vendor/@anvil/common/src/constants/deepseek-direct.ts +55 -0
  65. package/vendor/@anvil/common/src/constants/feedback.ts +13 -0
  66. package/vendor/@anvil/common/src/constants/foreign-client-signals.ts +272 -0
  67. package/vendor/@anvil/common/src/constants/free-agents.ts +777 -0
  68. package/vendor/@anvil/common/src/constants/gemini.ts +15 -0
  69. package/vendor/@anvil/common/src/constants/grant-priorities.ts +13 -0
  70. package/vendor/@anvil/common/src/constants/hosts.ts +6 -0
  71. package/vendor/@anvil/common/src/constants/images.ts +51 -0
  72. package/vendor/@anvil/common/src/constants/index.ts +7 -0
  73. package/vendor/@anvil/common/src/constants/knowledge.ts +35 -0
  74. package/vendor/@anvil/common/src/constants/limits.ts +23 -0
  75. package/vendor/@anvil/common/src/constants/model-config.ts +277 -0
  76. package/vendor/@anvil/common/src/constants/openrouter-attribution.ts +8 -0
  77. package/vendor/@anvil/common/src/constants/paths.ts +69 -0
  78. package/vendor/@anvil/common/src/constants/provider-routes.ts +317 -0
  79. package/vendor/@anvil/common/src/constants/reasoning-effort.ts +79 -0
  80. package/vendor/@anvil/common/src/constants/skills.ts +60 -0
  81. package/vendor/@anvil/common/src/constants/subscription-plans.ts +49 -0
  82. package/vendor/@anvil/common/src/constants/ui.ts +25 -0
  83. package/vendor/@anvil/common/src/env-ci.ts +36 -0
  84. package/vendor/@anvil/common/src/env-process.ts +95 -0
  85. package/vendor/@anvil/common/src/env-schema.ts +95 -0
  86. package/vendor/@anvil/common/src/env.ts +24 -0
  87. package/vendor/@anvil/common/src/gravity-capi.ts +207 -0
  88. package/vendor/@anvil/common/src/mcp/client.ts +233 -0
  89. package/vendor/@anvil/common/src/old-constants.ts +10 -0
  90. package/vendor/@anvil/common/src/project-file-tree.ts +355 -0
  91. package/vendor/@anvil/common/src/reddit-capi.ts +254 -0
  92. package/vendor/@anvil/common/src/schemas/feedback.ts +52 -0
  93. package/vendor/@anvil/common/src/schemas/logs.ts +66 -0
  94. package/vendor/@anvil/common/src/templates/agent-validation.ts +392 -0
  95. package/vendor/@anvil/common/src/templates/initial-agents-dir/LICENSE +202 -0
  96. package/vendor/@anvil/common/src/templates/initial-agents-dir/README.md +294 -0
  97. package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/01-basic-diff-reviewer.ts +17 -0
  98. package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/02-intermediate-git-committer.ts +78 -0
  99. package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/03-advanced-file-explorer.ts +73 -0
  100. package/vendor/@anvil/common/src/templates/initial-agents-dir/my-custom-agent.ts +40 -0
  101. package/vendor/@anvil/common/src/templates/initial-agents-dir/package.json +6 -0
  102. package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/README.md +65 -0
  103. package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/example-skill/SKILL.md +29 -0
  104. package/vendor/@anvil/common/src/templates/initial-agents-dir/types/agent-definition.ts +497 -0
  105. package/vendor/@anvil/common/src/templates/initial-agents-dir/types/tools.ts +444 -0
  106. package/vendor/@anvil/common/src/templates/initial-agents-dir/types/util-types.ts +178 -0
  107. package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +351 -0
  108. package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +169 -0
  109. package/vendor/@anvil/common/src/testing/errors.ts +33 -0
  110. package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +334 -0
  111. package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +6 -0
  112. package/vendor/@anvil/common/src/testing/index.ts +84 -0
  113. package/vendor/@anvil/common/src/testing/mock-modules.ts +53 -0
  114. package/vendor/@anvil/common/src/testing/mock-types.ts +123 -0
  115. package/vendor/@anvil/common/src/testing/mocks/analytics.ts +261 -0
  116. package/vendor/@anvil/common/src/testing/mocks/child-process.ts +93 -0
  117. package/vendor/@anvil/common/src/testing/mocks/crypto.ts +218 -0
  118. package/vendor/@anvil/common/src/testing/mocks/database.ts +337 -0
  119. package/vendor/@anvil/common/src/testing/mocks/fetch.ts +219 -0
  120. package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +166 -0
  121. package/vendor/@anvil/common/src/testing/mocks/index.ts +101 -0
  122. package/vendor/@anvil/common/src/testing/mocks/logger.ts +135 -0
  123. package/vendor/@anvil/common/src/testing/mocks/stream.ts +313 -0
  124. package/vendor/@anvil/common/src/testing/mocks/timers.ts +132 -0
  125. package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +127 -0
  126. package/vendor/@anvil/common/src/testing/setup.ts +282 -0
  127. package/vendor/@anvil/common/src/testing-env-ci.ts +15 -0
  128. package/vendor/@anvil/common/src/testing-env-process.ts +78 -0
  129. package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +34 -0
  130. package/vendor/@anvil/common/src/tools/compile-tool-definitions.ts +157 -0
  131. package/vendor/@anvil/common/src/tools/constants.ts +117 -0
  132. package/vendor/@anvil/common/src/tools/list.ts +190 -0
  133. package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +213 -0
  134. package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +47 -0
  135. package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +65 -0
  136. package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +49 -0
  137. package/vendor/@anvil/common/src/tools/params/tool/add-message.ts +39 -0
  138. package/vendor/@anvil/common/src/tools/params/tool/add-subgoal.ts +57 -0
  139. package/vendor/@anvil/common/src/tools/params/tool/apply-patch.ts +110 -0
  140. package/vendor/@anvil/common/src/tools/params/tool/ask-user.ts +181 -0
  141. package/vendor/@anvil/common/src/tools/params/tool/browser-logs.ts +85 -0
  142. package/vendor/@anvil/common/src/tools/params/tool/cloud-plan-ready.ts +94 -0
  143. package/vendor/@anvil/common/src/tools/params/tool/code-search.ts +159 -0
  144. package/vendor/@anvil/common/src/tools/params/tool/composio.ts +131 -0
  145. package/vendor/@anvil/common/src/tools/params/tool/create-plan.ts +80 -0
  146. package/vendor/@anvil/common/src/tools/params/tool/end-turn.ts +57 -0
  147. package/vendor/@anvil/common/src/tools/params/tool/find-files.ts +60 -0
  148. package/vendor/@anvil/common/src/tools/params/tool/glob.ts +80 -0
  149. package/vendor/@anvil/common/src/tools/params/tool/gravity-index.ts +93 -0
  150. package/vendor/@anvil/common/src/tools/params/tool/list-directory.ts +58 -0
  151. package/vendor/@anvil/common/src/tools/params/tool/lookup-agent-info.ts +37 -0
  152. package/vendor/@anvil/common/src/tools/params/tool/propose-str-replace.ts +103 -0
  153. package/vendor/@anvil/common/src/tools/params/tool/propose-write-file.ts +71 -0
  154. package/vendor/@anvil/common/src/tools/params/tool/read-docs.ts +90 -0
  155. package/vendor/@anvil/common/src/tools/params/tool/read-files.ts +109 -0
  156. package/vendor/@anvil/common/src/tools/params/tool/read-subtree.ts +79 -0
  157. package/vendor/@anvil/common/src/tools/params/tool/read-url.ts +81 -0
  158. package/vendor/@anvil/common/src/tools/params/tool/render-ui.ts +168 -0
  159. package/vendor/@anvil/common/src/tools/params/tool/run-file-change-hooks.ts +57 -0
  160. package/vendor/@anvil/common/src/tools/params/tool/run-terminal-command.ts +211 -0
  161. package/vendor/@anvil/common/src/tools/params/tool/screenshot.ts +97 -0
  162. package/vendor/@anvil/common/src/tools/params/tool/set-messages.ts +44 -0
  163. package/vendor/@anvil/common/src/tools/params/tool/set-output.ts +61 -0
  164. package/vendor/@anvil/common/src/tools/params/tool/skill.ts +59 -0
  165. package/vendor/@anvil/common/src/tools/params/tool/spawn-agent-inline.ts +56 -0
  166. package/vendor/@anvil/common/src/tools/params/tool/spawn-agents.ts +154 -0
  167. package/vendor/@anvil/common/src/tools/params/tool/str-replace.ts +107 -0
  168. package/vendor/@anvil/common/src/tools/params/tool/suggest-followups.ts +97 -0
  169. package/vendor/@anvil/common/src/tools/params/tool/task-completed.ts +61 -0
  170. package/vendor/@anvil/common/src/tools/params/tool/think-deeply.ts +56 -0
  171. package/vendor/@anvil/common/src/tools/params/tool/update-subgoal.ts +89 -0
  172. package/vendor/@anvil/common/src/tools/params/tool/vision-analyze.ts +82 -0
  173. package/vendor/@anvil/common/src/tools/params/tool/web-search.ts +73 -0
  174. package/vendor/@anvil/common/src/tools/params/tool/write-file.ts +71 -0
  175. package/vendor/@anvil/common/src/tools/params/tool/write-todos.ts +67 -0
  176. package/vendor/@anvil/common/src/tools/params/utils.ts +150 -0
  177. package/vendor/@anvil/common/src/tools/utils.ts +24 -0
  178. package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +20 -0
  179. package/vendor/@anvil/common/src/types/agent-template.ts +215 -0
  180. package/vendor/@anvil/common/src/types/anvil-session.ts +535 -0
  181. package/vendor/@anvil/common/src/types/anvil-streak.ts +6 -0
  182. package/vendor/@anvil/common/src/types/anvil-usage.ts +64 -0
  183. package/vendor/@anvil/common/src/types/api/agents/publish.ts +61 -0
  184. package/vendor/@anvil/common/src/types/bun-test.d.ts +5 -0
  185. package/vendor/@anvil/common/src/types/contracts/agent-runtime.ts +75 -0
  186. package/vendor/@anvil/common/src/types/contracts/analytics.ts +9 -0
  187. package/vendor/@anvil/common/src/types/contracts/bigquery.ts +55 -0
  188. package/vendor/@anvil/common/src/types/contracts/billing.ts +46 -0
  189. package/vendor/@anvil/common/src/types/contracts/client.ts +53 -0
  190. package/vendor/@anvil/common/src/types/contracts/database.ts +112 -0
  191. package/vendor/@anvil/common/src/types/contracts/env.ts +203 -0
  192. package/vendor/@anvil/common/src/types/contracts/llm.ts +191 -0
  193. package/vendor/@anvil/common/src/types/contracts/logger.ts +14 -0
  194. package/vendor/@anvil/common/src/types/contracts/logs.ts +34 -0
  195. package/vendor/@anvil/common/src/types/contracts/trace.ts +21 -0
  196. package/vendor/@anvil/common/src/types/dynamic-agent-template.ts +328 -0
  197. package/vendor/@anvil/common/src/types/filesystem.ts +10 -0
  198. package/vendor/@anvil/common/src/types/function-params.ts +33 -0
  199. package/vendor/@anvil/common/src/types/grant.ts +20 -0
  200. package/vendor/@anvil/common/src/types/gravity-index.ts +170 -0
  201. package/vendor/@anvil/common/src/types/json.ts +29 -0
  202. package/vendor/@anvil/common/src/types/mcp.ts +24 -0
  203. package/vendor/@anvil/common/src/types/messages/anvil-message.ts +58 -0
  204. package/vendor/@anvil/common/src/types/messages/content-part.ts +59 -0
  205. package/vendor/@anvil/common/src/types/messages/data-content.ts +14 -0
  206. package/vendor/@anvil/common/src/types/messages/provider-metadata.ts +13 -0
  207. package/vendor/@anvil/common/src/types/organization.ts +118 -0
  208. package/vendor/@anvil/common/src/types/print-mode.ts +121 -0
  209. package/vendor/@anvil/common/src/types/publisher.ts +67 -0
  210. package/vendor/@anvil/common/src/types/session-state.ts +149 -0
  211. package/vendor/@anvil/common/src/types/skill.ts +86 -0
  212. package/vendor/@anvil/common/src/types/source.ts +11 -0
  213. package/vendor/@anvil/common/src/types/spawn.ts +13 -0
  214. package/vendor/@anvil/common/src/types/subscription.ts +67 -0
  215. package/vendor/@anvil/common/src/types/usage.ts +16 -0
  216. package/vendor/@anvil/common/src/types/util.ts +3 -0
  217. package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +26 -0
  218. package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +122 -0
  219. package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +102 -0
  220. package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +143 -0
  221. package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +202 -0
  222. package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +193 -0
  223. package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +140 -0
  224. package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +148 -0
  225. package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +115 -0
  226. package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +57 -0
  227. package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +774 -0
  228. package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +206 -0
  229. package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +173 -0
  230. package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +60 -0
  231. package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +31 -0
  232. package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +1252 -0
  233. package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +505 -0
  234. package/vendor/@anvil/common/src/util/__tests__/path.test.ts +22 -0
  235. package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +90 -0
  236. package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +325 -0
  237. package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +28 -0
  238. package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +130 -0
  239. package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +1008 -0
  240. package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +289 -0
  241. package/vendor/@anvil/common/src/util/__tests__/string.test.ts +239 -0
  242. package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +70 -0
  243. package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +108 -0
  244. package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +180 -0
  245. package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +24 -0
  246. package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +88 -0
  247. package/vendor/@anvil/common/src/util/ad-user-agent.ts +25 -0
  248. package/vendor/@anvil/common/src/util/agent-file-utils.ts +110 -0
  249. package/vendor/@anvil/common/src/util/agent-id-parsing.ts +136 -0
  250. package/vendor/@anvil/common/src/util/agent-name-normalization.ts +38 -0
  251. package/vendor/@anvil/common/src/util/agent-name-resolver.ts +86 -0
  252. package/vendor/@anvil/common/src/util/analytics-dispatcher.ts +82 -0
  253. package/vendor/@anvil/common/src/util/analytics-log.ts +78 -0
  254. package/vendor/@anvil/common/src/util/analytics-sampling.ts +255 -0
  255. package/vendor/@anvil/common/src/util/anvil-model-availability.ts +102 -0
  256. package/vendor/@anvil/common/src/util/anvil-privacy.ts +82 -0
  257. package/vendor/@anvil/common/src/util/anvil-streak-line.ts +103 -0
  258. package/vendor/@anvil/common/src/util/anvil-streak.ts +156 -0
  259. package/vendor/@anvil/common/src/util/anvil-usage-summary.ts +125 -0
  260. package/vendor/@anvil/common/src/util/array.ts +31 -0
  261. package/vendor/@anvil/common/src/util/axiom-only-log.ts +124 -0
  262. package/vendor/@anvil/common/src/util/cache-debug.ts +171 -0
  263. package/vendor/@anvil/common/src/util/client-user-agent.ts +114 -0
  264. package/vendor/@anvil/common/src/util/credentials.ts +26 -0
  265. package/vendor/@anvil/common/src/util/currency.ts +25 -0
  266. package/vendor/@anvil/common/src/util/dates.ts +81 -0
  267. package/vendor/@anvil/common/src/util/disposable-email.ts +277 -0
  268. package/vendor/@anvil/common/src/util/engagement-tracker.ts +129 -0
  269. package/vendor/@anvil/common/src/util/env-file-path.ts +40 -0
  270. package/vendor/@anvil/common/src/util/error.ts +562 -0
  271. package/vendor/@anvil/common/src/util/file-read-limits.ts +236 -0
  272. package/vendor/@anvil/common/src/util/file.ts +339 -0
  273. package/vendor/@anvil/common/src/util/format-code-search.ts +115 -0
  274. package/vendor/@anvil/common/src/util/lazy-response-ads.ts +92 -0
  275. package/vendor/@anvil/common/src/util/log-data.ts +57 -0
  276. package/vendor/@anvil/common/src/util/log-ingest.ts +58 -0
  277. package/vendor/@anvil/common/src/util/log-mirror.ts +34 -0
  278. package/vendor/@anvil/common/src/util/lru-cache.ts +67 -0
  279. package/vendor/@anvil/common/src/util/messages.ts +685 -0
  280. package/vendor/@anvil/common/src/util/min-heap.ts +87 -0
  281. package/vendor/@anvil/common/src/util/model-utils.ts +4 -0
  282. package/vendor/@anvil/common/src/util/object.ts +128 -0
  283. package/vendor/@anvil/common/src/util/partial-json-delta.ts +89 -0
  284. package/vendor/@anvil/common/src/util/path.ts +15 -0
  285. package/vendor/@anvil/common/src/util/project-ignore.ts +119 -0
  286. package/vendor/@anvil/common/src/util/promise.ts +73 -0
  287. package/vendor/@anvil/common/src/util/random.ts +15 -0
  288. package/vendor/@anvil/common/src/util/rate-limit.ts +56 -0
  289. package/vendor/@anvil/common/src/util/reddit-anvil-retention.ts +60 -0
  290. package/vendor/@anvil/common/src/util/reddit-capi-events.ts +36 -0
  291. package/vendor/@anvil/common/src/util/response-ad-positions.ts +54 -0
  292. package/vendor/@anvil/common/src/util/saxy.ts +741 -0
  293. package/vendor/@anvil/common/src/util/skills.test.ts +44 -0
  294. package/vendor/@anvil/common/src/util/skills.ts +36 -0
  295. package/vendor/@anvil/common/src/util/split-data.ts +259 -0
  296. package/vendor/@anvil/common/src/util/stop-sequence.ts +61 -0
  297. package/vendor/@anvil/common/src/util/string.ts +426 -0
  298. package/vendor/@anvil/common/src/util/system-info.ts +53 -0
  299. package/vendor/@anvil/common/src/util/thread-title.ts +46 -0
  300. package/vendor/@anvil/common/src/util/ttft-histogram.ts +73 -0
  301. package/vendor/@anvil/common/src/util/xml-parser.ts +27 -0
  302. package/vendor/@anvil/common/src/util/xml.ts +17 -0
  303. package/vendor/@anvil/common/src/util/zod-schema.ts +25 -0
  304. package/vendor/@anvil/common/src/util/zoned-time.ts +136 -0
  305. package/vendor/@anvil/common/src/utils/ask-user-bridge.ts +44 -0
  306. package/vendor/@anvil/sdk/dist/index.cjs +52297 -0
  307. package/vendor/@anvil/sdk/dist/index.cjs.map +440 -0
  308. package/vendor/@anvil/sdk/dist/index.d.ts +4277 -0
  309. package/vendor/@anvil/sdk/dist/index.mjs +52290 -0
  310. package/vendor/@anvil/sdk/dist/index.mjs.map +440 -0
  311. package/vendor/@anvil/sdk/dist/vendor/ai.cjs +30886 -0
  312. package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
  313. package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-linux/rg +0 -0
  314. package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-darwin/rg +0 -0
  315. package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-linux/rg +0 -0
  316. package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
  317. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
  318. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-cpp.wasm +0 -0
  319. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-go.wasm +0 -0
  320. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-java.wasm +0 -0
  321. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-javascript.wasm +0 -0
  322. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-python.wasm +0 -0
  323. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-ruby.wasm +0 -0
  324. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-rust.wasm +0 -0
  325. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-tsx.wasm +0 -0
  326. package/vendor/@anvil/sdk/dist/wasm/tree-sitter-typescript.wasm +0 -0
  327. package/vendor/@anvil/sdk/dist/wasm/tree-sitter.wasm +0 -0
  328. package/vendor/@anvil/sdk/package.json +21 -0
@@ -0,0 +1,168 @@
1
+ import z from 'zod/v4'
2
+
3
+ import { $getNativeToolCallExampleString, jsonToolResultSchema } from '../utils'
4
+
5
+ import type { $ToolParams } from '../../constants'
6
+
7
+ const toolName = 'render_ui'
8
+ const endsAgentStep = false
9
+
10
+ const buttonLinkSchema = z
11
+ .string()
12
+ .url()
13
+ .refine(
14
+ (value) => {
15
+ try {
16
+ const url = new URL(value)
17
+ return url.protocol === 'https:' || url.protocol === 'http:'
18
+ } catch {
19
+ return false
20
+ }
21
+ },
22
+ { message: 'Button links must use http:// or https://' },
23
+ )
24
+
25
+ const gravityIndexButtonLinkSchema = z
26
+ .object({
27
+ source: z.literal('gravity_index'),
28
+ search_id: z
29
+ .string()
30
+ .min(1)
31
+ .describe('The exact search_id returned by gravity_index.'),
32
+ service_slug: z
33
+ .string()
34
+ .min(1)
35
+ .describe(
36
+ 'The exact slug of the recommendation or option selected from that search.',
37
+ ),
38
+ })
39
+ .describe(
40
+ 'A reference to a tracked click URL in a prior gravity_index search result. The runtime substitutes the exact stored URL.',
41
+ )
42
+
43
+ export type RenderUIGravityIndexLink = z.infer<
44
+ typeof gravityIndexButtonLinkSchema
45
+ >
46
+
47
+ const buttonWidgetBaseSchema = z.object({
48
+ type: z
49
+ .literal('button')
50
+ .describe('Widget type. Currently, the only supported widget is button.'),
51
+ text: z
52
+ .string()
53
+ .min(1)
54
+ .max(80)
55
+ .describe('Short button label shown to the user.'),
56
+ variant: z
57
+ .enum(['primary', 'secondary'])
58
+ .optional()
59
+ .default('primary')
60
+ .describe(
61
+ 'Theme-aware color treatment. Use primary for the main action and secondary for lower-emphasis actions.',
62
+ ),
63
+ })
64
+
65
+ const resolvedButtonWidgetSchema = buttonWidgetBaseSchema.extend({
66
+ link: buttonLinkSchema.describe(
67
+ 'The http:// or https:// URL to open when the user clicks the button.',
68
+ ),
69
+ })
70
+
71
+ const buttonWidgetSchema = buttonWidgetBaseSchema.extend({
72
+ link: z
73
+ .union([buttonLinkSchema, gravityIndexButtonLinkSchema])
74
+ .describe(
75
+ 'Either an http(s) URL or a gravity_index reference that the runtime resolves to the exact tracked click URL.',
76
+ ),
77
+ })
78
+
79
+ export type RenderUIButtonWidget = z.infer<typeof resolvedButtonWidgetSchema>
80
+
81
+ /**
82
+ * Validates the resolved widget shape consumed by UI surfaces. Keeping this
83
+ * beside the tool schema gives CLI, Chat, Web, and Cloud one runtime contract.
84
+ */
85
+ export function parseRenderUIButtonWidget(
86
+ widget: unknown,
87
+ ): RenderUIButtonWidget | null {
88
+ const rawLink =
89
+ widget && typeof widget === 'object' && !Array.isArray(widget)
90
+ ? (widget as { link?: unknown }).link
91
+ : undefined
92
+ if (typeof rawLink !== 'string') return null
93
+
94
+ const result = resolvedButtonWidgetSchema.safeParse(widget)
95
+ if (!result.success || result.data.link !== rawLink) return null
96
+
97
+ const text = result.data.text.trim()
98
+ return text ? { ...result.data, text } : null
99
+ }
100
+
101
+ const widgetSchema = z.discriminatedUnion('type', [buttonWidgetSchema])
102
+
103
+ const inputSchema = z
104
+ .object({
105
+ widget: widgetSchema.describe('The UI widget to render.'),
106
+ })
107
+ .describe('Render a small interactive UI widget for the user.')
108
+
109
+ const outputSchema = z.object({
110
+ message: z.string(),
111
+ })
112
+
113
+ const description = `
114
+ Render a small interactive UI widget for the user.
115
+
116
+ Currently supported widgets:
117
+ - button: renders a clickable button with text and an http(s) link.
118
+
119
+ Use this when the user should click a clear action, such as opening a generated report, documentation page, checkout page, deployment URL, preview, or dashboard.
120
+
121
+ For a service selected from a gravity_index search, do not copy its opaque URL. Set \`link\` to a gravity_index reference containing the exact \`search_id\` and selected \`service_slug\`. The runtime verifies the selection against prior tool results and substitutes the exact stored click URL. Call render_ui only after deciding which service to recommend.
122
+
123
+ Color variants:
124
+ - primary: the main action
125
+ - secondary: a lower-emphasis action
126
+
127
+ Keep button text short and action-oriented.
128
+
129
+ ${$getNativeToolCallExampleString({
130
+ toolName,
131
+ inputSchema,
132
+ input: {
133
+ widget: {
134
+ type: 'button',
135
+ text: 'Open preview',
136
+ link: 'https://example.com/preview',
137
+ variant: 'primary',
138
+ },
139
+ },
140
+ endsAgentStep,
141
+ })}
142
+
143
+ ${$getNativeToolCallExampleString({
144
+ toolName,
145
+ inputSchema,
146
+ input: {
147
+ widget: {
148
+ type: 'button',
149
+ text: 'Get your Resend API key',
150
+ link: {
151
+ source: 'gravity_index',
152
+ search_id: 'search_id_from_gravity_index',
153
+ service_slug: 'resend',
154
+ },
155
+ variant: 'primary',
156
+ },
157
+ },
158
+ endsAgentStep,
159
+ })}
160
+ `.trim()
161
+
162
+ export const renderUIParams = {
163
+ toolName,
164
+ endsAgentStep,
165
+ description,
166
+ inputSchema,
167
+ outputSchema: jsonToolResultSchema(outputSchema),
168
+ } satisfies $ToolParams
@@ -0,0 +1,57 @@
1
+ import z from 'zod/v4'
2
+
3
+ import { terminalCommandOutputSchema } from './run-terminal-command'
4
+ import { $getNativeToolCallExampleString, jsonToolResultSchema } from '../utils'
5
+
6
+ import type { $ToolParams } from '../../constants'
7
+
8
+ const toolName = 'run_file_change_hooks'
9
+ const endsAgentStep = true
10
+ const inputSchema = z.object({
11
+ files: z
12
+ .array(z.string())
13
+ .describe(
14
+ `List of file paths that were changed and should trigger file change hooks`,
15
+ ),
16
+ })
17
+ const description = `
18
+ Purpose: Trigger client-configured file change hooks for the specified files. This tool allows the backend to request the client to run its configured file change hooks (like tests, linting, type checking) after file changes have been applied.
19
+
20
+ Use cases:
21
+ - After making code changes, trigger the relevant tests and checks
22
+ - Ensure code quality by running configured linters and type checkers
23
+ - Validate that changes don't break the build
24
+
25
+ The client will run only the hooks whose filePattern matches the provided files.
26
+
27
+ Example:
28
+ ${$getNativeToolCallExampleString({
29
+ toolName,
30
+ inputSchema,
31
+ input: {
32
+ files: ['src/components/Button.tsx', 'src/utils/helpers.ts'],
33
+ },
34
+ endsAgentStep,
35
+ })}
36
+ `.trim()
37
+
38
+ export const runFileChangeHooksParams = {
39
+ toolName,
40
+ endsAgentStep,
41
+ description,
42
+ inputSchema,
43
+ outputSchema: jsonToolResultSchema(
44
+ z
45
+ .union([
46
+ terminalCommandOutputSchema.and(
47
+ z.object({
48
+ hookName: z.string(),
49
+ }),
50
+ ),
51
+ z.object({
52
+ errorMessage: z.string(),
53
+ }),
54
+ ])
55
+ .array(),
56
+ ),
57
+ } satisfies $ToolParams
@@ -0,0 +1,211 @@
1
+ import z from 'zod/v4'
2
+
3
+ import { $getNativeToolCallExampleString, jsonToolResultSchema } from '../utils'
4
+
5
+ import type { $ToolParams } from '../../constants'
6
+
7
+ /**
8
+ * Ceiling on a model-chosen SYNC command timeout.
9
+ *
10
+ * The value came straight from the model to the client with nothing in between
11
+ * — no clamp anywhere in the runtime — and the only guidance was "Default 30".
12
+ * In practice models picked 3-minute, 10-minute and 50-minute budgets for work
13
+ * that finishes in seconds, and the cost of an over-long value is paid entirely
14
+ * by the user: when the command does hang, they wait the whole budget watching
15
+ * nothing happen.
16
+ *
17
+ * 10 minutes is above any legitimate SYNC command we ship (the longest bundled
18
+ * agent budget is the librarian's 180s `git clone`) while cutting the tail that
19
+ * makes a hang indistinguishable from a freeze. Genuinely open-ended work has
20
+ * two better doors that this does not touch: `-1` for an explicit indefinite
21
+ * wait, and `process_type: BACKGROUND` for long-running processes.
22
+ */
23
+ export const MAX_TERMINAL_TIMEOUT_SECONDS = 600
24
+ export const MAX_TERMINAL_TIMEOUT_MINUTES = MAX_TERMINAL_TIMEOUT_SECONDS / 60
25
+
26
+ /** Clamp a model-supplied timeout, preserving the -1 "no timeout" sentinel and
27
+ * leaving an absent value to the schema default. */
28
+ export function clampTerminalTimeoutSeconds(
29
+ seconds: number | undefined,
30
+ ): number | undefined {
31
+ if (seconds === undefined) return undefined
32
+ if (seconds === -1) return -1
33
+ if (!Number.isFinite(seconds)) return MAX_TERMINAL_TIMEOUT_SECONDS
34
+ // A zero or negative value other than -1 is nonsense rather than a request
35
+ // for a short wait; fall back to the default instead of failing instantly.
36
+ if (seconds <= 0) return 30
37
+ return Math.min(seconds, MAX_TERMINAL_TIMEOUT_SECONDS)
38
+ }
39
+
40
+ export const terminalCommandOutputSchema = z.union([
41
+ z.object({
42
+ command: z.string(),
43
+ startingCwd: z.string().optional(),
44
+ message: z.string().optional(),
45
+ stderr: z.string().optional(),
46
+ stdout: z.string().optional(),
47
+ exitCode: z.number().optional(),
48
+ }),
49
+ z.object({
50
+ command: z.string(),
51
+ startingCwd: z.string().optional(),
52
+ message: z.string().optional(),
53
+ stderr: z.string().optional(),
54
+ stdoutOmittedForLength: z.literal(true),
55
+ exitCode: z.number().optional(),
56
+ }),
57
+ z.object({
58
+ command: z.string(),
59
+ processId: z.number(),
60
+ backgroundProcessStatus: z.enum(['running', 'completed', 'error']),
61
+ }),
62
+ z.object({
63
+ command: z.string(),
64
+ errorMessage: z.string(),
65
+ }),
66
+ ])
67
+
68
+ export const gitCommitGuidePrompt = `
69
+ ### Using git to commit changes
70
+
71
+ When the user requests a new git commit, please follow these steps closely:
72
+
73
+ 1. **Run two run_terminal_command tool calls:**
74
+ - Run \`git diff\` to review both staged and unstaged modifications.
75
+ - Run \`git log\` to check recent commit messages, ensuring consistency with this repository's style.
76
+
77
+ 2. **Select relevant files to include in the commit:**
78
+ Use the git context established at the start of this conversation to decide which files are pertinent to the changes. Stage any new untracked files that are relevant, but avoid committing previously modified files (from the beginning of the conversation) unless they directly relate to this commit.
79
+
80
+ 3. **Analyze the staged changes and compose a commit message:**
81
+ Enclose your analysis in <commit_analysis> tags. Within these tags, you should:
82
+ - Note which files have been altered or added.
83
+ - Categorize the nature of the changes (e.g., new feature, fix, refactor, documentation, etc.).
84
+ - Consider the purpose or motivation behind the alterations.
85
+ - Refrain from using tools to inspect code beyond what is presented in the git context.
86
+ - Evaluate the overall impact on the project.
87
+ - Check for sensitive details that should not be committed.
88
+ - Draft a concise, one- to two-sentence commit message focusing on the “why” rather than the “what.”
89
+ - Use precise, straightforward language that accurately represents the changes.
90
+ - Ensure the message provides clarity—avoid generic or vague terms like “Update” or “Fix” without context.
91
+ - Revisit your draft to confirm it truly reflects the changes and their intention.
92
+
93
+ 4. **Create the commit, ending with this specific footer:**
94
+ \`\`\`
95
+ Generated with Anvil 🤖
96
+ Co-Authored-By: Anvil <noreply@codebuff.com>
97
+ \`\`\`
98
+ Commands run in bash on every OS (Git Bash on Windows), so always use HEREDOC syntax to format the message:
99
+ \`\`\`
100
+ git commit -m "$(cat <<'EOF'
101
+ Your commit message here.
102
+
103
+ 🤖 Generated with Anvil
104
+ Co-Authored-By: Anvil <noreply@codebuff.com>
105
+ EOF
106
+ )"
107
+ \`\`\`
108
+
109
+ **Important details**
110
+
111
+ - When feasible, use a single \`git commit -am\` command to add and commit together, but do not accidentally stage unrelated files.
112
+ - Never alter the git config.
113
+ - Do not push to the remote repository.
114
+ - Avoid using interactive flags (e.g., \`-i\`) that require unsupported interactive input.
115
+ - Do not create an empty commit if there are no changes.
116
+ - Make sure your commit message is concise yet descriptive, focusing on the intention behind the changes rather than merely describing them.
117
+ `
118
+
119
+ const toolName = 'run_terminal_command'
120
+ const endsAgentStep = true
121
+ const inputSchema = z
122
+ .object({
123
+ // Can be empty to use it for a timeout.
124
+ command: z
125
+ .string()
126
+ .min(1, 'Command cannot be empty')
127
+ .describe(
128
+ `CLI command. Always executed with bash (Git Bash on Windows), so use POSIX syntax on every OS: \`mv\`/\`rm\`, \`/dev/null\`, heredocs. Never use cmd.exe syntax like \`del\`, \`move\`, or \`> nul\` — on Windows \`> nul\` creates a literal file named "nul" that is very hard to delete.`,
129
+ ),
130
+ process_type: z
131
+ .enum(['SYNC', 'BACKGROUND'])
132
+ .default('SYNC')
133
+ .describe(
134
+ `Either SYNC (waits, returns output) or BACKGROUND (runs in background). Default SYNC`,
135
+ ),
136
+ cwd: z
137
+ .string()
138
+ .optional()
139
+ .describe(
140
+ `The working directory to run the command in. Default is the project root.`,
141
+ ),
142
+ timeout_seconds: z
143
+ .number()
144
+ .default(30)
145
+ .optional()
146
+ .transform(clampTerminalTimeoutSeconds)
147
+ .describe(
148
+ `How long to wait, in seconds. Default 30, which is right for almost everything — omit this field unless the command genuinely runs longer. Budget for the command you are actually running (a typecheck or test run is tens of seconds, not minutes); an over-long value does not make a command safer, it just means you wait that long when something hangs. Values above ${MAX_TERMINAL_TIMEOUT_SECONDS} (${MAX_TERMINAL_TIMEOUT_MINUTES} minutes) are clamped. Set to -1 to wait indefinitely, for genuinely open-ended commands only. Does not apply for BACKGROUND commands — use those for long-running processes instead.`,
149
+ ),
150
+ })
151
+ .describe(
152
+ `Execute a CLI command from the **project root** (different from the user's cwd).`,
153
+ )
154
+ const description = `
155
+ Stick to these use cases:
156
+ 1. Typechecking the project or running build (e.g., "npm run build"). Reading the output can help you edit code to fix build errors. If possible, use an option that performs checks but doesn't emit files, e.g. \`tsc --noEmit\`.
157
+ 2. Running tests (e.g., "npm test"). Reading the output can help you edit code to fix failing tests. Or, you could write new unit tests and then run them.
158
+ 3. Moving, renaming, or deleting files and directories. These actions can be vital for refactoring requests. Use \`mv\` or \`rm\` (commands run in bash on every OS, including Windows — do not use \`move\`/\`del\`).
159
+
160
+ Most likely, you should ask for permission for any other type of command you want to run. If asking for permission, show the user the command you want to run using \`\`\` tags and *do not* use the tool call format, e.g.:
161
+ \`\`\`bash
162
+ git branch -D foo
163
+ \`\`\`
164
+
165
+ DO NOT do any of the following:
166
+ 1. Run commands that can modify files outside of the project directory, install packages globally, install virtual environments, or have significant side effects outside of the project directory, unless you have explicit permission from the user. Treat anything outside of the project directory as read-only.
167
+ 2. Run \`git push\` because it can break production (!) if the user was not expecting it. Don't run \`git commit\`, \`git rebase\`, or related commands unless you get explicit permission. If a user asks to commit changes, you can do so, but you should not invoke any further git commands beyond the git commit command.
168
+ 3. Run scripts without asking. Especially don't run scripts that could run against the production environment or have permanent effects without explicit permission from the user.
169
+ 4. Be careful with any command that has big or irreversible effects. Anything that touches a production environment, servers, the database, or other systems that could be affected by a command should be run with explicit permission from the user.
170
+ 5. Use the run_terminal_command tool to create or edit files. Do not use \`cat\` or \`echo\` to create or edit files. You should instead use other tools for creating or editing files.
171
+ 6. Use the wrong package manager for the project. For example, if the project uses \`pnpm\` or \`bun\` or \`yarn\`, you should not use \`npm\`. Similarly not everyone uses \`pip\` for python, etc.
172
+
173
+ Do:
174
+ - If there's an opportunity to use "-y" or "--yes" flags, use them. Any command that prompts for confirmation will hang if you don't use the flags.
175
+
176
+ Notes:
177
+ - If the user references a specific file, it could be either from their cwd or from the project root. You **must** determine which they are referring to (either infer or ask). Then, you must specify the path relative to the project root (or use the cwd parameter)
178
+ - Commands can succeed without giving any output, e.g. if no type errors were found.
179
+
180
+ ${gitCommitGuidePrompt}
181
+
182
+ Example:
183
+ ${$getNativeToolCallExampleString({
184
+ toolName,
185
+ inputSchema,
186
+ input: {
187
+ command: 'echo "hello world"',
188
+ },
189
+ endsAgentStep,
190
+ })}
191
+
192
+ ${$getNativeToolCallExampleString({
193
+ toolName,
194
+ inputSchema,
195
+ input: {
196
+ command: `git commit -m "Your commit message here.
197
+
198
+ 🤖 Generated with Anvil
199
+ Co-Authored-By: Anvil <noreply@codebuff.com>"`,
200
+ },
201
+ endsAgentStep,
202
+ })}
203
+ `.trim()
204
+
205
+ export const runTerminalCommandParams = {
206
+ toolName,
207
+ endsAgentStep,
208
+ description,
209
+ inputSchema,
210
+ outputSchema: jsonToolResultSchema(terminalCommandOutputSchema),
211
+ } satisfies $ToolParams
@@ -0,0 +1,97 @@
1
+ import z from 'zod/v4'
2
+
3
+ import { jsonToolResultSchema } from '../utils'
4
+
5
+ import type { $ToolParams } from '../../constants'
6
+
7
+ const toolName = 'screenshot'
8
+ const endsAgentStep = true
9
+
10
+ const inputSchema = z
11
+ .object({
12
+ url: z
13
+ .string()
14
+ .describe(
15
+ 'The URL to capture. Can be a local dev server (http://localhost:3000) or any public URL.',
16
+ ),
17
+ output_path: z
18
+ .string()
19
+ .optional()
20
+ .describe(
21
+ 'File path to save the screenshot. Defaults to ./screenshot.png relative to the project root.',
22
+ ),
23
+ width: z
24
+ .number()
25
+ .optional()
26
+ .default(1280)
27
+ .describe('Viewport width in pixels. Default 1280.'),
28
+ height: z
29
+ .number()
30
+ .optional()
31
+ .default(800)
32
+ .describe('Viewport height in pixels. Default 800.'),
33
+ full_page: z
34
+ .boolean()
35
+ .optional()
36
+ .default(false)
37
+ .describe(
38
+ 'If true, capture the full scrollable page. If false, capture only the viewport.',
39
+ ),
40
+ wait_ms: z
41
+ .number()
42
+ .optional()
43
+ .default(2000)
44
+ .describe(
45
+ 'Milliseconds to wait after page load before capturing. Allows animations and lazy content to render. Default 2000.',
46
+ ),
47
+ dark_mode: z
48
+ .boolean()
49
+ .optional()
50
+ .default(false)
51
+ .describe(
52
+ 'If true, emulate dark mode (prefers-color-scheme: dark) before capturing.',
53
+ ),
54
+ })
55
+ .describe(
56
+ 'Capture a screenshot of a web page using Chrome headless. Requires Chrome to be installed.',
57
+ )
58
+
59
+ const screenshotOutputSchema = z.object({
60
+ success: z.boolean(),
61
+ output_path: z.string().optional(),
62
+ message: z.string(),
63
+ width: z.number(),
64
+ height: z.number(),
65
+ })
66
+
67
+ const description = `
68
+ Capture a screenshot of a web page using Chrome's headless mode.
69
+
70
+ **Use cases:**
71
+ - After building a UI, screenshot it to verify the visual result
72
+ - Capture before/after states for comparison
73
+ - Feed screenshots to vision_analyze for AI-powered design critique
74
+
75
+ **How it works:**
76
+ 1. Launches Chrome in headless mode with the specified viewport
77
+ 2. Navigates to the URL and waits for content to render
78
+ 3. Captures the screenshot (viewport or full page)
79
+ 4. Saves to the specified output path
80
+
81
+ **Requirements:**
82
+ - Chrome must be installed on the system
83
+ - The URL must be accessible (local dev server or public URL)
84
+
85
+ **Examples:**
86
+ - Screenshot a local dev server: url="http://localhost:3000"
87
+ - Screenshot with dark mode: url="http://localhost:3000", dark_mode=true
88
+ - Full page screenshot: url="http://localhost:3000", full_page=true
89
+ `.trim()
90
+
91
+ export const screenshotParams = {
92
+ toolName,
93
+ endsAgentStep,
94
+ description,
95
+ inputSchema,
96
+ outputSchema: jsonToolResultSchema(screenshotOutputSchema),
97
+ } satisfies $ToolParams
@@ -0,0 +1,44 @@
1
+ import z from 'zod/v4'
2
+
3
+ import {
4
+ $getNativeToolCallExampleString,
5
+ textToolResultSchema,
6
+ } from '../utils'
7
+
8
+ import type { $ToolParams } from '../../constants'
9
+
10
+ const toolName = 'set_messages'
11
+ const endsAgentStep = true
12
+ const inputSchema = z
13
+ .object({
14
+ messages: z.any(),
15
+ })
16
+ .describe(`Set the conversation history to the provided messages.`)
17
+ const description = `
18
+ Example:
19
+ ${$getNativeToolCallExampleString({
20
+ toolName,
21
+ inputSchema,
22
+ input: {
23
+ messages: [
24
+ {
25
+ role: 'user',
26
+ content: 'Hello, how are you?',
27
+ },
28
+ {
29
+ role: 'assistant',
30
+ content: 'I am fine, thank you.',
31
+ },
32
+ ],
33
+ },
34
+ endsAgentStep,
35
+ })}
36
+ `.trim()
37
+
38
+ export const setMessagesParams = {
39
+ toolName,
40
+ endsAgentStep,
41
+ description,
42
+ inputSchema,
43
+ outputSchema: textToolResultSchema(),
44
+ } satisfies $ToolParams
@@ -0,0 +1,61 @@
1
+ import z from 'zod/v4'
2
+
3
+ import { $getNativeToolCallExampleString } from '../utils'
4
+
5
+ import type { $ToolParams } from '../../constants'
6
+
7
+ const toolName = 'set_output'
8
+ const endsAgentStep = false
9
+
10
+ // WHY `data` EXISTS IN THE INPUT SCHEMA:
11
+ // Subagents inherit their parent's tool definitions, and because of prompt caching
12
+ // we cannot modify or add tools mid-conversation. OpenAI models enforce the tool's
13
+ // input schema strictly, so we need a permissive shape that any model can call.
14
+ // An empty schema or `z.object({}).passthrough()` would be rejected by OpenAI's
15
+ // strict schema enforcement. The `data: z.record(...)` field is a deliberately
16
+ // vague shape that satisfies OpenAI while allowing us to inject the real
17
+ // outputSchema later in the conversation (in the instructions prompt).
18
+ //
19
+ // At runtime, the handler (`packages/agent-runtime/src/tools/handlers/tool/set-output.ts`)
20
+ // tries parsing against the real outputSchema in two ways:
21
+ // 1. Parse the raw output (agent passed fields at top level)
22
+ // 2. Fallback: parse `output.data` (agent wrapped fields in `data`)
23
+ // This means both `{ results: [...] }` and `{ data: { results: [...] } }` are accepted.
24
+ const inputSchema = z
25
+ .looseObject({
26
+ data: z.record(z.string(), z.any()).optional(),
27
+ })
28
+ .describe(
29
+ 'JSON object to set as the agent output. The shape of the parameters are specified dynamically further down in the conversation. This completely replaces any previous output. If the agent was spawned, this value will be passed back to its parent. If the agent has an outputSchema defined, the output will be validated against it.',
30
+ )
31
+ const description = `
32
+ Subagents must use this tool as it is the only way to report any findings. Nothing else you write will be visible to the user/parent agent.
33
+
34
+ Note that the output schema is provided dynamically in a user prompt further down in the conversation. Be sure to follow what the latest output schema is when using this tool.
35
+
36
+ Please set the output with all the information and analysis you want to pass on. If you just want to send a simple message, use an object with the key "message" and value of the message you want to send.
37
+ Example:
38
+ ${$getNativeToolCallExampleString({
39
+ toolName,
40
+ inputSchema,
41
+ input: {
42
+ message: 'I found a bug in the code!',
43
+ },
44
+ endsAgentStep,
45
+ })}
46
+ `.trim()
47
+
48
+ export const setOutputParams = {
49
+ toolName,
50
+ endsAgentStep,
51
+ description,
52
+ inputSchema,
53
+ outputSchema: z.tuple([
54
+ z.object({
55
+ type: z.literal('json'),
56
+ value: z.object({
57
+ message: z.string(),
58
+ }),
59
+ }),
60
+ ]),
61
+ } satisfies $ToolParams