agents 0.0.0-f5b5854 → 0.0.0-f6b2319

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 (77) hide show
  1. package/README.md +255 -27
  2. package/dist/_esm-LV5FJ3HK.js +3922 -0
  3. package/dist/_esm-LV5FJ3HK.js.map +1 -0
  4. package/dist/ai-chat-agent.d.ts +55 -8
  5. package/dist/ai-chat-agent.js +574 -90
  6. package/dist/ai-chat-agent.js.map +1 -1
  7. package/dist/ai-chat-v5-migration.d.ts +152 -0
  8. package/dist/ai-chat-v5-migration.js +20 -0
  9. package/dist/ai-react.d.ts +78 -67
  10. package/dist/ai-react.js +273 -109
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types.d.ts +41 -18
  13. package/dist/ai-types.js +7 -0
  14. package/dist/ccip-CMBYN64O.js +15 -0
  15. package/dist/ccip-CMBYN64O.js.map +1 -0
  16. package/dist/chunk-254F4GDT.js +1343 -0
  17. package/dist/chunk-254F4GDT.js.map +1 -0
  18. package/dist/chunk-3OT2NNEW.js +941 -0
  19. package/dist/chunk-3OT2NNEW.js.map +1 -0
  20. package/dist/chunk-5Y6BEZDY.js +276 -0
  21. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  22. package/dist/chunk-BER7KXUJ.js +18 -0
  23. package/dist/chunk-BER7KXUJ.js.map +1 -0
  24. package/dist/chunk-JJBFIGUC.js +5202 -0
  25. package/dist/chunk-JJBFIGUC.js.map +1 -0
  26. package/dist/chunk-PR4QN5HX.js +43 -0
  27. package/dist/chunk-PR4QN5HX.js.map +1 -0
  28. package/dist/chunk-QEVM4BVL.js +116 -0
  29. package/dist/chunk-QEVM4BVL.js.map +1 -0
  30. package/dist/chunk-TYAY6AU6.js +159 -0
  31. package/dist/chunk-TYAY6AU6.js.map +1 -0
  32. package/dist/chunk-UJVEAURM.js +150 -0
  33. package/dist/chunk-UJVEAURM.js.map +1 -0
  34. package/dist/chunk-Z44WASMA.js +114 -0
  35. package/dist/chunk-Z44WASMA.js.map +1 -0
  36. package/dist/client-DVoPb3-C.d.ts +5120 -0
  37. package/dist/client.d.ts +16 -2
  38. package/dist/client.js +8 -126
  39. package/dist/client.js.map +1 -1
  40. package/dist/codemode/ai.d.ts +25 -0
  41. package/dist/codemode/ai.js +5109 -0
  42. package/dist/codemode/ai.js.map +1 -0
  43. package/dist/index.d.ts +277 -22
  44. package/dist/index.js +18 -6
  45. package/dist/mcp/client.d.ts +10 -761
  46. package/dist/mcp/client.js +4 -402
  47. package/dist/mcp/client.js.map +1 -1
  48. package/dist/mcp/do-oauth-client-provider.d.ts +4 -3
  49. package/dist/mcp/do-oauth-client-provider.js +4 -103
  50. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  51. package/dist/mcp/index.d.ts +69 -51
  52. package/dist/mcp/index.js +982 -661
  53. package/dist/mcp/index.js.map +1 -1
  54. package/dist/mcp/x402.d.ts +39 -0
  55. package/dist/mcp/x402.js +3195 -0
  56. package/dist/mcp/x402.js.map +1 -0
  57. package/dist/mcp-BH1fJeiU.d.ts +58 -0
  58. package/dist/observability/index.d.ts +34 -0
  59. package/dist/observability/index.js +12 -0
  60. package/dist/observability/index.js.map +1 -0
  61. package/dist/react.d.ts +97 -9
  62. package/dist/react.js +123 -11
  63. package/dist/react.js.map +1 -1
  64. package/dist/schedule.d.ts +81 -7
  65. package/dist/schedule.js +20 -7
  66. package/dist/schedule.js.map +1 -1
  67. package/dist/secp256k1-M22GZP2U.js +2193 -0
  68. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  69. package/dist/serializable.d.ts +32 -0
  70. package/dist/serializable.js +1 -0
  71. package/dist/serializable.js.map +1 -0
  72. package/package.json +98 -64
  73. package/src/index.ts +1271 -152
  74. package/dist/chunk-HMLY7DHA.js +0 -16
  75. package/dist/chunk-XG52S6YY.js +0 -591
  76. package/dist/chunk-XG52S6YY.js.map +0 -1
  77. /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
@@ -1,7 +1,20 @@
1
+ import { UIMessage, StreamTextOnFinishCallback, ToolSet } from "ai";
1
2
  import { Agent, AgentContext } from "./index.js";
2
- import { Message, StreamTextOnFinishCallback, ToolSet } from "ai";
3
3
  import { Connection, WSMessage } from "partyserver";
4
- import "node:async_hooks";
4
+ import "cloudflare:workers";
5
+ import "@modelcontextprotocol/sdk/client/index.js";
6
+ import "@modelcontextprotocol/sdk/types.js";
7
+ import "./client-DVoPb3-C.js";
8
+ import "zod";
9
+ import "@modelcontextprotocol/sdk/shared/protocol.js";
10
+ import "./mcp-BH1fJeiU.js";
11
+ import "@modelcontextprotocol/sdk/client/sse.js";
12
+ import "@modelcontextprotocol/sdk/client/streamableHttp.js";
13
+ import "./mcp/do-oauth-client-provider.js";
14
+ import "@modelcontextprotocol/sdk/client/auth.js";
15
+ import "@modelcontextprotocol/sdk/shared/auth.js";
16
+ import "./observability/index.js";
17
+ import "./ai-types.js";
5
18
 
6
19
  /**
7
20
  * Extension of Agent with built-in chat capabilities
@@ -11,29 +24,63 @@ declare class AIChatAgent<Env = unknown, State = unknown> extends Agent<
11
24
  Env,
12
25
  State
13
26
  > {
14
- #private;
27
+ /**
28
+ * Map of message `id`s to `AbortController`s
29
+ * useful to propagate request cancellation signals for any external calls made by the agent
30
+ */
31
+ private _chatMessageAbortControllers;
15
32
  /** Array of chat messages for the current conversation */
16
- messages: Message[];
33
+ messages: UIMessage[];
17
34
  constructor(ctx: AgentContext, env: Env);
35
+ private _broadcastChatMessage;
18
36
  onMessage(connection: Connection, message: WSMessage): Promise<void>;
19
37
  onRequest(request: Request): Promise<Response>;
38
+ private _tryCatchChat;
20
39
  /**
21
40
  * Handle incoming chat messages and generate a response
22
41
  * @param onFinish Callback to be called when the response is finished
42
+ * @param options.signal A signal to pass to any child requests which can be used to cancel them
23
43
  * @returns Response to send to the client or undefined
24
44
  */
25
45
  onChatMessage(
26
- onFinish: StreamTextOnFinishCallback<ToolSet>
46
+ onFinish: StreamTextOnFinishCallback<ToolSet>,
47
+ options?: {
48
+ abortSignal: AbortSignal | undefined;
49
+ }
27
50
  ): Promise<Response | undefined>;
28
51
  /**
29
- * Save messages on the server side and trigger AI response
52
+ * Save messages on the server side
30
53
  * @param messages Chat messages to save
31
54
  */
32
- saveMessages(messages: Message[]): Promise<void>;
55
+ saveMessages(messages: UIMessage[]): Promise<void>;
33
56
  persistMessages(
34
- messages: Message[],
57
+ messages: UIMessage[],
35
58
  excludeBroadcastIds?: string[]
36
59
  ): Promise<void>;
60
+ private _reply;
61
+ /**
62
+ * For the given message id, look up its associated AbortController
63
+ * If the AbortController does not exist, create and store one in memory
64
+ *
65
+ * returns the AbortSignal associated with the AbortController
66
+ */
67
+ private _getAbortSignal;
68
+ /**
69
+ * Remove an abort controller from the cache of pending message responses
70
+ */
71
+ private _removeAbortController;
72
+ /**
73
+ * Propagate an abort signal for any requests associated with the given message id
74
+ */
75
+ private _cancelChatRequest;
76
+ /**
77
+ * Abort all pending requests and clear the cache of AbortControllers
78
+ */
79
+ private _destroyAbortControllers;
80
+ /**
81
+ * When the DO is destroyed, cancel all pending requests
82
+ */
83
+ destroy(): Promise<void>;
37
84
  }
38
85
 
39
86
  export { AIChatAgent };