agents 0.0.0-b4ebb44 → 0.0.0-b507395

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 +257 -27
  2. package/dist/ai-chat-agent.d.ts +104 -19
  3. package/dist/ai-chat-agent.js +812 -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 +79 -85
  10. package/dist/ai-react.js +411 -199
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-CwgHzwUb.js +24 -0
  13. package/dist/ai-types-CwgHzwUb.js.map +1 -0
  14. package/dist/ai-types-D_hTbf25.d.ts +103 -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-CcyhkGfN.js +117 -0
  21. package/dist/client-CcyhkGfN.js.map +1 -0
  22. package/dist/client-ClORm6f0.d.ts +104 -0
  23. package/dist/client-DfIOsabL.d.ts +834 -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-CyDpAVHZ.d.ts +58 -0
  40. package/dist/index-DPJ32qQn.d.ts +577 -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 +191 -81
  48. package/dist/mcp/index.js +1435 -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-MaOSl7Pr.d.ts +113 -0
  57. package/dist/react.d.ts +11 -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-BmbDclOA.js +1181 -0
  67. package/dist/src-BmbDclOA.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,95 @@
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-DfIOsabL.js";
3
+ import "./mcp-CzbSsLfc.js";
4
+ import "./do-oauth-client-provider-B-ryFIPr.js";
5
+ import "./index-CyDpAVHZ.js";
6
+ import "./ai-types-D_hTbf25.js";
7
+ import "./index-DPJ32qQn.js";
8
+ import "./serializable-C4GLimgv.js";
9
+ import "./client-ClORm6f0.js";
10
+ import { n as useAgent } from "./react-MaOSl7Pr.js";
11
+ import { UseChatOptions, useChat } from "@ai-sdk/react";
12
+ import { ChatInit, UIMessage } from "ai";
20
13
 
14
+ //#region src/ai-react.d.ts
15
+ type AITool<Input = unknown, Output = unknown> = {
16
+ description?: string;
17
+ inputSchema?: unknown;
18
+ execute?: (input: Input) => Output | Promise<Output>;
19
+ };
21
20
  type GetInitialMessagesOptions = {
22
21
  agent: string;
23
22
  name: string;
24
23
  url: string;
25
24
  };
25
+ type UseChatParams<M extends UIMessage = UIMessage> = ChatInit<M> &
26
+ UseChatOptions<M>;
26
27
  /**
27
28
  * Options for the useAgentChat hook
28
29
  */
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
- >;
30
+ type UseAgentChatOptions<
31
+ State,
32
+ ChatMessage extends UIMessage = UIMessage
33
+ > = Omit<UseChatParams<ChatMessage>, "fetch"> & {
34
+ /** Agent connection from useAgent */
35
+ agent: ReturnType<typeof useAgent<State>>;
36
+ getInitialMessages?:
37
+ | undefined
38
+ | null
39
+ | ((options: GetInitialMessagesOptions) => Promise<ChatMessage[]>);
40
+ /** Request credentials */
41
+ credentials?: RequestCredentials;
42
+ /** Request headers */
43
+ headers?: HeadersInit;
44
+ /**
45
+ * @description Whether to automatically resolve tool calls that do not require human interaction.
46
+ * @experimental
47
+ */
48
+ experimental_automaticToolResolution?: boolean;
49
+ /**
50
+ * @description Tools object for automatic detection of confirmation requirements.
51
+ * Tools without execute function will require confirmation.
52
+ */
53
+ tools?: Record<string, AITool<unknown, unknown>>;
54
+ /**
55
+ * @description Manual override for tools requiring confirmation.
56
+ * If not provided, will auto-detect from tools object.
57
+ */
58
+ toolsRequiringConfirmation?: string[];
59
+ /**
60
+ * When true (default), automatically sends the next message only after
61
+ * all pending confirmation-required tool calls have been resolved.
62
+ * @default true
63
+ */
64
+ autoSendAfterAllConfirmationsResolved?: boolean;
65
+ /**
66
+ * Set to false to disable automatic stream resumption.
67
+ * @default true
68
+ */
69
+ resume?: boolean;
70
+ };
40
71
  /**
41
72
  * React hook for building AI chat interfaces using an Agent
42
73
  * @param options Chat options including the agent connection
43
74
  * @returns Chat interface controls and state with added clearHistory method
44
75
  */
45
- declare function useAgentChat<State = unknown>(
46
- options: UseAgentChatOptions<State>
47
- ): {
48
- /**
49
- * Clear chat history on both client and Agent
50
- */
76
+ /**
77
+ * Automatically detects which tools require confirmation based on their configuration.
78
+ * Tools require confirmation if they have no execute function AND are not server-executed.
79
+ * @param tools - Record of tool name to tool definition
80
+ * @returns Array of tool names that require confirmation
81
+ */
82
+ declare function detectToolsRequiringConfirmation(
83
+ tools?: Record<string, AITool<unknown, unknown>>
84
+ ): string[];
85
+ declare function useAgentChat<
86
+ State = unknown,
87
+ ChatMessage extends UIMessage = UIMessage
88
+ >(
89
+ options: UseAgentChatOptions<State, ChatMessage>
90
+ ): ReturnType<typeof useChat<ChatMessage>> & {
51
91
  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
92
  };
100
-
101
- export { useAgentChat };
93
+ //#endregion
94
+ export { AITool, detectToolsRequiringConfirmation, useAgentChat };
95
+ //# sourceMappingURL=ai-react.d.ts.map