deepagentsdk 0.12.0 → 0.13.0

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 (37) hide show
  1. package/dist/adapters/elements/index.cjs +244 -294
  2. package/dist/adapters/elements/index.cjs.map +1 -1
  3. package/dist/adapters/elements/index.d.cts +84 -174
  4. package/dist/adapters/elements/index.d.mts +84 -174
  5. package/dist/adapters/elements/index.mjs +238 -290
  6. package/dist/adapters/elements/index.mjs.map +1 -1
  7. package/dist/{types-4g9UvXal.d.mts → agent-BDM-PIu8.d.mts} +374 -25
  8. package/dist/{types-IulnvhFg.d.cts → agent-DToEVxs-.d.cts} +374 -25
  9. package/dist/{chunk-CbDLau6x.cjs → chunk-C5azi7Hr.cjs} +33 -0
  10. package/dist/cli/index.cjs +12 -12
  11. package/dist/cli/index.cjs.map +1 -1
  12. package/dist/cli/index.mjs +2 -2
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/{agent-Cuks-Idh.cjs → file-saver-BYPKakT4.cjs} +799 -205
  15. package/dist/file-saver-BYPKakT4.cjs.map +1 -0
  16. package/dist/{agent-CrH-He58.mjs → file-saver-Hj5so3dV.mjs} +793 -199
  17. package/dist/file-saver-Hj5so3dV.mjs.map +1 -0
  18. package/dist/index.cjs +83 -73
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +5 -353
  21. package/dist/index.d.mts +5 -353
  22. package/dist/index.mjs +13 -3
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{load-B6CA5js_.mjs → load-BBYEnMwz.mjs} +1 -1
  25. package/dist/{load-B6CA5js_.mjs.map → load-BBYEnMwz.mjs.map} +1 -1
  26. package/dist/{load-94gjHorc.mjs → load-BDxe6Cet.mjs} +1 -1
  27. package/dist/{load-79a2H4m0.cjs → load-BrRAKlO6.cjs} +2 -2
  28. package/dist/{load-79a2H4m0.cjs.map → load-BrRAKlO6.cjs.map} +1 -1
  29. package/dist/load-DqllBbDc.cjs +4 -0
  30. package/package.json +1 -1
  31. package/dist/agent-CrH-He58.mjs.map +0 -1
  32. package/dist/agent-Cuks-Idh.cjs.map +0 -1
  33. package/dist/file-saver-BJCqMIb5.mjs +0 -655
  34. package/dist/file-saver-BJCqMIb5.mjs.map +0 -1
  35. package/dist/file-saver-C6O2LAvg.cjs +0 -679
  36. package/dist/file-saver-C6O2LAvg.cjs.map +0 -1
  37. package/dist/load-C2qVmZMp.cjs +0 -3
@@ -1,212 +1,122 @@
1
- import { _t as BackendProtocol, d as DeepAgentEvent } from "../../types-IulnvhFg.cjs";
2
- import { LanguageModel, ToolSet } from "ai";
3
- import "react";
1
+ import { r as ModelMessage$1, t as DeepAgent, yt as DeepAgentState } from "../../agent-DToEVxs-.cjs";
2
+ import { UIMessage, UIMessage as UIMessage$1, UIMessagePart } from "ai";
4
3
 
5
- //#region src/adapters/elements/types.d.ts
4
+ //#region src/adapters/elements/createElementsRouteHandler.d.ts
6
5
 
7
6
  /**
8
- * Types for AI SDK Elements adapter
9
- *
10
- * These types align with Vercel AI SDK Elements UI component expectations.
11
- * @see https://ai-sdk.dev/elements
12
- */
13
- /**
14
- * UI message part types that Elements components expect
15
- */
16
- type UIMessagePart = {
17
- type: "text";
18
- text: string;
19
- } | {
20
- type: "tool-call";
21
- toolCallId: string;
22
- toolName: string;
23
- args: unknown;
24
- } | {
25
- type: "tool-result";
26
- toolCallId: string;
27
- toolName: string;
28
- result: unknown;
29
- isError?: boolean;
30
- };
31
- /**
32
- * UI message format expected by Elements Message component
33
- */
34
- interface UIMessage {
35
- id: string;
36
- role: "user" | "assistant";
37
- parts: UIMessagePart[];
38
- status: "submitted" | "streaming" | "ready" | "error";
39
- }
40
- /**
41
- * UI status that Elements components use
42
- */
43
- type UIStatus = "submitted" | "streaming" | "ready" | "error";
44
- /**
45
- * PromptInput component message format
46
- */
47
- interface PromptInputMessage {
48
- text: string;
49
- }
50
- /**
51
- * Tool parts extracted from current message for Tool component
52
- */
53
- interface ToolUIPart {
54
- type: "tool-call" | "tool-result";
55
- toolCallId: string;
56
- toolName: string;
57
- args?: unknown;
58
- result?: unknown;
59
- isError?: boolean;
60
- }
61
- /**
62
- * Return type for useElementsAdapter hook
7
+ * Options for creating an Elements route handler
63
8
  */
64
- interface UseElementsAdapterReturn {
65
- /**
66
- * Messages formatted for Elements Message component
67
- */
68
- uiMessages: UIMessage[];
9
+ interface CreateElementsRouteHandlerOptions {
69
10
  /**
70
- * Current UI status for Elements components
11
+ * The DeepAgent instance to use for handling requests
71
12
  */
72
- uiStatus: UIStatus;
13
+ agent: DeepAgent;
73
14
  /**
74
- * Tool parts from current message for Tool component
15
+ * Optional callback before processing a request.
16
+ * Use for authentication, logging, rate limiting, etc.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * onRequest: async (req) => {
21
+ * const token = req.headers.get('Authorization');
22
+ * if (!validateToken(token)) {
23
+ * throw new Error('Unauthorized');
24
+ * }
25
+ * }
26
+ * ```
75
27
  */
76
- toolParts: ToolUIPart[];
28
+ onRequest?: (req: Request) => Promise<void> | void;
77
29
  /**
78
- * Send a message (compatible with PromptInput onSubmit)
30
+ * Optional initial state to provide to the agent.
31
+ * If not provided, uses empty state { todos: [], files: {} }
79
32
  */
80
- sendMessage: (message: PromptInputMessage) => Promise<void>;
33
+ initialState?: DeepAgentState;
81
34
  /**
82
- * Abort current streaming
35
+ * Optional thread ID for checkpointing.
36
+ * If provided, enables conversation persistence.
83
37
  */
84
- abort: () => void;
38
+ threadId?: string;
85
39
  /**
86
- * Clear all messages
87
- */
88
- clear: () => void;
89
- }
90
- //#endregion
91
- //#region src/adapters/elements/useElementsAdapter.d.ts
92
- /**
93
- * Options for useElementsAdapter hook
94
- */
95
- interface UseElementsAdapterOptions {
96
- /**
97
- * Language model instance from AI SDK provider
98
- */
99
- model: LanguageModel;
100
- /**
101
- * Backend for state management
102
- */
103
- backend: BackendProtocol;
104
- /**
105
- * Optional tools to provide to the agent
106
- */
107
- tools?: ToolSet;
108
- /**
109
- * Maximum number of tool loop iterations
110
- * @default 10
40
+ * Optional maximum number of steps for the agent loop.
111
41
  */
112
42
  maxSteps?: number;
113
43
  /**
114
- * System prompt for the agent
44
+ * Custom ID generator for message IDs.
45
+ * Defaults to crypto.randomUUID if available.
115
46
  */
116
- systemPrompt?: string;
47
+ generateId?: () => string;
117
48
  }
118
49
  /**
119
- * Hook that adapts deepagentsdk to work with AI SDK Elements UI components
50
+ * Creates a route handler that processes chat requests using DeepAgent
51
+ * and returns UI Message Stream compatible responses.
52
+ *
53
+ * The returned handler:
54
+ * - Accepts POST requests with { messages: UIMessage[] } body
55
+ * - Runs DeepAgent with the conversation history
56
+ * - Streams responses in UI Message Stream Protocol format
57
+ * - Works with useChat hook from @ai-sdk/react
120
58
  *
121
59
  * @param options - Configuration options
122
- * @returns Elements-compatible interface
60
+ * @returns A request handler function compatible with Next.js/Express
61
+ */
62
+ declare function createElementsRouteHandler(options: CreateElementsRouteHandlerOptions): (req: Request) => Promise<Response>;
63
+ /**
64
+ * Type for the request handler returned by createElementsRouteHandler
65
+ */
66
+ type ElementsRouteHandler = (req: Request) => Promise<Response>;
67
+ //#endregion
68
+ //#region src/adapters/elements/messageConverters.d.ts
69
+ /**
70
+ * Re-export AI SDK's convertToModelMessages for convenience.
123
71
  *
124
- * @example
125
- * ```tsx
126
- * import { useElementsAdapter } from 'deepagentsdk/elements';
127
- * import { Conversation, Message, PromptInput } from '@/components/ai-elements';
72
+ * This function converts UIMessage[] (from useChat) to ModelMessage[]
73
+ * (for agent consumption), handling:
74
+ * - Role mapping (user/assistant)
75
+ * - Tool call/result parts
76
+ * - Text content extraction
128
77
  *
129
- * function Chat() {
130
- * const { uiMessages, sendMessage } = useElementsAdapter({
131
- * model,
132
- * backend
133
- * });
78
+ * @example
79
+ * ```typescript
80
+ * import { convertUIMessagesToModelMessages } from 'deepagentsdk/adapters/elements';
134
81
  *
135
- * return (
136
- * <Conversation>
137
- * {uiMessages.map(msg => <Message key={msg.id} from={msg.role} />)}
138
- * <PromptInput onSubmit={sendMessage} />
139
- * </Conversation>
140
- * );
141
- * }
82
+ * const modelMessages = await convertUIMessagesToModelMessages(uiMessages);
142
83
  * ```
143
84
  */
144
- declare function useElementsAdapter(options: UseElementsAdapterOptions): UseElementsAdapterReturn;
145
- //#endregion
146
- //#region src/cli/hooks/useAgent.d.ts
147
- type AgentStatus = "idle" | "thinking" | "streaming" | "tool-call" | "subagent" | "done" | "error";
148
- interface AgentEventLog {
149
- id: string;
150
- type: DeepAgentEvent["type"] | "text-segment";
151
- event: DeepAgentEvent | {
152
- type: "text-segment";
153
- text: string;
154
- };
155
- timestamp: Date;
156
- }
157
- //#endregion
158
- //#region src/adapters/elements/statusAdapter.d.ts
85
+ declare function convertUIMessagesToModelMessages(messages: UIMessage$1[]): Promise<ModelMessage$1[]>;
159
86
  /**
160
- * Maps deepagentsdk AgentStatus to Elements UIStatus
87
+ * Extract the last user message text from a UIMessage array.
88
+ * Useful for extracting the prompt from a conversation.
161
89
  *
162
- * @param agentStatus - The agent status from useAgent hook
163
- * @returns The corresponding UI status for Elements components
164
- *
165
- * Mapping rules:
166
- * - idle/done → ready (agent is waiting for input)
167
- * - thinking/tool-call/subagent → submitted (agent is processing)
168
- * - streaming → streaming (agent is generating text)
169
- * - error → error (an error occurred)
90
+ * @param messages - Array of UI messages
91
+ * @returns The text content of the last user message, or undefined if none
170
92
  */
171
- declare function mapAgentStatusToUIStatus(agentStatus: AgentStatus): UIStatus;
172
- //#endregion
173
- //#region src/adapters/elements/messageAdapter.d.ts
93
+ declare function extractLastUserMessage(messages: UIMessage$1[]): string | undefined;
174
94
  /**
175
- * Converts agent event log to UIMessage format expected by Elements
95
+ * Check if the messages contain any tool parts.
96
+ * This is a simplified helper that checks for any tool-related parts.
176
97
  *
177
- * @param events - Array of agent events from useAgent hook
178
- * @param streamingText - Current streaming text (if any)
179
- * @param uiStatus - Current UI status
180
- * @returns Array of UIMessage objects for Elements Message component
98
+ * @param messages - Array of UI messages
99
+ * @returns True if there are any tool-related parts in the messages
100
+ */
101
+ declare function hasToolParts(messages: UIMessage$1[]): boolean;
102
+ /**
103
+ * Count the number of messages by role.
181
104
  *
182
- * Conversion logic:
183
- * 1. Group events by role (user/assistant)
184
- * 2. Convert each event type to appropriate UIMessagePart
185
- * 3. Handle streaming text as in-progress message
186
- * 4. Preserve event order and tool call/result pairing
105
+ * @param messages - Array of UI messages
106
+ * @returns Object with counts by role
187
107
  */
188
- declare function convertEventsToUIMessages(events: AgentEventLog[], streamingText: string, uiStatus: UIStatus): UIMessage[];
108
+ declare function countMessagesByRole(messages: UIMessage$1[]): {
109
+ user: number;
110
+ assistant: number;
111
+ system: number;
112
+ };
189
113
  /**
190
- * Extracts tool parts from the most recent assistant message
114
+ * Extract all text content from a message.
191
115
  *
192
- * @param messages - UIMessage array
193
- * @returns Array of tool parts (tool-call and tool-result)
116
+ * @param message - A UI message
117
+ * @returns Combined text from all text parts
194
118
  */
195
- declare function extractToolParts(messages: UIMessage[]): ({
196
- type: "tool-call";
197
- toolCallId: string;
198
- toolName: string;
199
- args: unknown;
200
- result?: undefined;
201
- isError?: undefined;
202
- } | {
203
- type: "tool-result";
204
- toolCallId: string;
205
- toolName: string;
206
- result: unknown;
207
- isError: boolean | undefined;
208
- args?: undefined;
209
- })[];
119
+ declare function extractTextFromMessage(message: UIMessage$1): string;
210
120
  //#endregion
211
- export { type PromptInputMessage, type ToolUIPart, type UIMessage, type UIMessagePart, type UIStatus, type UseElementsAdapterOptions, type UseElementsAdapterReturn, convertEventsToUIMessages, extractToolParts, mapAgentStatusToUIStatus, useElementsAdapter };
121
+ export { type CreateElementsRouteHandlerOptions, type ElementsRouteHandler, type UIMessage, type UIMessagePart, convertUIMessagesToModelMessages, countMessagesByRole, createElementsRouteHandler, extractLastUserMessage, extractTextFromMessage, hasToolParts };
212
122
  //# sourceMappingURL=index.d.cts.map
@@ -1,212 +1,122 @@
1
- import { _t as BackendProtocol, d as DeepAgentEvent } from "../../types-4g9UvXal.mjs";
2
- import { LanguageModel, ToolSet } from "ai";
3
- import "react";
1
+ import { r as ModelMessage$1, t as DeepAgent, yt as DeepAgentState } from "../../agent-BDM-PIu8.mjs";
2
+ import { UIMessage, UIMessage as UIMessage$1, UIMessagePart } from "ai";
4
3
 
5
- //#region src/adapters/elements/types.d.ts
4
+ //#region src/adapters/elements/createElementsRouteHandler.d.ts
6
5
 
7
6
  /**
8
- * Types for AI SDK Elements adapter
9
- *
10
- * These types align with Vercel AI SDK Elements UI component expectations.
11
- * @see https://ai-sdk.dev/elements
12
- */
13
- /**
14
- * UI message part types that Elements components expect
15
- */
16
- type UIMessagePart = {
17
- type: "text";
18
- text: string;
19
- } | {
20
- type: "tool-call";
21
- toolCallId: string;
22
- toolName: string;
23
- args: unknown;
24
- } | {
25
- type: "tool-result";
26
- toolCallId: string;
27
- toolName: string;
28
- result: unknown;
29
- isError?: boolean;
30
- };
31
- /**
32
- * UI message format expected by Elements Message component
33
- */
34
- interface UIMessage {
35
- id: string;
36
- role: "user" | "assistant";
37
- parts: UIMessagePart[];
38
- status: "submitted" | "streaming" | "ready" | "error";
39
- }
40
- /**
41
- * UI status that Elements components use
42
- */
43
- type UIStatus = "submitted" | "streaming" | "ready" | "error";
44
- /**
45
- * PromptInput component message format
46
- */
47
- interface PromptInputMessage {
48
- text: string;
49
- }
50
- /**
51
- * Tool parts extracted from current message for Tool component
52
- */
53
- interface ToolUIPart {
54
- type: "tool-call" | "tool-result";
55
- toolCallId: string;
56
- toolName: string;
57
- args?: unknown;
58
- result?: unknown;
59
- isError?: boolean;
60
- }
61
- /**
62
- * Return type for useElementsAdapter hook
7
+ * Options for creating an Elements route handler
63
8
  */
64
- interface UseElementsAdapterReturn {
65
- /**
66
- * Messages formatted for Elements Message component
67
- */
68
- uiMessages: UIMessage[];
9
+ interface CreateElementsRouteHandlerOptions {
69
10
  /**
70
- * Current UI status for Elements components
11
+ * The DeepAgent instance to use for handling requests
71
12
  */
72
- uiStatus: UIStatus;
13
+ agent: DeepAgent;
73
14
  /**
74
- * Tool parts from current message for Tool component
15
+ * Optional callback before processing a request.
16
+ * Use for authentication, logging, rate limiting, etc.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * onRequest: async (req) => {
21
+ * const token = req.headers.get('Authorization');
22
+ * if (!validateToken(token)) {
23
+ * throw new Error('Unauthorized');
24
+ * }
25
+ * }
26
+ * ```
75
27
  */
76
- toolParts: ToolUIPart[];
28
+ onRequest?: (req: Request) => Promise<void> | void;
77
29
  /**
78
- * Send a message (compatible with PromptInput onSubmit)
30
+ * Optional initial state to provide to the agent.
31
+ * If not provided, uses empty state { todos: [], files: {} }
79
32
  */
80
- sendMessage: (message: PromptInputMessage) => Promise<void>;
33
+ initialState?: DeepAgentState;
81
34
  /**
82
- * Abort current streaming
35
+ * Optional thread ID for checkpointing.
36
+ * If provided, enables conversation persistence.
83
37
  */
84
- abort: () => void;
38
+ threadId?: string;
85
39
  /**
86
- * Clear all messages
87
- */
88
- clear: () => void;
89
- }
90
- //#endregion
91
- //#region src/adapters/elements/useElementsAdapter.d.ts
92
- /**
93
- * Options for useElementsAdapter hook
94
- */
95
- interface UseElementsAdapterOptions {
96
- /**
97
- * Language model instance from AI SDK provider
98
- */
99
- model: LanguageModel;
100
- /**
101
- * Backend for state management
102
- */
103
- backend: BackendProtocol;
104
- /**
105
- * Optional tools to provide to the agent
106
- */
107
- tools?: ToolSet;
108
- /**
109
- * Maximum number of tool loop iterations
110
- * @default 10
40
+ * Optional maximum number of steps for the agent loop.
111
41
  */
112
42
  maxSteps?: number;
113
43
  /**
114
- * System prompt for the agent
44
+ * Custom ID generator for message IDs.
45
+ * Defaults to crypto.randomUUID if available.
115
46
  */
116
- systemPrompt?: string;
47
+ generateId?: () => string;
117
48
  }
118
49
  /**
119
- * Hook that adapts deepagentsdk to work with AI SDK Elements UI components
50
+ * Creates a route handler that processes chat requests using DeepAgent
51
+ * and returns UI Message Stream compatible responses.
52
+ *
53
+ * The returned handler:
54
+ * - Accepts POST requests with { messages: UIMessage[] } body
55
+ * - Runs DeepAgent with the conversation history
56
+ * - Streams responses in UI Message Stream Protocol format
57
+ * - Works with useChat hook from @ai-sdk/react
120
58
  *
121
59
  * @param options - Configuration options
122
- * @returns Elements-compatible interface
60
+ * @returns A request handler function compatible with Next.js/Express
61
+ */
62
+ declare function createElementsRouteHandler(options: CreateElementsRouteHandlerOptions): (req: Request) => Promise<Response>;
63
+ /**
64
+ * Type for the request handler returned by createElementsRouteHandler
65
+ */
66
+ type ElementsRouteHandler = (req: Request) => Promise<Response>;
67
+ //#endregion
68
+ //#region src/adapters/elements/messageConverters.d.ts
69
+ /**
70
+ * Re-export AI SDK's convertToModelMessages for convenience.
123
71
  *
124
- * @example
125
- * ```tsx
126
- * import { useElementsAdapter } from 'deepagentsdk/elements';
127
- * import { Conversation, Message, PromptInput } from '@/components/ai-elements';
72
+ * This function converts UIMessage[] (from useChat) to ModelMessage[]
73
+ * (for agent consumption), handling:
74
+ * - Role mapping (user/assistant)
75
+ * - Tool call/result parts
76
+ * - Text content extraction
128
77
  *
129
- * function Chat() {
130
- * const { uiMessages, sendMessage } = useElementsAdapter({
131
- * model,
132
- * backend
133
- * });
78
+ * @example
79
+ * ```typescript
80
+ * import { convertUIMessagesToModelMessages } from 'deepagentsdk/adapters/elements';
134
81
  *
135
- * return (
136
- * <Conversation>
137
- * {uiMessages.map(msg => <Message key={msg.id} from={msg.role} />)}
138
- * <PromptInput onSubmit={sendMessage} />
139
- * </Conversation>
140
- * );
141
- * }
82
+ * const modelMessages = await convertUIMessagesToModelMessages(uiMessages);
142
83
  * ```
143
84
  */
144
- declare function useElementsAdapter(options: UseElementsAdapterOptions): UseElementsAdapterReturn;
145
- //#endregion
146
- //#region src/cli/hooks/useAgent.d.ts
147
- type AgentStatus = "idle" | "thinking" | "streaming" | "tool-call" | "subagent" | "done" | "error";
148
- interface AgentEventLog {
149
- id: string;
150
- type: DeepAgentEvent["type"] | "text-segment";
151
- event: DeepAgentEvent | {
152
- type: "text-segment";
153
- text: string;
154
- };
155
- timestamp: Date;
156
- }
157
- //#endregion
158
- //#region src/adapters/elements/statusAdapter.d.ts
85
+ declare function convertUIMessagesToModelMessages(messages: UIMessage$1[]): Promise<ModelMessage$1[]>;
159
86
  /**
160
- * Maps deepagentsdk AgentStatus to Elements UIStatus
87
+ * Extract the last user message text from a UIMessage array.
88
+ * Useful for extracting the prompt from a conversation.
161
89
  *
162
- * @param agentStatus - The agent status from useAgent hook
163
- * @returns The corresponding UI status for Elements components
164
- *
165
- * Mapping rules:
166
- * - idle/done → ready (agent is waiting for input)
167
- * - thinking/tool-call/subagent → submitted (agent is processing)
168
- * - streaming → streaming (agent is generating text)
169
- * - error → error (an error occurred)
90
+ * @param messages - Array of UI messages
91
+ * @returns The text content of the last user message, or undefined if none
170
92
  */
171
- declare function mapAgentStatusToUIStatus(agentStatus: AgentStatus): UIStatus;
172
- //#endregion
173
- //#region src/adapters/elements/messageAdapter.d.ts
93
+ declare function extractLastUserMessage(messages: UIMessage$1[]): string | undefined;
174
94
  /**
175
- * Converts agent event log to UIMessage format expected by Elements
95
+ * Check if the messages contain any tool parts.
96
+ * This is a simplified helper that checks for any tool-related parts.
176
97
  *
177
- * @param events - Array of agent events from useAgent hook
178
- * @param streamingText - Current streaming text (if any)
179
- * @param uiStatus - Current UI status
180
- * @returns Array of UIMessage objects for Elements Message component
98
+ * @param messages - Array of UI messages
99
+ * @returns True if there are any tool-related parts in the messages
100
+ */
101
+ declare function hasToolParts(messages: UIMessage$1[]): boolean;
102
+ /**
103
+ * Count the number of messages by role.
181
104
  *
182
- * Conversion logic:
183
- * 1. Group events by role (user/assistant)
184
- * 2. Convert each event type to appropriate UIMessagePart
185
- * 3. Handle streaming text as in-progress message
186
- * 4. Preserve event order and tool call/result pairing
105
+ * @param messages - Array of UI messages
106
+ * @returns Object with counts by role
187
107
  */
188
- declare function convertEventsToUIMessages(events: AgentEventLog[], streamingText: string, uiStatus: UIStatus): UIMessage[];
108
+ declare function countMessagesByRole(messages: UIMessage$1[]): {
109
+ user: number;
110
+ assistant: number;
111
+ system: number;
112
+ };
189
113
  /**
190
- * Extracts tool parts from the most recent assistant message
114
+ * Extract all text content from a message.
191
115
  *
192
- * @param messages - UIMessage array
193
- * @returns Array of tool parts (tool-call and tool-result)
116
+ * @param message - A UI message
117
+ * @returns Combined text from all text parts
194
118
  */
195
- declare function extractToolParts(messages: UIMessage[]): ({
196
- type: "tool-call";
197
- toolCallId: string;
198
- toolName: string;
199
- args: unknown;
200
- result?: undefined;
201
- isError?: undefined;
202
- } | {
203
- type: "tool-result";
204
- toolCallId: string;
205
- toolName: string;
206
- result: unknown;
207
- isError: boolean | undefined;
208
- args?: undefined;
209
- })[];
119
+ declare function extractTextFromMessage(message: UIMessage$1): string;
210
120
  //#endregion
211
- export { type PromptInputMessage, type ToolUIPart, type UIMessage, type UIMessagePart, type UIStatus, type UseElementsAdapterOptions, type UseElementsAdapterReturn, convertEventsToUIMessages, extractToolParts, mapAgentStatusToUIStatus, useElementsAdapter };
121
+ export { type CreateElementsRouteHandlerOptions, type ElementsRouteHandler, type UIMessage, type UIMessagePart, convertUIMessagesToModelMessages, countMessagesByRole, createElementsRouteHandler, extractLastUserMessage, extractTextFromMessage, hasToolParts };
212
122
  //# sourceMappingURL=index.d.mts.map