agents 0.0.0-197e86a → 0.0.0-1a3d226

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 (83) hide show
  1. package/README.md +255 -10
  2. package/dist/ai-chat-agent.d.ts +238 -31
  3. package/dist/ai-chat-agent.js +1118 -260
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration.d.ts +155 -0
  6. package/dist/ai-chat-v5-migration.js +155 -0
  7. package/dist/ai-chat-v5-migration.js.map +1 -0
  8. package/dist/ai-react.d.ts +197 -86
  9. package/dist/ai-react.js +574 -199
  10. package/dist/ai-react.js.map +1 -1
  11. package/dist/ai-types-0OnT3FHg.d.ts +127 -0
  12. package/dist/ai-types-DEtF_8Km.js +28 -0
  13. package/dist/ai-types-DEtF_8Km.js.map +1 -0
  14. package/dist/ai-types.d.ts +6 -74
  15. package/dist/ai-types.js +3 -1
  16. package/dist/cli/index.d.ts +1 -0
  17. package/dist/cli/index.js +28 -0
  18. package/dist/cli/index.js.map +1 -0
  19. package/dist/client-BINtT7y-.d.ts +834 -0
  20. package/dist/client-CdM5I962.d.ts +104 -0
  21. package/dist/client-DjTPRM8-.js +117 -0
  22. package/dist/client-DjTPRM8-.js.map +1 -0
  23. package/dist/client-QZa2Rq0l.js +1105 -0
  24. package/dist/client-QZa2Rq0l.js.map +1 -0
  25. package/dist/client.d.ts +10 -92
  26. package/dist/client.js +3 -11
  27. package/dist/codemode/ai.d.ts +27 -0
  28. package/dist/codemode/ai.js +151 -0
  29. package/dist/codemode/ai.js.map +1 -0
  30. package/dist/context-BkKbAa1R.js +8 -0
  31. package/dist/context-BkKbAa1R.js.map +1 -0
  32. package/dist/context-DcbQ8o7k.d.ts +24 -0
  33. package/dist/context.d.ts +6 -0
  34. package/dist/context.js +3 -0
  35. package/dist/do-oauth-client-provider--To1Tsjj.d.ts +70 -0
  36. package/dist/do-oauth-client-provider-B1fVIshX.js +155 -0
  37. package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
  38. package/dist/{index-BCJclX6q.d.ts → index-CfZ2mfMI.d.ts} +131 -170
  39. package/dist/index-DLuxm_9W.d.ts +58 -0
  40. package/dist/index.d.ts +66 -40
  41. package/dist/index.js +7 -28
  42. package/dist/mcp/client.d.ts +2 -11
  43. package/dist/mcp/client.js +4 -9
  44. package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
  45. package/dist/mcp/do-oauth-client-provider.js +3 -7
  46. package/dist/mcp/index.d.ts +197 -109
  47. package/dist/mcp/index.js +1429 -942
  48. package/dist/mcp/index.js.map +1 -1
  49. package/dist/mcp/x402.d.ts +34 -0
  50. package/dist/mcp/x402.js +198 -0
  51. package/dist/mcp/x402.js.map +1 -0
  52. package/dist/mcp-CPSfGUgd.d.ts +61 -0
  53. package/dist/observability/index.d.ts +2 -14
  54. package/dist/observability/index.js +7 -10
  55. package/dist/react.d.ts +48 -35
  56. package/dist/react.js +183 -110
  57. package/dist/react.js.map +1 -1
  58. package/dist/schedule.d.ts +61 -38
  59. package/dist/schedule.js +46 -21
  60. package/dist/schedule.js.map +1 -1
  61. package/dist/serializable-Crsj26mx.d.ts +39 -0
  62. package/dist/serializable.d.ts +7 -32
  63. package/dist/serializable.js +1 -1
  64. package/dist/src-BZDh910Z.js +1181 -0
  65. package/dist/src-BZDh910Z.js.map +1 -0
  66. package/package.json +93 -29
  67. package/dist/ai-types.js.map +0 -1
  68. package/dist/chunk-HY7ZLHJB.js +0 -598
  69. package/dist/chunk-HY7ZLHJB.js.map +0 -1
  70. package/dist/chunk-JXN5WZFQ.js +0 -1287
  71. package/dist/chunk-JXN5WZFQ.js.map +0 -1
  72. package/dist/chunk-KUH345EY.js +0 -116
  73. package/dist/chunk-KUH345EY.js.map +0 -1
  74. package/dist/chunk-PVQZBKN7.js +0 -106
  75. package/dist/chunk-PVQZBKN7.js.map +0 -1
  76. package/dist/client-DgyzBU_8.d.ts +0 -4601
  77. package/dist/client.js.map +0 -1
  78. package/dist/index.js.map +0 -1
  79. package/dist/mcp/client.js.map +0 -1
  80. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  81. package/dist/observability/index.js.map +0 -1
  82. package/dist/serializable.js.map +0 -1
  83. package/src/index.ts +0 -1917
@@ -1,103 +1,214 @@
1
- import * as ai from "ai";
2
- import { Message } from "ai";
3
- import { useChat } from "@ai-sdk/react";
1
+ import "./context-DcbQ8o7k.js";
2
+ import "./client-BINtT7y-.js";
3
+ import "./ai-types-0OnT3FHg.js";
4
+ import "./index-CfZ2mfMI.js";
5
+ import "./client-CdM5I962.js";
4
6
  import { useAgent } from "./react.js";
5
- import "partysocket";
6
- import "partysocket/react";
7
- import "./index-BCJclX6q.js";
8
- import "cloudflare:workers";
9
- import "@modelcontextprotocol/sdk/client/index.js";
10
- import "@modelcontextprotocol/sdk/types.js";
11
- import "partyserver";
12
- import "./client-DgyzBU_8.js";
13
- import "zod";
14
- import "@modelcontextprotocol/sdk/shared/protocol.js";
15
- import "@modelcontextprotocol/sdk/client/sse.js";
16
- import "@modelcontextprotocol/sdk/client/streamableHttp.js";
17
- import "./mcp/do-oauth-client-provider.js";
18
- import "@modelcontextprotocol/sdk/client/auth.js";
19
- import "@modelcontextprotocol/sdk/shared/auth.js";
20
- import "./client.js";
21
- import "./serializable.js";
7
+ import { ChatInit, JSONSchema7, Tool, UIMessage } from "ai";
8
+ import { UseChatOptions, useChat } from "@ai-sdk/react";
22
9
 
10
+ //#region src/ai-react.d.ts
11
+ /**
12
+ * JSON Schema type for tool parameters.
13
+ * Re-exported from the AI SDK for convenience.
14
+ * @deprecated Import JSONSchema7 directly from "ai" instead.
15
+ */
16
+ type JSONSchemaType = JSONSchema7;
17
+ /**
18
+ * Definition for a tool that can be executed on the client.
19
+ * Tools with an `execute` function are automatically registered with the server.
20
+ *
21
+ * Note: Uses `parameters` (JSONSchema7) rather than AI SDK's `inputSchema` (FlexibleSchema)
22
+ * because client tools must be serializable for the wire format. Zod schemas cannot be
23
+ * serialized, so we require raw JSON Schema here.
24
+ */
25
+ type AITool<Input = unknown, Output = unknown> = {
26
+ /** Human-readable description of what the tool does */
27
+ description?: Tool["description"];
28
+ /** JSON Schema defining the tool's input parameters */
29
+ parameters?: JSONSchema7;
30
+ /**
31
+ * @deprecated Use `parameters` instead. Will be removed in a future version.
32
+ */
33
+ inputSchema?: JSONSchema7;
34
+ /**
35
+ * Function to execute the tool on the client.
36
+ * If provided, the tool schema is automatically sent to the server.
37
+ */
38
+ execute?: (input: Input) => Output | Promise<Output>;
39
+ };
40
+ /**
41
+ * Schema for a client tool sent to the server.
42
+ * This is the wire format - what gets sent in the request body.
43
+ * Must match the server-side ClientToolSchema type in ai-chat-agent.ts.
44
+ */
45
+ type ClientToolSchema = {
46
+ /** Unique name for the tool */
47
+ name: string;
48
+ /** Human-readable description of what the tool does */
49
+ description?: Tool["description"];
50
+ /** JSON Schema defining the tool's input parameters */
51
+ parameters?: JSONSchema7;
52
+ };
53
+ /**
54
+ * Extracts tool schemas from tools that have client-side execute functions.
55
+ * These schemas are automatically sent to the server with each request.
56
+ * @param tools - Record of tool name to tool definition
57
+ * @returns Array of tool schemas to send to server, or undefined if none
58
+ */
59
+ declare function extractClientToolSchemas(
60
+ tools?: Record<string, AITool<unknown, unknown>>
61
+ ): ClientToolSchema[] | undefined;
23
62
  type GetInitialMessagesOptions = {
24
63
  agent: string;
25
64
  name: string;
26
65
  url: string;
27
66
  };
67
+ type UseChatParams<M extends UIMessage = UIMessage> = ChatInit<M> &
68
+ UseChatOptions<M>;
69
+ /**
70
+ * Options for preparing the send messages request.
71
+ * Used by prepareSendMessagesRequest callback.
72
+ */
73
+ type PrepareSendMessagesRequestOptions<
74
+ ChatMessage extends UIMessage = UIMessage
75
+ > = {
76
+ /** The chat ID */
77
+ id: string;
78
+ /** Messages to send */
79
+ messages: ChatMessage[];
80
+ /** What triggered this request */
81
+ trigger: "submit-message" | "regenerate-message";
82
+ /** ID of the message being sent (if applicable) */
83
+ messageId?: string;
84
+ /** Request metadata */
85
+ requestMetadata?: unknown;
86
+ /** Current body (if any) */
87
+ body?: Record<string, unknown>;
88
+ /** Current credentials (if any) */
89
+ credentials?: RequestCredentials;
90
+ /** Current headers (if any) */
91
+ headers?: HeadersInit;
92
+ /** API endpoint */
93
+ api?: string;
94
+ };
95
+ /**
96
+ * Return type for prepareSendMessagesRequest callback.
97
+ * Allows customizing headers, body, and credentials for each request.
98
+ * All fields are optional; only specify what you need to customize.
99
+ */
100
+ type PrepareSendMessagesRequestResult = {
101
+ /** Custom headers to send with the request */
102
+ headers?: HeadersInit;
103
+ /** Custom body data to merge with the request */
104
+ body?: Record<string, unknown>;
105
+ /** Custom credentials option */
106
+ credentials?: RequestCredentials;
107
+ /** Custom API endpoint */
108
+ api?: string;
109
+ };
28
110
  /**
29
111
  * Options for the useAgentChat hook
30
112
  */
31
- type UseAgentChatOptions<State> = Omit<
32
- Parameters<typeof useChat>[0] & {
33
- /** Agent connection from useAgent */
34
- agent: ReturnType<typeof useAgent<State>>;
35
- getInitialMessages?:
36
- | undefined
37
- | null
38
- | ((options: GetInitialMessagesOptions) => Promise<Message[]>);
39
- },
40
- "fetch"
41
- >;
113
+ type UseAgentChatOptions<
114
+ State,
115
+ ChatMessage extends UIMessage = UIMessage
116
+ > = Omit<UseChatParams<ChatMessage>, "fetch"> & {
117
+ /** Agent connection from useAgent */
118
+ agent: ReturnType<typeof useAgent<State>>;
119
+ getInitialMessages?:
120
+ | undefined
121
+ | null
122
+ | ((options: GetInitialMessagesOptions) => Promise<ChatMessage[]>);
123
+ /** Request credentials */
124
+ credentials?: RequestCredentials;
125
+ /** Request headers */
126
+ headers?: HeadersInit;
127
+ /**
128
+ * @description Whether to automatically resolve tool calls that do not require human interaction.
129
+ * @experimental
130
+ */
131
+ experimental_automaticToolResolution?: boolean;
132
+ /**
133
+ * Tools that can be executed on the client.
134
+ */
135
+ tools?: Record<string, AITool<unknown, unknown>>;
136
+ /**
137
+ * @description Manual override for tools requiring confirmation.
138
+ * If not provided, will auto-detect from tools object (tools without execute require confirmation).
139
+ */
140
+ toolsRequiringConfirmation?: string[];
141
+ /**
142
+ * When true, the server automatically continues the conversation after
143
+ * receiving client-side tool results, similar to how server-executed tools
144
+ * work with maxSteps in streamText. The continuation is merged into the
145
+ * same assistant message.
146
+ *
147
+ * When false (default), the client calls sendMessage() after tool results
148
+ * to continue the conversation, which creates a new assistant message.
149
+ *
150
+ * @default false
151
+ */
152
+ autoContinueAfterToolResult?: boolean;
153
+ /**
154
+ * When true (default), automatically sends the next message only after
155
+ * all pending confirmation-required tool calls have been resolved.
156
+ * When false, sends immediately after each tool result.
157
+ *
158
+ * Only applies when `autoContinueAfterToolResult` is false.
159
+ *
160
+ * @default true
161
+ */
162
+ autoSendAfterAllConfirmationsResolved?: boolean;
163
+ /**
164
+ * Set to false to disable automatic stream resumption.
165
+ * @default true
166
+ */
167
+ resume?: boolean;
168
+ /**
169
+ * Callback to customize the request before sending messages.
170
+ * Use this for advanced scenarios like adding custom headers or dynamic context.
171
+ *
172
+ * Note: Client tool schemas are automatically sent when tools have `execute` functions.
173
+ * This callback can add additional data alongside the auto-extracted schemas.
174
+ */
175
+ prepareSendMessagesRequest?: (
176
+ options: PrepareSendMessagesRequestOptions<ChatMessage>
177
+ ) =>
178
+ | PrepareSendMessagesRequestResult
179
+ | Promise<PrepareSendMessagesRequestResult>;
180
+ };
42
181
  /**
43
182
  * React hook for building AI chat interfaces using an Agent
44
183
  * @param options Chat options including the agent connection
45
184
  * @returns Chat interface controls and state with added clearHistory method
46
185
  */
47
- declare function useAgentChat<State = unknown>(
48
- options: UseAgentChatOptions<State>
49
- ): {
50
- /**
51
- * Clear chat history on both client and Agent
52
- */
186
+ /**
187
+ * Automatically detects which tools require confirmation based on their configuration.
188
+ * Tools require confirmation if they have no execute function AND are not server-executed.
189
+ * @param tools - Record of tool name to tool definition
190
+ * @returns Array of tool names that require confirmation
191
+ */
192
+ declare function detectToolsRequiringConfirmation(
193
+ tools?: Record<string, AITool<unknown, unknown>>
194
+ ): string[];
195
+ declare function useAgentChat<
196
+ State = unknown,
197
+ ChatMessage extends UIMessage = UIMessage
198
+ >(
199
+ options: UseAgentChatOptions<State, ChatMessage>
200
+ ): ReturnType<typeof useChat<ChatMessage>> & {
53
201
  clearHistory: () => void;
54
- /**
55
- * Set the chat messages and synchronize with the Agent
56
- * @param messages New messages to set
57
- */
58
- setMessages: (messages: Message[]) => void;
59
- messages: ai.UIMessage[];
60
- error: undefined | Error;
61
- append: (
62
- message: Message | ai.CreateMessage,
63
- chatRequestOptions?: ai.ChatRequestOptions
64
- ) => Promise<string | null | undefined>;
65
- reload: (
66
- chatRequestOptions?: ai.ChatRequestOptions
67
- ) => Promise<string | null | undefined>;
68
- stop: () => void;
69
- experimental_resume: () => void;
70
- input: string;
71
- setInput: React.Dispatch<React.SetStateAction<string>>;
72
- handleInputChange: (
73
- e:
74
- | React.ChangeEvent<HTMLInputElement>
75
- | React.ChangeEvent<HTMLTextAreaElement>
76
- ) => void;
77
- handleSubmit: (
78
- event?: {
79
- preventDefault?: () => void;
80
- },
81
- chatRequestOptions?: ai.ChatRequestOptions
82
- ) => void;
83
- metadata?: Object;
84
- isLoading: boolean;
85
- status: "submitted" | "streaming" | "ready" | "error";
86
- data?: ai.JSONValue[];
87
- setData: (
88
- data:
89
- | ai.JSONValue[]
90
- | undefined
91
- | ((data: ai.JSONValue[] | undefined) => ai.JSONValue[] | undefined)
92
- ) => void;
93
- id: string;
94
- addToolResult: ({
95
- toolCallId,
96
- result
97
- }: {
98
- toolCallId: string;
99
- result: any;
100
- }) => void;
101
202
  };
102
-
103
- export { useAgentChat };
203
+ //#endregion
204
+ export {
205
+ AITool,
206
+ ClientToolSchema,
207
+ JSONSchemaType,
208
+ PrepareSendMessagesRequestOptions,
209
+ PrepareSendMessagesRequestResult,
210
+ detectToolsRequiringConfirmation,
211
+ extractClientToolSchemas,
212
+ useAgentChat
213
+ };
214
+ //# sourceMappingURL=ai-react.d.ts.map