agents 0.0.0-c3e8618 → 0.0.0-c41ebbc

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 (76) 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 +78 -23
  5. package/dist/ai-chat-agent.js +657 -0
  6. package/dist/ai-chat-agent.js.map +1 -0
  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-chat-v5-migration.js.map +1 -0
  10. package/dist/ai-react.d.ts +86 -47
  11. package/dist/ai-react.js +356 -0
  12. package/dist/ai-react.js.map +1 -0
  13. package/dist/ai-types.d.ts +84 -41
  14. package/dist/ai-types.js +8 -0
  15. package/dist/ai-types.js.map +1 -0
  16. package/dist/ccip-CMBYN64O.js +15 -0
  17. package/dist/ccip-CMBYN64O.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-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-XGMKNUJA.js +1343 -0
  35. package/dist/chunk-XGMKNUJA.js.map +1 -0
  36. package/dist/chunk-ZMMHNOMZ.js +942 -0
  37. package/dist/chunk-ZMMHNOMZ.js.map +1 -0
  38. package/dist/client-D1Fa-xS_.d.ts +5120 -0
  39. package/dist/client.d.ts +71 -37
  40. package/dist/client.js +13 -0
  41. package/dist/client.js.map +1 -0
  42. package/dist/codemode/ai.d.ts +25 -0
  43. package/dist/codemode/ai.js +5200 -0
  44. package/dist/codemode/ai.js.map +1 -0
  45. package/dist/index.d.ts +479 -181
  46. package/dist/index.js +32 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/mcp/client.d.ts +12 -675
  49. package/dist/mcp/client.js +10 -0
  50. package/dist/mcp/client.js.map +1 -0
  51. package/dist/mcp/do-oauth-client-provider.d.ts +42 -0
  52. package/dist/mcp/do-oauth-client-provider.js +8 -0
  53. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  54. package/dist/mcp/index.d.ts +71 -33
  55. package/dist/mcp/index.js +1099 -0
  56. package/dist/mcp/index.js.map +1 -0
  57. package/dist/mcp/x402.d.ts +39 -0
  58. package/dist/mcp/x402.js +3195 -0
  59. package/dist/mcp/x402.js.map +1 -0
  60. package/dist/mcp-BH1fJeiU.d.ts +58 -0
  61. package/dist/observability/index.d.ts +34 -0
  62. package/dist/observability/index.js +12 -0
  63. package/dist/observability/index.js.map +1 -0
  64. package/dist/react.d.ts +115 -18
  65. package/dist/react.js +216 -0
  66. package/dist/react.js.map +1 -0
  67. package/dist/schedule.d.ts +106 -22
  68. package/dist/schedule.js +86 -0
  69. package/dist/schedule.js.map +1 -0
  70. package/dist/secp256k1-M22GZP2U.js +2193 -0
  71. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  72. package/dist/serializable.d.ts +32 -0
  73. package/dist/serializable.js +1 -0
  74. package/dist/serializable.js.map +1 -0
  75. package/package.json +103 -52
  76. package/src/index.ts +1268 -156
@@ -1,31 +1,86 @@
1
- import { Agent, AgentContext } from './index.js';
2
- import { Message, StreamTextOnFinishCallback, ToolSet } from 'ai';
3
- import { Connection, WSMessage } from 'partyserver';
4
- import 'node:async_hooks';
5
- import 'cloudflare:workers';
1
+ import { UIMessage, StreamTextOnFinishCallback, ToolSet } from "ai";
2
+ import { Agent, AgentContext } from "./index.js";
3
+ import { Connection, WSMessage } from "partyserver";
4
+ import "cloudflare:workers";
5
+ import "@modelcontextprotocol/sdk/client/index.js";
6
+ import "@modelcontextprotocol/sdk/types.js";
7
+ import "./client-D1Fa-xS_.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";
6
18
 
7
19
  /**
8
20
  * Extension of Agent with built-in chat capabilities
9
21
  * @template Env Environment type containing bindings
10
22
  */
11
- declare class AIChatAgent<Env = unknown, State = unknown> extends Agent<Env, State> {
12
- #private;
13
- /** Array of chat messages for the current conversation */
14
- messages: Message[];
15
- constructor(ctx: AgentContext, env: Env);
16
- onMessage(connection: Connection, message: WSMessage): Promise<void>;
17
- onRequest(request: Request): Promise<Response>;
18
- /**
19
- * Handle incoming chat messages and generate a response
20
- * @param onFinish Callback to be called when the response is finished
21
- * @returns Response to send to the client or undefined
22
- */
23
- onChatMessage(onFinish: StreamTextOnFinishCallback<ToolSet>): Promise<Response | undefined>;
24
- /**
25
- * Save messages on the server side and trigger AI response
26
- * @param messages Chat messages to save
27
- */
28
- saveMessages(messages: Message[]): Promise<void>;
23
+ declare class AIChatAgent<Env = unknown, State = unknown> extends Agent<
24
+ Env,
25
+ State
26
+ > {
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;
32
+ /** Array of chat messages for the current conversation */
33
+ messages: UIMessage[];
34
+ constructor(ctx: AgentContext, env: Env);
35
+ private _broadcastChatMessage;
36
+ onMessage(connection: Connection, message: WSMessage): Promise<void>;
37
+ onRequest(request: Request): Promise<Response>;
38
+ private _tryCatchChat;
39
+ /**
40
+ * Handle incoming chat messages and generate a response
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
43
+ * @returns Response to send to the client or undefined
44
+ */
45
+ onChatMessage(
46
+ onFinish: StreamTextOnFinishCallback<ToolSet>,
47
+ options?: {
48
+ abortSignal: AbortSignal | undefined;
49
+ }
50
+ ): Promise<Response | undefined>;
51
+ /**
52
+ * Save messages on the server side
53
+ * @param messages Chat messages to save
54
+ */
55
+ saveMessages(messages: UIMessage[]): Promise<void>;
56
+ persistMessages(
57
+ messages: UIMessage[],
58
+ excludeBroadcastIds?: string[]
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>;
29
84
  }
30
85
 
31
86
  export { AIChatAgent };