agents 0.0.0-d045755 → 0.0.0-d08612f

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 +257 -27
  2. package/dist/ai-chat-agent.d.ts +142 -12
  3. package/dist/ai-chat-agent.js +812 -159
  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 -72
  10. package/dist/ai-react.js +411 -185
  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 -69
  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 -79
  27. package/dist/client.js +3 -137
  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 +63 -302
  42. package/dist/index.js +8 -22
  43. package/dist/mcp/client.d.ts +4 -0
  44. package/dist/mcp/client.js +4 -0
  45. package/dist/mcp/do-oauth-client-provider.d.ts +2 -0
  46. package/dist/mcp/do-oauth-client-provider.js +3 -0
  47. package/dist/mcp/index.d.ts +194 -0
  48. package/dist/mcp/index.js +1448 -0
  49. package/dist/mcp/index.js.map +1 -0
  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-DTzwSLAh.d.ts +137 -0
  57. package/dist/react.d.ts +15 -39
  58. package/dist/react.js +192 -93
  59. package/dist/react.js.map +1 -1
  60. package/dist/schedule.d.ts +89 -12
  61. package/dist/schedule.js +46 -23
  62. package/dist/schedule.js.map +1 -1
  63. package/dist/serializable-C4GLimgv.d.ts +39 -0
  64. package/dist/serializable.d.ts +7 -0
  65. package/dist/serializable.js +1 -0
  66. package/dist/src-BmbDclOA.js +1181 -0
  67. package/dist/src-BmbDclOA.js.map +1 -0
  68. package/package.json +133 -51
  69. package/dist/ai-types.js.map +0 -1
  70. package/dist/chunk-3PRPPPJY.js +0 -596
  71. package/dist/chunk-3PRPPPJY.js.map +0 -1
  72. package/dist/chunk-HMLY7DHA.js +0 -16
  73. package/dist/chunk-HMLY7DHA.js.map +0 -1
  74. package/dist/client.js.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/mcp.d.ts +0 -58
  77. package/dist/mcp.js +0 -945
  78. package/dist/mcp.js.map +0 -1
  79. package/src/index.ts +0 -922
@@ -1,88 +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 "./client.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 { r as useAgent } from "./react-DTzwSLAh.js";
11
+ import { UseChatOptions, useChat } from "@ai-sdk/react";
12
+ import { ChatInit, UIMessage } from "ai";
8
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
+ };
9
20
  type GetInitialMessagesOptions = {
10
21
  agent: string;
11
22
  name: string;
12
23
  url: string;
13
24
  };
25
+ type UseChatParams<M extends UIMessage = UIMessage> = ChatInit<M> &
26
+ UseChatOptions<M>;
14
27
  /**
15
28
  * Options for the useAgentChat hook
16
29
  */
17
- type UseAgentChatOptions<State> = Omit<
18
- Parameters<typeof useChat>[0] & {
19
- /** Agent connection from useAgent */
20
- agent: ReturnType<typeof useAgent<State>>;
21
- getInitialMessages?:
22
- | undefined
23
- | null
24
- | ((options: GetInitialMessagesOptions) => Promise<Message[]>);
25
- },
26
- "fetch"
27
- >;
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
+ };
28
71
  /**
29
72
  * React hook for building AI chat interfaces using an Agent
30
73
  * @param options Chat options including the agent connection
31
74
  * @returns Chat interface controls and state with added clearHistory method
32
75
  */
33
- declare function useAgentChat<State = unknown>(
34
- options: UseAgentChatOptions<State>
35
- ): {
36
- /**
37
- * Set the chat messages and synchronize with the Agent
38
- * @param messages New messages to set
39
- */
40
- setMessages: (messages: Message[]) => void;
41
- /**
42
- * Clear chat history on both client and Agent
43
- */
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>> & {
44
91
  clearHistory: () => void;
45
- messages: ai.UIMessage[];
46
- error: undefined | Error;
47
- append: (
48
- message: Message | ai.CreateMessage,
49
- chatRequestOptions?: ai.ChatRequestOptions
50
- ) => Promise<string | null | undefined>;
51
- reload: (
52
- chatRequestOptions?: ai.ChatRequestOptions
53
- ) => Promise<string | null | undefined>;
54
- stop: () => void;
55
- input: string;
56
- setInput: React.Dispatch<React.SetStateAction<string>>;
57
- handleInputChange: (
58
- e:
59
- | React.ChangeEvent<HTMLInputElement>
60
- | React.ChangeEvent<HTMLTextAreaElement>
61
- ) => void;
62
- handleSubmit: (
63
- event?: {
64
- preventDefault?: () => void;
65
- },
66
- chatRequestOptions?: ai.ChatRequestOptions
67
- ) => void;
68
- metadata?: Object;
69
- isLoading: boolean;
70
- status: "submitted" | "streaming" | "ready" | "error";
71
- data?: ai.JSONValue[];
72
- setData: (
73
- data:
74
- | ai.JSONValue[]
75
- | undefined
76
- | ((data: ai.JSONValue[] | undefined) => ai.JSONValue[] | undefined)
77
- ) => void;
78
- id: string;
79
- addToolResult: ({
80
- toolCallId,
81
- result,
82
- }: {
83
- toolCallId: string;
84
- result: any;
85
- }) => void;
86
92
  };
87
-
88
- export { useAgentChat };
93
+ //#endregion
94
+ export { AITool, detectToolsRequiringConfirmation, useAgentChat };
95
+ //# sourceMappingURL=ai-react.d.ts.map