agents 0.0.0-ad0054b → 0.0.0-afd9efd

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 (78) 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 +42 -10
  5. package/dist/ai-chat-agent.js +603 -150
  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 +254 -108
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types.d.ts +37 -19
  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-2Y6KNRNP.js +1343 -0
  17. package/dist/chunk-2Y6KNRNP.js.map +1 -0
  18. package/dist/chunk-5Y6BEZDY.js +276 -0
  19. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  20. package/dist/chunk-BER7KXUJ.js +18 -0
  21. package/dist/chunk-BER7KXUJ.js.map +1 -0
  22. package/dist/chunk-C2OEBJZ2.js +113 -0
  23. package/dist/chunk-C2OEBJZ2.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-QUOGV3WN.js +949 -0
  31. package/dist/chunk-QUOGV3WN.js.map +1 -0
  32. package/dist/chunk-TYAY6AU6.js +159 -0
  33. package/dist/chunk-TYAY6AU6.js.map +1 -0
  34. package/dist/chunk-UJVEAURM.js +150 -0
  35. package/dist/chunk-UJVEAURM.js.map +1 -0
  36. package/dist/client-C8tswVoM.d.ts +5248 -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 +5200 -0
  42. package/dist/codemode/ai.js.map +1 -0
  43. package/dist/index.d.ts +269 -26
  44. package/dist/index.js +14 -3
  45. package/dist/mcp/client.d.ts +10 -775
  46. package/dist/mcp/client.js +2 -2
  47. package/dist/mcp/do-oauth-client-provider.d.ts +4 -3
  48. package/dist/mcp/do-oauth-client-provider.js +4 -103
  49. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  50. package/dist/mcp/index.d.ts +64 -59
  51. package/dist/mcp/index.js +992 -685
  52. package/dist/mcp/index.js.map +1 -1
  53. package/dist/mcp/x402.d.ts +39 -0
  54. package/dist/mcp/x402.js +3195 -0
  55. package/dist/mcp/x402.js.map +1 -0
  56. package/dist/mcp-BH1fJeiU.d.ts +58 -0
  57. package/dist/observability/index.d.ts +34 -0
  58. package/dist/observability/index.js +12 -0
  59. package/dist/observability/index.js.map +1 -0
  60. package/dist/react.d.ts +97 -9
  61. package/dist/react.js +123 -11
  62. package/dist/react.js.map +1 -1
  63. package/dist/schedule.d.ts +81 -7
  64. package/dist/schedule.js +20 -7
  65. package/dist/schedule.js.map +1 -1
  66. package/dist/secp256k1-M22GZP2U.js +2193 -0
  67. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  68. package/dist/serializable.d.ts +32 -0
  69. package/dist/serializable.js +1 -0
  70. package/dist/serializable.js.map +1 -0
  71. package/package.json +103 -67
  72. package/src/index.ts +1245 -156
  73. package/dist/chunk-A65CRW2D.js +0 -609
  74. package/dist/chunk-A65CRW2D.js.map +0 -1
  75. package/dist/chunk-HMLY7DHA.js +0 -16
  76. package/dist/chunk-Q5ZBHY4Z.js +0 -456
  77. package/dist/chunk-Q5ZBHY4Z.js.map +0 -1
  78. /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
@@ -1,15 +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 "./mcp/client.js";
5
- import "zod";
6
- import "@modelcontextprotocol/sdk/types.js";
4
+ import "cloudflare:workers";
7
5
  import "@modelcontextprotocol/sdk/client/index.js";
6
+ import "@modelcontextprotocol/sdk/types.js";
7
+ import "./client-C8tswVoM.js";
8
+ import "zod";
9
+ import "@modelcontextprotocol/sdk/shared/protocol.js";
10
+ import "./mcp-BH1fJeiU.js";
8
11
  import "@modelcontextprotocol/sdk/client/sse.js";
12
+ import "@modelcontextprotocol/sdk/client/streamableHttp.js";
9
13
  import "./mcp/do-oauth-client-provider.js";
10
14
  import "@modelcontextprotocol/sdk/client/auth.js";
11
15
  import "@modelcontextprotocol/sdk/shared/auth.js";
12
- import "@modelcontextprotocol/sdk/shared/protocol.js";
16
+ import "./observability/index.js";
17
+ import "./ai-types.js";
13
18
 
14
19
  /**
15
20
  * Extension of Agent with built-in chat capabilities
@@ -19,12 +24,19 @@ declare class AIChatAgent<Env = unknown, State = unknown> extends Agent<
19
24
  Env,
20
25
  State
21
26
  > {
22
- #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;
23
32
  /** Array of chat messages for the current conversation */
24
- messages: Message[];
33
+ messages: UIMessage[];
25
34
  constructor(ctx: AgentContext, env: Env);
35
+ private _broadcastChatMessage;
36
+ private _loadMessagesFromDb;
26
37
  onMessage(connection: Connection, message: WSMessage): Promise<void>;
27
38
  onRequest(request: Request): Promise<Response>;
39
+ private _tryCatchChat;
28
40
  /**
29
41
  * Handle incoming chat messages and generate a response
30
42
  * @param onFinish Callback to be called when the response is finished
@@ -38,14 +50,34 @@ declare class AIChatAgent<Env = unknown, State = unknown> extends Agent<
38
50
  }
39
51
  ): Promise<Response | undefined>;
40
52
  /**
41
- * Save messages on the server side and trigger AI response
53
+ * Save messages on the server side
42
54
  * @param messages Chat messages to save
43
55
  */
44
- saveMessages(messages: Message[]): Promise<void>;
56
+ saveMessages(messages: UIMessage[]): Promise<void>;
45
57
  persistMessages(
46
- messages: Message[],
58
+ messages: UIMessage[],
47
59
  excludeBroadcastIds?: string[]
48
60
  ): Promise<void>;
61
+ private _reply;
62
+ /**
63
+ * For the given message id, look up its associated AbortController
64
+ * If the AbortController does not exist, create and store one in memory
65
+ *
66
+ * returns the AbortSignal associated with the AbortController
67
+ */
68
+ private _getAbortSignal;
69
+ /**
70
+ * Remove an abort controller from the cache of pending message responses
71
+ */
72
+ private _removeAbortController;
73
+ /**
74
+ * Propagate an abort signal for any requests associated with the given message id
75
+ */
76
+ private _cancelChatRequest;
77
+ /**
78
+ * Abort all pending requests and clear the cache of AbortControllers
79
+ */
80
+ private _destroyAbortControllers;
49
81
  /**
50
82
  * When the DO is destroyed, cancel all pending requests
51
83
  */