@alumbwe/anvil 1.0.20 → 1.0.21

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 +6 -2
  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,4277 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /// <reference types="node" />
4
+
5
+ type SourceReader = (filePath: string) => string | null | Promise<string | null>;
6
+ export interface TokenCallerMap {
7
+ [filePath: string]: {
8
+ [token: string]: string[];
9
+ };
10
+ }
11
+ export interface FileTokenData {
12
+ tokenScores: {
13
+ [filePath: string]: {
14
+ [token: string]: number;
15
+ };
16
+ };
17
+ tokenCallers: TokenCallerMap;
18
+ }
19
+ declare function getFileTokenScores(projectRoot: string, filePaths: string[], readFile?: SourceReader): Promise<FileTokenData>;
20
+ export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
21
+ export declare const jsonValueSchema: z.ZodType<JSONValue>;
22
+ export declare const jsonObjectSchema: z.ZodType<JSONObject>;
23
+ export type JSONObject = {
24
+ [key in string]: JSONValue | undefined;
25
+ };
26
+ export declare const jsonArraySchema: z.ZodType<JSONArray>;
27
+ export type JSONArray = JSONValue[];
28
+ type ProviderMetadata = Record<string, Record<string, JSONValue | undefined>>;
29
+ declare const textPartSchema: z.ZodObject<{
30
+ type: z.ZodLiteral<"text">;
31
+ text: z.ZodString;
32
+ providerOptions: z.ZodOptional<z.ZodType<ProviderMetadata, unknown, z.core.$ZodTypeInternals<ProviderMetadata, unknown>>>;
33
+ }, z.core.$strip>;
34
+ export type TextPart = z.infer<typeof textPartSchema>;
35
+ declare const imagePartSchema: z.ZodObject<{
36
+ type: z.ZodLiteral<"image">;
37
+ image: z.ZodUnion<readonly [
38
+ z.ZodUnion<readonly [
39
+ z.ZodString,
40
+ z.ZodCustom<Uint8Array, Uint8Array>,
41
+ z.ZodCustom<ArrayBuffer, ArrayBuffer>,
42
+ z.ZodCustom<Buffer, Buffer>
43
+ ]>,
44
+ z.ZodCustom<URL, URL>
45
+ ]>;
46
+ mediaType: z.ZodOptional<z.ZodString>;
47
+ providerOptions: z.ZodOptional<z.ZodType<ProviderMetadata, unknown, z.core.$ZodTypeInternals<ProviderMetadata, unknown>>>;
48
+ }, z.core.$strip>;
49
+ export type ImagePart = z.infer<typeof imagePartSchema>;
50
+ declare const filePartSchema: z.ZodObject<{
51
+ type: z.ZodLiteral<"file">;
52
+ data: z.ZodUnion<readonly [
53
+ z.ZodUnion<readonly [
54
+ z.ZodString,
55
+ z.ZodCustom<Uint8Array, Uint8Array>,
56
+ z.ZodCustom<ArrayBuffer, ArrayBuffer>,
57
+ z.ZodCustom<Buffer, Buffer>
58
+ ]>,
59
+ z.ZodCustom<URL, URL>
60
+ ]>;
61
+ filename: z.ZodOptional<z.ZodString>;
62
+ mediaType: z.ZodString;
63
+ providerOptions: z.ZodOptional<z.ZodType<ProviderMetadata, unknown, z.core.$ZodTypeInternals<ProviderMetadata, unknown>>>;
64
+ }, z.core.$strip>;
65
+ type FilePart = z.infer<typeof filePartSchema>;
66
+ declare const reasoningPartSchema: z.ZodObject<{
67
+ type: z.ZodLiteral<"reasoning">;
68
+ text: z.ZodString;
69
+ providerOptions: z.ZodOptional<z.ZodType<ProviderMetadata, unknown, z.core.$ZodTypeInternals<ProviderMetadata, unknown>>>;
70
+ }, z.core.$strip>;
71
+ type ReasoningPart = z.infer<typeof reasoningPartSchema>;
72
+ declare const toolCallPartSchema: z.ZodObject<{
73
+ type: z.ZodLiteral<"tool-call">;
74
+ toolCallId: z.ZodString;
75
+ toolName: z.ZodString;
76
+ input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
77
+ providerOptions: z.ZodOptional<z.ZodType<ProviderMetadata, unknown, z.core.$ZodTypeInternals<ProviderMetadata, unknown>>>;
78
+ providerExecuted: z.ZodOptional<z.ZodBoolean>;
79
+ }, z.core.$strip>;
80
+ type ToolCallPart = z.infer<typeof toolCallPartSchema>;
81
+ declare const toolResultOutputSchema: z.ZodDiscriminatedUnion<[
82
+ z.ZodObject<{
83
+ type: z.ZodLiteral<"json">;
84
+ value: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
85
+ }, z.core.$strip>,
86
+ z.ZodObject<{
87
+ type: z.ZodLiteral<"media">;
88
+ data: z.ZodString;
89
+ mediaType: z.ZodString;
90
+ }, z.core.$strip>
91
+ ], "type">;
92
+ type ToolResultOutput = z.infer<typeof toolResultOutputSchema>;
93
+ export type AuxiliaryMessageData = {
94
+ providerOptions?: ProviderMetadata;
95
+ tags?: string[];
96
+ /**
97
+ * Unix timestamp (ms) when the message was added to history.
98
+ * Used to detect prompt cache expiry (>5 min gap = cache miss).
99
+ * This field is stripped before sending to the LLM.
100
+ */
101
+ sentAt?: number;
102
+ /** @deprecated Use tags instead. */
103
+ timeToLive?: "agentStep" | "userPrompt";
104
+ /** @deprecated Use tags instead. */
105
+ keepDuringTruncation?: boolean;
106
+ /** @deprecated Use tags instead. */
107
+ keepLastTags?: string[];
108
+ };
109
+ export type SystemMessage = {
110
+ role: "system";
111
+ content: TextPart[];
112
+ } & AuxiliaryMessageData;
113
+ export type UserMessage = {
114
+ role: "user";
115
+ content: (TextPart | ImagePart | FilePart)[];
116
+ } & AuxiliaryMessageData;
117
+ export type AssistantMessage = {
118
+ role: "assistant";
119
+ content: (TextPart | ReasoningPart | ToolCallPart)[];
120
+ } & AuxiliaryMessageData;
121
+ export type ToolMessage = {
122
+ role: "tool";
123
+ toolCallId: string;
124
+ toolName: string;
125
+ content: ToolResultOutput[];
126
+ } & AuxiliaryMessageData;
127
+ export type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
128
+ export declare const dataContentSchema: z.ZodUnion<readonly [
129
+ z.ZodString,
130
+ z.ZodCustom<Uint8Array, Uint8Array>,
131
+ z.ZodCustom<ArrayBuffer, ArrayBuffer>,
132
+ z.ZodCustom<Buffer, Buffer>
133
+ ]>;
134
+ export type DataContent = z.infer<typeof dataContentSchema>;
135
+ export declare const printModeStartSchema: z.ZodObject<{
136
+ type: z.ZodLiteral<"start">;
137
+ agentId: z.ZodOptional<z.ZodString>;
138
+ messageHistoryLength: z.ZodNumber;
139
+ }, z.core.$strip>;
140
+ export type PrintModeStart = z.infer<typeof printModeStartSchema>;
141
+ export declare const printModeErrorSchema: z.ZodObject<{
142
+ type: z.ZodLiteral<"error">;
143
+ message: z.ZodString;
144
+ source: z.ZodOptional<z.ZodEnum<{
145
+ "stream-interrupted": "stream-interrupted";
146
+ "output-limit": "output-limit";
147
+ }>>;
148
+ }, z.core.$strip>;
149
+ export type PrintModeError = z.infer<typeof printModeErrorSchema>;
150
+ export declare const printModeDownloadStatusSchema: z.ZodObject<{
151
+ type: z.ZodLiteral<"download">;
152
+ version: z.ZodString;
153
+ status: z.ZodEnum<{
154
+ complete: "complete";
155
+ failed: "failed";
156
+ }>;
157
+ }, z.core.$strip>;
158
+ export type PrintModeDownloadStatus = z.infer<typeof printModeDownloadStatusSchema>;
159
+ export declare const printModeToolCallSchema: z.ZodObject<{
160
+ type: z.ZodLiteral<"tool_call">;
161
+ toolCallId: z.ZodString;
162
+ toolName: z.ZodString;
163
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
164
+ agentId: z.ZodOptional<z.ZodString>;
165
+ parentAgentId: z.ZodOptional<z.ZodString>;
166
+ includeToolCall: z.ZodOptional<z.ZodBoolean>;
167
+ }, z.core.$strip>;
168
+ export type PrintModeToolCall = z.infer<typeof printModeToolCallSchema>;
169
+ export declare const printModeToolResultSchema: z.ZodObject<{
170
+ type: z.ZodLiteral<"tool_result">;
171
+ toolCallId: z.ZodString;
172
+ toolName: z.ZodString;
173
+ output: z.ZodArray<z.ZodDiscriminatedUnion<[
174
+ z.ZodObject<{
175
+ type: z.ZodLiteral<"json">;
176
+ value: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
177
+ }, z.core.$strip>,
178
+ z.ZodObject<{
179
+ type: z.ZodLiteral<"media">;
180
+ data: z.ZodString;
181
+ mediaType: z.ZodString;
182
+ }, z.core.$strip>
183
+ ], "type">>;
184
+ parentAgentId: z.ZodOptional<z.ZodString>;
185
+ }, z.core.$strip>;
186
+ export type PrintModeToolResult = z.infer<typeof printModeToolResultSchema>;
187
+ export declare const printModeTextSchema: z.ZodObject<{
188
+ type: z.ZodLiteral<"text">;
189
+ text: z.ZodString;
190
+ agentId: z.ZodOptional<z.ZodString>;
191
+ }, z.core.$strip>;
192
+ export type PrintModeText = z.infer<typeof printModeTextSchema>;
193
+ export declare const printModeFinishSchema: z.ZodObject<{
194
+ type: z.ZodLiteral<"finish">;
195
+ agentId: z.ZodOptional<z.ZodString>;
196
+ totalCost: z.ZodNumber;
197
+ }, z.core.$strip>;
198
+ export type PrintModeFinish = z.infer<typeof printModeFinishSchema>;
199
+ export declare const printModeSubagentStartSchema: z.ZodObject<{
200
+ type: z.ZodLiteral<"subagent_start">;
201
+ agentId: z.ZodString;
202
+ agentType: z.ZodString;
203
+ displayName: z.ZodString;
204
+ onlyChild: z.ZodBoolean;
205
+ parentAgentId: z.ZodOptional<z.ZodString>;
206
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
207
+ prompt: z.ZodOptional<z.ZodString>;
208
+ }, z.core.$strip>;
209
+ export type PrintModeSubagentStart = z.infer<typeof printModeSubagentStartSchema>;
210
+ export declare const printModeSubagentFinishSchema: z.ZodObject<{
211
+ type: z.ZodLiteral<"subagent_finish">;
212
+ agentId: z.ZodString;
213
+ agentType: z.ZodString;
214
+ displayName: z.ZodString;
215
+ onlyChild: z.ZodBoolean;
216
+ parentAgentId: z.ZodOptional<z.ZodString>;
217
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
218
+ prompt: z.ZodOptional<z.ZodString>;
219
+ }, z.core.$strip>;
220
+ export type PrintModeSubagentFinish = z.infer<typeof printModeSubagentFinishSchema>;
221
+ export declare const printModeReasoningDeltaSchema: z.ZodObject<{
222
+ type: z.ZodLiteral<"reasoning_delta">;
223
+ text: z.ZodString;
224
+ ancestorRunIds: z.ZodArray<z.ZodString>;
225
+ runId: z.ZodString;
226
+ agentId: z.ZodString;
227
+ }, z.core.$strip>;
228
+ export type PrintModeReasoningDelta = z.infer<typeof printModeReasoningDeltaSchema>;
229
+ export declare const printModeEventSchema: z.ZodDiscriminatedUnion<[
230
+ z.ZodObject<{
231
+ type: z.ZodLiteral<"download">;
232
+ version: z.ZodString;
233
+ status: z.ZodEnum<{
234
+ complete: "complete";
235
+ failed: "failed";
236
+ }>;
237
+ }, z.core.$strip>,
238
+ z.ZodObject<{
239
+ type: z.ZodLiteral<"error">;
240
+ message: z.ZodString;
241
+ source: z.ZodOptional<z.ZodEnum<{
242
+ "stream-interrupted": "stream-interrupted";
243
+ "output-limit": "output-limit";
244
+ }>>;
245
+ }, z.core.$strip>,
246
+ z.ZodObject<{
247
+ type: z.ZodLiteral<"finish">;
248
+ agentId: z.ZodOptional<z.ZodString>;
249
+ totalCost: z.ZodNumber;
250
+ }, z.core.$strip>,
251
+ z.ZodObject<{
252
+ type: z.ZodLiteral<"start">;
253
+ agentId: z.ZodOptional<z.ZodString>;
254
+ messageHistoryLength: z.ZodNumber;
255
+ }, z.core.$strip>,
256
+ z.ZodObject<{
257
+ type: z.ZodLiteral<"subagent_finish">;
258
+ agentId: z.ZodString;
259
+ agentType: z.ZodString;
260
+ displayName: z.ZodString;
261
+ onlyChild: z.ZodBoolean;
262
+ parentAgentId: z.ZodOptional<z.ZodString>;
263
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
264
+ prompt: z.ZodOptional<z.ZodString>;
265
+ }, z.core.$strip>,
266
+ z.ZodObject<{
267
+ type: z.ZodLiteral<"subagent_start">;
268
+ agentId: z.ZodString;
269
+ agentType: z.ZodString;
270
+ displayName: z.ZodString;
271
+ onlyChild: z.ZodBoolean;
272
+ parentAgentId: z.ZodOptional<z.ZodString>;
273
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
274
+ prompt: z.ZodOptional<z.ZodString>;
275
+ }, z.core.$strip>,
276
+ z.ZodObject<{
277
+ type: z.ZodLiteral<"text">;
278
+ text: z.ZodString;
279
+ agentId: z.ZodOptional<z.ZodString>;
280
+ }, z.core.$strip>,
281
+ z.ZodObject<{
282
+ type: z.ZodLiteral<"tool_call">;
283
+ toolCallId: z.ZodString;
284
+ toolName: z.ZodString;
285
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
286
+ agentId: z.ZodOptional<z.ZodString>;
287
+ parentAgentId: z.ZodOptional<z.ZodString>;
288
+ includeToolCall: z.ZodOptional<z.ZodBoolean>;
289
+ }, z.core.$strip>,
290
+ z.ZodObject<{
291
+ type: z.ZodLiteral<"tool_result">;
292
+ toolCallId: z.ZodString;
293
+ toolName: z.ZodString;
294
+ output: z.ZodArray<z.ZodDiscriminatedUnion<[
295
+ z.ZodObject<{
296
+ type: z.ZodLiteral<"json">;
297
+ value: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
298
+ }, z.core.$strip>,
299
+ z.ZodObject<{
300
+ type: z.ZodLiteral<"media">;
301
+ data: z.ZodString;
302
+ mediaType: z.ZodString;
303
+ }, z.core.$strip>
304
+ ], "type">>;
305
+ parentAgentId: z.ZodOptional<z.ZodString>;
306
+ }, z.core.$strip>,
307
+ z.ZodObject<{
308
+ type: z.ZodLiteral<"reasoning_delta">;
309
+ text: z.ZodString;
310
+ ancestorRunIds: z.ZodArray<z.ZodString>;
311
+ runId: z.ZodString;
312
+ agentId: z.ZodString;
313
+ }, z.core.$strip>
314
+ ], "type">;
315
+ export type PrintModeEvent = z.infer<typeof printModeEventSchema>;
316
+ export declare const KNOWLEDGE_FILE_NAMES: readonly [
317
+ "AGENTS.md",
318
+ "CLAUDE.md"
319
+ ];
320
+ /**
321
+ * Checks if a file path is a knowledge file.
322
+ * Matches:
323
+ * - Exact file names: AGENTS.md, CLAUDE.md (case-insensitive)
324
+ * - Pattern: *.knowledge.md (e.g., authentication.knowledge.md)
325
+ */
326
+ export declare function isKnowledgeFile(filePath: string): boolean;
327
+ declare const toolNames: readonly [
328
+ "apply_patch",
329
+ "add_subgoal",
330
+ "add_message",
331
+ "ask_user",
332
+ "browser_logs",
333
+ "code_search",
334
+ "cloud_plan_ready",
335
+ "create_plan",
336
+ "end_turn",
337
+ "find_files",
338
+ "glob",
339
+ "gravity_index",
340
+ "list_directory",
341
+ "lookup_agent_info",
342
+ "propose_str_replace",
343
+ "propose_write_file",
344
+ "read_docs",
345
+ "read_files",
346
+ "read_subtree",
347
+ "read_url",
348
+ "render_ui",
349
+ "run_file_change_hooks",
350
+ "run_terminal_command",
351
+ "set_messages",
352
+ "set_output",
353
+ "skill",
354
+ "spawn_agents",
355
+ "spawn_agent_inline",
356
+ "str_replace",
357
+ "suggest_followups",
358
+ "task_completed",
359
+ "think_deeply",
360
+ "update_subgoal",
361
+ "screenshot",
362
+ "vision_analyze",
363
+ "web_search",
364
+ "write_file",
365
+ "write_todos",
366
+ "composio_manage_connections",
367
+ "composio_multi_execute_tool",
368
+ "composio_search_tools",
369
+ "composio_get_tool_schemas"
370
+ ];
371
+ declare const publishedTools: readonly [
372
+ "apply_patch",
373
+ "add_message",
374
+ "ask_user",
375
+ "code_search",
376
+ "cloud_plan_ready",
377
+ "end_turn",
378
+ "find_files",
379
+ "glob",
380
+ "gravity_index",
381
+ "list_directory",
382
+ "lookup_agent_info",
383
+ "propose_str_replace",
384
+ "propose_write_file",
385
+ "read_docs",
386
+ "read_files",
387
+ "read_subtree",
388
+ "read_url",
389
+ "render_ui",
390
+ "run_file_change_hooks",
391
+ "run_terminal_command",
392
+ "screenshot",
393
+ "vision_analyze",
394
+ "set_messages",
395
+ "set_output",
396
+ "skill",
397
+ "spawn_agents",
398
+ "str_replace",
399
+ "suggest_followups",
400
+ "task_completed",
401
+ "think_deeply",
402
+ "web_search",
403
+ "write_file",
404
+ "write_todos"
405
+ ];
406
+ export type ToolName = (typeof toolNames)[number];
407
+ type PublishedToolName = (typeof publishedTools)[number];
408
+ export type CustomToolDefinition<N extends string = string, Args extends any = any, Input extends any = any> = {
409
+ toolName: N;
410
+ inputSchema: z.ZodType<Args, Input>;
411
+ description: string;
412
+ endsAgentStep: boolean;
413
+ exampleInputs: Input[];
414
+ execute: (params: Args) => Promise<ToolResultOutput[]>;
415
+ };
416
+ /**
417
+ * Creates a CustomToolDefinition object
418
+ *
419
+ * @param toolName the name of the tool
420
+ * @param inputSchema a Zod4 schema describing the input of the tool.
421
+ * @param description a description of the tool to be passed to the LLM. This should describe what the tool does and when to use it.
422
+ * @param endsAgentStep whether the tool ends the agent step. If `true`, this will be used as a "stop sequence" for the LLM. i.e. it will not be able to call any other tools after this one in a single step and must wait for the tool results. Used for tools that give more information to the LLM.
423
+ * @param exampleInputs an array of example inputs for the tool.
424
+ * @param execute what to do when the tool is called. Can be either a sync or async. Must return an array of {@linkcode ToolResultOutput}
425
+ * @returns a {@linkcode CustomToolDefinition} object
426
+ */
427
+ export declare function getCustomToolDefinition<TN extends string, Args extends any, Input extends any>({ toolName, inputSchema, description, endsAgentStep, exampleInputs, execute, }: {
428
+ toolName: TN extends ToolName ? TN & {
429
+ error: `Hi there. This is a message from the Anvil team: You have used a custom tool where you needed to use overrideTools instead for name: ${TN}`;
430
+ } : TN;
431
+ inputSchema: z.ZodType<Args, Input>;
432
+ description: string;
433
+ endsAgentStep?: boolean;
434
+ exampleInputs?: Input[];
435
+ execute: (params: Args) => Promise<ToolResultOutput[]> | ToolResultOutput[];
436
+ }): CustomToolDefinition<TN, Args, Input>;
437
+ type ToolName$1 = "add_message" | "apply_patch" | "ask_user" | "cloud_plan_ready" | "code_search" | "end_turn" | "find_files" | "glob" | "gravity_index" | "list_directory" | "lookup_agent_info" | "propose_str_replace" | "propose_write_file" | "read_docs" | "read_files" | "read_subtree" | "read_url" | "render_ui" | "run_file_change_hooks" | "run_terminal_command" | "set_messages" | "set_output" | "skill" | "spawn_agents" | "str_replace" | "suggest_followups" | "task_completed" | "think_deeply" | "web_search" | "write_file" | "write_todos";
438
+ interface ToolParamsMap {
439
+ add_message: AddMessageParams;
440
+ apply_patch: ApplyPatchParams;
441
+ ask_user: AskUserParams;
442
+ cloud_plan_ready: CloudPlanReadyParams;
443
+ code_search: CodeSearchParams;
444
+ end_turn: EndTurnParams;
445
+ find_files: FindFilesParams;
446
+ glob: GlobParams;
447
+ gravity_index: GravityIndexParams;
448
+ list_directory: ListDirectoryParams;
449
+ lookup_agent_info: LookupAgentInfoParams;
450
+ propose_str_replace: ProposeStrReplaceParams;
451
+ propose_write_file: ProposeWriteFileParams;
452
+ read_docs: ReadDocsParams;
453
+ read_files: ReadFilesParams;
454
+ read_subtree: ReadSubtreeParams;
455
+ read_url: ReadUrlParams;
456
+ render_ui: RenderUiParams;
457
+ run_file_change_hooks: RunFileChangeHooksParams;
458
+ run_terminal_command: RunTerminalCommandParams;
459
+ set_messages: SetMessagesParams;
460
+ set_output: SetOutputParams;
461
+ skill: SkillParams;
462
+ spawn_agents: SpawnAgentsParams;
463
+ str_replace: StrReplaceParams;
464
+ suggest_followups: SuggestFollowupsParams;
465
+ task_completed: TaskCompletedParams;
466
+ think_deeply: ThinkDeeplyParams;
467
+ web_search: WebSearchParams;
468
+ write_file: WriteFileParams;
469
+ write_todos: WriteTodosParams;
470
+ }
471
+ interface AddMessageParams {
472
+ role: "user" | "assistant";
473
+ content: string;
474
+ }
475
+ interface ApplyPatchParams {
476
+ /** The file operation to perform. */
477
+ operation: {
478
+ /** Operation type: create_file, update_file, or delete_file */
479
+ type: "create_file" | "update_file" | "delete_file";
480
+ /** File path relative to project root */
481
+ path: string;
482
+ /** Diff content. Required for create_file and update_file. Lines prefixed with + for creates, unified diff with @@ hunks for updates. */
483
+ diff?: string;
484
+ };
485
+ }
486
+ interface AskUserParams {
487
+ /** List of multiple choice questions to ask the user */
488
+ questions: {
489
+ /** The question to ask the user */
490
+ question: string;
491
+ /** Short label (max 12 chars) displayed as a chip/tag */
492
+ header?: string;
493
+ /** Array of answer options with label and optional description (minimum 2) */
494
+ options: {
495
+ /** The display text for this option */
496
+ label: string;
497
+ /** Explanation shown when option is focused */
498
+ description?: string;
499
+ }[];
500
+ /** If true, allows selecting multiple options (checkbox). If false, single selection only (radio). */
501
+ multiSelect?: boolean;
502
+ /** Validation rules for "Other" text input */
503
+ validation?: {
504
+ /** Maximum length for "Other" text input */
505
+ maxLength?: number;
506
+ /** Minimum length for "Other" text input */
507
+ minLength?: number;
508
+ /** Regex pattern for "Other" text input */
509
+ pattern?: string;
510
+ /** Custom error message when pattern fails */
511
+ patternError?: string;
512
+ };
513
+ }[];
514
+ }
515
+ interface CloudPlanReadyParams {
516
+ summary: string;
517
+ stack: string[];
518
+ build_prompt: string;
519
+ }
520
+ interface CodeSearchParams {
521
+ /** The pattern to search for. */
522
+ pattern: string;
523
+ /** Optional ripgrep flags to customize the search (e.g., "-i" for case-insensitive, "-g *.ts -g *.js" for TypeScript and JavaScript files only, "-g !*.test.ts" to exclude Typescript test files, "-A 3" for 3 lines after match, "-B 2" for 2 lines before match). */
524
+ flags?: string;
525
+ /** Optional working directory to search within, relative to the project root. Defaults to searching the entire project. */
526
+ cwd?: string;
527
+ /** Maximum number of results to return per file. Defaults to 15. There is also a global limit of 250 results across all files. */
528
+ maxResults?: number;
529
+ }
530
+ interface EndTurnParams {
531
+ }
532
+ interface FindFilesParams {
533
+ /** A brief natural language description of the files or the name of a function or class you are looking for. It's also helpful to mention a directory or two to look within. */
534
+ prompt: string;
535
+ }
536
+ interface GlobParams {
537
+ /** Glob pattern to match files against (e.g., *.js, src/glob/*.ts, glob/test/glob/*.go). */
538
+ pattern: string;
539
+ /** Optional working directory to search within, relative to project root. If not provided, searches from project root. */
540
+ cwd?: string;
541
+ }
542
+ interface GravityIndexParams {
543
+ /** Which Gravity Index operation to perform. search: recommend a provider; browse: list catalog services; list_categories: list categories with counts; get_service: full detail for a known slug; report_integration: report a completed integration. */
544
+ action: "search" | "browse" | "list_categories" | "get_service" | "report_integration";
545
+ /** For action "search": what the user needs, including stack, constraints, and required capabilities. */
546
+ query?: string;
547
+ /** For action "search": continue a previous search. For action "report_integration": the search_id from the earlier search result (required). */
548
+ search_id?: string;
549
+ /** For action "search": optional structured JSON context about the project, stack, or constraints. */
550
+ context?: Record<string, any>;
551
+ /** For action "browse": optional category filter, e.g. Database, Auth, Payments, Hosting, Email, AI. */
552
+ category?: string;
553
+ /** For action "browse": optional keyword filter, e.g. sendgrid or postgres. */
554
+ q?: string;
555
+ /** For action "get_service": service slug, e.g. supabase, stripe, sendgrid (required). */
556
+ slug?: string;
557
+ /** For action "report_integration": slug of the service that was actually integrated (required). */
558
+ integrated_slug?: string;
559
+ }
560
+ interface ListDirectoryParams {
561
+ /** Directory path to list, relative to the project root. */
562
+ path: string;
563
+ }
564
+ interface LookupAgentInfoParams {
565
+ /** Agent ID (short local or full published format) */
566
+ agentId: string;
567
+ }
568
+ interface ProposeStrReplaceParams {
569
+ /** The path to the file to edit. */
570
+ path: string;
571
+ /** Array of replacements to make. */
572
+ replacements: {
573
+ /** The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation. */
574
+ oldString: string;
575
+ /** The string to replace the corresponding oldString with. Can be empty to delete. */
576
+ newString: string;
577
+ /** Whether to allow multiple replacements of oldString. */
578
+ allowMultiple?: boolean;
579
+ }[];
580
+ }
581
+ interface ProposeWriteFileParams {
582
+ /** Path to the file relative to the **project root** */
583
+ path: string;
584
+ /** What the change is intended to do in only one sentence. */
585
+ instructions: string;
586
+ /** Edit snippet to apply to the file. */
587
+ content: string;
588
+ }
589
+ interface ReadDocsParams {
590
+ /** The library or framework name (e.g., "Next.js", "MongoDB", "React"). Use the official name as it appears in documentation if possible. Only public libraries available in Context7's database are supported, so small or private libraries may not be available. */
591
+ libraryTitle: string;
592
+ /** Specific topic to focus on (e.g., "routing", "hooks", "authentication") */
593
+ topic: string;
594
+ /** Optional maximum number of tokens to return. Defaults to 10000. */
595
+ max_tokens?: number;
596
+ }
597
+ interface ReadFilesParams {
598
+ /** List of file paths to read. */
599
+ paths: string[];
600
+ }
601
+ interface ReadSubtreeParams {
602
+ /** List of paths to directories or files. Relative to the project root. If omitted, the entire project tree is used. */
603
+ paths?: string[];
604
+ /** Maximum token budget for the subtree blob; the tree will be truncated to fit within this budget by first dropping file variables and then removing the most-nested files and directories. */
605
+ maxTokens?: number;
606
+ }
607
+ interface ReadUrlParams {
608
+ /** The full http:// or https:// URL to fetch and extract readable text from. */
609
+ url: string;
610
+ /** Maximum number of extracted text characters to return. Defaults to 20000. */
611
+ max_chars?: number;
612
+ }
613
+ interface RenderUiParams {
614
+ /** The UI widget to render. */
615
+ widget: {
616
+ /** Widget type. Currently, the only supported widget is button. */
617
+ type: "button";
618
+ /** Short button label shown to the user. */
619
+ text: string;
620
+ /** The http:// or https:// URL to open when the user clicks the button. */
621
+ link: string;
622
+ /** Theme-aware color treatment. Use primary for the main action and secondary for lower-emphasis actions. */
623
+ variant?: "primary" | "secondary";
624
+ };
625
+ }
626
+ interface RunFileChangeHooksParams {
627
+ /** List of file paths that were changed and should trigger file change hooks */
628
+ files: string[];
629
+ }
630
+ interface RunTerminalCommandParams {
631
+ /** CLI command valid for user's OS. */
632
+ command: string;
633
+ /** Either SYNC (waits, returns output) or BACKGROUND (runs in background). Default SYNC */
634
+ process_type?: "SYNC" | "BACKGROUND";
635
+ /** The working directory to run the command in. Default is the project root. */
636
+ cwd?: string;
637
+ /** Set to -1 for no timeout. Does not apply for BACKGROUND commands. Default 30 */
638
+ timeout_seconds?: number;
639
+ }
640
+ interface SetMessagesParams {
641
+ messages: any;
642
+ }
643
+ interface SetOutputParams {
644
+ }
645
+ interface SkillParams {
646
+ /** The name of the skill to load */
647
+ name: string;
648
+ }
649
+ interface SpawnAgentsParams {
650
+ agents: {
651
+ /** Agent to spawn */
652
+ agent_type: string;
653
+ /** Prompt to send to the agent */
654
+ prompt?: string;
655
+ /** Parameters object for the agent (if any) */
656
+ params?: Record<string, any>;
657
+ }[];
658
+ }
659
+ interface StrReplaceParams {
660
+ /** The path to the file to edit. */
661
+ path: string;
662
+ /** Array of replacements to make. */
663
+ replacements: {
664
+ /** The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation. */
665
+ oldString: string;
666
+ /** The string to replace the corresponding oldString with. Can be empty to delete. */
667
+ newString: string;
668
+ /** Whether to allow multiple replacements of oldString. */
669
+ allowMultiple?: boolean;
670
+ }[];
671
+ }
672
+ interface SuggestFollowupsParams {
673
+ /** List of suggested followup prompts the user can click to send */
674
+ followups: {
675
+ /** The prompt text to send as a user message when clicked. Keep it short and goal-oriented — one sentence naming the outcome, not the steps to get there */
676
+ prompt: string;
677
+ /** Short display label for the card (defaults to truncated prompt if not provided) */
678
+ label?: string;
679
+ }[];
680
+ }
681
+ interface TaskCompletedParams {
682
+ }
683
+ interface ThinkDeeplyParams {
684
+ /** Detailed step-by-step analysis. Initially keep each step concise (max ~5-7 words per step). */
685
+ thought: string;
686
+ }
687
+ interface WebSearchParams {
688
+ /** The search query to find relevant web content */
689
+ query: string;
690
+ /** Search depth - 'standard' for quick results, 'deep' for more comprehensive search. Default is 'standard'. */
691
+ depth?: "standard" | "deep";
692
+ }
693
+ interface WriteFileParams {
694
+ /** Path to the file relative to the **project root** */
695
+ path: string;
696
+ /** What the change is intended to do in only one sentence. */
697
+ instructions: string;
698
+ /** Edit snippet to apply to the file. */
699
+ content: string;
700
+ }
701
+ interface WriteTodosParams {
702
+ /** List of todos with their completion status. Add ALL of the applicable tasks to the list, so you don't forget to do anything. Try to order the todos the same way you will complete them. Do not mark todos as completed if you have not completed them yet! */
703
+ todos: {
704
+ /** Description of the task */
705
+ task: string;
706
+ /** Whether the task is completed */
707
+ completed: boolean;
708
+ }[];
709
+ }
710
+ type GetToolParams<T extends ToolName$1> = ToolParamsMap[T];
711
+ type JSONValue$1 = null | string | number | boolean | JSONObject$1 | JSONArray$1;
712
+ type JSONObject$1 = {
713
+ [key: string]: JSONValue$1 | undefined;
714
+ };
715
+ type JSONArray$1 = JSONValue$1[];
716
+ type JsonSchema = {
717
+ type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
718
+ description?: string;
719
+ properties?: Record<string, JsonSchema | boolean>;
720
+ required?: string[];
721
+ enum?: Array<string | number | boolean | null>;
722
+ [k: string]: unknown;
723
+ };
724
+ type JsonObjectSchema = JsonSchema & {
725
+ type: "object";
726
+ };
727
+ type DataContent$1 = string | Uint8Array | ArrayBuffer | Buffer;
728
+ type ProviderMetadata$1 = Record<string, Record<string, JSONValue$1 | undefined>>;
729
+ type TextPart$1 = {
730
+ type: "text";
731
+ text: string;
732
+ providerOptions?: ProviderMetadata$1;
733
+ };
734
+ type ImagePart$1 = {
735
+ type: "image";
736
+ image: DataContent$1;
737
+ mediaType?: string;
738
+ providerOptions?: ProviderMetadata$1;
739
+ };
740
+ type FilePart$1 = {
741
+ type: "file";
742
+ data: DataContent$1;
743
+ filename?: string;
744
+ mediaType: string;
745
+ providerOptions?: ProviderMetadata$1;
746
+ };
747
+ type ReasoningPart$1 = {
748
+ type: "reasoning";
749
+ text: string;
750
+ providerOptions?: ProviderMetadata$1;
751
+ };
752
+ type ToolCallPart$1 = {
753
+ type: "tool-call";
754
+ toolCallId: string;
755
+ toolName: string;
756
+ input: Record<string, unknown>;
757
+ providerOptions?: ProviderMetadata$1;
758
+ providerExecuted?: boolean;
759
+ };
760
+ type ToolResultOutput$1 = {
761
+ type: "json";
762
+ value: JSONValue$1;
763
+ } | {
764
+ type: "media";
765
+ data: string;
766
+ mediaType: string;
767
+ };
768
+ type AuxiliaryMessageData$1 = {
769
+ providerOptions?: ProviderMetadata$1;
770
+ tags?: string[];
771
+ /** @deprecated Use tags instead. */
772
+ timeToLive?: "agentStep" | "userPrompt";
773
+ /** @deprecated Use tags instead. */
774
+ keepDuringTruncation?: boolean;
775
+ /** @deprecated Use tags instead. */
776
+ keepLastTags?: string[];
777
+ };
778
+ type SystemMessage$1 = {
779
+ role: "system";
780
+ content: TextPart$1[];
781
+ } & AuxiliaryMessageData$1;
782
+ type UserMessage$1 = {
783
+ role: "user";
784
+ content: (TextPart$1 | ImagePart$1 | FilePart$1)[];
785
+ } & AuxiliaryMessageData$1;
786
+ type AssistantMessage$1 = {
787
+ role: "assistant";
788
+ content: (TextPart$1 | ReasoningPart$1 | ToolCallPart$1)[];
789
+ } & AuxiliaryMessageData$1;
790
+ type ToolMessage$1 = {
791
+ role: "tool";
792
+ toolCallId: string;
793
+ toolName: string;
794
+ content: ToolResultOutput$1[];
795
+ } & AuxiliaryMessageData$1;
796
+ type Message$1 = SystemMessage$1 | UserMessage$1 | AssistantMessage$1 | ToolMessage$1;
797
+ type MCPConfig = {
798
+ type?: "stdio";
799
+ command: string;
800
+ args?: string[];
801
+ env?: Record<string, string>;
802
+ } | {
803
+ type?: "http" | "sse";
804
+ url: string;
805
+ params?: Record<string, string>;
806
+ headers?: Record<string, string>;
807
+ };
808
+ interface Logger {
809
+ debug: (data: any, msg?: string) => void;
810
+ info: (data: any, msg?: string) => void;
811
+ warn: (data: any, msg?: string) => void;
812
+ error: (data: any, msg?: string) => void;
813
+ }
814
+ /**
815
+ * Anvil Agent Type Definitions
816
+ *
817
+ * This file provides TypeScript type definitions for creating custom Anvil agents.
818
+ * Import these types in your agent files to get full type safety and IntelliSense.
819
+ *
820
+ * Usage in .agents/your-agent.ts:
821
+ * import { AgentDefinition, ToolName, ModelName } from './types/agent-definition'
822
+ *
823
+ * const definition: AgentDefinition = {
824
+ * // ... your agent configuration with full type safety ...
825
+ * }
826
+ *
827
+ * export default definition
828
+ */
829
+ export interface AgentDefinition {
830
+ /** Unique identifier for this agent. Must contain only lowercase letters, numbers, and hyphens, e.g. 'code-reviewer' */
831
+ id: string;
832
+ /** Version string (if not provided, will default to '0.0.1' and be bumped on each publish) */
833
+ version?: string;
834
+ /** Publisher ID for the agent. Must be provided if you want to publish the agent. */
835
+ publisher?: string;
836
+ /** Human-readable name for the agent */
837
+ displayName: string;
838
+ /** AI model to use for this agent. Can be any model in OpenRouter: https://openrouter.ai/models */
839
+ model: ModelName;
840
+ /**
841
+ * https://openrouter.ai/docs/use-cases/reasoning-tokens
842
+ * One of `max_tokens` or `effort` is required.
843
+ * If `exclude` is true, reasoning will be removed from the response. Default is false.
844
+ */
845
+ reasoningOptions?: {
846
+ enabled?: boolean;
847
+ exclude?: boolean;
848
+ } & ({
849
+ max_tokens: number;
850
+ } | {
851
+ effort: "high" | "medium" | "low" | "minimal" | "none";
852
+ });
853
+ /**
854
+ * Provider routing options for OpenRouter.
855
+ * Controls which providers to use and fallback behavior.
856
+ * See https://openrouter.ai/docs/features/provider-routing
857
+ */
858
+ providerOptions?: {
859
+ /**
860
+ * List of provider slugs to try in order (e.g. ["anthropic", "openai"])
861
+ */
862
+ order?: string[];
863
+ /**
864
+ * Whether to allow backup providers when primary is unavailable (default: true)
865
+ */
866
+ allow_fallbacks?: boolean;
867
+ /**
868
+ * Only use providers that support all parameters in your request (default: false)
869
+ */
870
+ require_parameters?: boolean;
871
+ /**
872
+ * Control whether to use providers that may store data
873
+ */
874
+ data_collection?: "allow" | "deny";
875
+ /**
876
+ * List of provider slugs to allow for this request
877
+ */
878
+ only?: string[];
879
+ /**
880
+ * List of provider slugs to skip for this request
881
+ */
882
+ ignore?: string[];
883
+ /**
884
+ * List of quantization levels to filter by (e.g. ["int4", "int8"])
885
+ */
886
+ quantizations?: Array<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown">;
887
+ /**
888
+ * Sort providers by price, throughput, or latency
889
+ */
890
+ sort?: "price" | "throughput" | "latency";
891
+ /**
892
+ * Maximum pricing you want to pay for this request
893
+ */
894
+ max_price?: {
895
+ prompt?: number | string;
896
+ completion?: number | string;
897
+ image?: number | string;
898
+ audio?: number | string;
899
+ request?: number | string;
900
+ };
901
+ };
902
+ /** MCP servers by name. Names cannot contain `/`. */
903
+ mcpServers?: Record<string, MCPConfig>;
904
+ /**
905
+ * Tools this agent can use.
906
+ *
907
+ * By default, all tools are available from any specified MCP server. In
908
+ * order to limit the tools from a specific MCP server, add the tool name(s)
909
+ * in the format `'mcpServerName/toolName1'`, `'mcpServerName/toolName2'`,
910
+ * etc.
911
+ */
912
+ toolNames?: (ToolName$1 | (string & {}))[];
913
+ /** Other agents this agent can spawn, like 'anvil/file-picker@0.0.1'.
914
+ *
915
+ * Use the fully qualified agent id from the agent store, including publisher and version: 'anvil/file-picker@0.0.1'
916
+ * (publisher and version are required!)
917
+ *
918
+ * Or, use the agent id from a local agent file in your .agents directory: 'file-picker'.
919
+ */
920
+ spawnableAgents?: string[];
921
+ /** The input schema required to spawn the agent. Provide a prompt string and/or a params object or none.
922
+ * 80% of the time you want just a prompt string with a description:
923
+ * inputSchema: {
924
+ * prompt: { type: 'string', description: 'A description of what info would be helpful to the agent' }
925
+ * }
926
+ */
927
+ inputSchema?: {
928
+ prompt?: {
929
+ type: "string";
930
+ description?: string;
931
+ };
932
+ params?: JsonObjectSchema;
933
+ };
934
+ /** How the agent should output a response to its parent (defaults to 'last_message')
935
+ *
936
+ * last_message: The last message from the agent, typically after using tools.
937
+ *
938
+ * all_messages: All messages from the agent, including tool calls and results.
939
+ *
940
+ * structured_output: Make the agent output a JSON object. Can be used with outputSchema or without if you want freeform json output.
941
+ */
942
+ outputMode?: "last_message" | "all_messages" | "structured_output";
943
+ /** JSON schema for structured output (when outputMode is 'structured_output') */
944
+ outputSchema?: JsonObjectSchema;
945
+ /** Prompt for when and why to spawn this agent. Include the main purpose and use cases.
946
+ *
947
+ * This field is key if the agent is intended to be spawned by other agents. */
948
+ spawnerPrompt?: string;
949
+ /** Whether to include conversation history from the parent agent in context.
950
+ *
951
+ * Defaults to false.
952
+ * Use this when the agent needs to know all the previous messages in the conversation.
953
+ */
954
+ includeMessageHistory?: boolean;
955
+ /** Whether to inherit the parent agent's system prompt instead of using this agent's own systemPrompt.
956
+ *
957
+ * Defaults to false.
958
+ * Use this when you want to enable prompt caching by preserving the same system prompt prefix.
959
+ * Cannot be used together with the systemPrompt field.
960
+ */
961
+ inheritParentSystemPrompt?: boolean;
962
+ /** Opt in to windowed file reads: read_files accepts { path, offset, limit }
963
+ * entries, whole-file reads are capped per file, glob results are capped, and
964
+ * the read_files/code_search tool descriptions teach a search-first reading
965
+ * style. Defaults to false, which keeps the legacy read behavior.
966
+ */
967
+ windowedFileReads?: boolean;
968
+ /** Opt in to mechanical context compaction: the runtime rewrites old history
969
+ * into a condensed summary before the next step. Defaults to false.
970
+ *
971
+ * Compaction runs when the context grows past the model's budget, and also
972
+ * once the prompt cache has gone cold — the next request re-reads the whole
973
+ * history at full price anyway, so rewriting it there is free. Pass
974
+ * `{ cacheExpiryMs }` to tune that idle threshold, or `{ cacheExpiryMs: null }`
975
+ * to compact on the context limit only.
976
+ *
977
+ * The cold-cache pass is skipped on a context smaller than
978
+ * `cacheExpiryMinTokens`, since compaction always costs detail and a small
979
+ * history has little to reclaim. Pass null to take it at any size. The
980
+ * context-limit pass ignores this floor.
981
+ */
982
+ compactContext?: boolean | {
983
+ cacheExpiryMs?: number | null;
984
+ cacheExpiryMinTokens?: number | null;
985
+ };
986
+ /** Background information for the agent. Fairly optional. Prefer using instructionsPrompt for agent instructions. */
987
+ systemPrompt?: string;
988
+ /** Instructions for the agent.
989
+ *
990
+ * IMPORTANT: Updating this prompt is the best way to shape the agent's behavior.
991
+ * This prompt is inserted after each user input. */
992
+ instructionsPrompt?: string;
993
+ /** Prompt inserted at each agent step.
994
+ *
995
+ * Powerful for changing the agent's behavior, but usually not necessary for smart models.
996
+ * Prefer instructionsPrompt for most instructions. */
997
+ stepPrompt?: string;
998
+ /** Programmatically step the agent forward and run tools.
999
+ *
1000
+ * You can either yield:
1001
+ * - A tool call object with toolName and input properties.
1002
+ * - 'STEP' to run agent's model and generate one assistant message.
1003
+ * - 'STEP_ALL' to run the agent's model until it uses the end_turn tool or stops includes no tool calls in a message.
1004
+ *
1005
+ * Or use 'return' to end the turn.
1006
+ *
1007
+ * Example 1:
1008
+ * function* handleSteps({ agentState, prompt, params, logger }) {
1009
+ * logger.info('Starting file read process')
1010
+ * const { toolResult } = yield {
1011
+ * toolName: 'read_files',
1012
+ * input: { paths: ['file1.txt', 'file2.txt'] }
1013
+ * }
1014
+ * yield 'STEP_ALL'
1015
+ *
1016
+ * // Optionally do a post-processing step here...
1017
+ * logger.info('Files read successfully, setting output')
1018
+ * yield {
1019
+ * toolName: 'set_output',
1020
+ * input: {
1021
+ * output: 'The files were read successfully.',
1022
+ * },
1023
+ * }
1024
+ * }
1025
+ *
1026
+ * Example 2:
1027
+ * handleSteps: function* ({ agentState, prompt, params, logger }) {
1028
+ * while (true) {
1029
+ * logger.debug('Spawning thinker agent')
1030
+ * yield {
1031
+ * toolName: 'spawn_agents',
1032
+ * input: {
1033
+ * agents: [
1034
+ * {
1035
+ * agent_type: 'thinker',
1036
+ * prompt: 'Think deeply about the user request',
1037
+ * },
1038
+ * ],
1039
+ * },
1040
+ * }
1041
+ * const { stepsComplete } = yield 'STEP'
1042
+ * if (stepsComplete) break
1043
+ * }
1044
+ * }
1045
+ */
1046
+ handleSteps?: (context: AgentStepContext) => Generator<ToolCall | "STEP" | "STEP_ALL" | StepText | GenerateN, void, {
1047
+ agentState: AgentState;
1048
+ toolResult: ToolResultOutput$1[] | undefined;
1049
+ stepsComplete: boolean;
1050
+ nResponses?: string[];
1051
+ }>;
1052
+ }
1053
+ interface AgentState {
1054
+ agentId: string;
1055
+ runId: string;
1056
+ parentId: string | undefined;
1057
+ /** The agent's conversation history: messages from the user and the assistant. */
1058
+ messageHistory: Message$1[];
1059
+ /** The last value set by the set_output tool. This is a plain object or undefined if not set. */
1060
+ output: Record<string, any> | undefined;
1061
+ /** The system prompt for this agent. */
1062
+ systemPrompt: string;
1063
+ /** The tool definitions for this agent. */
1064
+ toolDefinitions: Record<string, {
1065
+ description: string | undefined;
1066
+ inputSchema: {};
1067
+ }>;
1068
+ /**
1069
+ * The token count from the Anthropic API.
1070
+ * This is updated on every agent step via the /api/v1/token-count endpoint.
1071
+ */
1072
+ contextTokenCount: number;
1073
+ }
1074
+ interface AgentStepContext {
1075
+ agentState: AgentState;
1076
+ prompt?: string;
1077
+ params?: Record<string, any>;
1078
+ /**
1079
+ * The model this step is running on, after any per-request override of the
1080
+ * definition's `model`. `handleSteps` is serialized with `toString()`, so a
1081
+ * generator cannot close over request-time state — read the model here
1082
+ * instead (e.g. to size a context budget to the model's window).
1083
+ *
1084
+ * Supplied by the runtime; optional so a generator invoked directly (tests)
1085
+ * or run on an older runtime degrades rather than throwing. Treat
1086
+ * `undefined` as "unknown model" and pick a safe default.
1087
+ */
1088
+ model?: string;
1089
+ logger: Logger;
1090
+ }
1091
+ type StepText = {
1092
+ type: "STEP_TEXT";
1093
+ text: string;
1094
+ };
1095
+ type GenerateN = {
1096
+ type: "GENERATE_N";
1097
+ n: number;
1098
+ };
1099
+ type ToolCall<T extends ToolName$1 = ToolName$1> = {
1100
+ [K in T]: {
1101
+ toolName: K;
1102
+ input: GetToolParams<K>;
1103
+ includeToolCall?: boolean;
1104
+ };
1105
+ }[T];
1106
+ type ModelName = "openai/gpt-5.3" | "openai/gpt-5.3-codex" | "openai/gpt-5.2" | "openai/gpt-5.1" | "openai/gpt-5.1-chat" | "openai/gpt-5-mini" | "openai/gpt-5-nano" | "anthropic/claude-fable-5" | "anthropic/claude-opus-5" | "anthropic/claude-sonnet-4.6" | "anthropic/claude-opus-4.8" | "anthropic/claude-opus-4.7" | "anthropic/claude-opus-4.6" | "anthropic/claude-opus-4.5" | "anthropic/claude-haiku-4.5" | "anthropic/claude-sonnet-4.5" | "anthropic/claude-opus-4.1" | "google/gemini-3.1-pro-preview" | "google/gemini-3-pro-preview" | "google/gemini-3-flash-preview" | "google/gemini-3.5-flash-lite" | "google/gemini-3.1-flash-lite" | "google/gemini-2.5-pro" | "google/gemini-2.5-flash" | "google/gemini-2.5-flash-lite" | "qwen/qwen3-max" | "qwen/qwen3-coder-plus" | "qwen/qwen3-coder" | "qwen/qwen3-coder:nitro" | "qwen/qwen3-coder-flash" | "qwen/qwen3-235b-a22b-2507" | "qwen/qwen3-235b-a22b-2507:nitro" | "qwen/qwen3-235b-a22b-thinking-2507" | "qwen/qwen3-235b-a22b-thinking-2507:nitro" | "qwen/qwen3-30b-a3b" | "qwen/qwen3-30b-a3b:nitro" | "deepseek/deepseek-v4-pro" | "deepseek-v4-pro" | "deepseek/deepseek-v4-flash" | "deepseek-v4-flash" | "deepseek/deepseek-chat-v3-0324" | "deepseek/deepseek-chat-v3-0324:nitro" | "deepseek/deepseek-r1-0528" | "deepseek/deepseek-r1-0528:nitro" | "mimo/mimo-v2.5" | "mimo-v2.5" | "mimo/mimo-v2.5-pro" | "mimo-v2.5-pro" | "moonshotai/kimi-k2" | "moonshotai/kimi-k2:nitro" | "moonshotai/kimi-k2.6" | "moonshotai/kimi-k2.7-code" | "z-ai/glm-5" | "z-ai/glm-5.1" | "z-ai/glm-4.6" | "z-ai/glm-4.6:nitro" | "z-ai/glm-4.7" | "z-ai/glm-4.7:nitro" | "z-ai/glm-4.7-flash" | "z-ai/glm-4.7-flash:nitro" | "minimax/minimax-m2.5" | "minimax/minimax-m3" | (string & {});
1107
+ type LoggerFn = (data: unknown, msg?: string, ...args: unknown[]) => unknown;
1108
+ type Logger$1 = {
1109
+ debug: LoggerFn;
1110
+ info: LoggerFn;
1111
+ warn: LoggerFn;
1112
+ error: LoggerFn;
1113
+ };
1114
+ /** File system used for Anvil SDK.
1115
+ *
1116
+ * Compatible with `fs.promises` from the `'fs'` module.
1117
+ */
1118
+ export type AnvilFileSystem = Pick<typeof fs.promises, "mkdir" | "readdir" | "readFile" | "stat" | "unlink" | "writeFile">;
1119
+ declare const SkillDefinitionSchema: z.ZodObject<{
1120
+ name: z.ZodString;
1121
+ description: z.ZodString;
1122
+ license: z.ZodOptional<z.ZodString>;
1123
+ disableModelInvocation: z.ZodOptional<z.ZodBoolean>;
1124
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1125
+ content: z.ZodString;
1126
+ filePath: z.ZodString;
1127
+ }, z.core.$strip>;
1128
+ export type SkillDefinition = z.infer<typeof SkillDefinitionSchema>;
1129
+ /**
1130
+ * Collection of skills keyed by skill name.
1131
+ */
1132
+ export type SkillsMap = Record<string, SkillDefinition>;
1133
+ interface FileTreeNode {
1134
+ name: string;
1135
+ type: "file" | "directory";
1136
+ filePath: string;
1137
+ lastReadTime?: number;
1138
+ children?: FileTreeNode[];
1139
+ }
1140
+ declare const customToolDefinitionsSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1141
+ inputSchema: z.ZodCustom<Record<string, unknown> | z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, Record<string, unknown> | z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
1142
+ endsAgentStep: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1143
+ description: z.ZodOptional<z.ZodString>;
1144
+ exampleInputs: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>>>;
1145
+ }, z.core.$strip>>>;
1146
+ type CustomToolDefinitions = NonNullable<z.input<typeof customToolDefinitionsSchema>>;
1147
+ type ProjectFileContext = {
1148
+ projectRoot: string;
1149
+ cwd: string;
1150
+ fileTree: FileTreeNode[];
1151
+ fileTokenScores: Record<string, Record<string, number>>;
1152
+ tokenCallers?: Record<string, Record<string, string[]>>;
1153
+ knowledgeFiles: Record<string, string>;
1154
+ userKnowledgeFiles?: Record<string, string>;
1155
+ agentTemplates: Record<string, any>;
1156
+ customToolDefinitions: CustomToolDefinitions;
1157
+ skills?: SkillsMap;
1158
+ gitChanges: {
1159
+ status: string;
1160
+ diff: string;
1161
+ diffCached: string;
1162
+ lastCommitMessages: string;
1163
+ };
1164
+ changesSinceLastChat: Record<string, string>;
1165
+ shellConfigFiles: Record<string, string>;
1166
+ systemInfo: {
1167
+ platform: string;
1168
+ shell: string;
1169
+ nodeVersion: string;
1170
+ arch: string;
1171
+ homedir: string;
1172
+ cpus: number;
1173
+ chromeAvailable: boolean;
1174
+ };
1175
+ };
1176
+ declare const toolCallSchema: z.ZodObject<{
1177
+ toolName: z.ZodString;
1178
+ toolCallId: z.ZodString;
1179
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
1180
+ }, z.core.$strip>;
1181
+ type ToolCall$1 = z.infer<typeof toolCallSchema>;
1182
+ declare const subgoalSchema: z.ZodObject<{
1183
+ objective: z.ZodOptional<z.ZodString>;
1184
+ status: z.ZodOptional<z.ZodEnum<{
1185
+ NOT_STARTED: "NOT_STARTED";
1186
+ IN_PROGRESS: "IN_PROGRESS";
1187
+ COMPLETE: "COMPLETE";
1188
+ ABORTED: "ABORTED";
1189
+ }>>;
1190
+ plan: z.ZodOptional<z.ZodString>;
1191
+ logs: z.ZodArray<z.ZodString>;
1192
+ }, z.core.$strip>;
1193
+ type Subgoal = z.infer<typeof subgoalSchema>;
1194
+ type AgentState$1 = {
1195
+ /**
1196
+ * @deprecated agentId is replaced by runId
1197
+ */
1198
+ agentId: string;
1199
+ agentType: AgentTemplateType | null;
1200
+ agentContext: Record<string, Subgoal>;
1201
+ ancestorRunIds: string[];
1202
+ runId?: string;
1203
+ subagents: AgentState$1[];
1204
+ childRunIds: string[];
1205
+ messageHistory: Message[];
1206
+ stepsRemaining: number;
1207
+ creditsUsed: number;
1208
+ directCreditsUsed: number;
1209
+ output?: Record<string, any>;
1210
+ parentId?: string;
1211
+ systemPrompt: string;
1212
+ toolDefinitions: Record<string, {
1213
+ description: string | undefined;
1214
+ inputSchema: {};
1215
+ }>;
1216
+ /**
1217
+ * The accurate token count from the Anthropic API.
1218
+ * This is updated on every agent step via the /api/v1/token-count endpoint.
1219
+ */
1220
+ contextTokenCount: number;
1221
+ };
1222
+ declare const AgentOutputSchema: z.ZodDiscriminatedUnion<[
1223
+ z.ZodObject<{
1224
+ type: z.ZodLiteral<"structuredOutput">;
1225
+ value: z.ZodUnion<[
1226
+ z.ZodRecord<z.ZodString, z.ZodAny>,
1227
+ z.ZodNull
1228
+ ]>;
1229
+ }, z.core.$strip>,
1230
+ z.ZodObject<{
1231
+ type: z.ZodLiteral<"lastMessage">;
1232
+ value: z.ZodArray<z.ZodAny>;
1233
+ }, z.core.$strip>,
1234
+ z.ZodObject<{
1235
+ type: z.ZodLiteral<"allMessages">;
1236
+ value: z.ZodArray<z.ZodAny>;
1237
+ }, z.core.$strip>,
1238
+ z.ZodObject<{
1239
+ type: z.ZodLiteral<"error">;
1240
+ message: z.ZodString;
1241
+ statusCode: z.ZodOptional<z.ZodNumber>;
1242
+ error: z.ZodOptional<z.ZodString>;
1243
+ countryCode: z.ZodOptional<z.ZodString>;
1244
+ countryBlockReason: z.ZodOptional<z.ZodString>;
1245
+ ipPrivacySignals: z.ZodOptional<z.ZodArray<z.ZodString>>;
1246
+ }, z.core.$strip>
1247
+ ], "type">;
1248
+ type AgentOutput = z.infer<typeof AgentOutputSchema>;
1249
+ declare const agentTemplateTypeSchema: z.ZodEnum<{
1250
+ base: "base";
1251
+ base_free: "base_free";
1252
+ base_max: "base_max";
1253
+ base_experimental: "base_experimental";
1254
+ claude4_gemini_thinking: "claude4_gemini_thinking";
1255
+ superagent: "superagent";
1256
+ base_agent_builder: "base_agent_builder";
1257
+ ask: "ask";
1258
+ planner: "planner";
1259
+ dry_run: "dry_run";
1260
+ thinker: "thinker";
1261
+ file_picker: "file_picker";
1262
+ file_explorer: "file_explorer";
1263
+ researcher: "researcher";
1264
+ reviewer: "reviewer";
1265
+ agent_builder: "agent_builder";
1266
+ example_programmatic: "example_programmatic";
1267
+ }>;
1268
+ type AgentTemplateType = z.infer<typeof agentTemplateTypeSchema> | (string & {});
1269
+ type SessionState = {
1270
+ fileContext: ProjectFileContext;
1271
+ mainAgentState: AgentState$1;
1272
+ };
1273
+ type AnvilSpawn = (command: string, args?: readonly string[], options?: SpawnOptions) => ChildProcess;
1274
+ export type RunState = {
1275
+ sessionState?: SessionState;
1276
+ output: AgentOutput;
1277
+ traceSessionId: string;
1278
+ };
1279
+ /** Result of indexing `projectFiles`: the file tree plus tree-sitter token
1280
+ * scores. Deterministic for a given file set, so hosts that run many
1281
+ * sessions over the same files (e.g. the Anvil web runner, one process
1282
+ * serving consecutive turns of a thread) can compute it once with
1283
+ * `computeProjectIndexFromFiles` and pass it back via the `projectIndex`
1284
+ * option instead of paying the tree-sitter parse (CPU + wasm memory) on
1285
+ * every run. */
1286
+ export type ComputedProjectIndex = {
1287
+ fileTree: FileTreeNode[];
1288
+ fileTokenScores: Record<string, any>;
1289
+ tokenCallers: Record<string, any>;
1290
+ };
1291
+ export type InitialSessionStateOptions = {
1292
+ cwd?: string;
1293
+ /** Optional directory path to load skills from. When provided, skills are loaded from this directory instead of the default locations. */
1294
+ skillsDir?: string;
1295
+ projectFiles?: Record<string, string>;
1296
+ /** Precomputed index for exactly these `projectFiles` (see
1297
+ * ComputedProjectIndex). Ignored when `projectFiles` is absent. */
1298
+ projectIndex?: ComputedProjectIndex;
1299
+ knowledgeFiles?: Record<string, string>;
1300
+ /** User-provided knowledge files that will be merged with home directory files */
1301
+ userKnowledgeFiles?: Record<string, string>;
1302
+ agentDefinitions?: AgentDefinition[];
1303
+ customToolDefinitions?: CustomToolDefinition[];
1304
+ maxAgentSteps?: number;
1305
+ fs?: AnvilFileSystem;
1306
+ spawn?: AnvilSpawn;
1307
+ logger?: Logger$1;
1308
+ };
1309
+ /**
1310
+ * Standalone version of the index build `run()` performs internally when
1311
+ * given `projectFiles`. Hosts can call this once per distinct file set and
1312
+ * feed the result to subsequent runs via the `projectIndex` option.
1313
+ */
1314
+ export declare function computeProjectIndexFromFiles(params: {
1315
+ cwd: string;
1316
+ projectFiles: Record<string, string>;
1317
+ }): Promise<ComputedProjectIndex>;
1318
+ export declare function initialSessionState(params: InitialSessionStateOptions): Promise<SessionState>;
1319
+ export declare function generateInitialRunState({ cwd, skillsDir, projectFiles, knowledgeFiles, userKnowledgeFiles, agentDefinitions, customToolDefinitions, maxAgentSteps, fs, }: {
1320
+ cwd: string;
1321
+ skillsDir?: string;
1322
+ projectFiles?: Record<string, string>;
1323
+ knowledgeFiles?: Record<string, string>;
1324
+ userKnowledgeFiles?: Record<string, string>;
1325
+ agentDefinitions?: AgentDefinition[];
1326
+ customToolDefinitions?: CustomToolDefinition[];
1327
+ maxAgentSteps?: number;
1328
+ fs: AnvilFileSystem;
1329
+ }): Promise<RunState>;
1330
+ export declare function withAdditionalMessage({ runState, message, }: {
1331
+ runState: RunState;
1332
+ message: Message;
1333
+ }): RunState;
1334
+ export declare function withMessageHistory({ runState, messages, }: {
1335
+ runState: RunState;
1336
+ messages: Message[];
1337
+ }): RunState;
1338
+ /**
1339
+ * Applies overrides to an existing session state, allowing specific fields to be updated
1340
+ * even when continuing from a previous run.
1341
+ */
1342
+ export declare function applyOverridesToSessionState(cwd: string | undefined, baseSessionState: SessionState, overrides: {
1343
+ projectFiles?: Record<string, string>;
1344
+ /** Precomputed index for exactly these `projectFiles` (see
1345
+ * ComputedProjectIndex). Ignored when `projectFiles` is absent. */
1346
+ projectIndex?: ComputedProjectIndex;
1347
+ knowledgeFiles?: Record<string, string>;
1348
+ agentDefinitions?: AgentDefinition[];
1349
+ customToolDefinitions?: CustomToolDefinition[];
1350
+ maxAgentSteps?: number;
1351
+ }): Promise<SessionState>;
1352
+ declare const toolParams: {
1353
+ composio_manage_connections: {
1354
+ toolName: "composio_manage_connections";
1355
+ endsAgentStep: true;
1356
+ description: string;
1357
+ inputSchema: z.ZodObject<{
1358
+ toolkits: z.ZodArray<z.ZodString>;
1359
+ reinitiate_all: z.ZodOptional<z.ZodBoolean>;
1360
+ session_id: z.ZodOptional<z.ZodString>;
1361
+ }, z.core.$catchall<z.ZodUnknown>>;
1362
+ outputSchema: z.ZodTuple<[
1363
+ z.ZodObject<{
1364
+ type: z.ZodLiteral<"json">;
1365
+ value: z.ZodType<z.core.util.JSONType | {
1366
+ errorMessage: string;
1367
+ status?: number | undefined;
1368
+ }, unknown, z.core.$ZodTypeInternals<z.core.util.JSONType | {
1369
+ errorMessage: string;
1370
+ status?: number | undefined;
1371
+ }, unknown>>;
1372
+ }, z.core.$strip>
1373
+ ], null>;
1374
+ };
1375
+ composio_multi_execute_tool: {
1376
+ toolName: "composio_multi_execute_tool";
1377
+ endsAgentStep: true;
1378
+ description: string;
1379
+ inputSchema: z.ZodObject<{
1380
+ tools: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1381
+ thought: z.ZodOptional<z.ZodString>;
1382
+ sync_response_to_workbench: z.ZodDefault<z.ZodBoolean>;
1383
+ session_id: z.ZodOptional<z.ZodString>;
1384
+ }, z.core.$catchall<z.ZodUnknown>>;
1385
+ outputSchema: z.ZodTuple<[
1386
+ z.ZodObject<{
1387
+ type: z.ZodLiteral<"json">;
1388
+ value: z.ZodType<z.core.util.JSONType | {
1389
+ errorMessage: string;
1390
+ status?: number | undefined;
1391
+ }, unknown, z.core.$ZodTypeInternals<z.core.util.JSONType | {
1392
+ errorMessage: string;
1393
+ status?: number | undefined;
1394
+ }, unknown>>;
1395
+ }, z.core.$strip>
1396
+ ], null>;
1397
+ };
1398
+ composio_search_tools: {
1399
+ toolName: "composio_search_tools";
1400
+ endsAgentStep: true;
1401
+ description: string;
1402
+ inputSchema: z.ZodObject<{
1403
+ queries: z.ZodArray<z.ZodUnknown>;
1404
+ session: z.ZodObject<{
1405
+ generate_id: z.ZodOptional<z.ZodBoolean>;
1406
+ id: z.ZodOptional<z.ZodString>;
1407
+ }, z.core.$catchall<z.ZodUnknown>>;
1408
+ model: z.ZodOptional<z.ZodString>;
1409
+ }, z.core.$catchall<z.ZodUnknown>>;
1410
+ outputSchema: z.ZodTuple<[
1411
+ z.ZodObject<{
1412
+ type: z.ZodLiteral<"json">;
1413
+ value: z.ZodType<z.core.util.JSONType | {
1414
+ errorMessage: string;
1415
+ status?: number | undefined;
1416
+ }, unknown, z.core.$ZodTypeInternals<z.core.util.JSONType | {
1417
+ errorMessage: string;
1418
+ status?: number | undefined;
1419
+ }, unknown>>;
1420
+ }, z.core.$strip>
1421
+ ], null>;
1422
+ };
1423
+ composio_get_tool_schemas: {
1424
+ toolName: "composio_get_tool_schemas";
1425
+ endsAgentStep: true;
1426
+ description: string;
1427
+ inputSchema: z.ZodObject<{
1428
+ tool_slugs: z.ZodArray<z.ZodString>;
1429
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
1430
+ session_id: z.ZodOptional<z.ZodString>;
1431
+ }, z.core.$catchall<z.ZodUnknown>>;
1432
+ outputSchema: z.ZodTuple<[
1433
+ z.ZodObject<{
1434
+ type: z.ZodLiteral<"json">;
1435
+ value: z.ZodType<z.core.util.JSONType | {
1436
+ errorMessage: string;
1437
+ status?: number | undefined;
1438
+ }, unknown, z.core.$ZodTypeInternals<z.core.util.JSONType | {
1439
+ errorMessage: string;
1440
+ status?: number | undefined;
1441
+ }, unknown>>;
1442
+ }, z.core.$strip>
1443
+ ], null>;
1444
+ };
1445
+ add_message: {
1446
+ toolName: "add_message";
1447
+ endsAgentStep: true;
1448
+ description: string;
1449
+ inputSchema: z.ZodObject<{
1450
+ role: z.ZodEnum<{
1451
+ user: "user";
1452
+ assistant: "assistant";
1453
+ }>;
1454
+ content: z.ZodString;
1455
+ }, z.core.$strip>;
1456
+ outputSchema: z.ZodTuple<[
1457
+ z.ZodObject<{
1458
+ type: z.ZodLiteral<"json">;
1459
+ value: z.ZodObject<{
1460
+ message: z.ZodString;
1461
+ }, z.core.$strip>;
1462
+ }, z.core.$strip>
1463
+ ], null>;
1464
+ };
1465
+ add_subgoal: {
1466
+ toolName: "add_subgoal";
1467
+ endsAgentStep: false;
1468
+ description: string;
1469
+ inputSchema: z.ZodObject<{
1470
+ id: z.ZodString;
1471
+ objective: z.ZodString;
1472
+ status: z.ZodEnum<{
1473
+ NOT_STARTED: "NOT_STARTED";
1474
+ IN_PROGRESS: "IN_PROGRESS";
1475
+ COMPLETE: "COMPLETE";
1476
+ ABORTED: "ABORTED";
1477
+ }>;
1478
+ plan: z.ZodOptional<z.ZodString>;
1479
+ log: z.ZodOptional<z.ZodString>;
1480
+ }, z.core.$strip>;
1481
+ outputSchema: z.ZodTuple<[
1482
+ z.ZodObject<{
1483
+ type: z.ZodLiteral<"json">;
1484
+ value: z.ZodType<{
1485
+ message: string;
1486
+ }, unknown, z.core.$ZodTypeInternals<{
1487
+ message: string;
1488
+ }, unknown>>;
1489
+ }, z.core.$strip>
1490
+ ], null>;
1491
+ };
1492
+ apply_patch: {
1493
+ toolName: "apply_patch";
1494
+ endsAgentStep: false;
1495
+ description: string;
1496
+ inputSchema: z.ZodObject<{
1497
+ operation: z.ZodDiscriminatedUnion<[
1498
+ z.ZodObject<{
1499
+ type: z.ZodLiteral<"create_file">;
1500
+ path: z.ZodString;
1501
+ diff: z.ZodString;
1502
+ }, z.core.$strip>,
1503
+ z.ZodObject<{
1504
+ type: z.ZodLiteral<"update_file">;
1505
+ path: z.ZodString;
1506
+ diff: z.ZodString;
1507
+ }, z.core.$strip>,
1508
+ z.ZodObject<{
1509
+ type: z.ZodLiteral<"delete_file">;
1510
+ path: z.ZodString;
1511
+ }, z.core.$strip>
1512
+ ], "type">;
1513
+ }, z.core.$strip>;
1514
+ outputSchema: z.ZodTuple<[
1515
+ z.ZodObject<{
1516
+ type: z.ZodLiteral<"json">;
1517
+ value: z.ZodType<{
1518
+ message: string;
1519
+ applied: {
1520
+ file: string;
1521
+ action: "add" | "update" | "delete";
1522
+ }[];
1523
+ } | {
1524
+ errorMessage: string;
1525
+ }, unknown, z.core.$ZodTypeInternals<{
1526
+ message: string;
1527
+ applied: {
1528
+ file: string;
1529
+ action: "add" | "update" | "delete";
1530
+ }[];
1531
+ } | {
1532
+ errorMessage: string;
1533
+ }, unknown>>;
1534
+ }, z.core.$strip>
1535
+ ], null>;
1536
+ };
1537
+ ask_user: {
1538
+ toolName: "ask_user";
1539
+ endsAgentStep: true;
1540
+ description: string;
1541
+ inputSchema: z.ZodObject<{
1542
+ questions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
1543
+ question: z.ZodString;
1544
+ header: z.ZodOptional<z.ZodString>;
1545
+ options: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
1546
+ label: z.ZodString;
1547
+ description: z.ZodOptional<z.ZodString>;
1548
+ }, z.core.$strip>>>;
1549
+ multiSelect: z.ZodDefault<z.ZodBoolean>;
1550
+ validation: z.ZodOptional<z.ZodObject<{
1551
+ maxLength: z.ZodOptional<z.ZodNumber>;
1552
+ minLength: z.ZodOptional<z.ZodNumber>;
1553
+ pattern: z.ZodOptional<z.ZodString>;
1554
+ patternError: z.ZodOptional<z.ZodString>;
1555
+ }, z.core.$strip>>;
1556
+ }, z.core.$strip>>>;
1557
+ }, z.core.$strip>;
1558
+ outputSchema: z.ZodTuple<[
1559
+ z.ZodObject<{
1560
+ type: z.ZodLiteral<"json">;
1561
+ value: z.ZodType<{
1562
+ answers?: {
1563
+ questionIndex: number;
1564
+ selectedOption?: string | undefined;
1565
+ selectedOptions?: string[] | undefined;
1566
+ otherText?: string | undefined;
1567
+ }[] | undefined;
1568
+ skipped?: boolean | undefined;
1569
+ }, unknown, z.core.$ZodTypeInternals<{
1570
+ answers?: {
1571
+ questionIndex: number;
1572
+ selectedOption?: string | undefined;
1573
+ selectedOptions?: string[] | undefined;
1574
+ otherText?: string | undefined;
1575
+ }[] | undefined;
1576
+ skipped?: boolean | undefined;
1577
+ }, unknown>>;
1578
+ }, z.core.$strip>
1579
+ ], null>;
1580
+ };
1581
+ browser_logs: {
1582
+ toolName: "browser_logs";
1583
+ endsAgentStep: true;
1584
+ description: string;
1585
+ inputSchema: z.ZodObject<{
1586
+ type: z.ZodString;
1587
+ url: z.ZodString;
1588
+ waitUntil: z.ZodOptional<z.ZodEnum<{
1589
+ networkidle0: "networkidle0";
1590
+ load: "load";
1591
+ domcontentloaded: "domcontentloaded";
1592
+ }>>;
1593
+ }, z.core.$strip>;
1594
+ outputSchema: z.ZodTuple<[
1595
+ z.ZodObject<{
1596
+ type: z.ZodLiteral<"json">;
1597
+ value: z.ZodType<{
1598
+ success: boolean;
1599
+ logs: {
1600
+ type: "error" | "debug" | "info" | "warning" | "verbose";
1601
+ message: string;
1602
+ timestamp: number;
1603
+ source: "tool" | "browser";
1604
+ location?: string | undefined;
1605
+ stack?: string | undefined;
1606
+ category?: string | undefined;
1607
+ level?: number | undefined;
1608
+ }[];
1609
+ error?: string | undefined;
1610
+ logFilter?: {
1611
+ types?: ("error" | "debug" | "info" | "warning" | "verbose")[] | undefined;
1612
+ minLevel?: number | undefined;
1613
+ categories?: string[] | undefined;
1614
+ } | undefined;
1615
+ networkEvents?: {
1616
+ url: string;
1617
+ method: string;
1618
+ timestamp: number;
1619
+ status?: number | undefined;
1620
+ errorText?: string | undefined;
1621
+ }[] | undefined;
1622
+ metrics?: {
1623
+ loadTime: number;
1624
+ memoryUsage: number;
1625
+ jsErrors: number;
1626
+ networkErrors: number;
1627
+ ttfb?: number | undefined;
1628
+ lcp?: number | undefined;
1629
+ fcp?: number | undefined;
1630
+ domContentLoaded?: number | undefined;
1631
+ sessionDuration?: number | undefined;
1632
+ } | undefined;
1633
+ screenshots?: {
1634
+ post: {
1635
+ type: "image";
1636
+ source: {
1637
+ type: "base64";
1638
+ media_type: "image/jpeg";
1639
+ data: string;
1640
+ };
1641
+ };
1642
+ pre?: {
1643
+ type: "image";
1644
+ source: {
1645
+ type: "base64";
1646
+ media_type: "image/jpeg";
1647
+ data: string;
1648
+ };
1649
+ } | undefined;
1650
+ } | undefined;
1651
+ }, unknown, z.core.$ZodTypeInternals<{
1652
+ success: boolean;
1653
+ logs: {
1654
+ type: "error" | "debug" | "info" | "warning" | "verbose";
1655
+ message: string;
1656
+ timestamp: number;
1657
+ source: "tool" | "browser";
1658
+ location?: string | undefined;
1659
+ stack?: string | undefined;
1660
+ category?: string | undefined;
1661
+ level?: number | undefined;
1662
+ }[];
1663
+ error?: string | undefined;
1664
+ logFilter?: {
1665
+ types?: ("error" | "debug" | "info" | "warning" | "verbose")[] | undefined;
1666
+ minLevel?: number | undefined;
1667
+ categories?: string[] | undefined;
1668
+ } | undefined;
1669
+ networkEvents?: {
1670
+ url: string;
1671
+ method: string;
1672
+ timestamp: number;
1673
+ status?: number | undefined;
1674
+ errorText?: string | undefined;
1675
+ }[] | undefined;
1676
+ metrics?: {
1677
+ loadTime: number;
1678
+ memoryUsage: number;
1679
+ jsErrors: number;
1680
+ networkErrors: number;
1681
+ ttfb?: number | undefined;
1682
+ lcp?: number | undefined;
1683
+ fcp?: number | undefined;
1684
+ domContentLoaded?: number | undefined;
1685
+ sessionDuration?: number | undefined;
1686
+ } | undefined;
1687
+ screenshots?: {
1688
+ post: {
1689
+ type: "image";
1690
+ source: {
1691
+ type: "base64";
1692
+ media_type: "image/jpeg";
1693
+ data: string;
1694
+ };
1695
+ };
1696
+ pre?: {
1697
+ type: "image";
1698
+ source: {
1699
+ type: "base64";
1700
+ media_type: "image/jpeg";
1701
+ data: string;
1702
+ };
1703
+ } | undefined;
1704
+ } | undefined;
1705
+ }, unknown>>;
1706
+ }, z.core.$strip>
1707
+ ], null>;
1708
+ };
1709
+ code_search: {
1710
+ toolName: "code_search";
1711
+ endsAgentStep: true;
1712
+ description: string;
1713
+ inputSchema: z.ZodObject<{
1714
+ pattern: z.ZodString;
1715
+ flags: z.ZodOptional<z.ZodString>;
1716
+ cwd: z.ZodOptional<z.ZodString>;
1717
+ maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
1718
+ }, z.core.$strip>;
1719
+ outputSchema: z.ZodTuple<[
1720
+ z.ZodObject<{
1721
+ type: z.ZodLiteral<"json">;
1722
+ value: z.ZodType<{
1723
+ stdout: string;
1724
+ message: string;
1725
+ stderr?: string | undefined;
1726
+ exitCode?: number | undefined;
1727
+ } | {
1728
+ errorMessage: string;
1729
+ }, unknown, z.core.$ZodTypeInternals<{
1730
+ stdout: string;
1731
+ message: string;
1732
+ stderr?: string | undefined;
1733
+ exitCode?: number | undefined;
1734
+ } | {
1735
+ errorMessage: string;
1736
+ }, unknown>>;
1737
+ }, z.core.$strip>
1738
+ ], null>;
1739
+ };
1740
+ cloud_plan_ready: {
1741
+ toolName: "cloud_plan_ready";
1742
+ endsAgentStep: true;
1743
+ description: string;
1744
+ inputSchema: z.ZodObject<{
1745
+ summary: z.ZodString;
1746
+ stack: z.ZodArray<z.ZodString>;
1747
+ build_prompt: z.ZodString;
1748
+ required_integrations: z.ZodDefault<z.ZodArray<z.ZodObject<{
1749
+ search_id: z.ZodString;
1750
+ slug: z.ZodString;
1751
+ }, z.core.$strip>>>;
1752
+ }, z.core.$strip>;
1753
+ outputSchema: z.ZodTuple<[
1754
+ z.ZodObject<{
1755
+ type: z.ZodLiteral<"json">;
1756
+ value: z.ZodType<{
1757
+ message: string;
1758
+ }, unknown, z.core.$ZodTypeInternals<{
1759
+ message: string;
1760
+ }, unknown>>;
1761
+ }, z.core.$strip>
1762
+ ], null>;
1763
+ };
1764
+ create_plan: {
1765
+ toolName: "create_plan";
1766
+ endsAgentStep: false;
1767
+ description: string;
1768
+ inputSchema: z.ZodObject<{
1769
+ path: z.ZodString;
1770
+ plan: z.ZodString;
1771
+ }, z.core.$strip>;
1772
+ outputSchema: z.ZodTuple<[
1773
+ z.ZodObject<{
1774
+ type: z.ZodLiteral<"json">;
1775
+ value: z.ZodType<{
1776
+ file: string;
1777
+ message: string;
1778
+ } | {
1779
+ file: string;
1780
+ errorMessage: string;
1781
+ patch?: string | undefined;
1782
+ }, unknown, z.core.$ZodTypeInternals<{
1783
+ file: string;
1784
+ message: string;
1785
+ } | {
1786
+ file: string;
1787
+ errorMessage: string;
1788
+ patch?: string | undefined;
1789
+ }, unknown>>;
1790
+ }, z.core.$strip>
1791
+ ], null>;
1792
+ };
1793
+ end_turn: {
1794
+ toolName: "end_turn";
1795
+ endsAgentStep: true;
1796
+ description: string;
1797
+ inputSchema: z.ZodObject<{}, z.core.$strip>;
1798
+ outputSchema: z.ZodTuple<[
1799
+ z.ZodObject<{
1800
+ type: z.ZodLiteral<"json">;
1801
+ value: z.ZodObject<{
1802
+ message: z.ZodString;
1803
+ }, z.core.$strip>;
1804
+ }, z.core.$strip>
1805
+ ], null>;
1806
+ };
1807
+ find_files: {
1808
+ toolName: "find_files";
1809
+ endsAgentStep: true;
1810
+ description: string;
1811
+ inputSchema: z.ZodObject<{
1812
+ prompt: z.ZodString;
1813
+ }, z.core.$strip>;
1814
+ outputSchema: z.ZodTuple<[
1815
+ z.ZodObject<{
1816
+ type: z.ZodLiteral<"json">;
1817
+ value: z.ZodType<({
1818
+ path: string;
1819
+ content: string;
1820
+ referencedBy?: Record<string, string[]> | undefined;
1821
+ } | {
1822
+ path: string;
1823
+ contentOmittedForLength: true;
1824
+ })[] | {
1825
+ message: string;
1826
+ }, unknown, z.core.$ZodTypeInternals<({
1827
+ path: string;
1828
+ content: string;
1829
+ referencedBy?: Record<string, string[]> | undefined;
1830
+ } | {
1831
+ path: string;
1832
+ contentOmittedForLength: true;
1833
+ })[] | {
1834
+ message: string;
1835
+ }, unknown>>;
1836
+ }, z.core.$strip>
1837
+ ], null>;
1838
+ };
1839
+ glob: {
1840
+ toolName: "glob";
1841
+ description: string;
1842
+ endsAgentStep: false;
1843
+ inputSchema: z.ZodObject<{
1844
+ pattern: z.ZodString;
1845
+ cwd: z.ZodOptional<z.ZodString>;
1846
+ max_results: z.ZodOptional<z.ZodNumber>;
1847
+ }, z.core.$strip>;
1848
+ outputSchema: z.ZodTuple<[
1849
+ z.ZodObject<{
1850
+ type: z.ZodLiteral<"json">;
1851
+ value: z.ZodType<{
1852
+ files: string[];
1853
+ count: number;
1854
+ message: string;
1855
+ } | {
1856
+ errorMessage: string;
1857
+ }, unknown, z.core.$ZodTypeInternals<{
1858
+ files: string[];
1859
+ count: number;
1860
+ message: string;
1861
+ } | {
1862
+ errorMessage: string;
1863
+ }, unknown>>;
1864
+ }, z.core.$strip>
1865
+ ], null>;
1866
+ };
1867
+ gravity_index: {
1868
+ toolName: "gravity_index";
1869
+ endsAgentStep: true;
1870
+ description: string;
1871
+ inputSchema: z.ZodObject<{
1872
+ action: z.ZodEnum<{
1873
+ search: "search";
1874
+ browse: "browse";
1875
+ list_categories: "list_categories";
1876
+ get_service: "get_service";
1877
+ report_integration: "report_integration";
1878
+ }>;
1879
+ query: z.ZodOptional<z.ZodString>;
1880
+ search_id: z.ZodOptional<z.ZodString>;
1881
+ context: z.ZodOptional<z.ZodType<JSONObject, unknown, z.core.$ZodTypeInternals<JSONObject, unknown>>>;
1882
+ category: z.ZodOptional<z.ZodString>;
1883
+ q: z.ZodOptional<z.ZodString>;
1884
+ slug: z.ZodOptional<z.ZodString>;
1885
+ integrated_slug: z.ZodOptional<z.ZodString>;
1886
+ }, z.core.$strip>;
1887
+ outputSchema: z.ZodTuple<[
1888
+ z.ZodObject<{
1889
+ type: z.ZodLiteral<"json">;
1890
+ value: z.ZodType<JSONObject | {
1891
+ errorMessage: string;
1892
+ }, unknown, z.core.$ZodTypeInternals<JSONObject | {
1893
+ errorMessage: string;
1894
+ }, unknown>>;
1895
+ }, z.core.$strip>
1896
+ ], null>;
1897
+ };
1898
+ list_directory: {
1899
+ toolName: "list_directory";
1900
+ endsAgentStep: true;
1901
+ description: string;
1902
+ inputSchema: z.ZodObject<{
1903
+ path: z.ZodString;
1904
+ }, z.core.$strip>;
1905
+ outputSchema: z.ZodTuple<[
1906
+ z.ZodObject<{
1907
+ type: z.ZodLiteral<"json">;
1908
+ value: z.ZodType<{
1909
+ files: string[];
1910
+ directories: string[];
1911
+ path: string;
1912
+ } | {
1913
+ errorMessage: string;
1914
+ }, unknown, z.core.$ZodTypeInternals<{
1915
+ files: string[];
1916
+ directories: string[];
1917
+ path: string;
1918
+ } | {
1919
+ errorMessage: string;
1920
+ }, unknown>>;
1921
+ }, z.core.$strip>
1922
+ ], null>;
1923
+ };
1924
+ lookup_agent_info: {
1925
+ toolName: "lookup_agent_info";
1926
+ endsAgentStep: false;
1927
+ description: string;
1928
+ inputSchema: z.ZodObject<{
1929
+ agentId: z.ZodString;
1930
+ }, z.core.$strip>;
1931
+ outputSchema: z.ZodTuple<[
1932
+ z.ZodObject<{
1933
+ type: z.ZodLiteral<"json">;
1934
+ value: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
1935
+ }, z.core.$strip>
1936
+ ], null>;
1937
+ };
1938
+ propose_str_replace: {
1939
+ toolName: "propose_str_replace";
1940
+ endsAgentStep: false;
1941
+ description: string;
1942
+ inputSchema: z.ZodObject<{
1943
+ path: z.ZodString;
1944
+ replacements: z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodObject<{
1945
+ oldString: z.ZodString;
1946
+ newString: z.ZodString;
1947
+ allowMultiple: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1948
+ }, z.core.$strip>>>>;
1949
+ }, z.core.$strip>;
1950
+ outputSchema: z.ZodTuple<[
1951
+ z.ZodObject<{
1952
+ type: z.ZodLiteral<"json">;
1953
+ value: z.ZodType<{
1954
+ file: string;
1955
+ message: string;
1956
+ unifiedDiff: string;
1957
+ } | {
1958
+ file: string;
1959
+ errorMessage: string;
1960
+ }, unknown, z.core.$ZodTypeInternals<{
1961
+ file: string;
1962
+ message: string;
1963
+ unifiedDiff: string;
1964
+ } | {
1965
+ file: string;
1966
+ errorMessage: string;
1967
+ }, unknown>>;
1968
+ }, z.core.$strip>
1969
+ ], null>;
1970
+ };
1971
+ propose_write_file: {
1972
+ toolName: "propose_write_file";
1973
+ endsAgentStep: false;
1974
+ description: string;
1975
+ inputSchema: z.ZodObject<{
1976
+ path: z.ZodString;
1977
+ instructions: z.ZodString;
1978
+ content: z.ZodString;
1979
+ }, z.core.$strip>;
1980
+ outputSchema: z.ZodTuple<[
1981
+ z.ZodObject<{
1982
+ type: z.ZodLiteral<"json">;
1983
+ value: z.ZodType<{
1984
+ file: string;
1985
+ message: string;
1986
+ unifiedDiff: string;
1987
+ } | {
1988
+ file: string;
1989
+ errorMessage: string;
1990
+ }, unknown, z.core.$ZodTypeInternals<{
1991
+ file: string;
1992
+ message: string;
1993
+ unifiedDiff: string;
1994
+ } | {
1995
+ file: string;
1996
+ errorMessage: string;
1997
+ }, unknown>>;
1998
+ }, z.core.$strip>
1999
+ ], null>;
2000
+ };
2001
+ read_docs: {
2002
+ toolName: "read_docs";
2003
+ endsAgentStep: true;
2004
+ description: string;
2005
+ inputSchema: z.ZodObject<{
2006
+ libraryTitle: z.ZodString;
2007
+ topic: z.ZodString;
2008
+ max_tokens: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
2009
+ }, z.core.$strip>;
2010
+ outputSchema: z.ZodTuple<[
2011
+ z.ZodObject<{
2012
+ type: z.ZodLiteral<"json">;
2013
+ value: z.ZodType<{
2014
+ documentation: string;
2015
+ }, unknown, z.core.$ZodTypeInternals<{
2016
+ documentation: string;
2017
+ }, unknown>>;
2018
+ }, z.core.$strip>
2019
+ ], null>;
2020
+ };
2021
+ read_files: {
2022
+ toolName: "read_files";
2023
+ endsAgentStep: true;
2024
+ description: string;
2025
+ inputSchema: z.ZodObject<{
2026
+ paths: z.ZodPreprocess<z.ZodArray<z.ZodUnion<readonly [
2027
+ z.ZodString,
2028
+ z.ZodObject<{
2029
+ path: z.ZodString;
2030
+ offset: z.ZodOptional<z.ZodNumber>;
2031
+ limit: z.ZodOptional<z.ZodNumber>;
2032
+ }, z.core.$strip>
2033
+ ]>>>;
2034
+ }, z.core.$strip>;
2035
+ outputSchema: z.ZodTuple<[
2036
+ z.ZodObject<{
2037
+ type: z.ZodLiteral<"json">;
2038
+ value: z.ZodType<({
2039
+ path: string;
2040
+ content: string;
2041
+ referencedBy?: Record<string, string[]> | undefined;
2042
+ } | {
2043
+ path: string;
2044
+ contentOmittedForLength: true;
2045
+ })[], unknown, z.core.$ZodTypeInternals<({
2046
+ path: string;
2047
+ content: string;
2048
+ referencedBy?: Record<string, string[]> | undefined;
2049
+ } | {
2050
+ path: string;
2051
+ contentOmittedForLength: true;
2052
+ })[], unknown>>;
2053
+ }, z.core.$strip>
2054
+ ], null>;
2055
+ };
2056
+ read_subtree: {
2057
+ toolName: "read_subtree";
2058
+ endsAgentStep: true;
2059
+ description: string;
2060
+ inputSchema: z.ZodObject<{
2061
+ paths: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodString>>>;
2062
+ maxTokens: z.ZodDefault<z.ZodNumber>;
2063
+ }, z.core.$strip>;
2064
+ outputSchema: z.ZodTuple<[
2065
+ z.ZodObject<{
2066
+ type: z.ZodLiteral<"json">;
2067
+ value: z.ZodType<({
2068
+ path: string;
2069
+ type: "directory";
2070
+ printedTree: string;
2071
+ tokenCount: number;
2072
+ truncationLevel: "none" | "unimportant-files" | "tokens" | "depth-based";
2073
+ } | {
2074
+ path: string;
2075
+ type: "file";
2076
+ variables: string[];
2077
+ } | {
2078
+ path: string;
2079
+ errorMessage: string;
2080
+ })[], unknown, z.core.$ZodTypeInternals<({
2081
+ path: string;
2082
+ type: "directory";
2083
+ printedTree: string;
2084
+ tokenCount: number;
2085
+ truncationLevel: "none" | "unimportant-files" | "tokens" | "depth-based";
2086
+ } | {
2087
+ path: string;
2088
+ type: "file";
2089
+ variables: string[];
2090
+ } | {
2091
+ path: string;
2092
+ errorMessage: string;
2093
+ })[], unknown>>;
2094
+ }, z.core.$strip>
2095
+ ], null>;
2096
+ };
2097
+ read_url: {
2098
+ toolName: "read_url";
2099
+ endsAgentStep: true;
2100
+ description: string;
2101
+ inputSchema: z.ZodObject<{
2102
+ url: z.ZodURL;
2103
+ max_chars: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
2104
+ }, z.core.$strip>;
2105
+ outputSchema: z.ZodTuple<[
2106
+ z.ZodObject<{
2107
+ type: z.ZodLiteral<"json">;
2108
+ value: z.ZodType<{
2109
+ url: string;
2110
+ finalUrl: string;
2111
+ status: number;
2112
+ text: string;
2113
+ truncated: boolean;
2114
+ contentType?: string | undefined;
2115
+ title?: string | undefined;
2116
+ description?: string | undefined;
2117
+ } | {
2118
+ errorMessage: string;
2119
+ url?: string | undefined;
2120
+ }, unknown, z.core.$ZodTypeInternals<{
2121
+ url: string;
2122
+ finalUrl: string;
2123
+ status: number;
2124
+ text: string;
2125
+ truncated: boolean;
2126
+ contentType?: string | undefined;
2127
+ title?: string | undefined;
2128
+ description?: string | undefined;
2129
+ } | {
2130
+ errorMessage: string;
2131
+ url?: string | undefined;
2132
+ }, unknown>>;
2133
+ }, z.core.$strip>
2134
+ ], null>;
2135
+ };
2136
+ render_ui: {
2137
+ toolName: "render_ui";
2138
+ endsAgentStep: false;
2139
+ description: string;
2140
+ inputSchema: z.ZodObject<{
2141
+ widget: z.ZodDiscriminatedUnion<[
2142
+ z.ZodObject<{
2143
+ type: z.ZodLiteral<"button">;
2144
+ text: z.ZodString;
2145
+ variant: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
2146
+ primary: "primary";
2147
+ secondary: "secondary";
2148
+ }>>>;
2149
+ link: z.ZodUnion<readonly [
2150
+ z.ZodString,
2151
+ z.ZodObject<{
2152
+ source: z.ZodLiteral<"gravity_index">;
2153
+ search_id: z.ZodString;
2154
+ service_slug: z.ZodString;
2155
+ }, z.core.$strip>
2156
+ ]>;
2157
+ }, z.core.$strip>
2158
+ ], "type">;
2159
+ }, z.core.$strip>;
2160
+ outputSchema: z.ZodTuple<[
2161
+ z.ZodObject<{
2162
+ type: z.ZodLiteral<"json">;
2163
+ value: z.ZodType<{
2164
+ message: string;
2165
+ }, unknown, z.core.$ZodTypeInternals<{
2166
+ message: string;
2167
+ }, unknown>>;
2168
+ }, z.core.$strip>
2169
+ ], null>;
2170
+ };
2171
+ run_file_change_hooks: {
2172
+ toolName: "run_file_change_hooks";
2173
+ endsAgentStep: true;
2174
+ description: string;
2175
+ inputSchema: z.ZodObject<{
2176
+ files: z.ZodArray<z.ZodString>;
2177
+ }, z.core.$strip>;
2178
+ outputSchema: z.ZodTuple<[
2179
+ z.ZodObject<{
2180
+ type: z.ZodLiteral<"json">;
2181
+ value: z.ZodType<((({
2182
+ command: string;
2183
+ startingCwd?: string | undefined;
2184
+ message?: string | undefined;
2185
+ stderr?: string | undefined;
2186
+ stdout?: string | undefined;
2187
+ exitCode?: number | undefined;
2188
+ } | {
2189
+ command: string;
2190
+ stdoutOmittedForLength: true;
2191
+ startingCwd?: string | undefined;
2192
+ message?: string | undefined;
2193
+ stderr?: string | undefined;
2194
+ exitCode?: number | undefined;
2195
+ } | {
2196
+ command: string;
2197
+ processId: number;
2198
+ backgroundProcessStatus: "error" | "running" | "completed";
2199
+ } | {
2200
+ command: string;
2201
+ errorMessage: string;
2202
+ }) & {
2203
+ hookName: string;
2204
+ }) | {
2205
+ errorMessage: string;
2206
+ })[], unknown, z.core.$ZodTypeInternals<((({
2207
+ command: string;
2208
+ startingCwd?: string | undefined;
2209
+ message?: string | undefined;
2210
+ stderr?: string | undefined;
2211
+ stdout?: string | undefined;
2212
+ exitCode?: number | undefined;
2213
+ } | {
2214
+ command: string;
2215
+ stdoutOmittedForLength: true;
2216
+ startingCwd?: string | undefined;
2217
+ message?: string | undefined;
2218
+ stderr?: string | undefined;
2219
+ exitCode?: number | undefined;
2220
+ } | {
2221
+ command: string;
2222
+ processId: number;
2223
+ backgroundProcessStatus: "error" | "running" | "completed";
2224
+ } | {
2225
+ command: string;
2226
+ errorMessage: string;
2227
+ }) & {
2228
+ hookName: string;
2229
+ }) | {
2230
+ errorMessage: string;
2231
+ })[], unknown>>;
2232
+ }, z.core.$strip>
2233
+ ], null>;
2234
+ };
2235
+ run_terminal_command: {
2236
+ toolName: "run_terminal_command";
2237
+ endsAgentStep: true;
2238
+ description: string;
2239
+ inputSchema: z.ZodObject<{
2240
+ command: z.ZodString;
2241
+ process_type: z.ZodDefault<z.ZodEnum<{
2242
+ SYNC: "SYNC";
2243
+ BACKGROUND: "BACKGROUND";
2244
+ }>>;
2245
+ cwd: z.ZodOptional<z.ZodString>;
2246
+ timeout_seconds: z.ZodPipe<z.ZodOptional<z.ZodDefault<z.ZodNumber>>, z.ZodTransform<number | undefined, number | undefined>>;
2247
+ }, z.core.$strip>;
2248
+ outputSchema: z.ZodTuple<[
2249
+ z.ZodObject<{
2250
+ type: z.ZodLiteral<"json">;
2251
+ value: z.ZodType<{
2252
+ command: string;
2253
+ startingCwd?: string | undefined;
2254
+ message?: string | undefined;
2255
+ stderr?: string | undefined;
2256
+ stdout?: string | undefined;
2257
+ exitCode?: number | undefined;
2258
+ } | {
2259
+ command: string;
2260
+ stdoutOmittedForLength: true;
2261
+ startingCwd?: string | undefined;
2262
+ message?: string | undefined;
2263
+ stderr?: string | undefined;
2264
+ exitCode?: number | undefined;
2265
+ } | {
2266
+ command: string;
2267
+ processId: number;
2268
+ backgroundProcessStatus: "error" | "running" | "completed";
2269
+ } | {
2270
+ command: string;
2271
+ errorMessage: string;
2272
+ }, unknown, z.core.$ZodTypeInternals<{
2273
+ command: string;
2274
+ startingCwd?: string | undefined;
2275
+ message?: string | undefined;
2276
+ stderr?: string | undefined;
2277
+ stdout?: string | undefined;
2278
+ exitCode?: number | undefined;
2279
+ } | {
2280
+ command: string;
2281
+ stdoutOmittedForLength: true;
2282
+ startingCwd?: string | undefined;
2283
+ message?: string | undefined;
2284
+ stderr?: string | undefined;
2285
+ exitCode?: number | undefined;
2286
+ } | {
2287
+ command: string;
2288
+ processId: number;
2289
+ backgroundProcessStatus: "error" | "running" | "completed";
2290
+ } | {
2291
+ command: string;
2292
+ errorMessage: string;
2293
+ }, unknown>>;
2294
+ }, z.core.$strip>
2295
+ ], null>;
2296
+ };
2297
+ set_messages: {
2298
+ toolName: "set_messages";
2299
+ endsAgentStep: true;
2300
+ description: string;
2301
+ inputSchema: z.ZodObject<{
2302
+ messages: z.ZodAny;
2303
+ }, z.core.$strip>;
2304
+ outputSchema: z.ZodTuple<[
2305
+ z.ZodObject<{
2306
+ type: z.ZodLiteral<"json">;
2307
+ value: z.ZodObject<{
2308
+ message: z.ZodString;
2309
+ }, z.core.$strip>;
2310
+ }, z.core.$strip>
2311
+ ], null>;
2312
+ };
2313
+ set_output: {
2314
+ toolName: "set_output";
2315
+ endsAgentStep: false;
2316
+ description: string;
2317
+ inputSchema: z.ZodObject<{
2318
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2319
+ }, z.core.$loose>;
2320
+ outputSchema: z.ZodTuple<[
2321
+ z.ZodObject<{
2322
+ type: z.ZodLiteral<"json">;
2323
+ value: z.ZodObject<{
2324
+ message: z.ZodString;
2325
+ }, z.core.$strip>;
2326
+ }, z.core.$strip>
2327
+ ], null>;
2328
+ };
2329
+ skill: {
2330
+ toolName: "skill";
2331
+ endsAgentStep: true;
2332
+ description: string;
2333
+ inputSchema: z.ZodObject<{
2334
+ name: z.ZodString;
2335
+ }, z.core.$strip>;
2336
+ outputSchema: z.ZodTuple<[
2337
+ z.ZodObject<{
2338
+ type: z.ZodLiteral<"json">;
2339
+ value: z.ZodType<{
2340
+ name: string;
2341
+ description: string;
2342
+ content: string;
2343
+ license?: string | undefined;
2344
+ }, unknown, z.core.$ZodTypeInternals<{
2345
+ name: string;
2346
+ description: string;
2347
+ content: string;
2348
+ license?: string | undefined;
2349
+ }, unknown>>;
2350
+ }, z.core.$strip>
2351
+ ], null>;
2352
+ };
2353
+ spawn_agents: {
2354
+ toolName: "spawn_agents";
2355
+ endsAgentStep: true;
2356
+ description: string;
2357
+ inputSchema: z.ZodObject<{
2358
+ agents: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
2359
+ agent_type: z.ZodString;
2360
+ prompt: z.ZodOptional<z.ZodString>;
2361
+ params: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
2362
+ command: z.ZodOptional<z.ZodString>;
2363
+ what_to_summarize: z.ZodOptional<z.ZodString>;
2364
+ timeout_seconds: z.ZodOptional<z.ZodNumber>;
2365
+ searchQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
2366
+ pattern: z.ZodString;
2367
+ flags: z.ZodOptional<z.ZodString>;
2368
+ cwd: z.ZodOptional<z.ZodString>;
2369
+ maxResults: z.ZodOptional<z.ZodNumber>;
2370
+ }, z.core.$strip>>>;
2371
+ filePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
2372
+ directories: z.ZodOptional<z.ZodArray<z.ZodString>>;
2373
+ url: z.ZodOptional<z.ZodString>;
2374
+ prompts: z.ZodOptional<z.ZodArray<z.ZodString>>;
2375
+ }, z.core.$catchall<z.ZodAny>>>>;
2376
+ }, z.core.$strip>>>;
2377
+ }, z.core.$strip>;
2378
+ outputSchema: z.ZodTuple<[
2379
+ z.ZodObject<{
2380
+ type: z.ZodLiteral<"json">;
2381
+ value: z.ZodType<({
2382
+ agentType: string;
2383
+ } & JSONObject)[], unknown, z.core.$ZodTypeInternals<({
2384
+ agentType: string;
2385
+ } & JSONObject)[], unknown>>;
2386
+ }, z.core.$strip>
2387
+ ], null>;
2388
+ };
2389
+ spawn_agent_inline: {
2390
+ toolName: "spawn_agent_inline";
2391
+ endsAgentStep: true;
2392
+ description: string;
2393
+ inputSchema: z.ZodObject<{
2394
+ agent_type: z.ZodString;
2395
+ prompt: z.ZodOptional<z.ZodString>;
2396
+ params: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodAny>>>;
2397
+ }, z.core.$strip>;
2398
+ outputSchema: z.ZodTuple<[
2399
+ z.ZodObject<{
2400
+ type: z.ZodLiteral<"json">;
2401
+ value: z.ZodObject<{
2402
+ message: z.ZodString;
2403
+ }, z.core.$strip>;
2404
+ }, z.core.$strip>
2405
+ ], null>;
2406
+ };
2407
+ str_replace: {
2408
+ toolName: "str_replace";
2409
+ endsAgentStep: false;
2410
+ description: string;
2411
+ inputSchema: z.ZodObject<{
2412
+ path: z.ZodString;
2413
+ replacements: z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodObject<{
2414
+ oldString: z.ZodString;
2415
+ newString: z.ZodString;
2416
+ allowMultiple: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
2417
+ }, z.core.$strip>>>>;
2418
+ }, z.core.$strip>;
2419
+ outputSchema: z.ZodTuple<[
2420
+ z.ZodObject<{
2421
+ type: z.ZodLiteral<"json">;
2422
+ value: z.ZodType<{
2423
+ file: string;
2424
+ message: string;
2425
+ } | {
2426
+ file: string;
2427
+ errorMessage: string;
2428
+ patch?: string | undefined;
2429
+ }, unknown, z.core.$ZodTypeInternals<{
2430
+ file: string;
2431
+ message: string;
2432
+ } | {
2433
+ file: string;
2434
+ errorMessage: string;
2435
+ patch?: string | undefined;
2436
+ }, unknown>>;
2437
+ }, z.core.$strip>
2438
+ ], null>;
2439
+ };
2440
+ suggest_followups: {
2441
+ toolName: "suggest_followups";
2442
+ endsAgentStep: false;
2443
+ description: string;
2444
+ inputSchema: z.ZodObject<{
2445
+ followups: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
2446
+ prompt: z.ZodString;
2447
+ label: z.ZodOptional<z.ZodString>;
2448
+ }, z.core.$strip>>>;
2449
+ }, z.core.$strip>;
2450
+ outputSchema: z.ZodTuple<[
2451
+ z.ZodObject<{
2452
+ type: z.ZodLiteral<"json">;
2453
+ value: z.ZodType<{
2454
+ message: string;
2455
+ }, unknown, z.core.$ZodTypeInternals<{
2456
+ message: string;
2457
+ }, unknown>>;
2458
+ }, z.core.$strip>
2459
+ ], null>;
2460
+ };
2461
+ task_completed: {
2462
+ toolName: "task_completed";
2463
+ endsAgentStep: true;
2464
+ description: string;
2465
+ inputSchema: z.ZodObject<{}, z.core.$strip>;
2466
+ outputSchema: z.ZodTuple<[
2467
+ z.ZodObject<{
2468
+ type: z.ZodLiteral<"json">;
2469
+ value: z.ZodObject<{
2470
+ message: z.ZodString;
2471
+ }, z.core.$strip>;
2472
+ }, z.core.$strip>
2473
+ ], null>;
2474
+ };
2475
+ think_deeply: {
2476
+ toolName: "think_deeply";
2477
+ endsAgentStep: false;
2478
+ description: string;
2479
+ inputSchema: z.ZodObject<{
2480
+ thought: z.ZodString;
2481
+ }, z.core.$strip>;
2482
+ outputSchema: z.ZodTuple<[
2483
+ z.ZodObject<{
2484
+ type: z.ZodLiteral<"json">;
2485
+ value: z.ZodObject<{
2486
+ message: z.ZodString;
2487
+ }, z.core.$strip>;
2488
+ }, z.core.$strip>
2489
+ ], null>;
2490
+ };
2491
+ update_subgoal: {
2492
+ toolName: "update_subgoal";
2493
+ endsAgentStep: false;
2494
+ description: string;
2495
+ inputSchema: z.ZodObject<{
2496
+ id: z.ZodString;
2497
+ status: z.ZodOptional<z.ZodEnum<{
2498
+ NOT_STARTED: "NOT_STARTED";
2499
+ IN_PROGRESS: "IN_PROGRESS";
2500
+ COMPLETE: "COMPLETE";
2501
+ ABORTED: "ABORTED";
2502
+ }>>;
2503
+ plan: z.ZodOptional<z.ZodString>;
2504
+ log: z.ZodOptional<z.ZodString>;
2505
+ }, z.core.$strip>;
2506
+ outputSchema: z.ZodTuple<[
2507
+ z.ZodObject<{
2508
+ type: z.ZodLiteral<"json">;
2509
+ value: z.ZodType<{
2510
+ message: string;
2511
+ }, unknown, z.core.$ZodTypeInternals<{
2512
+ message: string;
2513
+ }, unknown>>;
2514
+ }, z.core.$strip>
2515
+ ], null>;
2516
+ };
2517
+ screenshot: {
2518
+ toolName: "screenshot";
2519
+ endsAgentStep: true;
2520
+ description: string;
2521
+ inputSchema: z.ZodObject<{
2522
+ url: z.ZodString;
2523
+ output_path: z.ZodOptional<z.ZodString>;
2524
+ width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
2525
+ height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
2526
+ full_page: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
2527
+ wait_ms: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
2528
+ dark_mode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
2529
+ }, z.core.$strip>;
2530
+ outputSchema: z.ZodTuple<[
2531
+ z.ZodObject<{
2532
+ type: z.ZodLiteral<"json">;
2533
+ value: z.ZodType<{
2534
+ success: boolean;
2535
+ message: string;
2536
+ width: number;
2537
+ height: number;
2538
+ output_path?: string | undefined;
2539
+ }, unknown, z.core.$ZodTypeInternals<{
2540
+ success: boolean;
2541
+ message: string;
2542
+ width: number;
2543
+ height: number;
2544
+ output_path?: string | undefined;
2545
+ }, unknown>>;
2546
+ }, z.core.$strip>
2547
+ ], null>;
2548
+ };
2549
+ vision_analyze: {
2550
+ toolName: "vision_analyze";
2551
+ endsAgentStep: true;
2552
+ description: string;
2553
+ inputSchema: z.ZodObject<{
2554
+ image_path: z.ZodString;
2555
+ prompt: z.ZodString;
2556
+ context: z.ZodOptional<z.ZodString>;
2557
+ focus_areas: z.ZodOptional<z.ZodArray<z.ZodString>>;
2558
+ }, z.core.$strip>;
2559
+ outputSchema: z.ZodTuple<[
2560
+ z.ZodObject<{
2561
+ type: z.ZodLiteral<"json">;
2562
+ value: z.ZodType<{
2563
+ analysis: string;
2564
+ issues_found: {
2565
+ severity: "info" | "warning" | "critical";
2566
+ area: string;
2567
+ description: string;
2568
+ suggestion: string;
2569
+ }[];
2570
+ score: number;
2571
+ summary: string;
2572
+ }, unknown, z.core.$ZodTypeInternals<{
2573
+ analysis: string;
2574
+ issues_found: {
2575
+ severity: "info" | "warning" | "critical";
2576
+ area: string;
2577
+ description: string;
2578
+ suggestion: string;
2579
+ }[];
2580
+ score: number;
2581
+ summary: string;
2582
+ }, unknown>>;
2583
+ }, z.core.$strip>
2584
+ ], null>;
2585
+ };
2586
+ web_search: {
2587
+ toolName: "web_search";
2588
+ endsAgentStep: true;
2589
+ description: string;
2590
+ inputSchema: z.ZodObject<{
2591
+ query: z.ZodString;
2592
+ depth: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
2593
+ standard: "standard";
2594
+ deep: "deep";
2595
+ }>>>;
2596
+ }, z.core.$strip>;
2597
+ outputSchema: z.ZodTuple<[
2598
+ z.ZodObject<{
2599
+ type: z.ZodLiteral<"json">;
2600
+ value: z.ZodType<{
2601
+ result: string;
2602
+ } | {
2603
+ errorMessage: string;
2604
+ }, unknown, z.core.$ZodTypeInternals<{
2605
+ result: string;
2606
+ } | {
2607
+ errorMessage: string;
2608
+ }, unknown>>;
2609
+ }, z.core.$strip>
2610
+ ], null>;
2611
+ };
2612
+ write_file: {
2613
+ toolName: "write_file";
2614
+ endsAgentStep: false;
2615
+ description: string;
2616
+ inputSchema: z.ZodObject<{
2617
+ path: z.ZodString;
2618
+ instructions: z.ZodString;
2619
+ content: z.ZodString;
2620
+ }, z.core.$strip>;
2621
+ outputSchema: z.ZodTuple<[
2622
+ z.ZodObject<{
2623
+ type: z.ZodLiteral<"json">;
2624
+ value: z.ZodType<{
2625
+ file: string;
2626
+ message: string;
2627
+ } | {
2628
+ file: string;
2629
+ errorMessage: string;
2630
+ patch?: string | undefined;
2631
+ }, unknown, z.core.$ZodTypeInternals<{
2632
+ file: string;
2633
+ message: string;
2634
+ } | {
2635
+ file: string;
2636
+ errorMessage: string;
2637
+ patch?: string | undefined;
2638
+ }, unknown>>;
2639
+ }, z.core.$strip>
2640
+ ], null>;
2641
+ };
2642
+ write_todos: {
2643
+ toolName: "write_todos";
2644
+ endsAgentStep: false;
2645
+ description: string;
2646
+ inputSchema: z.ZodObject<{
2647
+ todos: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
2648
+ task: z.ZodString;
2649
+ completed: z.ZodBoolean;
2650
+ }, z.core.$strip>>>;
2651
+ }, z.core.$strip>;
2652
+ outputSchema: z.ZodTuple<[
2653
+ z.ZodObject<{
2654
+ type: z.ZodLiteral<"json">;
2655
+ value: z.ZodObject<{
2656
+ message: z.ZodString;
2657
+ }, z.core.$strip>;
2658
+ }, z.core.$strip>
2659
+ ], null>;
2660
+ };
2661
+ };
2662
+ export type AnvilToolOutput<T extends ToolName = ToolName> = {
2663
+ [K in ToolName]: K extends ToolName ? z.infer<(typeof toolParams)[K]["outputSchema"]> : never;
2664
+ }[T];
2665
+ declare const clientToolCallSchema: z.ZodDiscriminatedUnion<[
2666
+ z.ZodObject<{
2667
+ toolName: z.ZodLiteral<"apply_patch">;
2668
+ input: z.ZodObject<{
2669
+ operation: z.ZodDiscriminatedUnion<[
2670
+ z.ZodObject<{
2671
+ type: z.ZodLiteral<"create_file">;
2672
+ path: z.ZodString;
2673
+ diff: z.ZodString;
2674
+ }, z.core.$strip>,
2675
+ z.ZodObject<{
2676
+ type: z.ZodLiteral<"update_file">;
2677
+ path: z.ZodString;
2678
+ diff: z.ZodString;
2679
+ }, z.core.$strip>,
2680
+ z.ZodObject<{
2681
+ type: z.ZodLiteral<"delete_file">;
2682
+ path: z.ZodString;
2683
+ }, z.core.$strip>
2684
+ ], "type">;
2685
+ }, z.core.$strip>;
2686
+ }, z.core.$strip>,
2687
+ z.ZodObject<{
2688
+ toolName: z.ZodLiteral<"ask_user">;
2689
+ input: z.ZodObject<{
2690
+ questions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
2691
+ question: z.ZodString;
2692
+ header: z.ZodOptional<z.ZodString>;
2693
+ options: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
2694
+ label: z.ZodString;
2695
+ description: z.ZodOptional<z.ZodString>;
2696
+ }, z.core.$strip>>>;
2697
+ multiSelect: z.ZodDefault<z.ZodBoolean>;
2698
+ validation: z.ZodOptional<z.ZodObject<{
2699
+ maxLength: z.ZodOptional<z.ZodNumber>;
2700
+ minLength: z.ZodOptional<z.ZodNumber>;
2701
+ pattern: z.ZodOptional<z.ZodString>;
2702
+ patternError: z.ZodOptional<z.ZodString>;
2703
+ }, z.core.$strip>>;
2704
+ }, z.core.$strip>>>;
2705
+ }, z.core.$strip>;
2706
+ }, z.core.$strip>,
2707
+ z.ZodObject<{
2708
+ toolName: z.ZodLiteral<"browser_logs">;
2709
+ input: z.ZodObject<{
2710
+ type: z.ZodString;
2711
+ url: z.ZodString;
2712
+ waitUntil: z.ZodOptional<z.ZodEnum<{
2713
+ networkidle0: "networkidle0";
2714
+ load: "load";
2715
+ domcontentloaded: "domcontentloaded";
2716
+ }>>;
2717
+ }, z.core.$strip>;
2718
+ }, z.core.$strip>,
2719
+ z.ZodObject<{
2720
+ toolName: z.ZodLiteral<"code_search">;
2721
+ input: z.ZodObject<{
2722
+ pattern: z.ZodString;
2723
+ flags: z.ZodOptional<z.ZodString>;
2724
+ cwd: z.ZodOptional<z.ZodString>;
2725
+ maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
2726
+ }, z.core.$strip>;
2727
+ }, z.core.$strip>,
2728
+ z.ZodObject<{
2729
+ toolName: z.ZodLiteral<"create_plan">;
2730
+ input: z.ZodObject<{
2731
+ type: z.ZodEnum<{
2732
+ file: "file";
2733
+ patch: "patch";
2734
+ }>;
2735
+ path: z.ZodString;
2736
+ content: z.ZodString;
2737
+ }, z.core.$strip>;
2738
+ }, z.core.$strip>,
2739
+ z.ZodObject<{
2740
+ toolName: z.ZodLiteral<"glob">;
2741
+ input: z.ZodObject<{
2742
+ pattern: z.ZodString;
2743
+ cwd: z.ZodOptional<z.ZodString>;
2744
+ max_results: z.ZodOptional<z.ZodNumber>;
2745
+ }, z.core.$strip>;
2746
+ }, z.core.$strip>,
2747
+ z.ZodObject<{
2748
+ toolName: z.ZodLiteral<"list_directory">;
2749
+ input: z.ZodObject<{
2750
+ path: z.ZodString;
2751
+ }, z.core.$strip>;
2752
+ }, z.core.$strip>,
2753
+ z.ZodObject<{
2754
+ toolName: z.ZodLiteral<"run_file_change_hooks">;
2755
+ input: z.ZodObject<{
2756
+ files: z.ZodArray<z.ZodString>;
2757
+ }, z.core.$strip>;
2758
+ }, z.core.$strip>,
2759
+ z.ZodObject<{
2760
+ toolName: z.ZodLiteral<"read_url">;
2761
+ input: z.ZodObject<{
2762
+ url: z.ZodURL;
2763
+ max_chars: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
2764
+ }, z.core.$strip>;
2765
+ }, z.core.$strip>,
2766
+ z.ZodObject<{
2767
+ toolName: z.ZodLiteral<"run_terminal_command">;
2768
+ input: z.ZodIntersection<z.ZodObject<{
2769
+ command: z.ZodString;
2770
+ process_type: z.ZodDefault<z.ZodEnum<{
2771
+ SYNC: "SYNC";
2772
+ BACKGROUND: "BACKGROUND";
2773
+ }>>;
2774
+ cwd: z.ZodOptional<z.ZodString>;
2775
+ timeout_seconds: z.ZodPipe<z.ZodOptional<z.ZodDefault<z.ZodNumber>>, z.ZodTransform<number | undefined, number | undefined>>;
2776
+ }, z.core.$strip>, z.ZodObject<{
2777
+ mode: z.ZodEnum<{
2778
+ user: "user";
2779
+ assistant: "assistant";
2780
+ }>;
2781
+ }, z.core.$strip>>;
2782
+ }, z.core.$strip>,
2783
+ z.ZodObject<{
2784
+ toolName: z.ZodLiteral<"str_replace">;
2785
+ input: z.ZodObject<{
2786
+ type: z.ZodEnum<{
2787
+ file: "file";
2788
+ patch: "patch";
2789
+ }>;
2790
+ path: z.ZodString;
2791
+ content: z.ZodString;
2792
+ }, z.core.$strip>;
2793
+ }, z.core.$strip>,
2794
+ z.ZodObject<{
2795
+ toolName: z.ZodLiteral<"write_file">;
2796
+ input: z.ZodObject<{
2797
+ type: z.ZodEnum<{
2798
+ file: "file";
2799
+ patch: "patch";
2800
+ }>;
2801
+ path: z.ZodString;
2802
+ content: z.ZodString;
2803
+ }, z.core.$strip>;
2804
+ }, z.core.$strip>,
2805
+ z.ZodObject<{
2806
+ toolName: z.ZodLiteral<"composio_manage_connections">;
2807
+ input: z.ZodObject<{
2808
+ toolkits: z.ZodArray<z.ZodString>;
2809
+ reinitiate_all: z.ZodOptional<z.ZodBoolean>;
2810
+ session_id: z.ZodOptional<z.ZodString>;
2811
+ }, z.core.$catchall<z.ZodUnknown>>;
2812
+ }, z.core.$strip>,
2813
+ z.ZodObject<{
2814
+ toolName: z.ZodLiteral<"composio_multi_execute_tool">;
2815
+ input: z.ZodObject<{
2816
+ tools: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2817
+ thought: z.ZodOptional<z.ZodString>;
2818
+ sync_response_to_workbench: z.ZodDefault<z.ZodBoolean>;
2819
+ session_id: z.ZodOptional<z.ZodString>;
2820
+ }, z.core.$catchall<z.ZodUnknown>>;
2821
+ }, z.core.$strip>,
2822
+ z.ZodObject<{
2823
+ toolName: z.ZodLiteral<"composio_search_tools">;
2824
+ input: z.ZodObject<{
2825
+ queries: z.ZodArray<z.ZodUnknown>;
2826
+ session: z.ZodObject<{
2827
+ generate_id: z.ZodOptional<z.ZodBoolean>;
2828
+ id: z.ZodOptional<z.ZodString>;
2829
+ }, z.core.$catchall<z.ZodUnknown>>;
2830
+ model: z.ZodOptional<z.ZodString>;
2831
+ }, z.core.$catchall<z.ZodUnknown>>;
2832
+ }, z.core.$strip>,
2833
+ z.ZodObject<{
2834
+ toolName: z.ZodLiteral<"composio_get_tool_schemas">;
2835
+ input: z.ZodObject<{
2836
+ tool_slugs: z.ZodArray<z.ZodString>;
2837
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
2838
+ session_id: z.ZodOptional<z.ZodString>;
2839
+ }, z.core.$catchall<z.ZodUnknown>>;
2840
+ }, z.core.$strip>
2841
+ ], "toolName">;
2842
+ declare const clientToolNames: ("glob" | "composio_manage_connections" | "composio_multi_execute_tool" | "composio_search_tools" | "composio_get_tool_schemas" | "create_plan" | "apply_patch" | "ask_user" | "browser_logs" | "code_search" | "list_directory" | "read_url" | "run_file_change_hooks" | "run_terminal_command" | "str_replace" | "write_file")[];
2843
+ export type ClientToolName = (typeof clientToolNames)[number];
2844
+ export type ClientToolCall<T extends ClientToolName = ClientToolName> = Extract<z.infer<typeof clientToolCallSchema>, {
2845
+ toolName: T;
2846
+ }> & Pick<ToolCallPart, "toolCallId" | "toolName" | "input" | "providerOptions">;
2847
+ type PublishedClientToolName = Extract<ClientToolName, PublishedToolName>;
2848
+ export type TerminalCommandSpawnRequest = {
2849
+ executable: string;
2850
+ args: string[];
2851
+ cwd: string;
2852
+ env: NodeJS.ProcessEnv;
2853
+ };
2854
+ /** A command process whose complete descendant tree has one owner. */
2855
+ export interface TerminalCommandProcess {
2856
+ pid?: number;
2857
+ stdout: Readable;
2858
+ stderr: Readable;
2859
+ /** Settles after stdout/stderr drain; brokers also finish tree cleanup. */
2860
+ completion: Promise<number | null>;
2861
+ kill(signal: NodeJS.Signals): void;
2862
+ isAlive(): boolean;
2863
+ }
2864
+ /**
2865
+ * Host-provided process boundary for interactive applications.
2866
+ *
2867
+ * A broker must start the requested executable without attaching it to the
2868
+ * host's console and return a handle that owns the complete process tree.
2869
+ * Headless SDK consumers can omit this and use the direct process runner.
2870
+ */
2871
+ export interface TerminalCommandBroker {
2872
+ start(request: TerminalCommandSpawnRequest): TerminalCommandProcess;
2873
+ }
2874
+ export type ActiveTerminalCommandProcess = {
2875
+ pid: number;
2876
+ processGroupId?: number;
2877
+ };
2878
+ /**
2879
+ * Return the process IDs owned by in-flight terminal tools. Commands are
2880
+ * started in their own process group on POSIX, where the group ID matches the
2881
+ * child PID. No command text or environment is exposed: diagnostics are often
2882
+ * pasted into bug reports and those values may contain secrets.
2883
+ */
2884
+ export declare function getActiveTerminalCommandProcesses(): ActiveTerminalCommandProcess[];
2885
+ export declare function runTerminalCommand({ command, process_type, cwd, timeout_seconds, env, signal, terminalCommandBroker, }: {
2886
+ command: string;
2887
+ process_type: "SYNC" | "BACKGROUND";
2888
+ cwd: string;
2889
+ timeout_seconds: number;
2890
+ env?: NodeJS.ProcessEnv;
2891
+ signal?: AbortSignal;
2892
+ terminalCommandBroker?: TerminalCommandBroker;
2893
+ }): Promise<AnvilToolOutput<"run_terminal_command">>;
2894
+ type GrantType = "free" | "referral" | "referral_legacy" | "subscription" | "purchase" | "admin" | "organization" | "ad";
2895
+ declare const mcpConfigSchema: z.ZodUnion<readonly [
2896
+ z.ZodObject<{
2897
+ type: z.ZodDefault<z.ZodEnum<{
2898
+ http: "http";
2899
+ sse: "sse";
2900
+ }>>;
2901
+ url: z.ZodString;
2902
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
2903
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
2904
+ }, z.core.$strict>,
2905
+ z.ZodObject<{
2906
+ type: z.ZodDefault<z.ZodLiteral<"stdio">>;
2907
+ command: z.ZodString;
2908
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
2909
+ env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
2910
+ }, z.core.$strict>
2911
+ ]>;
2912
+ type MCPConfig$1 = z.infer<typeof mcpConfigSchema>;
2913
+ type ServerActionResponseChunk = {
2914
+ type: "response-chunk";
2915
+ userInputId: string;
2916
+ chunk: string | PrintModeEvent;
2917
+ };
2918
+ type ServerActionSubagentResponseChunk = {
2919
+ type: "subagent-response-chunk";
2920
+ userInputId: string;
2921
+ agentId: string;
2922
+ agentType: string;
2923
+ chunk: string;
2924
+ prompt?: string;
2925
+ forwardToPrompt?: boolean;
2926
+ };
2927
+ type ServerActionHandleStepsLogChunk = {
2928
+ type: "handlesteps-log-chunk";
2929
+ userInputId: string;
2930
+ agentId: string;
2931
+ level: "debug" | "info" | "warn" | "error";
2932
+ data: any;
2933
+ message?: string;
2934
+ };
2935
+ type PromptResponse = {
2936
+ type: "prompt-response";
2937
+ promptId: string;
2938
+ sessionState: SessionState;
2939
+ toolCalls?: ToolCall$1[];
2940
+ toolResults?: ToolMessage[];
2941
+ output?: AgentOutput;
2942
+ };
2943
+ type ServerActionReadFiles = {
2944
+ type: "read-files";
2945
+ filePaths: string[];
2946
+ requestId: string;
2947
+ };
2948
+ type ServerActionToolCallRequest = {
2949
+ type: "tool-call-request";
2950
+ userInputId: string;
2951
+ requestId: string;
2952
+ toolName: string;
2953
+ input: Record<string, any>;
2954
+ timeout?: number;
2955
+ mcpConfig?: MCPConfig$1;
2956
+ };
2957
+ type InitResponse = {
2958
+ type: "init-response";
2959
+ message?: string;
2960
+ agentNames?: Record<string, string>;
2961
+ } & Omit<UsageResponse, "type">;
2962
+ type UsageResponse = {
2963
+ type: "usage-response";
2964
+ usage: number;
2965
+ remainingBalance: number;
2966
+ balanceBreakdown?: Record<GrantType, number>;
2967
+ next_quota_reset: Date | null;
2968
+ autoTopupAdded?: number;
2969
+ autoTopupEnabled?: boolean;
2970
+ };
2971
+ type MessageCostResponse = {
2972
+ type: "message-cost-response";
2973
+ promptId: string;
2974
+ credits: number;
2975
+ agentId?: string;
2976
+ };
2977
+ type ServerActionActionError = {
2978
+ type: "action-error";
2979
+ message: string;
2980
+ error?: string;
2981
+ remainingBalance?: number;
2982
+ };
2983
+ type ServerActionPromptError = {
2984
+ type: "prompt-error";
2985
+ userInputId: string;
2986
+ message: string;
2987
+ error?: string;
2988
+ remainingBalance?: number;
2989
+ };
2990
+ type ServerActionRequestReconnect = {
2991
+ type: "request-reconnect";
2992
+ };
2993
+ type ServerActionRequestMcpToolData = {
2994
+ type: "request-mcp-tool-data";
2995
+ requestId: string;
2996
+ mcpConfig: MCPConfig$1;
2997
+ toolNames?: string[];
2998
+ };
2999
+ type ServerActionAny = ServerActionResponseChunk | ServerActionSubagentResponseChunk | ServerActionHandleStepsLogChunk | PromptResponse | ServerActionReadFiles | ServerActionToolCallRequest | InitResponse | UsageResponse | MessageCostResponse | ServerActionActionError | ServerActionPromptError | ServerActionRequestReconnect | ServerActionRequestMcpToolData;
3000
+ type ServerActionType = ServerActionAny["type"];
3001
+ type ServerAction<T extends ServerActionType = ServerActionType> = {
3002
+ [K in ServerActionType]: Extract<ServerActionAny, {
3003
+ type: K;
3004
+ }>;
3005
+ }[T];
3006
+ type FileReadWindow = {
3007
+ offset?: number;
3008
+ limit?: number;
3009
+ };
3010
+ type SendActionFn = (params: {
3011
+ action: ServerAction;
3012
+ }) => void;
3013
+ export type FileFilterResult = {
3014
+ status: "blocked" | "allow-example" | "allow";
3015
+ };
3016
+ export type FileFilter = (filePath: string) => FileFilterResult;
3017
+ export declare function getFiles(params: {
3018
+ filePaths: string[];
3019
+ cwd: string;
3020
+ fs: AnvilFileSystem;
3021
+ fileWindows?: Record<string, FileReadWindow[]>;
3022
+ /**
3023
+ * Apply the user-facing read_files output budget. Internal edit tools need
3024
+ * the complete file so replacements below the display limit can still match.
3025
+ */
3026
+ limitContent?: boolean;
3027
+ /** Apply the read_files-only .env restriction. */
3028
+ enforceEnvPolicy?: boolean;
3029
+ /**
3030
+ * Filter to classify files before reading.
3031
+ * If provided, the caller takes control of additional filtering. The SDK's
3032
+ * read_files .env policy applies by default, including ordinary gitignore
3033
+ * checks for env templates.
3034
+ */
3035
+ fileFilter?: FileFilter;
3036
+ }): Promise<{
3037
+ [x: string]: string | null;
3038
+ }>;
3039
+ declare enum AnalyticsEvent {
3040
+ MESSAGE_SENT = "message_sent",
3041
+ PRODUCT_ACTIVE_MINUTE = "product_active_minute",
3042
+ APP_LAUNCHED = "cli.app_launched",
3043
+ FINGERPRINT_GENERATED = "cli.fingerprint_generated",
3044
+ CHANGE_DIRECTORY = "cli.change_directory",
3045
+ INVALID_COMMAND = "cli.invalid_command",
3046
+ KNOWLEDGE_FILE_UPDATED = "cli.knowledge_file_updated",
3047
+ LOGIN = "cli.login",
3048
+ LOGIN_STARTED = "cli.login_started",
3049
+ LOGIN_FAILED = "cli.login_failed",
3050
+ LOGIN_TIMEOUT = "cli.login_timeout",
3051
+ LOGIN_ABORTED = "cli.login_aborted",
3052
+ SLASH_MENU_ACTIVATED = "cli.slash_menu_activated",
3053
+ SLASH_COMMAND_USED = "cli.slash_command_used",
3054
+ TERMINAL_BROKER_SPAWN_FAILED = "cli.terminal_broker_spawn_failed",
3055
+ TERMINAL_WATCHDOG_FAILED = "cli.terminal_watchdog_failed",
3056
+ TERMINAL_COMMAND_COMPLETED = "cli.terminal_command_completed",
3057
+ USER_INPUT_COMPLETE = "cli.user_input_complete",
3058
+ UPDATE_ANVIL_FAILED = "cli.update_anvil_failed",
3059
+ FEEDBACK_BUTTON_HOVERED = "cli.feedback_button_hovered",
3060
+ FOLLOWUP_CLICKED = "cli.followup_clicked",
3061
+ SUGGESTED_PROMPT_SHOWN = "cli.suggested_prompt_shown",
3062
+ SUGGESTED_PROMPT_CLICKED = "cli.suggested_prompt_clicked",
3063
+ CLI_INLINE_AD_SLOT_ELIGIBLE = "cli.inline_ad_slot_eligible",
3064
+ CLI_INLINE_AD_POOL_REUSED = "cli.inline_ad_pool_reused",
3065
+ AGENT_STEP = "backend.agent_step",
3066
+ CREDIT_GRANT = "backend.credit_grant",
3067
+ CREDIT_CONSUMED = "backend.credit_consumed",
3068
+ MALFORMED_TOOL_CALL_JSON = "backend.malformed_tool_call_json",
3069
+ TOOL_USE = "backend.tool_use",
3070
+ UNKNOWN_TOOL_CALL = "backend.unknown_tool_call",
3071
+ USER_INPUT = "backend.user_input",
3072
+ ADVISORY_LOCK_CONTENTION = "backend.advisory_lock_contention",
3073
+ TRANSACTION_RETRY_THRESHOLD_EXCEEDED = "backend.transaction_retry_threshold_exceeded",
3074
+ SUBSCRIPTION_CREATED = "backend.subscription_created",
3075
+ SUBSCRIPTION_CANCELED = "backend.subscription_canceled",
3076
+ SUBSCRIPTION_PAYMENT_FAILED = "backend.subscription_payment_failed",
3077
+ SUBSCRIPTION_BLOCK_CREATED = "backend.subscription_block_created",
3078
+ SUBSCRIPTION_BLOCK_LIMIT_HIT = "backend.subscription_block_limit_hit",
3079
+ SUBSCRIPTION_WEEKLY_LIMIT_HIT = "backend.subscription_weekly_limit_hit",
3080
+ SUBSCRIPTION_CREDITS_MIGRATED = "backend.subscription_credits_migrated",
3081
+ SUBSCRIPTION_TIER_CHANGED = "backend.subscription_tier_changed",
3082
+ SIGNUP = "web.signup",
3083
+ AUTH_LOGIN_STARTED = "auth.login_started",
3084
+ AUTH_LOGOUT_COMPLETED = "auth.logout_completed",
3085
+ COOKIE_CONSENT_ACCEPTED = "cookie_consent.accepted",
3086
+ COOKIE_CONSENT_DECLINED = "cookie_consent.declined",
3087
+ ONBOARDING_STEP_COMPLETED = "onboarding_step_completed",
3088
+ ONBOARDING_STEP_VIEWED = "onboarding_step_viewed",
3089
+ ONBOARDING_PM_SELECTED = "onboarding_pm_selected",
3090
+ ONBOARDING_EDITOR_OPENED = "onboarding_editor_opened",
3091
+ ONBOARD_PAGE_CD_COMMAND_COPIED = "onboard_page.cd_command_copied",
3092
+ ONBOARD_PAGE_RUN_COMMAND_COPIED = "onboard_page.run_command_copied",
3093
+ ONBOARD_PAGE_INSTALL_COMMAND_COPIED = "onboard_page.install_command_copied",
3094
+ ANVIL_REFERRER_ATTRIBUTED = "anvil.referrer_attributed",
3095
+ INSTALL_DIALOG_CD_COMMAND_COPIED = "install_dialog.cd_command_copied",
3096
+ INSTALL_DIALOG_RUN_COMMAND_COPIED = "install_dialog.run_command_copied",
3097
+ INSTALL_DIALOG_INSTALL_COMMAND_COPIED = "install_dialog.install_command_copied",
3098
+ HOME_FEATURE_LEARN_MORE_CLICKED = "home.feature_learn_more_clicked",
3099
+ HOME_INSTALL_COMMAND_COPIED = "home.install_command_copied",
3100
+ HOME_TRY_FREE_CLICKED = "home.try_free_clicked",
3101
+ HOME_TESTIMONIAL_CLICKED = "home.testimonial_clicked",
3102
+ HOME_CTA_INSTALL_GUIDE_CLICKED = "home.cta_install_guide_clicked",
3103
+ HOME_COMPETITION_TAB_CHANGED = "home.competition_tab_changed",
3104
+ DEMO_TERMINAL_COMMAND_EXECUTED = "demo_terminal.command_executed",
3105
+ DEMO_TERMINAL_HELP_VIEWED = "demo_terminal.help_viewed",
3106
+ DEMO_TERMINAL_OPTIMIZE_REQUESTED = "demo_terminal.optimize_requested",
3107
+ DEMO_TERMINAL_FIX_MEMORY_LEAK = "demo_terminal.fix_memory_leak",
3108
+ DEMO_TERMINAL_REFACTOR_REQUESTED = "demo_terminal.refactor_requested",
3109
+ DEMO_TERMINAL_FEATURE_REQUESTED = "demo_terminal.feature_requested",
3110
+ DEMO_TERMINAL_THEME_CHANGED = "demo_terminal.theme_changed",
3111
+ TOAST_SHOWN = "toast.shown",
3112
+ AGENT_RUN_API_REQUEST = "api.agent_run_request",
3113
+ AGENT_RUN_CREATED = "api.agent_run_created",
3114
+ AGENT_RUN_COMPLETED = "api.agent_run_completed",
3115
+ AGENT_RUN_VALIDATION_ERROR = "api.agent_run_validation_error",
3116
+ AGENT_RUN_CREATION_ERROR = "api.agent_run_creation_error",
3117
+ AGENT_RUN_COMPLETION_ERROR = "api.agent_run_completion_error",
3118
+ ME_API_REQUEST = "api.me_request",
3119
+ ME_VALIDATION_ERROR = "api.me_validation_error",
3120
+ CHAT_COMPLETIONS_REQUEST = "api.chat_completions_request",
3121
+ CHAT_COMPLETIONS_AUTH_ERROR = "api.chat_completions_auth_error",
3122
+ CHAT_COMPLETIONS_VALIDATION_ERROR = "api.chat_completions_validation_error",
3123
+ CHAT_COMPLETIONS_INSUFFICIENT_CREDITS = "api.chat_completions_insufficient_credits",
3124
+ CHAT_COMPLETIONS_GENERATION_STARTED = "api.chat_completions_generation_started",
3125
+ CHAT_COMPLETIONS_STREAM_STARTED = "api.chat_completions_stream_started",
3126
+ CHAT_COMPLETIONS_ERROR = "api.chat_completions_error",
3127
+ USAGE_API_REQUEST = "api.usage_request",
3128
+ USAGE_API_AUTH_ERROR = "api.usage_auth_error",
3129
+ WEB_SEARCH_REQUEST = "api.web_search_request",
3130
+ WEB_SEARCH_AUTH_ERROR = "api.web_search_auth_error",
3131
+ WEB_SEARCH_VALIDATION_ERROR = "api.web_search_validation_error",
3132
+ WEB_SEARCH_INSUFFICIENT_CREDITS = "api.web_search_insufficient_credits",
3133
+ WEB_SEARCH_ERROR = "api.web_search_error",
3134
+ DOCS_SEARCH_REQUEST = "api.docs_search_request",
3135
+ DOCS_SEARCH_AUTH_ERROR = "api.docs_search_auth_error",
3136
+ DOCS_SEARCH_VALIDATION_ERROR = "api.docs_search_validation_error",
3137
+ DOCS_SEARCH_INSUFFICIENT_CREDITS = "api.docs_search_insufficient_credits",
3138
+ DOCS_SEARCH_ERROR = "api.docs_search_error",
3139
+ GRAVITY_INDEX_REQUEST = "api.gravity_index_request",
3140
+ GRAVITY_INDEX_AUTH_ERROR = "api.gravity_index_auth_error",
3141
+ GRAVITY_INDEX_VALIDATION_ERROR = "api.gravity_index_validation_error",
3142
+ GRAVITY_INDEX_ERROR = "api.gravity_index_error",
3143
+ FEEDBACK_SUBMITTED = "api.feedback_submitted",
3144
+ FEEDBACK_AUTH_ERROR = "api.feedback_auth_error",
3145
+ FEEDBACK_VALIDATION_ERROR = "api.feedback_validation_error",
3146
+ LOGS_INGEST_AUTH_ERROR = "api.logs_ingest_auth_error",
3147
+ LOGS_INGEST_VALIDATION_ERROR = "api.logs_ingest_validation_error",
3148
+ ADS_API_AUTH_ERROR = "api.ads_auth_error",
3149
+ ADS_FETCH_COMPLETED = "ads.fetch_completed",
3150
+ ADS_IMPRESSION_RECORDED = "ads.impression_recorded",
3151
+ ADS_CLICKED = "ads.clicked",
3152
+ TOKEN_COUNT_REQUEST = "api.token_count_request",
3153
+ TOKEN_COUNT_AUTH_ERROR = "api.token_count_auth_error",
3154
+ TOKEN_COUNT_VALIDATION_ERROR = "api.token_count_validation_error",
3155
+ TOKEN_COUNT_ERROR = "api.token_count_error",
3156
+ ANVIL_REFERRAL_REDEEMED = "anvil.referral.redeemed",
3157
+ ANVIL_REFERRAL_REDEEM_FAILED = "anvil.referral.redeem_failed",
3158
+ ANVIL_REFERRAL_SOCK_SIGNAL = "anvil.referral.sock_signal",
3159
+ ANVIL_GET_STARTED_VIEWED = "anvil.get_started_viewed",
3160
+ ANVIL_GET_STARTED_SIGN_IN_CLICKED = "anvil.get_started_sign_in_clicked",
3161
+ ANVIL_GET_STARTED_SIGNED_IN = "anvil.get_started_signed_in",
3162
+ ANVIL_GET_STARTED_ELIGIBILITY_RESOLVED = "anvil.get_started_eligibility_resolved",
3163
+ ANVIL_GET_STARTED_CONNECT_GITHUB_CLICKED = "anvil.get_started_connect_github_clicked",
3164
+ ANVIL_GET_STARTED_INSTALL_COMMAND_COPIED = "anvil.get_started_install_command_copied",
3165
+ ANVIL_GET_STARTED_WEB_CLICKED = "anvil.get_started_web_clicked",
3166
+ ANVIL_GET_STARTED_HELP_EXPANDED = "anvil.get_started_help_expanded",
3167
+ ANVIL_GET_STARTED_EDITOR_CLICKED = "anvil.get_started_editor_clicked",
3168
+ ANVIL_CHAT_TITLE_GENERATED = "anvil.chat_title_generated",
3169
+ ANVIL_CLI_INSTALL_COMMAND_COPIED = "anvil.cli_install_command_copied",
3170
+ ANVIL_ENTERPRISE_CONTACT_SUBMITTED = "anvil.enterprise_contact_submitted",
3171
+ ANVIL_DESKTOP_DOWNLOAD_CLICKED = "anvil.desktop_download_clicked",
3172
+ ANVIL_WEB_GATE_REDIRECT_CLICKED = "anvil.web_gate_redirect_clicked",
3173
+ ANVIL_WEB_ONBOARDING_STEP = "anvil.web_onboarding_step",
3174
+ ANVIL_WEB_ONBOARDING_FINISHED = "anvil.web_onboarding_finished",
3175
+ ANVIL_WEB_TOUR_STEP = "anvil.web_tour_step",
3176
+ ANVIL_WEB_TOUR_FINISHED = "anvil.web_tour_finished",
3177
+ ANVIL_BOOKMARK_GATE_SHOWN = "anvil.bookmark_gate_shown",
3178
+ ANVIL_BOOKMARK_GATE_CONFIRMED = "anvil.bookmark_gate_confirmed",
3179
+ ANVIL_CLOUD_CONNECT_REPO_CLICKED = "anvil.cloud_connect_repo_clicked",
3180
+ ANVIL_CLOUD_BLANK_PROJECT_CLICKED = "anvil.cloud_blank_project_clicked",
3181
+ ANVIL_HOME_INSTALL_COMMAND_COPIED = "anvil.home_install_command_copied",
3182
+ ANVIL_HOME_GITHUB_CLICKED = "anvil.home_github_clicked",
3183
+ ANVIL_HOME_INSTALL_GUIDE_EXPANDED = "anvil.home_install_guide_expanded",
3184
+ ANVIL_HOME_FAQ_OPENED = "anvil.home_faq_opened",
3185
+ ANVIL_HOME_SAVINGS_CTA_CLICKED = "anvil.home_savings_cta_clicked",
3186
+ ANVIL_ATTRIBUTED = "anvil.attributed",
3187
+ ANVIL_AFFILIATE_SIGNUP = "anvil.affiliate.signup",
3188
+ ANVIL_AFFILIATE_ACTIVATION = "anvil.affiliate.activation",
3189
+ ANVIL_REDDIT_FUNNEL_CLI_INSTALLED = "anvil.reddit_funnel.cli_installed",
3190
+ ANVIL_REDDIT_FUNNEL_LOGIN = "anvil.reddit_funnel.login",
3191
+ ANVIL_REDDIT_FUNNEL_SIGN_UP = "anvil.reddit_funnel.sign_up",
3192
+ ANVIL_REDDIT_FUNNEL_FIRST_PROMPT = "anvil.reddit_funnel.first_prompt",
3193
+ ANVIL_REDDIT_FUNNEL_RETENTION_1D = "anvil.reddit_funnel.retention_1d",
3194
+ ANVIL_REDDIT_FUNNEL_RETENTION_7D = "anvil.reddit_funnel.retention_7d",
3195
+ ANVIL_REDDIT_FUNNEL_RETENTION_24D = "anvil.reddit_funnel.retention_24d",
3196
+ ANVIL_REDDIT_FUNNEL_FIRST_PROMPT_CLI = "anvil.reddit_funnel.first_prompt_cli",
3197
+ ANVIL_REDDIT_FUNNEL_FIRST_PROMPT_WEB = "anvil.reddit_funnel.first_prompt_web",
3198
+ ANVIL_REDDIT_FUNNEL_FIRST_PROMPT_CHAT = "anvil.reddit_funnel.first_prompt_chat",
3199
+ ANVIL_REDDIT_FUNNEL_RETENTION_1D_CLI = "anvil.reddit_funnel.retention_1d_cli",
3200
+ ANVIL_REDDIT_FUNNEL_RETENTION_7D_CLI = "anvil.reddit_funnel.retention_7d_cli",
3201
+ ANVIL_REDDIT_FUNNEL_RETENTION_24D_CLI = "anvil.reddit_funnel.retention_24d_cli",
3202
+ ANVIL_REDDIT_FUNNEL_GRAVITY_AD_CLICK = "anvil.reddit_funnel.gravity_ad_click",
3203
+ ANVIL_CHAT_ADS_EXPERIMENT_EXPOSED = "anvil.chat_ads.experiment_exposed",
3204
+ ANVIL_CHAT_ADS_AD_SHOWN = "anvil.chat_ads.ad_shown",
3205
+ DESKTOP_APP_LAUNCHED = "desktop.app_launched",
3206
+ DESKTOP_LOGIN_STARTED = "desktop.login_started",
3207
+ DESKTOP_LOGIN = "desktop.login",
3208
+ DESKTOP_LOGIN_FAILED = "desktop.login_failed",
3209
+ DESKTOP_LOGOUT = "desktop.logout",
3210
+ DESKTOP_THREAD_CREATED = "desktop.thread_created",
3211
+ DESKTOP_THREAD_TITLED = "desktop.thread_titled",
3212
+ DESKTOP_PROJECT_OPENED = "desktop.project_opened",
3213
+ DESKTOP_PROJECT_REMOVED = "desktop.project_removed",
3214
+ DESKTOP_TURN_COMPLETED = "desktop.turn_completed",
3215
+ DESKTOP_FAILED_TURN_RECOVERY = "desktop.failed_turn_recovery",
3216
+ DESKTOP_HARNESS_CHANGED = "desktop.harness_changed",
3217
+ DESKTOP_MODEL_CHANGED = "desktop.model_changed",
3218
+ DESKTOP_SKILL_RUN = "desktop.skill_run",
3219
+ DESKTOP_QUEUE_SEND_NOW = "desktop.queue_send_now",
3220
+ DESKTOP_FEATURE_USED = "desktop.feature_used",
3221
+ DESKTOP_AUTORUN_TOGGLED = "desktop.autorun_toggled",
3222
+ DESKTOP_AUTORUN_SCOPE_SET = "desktop.autorun_scope_set",
3223
+ DESKTOP_CODEX_RESOLUTION = "desktop.codex_resolution",
3224
+ DESKTOP_AD_SHOWN = "desktop.ad_shown",
3225
+ DESKTOP_AD_CLICKED = "desktop.ad_clicked",
3226
+ DESKTOP_INLINE_AD_SLOT_ELIGIBLE = "desktop.inline_ad_slot_eligible",
3227
+ DESKTOP_SHUTDOWN_TURNS_ABORTED = "desktop.shutdown_turns_aborted",
3228
+ DESKTOP_ORPHANS_REAPED = "desktop.orphans_reaped",
3229
+ DESKTOP_WORKTREES_RECLAIMED = "desktop.worktrees_reclaimed",
3230
+ DESKTOP_TURNS_RESURRECTED = "desktop.turns_resurrected",
3231
+ DESKTOP_TURN_STALLED = "desktop.turn_stalled",
3232
+ DESKTOP_TURN_BACKGROUND_WAIT = "desktop.turn_background_wait",
3233
+ DESKTOP_EVENT_LOOP_HEALTH = "desktop.event_loop_health",
3234
+ DESKTOP_THREADS_AUTO_ARCHIVED = "desktop.threads_auto_archived",
3235
+ DESKTOP_DELIVERY_CONFLICT_CHANGED = "desktop.delivery_conflict_changed",
3236
+ FLUSH_FAILED = "common.flush_failed",
3237
+ CLI_LOG = "cli.log"
3238
+ }
3239
+ type TrackEventFn = (params: {
3240
+ event: AnalyticsEvent;
3241
+ userId: string;
3242
+ properties?: Record<string, any>;
3243
+ logger: Logger$1;
3244
+ }) => void;
3245
+ declare const models: {
3246
+ readonly ft_filepicker_003: "196166068534771712";
3247
+ readonly ft_filepicker_005: "8493203957034778624";
3248
+ readonly ft_filepicker_007: "2589952415784501248";
3249
+ readonly ft_filepicker_topk_001: "3676445825887633408";
3250
+ readonly ft_filepicker_008: "2672143108984012800";
3251
+ readonly ft_filepicker_topk_002: "1694861989844615168";
3252
+ readonly ft_filepicker_010: "3808739064941641728";
3253
+ readonly ft_filepicker_010_epoch_2: "6231675664466968576";
3254
+ readonly ft_filepicker_topk_003: "1502192368286171136";
3255
+ readonly openrouter_claude_sonnet_4_5: "anthropic/claude-sonnet-4.5";
3256
+ readonly openrouter_claude_sonnet_4: "anthropic/claude-4-sonnet-20250522";
3257
+ readonly openrouter_claude_opus_4: "anthropic/claude-opus-4.1";
3258
+ readonly openrouter_claude_3_5_haiku: "anthropic/claude-3.5-haiku-20241022";
3259
+ readonly openrouter_claude_3_5_sonnet: "anthropic/claude-3.5-sonnet-20240620";
3260
+ readonly openrouter_gpt4o: "openai/gpt-4o-2024-11-20";
3261
+ readonly openrouter_gpt5: "openai/gpt-5.1";
3262
+ readonly openrouter_gpt5_chat: "openai/gpt-5.1-chat";
3263
+ readonly openrouter_gpt4o_mini: "openai/gpt-4o-mini-2024-07-18";
3264
+ readonly openrouter_gpt4_1_nano: "openai/gpt-4.1-nano";
3265
+ readonly openrouter_o3_mini: "openai/o3-mini-2025-01-31";
3266
+ readonly openrouter_gemini2_5_pro_preview: "google/gemini-2.5-pro";
3267
+ readonly openrouter_gemini2_5_flash: "google/gemini-2.5-flash";
3268
+ readonly openrouter_gemini2_5_flash_thinking: "google/gemini-2.5-flash-preview:thinking";
3269
+ readonly openrouter_grok_4: "x-ai/grok-4-07-09";
3270
+ readonly minimaxM3: "minimax/minimax-m3";
3271
+ readonly mimoV25Direct: "mimo-v2.5";
3272
+ readonly mimoV25: "mimo/mimo-v2.5";
3273
+ readonly mimoV25ProDirect: "mimo-v2.5-pro";
3274
+ readonly mimoV25Pro: "mimo/mimo-v2.5-pro";
3275
+ readonly deepseekChat: "deepseek-chat";
3276
+ readonly deepseekReasoner: "deepseek-reasoner";
3277
+ readonly deepseekV4ProDirect: "deepseek-v4-pro";
3278
+ readonly deepseekV4Pro: "deepseek/deepseek-v4-pro";
3279
+ readonly deepseekV4FlashDirect: "deepseek-v4-flash";
3280
+ readonly deepseekV4Flash: "deepseek/deepseek-v4-flash";
3281
+ readonly gpt4_1: "gpt-4.1-2025-04-14";
3282
+ readonly gpt4o: "gpt-4o-2024-11-20";
3283
+ readonly gpt4omini: "gpt-4o-mini-2024-07-18";
3284
+ readonly o3mini: "o3-mini-2025-01-31";
3285
+ readonly o3: "o3-2025-04-16";
3286
+ readonly o3pro: "o3-pro-2025-06-10";
3287
+ readonly o4mini: "o4-mini-2025-04-16";
3288
+ readonly generatePatch: "ft:gpt-4o-2024-08-06:manifold-markets:generate-patch-batch2:AKYtDIhk";
3289
+ };
3290
+ type Model = (typeof models)[keyof typeof models] | (string & {});
3291
+ type OpenRouterReasoningOptions = {
3292
+ /**
3293
+ * https://openrouter.ai/docs/use-cases/reasoning-tokens
3294
+ * One of `max_tokens` or `effort` is required.
3295
+ * If `exclude` is true, reasoning will be removed from the response. Default is false.
3296
+ */
3297
+ enabled?: boolean;
3298
+ exclude?: boolean;
3299
+ } & ({
3300
+ max_tokens: number;
3301
+ } | {
3302
+ effort: "high" | "medium" | "low" | "minimal" | "none";
3303
+ });
3304
+ type OpenRouterProviderRoutingOptions = {
3305
+ /**
3306
+ * List of provider slugs to try in order (e.g. ["anthropic", "openai"])
3307
+ */
3308
+ order?: string[];
3309
+ /**
3310
+ * Whether to allow backup providers when primary is unavailable (default: true)
3311
+ */
3312
+ allow_fallbacks?: boolean;
3313
+ /**
3314
+ * Only use providers that support all parameters in your request (default: false)
3315
+ */
3316
+ require_parameters?: boolean;
3317
+ /**
3318
+ * Control whether to use providers that may store data
3319
+ */
3320
+ data_collection?: "allow" | "deny";
3321
+ /**
3322
+ * List of provider slugs to allow for this request
3323
+ */
3324
+ only?: string[];
3325
+ /**
3326
+ * List of provider slugs to skip for this request
3327
+ */
3328
+ ignore?: string[];
3329
+ /**
3330
+ * List of quantization levels to filter by (e.g. ["int4", "int8"])
3331
+ */
3332
+ quantizations?: Array<"int4" | "int8" | "fp4" | "fp6" | "fp8" | "fp16" | "bf16" | "fp32" | "unknown">;
3333
+ /**
3334
+ * Sort providers by price, throughput, or latency
3335
+ */
3336
+ sort?: "price" | "throughput" | "latency";
3337
+ /**
3338
+ * Maximum pricing you want to pay for this request
3339
+ */
3340
+ max_price?: {
3341
+ prompt?: number | string;
3342
+ completion?: number | string;
3343
+ image?: number | string;
3344
+ audio?: number | string;
3345
+ request?: number | string;
3346
+ };
3347
+ };
3348
+ type AgentTemplate<P = string | undefined, T = Record<string, any> | undefined> = {
3349
+ id: AgentTemplateType;
3350
+ displayName: string;
3351
+ model: Model;
3352
+ reasoningOptions?: OpenRouterReasoningOptions;
3353
+ providerOptions?: OpenRouterProviderRoutingOptions;
3354
+ mcpServers: Record<string, MCPConfig$1>;
3355
+ toolNames: (ToolName | (string & {}))[];
3356
+ spawnableAgents: AgentTemplateType[];
3357
+ spawnerPrompt?: string;
3358
+ systemPrompt: string;
3359
+ instructionsPrompt: string;
3360
+ stepPrompt: string;
3361
+ parentInstructions?: Record<string, string>;
3362
+ inputSchema: {
3363
+ prompt?: z.ZodSchema<P>;
3364
+ params?: z.ZodSchema<T>;
3365
+ };
3366
+ includeMessageHistory: boolean;
3367
+ inheritParentSystemPrompt: boolean;
3368
+ windowedFileReads?: boolean;
3369
+ compactContext?: boolean | {
3370
+ cacheExpiryMs?: number | null;
3371
+ cacheExpiryMinTokens?: number | null;
3372
+ };
3373
+ outputMode: "last_message" | "all_messages" | "structured_output";
3374
+ outputSchema?: z.ZodSchema<any>;
3375
+ handleSteps?: StepHandler<P, T> | string;
3376
+ /**
3377
+ * Live copy of handleSteps kept alongside the serialized string. The string
3378
+ * form of a bundled function can reference out-of-scope bundler helpers
3379
+ * (esbuild keepNames injects `__name(...)`, minified to a bare identifier),
3380
+ * which breaks the eval path. When the runtime is in-process, prefer this
3381
+ * function. Dropped automatically by JSON serialization (resume blobs, DB).
3382
+ */
3383
+ handleStepsFn?: StepHandler<P, T>;
3384
+ };
3385
+ type StepText$1 = {
3386
+ type: "STEP_TEXT";
3387
+ text: string;
3388
+ };
3389
+ type GenerateN$1 = {
3390
+ type: "GENERATE_N";
3391
+ n: number;
3392
+ };
3393
+ type StepGenerator = Generator<Omit<ToolCall, "toolCallId"> | "STEP" | "STEP_ALL" | StepText$1 | GenerateN$1, // Generic tool call type
3394
+ void, {
3395
+ agentState: AgentState;
3396
+ toolResult: ToolResultOutput[];
3397
+ stepsComplete: boolean;
3398
+ nResponses?: string[];
3399
+ }>;
3400
+ type StepHandler<P = string | undefined, T = Record<string, any> | undefined> = (context: {
3401
+ agentState: AgentState$1;
3402
+ prompt: P;
3403
+ params: T;
3404
+ /**
3405
+ * The model this agent step is running on, after any per-request override of
3406
+ * the template's `model`. Needed because `handleSteps` is serialized with
3407
+ * `toString()` (no closures survive), so a caller that swaps the model at
3408
+ * request time has no other way to tell the generator which model it got.
3409
+ *
3410
+ * Supplied by the runtime; optional so generators invoked directly in tests
3411
+ * keep compiling. Treat `undefined` as "unknown model".
3412
+ */
3413
+ model?: string;
3414
+ logger: Logger;
3415
+ }) => StepGenerator;
3416
+ type Prettify<T> = {
3417
+ [K in keyof T]: T[K];
3418
+ } & {};
3419
+ type StripExact<T> = T extends infer U & {
3420
+ [x: string]: never;
3421
+ } ? U : T;
3422
+ type ParamsOfFunction<T> = T extends (params: infer C) => any ? StripExact<C> : never;
3423
+ type IsUnion<T, U = T> = T extends any ? ([
3424
+ U
3425
+ ] extends [
3426
+ T
3427
+ ] ? false : true) : false;
3428
+ type ParamsOfArray<T> = UnionToIntersection<T extends [
3429
+ infer fn,
3430
+ ...infer rest
3431
+ ] ? ParamsOfFunction<fn> | ParamsOfArray<rest> : {}>;
3432
+ type ParamsOfUnion<T> = IsUnion<T> extends true ? UnionToIntersection<ParamsOfFunction<T>> : ParamsOfFunction<T>;
3433
+ type ParamsOf<T> = Prettify<T extends any[] ? ParamsOfArray<T> : ParamsOfUnion<T>>;
3434
+ type ParamsExcluding<T, K extends keyof ParamsOf<T>> = Prettify<Omit<ParamsOf<T>, K>>;
3435
+ type PromptResult<T> = PromptSuccess<T> | PromptAborted;
3436
+ type PromptSuccess<T> = {
3437
+ aborted: false;
3438
+ value: T;
3439
+ };
3440
+ type PromptAborted = {
3441
+ aborted: true;
3442
+ reason?: string;
3443
+ };
3444
+ type StreamRecoverySource = "stream-interrupted" | "output-limit";
3445
+ type StreamChunk = {
3446
+ type: "text";
3447
+ text: string;
3448
+ agentId?: string;
3449
+ } | {
3450
+ type: "reasoning";
3451
+ text: string;
3452
+ /** Provider metadata for the whole reasoning segment (e.g. OpenRouter
3453
+ * reasoning_details with thinking signatures), delivered on a final
3454
+ * empty-text chunk once the segment ends. Stored on the history's
3455
+ * reasoning part so the next request can replay it. */
3456
+ providerOptions?: ProviderMetadata;
3457
+ } | Pick<ToolCallPart, "type" | "toolCallId" | "toolName" | "input" | "providerOptions"> | {
3458
+ type: "error";
3459
+ message: string;
3460
+ /** When set, this is an auto-recovered stream ending rather than a
3461
+ * failure: consumers force another agent step so the model can
3462
+ * continue, instead of wrapping the message as a tool-call failure and
3463
+ * instead of the turn silently ending. */
3464
+ source?: StreamRecoverySource;
3465
+ };
3466
+ type CacheDebugUsageData = {
3467
+ inputTokens: number;
3468
+ outputTokens: number;
3469
+ reasoningOutputTokens?: number;
3470
+ cachedInputTokens: number;
3471
+ totalTokens: number;
3472
+ };
3473
+ type ModelUsageData = CacheDebugUsageData;
3474
+ type AgentUsageData = ModelUsageData & {
3475
+ isRoot: boolean;
3476
+ agentId?: string;
3477
+ };
3478
+ type ContextCompactionData = {
3479
+ trigger: "context_limit" | "cache_expiry" | "context_limit_and_cache_expiry";
3480
+ thresholdTokens: number;
3481
+ };
3482
+ type PromptAiSdkStreamFn = (params: {
3483
+ apiKey: string;
3484
+ runId: string;
3485
+ messages: Message[];
3486
+ clientSessionId: string;
3487
+ fingerprintId: string;
3488
+ model: Model;
3489
+ userId: string | undefined;
3490
+ chargeUser?: boolean;
3491
+ thinkingBudget?: number;
3492
+ userInputId: string;
3493
+ agentId?: string;
3494
+ maxRetries?: number;
3495
+ onCostCalculated?: (credits: number) => Promise<void>;
3496
+ onCacheDebugProviderRequestBuilt?: (params: {
3497
+ provider: string;
3498
+ rawBody: unknown;
3499
+ normalizedBody?: unknown;
3500
+ }) => void;
3501
+ onCacheDebugUsageReceived?: (usage: CacheDebugUsageData) => void;
3502
+ onUsageReceived?: (usage: ModelUsageData) => void;
3503
+ /** The request ended without an exact final provider usage receipt. */
3504
+ onUsageIncomplete?: () => void;
3505
+ includeCacheControl?: boolean;
3506
+ cacheDebugCorrelation?: string;
3507
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
3508
+ /** List of agents that can be spawned - used to transform agent tool calls */
3509
+ spawnableAgents?: string[];
3510
+ /** Map of locally available agent templates - used to transform agent tool calls */
3511
+ localAgentTemplates?: Record<string, AgentTemplate>;
3512
+ /** Cost mode - 'free' mode means 0 credits charged for all agents */
3513
+ costMode?: string;
3514
+ /** Extra key/values merged into the request's `anvil_metadata` field.
3515
+ * Used to forward client-scoped identifiers (e.g. `anvil_instance_id`)
3516
+ * that server-side gates read from the chat-completions body. */
3517
+ extraAnvilMetadata?: Record<string, string>;
3518
+ sendAction: SendActionFn;
3519
+ logger: Logger$1;
3520
+ trackEvent: TrackEventFn;
3521
+ signal: AbortSignal;
3522
+ } & ParamsExcluding<typeof streamText, "model" | "messages">) => AsyncGenerator<StreamChunk, PromptResult<string | null>>;
3523
+ type PromptAiSdkFn = (params: {
3524
+ apiKey: string;
3525
+ runId: string;
3526
+ messages: Message[];
3527
+ clientSessionId: string;
3528
+ fingerprintId: string;
3529
+ userInputId: string;
3530
+ model: Model;
3531
+ userId: string | undefined;
3532
+ chargeUser?: boolean;
3533
+ agentId?: string;
3534
+ onCostCalculated?: (credits: number) => Promise<void>;
3535
+ onCacheDebugProviderRequestBuilt?: (params: {
3536
+ provider: string;
3537
+ rawBody: unknown;
3538
+ normalizedBody?: unknown;
3539
+ }) => void;
3540
+ onCacheDebugUsageReceived?: (usage: CacheDebugUsageData) => void;
3541
+ includeCacheControl?: boolean;
3542
+ cacheDebugCorrelation?: string;
3543
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
3544
+ maxRetries?: number;
3545
+ /** Cost mode - 'free' mode means 0 credits charged for all agents */
3546
+ costMode?: string;
3547
+ sendAction: SendActionFn;
3548
+ logger: Logger$1;
3549
+ trackEvent: TrackEventFn;
3550
+ n?: number;
3551
+ signal: AbortSignal;
3552
+ } & ParamsExcluding<typeof generateText, "model" | "messages">) => Promise<PromptResult<string>>;
3553
+ type PromptAiSdkStructuredInput<T> = {
3554
+ apiKey: string;
3555
+ runId: string;
3556
+ messages: Message[];
3557
+ schema: z.ZodType<T>;
3558
+ clientSessionId: string;
3559
+ fingerprintId: string;
3560
+ userInputId: string;
3561
+ model: Model;
3562
+ userId: string | undefined;
3563
+ maxTokens?: number;
3564
+ temperature?: number;
3565
+ timeout?: number;
3566
+ chargeUser?: boolean;
3567
+ agentId?: string;
3568
+ onCostCalculated?: (credits: number) => Promise<void>;
3569
+ onCacheDebugProviderRequestBuilt?: (params: {
3570
+ provider: string;
3571
+ rawBody: unknown;
3572
+ normalizedBody?: unknown;
3573
+ }) => void;
3574
+ onCacheDebugUsageReceived?: (usage: CacheDebugUsageData) => void;
3575
+ includeCacheControl?: boolean;
3576
+ cacheDebugCorrelation?: string;
3577
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
3578
+ maxRetries?: number;
3579
+ sendAction: SendActionFn;
3580
+ logger: Logger$1;
3581
+ trackEvent: TrackEventFn;
3582
+ signal: AbortSignal;
3583
+ };
3584
+ type PromptAiSdkStructuredOutput<T> = Promise<PromptResult<T>>;
3585
+ /**
3586
+ * Records agent message histories for debugging (e.g. to a trace.jsonl file).
3587
+ *
3588
+ * Callers pass the agent's full message history at each step boundary;
3589
+ * implementations are expected to persist each message only once (appending
3590
+ * the delta since the previous call for the same agentId), so calling this
3591
+ * every step does not grow storage quadratically.
3592
+ */
3593
+ export type TraceWriter = {
3594
+ recordStep: (params: {
3595
+ agentId: string;
3596
+ agentType: string;
3597
+ runId: string | undefined;
3598
+ userInputId: string;
3599
+ step: number;
3600
+ system: string | undefined;
3601
+ messages: Message[];
3602
+ }) => void;
3603
+ };
3604
+ type Source<T> = T | Promise<T> | (T extends (...args: unknown[]) => unknown ? never : () => T | Promise<T>);
3605
+ type OverrideToolHandlers = {
3606
+ [K in PublishedClientToolName]?: (input: any) => Promise<ToolResultOutput[]>;
3607
+ } & {
3608
+ read_files?: (input: {
3609
+ filePaths: string[];
3610
+ /** Present only for `windowedFileReads` agents. An override that ignores
3611
+ * it returns whole files, which is a cost regression rather than a
3612
+ * correctness bug — but it is the whole point of the flag, so overrides
3613
+ * on hosted surfaces window the content themselves (they hold the file
3614
+ * before their own read budget truncates it). */
3615
+ fileWindows?: Record<string, FileReadWindow[]>;
3616
+ }) => Promise<Record<string, string | null>>;
3617
+ };
3618
+ export type AnvilClientOptions = {
3619
+ apiKey?: string;
3620
+ cwd?: string;
3621
+ /** Optional directory path to load skills from. Skills found here will be available to the `skill` tool. */
3622
+ skillsDir?: string;
3623
+ projectFiles?: Record<string, string>;
3624
+ /** Precomputed index for exactly these `projectFiles` (build it with
3625
+ * `computeProjectIndexFromFiles`). Skips the per-run tree-sitter parse;
3626
+ * ignored when `projectFiles` is absent. */
3627
+ projectIndex?: ComputedProjectIndex;
3628
+ knowledgeFiles?: Record<string, string>;
3629
+ agentDefinitions?: AgentDefinition[];
3630
+ maxAgentSteps?: number;
3631
+ env?: Record<string, string>;
3632
+ /** Optional host process boundary that keeps terminal tools away from an
3633
+ * interactive console. Headless consumers can omit it. */
3634
+ terminalCommandBroker?: TerminalCommandBroker;
3635
+ handleEvent?: (event: PrintModeEvent) => void | Promise<void>;
3636
+ handleStreamChunk?: (chunk: string | {
3637
+ type: "subagent_chunk";
3638
+ agentId: string;
3639
+ agentType: string;
3640
+ chunk: string;
3641
+ } | {
3642
+ type: "reasoning_chunk";
3643
+ agentId: string;
3644
+ ancestorRunIds: string[];
3645
+ chunk: string;
3646
+ }) => void | Promise<void>;
3647
+ /** Optional filter to classify files before reading (runs before gitignore check) */
3648
+ fileFilter?: FileFilter;
3649
+ overrideTools?: OverrideToolHandlers;
3650
+ customToolDefinitions?: CustomToolDefinition[];
3651
+ fsSource?: Source<AnvilFileSystem>;
3652
+ spawnSource?: Source<AnvilSpawn>;
3653
+ logger?: Logger$1;
3654
+ /** Optional debug trace of agent message histories. Called with the full
3655
+ * history at each agent step boundary; implementations should append each
3656
+ * message once (see TraceWriter). */
3657
+ traceWriter?: TraceWriter;
3658
+ };
3659
+ export type ImageContent = {
3660
+ type: "image";
3661
+ image: string;
3662
+ mediaType: string;
3663
+ };
3664
+ export type TextContent = {
3665
+ type: "text";
3666
+ text: string;
3667
+ };
3668
+ export type MessageContent = TextContent | ImageContent;
3669
+ export type RunOptions = {
3670
+ agent: string | AgentDefinition;
3671
+ prompt: string;
3672
+ /** End user represented by this run. Trusted service accounts may use this
3673
+ * to run on behalf of a signed-in user; ordinary API keys cannot delegate. */
3674
+ userId?: string;
3675
+ /** Content array for multimodal messages (text + images) */
3676
+ content?: MessageContent[];
3677
+ params?: Record<string, any>;
3678
+ previousRun?: RunState;
3679
+ extraToolResults?: ToolMessage[];
3680
+ signal?: AbortSignal;
3681
+ /** Optional steering hook. Drained at each agent step boundary during the run;
3682
+ * any returned texts are appended to the conversation as user prompts (and keep
3683
+ * the turn going) before the next LLM call. Lets a host inject messages into a
3684
+ * running agent without aborting — i.e. "steer" it, as opposed to queuing a new
3685
+ * prompt for after the turn finishes. */
3686
+ drainSteeringMessages?: () => string[];
3687
+ costMode?: string;
3688
+ /** Extra key/values merged into each LLM request's `anvil_metadata`.
3689
+ * Used by hosts (e.g. the CLI) to forward client-scoped identifiers like
3690
+ * `anvil_instance_id` that server-side gates read from the request body. */
3691
+ extraAnvilMetadata?: Record<string, string>;
3692
+ /** Optional checkpoint hook. Called once when the run starts and then
3693
+ * periodically while it is in flight, with a RunState snapshot that
3694
+ * preserves all progress so far (the user's prompt plus any completed
3695
+ * agent steps, ending with an interruption note). Hosts can persist these
3696
+ * snapshots so that a killed process (closed terminal, crash) does not
3697
+ * lose the in-flight turn. The final resolved RunState supersedes any
3698
+ * snapshot; no snapshots are emitted after the run settles. */
3699
+ onStateSnapshot?: (runState: RunState) => void;
3700
+ /** Provider-reported usage for each root-agent model request. */
3701
+ onUsage?: (usage: AgentUsageData) => void;
3702
+ /** A model request ended before an exact provider usage receipt arrived. */
3703
+ onUsageIncomplete?: () => void;
3704
+ /** Mechanical context compaction performed by the root agent runtime. */
3705
+ onCompaction?: (data: ContextCompactionData) => void;
3706
+ };
3707
+ export declare const STATE_SNAPSHOT_INTERRUPTION_MESSAGE = "The session ended before this response completed. Partial progress has been preserved.";
3708
+ type RunExecutionOptions = RunOptions & AnvilClientOptions & {
3709
+ apiKey: string;
3710
+ fingerprintId: string;
3711
+ };
3712
+ export declare function run(options: RunExecutionOptions): Promise<RunState>;
3713
+ /**
3714
+ * Combines prompt, params, and content into a unified message content structure.
3715
+ */
3716
+ export declare function buildUserMessageContent(prompt: string | undefined, params: Record<string, any> | undefined, content?: Array<TextPart | ImagePart>): Array<TextPart | ImagePart>;
3717
+ export declare class AnvilClient {
3718
+ options: AnvilClientOptions & {
3719
+ apiKey: string;
3720
+ fingerprintId: string;
3721
+ };
3722
+ constructor(options: AnvilClientOptions);
3723
+ /**
3724
+ * Run a Anvil agent with the specified options.
3725
+ *
3726
+ * @param agent - The agent to run. Use 'base' for the default agent, or specify a custom agent ID if you made your own agent config.
3727
+ * @param prompt - The user prompt describing what you want the agent to do.
3728
+ * @param params - (Optional) Additional parameters for the agent. Most agents don't use this, but some custom agents can take a JSON object as input in addition to the user prompt string.
3729
+ * @param handleEvent - (Optional) Callback function that receives every event during execution (assistant messages, tool calls, etc.). This allows you to stream the agent's progress in real-time. We will likely add a token-by-token streaming callback in the future.
3730
+ * @param previousRun - (Optional) JSON state returned from a previous run() call. Use this to continue a conversation or session with the agent, maintaining context from previous interactions.
3731
+ * @param projectFiles - (Optional) All the files in your project as a plain JavaScript object. Keys should be the full path from your current directory to each file, and values should be the string contents of the file. Example: { "src/index.ts": "console.log('hi')" }. This helps Anvil pick good source files for context.
3732
+ * @param knowledgeFiles - (Optional) Knowledge files to inject into every run() call. Uses the same schema as projectFiles - keys are file paths and values are file contents. These files are added directly to the agent's context.
3733
+ * @param agentDefinitions - (Optional) Array of custom agent definitions. Each object should satisfy the AgentDefinition type. You can input the agent's id field into the agent parameter to run that agent.
3734
+ * @param customToolDefinitions - (Optional) Array of custom tool definitions that extend the agent's capabilities. Each tool definition includes a name, Zod schema for input validation, and a handler function. These tools can be called by the agent during execution.
3735
+ * @param skillsDir - (Optional) Path to a directory containing skills to load. Each skill should be in its own subdirectory with a SKILL.md file (e.g., `skillsDir/my-skill/SKILL.md`). When provided, skills are loaded from this directory instead of the default locations. The loaded skills will be listed in the `skill` tool's description and can be loaded by the agent.
3736
+ * @param maxAgentSteps - (Optional) Maximum number of steps the agent can take before stopping. Use this as a safety measure in case your agent starts going off the rails. A reasonable number is around 20.
3737
+ * @param env - (Optional) Environment variables to pass to terminal commands executed by the agent. These will be merged with the current process environment, with the custom values taking precedence. Can also be provided in individual run() calls to override.
3738
+ *
3739
+ * @returns A Promise that resolves to a RunState JSON object which you can pass to a subsequent run() call to continue the run. Use result.output to get the agent's output.
3740
+ */
3741
+ run(options: RunOptions & AnvilClientOptions): Promise<RunState>;
3742
+ /**
3743
+ * Check connection to the Anvil backend by hitting the /healthz endpoint.
3744
+ *
3745
+ * @returns Promise that resolves to true if connected, false otherwise
3746
+ */
3747
+ checkConnection(): Promise<boolean>;
3748
+ }
3749
+ declare const clientEnvSchema: z.ZodObject<{
3750
+ NEXT_PUBLIC_CB_ENVIRONMENT: z.ZodEnum<{
3751
+ dev: "dev";
3752
+ test: "test";
3753
+ prod: "prod";
3754
+ }>;
3755
+ NEXT_PUBLIC_ANVIL_APP_URL: z.ZodURL;
3756
+ NEXT_PUBLIC_SUPPORT_EMAIL: z.ZodEmail;
3757
+ NEXT_PUBLIC_POSTHOG_API_KEY: z.ZodString;
3758
+ NEXT_PUBLIC_POSTHOG_HOST_URL: z.ZodURL;
3759
+ NEXT_PUBLIC_GRAVITY_PIXEL_ID: z.ZodOptional<z.ZodUUID>;
3760
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.ZodString;
3761
+ NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL: z.ZodURL;
3762
+ NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION_ID: z.ZodOptional<z.ZodString>;
3763
+ NEXT_PUBLIC_WEB_PORT: z.ZodCoercedNumber<unknown>;
3764
+ NEXT_PUBLIC_TURNSTILE_SITE_KEY: z.ZodOptional<z.ZodString>;
3765
+ NEXT_PUBLIC_RECAPTCHA_V2_SITE_KEY: z.ZodOptional<z.ZodString>;
3766
+ NEXT_PUBLIC_RECAPTCHA_V3_SITE_KEY: z.ZodOptional<z.ZodString>;
3767
+ NEXT_PUBLIC_RECAPTCHA_V2_SIZE: z.ZodOptional<z.ZodEnum<{
3768
+ checkbox: "checkbox";
3769
+ invisible: "invisible";
3770
+ }>>;
3771
+ NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY: z.ZodOptional<z.ZodString>;
3772
+ NEXT_PUBLIC_HUMANBEHAVIOR_INGESTION_URL: z.ZodOptional<z.ZodURL>;
3773
+ }, z.core.$strip>;
3774
+ type ClientEnv = z.infer<typeof clientEnvSchema>;
3775
+ type BaseEnv = {
3776
+ SHELL?: string;
3777
+ COMSPEC?: string;
3778
+ HOME?: string;
3779
+ USERPROFILE?: string;
3780
+ APPDATA?: string;
3781
+ XDG_CONFIG_HOME?: string;
3782
+ TERM?: string;
3783
+ TERM_PROGRAM?: string;
3784
+ TERM_BACKGROUND?: string;
3785
+ TERMINAL_EMULATOR?: string;
3786
+ COLORFGBG?: string;
3787
+ NODE_ENV?: string;
3788
+ NODE_PATH?: string;
3789
+ PATH?: string;
3790
+ };
3791
+ type SdkEnv = BaseEnv & {
3792
+ ANVIL_RG_PATH?: string;
3793
+ ANVIL_WASM_DIR?: string;
3794
+ VERBOSE?: string;
3795
+ OVERRIDE_TARGET?: string;
3796
+ OVERRIDE_PLATFORM?: string;
3797
+ OVERRIDE_ARCH?: string;
3798
+ };
3799
+ /**
3800
+ * Get the path to the bundled ripgrep binary based on the current platform
3801
+ * @param importMetaUrl - import.meta.url from the calling module
3802
+ * @returns Path to the ripgrep binary
3803
+ */
3804
+ export declare function getBundledRgPath(importMetaUrl?: string, env?: SdkEnv): string;
3805
+ declare function changeFile(params: {
3806
+ parameters: unknown;
3807
+ cwd: string;
3808
+ fs: AnvilFileSystem;
3809
+ }): Promise<AnvilToolOutput<"str_replace">>;
3810
+ declare function codeSearch({ projectPath, pattern, flags, cwd, maxResults, globalMaxResults, maxOutputStringLength, timeoutSeconds, logger, signal, }: {
3811
+ projectPath: string;
3812
+ pattern: string;
3813
+ flags?: string;
3814
+ cwd?: string;
3815
+ maxResults?: number;
3816
+ globalMaxResults?: number;
3817
+ maxOutputStringLength?: number;
3818
+ timeoutSeconds?: number;
3819
+ logger?: Logger$1;
3820
+ /** External abort (e.g. user interrupt); kills the ripgrep process. */
3821
+ signal?: AbortSignal;
3822
+ }): Promise<AnvilToolOutput<"code_search">>;
3823
+ declare function glob(params: {
3824
+ pattern: string;
3825
+ projectPath: string;
3826
+ cwd?: string;
3827
+ maxResults?: number;
3828
+ fs: AnvilFileSystem;
3829
+ }): Promise<AnvilToolOutput<"glob">>;
3830
+ declare function listDirectory(params: {
3831
+ directoryPath: string;
3832
+ projectPath: string;
3833
+ fs: AnvilFileSystem;
3834
+ }): Promise<AnvilToolOutput<"list_directory">>;
3835
+ declare function runFileChangeHooks({ files, }: {
3836
+ files: string[];
3837
+ }): Promise<AnvilToolOutput<"run_file_change_hooks">>;
3838
+ export declare const ToolHelpers: {
3839
+ runTerminalCommand: typeof runTerminalCommand;
3840
+ codeSearch: typeof codeSearch;
3841
+ glob: typeof glob;
3842
+ listDirectory: typeof listDirectory;
3843
+ getFiles: typeof getFiles;
3844
+ runFileChangeHooks: typeof runFileChangeHooks;
3845
+ changeFile: typeof changeFile;
3846
+ };
3847
+ export declare const IS_DEV: boolean;
3848
+ export declare const IS_TEST: boolean;
3849
+ export declare const IS_PROD: boolean;
3850
+ export declare const ANVIL_BINARY = "anvil";
3851
+ /**
3852
+ * Resolve the Anvil backend base URL at call time. Remote hosts that bundle
3853
+ * the SDK (Convex Node actions, Next server routes) must not rely on the
3854
+ * bundle-time value: esbuild can inline a dev-machine localhost URL that the
3855
+ * remote runtime cannot reach. Deployment env wins when present.
3856
+ */
3857
+ export declare function getWebsiteUrl(): string;
3858
+ /** @deprecated Prefer {@link getWebsiteUrl} for runtime resolution. */
3859
+ export declare const WEBSITE_URL: string;
3860
+ type User = {
3861
+ id: string;
3862
+ email: string;
3863
+ discord_id: string | null;
3864
+ stripe_customer_id: string | null;
3865
+ banned: boolean;
3866
+ created_at: Date;
3867
+ };
3868
+ type UserColumn = keyof User;
3869
+ type GetUserInfoFromApiKeyInput<T extends UserColumn> = {
3870
+ apiKey: string;
3871
+ fields: readonly T[];
3872
+ logger: Logger$1;
3873
+ };
3874
+ type GetUserInfoFromApiKeyOutput<T extends UserColumn> = Promise<{
3875
+ [K in T]: User[K];
3876
+ } | null>;
3877
+ export declare function getUserInfoFromApiKey<T extends UserColumn>(params: GetUserInfoFromApiKeyInput<T>): GetUserInfoFromApiKeyOutput<T>;
3878
+ declare const userSchema: z.ZodObject<{
3879
+ id: z.ZodString;
3880
+ email: z.ZodString;
3881
+ name: z.ZodNullable<z.ZodString>;
3882
+ authToken: z.ZodString;
3883
+ fingerprintId: z.ZodString;
3884
+ fingerprintHash: z.ZodString;
3885
+ }, z.core.$strip>;
3886
+ type User$1 = z.infer<typeof userSchema>;
3887
+ export declare const userFromJson: (json: string) => User$1 | null;
3888
+ /**
3889
+ * Get the config directory path based on the environment.
3890
+ * Uses the clientEnv to determine the environment suffix.
3891
+ */
3892
+ export declare const getConfigDir: (clientEnv?: ClientEnv) => string;
3893
+ /**
3894
+ * Get the credentials file path based on the environment.
3895
+ */
3896
+ export declare const getCredentialsPath: (clientEnv?: ClientEnv) => string;
3897
+ export declare const getUserCredentials: (clientEnv?: ClientEnv) => User$1 | null;
3898
+ /**
3899
+ * Agent definition with source file path metadata.
3900
+ */
3901
+ export type LoadedAgentDefinition = AgentDefinition & {
3902
+ /** The file path this agent was loaded from */
3903
+ _sourceFilePath: string;
3904
+ /** Live copy of handleSteps kept alongside its stringified form (see
3905
+ * processedAgentDefinition below). */
3906
+ handleStepsFn?: AgentDefinition["handleSteps"];
3907
+ };
3908
+ /**
3909
+ * Loaded agent definitions keyed by agent ID.
3910
+ */
3911
+ export type LoadedAgents = Record<string, LoadedAgentDefinition>;
3912
+ /**
3913
+ * Validation error for an agent that failed validation.
3914
+ */
3915
+ export type AgentValidationError = {
3916
+ /** The agent's ID */
3917
+ agentId: string;
3918
+ /** The source file path where the agent was loaded from */
3919
+ filePath: string;
3920
+ /** The validation error message */
3921
+ message: string;
3922
+ };
3923
+ /**
3924
+ * Result returned by loadLocalAgents when validate: true.
3925
+ * Contains both the valid agents and any validation errors.
3926
+ */
3927
+ export type LoadLocalAgentsResult = {
3928
+ /** Valid agent definitions that passed validation */
3929
+ agents: LoadedAgents;
3930
+ /** Validation errors for agents that failed validation */
3931
+ validationErrors: AgentValidationError[];
3932
+ };
3933
+ /**
3934
+ * Load agent definitions from `.agents` directories.
3935
+ *
3936
+ * By default, searches for agents in:
3937
+ * - `{cwd}/.agents`
3938
+ * - `{cwd}/../.agents`
3939
+ * - `{homedir}/.agents`
3940
+ *
3941
+ * Agent files can be `.ts`, `.tsx`, `.js`, `.mjs`, or `.cjs`.
3942
+ * TypeScript files are loaded natively by Bun's runtime.
3943
+ *
3944
+ * @param options.agentsPath - Optional path to a specific agents directory
3945
+ * @param options.verbose - Whether to log errors during loading
3946
+ * @param options.validate - Whether to validate agents after loading
3947
+ * @returns When validate is false/omitted: Record of agent definitions keyed by agent ID.
3948
+ * When validate is true: Object with valid agents and validation errors.
3949
+ *
3950
+ * @example
3951
+ * ```typescript
3952
+ * // Load from default locations
3953
+ * const agents = await loadLocalAgents({ verbose: true })
3954
+ *
3955
+ * // Load from a specific directory
3956
+ * const agents = await loadLocalAgents({ agentsPath: './my-agents' })
3957
+ *
3958
+ * // Load and validate agents - returns both valid agents and errors
3959
+ * const { agents, validationErrors } = await loadLocalAgents({ validate: true })
3960
+ * if (validationErrors.length > 0) {
3961
+ * console.error('Some agents failed validation:', validationErrors)
3962
+ * }
3963
+ *
3964
+ * // Access source file path for debugging
3965
+ * for (const agent of Object.values(agents)) {
3966
+ * console.log(`${agent.id} loaded from ${agent._sourceFilePath}`)
3967
+ * }
3968
+ *
3969
+ * // Use with client.run()
3970
+ * const result = await client.run({
3971
+ * agent: 'my-agent',
3972
+ * agentDefinitions: Object.values(agents),
3973
+ * prompt: 'Hello',
3974
+ * })
3975
+ * ```
3976
+ */
3977
+ export declare function loadLocalAgents(options: {
3978
+ agentsPath?: string;
3979
+ verbose?: boolean;
3980
+ validate: true;
3981
+ }): Promise<LoadLocalAgentsResult>;
3982
+ export declare function loadLocalAgents(options: {
3983
+ agentsPath?: string;
3984
+ verbose?: boolean;
3985
+ validate?: false;
3986
+ }): Promise<LoadedAgents>;
3987
+ declare const mcpFileSchema: z.ZodObject<{
3988
+ mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [
3989
+ z.ZodObject<{
3990
+ type: z.ZodDefault<z.ZodEnum<{
3991
+ http: "http";
3992
+ sse: "sse";
3993
+ }>>;
3994
+ url: z.ZodString;
3995
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
3996
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
3997
+ }, z.core.$strict>,
3998
+ z.ZodObject<{
3999
+ type: z.ZodDefault<z.ZodLiteral<"stdio">>;
4000
+ command: z.ZodString;
4001
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
4002
+ env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
4003
+ }, z.core.$strict>
4004
+ ]>>>;
4005
+ }, z.core.$strip>;
4006
+ export type MCPFileConfig = z.infer<typeof mcpFileSchema>;
4007
+ /**
4008
+ * Loaded MCP configuration with resolved environment variables.
4009
+ */
4010
+ export type LoadedMCPConfig = {
4011
+ mcpServers: Record<string, MCPConfig$1>;
4012
+ /** The file path this config was loaded from */
4013
+ _sourceFilePath: string;
4014
+ };
4015
+ /**
4016
+ * Load MCP configuration from `mcp.json` files in `.agents` directories.
4017
+ *
4018
+ * By default, searches for mcp.json in:
4019
+ * - `{cwd}/.agents/mcp.json`
4020
+ * - `{cwd}/../.agents/mcp.json`
4021
+ * - `{homedir}/.agents/mcp.json`
4022
+ *
4023
+ * Later directories take precedence, so project MCP servers override global ones.
4024
+ * Environment variable references (e.g., `$API_KEY`) are resolved from process.env.
4025
+ *
4026
+ * @param options.verbose - Whether to log errors during loading
4027
+ * @returns Record of MCP server configurations keyed by server name
4028
+ *
4029
+ * @example
4030
+ * ```typescript
4031
+ * // Load from default locations
4032
+ * const mcpConfig = await loadMCPConfig({ verbose: true })
4033
+ *
4034
+ * // Access MCP servers
4035
+ * for (const [serverName, config] of Object.entries(mcpConfig.mcpServers)) {
4036
+ * console.log(`MCP server: ${serverName}`)
4037
+ * }
4038
+ * ```
4039
+ */
4040
+ export declare function loadMCPConfig(options: {
4041
+ verbose?: boolean;
4042
+ }): Promise<LoadedMCPConfig>;
4043
+ /**
4044
+ * Synchronously load MCP configuration from `mcp.json` files in `.agents` directories.
4045
+ * This is a sync version for use in contexts where async is not available.
4046
+ *
4047
+ * @param options.verbose - Whether to log errors during loading
4048
+ * @returns Record of MCP server configurations keyed by server name
4049
+ */
4050
+ export declare function loadMCPConfigSync(options: {
4051
+ verbose?: boolean;
4052
+ }): LoadedMCPConfig;
4053
+ /**
4054
+ * Formats available skills as XML for inclusion in tool descriptions.
4055
+ */
4056
+ export declare function formatAvailableSkillsXml(skills: SkillsMap): string;
4057
+ /**
4058
+ * Loads a single skill from a SKILL.md file.
4059
+ * Returns null if the skill is invalid.
4060
+ */
4061
+ /** Parse and validate one SKILL.md document without touching disk. */
4062
+ export declare function parseSkillFileContent(content: string, options: {
4063
+ directoryName: string;
4064
+ filePath: string;
4065
+ verbose?: boolean;
4066
+ }): SkillDefinition | null;
4067
+ export type LoadSkillsOptions = {
4068
+ /** Working directory for project skills. Defaults to process.cwd() */
4069
+ cwd?: string;
4070
+ /** Optional specific skills directory path */
4071
+ skillsPath?: string;
4072
+ /** Whether to log errors during loading */
4073
+ verbose?: boolean;
4074
+ };
4075
+ /**
4076
+ * Load skills from .agents/skills and .claude/skills directories.
4077
+ *
4078
+ * By default, searches for skills in (later overrides earlier):
4079
+ * - `~/.claude/skills/` (global, Claude Code compatible)
4080
+ * - `~/.agents/skills/` (global)
4081
+ * - `{cwd}/.claude/skills/` (project, Claude Code compatible)
4082
+ * - `{cwd}/.agents/skills/` (project, highest priority)
4083
+ *
4084
+ * Each skill must be in its own directory with a SKILL.md file:
4085
+ * - `.agents/skills/my-skill/SKILL.md`
4086
+ * - `.claude/skills/my-skill/SKILL.md`
4087
+ *
4088
+ * @param options.cwd - Working directory for project skills
4089
+ * @param options.skillsPath - Optional path to a specific skills directory
4090
+ * @param options.verbose - Whether to log errors during loading
4091
+ * @returns Record of skill definitions keyed by skill name
4092
+ *
4093
+ * @example
4094
+ * ```typescript
4095
+ * // Load from default locations
4096
+ * const skills = await loadSkills({ verbose: true })
4097
+ *
4098
+ * // Load from a specific directory
4099
+ * const skills = await loadSkills({ skillsPath: './my-skills' })
4100
+ *
4101
+ * // Access a skill
4102
+ * const gitReleaseSkill = skills['git-release']
4103
+ * console.log(gitReleaseSkill.description)
4104
+ * ```
4105
+ */
4106
+ export declare function loadSkillsSync(options?: LoadSkillsOptions): SkillsMap;
4107
+ /** Async-compatible public loader retained for existing callers. */
4108
+ export declare function loadSkills(options?: LoadSkillsOptions): Promise<SkillsMap>;
4109
+ export interface ValidationResult {
4110
+ success: boolean;
4111
+ validationErrors: Array<{
4112
+ id: string;
4113
+ message: string;
4114
+ }>;
4115
+ errorCount: number;
4116
+ }
4117
+ export interface ValidateAgentsOptions {
4118
+ /**
4119
+ * Whether to perform remote validation via the web API.
4120
+ * Remote validation checks spawnable agents against the database.
4121
+ */
4122
+ remote?: boolean;
4123
+ /**
4124
+ * The base URL of the Anvil website API.
4125
+ * Optional - defaults to NEXT_PUBLIC_ANVIL_APP_URL or environment-based URL.
4126
+ * Example: 'https://codebuff.com'
4127
+ */
4128
+ websiteUrl?: string;
4129
+ }
4130
+ /**
4131
+ * Validates an array of agent definitions.
4132
+ *
4133
+ * By default, performs local Zod schema validation.
4134
+ * When `options.remote` is true, additionally validates spawnable agents via the web API.
4135
+ *
4136
+ * @param definitions - Array of agent definitions to validate
4137
+ * @param options - Optional configuration for validation
4138
+ * @returns Promise<ValidationResult> - Validation results with any errors
4139
+ *
4140
+ * @example
4141
+ * ```typescript
4142
+ * // Local validation only
4143
+ * const result = await validateAgents(definitions)
4144
+ *
4145
+ * // Remote validation
4146
+ * const result = await validateAgents(definitions, {
4147
+ * remote: true,
4148
+ * websiteUrl: 'https://codebuff.com'
4149
+ * })
4150
+ * ```
4151
+ */
4152
+ export declare function validateAgents(definitions: AgentDefinition[], options?: ValidateAgentsOptions): Promise<ValidationResult>;
4153
+ /**
4154
+ * Notification hook for free-mode capacity deferrals. When the backend sheds
4155
+ * a free-mode completion under saturation (HTTP 429 with
4156
+ * `error: 'free_mode_capacity_deferred'` — see the server's
4157
+ * free-mode-priority.ts), the AI SDK's retry loop absorbs the wait silently.
4158
+ * Hosts (the CLI) can register here to surface a "high demand" indicator
4159
+ * instead of an unexplained pause.
4160
+ */
4161
+ export type FreeModeCapacityDeferral = {
4162
+ retryAfterSeconds: number;
4163
+ };
4164
+ export declare function setFreeModeCapacityDeferralListener(listener: ((deferral: FreeModeCapacityDeferral) => void) | null): void;
4165
+ /**
4166
+ * SDK Error Utilities
4167
+ *
4168
+ * Simple utilities for error handling based on HTTP status codes.
4169
+ * Uses the AI SDK's error types which include statusCode property.
4170
+ */
4171
+ /**
4172
+ * Error type with statusCode property
4173
+ */
4174
+ export type HttpError = Error & {
4175
+ statusCode: number;
4176
+ };
4177
+ /**
4178
+ * HTTP status codes that should trigger automatic retry
4179
+ */
4180
+ export declare const RETRYABLE_STATUS_CODES: Set<number>;
4181
+ /**
4182
+ * Creates an Error with a statusCode property
4183
+ */
4184
+ export declare function createHttpError(message: string, statusCode: number): HttpError;
4185
+ /**
4186
+ * Creates an authentication error (401)
4187
+ */
4188
+ export declare function createAuthError(message?: string): HttpError;
4189
+ /**
4190
+ * Creates a forbidden error (403)
4191
+ */
4192
+ export declare function createForbiddenError(message?: string): HttpError;
4193
+ /**
4194
+ * Creates a payment required error (402)
4195
+ */
4196
+ export declare function createPaymentRequiredError(message?: string): HttpError;
4197
+ /**
4198
+ * Creates a server error (500 by default, or custom 5xx)
4199
+ */
4200
+ export declare function createServerError(message?: string, statusCode?: number): HttpError;
4201
+ /**
4202
+ * Creates a network error (503 - service unavailable)
4203
+ * Used for connection failures, DNS errors, timeouts, etc.
4204
+ */
4205
+ export declare function createNetworkError(message?: string): HttpError;
4206
+ /**
4207
+ * Checks if an HTTP status code is retryable
4208
+ */
4209
+ export declare function isRetryableStatusCode(statusCode: number | undefined): boolean;
4210
+ /**
4211
+ * Extracts the statusCode from an error if available.
4212
+ * Checks both 'statusCode' (our convention) and 'status' (AI SDK's APICallError convention).
4213
+ */
4214
+ export declare function getErrorStatusCode(error: unknown): number | undefined;
4215
+ /**
4216
+ * Sanitizes error messages for display
4217
+ * Removes sensitive information and formats for user consumption
4218
+ */
4219
+ export declare function sanitizeErrorMessage(error: unknown): string;
4220
+ /**
4221
+ * Retry Configuration Constants
4222
+ *
4223
+ * This module defines constants for retry behavior and exponential backoff.
4224
+ * Used by the CLI to automatically retry failed messages after reconnection.
4225
+ *
4226
+ * @example
4227
+ * ```typescript
4228
+ * import { MAX_RETRIES_PER_MESSAGE, RETRY_BACKOFF_BASE_DELAY_MS } from '@anvil/sdk'
4229
+ *
4230
+ * let retryCount = 0
4231
+ * let backoffDelay = RETRY_BACKOFF_BASE_DELAY_MS
4232
+ *
4233
+ * while (retryCount < MAX_RETRIES_PER_MESSAGE) {
4234
+ * await new Promise(resolve => setTimeout(resolve, backoffDelay))
4235
+ * // ... retry logic
4236
+ * backoffDelay = Math.min(backoffDelay * 2, RETRY_BACKOFF_MAX_DELAY_MS)
4237
+ * retryCount++
4238
+ * }
4239
+ * ```
4240
+ */
4241
+ /**
4242
+ * Maximum number of retry attempts per message
4243
+ * After this many attempts, the message is marked as permanently failed
4244
+ */
4245
+ export declare const MAX_RETRIES_PER_MESSAGE = 3;
4246
+ /**
4247
+ * Base delay in milliseconds for exponential backoff
4248
+ * First retry: 1s, Second: 2s, Third: 4s, Fourth: 8s (capped)
4249
+ */
4250
+ export declare const RETRY_BACKOFF_BASE_DELAY_MS = 1000;
4251
+ /**
4252
+ * Maximum delay in milliseconds for exponential backoff
4253
+ * Prevents backoff from growing indefinitely
4254
+ */
4255
+ export declare const RETRY_BACKOFF_MAX_DELAY_MS = 8000;
4256
+ /**
4257
+ * Duration in milliseconds to show the reconnection message
4258
+ * After this time, the message auto-hides
4259
+ */
4260
+ export declare const RECONNECTION_MESSAGE_DURATION_MS = 2000;
4261
+ /**
4262
+ * Delay in milliseconds before retrying messages after reconnection
4263
+ * Gives the connection time to stabilize before attempting retries
4264
+ */
4265
+ export declare const RECONNECTION_RETRY_DELAY_MS = 500;
4266
+ export declare function promptAiSdkStream(params: ParamsOf<PromptAiSdkStreamFn>): ReturnType<PromptAiSdkStreamFn>;
4267
+ export declare function promptAiSdk(params: ParamsOf<PromptAiSdkFn>): ReturnType<PromptAiSdkFn>;
4268
+ export declare function promptAiSdkStructured<T>(params: PromptAiSdkStructuredInput<T>): PromptAiSdkStructuredOutput<T>;
4269
+ declare function getFileTokenScores$1(...args: Parameters<typeof getFileTokenScores>): ReturnType<typeof getFileTokenScores>;
4270
+ export declare function setWasmDir(dir: string): void;
4271
+ export declare function setTreeSitterWasmPath(wasmPath: string): void;
4272
+
4273
+ export {
4274
+ getFileTokenScores$1 as getFileTokenScores,
4275
+ };
4276
+
4277
+ export {};