@cloudflare/think 0.13.0 → 0.14.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 (88) hide show
  1. package/README.md +20 -6
  2. package/dist/{index-Cm0jriTY.d.ts → index-CDNxUctz.d.ts} +39 -6
  3. package/dist/messengers/index.d.ts +1 -1
  4. package/dist/messengers/telegram.d.ts +1 -1
  5. package/dist/studio/assets/{angular-html--XgCyfPu.js → angular-html-Dl5doFtz.js} +1 -1
  6. package/dist/studio/assets/{angular-ts-Dt-feQIe.js → angular-ts-CbN7_mlY.js} +1 -1
  7. package/dist/studio/assets/{apl-B7ymkyp4.js → apl-CUTyCKtR.js} +1 -1
  8. package/dist/studio/assets/{astro-Ce5cw2JI.js → astro-4sWs7Jg3.js} +1 -1
  9. package/dist/studio/assets/{blade-DL-aXwjv.js → blade-NmhW_pJp.js} +1 -1
  10. package/dist/studio/assets/{c-CFfr09UF.js → c-_ropPcoN.js} +1 -1
  11. package/dist/studio/assets/{cobol-Ba1f5ZqR.js → cobol-BacpIX4U.js} +1 -1
  12. package/dist/studio/assets/{coffee-BG2_viYI.js → coffee-DcwgCl9J.js} +1 -1
  13. package/dist/studio/assets/{cpp-pU5HgBva.js → cpp-BCPbrI0m.js} +1 -1
  14. package/dist/studio/assets/{crystal-Dlm_uR4r.js → crystal-DZXQ6wBH.js} +1 -1
  15. package/dist/studio/assets/{css-tUC4TMTn.js → css-BYyCaTYR.js} +1 -1
  16. package/dist/studio/assets/{edge-CQuSKMUt.js → edge-CVh9HJt8.js} +1 -1
  17. package/dist/studio/assets/{elixir-BmIB-Wi1.js → elixir-9uvyi7ZY.js} +1 -1
  18. package/dist/studio/assets/{elm-ByVNCtDB.js → elm-DDSgRIyn.js} +1 -1
  19. package/dist/studio/assets/{erb-DO4uDxTq.js → erb-DAVyz0cP.js} +1 -1
  20. package/dist/studio/assets/{git-rebase-CT8LXapC.js → git-rebase-z3txLW9w.js} +1 -1
  21. package/dist/studio/assets/{glimmer-js-DzIT0v-m.js → glimmer-js-BRADiKXN.js} +1 -1
  22. package/dist/studio/assets/{glimmer-ts-znG2j9R4.js → glimmer-ts-B6C6vVGo.js} +1 -1
  23. package/dist/studio/assets/{glsl-C1p8U_gW.js → glsl-34bCtA9U.js} +1 -1
  24. package/dist/studio/assets/{graphql-CFqegryf.js → graphql-CL83z2DV.js} +1 -1
  25. package/dist/studio/assets/{hack-BfVsNhqs.js → hack-B9WxPQav.js} +1 -1
  26. package/dist/studio/assets/{haml-DVcEksY5.js → haml-oavex6g4.js} +1 -1
  27. package/dist/studio/assets/{handlebars-DSWgWCJ4.js → handlebars-pd64xhEq.js} +1 -1
  28. package/dist/studio/assets/{highlighted-body-OFNGDK62-BIm4UpTS.js → highlighted-body-OFNGDK62-DB3-I0_d.js} +1 -1
  29. package/dist/studio/assets/{html-C-lP7-T4.js → html-A_mALprL.js} +1 -1
  30. package/dist/studio/assets/{html-derivative-ByukJopb.js → html-derivative-CBwZyoIR.js} +1 -1
  31. package/dist/studio/assets/{http-Bax2fYIk.js → http-Cua_-o-V.js} +1 -1
  32. package/dist/studio/assets/{hurl-BrI2qfvy.js → hurl-Dpr8mC4K.js} +1 -1
  33. package/dist/studio/assets/{index-DNSTOyBe.js → index-DmVgVRjr.js} +86 -86
  34. package/dist/studio/assets/{java-ZiR-uym-.js → java-B1Ptmnmm.js} +1 -1
  35. package/dist/studio/assets/{javascript-Dhhw85Vr.js → javascript-waNlhfIS.js} +1 -1
  36. package/dist/studio/assets/{jinja-DqSGkgE4.js → jinja-D06CyNkk.js} +1 -1
  37. package/dist/studio/assets/{jison-CwQ0BO-q.js → jison-CQo2g2q_.js} +1 -1
  38. package/dist/studio/assets/{json-Je3YfUTE.js → json-T8-gmbyP.js} +1 -1
  39. package/dist/studio/assets/{jsx-Da-dLbW1.js → jsx-pi8aEi7y.js} +1 -1
  40. package/dist/studio/assets/{julia-CBJ0H-0z.js → julia-DQ0CkLQi.js} +1 -1
  41. package/dist/studio/assets/{just-CnuRC_nd.js → just-BaZbjeHH.js} +1 -1
  42. package/dist/studio/assets/{latex-gZANCito.js → latex-CKRYEGLe.js} +1 -1
  43. package/dist/studio/assets/{liquid-0U9aXoFI.js → liquid-KfgQvxVp.js} +1 -1
  44. package/dist/studio/assets/{lua-CX_TqMxt.js → lua-BDYsw9Eb.js} +1 -1
  45. package/dist/studio/assets/{marko-StSURz0o.js → marko-BSPq2tuh.js} +1 -1
  46. package/dist/studio/assets/{mdc-CXZpf9k1.js → mdc-ZTdTy2-Y.js} +1 -1
  47. package/dist/studio/assets/mermaid-GHXKKRXX-UMXpy7w5.js +1 -0
  48. package/dist/studio/assets/{nginx-3Q2L4366.js → nginx-BsBsElo9.js} +1 -1
  49. package/dist/studio/assets/{nim-CqX_5eXP.js → nim-Fud12WJN.js} +1 -1
  50. package/dist/studio/assets/{perl-CLOu1GnZ.js → perl-BcRrrqpJ.js} +1 -1
  51. package/dist/studio/assets/{php-C1vkiu4h.js → php-CvBMy7ll.js} +1 -1
  52. package/dist/studio/assets/{pug-Cg3cFp5y.js → pug-9fn0F-sp.js} +1 -1
  53. package/dist/studio/assets/{qml-DhKeHMwt.js → qml-DPYDKGeG.js} +1 -1
  54. package/dist/studio/assets/{r--Lg2-Sir.js → r-B-BlSOk_.js} +1 -1
  55. package/dist/studio/assets/{razor-Cjptf146.js → razor-BBsuDNIH.js} +1 -1
  56. package/dist/studio/assets/{regexp-fS0DAwei.js → regexp-siAWelih.js} +1 -1
  57. package/dist/studio/assets/{rst-BBajBzk-.js → rst-DpBCyEwj.js} +1 -1
  58. package/dist/studio/assets/{ruby-KvFedogM.js → ruby-BQ1xX5ej.js} +1 -1
  59. package/dist/studio/assets/{sas-D6p27LWr.js → sas-Dft5mTiQ.js} +1 -1
  60. package/dist/studio/assets/{scss-6jXfJVsd.js → scss-BFMJsYGZ.js} +1 -1
  61. package/dist/studio/assets/{shellscript-BK0Qbt1B.js → shellscript-Cncrs_5T.js} +1 -1
  62. package/dist/studio/assets/{shellsession-BsXmVRU4.js → shellsession-BngbHbQf.js} +1 -1
  63. package/dist/studio/assets/{soy-BKtGCXkJ.js → soy-BY5W-W7z.js} +1 -1
  64. package/dist/studio/assets/{sql-vSUKslBj.js → sql-rEN1gzdE.js} +1 -1
  65. package/dist/studio/assets/{stata-BQ0iXcs9.js → stata-BDRzO3gs.js} +1 -1
  66. package/dist/studio/assets/{surrealql-v5pXHIwP.js → surrealql-DgF3SPLS.js} +1 -1
  67. package/dist/studio/assets/{svelte-BMFjqgJb.js → svelte-BsPFEf_A.js} +1 -1
  68. package/dist/studio/assets/{templ-DYMTOmIJ.js → templ-D4eIDjcz.js} +1 -1
  69. package/dist/studio/assets/{tex-BoQem9gj.js → tex-hl_BDesm.js} +1 -1
  70. package/dist/studio/assets/{ts-tags-Kp2pAlsd.js → ts-tags-mYERLvfx.js} +1 -1
  71. package/dist/studio/assets/{tsx-DaB2J5uo.js → tsx-4zmdohFv.js} +1 -1
  72. package/dist/studio/assets/{twig-DohCGJPH.js → twig-J6ElH33g.js} +1 -1
  73. package/dist/studio/assets/{typescript-BGG-5I-T.js → typescript-DaBxXTXh.js} +1 -1
  74. package/dist/studio/assets/{vue-CCDLUl9R.js → vue-CnJAvLlE.js} +1 -1
  75. package/dist/studio/assets/{vue-html-et9GYlaF.js → vue-html-5M7J-A2F.js} +1 -1
  76. package/dist/studio/assets/{vue-vine-C561z6bx.js → vue-vine-BgG3D4Fz.js} +1 -1
  77. package/dist/studio/assets/{xml-CJBA1ZPm.js → xml-BuA8iyrb.js} +1 -1
  78. package/dist/studio/assets/{xsl-De-lf9XG.js → xsl-CEhAy4QP.js} +1 -1
  79. package/dist/studio/assets/{yaml-BcMKxf75.js → yaml-CKMEvlUE.js} +1 -1
  80. package/dist/studio/index.html +1 -1
  81. package/dist/think.d.ts +1 -1
  82. package/dist/think.js +340 -181
  83. package/dist/think.js.map +1 -1
  84. package/dist/workflows.d.ts +1 -1
  85. package/docs/index.md +16 -0
  86. package/docs/tools.md +19 -2
  87. package/package.json +6 -6
  88. package/dist/studio/assets/mermaid-GHXKKRXX-CqDQH2-r.js +0 -1
@@ -1,4 +1,4 @@
1
- import { ln as Think, vn as ThinkSubmissionStatus } from "./index-Cm0jriTY.js";
1
+ import { ln as Think, vn as ThinkSubmissionStatus } from "./index-CDNxUctz.js";
2
2
  import { ZodObject, z } from "zod";
3
3
  import { WorkflowEvent, WorkflowSleepDuration } from "cloudflare:workers";
4
4
  import {
package/docs/index.md CHANGED
@@ -857,11 +857,27 @@ path.
857
857
  | `workspaceBash` | `true` | Include or configure the default workspace `bash` tool |
858
858
  | `fetchTools` | `false` | Opt-in allowlisted, read-only HTTP fetch tools (`fetch_url` + per-binding `fetch_<name>`). Set to a config object; see [Fetch tool](#fetch-tool) |
859
859
  | `messageConcurrency` | `"queue"` | How overlapping submits behave — see [Client Tools](./client-tools.md) |
860
+ | `includeMcpTools` | `true` | Automatically convert connected MCP tools to AI SDK tools and merge them into model turns |
860
861
  | `waitForMcpConnections` | `false` | Wait for MCP servers before inference |
861
862
  | `chatRecovery` | `true` | Wrap turns in `runFiber` for durable execution, including sub-agent turns. Set to `{ maxAttempts, stableTimeoutMs, terminalMessage, onExhausted }` to tune bounded recovery. |
862
863
  | `chatStreamStallTimeoutMs` | `0` (off) | Opt-in inactivity watchdog: abort a turn whose model stream produces no chunk for this long (measures the gap between chunks, including tool execution — set above your slowest model TTFT + tool, e.g. `120_000`). Emits a `chat:stream:stalled` event; with `chatRecovery` on (the default) the stall routes into bounded recovery (see below) instead of an infinite spinner, and only terminalizes once the budget is exhausted. Override per-turn via `TurnConfig.chatStreamStallTimeoutMs` (returned from `beforeTurn`) for a turn with a known-slow tool. |
863
864
  | `contextOverflow` | `undefined` | Opt-in mid-turn context-overflow handling: `{ reactive?, maxRetries?, proactive? }`. Requires `classifyChatError` + a session compaction function. See [Context-window overflow recovery](#context-window-overflow-recovery). |
864
865
 
866
+ ### MCP tools exposed outside the harness
867
+
868
+ Think normally calls `this.mcp.getAITools()` while assembling every turn. If you expose MCP tools through Code Mode or another mechanism outside Think's automatic tool set, set `includeMcpTools = false` to avoid direct JSON Schema-to-Zod materialization:
869
+
870
+ ```typescript
871
+ export class MyAgent extends Think<Env> {
872
+ includeMcpTools = false;
873
+ waitForMcpConnections = true;
874
+ }
875
+ ```
876
+
877
+ This setting affects only Think's automatic AI SDK tool merge. Connections still register, restore, discover, and wait normally; raw tool listing and calls, Code Mode access, and explicit `this.mcp.getAITools()` calls are unchanged. Returning `activeTools: []` from `beforeTurn` does not provide the same behavior because tool conversion occurs before that hook.
878
+
879
+ See [Tools](./tools.md#mcp-tools) for MCP setup and alternative exposure paths.
880
+
865
881
  ## Agent Skills
866
882
 
867
883
  Think supports [Agent Skills](https://agentskills.io/) as on-demand
package/docs/tools.md CHANGED
@@ -11,7 +11,7 @@ On every turn, Think merges tools from multiple sources. Later sources override
11
11
  3. **Extension tools** — tools from loaded extensions (prefixed by extension name)
12
12
  4. **Session tools** — `set_context`, `load_context`, `search_context` (from `configureSession`)
13
13
  5. **Skill tools** — `activate_skill`, `read_skill_resource`, `run_skill_script` (from `getSkills()`)
14
- 6. **MCP tools** — from connected MCP servers
14
+ 6. **MCP tools** — from connected MCP servers (when `includeMcpTools` is enabled)
15
15
  7. **Client tools** — from the browser (see [Client Tools](./client-tools.md))
16
16
 
17
17
  Tools belong to the agent running the turn. For parent-child orchestration,
@@ -182,7 +182,7 @@ beforeTurn(ctx: TurnContext) {
182
182
 
183
183
  ## MCP Tools
184
184
 
185
- Think inherits MCP client support from the `Agent` base class. MCP tools from connected servers are automatically merged into every turn.
185
+ Think inherits MCP client support from the `Agent` base class. By default, tools from connected MCP servers are converted to AI SDK tools and merged into every turn.
186
186
 
187
187
  Set `waitForMcpConnections` to ensure MCP servers are connected before the inference loop runs:
188
188
 
@@ -197,6 +197,23 @@ export class MyAgent extends Think<Env> {
197
197
  }
198
198
  ```
199
199
 
200
+ If you expose MCP tools through Code Mode or another mechanism outside Think's automatic tool set, disable direct AI SDK tool exposure:
201
+
202
+ ```typescript
203
+ export class MyAgent extends Think<Env> {
204
+ includeMcpTools = false;
205
+ waitForMcpConnections = true;
206
+
207
+ getModel() {
208
+ /* ... */
209
+ }
210
+ }
211
+ ```
212
+
213
+ `includeMcpTools = false` suppresses only Think's automatic `this.mcp.getAITools()` merge. MCP registration, restoration, discovery, waiting, raw catalog access, direct calls, Code Mode connectors, and explicit application calls to `this.mcp.getAITools()` continue to work. This avoids converting every MCP JSON Schema to Zod when the model only uses the raw MCP connection through the connector.
214
+
215
+ Use the class property instead of `beforeTurn({ activeTools: [] })` for this purpose. `activeTools` limits tools after turn assembly; MCP schema conversion happens while Think assembles the context, before `beforeTurn` runs.
216
+
200
217
  Add MCP servers programmatically or via `@callable` methods:
201
218
 
202
219
  ```typescript
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "tools"
10
10
  ],
11
11
  "type": "module",
12
- "version": "0.13.0",
12
+ "version": "0.14.0",
13
13
  "license": "MIT",
14
14
  "repository": {
15
15
  "directory": "packages/think",
@@ -26,8 +26,8 @@
26
26
  "dependencies": {
27
27
  "@ai-sdk/anthropic": "^3.0.83",
28
28
  "@ai-sdk/openai": "^3.0.70",
29
- "@cloudflare/codemode": "^0.4.3",
30
- "@cloudflare/shell": "^0.4.1",
29
+ "@cloudflare/codemode": "^0.4.4",
30
+ "@cloudflare/shell": "^0.4.2",
31
31
  "aywson": "^0.0.16",
32
32
  "chat": "^4.31.0",
33
33
  "create-think": "^0.1.1",
@@ -39,7 +39,7 @@
39
39
  "devDependencies": {
40
40
  "@ai-sdk/react": "^3.0.204",
41
41
  "@chat-adapter/telegram": "^4.31.0",
42
- "@cloudflare/ai-chat": "^0.9.3",
42
+ "@cloudflare/ai-chat": "^0.9.4",
43
43
  "@cloudflare/kumo": "^2.6.0",
44
44
  "@phosphor-icons/react": "^2.1.10",
45
45
  "@streamdown/code": "^1.1.1",
@@ -49,7 +49,7 @@
49
49
  "@types/react-dom": "^19.2.3",
50
50
  "@types/yargs": "^17.0.35",
51
51
  "@vitejs/plugin-react": "^6.0.3",
52
- "agents": "^0.17.4",
52
+ "agents": "^0.18.0",
53
53
  "ai": "^6.0.202",
54
54
  "jsdom": "^29.1.1",
55
55
  "react": "^19.2.7",
@@ -62,7 +62,7 @@
62
62
  "peerDependencies": {
63
63
  "@ai-sdk/react": "^3.0.204",
64
64
  "@chat-adapter/telegram": "^4.29.0",
65
- "agents": ">=0.17.1 <1.0.0",
65
+ "agents": ">=0.18.0 <1.0.0",
66
66
  "ai": "^6.0.182",
67
67
  "react": "^19.0.0",
68
68
  "vite": ">=6 <9",
@@ -1 +0,0 @@
1
- import{i as e}from"./index-DNSTOyBe.js";export{e as Mermaid};