agents 0.11.9 → 0.12.1

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 (45) hide show
  1. package/README.md +47 -1
  2. package/dist/{index-DSwOzhhd.d.ts → agent-tool-types-CB7nISDE.d.ts} +706 -100
  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-Bb1O8blK.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 +4 -1
  18. package/dist/chat/index.js +34 -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 +1803 -284
  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 +51 -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/sub-routing.js +7 -1
  43. package/dist/sub-routing.js.map +1 -1
  44. package/dist/workflows.d.ts +1 -1
  45. package/package.json +10 -5
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,52 @@ const chat = useAgent({
222
222
 
223
223
  The routed URL becomes `/agents/inbox/{userId}/sub/chat/{chatId}`.
224
224
 
225
+ Child WebSocket clients can use the same URL shape. The parent remains the
226
+ public address, while child agents still receive `onConnect`, `onMessage`,
227
+ `onClose`, `broadcast()`, and `getConnections()` calls scoped to their own
228
+ clients. Parent broadcasts do not leak to child-targeted sockets, and child
229
+ connection tags, readonly state, and protocol-message settings are preserved
230
+ when a connection is resumed from hibernation.
231
+
232
+ Nested sub-agent URLs are supported using repeated `/sub/{agent}/{name}`
233
+ segments, subject to the platform's current facet nesting limits.
234
+
235
+ ### Agent Tools
236
+
237
+ Run chat-capable sub-agents as tools from a parent chat agent. Think agents and
238
+ `AIChatAgent` subclasses are supported. The child keeps its own messages, tools,
239
+ SQLite storage, and resumable stream, while the parent broadcasts
240
+ `agent-tool-event` frames so the UI can render the child timeline inline.
241
+
242
+ ```typescript
243
+ import { Think } from "@cloudflare/think";
244
+ import { agentTool } from "agents/agent-tools";
245
+ import { z } from "zod";
246
+
247
+ export class Researcher extends Think<Env> {
248
+ getSystemPrompt() {
249
+ return "Research the requested topic and end with a concise summary.";
250
+ }
251
+ }
252
+
253
+ export class Assistant extends Think<Env> {
254
+ getTools() {
255
+ return {
256
+ research: agentTool(Researcher, {
257
+ description: "Research one topic in depth.",
258
+ inputSchema: z.object({ query: z.string().min(3) })
259
+ })
260
+ };
261
+ }
262
+ }
263
+ ```
264
+
265
+ For deterministic fan-out, call `this.runAgentTool(Researcher, { input })`
266
+ directly. In React, use `useAgentToolEvents({ agent })` to render retained and
267
+ replayed child timelines. AIChatAgent children run headlessly, so browser
268
+ client tools require a separate bridge; server-side tools work normally. See
269
+ the full [Agent Tools guide](../../docs/agent-tools.md).
270
+
225
271
  ### WebSocket Connections
226
272
 
227
273
  Handle real-time communication: