agents 0.0.0-7978d71 → 0.0.0-79843bd

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