@cloudflare/think 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/README.md +10 -17
  2. package/dist/{chat-sdk-Bb93yaZh.js → chat-sdk-D6cUghsQ.js} +33 -8
  3. package/dist/chat-sdk-D6cUghsQ.js.map +1 -0
  4. package/dist/cli/index.js +718 -55
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/{codegen-CuPdJRpV.js → codegen-DlA2QQuU.js} +6 -38
  7. package/dist/codegen-DlA2QQuU.js.map +1 -0
  8. package/dist/{config-D512sQYg.d.ts → config-CD7hqncK.d.ts} +5 -5
  9. package/dist/extensions/index.js +1 -1
  10. package/dist/framework/index.d.ts +17 -62
  11. package/dist/framework/index.js +3 -57
  12. package/dist/{think-CwxWGsX1.d.ts → index-D_S5mETO.d.ts} +1643 -688
  13. package/dist/{manager-BPndMP_6.js → manager-CSk5htym.js} +7 -7
  14. package/dist/{manager-BPndMP_6.js.map → manager-CSk5htym.js.map} +1 -1
  15. package/dist/{manifest-CpB-xngB.d.ts → manifest-DK5HuGga.d.ts} +16 -18
  16. package/dist/messengers/index.d.ts +59 -55
  17. package/dist/messengers/index.js +2 -2
  18. package/dist/messengers/telegram.d.ts +4 -4
  19. package/dist/messengers/telegram.js +1 -1
  20. package/dist/react.d.ts +79 -0
  21. package/dist/react.js +28 -0
  22. package/dist/react.js.map +1 -0
  23. package/dist/server-entry.d.ts +1 -1
  24. package/dist/server-entry.js +1 -1
  25. package/dist/server-entry.js.map +1 -1
  26. package/dist/studio/assets/abap-CLvhMVsD.js +1 -0
  27. package/dist/studio/assets/actionscript-3--17pq3dv.js +1 -0
  28. package/dist/studio/assets/ada-C5qYipkI.js +1 -0
  29. package/dist/studio/assets/andromeeda-vGVdxbeo.js +1 -0
  30. package/dist/studio/assets/angular-html-D27LthTc.js +1 -0
  31. package/dist/studio/assets/angular-ts-DtNL2gQ7.js +1 -0
  32. package/dist/studio/assets/apache-U0d_L8uA.js +1 -0
  33. package/dist/studio/assets/apex-CGTLDQj6.js +1 -0
  34. package/dist/studio/assets/apl-BgEcDqM0.js +1 -0
  35. package/dist/studio/assets/applescript-CCn79oCD.js +1 -0
  36. package/dist/studio/assets/ara-4CJ0cIlV.js +1 -0
  37. package/dist/studio/assets/asciidoc-DE70LPWp.js +1 -0
  38. package/dist/studio/assets/asm-Cmm7eHzH.js +1 -0
  39. package/dist/studio/assets/astro-CstbRF9e.js +1 -0
  40. package/dist/studio/assets/aurora-x-CDeNXAV0.js +1 -0
  41. package/dist/studio/assets/awk-BWXHIvNe.js +1 -0
  42. package/dist/studio/assets/ayu-dark-DluEY0Gj.js +1 -0
  43. package/dist/studio/assets/ayu-light-C3h-C4tm.js +1 -0
  44. package/dist/studio/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  45. package/dist/studio/assets/ballerina-B7ZEbQpA.js +1 -0
  46. package/dist/studio/assets/bat-Bo4NYOV-.js +1 -0
  47. package/dist/studio/assets/beancount-D-usSTwE.js +1 -0
  48. package/dist/studio/assets/berry-DKpUyyne.js +1 -0
  49. package/dist/studio/assets/bibtex-Ci_nEsc7.js +1 -0
  50. package/dist/studio/assets/bicep-CUHmPFLl.js +1 -0
  51. package/dist/studio/assets/bird2-C2hNVINV.js +1 -0
  52. package/dist/studio/assets/blade-CLG-7epG.js +1 -0
  53. package/dist/studio/assets/bsl-BkkzgIyY.js +1 -0
  54. package/dist/studio/assets/c-CssQqwxO.js +1 -0
  55. package/dist/studio/assets/c3-CnJL0r0V.js +1 -0
  56. package/dist/studio/assets/cadence-CQ2zXKGN.js +1 -0
  57. package/dist/studio/assets/cairo-DLTphjLi.js +1 -0
  58. package/dist/studio/assets/catppuccin-frappe-3VR1Za6u.js +1 -0
  59. package/dist/studio/assets/catppuccin-latte-DwIHMF0Q.js +1 -0
  60. package/dist/studio/assets/catppuccin-macchiato-DYnBP6_5.js +1 -0
  61. package/dist/studio/assets/catppuccin-mocha-DYhrFGRu.js +1 -0
  62. package/dist/studio/assets/clarity-SemFz856.js +1 -0
  63. package/dist/studio/assets/clojure-DqKBuwfJ.js +1 -0
  64. package/dist/studio/assets/cmake-Bj61d0ZC.js +1 -0
  65. package/dist/studio/assets/cobol-CjmzHCjg.js +1 -0
  66. package/dist/studio/assets/codeowners-C8r90Shi.js +1 -0
  67. package/dist/studio/assets/codeql-oeQT6MSM.js +1 -0
  68. package/dist/studio/assets/coffee-B_rqYPkp.js +1 -0
  69. package/dist/studio/assets/common-lisp-Cv5bFMCO.js +1 -0
  70. package/dist/studio/assets/coq-BrsZFFmf.js +1 -0
  71. package/dist/studio/assets/cpp-5YyZJlb7.js +1 -0
  72. package/dist/studio/assets/crystal-D7uKze0i.js +1 -0
  73. package/dist/studio/assets/csharp-Ct8U2NOr.js +1 -0
  74. package/dist/studio/assets/css-k9oPgg7G.js +1 -0
  75. package/dist/studio/assets/csv-Dx-8-gkx.js +1 -0
  76. package/dist/studio/assets/cue-CE9AQfxI.js +1 -0
  77. package/dist/studio/assets/cypher-ClKdZ_lG.js +1 -0
  78. package/dist/studio/assets/d-qD-0Kul2.js +1 -0
  79. package/dist/studio/assets/dark-plus-Cs2F2srj.js +1 -0
  80. package/dist/studio/assets/dart-DkHntEIa.js +1 -0
  81. package/dist/studio/assets/dax-BkyTk9wS.js +1 -0
  82. package/dist/studio/assets/desktop-Dlh5hvp9.js +1 -0
  83. package/dist/studio/assets/diff-woXpYk--.js +1 -0
  84. package/dist/studio/assets/docker-IyjqRm3v.js +1 -0
  85. package/dist/studio/assets/dotenv-_5a1GRtc.js +1 -0
  86. package/dist/studio/assets/dracula-BHWKrbxM.js +1 -0
  87. package/dist/studio/assets/dracula-soft-5eyTD99u.js +1 -0
  88. package/dist/studio/assets/dream-maker-DW3nJb8Q.js +1 -0
  89. package/dist/studio/assets/edge-CGgsSt0x.js +1 -0
  90. package/dist/studio/assets/elixir-BX_d5Evo.js +1 -0
  91. package/dist/studio/assets/elm-DENxDm5e.js +1 -0
  92. package/dist/studio/assets/emacs-lisp-C9PiwqqW.js +1 -0
  93. package/dist/studio/assets/erb-DvYOup03.js +1 -0
  94. package/dist/studio/assets/erlang-Cphh6RMH.js +1 -0
  95. package/dist/studio/assets/everforest-dark-sB-x3p7T.js +1 -0
  96. package/dist/studio/assets/everforest-light-Df2xbC6M.js +1 -0
  97. package/dist/studio/assets/fennel-DQxkIbk2.js +1 -0
  98. package/dist/studio/assets/fish-BJitypiv.js +1 -0
  99. package/dist/studio/assets/fluent-C03EYrpw.js +1 -0
  100. package/dist/studio/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
  101. package/dist/studio/assets/fortran-free-form-CYNrtFtB.js +1 -0
  102. package/dist/studio/assets/fsharp-D13ZGOAj.js +1 -0
  103. package/dist/studio/assets/gdresource-C0sCabJj.js +1 -0
  104. package/dist/studio/assets/gdscript-Cp2uCuqX.js +1 -0
  105. package/dist/studio/assets/gdshader-CBce3t8t.js +1 -0
  106. package/dist/studio/assets/genie-CV2tkWYe.js +1 -0
  107. package/dist/studio/assets/gherkin-DExj1W_8.js +1 -0
  108. package/dist/studio/assets/git-commit-BSykSTBG.js +1 -0
  109. package/dist/studio/assets/git-rebase-BsAdTS5A.js +1 -0
  110. package/dist/studio/assets/github-dark-C-LZuMrd.js +1 -0
  111. package/dist/studio/assets/github-dark-default-DXG-b-1a.js +1 -0
  112. package/dist/studio/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  113. package/dist/studio/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  114. package/dist/studio/assets/github-light-EUqPIrTm.js +1 -0
  115. package/dist/studio/assets/github-light-default-BXViO-2h.js +1 -0
  116. package/dist/studio/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  117. package/dist/studio/assets/gleam-CSRkHgEL.js +1 -0
  118. package/dist/studio/assets/glimmer-js-e0h98Z67.js +1 -0
  119. package/dist/studio/assets/glimmer-ts-C9s5Kv8m.js +1 -0
  120. package/dist/studio/assets/glsl-CCiyeTRs.js +1 -0
  121. package/dist/studio/assets/gn-ilITqXS6.js +1 -0
  122. package/dist/studio/assets/gnuplot-7GGW24-e.js +1 -0
  123. package/dist/studio/assets/go-BJwz_mda.js +1 -0
  124. package/dist/studio/assets/graphql-BRtHwsqk.js +1 -0
  125. package/dist/studio/assets/groovy-CacY0gHj.js +1 -0
  126. package/dist/studio/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  127. package/dist/studio/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  128. package/dist/studio/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  129. package/dist/studio/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  130. package/dist/studio/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  131. package/dist/studio/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  132. package/dist/studio/assets/hack-Dnt0QXHh.js +1 -0
  133. package/dist/studio/assets/haml-EXGmzuB1.js +1 -0
  134. package/dist/studio/assets/handlebars-CzyBIDJE.js +1 -0
  135. package/dist/studio/assets/haskell-D8IpX4py.js +1 -0
  136. package/dist/studio/assets/haxe-OTjmBuCE.js +1 -0
  137. package/dist/studio/assets/hcl-Dh228itO.js +1 -0
  138. package/dist/studio/assets/highlighted-body-OFNGDK62-CQUFKLNu.js +1 -0
  139. package/dist/studio/assets/hjson-CxZEssPk.js +1 -0
  140. package/dist/studio/assets/hlsl-Cvrh5tZx.js +1 -0
  141. package/dist/studio/assets/horizon-CE9ld1lL.js +1 -0
  142. package/dist/studio/assets/horizon-bright-Br1oVSNq.js +1 -0
  143. package/dist/studio/assets/houston-CsvMBhTu.js +1 -0
  144. package/dist/studio/assets/html-BAT8b_VM.js +1 -0
  145. package/dist/studio/assets/html-derivative-7tkS-r6F.js +1 -0
  146. package/dist/studio/assets/http-Cgka02Qq.js +1 -0
  147. package/dist/studio/assets/hurl-Cbkh8WEw.js +1 -0
  148. package/dist/studio/assets/hxml-B0Qn7Nwc.js +1 -0
  149. package/dist/studio/assets/hy-CZbG8q4J.js +1 -0
  150. package/dist/studio/assets/imba-DsUTQ-LC.js +1 -0
  151. package/dist/studio/assets/index-D6n8vpkp.js +390 -0
  152. package/dist/studio/assets/index-DkGWw6ES.css +2 -0
  153. package/dist/studio/assets/ini-B5eOa1yu.js +1 -0
  154. package/dist/studio/assets/java-DrRKiUno.js +1 -0
  155. package/dist/studio/assets/javascript-9LAnHOxD.js +1 -0
  156. package/dist/studio/assets/jinja-CqRt4prs.js +1 -0
  157. package/dist/studio/assets/jison-BX-IOQpJ.js +1 -0
  158. package/dist/studio/assets/json-dOrE-En8.js +1 -0
  159. package/dist/studio/assets/json5-BR5RXkoi.js +1 -0
  160. package/dist/studio/assets/jsonc-CYpm1nAK.js +1 -0
  161. package/dist/studio/assets/jsonl-CmCQp5Yx.js +1 -0
  162. package/dist/studio/assets/jsonnet-CJTPZ8u_.js +1 -0
  163. package/dist/studio/assets/jssm-DXw9l8Rf.js +1 -0
  164. package/dist/studio/assets/jsx-BSTPfqWX.js +1 -0
  165. package/dist/studio/assets/julia-Dvz-BPmf.js +1 -0
  166. package/dist/studio/assets/just-BHQm0Atq.js +1 -0
  167. package/dist/studio/assets/kanagawa-dragon-CXtmUGW6.js +1 -0
  168. package/dist/studio/assets/kanagawa-lotus-BN08jTvb.js +1 -0
  169. package/dist/studio/assets/kanagawa-wave-CTweb8Dz.js +1 -0
  170. package/dist/studio/assets/kdl-CsD5j6eV.js +1 -0
  171. package/dist/studio/assets/kotlin-DhhofPvG.js +1 -0
  172. package/dist/studio/assets/kusto-BUv0MjJC.js +1 -0
  173. package/dist/studio/assets/laserwave-C_8bwKvT.js +1 -0
  174. package/dist/studio/assets/latex-CxdhxuXv.js +1 -0
  175. package/dist/studio/assets/lean-CewbzKMR.js +1 -0
  176. package/dist/studio/assets/less-DVTAwKKz.js +1 -0
  177. package/dist/studio/assets/light-plus-DVQuIRkW.js +1 -0
  178. package/dist/studio/assets/liquid-D-hM-Q_F.js +1 -0
  179. package/dist/studio/assets/llvm-Cm23YOpf.js +1 -0
  180. package/dist/studio/assets/log-BNLmms1o.js +1 -0
  181. package/dist/studio/assets/logo-Cluzi2Zq.js +1 -0
  182. package/dist/studio/assets/lua-5qtqjLHq.js +1 -0
  183. package/dist/studio/assets/luau-CNKltnaQ.js +1 -0
  184. package/dist/studio/assets/make-Dixweg8N.js +1 -0
  185. package/dist/studio/assets/markdown-BYOwaDjH.js +1 -0
  186. package/dist/studio/assets/marko-5FJaM2co.js +1 -0
  187. package/dist/studio/assets/material-theme-Bm3Qr25_.js +1 -0
  188. package/dist/studio/assets/material-theme-darker-2IIEA8gg.js +1 -0
  189. package/dist/studio/assets/material-theme-lighter-uhdI0v04.js +1 -0
  190. package/dist/studio/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  191. package/dist/studio/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  192. package/dist/studio/assets/matlab-D7qyCx1q.js +1 -0
  193. package/dist/studio/assets/mdc-BhYW7lCG.js +1 -0
  194. package/dist/studio/assets/mdx-DQZ5AkYe.js +1 -0
  195. package/dist/studio/assets/mermaid-Bk4SNUv9.js +1 -0
  196. package/dist/studio/assets/mermaid-GHXKKRXX-CWM2EB-u.js +1 -0
  197. package/dist/studio/assets/min-dark-BSWPekZh.js +1 -0
  198. package/dist/studio/assets/min-light-DDpmG2fV.js +1 -0
  199. package/dist/studio/assets/mipsasm-BMqwQI7S.js +1 -0
  200. package/dist/studio/assets/mojo-BgCJLMeH.js +1 -0
  201. package/dist/studio/assets/monokai-CdkpiU2Y.js +1 -0
  202. package/dist/studio/assets/moonbit-CaWjb8XO.js +1 -0
  203. package/dist/studio/assets/move-B1IS1UjX.js +1 -0
  204. package/dist/studio/assets/narrat-_X_XdTYD.js +1 -0
  205. package/dist/studio/assets/nextflow-Bbiyy34d.js +1 -0
  206. package/dist/studio/assets/nextflow-groovy-Dc_ddanL.js +1 -0
  207. package/dist/studio/assets/nginx-rtAXrRye.js +1 -0
  208. package/dist/studio/assets/night-owl-DhmEMT88.js +1 -0
  209. package/dist/studio/assets/night-owl-light-eJ-hLW7d.js +1 -0
  210. package/dist/studio/assets/nim-DQSmaN9U.js +1 -0
  211. package/dist/studio/assets/nix-IvuFDN5E.js +1 -0
  212. package/dist/studio/assets/nord-Cb4Vim4T.js +1 -0
  213. package/dist/studio/assets/nushell-DcLAeLz5.js +1 -0
  214. package/dist/studio/assets/objective-c-D1A_Heim.js +1 -0
  215. package/dist/studio/assets/objective-cpp-BsSzOQcm.js +1 -0
  216. package/dist/studio/assets/ocaml-O90oeIOV.js +1 -0
  217. package/dist/studio/assets/odin-B1RWQWA5.js +1 -0
  218. package/dist/studio/assets/one-dark-pro-CLwyXe_n.js +1 -0
  219. package/dist/studio/assets/one-light-D7Lr4KcI.js +1 -0
  220. package/dist/studio/assets/openscad-BUDT5pXO.js +1 -0
  221. package/dist/studio/assets/pascal-4ZHwLPI5.js +1 -0
  222. package/dist/studio/assets/perl-B54AdcaE.js +1 -0
  223. package/dist/studio/assets/php-DpvTxCny.js +1 -0
  224. package/dist/studio/assets/pkl-ot-7Btpt.js +1 -0
  225. package/dist/studio/assets/plastic-DQwYfKfQ.js +1 -0
  226. package/dist/studio/assets/plsql-DGHpHOYJ.js +1 -0
  227. package/dist/studio/assets/po-BiJDBrnU.js +1 -0
  228. package/dist/studio/assets/poimandres-DRFjx7u4.js +1 -0
  229. package/dist/studio/assets/polar-C7UOKdEL.js +1 -0
  230. package/dist/studio/assets/postcss-BXeXVLqQ.js +1 -0
  231. package/dist/studio/assets/powerquery-DNMTfnFr.js +1 -0
  232. package/dist/studio/assets/powershell-DshXNtvi.js +1 -0
  233. package/dist/studio/assets/prisma-BsRQq5mF.js +1 -0
  234. package/dist/studio/assets/prolog-iXnhIJG7.js +1 -0
  235. package/dist/studio/assets/proto-DB4EqR-F.js +1 -0
  236. package/dist/studio/assets/pug-Cyffw0Ho.js +1 -0
  237. package/dist/studio/assets/puppet-CDv2pdJW.js +1 -0
  238. package/dist/studio/assets/purescript-9MfHhQsQ.js +1 -0
  239. package/dist/studio/assets/python-gzcpVVnB.js +1 -0
  240. package/dist/studio/assets/qml-CxRetSkO.js +1 -0
  241. package/dist/studio/assets/qmldir-DCQb3MpD.js +1 -0
  242. package/dist/studio/assets/qss-Fe1Jh2GI.js +1 -0
  243. package/dist/studio/assets/r-CXWRxrXc.js +1 -0
  244. package/dist/studio/assets/racket-DcIDlBhZ.js +1 -0
  245. package/dist/studio/assets/raku-B3gFvitq.js +1 -0
  246. package/dist/studio/assets/razor-BJzI-zc9.js +1 -0
  247. package/dist/studio/assets/red-CJ3rzSJv.js +1 -0
  248. package/dist/studio/assets/reg-CRGYupPL.js +1 -0
  249. package/dist/studio/assets/regexp-dqxdfrnE.js +1 -0
  250. package/dist/studio/assets/rel-BtDbiS_P.js +1 -0
  251. package/dist/studio/assets/riscv-Ckw8ddFX.js +1 -0
  252. package/dist/studio/assets/ron-VUp2lXgN.js +1 -0
  253. package/dist/studio/assets/rose-pine-BthvhNj6.js +1 -0
  254. package/dist/studio/assets/rose-pine-dawn-Dg85fqjY.js +1 -0
  255. package/dist/studio/assets/rose-pine-moon-hon4tzzS.js +1 -0
  256. package/dist/studio/assets/rosmsg-CAekHB0j.js +1 -0
  257. package/dist/studio/assets/rst-BW7eKYj4.js +1 -0
  258. package/dist/studio/assets/ruby-D5Npyj8-.js +1 -0
  259. package/dist/studio/assets/rust-Cfkwpbl8.js +1 -0
  260. package/dist/studio/assets/sas-DZLppjul.js +1 -0
  261. package/dist/studio/assets/sass-DXrisJhu.js +1 -0
  262. package/dist/studio/assets/scala-DKOlJaKm.js +1 -0
  263. package/dist/studio/assets/scheme-DQCgrYNe.js +1 -0
  264. package/dist/studio/assets/scss-CbqoxyAe.js +1 -0
  265. package/dist/studio/assets/sdbl-bTVj8UrX.js +1 -0
  266. package/dist/studio/assets/shaderlab-TOUzSsQk.js +1 -0
  267. package/dist/studio/assets/shellscript-CFHqBeXu.js +1 -0
  268. package/dist/studio/assets/shellsession-CbZDA4Bf.js +1 -0
  269. package/dist/studio/assets/slack-dark-DnToyrRv.js +1 -0
  270. package/dist/studio/assets/slack-ochin-B2OO5cIa.js +1 -0
  271. package/dist/studio/assets/smalltalk-B16xEiuN.js +1 -0
  272. package/dist/studio/assets/snazzy-light-4G7pJPwS.js +1 -0
  273. package/dist/studio/assets/solarized-dark-DV17i1UV.js +1 -0
  274. package/dist/studio/assets/solarized-light-DSh2HLQt.js +1 -0
  275. package/dist/studio/assets/solidity-CKzVLygQ.js +1 -0
  276. package/dist/studio/assets/soy-PImjtV58.js +1 -0
  277. package/dist/studio/assets/sparql-D_iOobhT.js +1 -0
  278. package/dist/studio/assets/splunk-BC2Px7Mm.js +1 -0
  279. package/dist/studio/assets/sql-DhGo8urW.js +1 -0
  280. package/dist/studio/assets/ssh-config-BgfXC-Er.js +1 -0
  281. package/dist/studio/assets/stata-CjHWbU2v.js +1 -0
  282. package/dist/studio/assets/stylus-B6D30XZt.js +1 -0
  283. package/dist/studio/assets/surrealql-o8Qr4t56.js +1 -0
  284. package/dist/studio/assets/svelte-DlSIyEV1.js +1 -0
  285. package/dist/studio/assets/swift-DonLKvLd.js +1 -0
  286. package/dist/studio/assets/synthwave-84-nFMaYfgc.js +1 -0
  287. package/dist/studio/assets/system-verilog-DJ5XKQeo.js +1 -0
  288. package/dist/studio/assets/systemd-BxMlprV5.js +1 -0
  289. package/dist/studio/assets/talonscript-CohzipZa.js +1 -0
  290. package/dist/studio/assets/tasl-DMoTqEGO.js +1 -0
  291. package/dist/studio/assets/tcl-CZd0xW_V.js +1 -0
  292. package/dist/studio/assets/templ-qizfwU1w.js +1 -0
  293. package/dist/studio/assets/terraform-DswuEJGm.js +1 -0
  294. package/dist/studio/assets/tex-Ca7T661H.js +1 -0
  295. package/dist/studio/assets/tokyo-night-oM2G3aXe.js +1 -0
  296. package/dist/studio/assets/toml-CcmNWLt0.js +1 -0
  297. package/dist/studio/assets/ts-tags-DUmjLkgl.js +1 -0
  298. package/dist/studio/assets/tsv-sltzmVWM.js +1 -0
  299. package/dist/studio/assets/tsx-CfwgIqHW.js +1 -0
  300. package/dist/studio/assets/turtle-ByJddavk.js +1 -0
  301. package/dist/studio/assets/twig-D7NAYUBY.js +1 -0
  302. package/dist/studio/assets/typescript-Bbz9oX-P.js +1 -0
  303. package/dist/studio/assets/typespec-B88KGewJ.js +1 -0
  304. package/dist/studio/assets/typst-DI99ib-x.js +1 -0
  305. package/dist/studio/assets/v-DETTlOr0.js +1 -0
  306. package/dist/studio/assets/vala-zf12oZj6.js +1 -0
  307. package/dist/studio/assets/vb-Djn5o6TS.js +1 -0
  308. package/dist/studio/assets/verilog-CiiDBU1e.js +1 -0
  309. package/dist/studio/assets/vesper-D5bVUKB1.js +1 -0
  310. package/dist/studio/assets/vhdl-BroJfC0k.js +1 -0
  311. package/dist/studio/assets/viml-DvXPmvsu.js +1 -0
  312. package/dist/studio/assets/vitesse-black-fwtXNY1n.js +1 -0
  313. package/dist/studio/assets/vitesse-dark-BZCL-v6S.js +1 -0
  314. package/dist/studio/assets/vitesse-light-VbXTXTou.js +1 -0
  315. package/dist/studio/assets/vue-html-CcxTb_Jn.js +1 -0
  316. package/dist/studio/assets/vue-vYpz06zQ.js +1 -0
  317. package/dist/studio/assets/vue-vine-DW4RqCKF.js +1 -0
  318. package/dist/studio/assets/vyper-CgoNMtux.js +1 -0
  319. package/dist/studio/assets/wasm-BnjxR4X6.js +1 -0
  320. package/dist/studio/assets/wasm-ByWQv1Qj.js +1 -0
  321. package/dist/studio/assets/wenyan-C8pVoKbM.js +1 -0
  322. package/dist/studio/assets/wgsl-BsKzXJz4.js +1 -0
  323. package/dist/studio/assets/wikitext-ClFFjSW2.js +1 -0
  324. package/dist/studio/assets/wit-DdvCle-K.js +1 -0
  325. package/dist/studio/assets/wolfram-DLL8P-h_.js +1 -0
  326. package/dist/studio/assets/xml-R4LZ_u4f.js +1 -0
  327. package/dist/studio/assets/xsl-CS-xzp3L.js +1 -0
  328. package/dist/studio/assets/yaml-CqDWbYXd.js +1 -0
  329. package/dist/studio/assets/zenscript-BnlCZFoB.js +1 -0
  330. package/dist/studio/assets/zig-CMLA9XwU.js +1 -0
  331. package/dist/studio/index.html +23 -0
  332. package/dist/think.d.ts +2 -2
  333. package/dist/think.js +8292 -2
  334. package/dist/think.js.map +1 -0
  335. package/dist/tools/extensions.js +1 -1
  336. package/dist/tools/workspace.js +2 -2
  337. package/dist/tools/workspace.js.map +1 -1
  338. package/dist/{types-codegen-B6c5KpYH.js → types-codegen-C-9yeFao.js} +9 -33
  339. package/dist/types-codegen-C-9yeFao.js.map +1 -0
  340. package/dist/vite.d.ts +12 -5
  341. package/dist/vite.js +73 -1
  342. package/dist/vite.js.map +1 -1
  343. package/dist/workflows.d.ts +1 -1
  344. package/docs/actions.md +297 -0
  345. package/docs/channels.md +185 -0
  346. package/docs/client-tools.md +233 -0
  347. package/docs/getting-started.md +314 -0
  348. package/docs/index.md +1272 -0
  349. package/docs/lifecycle-hooks.md +839 -0
  350. package/docs/messengers.md +197 -0
  351. package/docs/programmatic-submissions.md +206 -0
  352. package/docs/sub-agents.md +520 -0
  353. package/docs/tools.md +582 -0
  354. package/docs/workflows.md +217 -0
  355. package/package.json +57 -10
  356. package/dist/chat-sdk-Bb93yaZh.js.map +0 -1
  357. package/dist/codegen-CuPdJRpV.js.map +0 -1
  358. package/dist/framework/index.js.map +0 -1
  359. package/dist/think-2nHHEcY3.js +0 -6446
  360. package/dist/think-2nHHEcY3.js.map +0 -1
  361. package/dist/types-codegen-B6c5KpYH.js.map +0 -1
package/docs/tools.md ADDED
@@ -0,0 +1,582 @@
1
+ # Tools
2
+
3
+ Think provides built-in workspace file tools on every turn, plus integration points for custom tools, code execution, and dynamic extensions.
4
+
5
+ ## Tool Merge Order
6
+
7
+ On every turn, Think merges tools from multiple sources. Later sources override earlier ones if names collide:
8
+
9
+ 1. **Workspace tools** — `read`, `write`, `edit`, `list`, `find`, `grep`, `delete`, `bash` (built-in)
10
+ 2. **`getTools()`** — your custom server-side tools
11
+ 3. **Extension tools** — tools from loaded extensions (prefixed by extension name)
12
+ 4. **Session tools** — `set_context`, `load_context`, `search_context` (from `configureSession`)
13
+ 5. **Skill tools** — `activate_skill`, `read_skill_resource`, `run_skill_script` (from `getSkills()`)
14
+ 6. **MCP tools** — from connected MCP servers
15
+ 7. **Client tools** — from the browser (see [Client Tools](./client-tools.md))
16
+
17
+ Tools belong to the agent running the turn. For parent-child orchestration,
18
+ use [Agent Tools](https://github.com/cloudflare/agents/blob/main/docs/agents/agent-tools.md) instead of passing one-off tools through
19
+ `chat()`.
20
+
21
+ ## Built-in Workspace Tools
22
+
23
+ Every Think agent gets `this.workspace` — a virtual filesystem backed by the Durable Object's SQLite storage. Workspace tools are automatically available to the model with no configuration.
24
+
25
+ | Tool | Description |
26
+ | -------- | --------------------------------------------------------------------------- |
27
+ | `read` | Read text with line numbers; pass images and PDFs to multimodal models |
28
+ | `write` | Write content to a file (creates parent directories) |
29
+ | `edit` | Apply a find-and-replace edit to an existing file (supports fuzzy matching) |
30
+ | `list` | List files and directories in a path |
31
+ | `find` | Find files matching a glob pattern |
32
+ | `grep` | Search file contents by regex or fixed string |
33
+ | `delete` | Delete a file or directory |
34
+ | `bash` | Run a sandboxed Bash script against workspace files |
35
+
36
+ The `bash` tool is enabled by default. It mounts workspace files into a
37
+ `just-bash` virtual filesystem, runs with network access disabled, and writes
38
+ created, updated, and deleted files and empty directories back to the workspace.
39
+ Use it for shell-style workflows that combine multiple file operations; use the
40
+ narrower tools for simple reads, writes, and edits.
41
+
42
+ To keep tool calls bounded, the Bash tool snapshots up to 1,000 workspace files
43
+ by default and skips files larger than 1 MB. Skipped files are reported in the
44
+ tool result and are treated as protected during write-back so the script cannot
45
+ accidentally overwrite or delete content that was not mounted. You can tune
46
+ `maxWorkspaceFiles`, `maxWorkspaceFileBytes`, `maxOutputBytes`, `timeout`, and
47
+ `network` through `workspaceBash`.
48
+
49
+ Disable the default Bash tool for conservative deployments:
50
+
51
+ ```typescript
52
+ export class MyAgent extends Think<Env> {
53
+ workspaceBash = false;
54
+
55
+ getModel() {
56
+ /* ... */
57
+ }
58
+ }
59
+ ```
60
+
61
+ ### R2 Spillover
62
+
63
+ By default, the workspace stores everything in SQLite. For large files, override `workspace` to add R2 spillover:
64
+
65
+ ```typescript
66
+ import { Think } from "@cloudflare/think";
67
+ import { Workspace } from "@cloudflare/shell";
68
+
69
+ export class MyAgent extends Think<Env> {
70
+ override workspace = new Workspace({
71
+ sql: this.ctx.storage.sql,
72
+ r2: this.env.R2,
73
+ name: () => this.name
74
+ });
75
+
76
+ getModel() {
77
+ /* ... */
78
+ }
79
+ }
80
+ ```
81
+
82
+ This requires an R2 bucket binding in `wrangler.jsonc`:
83
+
84
+ ```jsonc
85
+ {
86
+ "r2_buckets": [{ "binding": "R2", "bucket_name": "agent-files" }]
87
+ }
88
+ ```
89
+
90
+ ## Custom Tools
91
+
92
+ Override `getTools()` to add your own tools. These are standard AI SDK `tool()` definitions with Zod schemas:
93
+
94
+ ```typescript
95
+ import { Think } from "@cloudflare/think";
96
+ import { tool } from "ai";
97
+ import type { ToolSet } from "ai";
98
+ import { z } from "zod";
99
+
100
+ export class MyAgent extends Think<Env> {
101
+ getModel() {
102
+ /* ... */
103
+ }
104
+
105
+ getTools(): ToolSet {
106
+ return {
107
+ getWeather: tool({
108
+ description: "Get the current weather for a city",
109
+ inputSchema: z.object({
110
+ city: z.string().describe("City name")
111
+ }),
112
+ execute: async ({ city }) => {
113
+ const res = await fetch(
114
+ `https://api.weather.com/v1/current?q=${city}&key=${this.env.WEATHER_KEY}`
115
+ );
116
+ return res.json();
117
+ }
118
+ }),
119
+
120
+ calculate: tool({
121
+ description: "Perform a math calculation",
122
+ inputSchema: z.object({
123
+ a: z.number(),
124
+ b: z.number(),
125
+ operator: z.enum(["+", "-", "*", "/"])
126
+ }),
127
+ execute: async ({ a, b, operator }) => {
128
+ const ops: Record<string, (x: number, y: number) => number> = {
129
+ "+": (x, y) => x + y,
130
+ "-": (x, y) => x - y,
131
+ "*": (x, y) => x * y,
132
+ "/": (x, y) => x / y
133
+ };
134
+ return { result: ops[operator](a, b) };
135
+ }
136
+ })
137
+ };
138
+ }
139
+ }
140
+ ```
141
+
142
+ Custom tools are merged with workspace tools automatically. If a custom tool has the same name as a workspace tool, the custom tool wins.
143
+
144
+ ### Tool Approval
145
+
146
+ Tools can require user approval before execution using the `needsApproval` option:
147
+
148
+ ```typescript
149
+ getTools(): ToolSet {
150
+ return {
151
+ deleteFile: tool({
152
+ description: "Delete a file from the system",
153
+ inputSchema: z.object({ path: z.string() }),
154
+ needsApproval: async ({ path }) => path.startsWith("/important/"),
155
+ execute: async ({ path }) => {
156
+ await this.workspace.rm(path);
157
+ return { deleted: path };
158
+ }
159
+ })
160
+ };
161
+ }
162
+ ```
163
+
164
+ When `needsApproval` returns `true`, the tool call is sent to the client for approval. The conversation pauses until the client responds with `CF_AGENT_TOOL_APPROVAL`. See [Client Tools](./client-tools.md) for the approval flow.
165
+
166
+ > Inside the [Code Execution Tool](#code-execution-tool)'s sandbox, `needsApproval` behaves differently: it maps to the codemode runtime's durable pause/approve/resume flow, and a function-valued `needsApproval` always requires approval (see [Approvals](#approvals-human-in-the-loop)).
167
+
168
+ ### Per-turn Tool Overrides
169
+
170
+ The `beforeTurn` hook can restrict or add tools for a specific turn:
171
+
172
+ ```typescript
173
+ beforeTurn(ctx: TurnContext) {
174
+ return {
175
+ activeTools: ["read", "write", "getWeather"],
176
+ tools: { emergencyTool: this.createEmergencyTool() }
177
+ };
178
+ }
179
+ ```
180
+
181
+ `activeTools` limits which tools the model can call. `tools` adds extra tools for this turn only (merged on top of existing tools).
182
+
183
+ ## MCP Tools
184
+
185
+ Think inherits MCP client support from the `Agent` base class. MCP tools from connected servers are automatically merged into every turn.
186
+
187
+ Set `waitForMcpConnections` to ensure MCP servers are connected before the inference loop runs:
188
+
189
+ ```typescript
190
+ export class MyAgent extends Think<Env> {
191
+ waitForMcpConnections = true; // default 10s timeout
192
+ // or: waitForMcpConnections = { timeout: 5000 };
193
+
194
+ getModel() {
195
+ /* ... */
196
+ }
197
+ }
198
+ ```
199
+
200
+ Add MCP servers programmatically or via `@callable` methods:
201
+
202
+ ```typescript
203
+ import { callable } from "agents";
204
+
205
+ export class MyAgent extends Think<Env> {
206
+ getModel() {
207
+ /* ... */
208
+ }
209
+
210
+ @callable()
211
+ async addServer(name: string, url: string) {
212
+ return await this.addMcpServer(name, url);
213
+ }
214
+
215
+ @callable()
216
+ async removeServer(serverId: string) {
217
+ await this.removeMcpServer(serverId);
218
+ }
219
+ }
220
+ ```
221
+
222
+ See [Connecting to MCP Servers](https://github.com/cloudflare/agents/blob/main/docs/agents/mcp-client.md) for full MCP client documentation.
223
+
224
+ ## Code Execution Tool
225
+
226
+ Let the LLM write and run TypeScript in a sandboxed Worker, recorded on a durable codemode runtime (abort-and-replay, human approvals, audit trail, reusable snippets). Requires `@cloudflare/codemode` and a `worker_loaders` binding.
227
+
228
+ ```sh
229
+ npm install @cloudflare/codemode
230
+ ```
231
+
232
+ The one-liner infers everything from the agent — `state.*` from `this.workspace`, the executor from `env.LOADER`, and a live browser (`cdp.*`) from `env.BROWSER` if bound:
233
+
234
+ ```typescript
235
+ import { Think } from "@cloudflare/think";
236
+ import { createExecuteTool } from "@cloudflare/think/tools/execute";
237
+
238
+ export class MyAgent extends Think<Env> {
239
+ getModel() {
240
+ /* ... */
241
+ }
242
+
243
+ getTools() {
244
+ return {
245
+ execute: createExecuteTool(this)
246
+ };
247
+ }
248
+ }
249
+ ```
250
+
251
+ Setup checklist:
252
+
253
+ ```jsonc
254
+ // wrangler.jsonc
255
+ {
256
+ "worker_loaders": [{ "binding": "LOADER" }],
257
+ "browser": { "binding": "BROWSER" } // optional — enables cdp.*
258
+ }
259
+ ```
260
+
261
+ ```typescript
262
+ // worker entry — the runtime lives in a Durable Object facet, so the class
263
+ // must be exported (the @cloudflare/codemode/vite plugin does this
264
+ // automatically; the Think framework's generated entry already includes it)
265
+ export { CodemodeRuntime } from "@cloudflare/codemode";
266
+ ```
267
+
268
+ Each missing piece fails with an error naming the step.
269
+
270
+ Inside the sandbox the model sees typed namespaces plus the platform SDK:
271
+
272
+ - `tools.*` — your AI SDK tools (object args, validated against their schemas). Only tools with an `execute` function are exposed — client-side tools can't run in the sandbox.
273
+ - `state.*` — the workspace filesystem (`state.readFile({ path })`, `state.glob({ pattern })`, `state.planEdits(...)`, …)
274
+ - `cdp.*` — the browser, when a Browser Rendering binding is configured. The execute tool defaults to `session: { mode: "dynamic" }`: sessions are per-execution unless the model promotes one with `cdp.startSession()`.
275
+ - `codemode.search` / `codemode.describe` / `codemode.step` / `codemode.run` — discovery, side-effect boundaries, and saved snippets
276
+
277
+ Pass overrides for anything beyond the defaults — e.g. custom `tools.*` alongside the agent-derived state:
278
+
279
+ ```typescript
280
+ execute: createExecuteTool(this, { tools: myDomainTools });
281
+ ```
282
+
283
+ Or fully explicit options (no agent inference):
284
+
285
+ ```typescript
286
+ import { createWorkspaceStateBackend } from "@cloudflare/shell";
287
+
288
+ createExecuteTool({
289
+ ctx: this.ctx,
290
+ tools: myDomainTools,
291
+ state: createWorkspaceStateBackend(this.workspace),
292
+ browser: this.env.BROWSER,
293
+ loader: this.env.LOADER
294
+ });
295
+ ```
296
+
297
+ ### Approvals (human-in-the-loop)
298
+
299
+ An AI SDK tool with `needsApproval` doesn't run immediately inside the sandbox — calling it **pauses the run durably**. The pause comes back as a normal tool output (`{ status: "paused", executionId, pending }`), the model tells the user what it needs, and the turn ends. Note this differs from the client-side approval flow for plain `getTools()` tools: inside the sandbox a function-valued `needsApproval` can't be evaluated against the call's arguments ahead of time, so it conservatively **always** requires approval. Think ships built-in callables to resolve it:
300
+
301
+ - `approveExecution(executionId)` — resumes the run where it stopped (already-done work is replayed, not re-executed); the outcome replaces the paused output in the transcript and the chat auto-continues.
302
+ - `rejectExecution(executionId, reason?)` — ends the run with `{ status: "rejected", reason }` so the model can adapt.
303
+ - `pendingExecutions()` — pending actions (with full args) for rendering approval UI.
304
+
305
+ > **Render approval cards from `pendingExecutions()`, not the transcript.** The `pending` array in the paused tool output is a _truncated preview_ — args are bounded (~2 KB each) so they don't blow up model context, but the full args (up to 1 MB) are what actually execute on approve. A human approving a gated call must see the authoritative args, so fetch them via `pendingExecutions(executionId)` before enabling the Approve button. `examples/assistant`'s `PausedExecutionCard` shows the pattern.
306
+
307
+ See `examples/assistant` for a working approval card, and `design/think-execute-hitl.md` for the design.
308
+
309
+ ### The runtime handle
310
+
311
+ `createExecuteRuntime` returns the moving parts when the host needs more than the tool — and the handle is also assigned to `this.codemode` when created from an agent:
312
+
313
+ ```typescript
314
+ import { createExecuteRuntime } from "@cloudflare/think/tools/execute";
315
+
316
+ const { runtime, connectors, tool } = createExecuteRuntime(this);
317
+ await runtime.executions(); // audit trail
318
+ await runtime.expirePaused(); // reclaim stale never-approved pauses (call from a scheduled task)
319
+ await runtime.saveSnippet("name", { executionId }); // promote a script for reuse
320
+ ```
321
+
322
+ ## Browser Tools
323
+
324
+ Give your agent full access to the Chrome DevTools Protocol (CDP) for web page inspection, scraping, screenshots, and debugging. Requires `@cloudflare/codemode` and a Browser Rendering binding.
325
+
326
+ ```sh
327
+ npm install @cloudflare/codemode
328
+ ```
329
+
330
+ ```typescript
331
+ import { Think } from "@cloudflare/think";
332
+ import { createBrowserTools } from "@cloudflare/think/tools/browser";
333
+
334
+ export class MyAgent extends Think<Env> {
335
+ getModel() {
336
+ /* ... */
337
+ }
338
+
339
+ getTools() {
340
+ return {
341
+ ...createBrowserTools({
342
+ ctx: this.ctx,
343
+ browser: this.env.BROWSER,
344
+ loader: this.env.LOADER
345
+ })
346
+ };
347
+ }
348
+ }
349
+ ```
350
+
351
+ Add the Browser Rendering and Worker Loader bindings in `wrangler.jsonc`:
352
+
353
+ ```jsonc
354
+ {
355
+ "browser": { "binding": "BROWSER" },
356
+ "worker_loaders": [{ "binding": "LOADER" }]
357
+ }
358
+ ```
359
+
360
+ This adds the durable CDP tool plus — whenever a `browser` binding is present — the stateless [Quick Action](https://github.com/cloudflare/agents/blob/main/docs/agents/browse-the-web.md#quick-actions-stateless-browsing) tools by default:
361
+
362
+ | Tool | Description |
363
+ | ------------------ | ----------------------------------------------------------------------------------------- |
364
+ | `browser_execute` | Run TypeScript against a live browser over CDP (screenshots, DOM reads, JS evaluation, …) |
365
+ | `browser_markdown` | Read a page (or raw HTML) as Markdown |
366
+ | `browser_extract` | Extract structured data from a page with AI |
367
+ | `browser_links` | List every link on a page |
368
+ | `browser_scrape` | Scrape specific elements by CSS selector |
369
+
370
+ Pass `quickActions: false` to keep only `browser_execute`, or `quickActions: { actions, maxChars, options }` to configure them. They share the `browser` binding, need no Worker Loader, and `ctx` is resolved from the current Agent automatically (you only need to pass it outside an Agent). For the stateless tools _without_ the CDP tool, import `createQuickActionTools` directly from `@cloudflare/think/tools/browser`.
371
+
372
+ `browser_execute` is backed by a codemode runtime with the `cdp` connector: the model writes async arrow functions that run in a sandboxed Worker isolate, with `cdp.send()`, `cdp.attachToTarget()`, `cdp.spec()` (the live, normalized protocol description), session helpers (`cdp.startSession()`, `cdp.sessionInfo()`, `cdp.closeSession()`), and debug-log helpers. Executions are recorded for abort-and-replay, so browser sessions survive approval pauses.
373
+
374
+ By default each execution gets a fresh browser session (`one-shot`), torn down when the run ends. Pass `session: { mode: "dynamic" }` to let the model promote a session with `cdp.startSession()` so later executions continue in the same browser, or `session: { mode: "reuse", key }` for a named long-lived session. Stale sessions are reclaimed by the connector's `sweep()` — call it from a scheduled task (see `createBrowserRuntime` in `agents/browser` for the connector handle).
375
+
376
+ > The simplest setup is the unified execute tool above: `createExecuteTool(this)` already includes `cdp.*` alongside `state.*` and `tools.*` when `env.BROWSER` is bound — one tool, one durable history. Use `createBrowserTools` when you want a separate, browser-only tool.
377
+
378
+ ### Combining with Other Tools
379
+
380
+ Browser tools compose naturally with workspace tools, code execution, MCP, and extensions:
381
+
382
+ ```typescript
383
+ import { createBrowserTools } from "@cloudflare/think/tools/browser";
384
+ import { createExecuteTool } from "@cloudflare/think/tools/execute";
385
+
386
+ export class ResearchAgent extends Think<Env> {
387
+ getModel() {
388
+ /* ... */
389
+ }
390
+
391
+ getTools() {
392
+ return {
393
+ // Browse the web (separate browser-only tool with its own history)
394
+ ...createBrowserTools({
395
+ ctx: this.ctx,
396
+ browser: this.env.BROWSER,
397
+ loader: this.env.LOADER
398
+ }),
399
+ // Run sandboxed code against workspace files
400
+ execute: createExecuteTool(this)
401
+ };
402
+ }
403
+ }
404
+ ```
405
+
406
+ ### Custom CDP Endpoint
407
+
408
+ To connect to a Chrome instance running outside of Browser Rendering (e.g. `chrome --remote-debugging-port=9222`), pass `cdpUrl` instead of `browser`:
409
+
410
+ ```typescript
411
+ createBrowserTools({
412
+ ctx: this.ctx,
413
+ cdpUrl: "http://localhost:9222",
414
+ loader: this.env.LOADER
415
+ });
416
+ ```
417
+
418
+ See [Browse the Web](https://github.com/cloudflare/agents/blob/main/docs/agents/browse-the-web.md) for the full CDP helper API reference, security model, and limitations.
419
+
420
+ ## Extensions
421
+
422
+ Extensions are dynamically loaded sandboxed Workers that add tools at runtime. The LLM can write extension source code, load it, and use the new tools on the next turn.
423
+
424
+ ### Setup
425
+
426
+ Extensions require `extensionLoader` (a `worker_loaders` binding) and the `ExtensionManager`:
427
+
428
+ ```typescript
429
+ import { Think } from "@cloudflare/think";
430
+ import { ExtensionManager } from "@cloudflare/think/extensions";
431
+ import { createExtensionTools } from "@cloudflare/think/tools/extensions";
432
+
433
+ export class MyAgent extends Think<Env> {
434
+ extensionLoader = this.env.LOADER;
435
+
436
+ getModel() {
437
+ /* ... */
438
+ }
439
+ }
440
+ ```
441
+
442
+ When `extensionLoader` is set, Think automatically creates an `ExtensionManager` and loads extensions from `getExtensions()`.
443
+
444
+ ### Static Extensions
445
+
446
+ Define extensions that load at startup:
447
+
448
+ ```typescript
449
+ export class MyAgent extends Think<Env> {
450
+ extensionLoader = this.env.LOADER;
451
+
452
+ getModel() {
453
+ /* ... */
454
+ }
455
+
456
+ getExtensions() {
457
+ return [
458
+ {
459
+ manifest: {
460
+ name: "math",
461
+ version: "1.0.0",
462
+ permissions: { network: false }
463
+ },
464
+ source: `({
465
+ tools: {
466
+ add: {
467
+ description: "Add two numbers",
468
+ parameters: {
469
+ a: { type: "number" },
470
+ b: { type: "number" }
471
+ },
472
+ execute: async ({ a, b }) => ({ result: a + b })
473
+ }
474
+ }
475
+ })`
476
+ }
477
+ ];
478
+ }
479
+ }
480
+ ```
481
+
482
+ Extension tools are namespaced — `math` extension with `add` tool becomes `math_add` in the model's tool set.
483
+
484
+ ### LLM-Driven Extensions
485
+
486
+ Give the model `createExtensionTools` so it can load extensions dynamically:
487
+
488
+ ```typescript
489
+ import { createExtensionTools } from "@cloudflare/think/tools/extensions";
490
+
491
+ export class MyAgent extends Think<Env> {
492
+ extensionLoader = this.env.LOADER;
493
+
494
+ getModel() {
495
+ /* ... */
496
+ }
497
+
498
+ getTools() {
499
+ return {
500
+ ...createExtensionTools({ manager: this.extensionManager! }),
501
+ ...this.extensionManager!.getTools()
502
+ };
503
+ }
504
+ }
505
+ ```
506
+
507
+ This gives the model two tools:
508
+
509
+ - `load_extension` — load a new extension from JavaScript source
510
+ - `list_extensions` — list currently loaded extensions
511
+
512
+ Loaded extensions persist across DO restarts via `extensionManager.restore()`.
513
+
514
+ ### Extension Context Blocks
515
+
516
+ Extensions can declare context blocks in their manifest. These are automatically registered with the Session:
517
+
518
+ ```typescript
519
+ getExtensions() {
520
+ return [{
521
+ manifest: {
522
+ name: "notes",
523
+ version: "1.0.0",
524
+ permissions: { network: false },
525
+ context: [
526
+ { label: "scratchpad", description: "Extension scratch space", maxTokens: 500 }
527
+ ]
528
+ },
529
+ source: `({ tools: { /* ... */ } })`
530
+ }];
531
+ }
532
+ ```
533
+
534
+ The context block is registered as `notes_scratchpad` (namespaced by extension name).
535
+
536
+ ## Workspace Tools for Custom Backends
537
+
538
+ The individual tool factories are exported for use with custom storage backends that implement the operations interfaces:
539
+
540
+ ```typescript
541
+ import {
542
+ createReadTool,
543
+ createWriteTool,
544
+ createEditTool,
545
+ createListTool,
546
+ createFindTool,
547
+ createGrepTool,
548
+ createDeleteTool
549
+ } from "@cloudflare/think/tools/workspace";
550
+ import type {
551
+ ReadOperations,
552
+ WriteOperations,
553
+ EditOperations,
554
+ ListOperations,
555
+ FindOperations,
556
+ GrepOperations,
557
+ DeleteOperations
558
+ } from "@cloudflare/think/tools/workspace";
559
+ ```
560
+
561
+ Implement the operations interface for your storage backend:
562
+
563
+ ```typescript
564
+ const myReadOps: ReadOperations = {
565
+ readFile: async (path) => fetchFromMyStorage(path),
566
+ readFileBytes: async (path) => fetchBytesFromMyStorage(path),
567
+ stat: async (path) => getFileInfo(path)
568
+ };
569
+
570
+ const readTool = createReadTool({ ops: myReadOps });
571
+ ```
572
+
573
+ Or create the full set from a Workspace:
574
+
575
+ ```typescript
576
+ import { createWorkspaceTools } from "@cloudflare/think/tools/workspace";
577
+
578
+ const tools = createWorkspaceTools(myCustomWorkspace);
579
+ const toolsWithoutBash = createWorkspaceTools(myCustomWorkspace, {
580
+ bash: false
581
+ });
582
+ ```