agents 0.11.9 → 0.12.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 (43) hide show
  1. package/README.md +37 -1
  2. package/dist/{index-DSwOzhhd.d.ts → agent-tool-types-tBGRsPm0.d.ts} +584 -99
  3. package/dist/agent-tool-types.d.ts +34 -0
  4. package/dist/agent-tool-types.js +1 -0
  5. package/dist/agent-tools-BAdX1vdI.js +425 -0
  6. package/dist/agent-tools-BAdX1vdI.js.map +1 -0
  7. package/dist/agent-tools-CIO14miM.d.ts +14 -0
  8. package/dist/agent-tools.d.ts +68 -0
  9. package/dist/agent-tools.js +51 -0
  10. package/dist/agent-tools.js.map +1 -0
  11. package/dist/browser/ai.d.ts +1 -1
  12. package/dist/browser/ai.js +2 -2
  13. package/dist/browser/index.d.ts +1 -1
  14. package/dist/browser/index.js +1 -1
  15. package/dist/browser/tanstack-ai.d.ts +1 -1
  16. package/dist/browser/tanstack-ai.js +1 -1
  17. package/dist/chat/index.d.ts +3 -1
  18. package/dist/chat/index.js +3 -300
  19. package/dist/chat/index.js.map +1 -1
  20. package/dist/client.d.ts +2 -2
  21. package/dist/{compaction-helpers-C_cN3z55.js → compaction-helpers-CSaqCmdE.js} +1 -1
  22. package/dist/{compaction-helpers-C_cN3z55.js.map → compaction-helpers-CSaqCmdE.js.map} +1 -1
  23. package/dist/{compaction-helpers-YzCLvunJ.d.ts → compaction-helpers-D92Ipstp.d.ts} +1 -1
  24. package/dist/experimental/memory/session/index.d.ts +1 -1
  25. package/dist/experimental/memory/session/index.js +1 -1
  26. package/dist/experimental/memory/utils/index.d.ts +1 -1
  27. package/dist/experimental/memory/utils/index.js +1 -1
  28. package/dist/index.d.ts +74 -42
  29. package/dist/index.js +1393 -296
  30. package/dist/index.js.map +1 -1
  31. package/dist/mcp/client.d.ts +1 -1
  32. package/dist/mcp/index.d.ts +1 -1
  33. package/dist/react.d.ts +16 -2
  34. package/dist/react.js +42 -1
  35. package/dist/react.js.map +1 -1
  36. package/dist/{serializable-Bg8ARWlN.d.ts → serializable-Brg7fRds.d.ts} +1 -1
  37. package/dist/serializable.d.ts +1 -1
  38. package/dist/{shared-mfBbxjS1.js → shared-C6l4ZKRN.js} +1 -1
  39. package/dist/{shared-mfBbxjS1.js.map → shared-C6l4ZKRN.js.map} +1 -1
  40. package/dist/{shared-BUHZFGTk.d.ts → shared-Ch9slKdI.d.ts} +1 -1
  41. package/dist/sub-routing.d.ts +6 -6
  42. package/dist/workflows.d.ts +1 -1
  43. package/package.json +9 -4
package/README.md CHANGED
@@ -111,7 +111,7 @@ Core State sync · Routing · HTTP & WebSockets · @callable RPC · Sub-
111
111
  Clients React hook · Vanilla JS · Real-time state sync
112
112
  Channels WebSocket · HTTP · Email · (coming: SMS, Voice, Messengers)
113
113
  Background Queue · Scheduling · Workflows · Human-in-the-loop
114
- AI Chat agents · Tool calling · MCP servers & clients
114
+ AI Chat agents · Agent tools · Tool calling · MCP servers & clients
115
115
  Platform Observability · Cross-domain auth · Resumable streams
116
116
  ```
117
117
 
@@ -222,6 +222,42 @@ const chat = useAgent({
222
222
 
223
223
  The routed URL becomes `/agents/inbox/{userId}/sub/chat/{chatId}`.
224
224
 
225
+ ### Agent Tools
226
+
227
+ Run chat-capable sub-agents as tools from a parent chat agent. Think agents and
228
+ `AIChatAgent` subclasses are supported. The child keeps its own messages, tools,
229
+ SQLite storage, and resumable stream, while the parent broadcasts
230
+ `agent-tool-event` frames so the UI can render the child timeline inline.
231
+
232
+ ```typescript
233
+ import { Think } from "@cloudflare/think";
234
+ import { agentTool } from "agents/agent-tools";
235
+ import { z } from "zod";
236
+
237
+ export class Researcher extends Think<Env> {
238
+ getSystemPrompt() {
239
+ return "Research the requested topic and end with a concise summary.";
240
+ }
241
+ }
242
+
243
+ export class Assistant extends Think<Env> {
244
+ getTools() {
245
+ return {
246
+ research: agentTool(Researcher, {
247
+ description: "Research one topic in depth.",
248
+ inputSchema: z.object({ query: z.string().min(3) })
249
+ })
250
+ };
251
+ }
252
+ }
253
+ ```
254
+
255
+ For deterministic fan-out, call `this.runAgentTool(Researcher, { input })`
256
+ directly. In React, use `useAgentToolEvents({ agent })` to render retained and
257
+ replayed child timelines. AIChatAgent children run headlessly, so browser
258
+ client tools require a separate bridge; server-side tools work normally. See
259
+ the full [Agent Tools guide](../../docs/agent-tools.md).
260
+
225
261
  ### WebSocket Connections
226
262
 
227
263
  Handle real-time communication: