agents 0.0.0-d40512c → 0.0.0-d520fe8

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 (79) hide show
  1. package/README.md +236 -6
  2. package/dist/ai-chat-agent.d.ts +95 -20
  3. package/dist/ai-chat-agent.js +798 -260
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration-BSiGZmYU.js +155 -0
  6. package/dist/ai-chat-v5-migration-BSiGZmYU.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 +78 -85
  10. package/dist/ai-react.js +396 -199
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-81H_-Uxh.d.ts +103 -0
  13. package/dist/ai-types-CrMqkwc_.js +24 -0
  14. package/dist/ai-types-CrMqkwc_.js.map +1 -0
  15. package/dist/ai-types.d.ts +6 -74
  16. package/dist/ai-types.js +3 -1
  17. package/dist/cli.d.ts +8 -0
  18. package/dist/cli.js +27 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/client-B3SR12TQ.js +117 -0
  21. package/dist/client-B3SR12TQ.js.map +1 -0
  22. package/dist/client-BAQA84dr.d.ts +104 -0
  23. package/dist/client-BZq9qau2.js +1093 -0
  24. package/dist/client-BZq9qau2.js.map +1 -0
  25. package/dist/client-CsaP9Irq.d.ts +1528 -0
  26. package/dist/client.d.ts +11 -92
  27. package/dist/client.js +4 -11
  28. package/dist/codemode/ai.d.ts +27 -0
  29. package/dist/codemode/ai.js +151 -0
  30. package/dist/codemode/ai.js.map +1 -0
  31. package/dist/do-oauth-client-provider-C2CHH5x-.d.ts +55 -0
  32. package/dist/do-oauth-client-provider-CwqK5SXm.js +94 -0
  33. package/dist/do-oauth-client-provider-CwqK5SXm.js.map +1 -0
  34. package/dist/index-BUle9RiP.d.ts +58 -0
  35. package/dist/{index-CITGJflw.d.ts → index-Bx5KK3VJ.d.ts} +256 -155
  36. package/dist/index.d.ts +69 -30
  37. package/dist/index.js +7 -22
  38. package/dist/mcp/client.d.ts +4 -1055
  39. package/dist/mcp/client.js +4 -9
  40. package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
  41. package/dist/mcp/do-oauth-client-provider.js +3 -7
  42. package/dist/mcp/index.d.ts +190 -81
  43. package/dist/mcp/index.js +1434 -770
  44. package/dist/mcp/index.js.map +1 -1
  45. package/dist/mcp/x402.d.ts +34 -0
  46. package/dist/mcp/x402.js +198 -0
  47. package/dist/mcp/x402.js.map +1 -0
  48. package/dist/mcp-BwPscEiF.d.ts +61 -0
  49. package/dist/observability/index.d.ts +3 -12
  50. package/dist/observability/index.js +7 -10
  51. package/dist/react-CbwD4fBf.d.ts +113 -0
  52. package/dist/react.d.ts +10 -119
  53. package/dist/react.js +183 -110
  54. package/dist/react.js.map +1 -1
  55. package/dist/schedule.d.ts +91 -14
  56. package/dist/schedule.js +46 -21
  57. package/dist/schedule.js.map +1 -1
  58. package/dist/serializable-faDkMCai.d.ts +39 -0
  59. package/dist/serializable.d.ts +7 -32
  60. package/dist/serializable.js +1 -1
  61. package/dist/src-D_KKH_4c.js +1184 -0
  62. package/dist/src-D_KKH_4c.js.map +1 -0
  63. package/package.json +78 -28
  64. package/dist/ai-types.js.map +0 -1
  65. package/dist/chunk-4RBEYCWK.js +0 -469
  66. package/dist/chunk-4RBEYCWK.js.map +0 -1
  67. package/dist/chunk-KUH345EY.js +0 -116
  68. package/dist/chunk-KUH345EY.js.map +0 -1
  69. package/dist/chunk-LU2RSO54.js +0 -910
  70. package/dist/chunk-LU2RSO54.js.map +0 -1
  71. package/dist/chunk-PVQZBKN7.js +0 -106
  72. package/dist/chunk-PVQZBKN7.js.map +0 -1
  73. package/dist/client.js.map +0 -1
  74. package/dist/index.js.map +0 -1
  75. package/dist/mcp/client.js.map +0 -1
  76. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  77. package/dist/observability/index.js.map +0 -1
  78. package/dist/serializable.js.map +0 -1
  79. package/src/index.ts +0 -1365
@@ -1,101 +1,94 @@
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-CITGJflw.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 "./client-CsaP9Irq.js";
2
+ import "./mcp-BwPscEiF.js";
3
+ import "./do-oauth-client-provider-C2CHH5x-.js";
4
+ import "./index-BUle9RiP.js";
5
+ import "./ai-types-81H_-Uxh.js";
6
+ import "./index-Bx5KK3VJ.js";
7
+ import "./serializable-faDkMCai.js";
8
+ import "./client-BAQA84dr.js";
9
+ import { n as useAgent } from "./react-CbwD4fBf.js";
10
+ import { UseChatOptions, useChat } from "@ai-sdk/react";
11
+ import { ChatInit, UIMessage } from "ai";
20
12
 
13
+ //#region src/ai-react.d.ts
14
+ type AITool<Input = unknown, Output = unknown> = {
15
+ description?: string;
16
+ inputSchema?: unknown;
17
+ execute?: (input: Input) => Output | Promise<Output>;
18
+ };
21
19
  type GetInitialMessagesOptions = {
22
20
  agent: string;
23
21
  name: string;
24
22
  url: string;
25
23
  };
24
+ type UseChatParams<M extends UIMessage = UIMessage> = ChatInit<M> &
25
+ UseChatOptions<M>;
26
26
  /**
27
27
  * Options for the useAgentChat hook
28
28
  */
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
- >;
29
+ type UseAgentChatOptions<
30
+ State,
31
+ ChatMessage extends UIMessage = UIMessage
32
+ > = Omit<UseChatParams<ChatMessage>, "fetch"> & {
33
+ /** Agent connection from useAgent */
34
+ agent: ReturnType<typeof useAgent<State>>;
35
+ getInitialMessages?:
36
+ | undefined
37
+ | null
38
+ | ((options: GetInitialMessagesOptions) => Promise<ChatMessage[]>);
39
+ /** Request credentials */
40
+ credentials?: RequestCredentials;
41
+ /** Request headers */
42
+ headers?: HeadersInit;
43
+ /**
44
+ * @description Whether to automatically resolve tool calls that do not require human interaction.
45
+ * @experimental
46
+ */
47
+ experimental_automaticToolResolution?: boolean;
48
+ /**
49
+ * @description Tools object for automatic detection of confirmation requirements.
50
+ * Tools without execute function will require confirmation.
51
+ */
52
+ tools?: Record<string, AITool<unknown, unknown>>;
53
+ /**
54
+ * @description Manual override for tools requiring confirmation.
55
+ * If not provided, will auto-detect from tools object.
56
+ */
57
+ toolsRequiringConfirmation?: string[];
58
+ /**
59
+ * When true (default), automatically sends the next message only after
60
+ * all pending confirmation-required tool calls have been resolved.
61
+ * @default true
62
+ */
63
+ autoSendAfterAllConfirmationsResolved?: boolean;
64
+ /**
65
+ * Set to false to disable automatic stream resumption.
66
+ * @default true
67
+ */
68
+ resume?: boolean;
69
+ };
40
70
  /**
41
71
  * React hook for building AI chat interfaces using an Agent
42
72
  * @param options Chat options including the agent connection
43
73
  * @returns Chat interface controls and state with added clearHistory method
44
74
  */
45
- declare function useAgentChat<State = unknown>(
46
- options: UseAgentChatOptions<State>
47
- ): {
48
- /**
49
- * Clear chat history on both client and Agent
50
- */
75
+ /**
76
+ * Automatically detects which tools require confirmation based on their configuration.
77
+ * Tools require confirmation if they have no execute function AND are not server-executed.
78
+ * @param tools - Record of tool name to tool definition
79
+ * @returns Array of tool names that require confirmation
80
+ */
81
+ declare function detectToolsRequiringConfirmation(
82
+ tools?: Record<string, AITool<unknown, unknown>>
83
+ ): string[];
84
+ declare function useAgentChat<
85
+ State = unknown,
86
+ ChatMessage extends UIMessage = UIMessage
87
+ >(
88
+ options: UseAgentChatOptions<State, ChatMessage>
89
+ ): ReturnType<typeof useChat<ChatMessage>> & {
51
90
  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
91
  };
100
-
101
- export { useAgentChat };
92
+ //#endregion
93
+ export { AITool, detectToolsRequiringConfirmation, useAgentChat };
94
+ //# sourceMappingURL=ai-react.d.ts.map