@voltagent/server-core 2.1.0 → 2.1.2

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.
@@ -228,6 +228,36 @@ declare const AGENT_ROUTES: {
228
228
  };
229
229
  };
230
230
  };
231
+ readonly resumeChatStream: {
232
+ readonly method: "get";
233
+ readonly path: "/agents/:id/chat/:conversationId/stream";
234
+ readonly summary: "Resume chat stream";
235
+ readonly description: "Resume an in-progress UI message stream for a chat conversation. Requires userId query parameter. Returns 204 if no active stream is found.";
236
+ readonly tags: readonly ["Agent Generation"];
237
+ readonly operationId: "resumeChatStream";
238
+ readonly responses: {
239
+ readonly 200: {
240
+ readonly description: "Successfully resumed SSE stream for chat generation";
241
+ readonly contentType: "text/event-stream";
242
+ };
243
+ readonly 400: {
244
+ readonly description: "Missing or invalid userId";
245
+ readonly contentType: "application/json";
246
+ };
247
+ readonly 204: {
248
+ readonly description: "No active stream found for the conversation";
249
+ readonly contentType: "text/plain";
250
+ };
251
+ readonly 404: {
252
+ readonly description: "Resumable streams not configured";
253
+ readonly contentType: "application/json";
254
+ };
255
+ readonly 500: {
256
+ readonly description: "Failed to resume chat stream due to server error";
257
+ readonly contentType: "application/json";
258
+ };
259
+ };
260
+ };
231
261
  readonly generateObject: {
232
262
  readonly method: "post";
233
263
  readonly path: "/agents/:id/object";
@@ -1684,6 +1714,36 @@ declare const ALL_ROUTES: {
1684
1714
  };
1685
1715
  };
1686
1716
  };
1717
+ readonly resumeChatStream: {
1718
+ readonly method: "get";
1719
+ readonly path: "/agents/:id/chat/:conversationId/stream";
1720
+ readonly summary: "Resume chat stream";
1721
+ readonly description: "Resume an in-progress UI message stream for a chat conversation. Requires userId query parameter. Returns 204 if no active stream is found.";
1722
+ readonly tags: readonly ["Agent Generation"];
1723
+ readonly operationId: "resumeChatStream";
1724
+ readonly responses: {
1725
+ readonly 200: {
1726
+ readonly description: "Successfully resumed SSE stream for chat generation";
1727
+ readonly contentType: "text/event-stream";
1728
+ };
1729
+ readonly 400: {
1730
+ readonly description: "Missing or invalid userId";
1731
+ readonly contentType: "application/json";
1732
+ };
1733
+ readonly 204: {
1734
+ readonly description: "No active stream found for the conversation";
1735
+ readonly contentType: "text/plain";
1736
+ };
1737
+ readonly 404: {
1738
+ readonly description: "Resumable streams not configured";
1739
+ readonly contentType: "application/json";
1740
+ };
1741
+ readonly 500: {
1742
+ readonly description: "Failed to resume chat stream due to server error";
1743
+ readonly contentType: "application/json";
1744
+ };
1745
+ };
1746
+ };
1687
1747
  readonly generateObject: {
1688
1748
  readonly method: "post";
1689
1749
  readonly path: "/agents/:id/object";
@@ -2143,6 +2203,11 @@ declare function handleStreamText(agentId: string, body: any, deps: ServerProvid
2143
2203
  * Returns AI SDK UI Message Stream Response
2144
2204
  */
2145
2205
  declare function handleChatStream(agentId: string, body: any, deps: ServerProviderDeps, logger: Logger, signal?: AbortSignal): Promise<Response>;
2206
+ /**
2207
+ * Handler for resuming chat streams
2208
+ * Returns SSE stream if active, or 204 if no stream is active
2209
+ */
2210
+ declare function handleResumeChatStream(agentId: string, conversationId: string, deps: ServerProviderDeps, logger: Logger, userId?: string): Promise<Response>;
2146
2211
  /**
2147
2212
  * Handler for generating objects
2148
2213
  * Returns generated object data
@@ -2382,4 +2447,4 @@ declare function mapHandlerResponse(response: ApiResponse, type?: string): ApiRe
2382
2447
  */
2383
2448
  declare function getResponseStatus(response: ApiResponse): number;
2384
2449
 
2385
- export { handleChatStream as $, type ApiResponse as A, type JsonRpcStream as B, type JsonRpcHandlerResult as C, type JsonRpcRequest as D, type ErrorResponse as E, type A2ARequestContext as F, type AgentCardSkill as G, type HttpMethod as H, type AgentCardProviderInfo as I, type JsonRpcError as J, type AgentCardCapabilities as K, LOG_ROUTES as L, type MemoryUserSummary as M, type AgentCard as N, OBSERVABILITY_ROUTES as O, A2AErrorCode as P, normalizeError as Q, type ResponseDefinition as R, type SuccessResponse as S, TOOL_ROUTES as T, UPDATE_ROUTES as U, VoltA2AError as V, WORKFLOW_ROUTES as W, isJsonRpcRequest as X, handleGetAgents as Y, handleGenerateText as Z, handleStreamText as _, type A2AServerLikeWithHandlers as a, handleGenerateObject as a0, handleStreamObject as a1, handleGetAgent as a2, handleGetAgentHistory as a3, handleGetWorkflows as a4, handleGetWorkflow as a5, handleExecuteWorkflow as a6, handleStreamWorkflow as a7, handleSuspendWorkflow as a8, handleCancelWorkflow as a9, handleResumeWorkflow as aa, handleListWorkflowRuns as ab, handleGetWorkflowState as ac, type LogFilterOptions as ad, type LogHandlerResponse as ae, handleGetLogs as af, listMemoryUsersHandler as ag, listMemoryConversationsHandler as ah, getConversationMessagesHandler as ai, getConversationStepsHandler as aj, getWorkingMemoryHandler as ak, mapLogResponse as al, mapHandlerResponse as am, getResponseStatus as an, type OpenApiInfo as ao, type AppSetupConfig as ap, getOrCreateLogger as aq, shouldEnableSwaggerUI as ar, getOpenApiDoc as as, DEFAULT_CORS_OPTIONS as at, type StreamResponse as b, isSuccessResponse as c, type MemoryUserAgentSummary as d, type MemoryConversationSummary as e, type MemoryConversationMessagesResult as f, type MemoryConversationStepsResult as g, type MemoryWorkingMemoryResult as h, isErrorResponse as i, type MemoryListUsersQuery as j, type MemoryListConversationsQuery as k, type MemoryGetMessagesQuery as l, type MemoryGetStepsQuery as m, type RouteDefinition as n, AGENT_ROUTES as o, OBSERVABILITY_MEMORY_ROUTES as p, ALL_ROUTES as q, getAllRoutesArray as r, MCP_ROUTES as s, A2A_ROUTES as t, getRoutesByTag as u, parseJsonRpcRequest as v, resolveAgentCard as w, executeA2ARequest as x, type A2AJsonRpcId as y, type JsonRpcResponse as z };
2450
+ export { handleChatStream as $, type ApiResponse as A, type JsonRpcStream as B, type JsonRpcHandlerResult as C, type JsonRpcRequest as D, type ErrorResponse as E, type A2ARequestContext as F, type AgentCardSkill as G, type HttpMethod as H, type AgentCardProviderInfo as I, type JsonRpcError as J, type AgentCardCapabilities as K, LOG_ROUTES as L, type MemoryUserSummary as M, type AgentCard as N, OBSERVABILITY_ROUTES as O, A2AErrorCode as P, normalizeError as Q, type ResponseDefinition as R, type SuccessResponse as S, TOOL_ROUTES as T, UPDATE_ROUTES as U, VoltA2AError as V, WORKFLOW_ROUTES as W, isJsonRpcRequest as X, handleGetAgents as Y, handleGenerateText as Z, handleStreamText as _, type A2AServerLikeWithHandlers as a, handleResumeChatStream as a0, handleGenerateObject as a1, handleStreamObject as a2, handleGetAgent as a3, handleGetAgentHistory as a4, handleGetWorkflows as a5, handleGetWorkflow as a6, handleExecuteWorkflow as a7, handleStreamWorkflow as a8, handleSuspendWorkflow as a9, handleCancelWorkflow as aa, handleResumeWorkflow as ab, handleListWorkflowRuns as ac, handleGetWorkflowState as ad, type LogFilterOptions as ae, type LogHandlerResponse as af, handleGetLogs as ag, listMemoryUsersHandler as ah, listMemoryConversationsHandler as ai, getConversationMessagesHandler as aj, getConversationStepsHandler as ak, getWorkingMemoryHandler as al, mapLogResponse as am, mapHandlerResponse as an, getResponseStatus as ao, type OpenApiInfo as ap, type AppSetupConfig as aq, getOrCreateLogger as ar, shouldEnableSwaggerUI as as, getOpenApiDoc as at, DEFAULT_CORS_OPTIONS as au, type StreamResponse as b, isSuccessResponse as c, type MemoryUserAgentSummary as d, type MemoryConversationSummary as e, type MemoryConversationMessagesResult as f, type MemoryConversationStepsResult as g, type MemoryWorkingMemoryResult as h, isErrorResponse as i, type MemoryListUsersQuery as j, type MemoryListConversationsQuery as k, type MemoryGetMessagesQuery as l, type MemoryGetStepsQuery as m, type RouteDefinition as n, AGENT_ROUTES as o, OBSERVABILITY_MEMORY_ROUTES as p, ALL_ROUTES as q, getAllRoutesArray as r, MCP_ROUTES as s, A2A_ROUTES as t, getRoutesByTag as u, parseJsonRpcRequest as v, resolveAgentCard as w, executeA2ARequest as x, type A2AJsonRpcId as y, type JsonRpcResponse as z };
@@ -228,6 +228,36 @@ declare const AGENT_ROUTES: {
228
228
  };
229
229
  };
230
230
  };
231
+ readonly resumeChatStream: {
232
+ readonly method: "get";
233
+ readonly path: "/agents/:id/chat/:conversationId/stream";
234
+ readonly summary: "Resume chat stream";
235
+ readonly description: "Resume an in-progress UI message stream for a chat conversation. Requires userId query parameter. Returns 204 if no active stream is found.";
236
+ readonly tags: readonly ["Agent Generation"];
237
+ readonly operationId: "resumeChatStream";
238
+ readonly responses: {
239
+ readonly 200: {
240
+ readonly description: "Successfully resumed SSE stream for chat generation";
241
+ readonly contentType: "text/event-stream";
242
+ };
243
+ readonly 400: {
244
+ readonly description: "Missing or invalid userId";
245
+ readonly contentType: "application/json";
246
+ };
247
+ readonly 204: {
248
+ readonly description: "No active stream found for the conversation";
249
+ readonly contentType: "text/plain";
250
+ };
251
+ readonly 404: {
252
+ readonly description: "Resumable streams not configured";
253
+ readonly contentType: "application/json";
254
+ };
255
+ readonly 500: {
256
+ readonly description: "Failed to resume chat stream due to server error";
257
+ readonly contentType: "application/json";
258
+ };
259
+ };
260
+ };
231
261
  readonly generateObject: {
232
262
  readonly method: "post";
233
263
  readonly path: "/agents/:id/object";
@@ -1684,6 +1714,36 @@ declare const ALL_ROUTES: {
1684
1714
  };
1685
1715
  };
1686
1716
  };
1717
+ readonly resumeChatStream: {
1718
+ readonly method: "get";
1719
+ readonly path: "/agents/:id/chat/:conversationId/stream";
1720
+ readonly summary: "Resume chat stream";
1721
+ readonly description: "Resume an in-progress UI message stream for a chat conversation. Requires userId query parameter. Returns 204 if no active stream is found.";
1722
+ readonly tags: readonly ["Agent Generation"];
1723
+ readonly operationId: "resumeChatStream";
1724
+ readonly responses: {
1725
+ readonly 200: {
1726
+ readonly description: "Successfully resumed SSE stream for chat generation";
1727
+ readonly contentType: "text/event-stream";
1728
+ };
1729
+ readonly 400: {
1730
+ readonly description: "Missing or invalid userId";
1731
+ readonly contentType: "application/json";
1732
+ };
1733
+ readonly 204: {
1734
+ readonly description: "No active stream found for the conversation";
1735
+ readonly contentType: "text/plain";
1736
+ };
1737
+ readonly 404: {
1738
+ readonly description: "Resumable streams not configured";
1739
+ readonly contentType: "application/json";
1740
+ };
1741
+ readonly 500: {
1742
+ readonly description: "Failed to resume chat stream due to server error";
1743
+ readonly contentType: "application/json";
1744
+ };
1745
+ };
1746
+ };
1687
1747
  readonly generateObject: {
1688
1748
  readonly method: "post";
1689
1749
  readonly path: "/agents/:id/object";
@@ -2143,6 +2203,11 @@ declare function handleStreamText(agentId: string, body: any, deps: ServerProvid
2143
2203
  * Returns AI SDK UI Message Stream Response
2144
2204
  */
2145
2205
  declare function handleChatStream(agentId: string, body: any, deps: ServerProviderDeps, logger: Logger, signal?: AbortSignal): Promise<Response>;
2206
+ /**
2207
+ * Handler for resuming chat streams
2208
+ * Returns SSE stream if active, or 204 if no stream is active
2209
+ */
2210
+ declare function handleResumeChatStream(agentId: string, conversationId: string, deps: ServerProviderDeps, logger: Logger, userId?: string): Promise<Response>;
2146
2211
  /**
2147
2212
  * Handler for generating objects
2148
2213
  * Returns generated object data
@@ -2382,4 +2447,4 @@ declare function mapHandlerResponse(response: ApiResponse, type?: string): ApiRe
2382
2447
  */
2383
2448
  declare function getResponseStatus(response: ApiResponse): number;
2384
2449
 
2385
- export { handleChatStream as $, type ApiResponse as A, type JsonRpcStream as B, type JsonRpcHandlerResult as C, type JsonRpcRequest as D, type ErrorResponse as E, type A2ARequestContext as F, type AgentCardSkill as G, type HttpMethod as H, type AgentCardProviderInfo as I, type JsonRpcError as J, type AgentCardCapabilities as K, LOG_ROUTES as L, type MemoryUserSummary as M, type AgentCard as N, OBSERVABILITY_ROUTES as O, A2AErrorCode as P, normalizeError as Q, type ResponseDefinition as R, type SuccessResponse as S, TOOL_ROUTES as T, UPDATE_ROUTES as U, VoltA2AError as V, WORKFLOW_ROUTES as W, isJsonRpcRequest as X, handleGetAgents as Y, handleGenerateText as Z, handleStreamText as _, type A2AServerLikeWithHandlers as a, handleGenerateObject as a0, handleStreamObject as a1, handleGetAgent as a2, handleGetAgentHistory as a3, handleGetWorkflows as a4, handleGetWorkflow as a5, handleExecuteWorkflow as a6, handleStreamWorkflow as a7, handleSuspendWorkflow as a8, handleCancelWorkflow as a9, handleResumeWorkflow as aa, handleListWorkflowRuns as ab, handleGetWorkflowState as ac, type LogFilterOptions as ad, type LogHandlerResponse as ae, handleGetLogs as af, listMemoryUsersHandler as ag, listMemoryConversationsHandler as ah, getConversationMessagesHandler as ai, getConversationStepsHandler as aj, getWorkingMemoryHandler as ak, mapLogResponse as al, mapHandlerResponse as am, getResponseStatus as an, type OpenApiInfo as ao, type AppSetupConfig as ap, getOrCreateLogger as aq, shouldEnableSwaggerUI as ar, getOpenApiDoc as as, DEFAULT_CORS_OPTIONS as at, type StreamResponse as b, isSuccessResponse as c, type MemoryUserAgentSummary as d, type MemoryConversationSummary as e, type MemoryConversationMessagesResult as f, type MemoryConversationStepsResult as g, type MemoryWorkingMemoryResult as h, isErrorResponse as i, type MemoryListUsersQuery as j, type MemoryListConversationsQuery as k, type MemoryGetMessagesQuery as l, type MemoryGetStepsQuery as m, type RouteDefinition as n, AGENT_ROUTES as o, OBSERVABILITY_MEMORY_ROUTES as p, ALL_ROUTES as q, getAllRoutesArray as r, MCP_ROUTES as s, A2A_ROUTES as t, getRoutesByTag as u, parseJsonRpcRequest as v, resolveAgentCard as w, executeA2ARequest as x, type A2AJsonRpcId as y, type JsonRpcResponse as z };
2450
+ export { handleChatStream as $, type ApiResponse as A, type JsonRpcStream as B, type JsonRpcHandlerResult as C, type JsonRpcRequest as D, type ErrorResponse as E, type A2ARequestContext as F, type AgentCardSkill as G, type HttpMethod as H, type AgentCardProviderInfo as I, type JsonRpcError as J, type AgentCardCapabilities as K, LOG_ROUTES as L, type MemoryUserSummary as M, type AgentCard as N, OBSERVABILITY_ROUTES as O, A2AErrorCode as P, normalizeError as Q, type ResponseDefinition as R, type SuccessResponse as S, TOOL_ROUTES as T, UPDATE_ROUTES as U, VoltA2AError as V, WORKFLOW_ROUTES as W, isJsonRpcRequest as X, handleGetAgents as Y, handleGenerateText as Z, handleStreamText as _, type A2AServerLikeWithHandlers as a, handleResumeChatStream as a0, handleGenerateObject as a1, handleStreamObject as a2, handleGetAgent as a3, handleGetAgentHistory as a4, handleGetWorkflows as a5, handleGetWorkflow as a6, handleExecuteWorkflow as a7, handleStreamWorkflow as a8, handleSuspendWorkflow as a9, handleCancelWorkflow as aa, handleResumeWorkflow as ab, handleListWorkflowRuns as ac, handleGetWorkflowState as ad, type LogFilterOptions as ae, type LogHandlerResponse as af, handleGetLogs as ag, listMemoryUsersHandler as ah, listMemoryConversationsHandler as ai, getConversationMessagesHandler as aj, getConversationStepsHandler as ak, getWorkingMemoryHandler as al, mapLogResponse as am, mapHandlerResponse as an, getResponseStatus as ao, type OpenApiInfo as ap, type AppSetupConfig as aq, getOrCreateLogger as ar, shouldEnableSwaggerUI as as, getOpenApiDoc as at, DEFAULT_CORS_OPTIONS as au, type StreamResponse as b, isSuccessResponse as c, type MemoryUserAgentSummary as d, type MemoryConversationSummary as e, type MemoryConversationMessagesResult as f, type MemoryConversationStepsResult as g, type MemoryWorkingMemoryResult as h, isErrorResponse as i, type MemoryListUsersQuery as j, type MemoryListConversationsQuery as k, type MemoryGetMessagesQuery as l, type MemoryGetStepsQuery as m, type RouteDefinition as n, AGENT_ROUTES as o, OBSERVABILITY_MEMORY_ROUTES as p, ALL_ROUTES as q, getAllRoutesArray as r, MCP_ROUTES as s, A2A_ROUTES as t, getRoutesByTag as u, parseJsonRpcRequest as v, resolveAgentCard as w, executeA2ARequest as x, type A2AJsonRpcId as y, type JsonRpcResponse as z };
package/dist/edge.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, x as executeA2ARequest, ai as getConversationMessagesHandler, aj as getConversationStepsHandler, aq as getOrCreateLogger, ak as getWorkingMemoryHandler, $ as handleChatStream, a6 as handleExecuteWorkflow, a0 as handleGenerateObject, Z as handleGenerateText, a2 as handleGetAgent, a3 as handleGetAgentHistory, Y as handleGetAgents, af as handleGetLogs, a5 as handleGetWorkflow, ac as handleGetWorkflowState, a4 as handleGetWorkflows, ab as handleListWorkflowRuns, aa as handleResumeWorkflow, a1 as handleStreamObject, _ as handleStreamText, a7 as handleStreamWorkflow, a8 as handleSuspendWorkflow, i as isErrorResponse, ah as listMemoryConversationsHandler, ag as listMemoryUsersHandler, al as mapLogResponse, v as parseJsonRpcRequest, w as resolveAgentCard } from './edge-YtITyx6y.mjs';
1
+ export { F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, x as executeA2ARequest, aj as getConversationMessagesHandler, ak as getConversationStepsHandler, ar as getOrCreateLogger, al as getWorkingMemoryHandler, $ as handleChatStream, a7 as handleExecuteWorkflow, a1 as handleGenerateObject, Z as handleGenerateText, a3 as handleGetAgent, a4 as handleGetAgentHistory, Y as handleGetAgents, ag as handleGetLogs, a6 as handleGetWorkflow, ad as handleGetWorkflowState, a5 as handleGetWorkflows, ac as handleListWorkflowRuns, a0 as handleResumeChatStream, ab as handleResumeWorkflow, a2 as handleStreamObject, _ as handleStreamText, a8 as handleStreamWorkflow, a9 as handleSuspendWorkflow, i as isErrorResponse, ai as listMemoryConversationsHandler, ah as listMemoryUsersHandler, am as mapLogResponse, v as parseJsonRpcRequest, w as resolveAgentCard } from './edge-B9hEI2RV.mjs';
2
2
  import '@voltagent/core';
3
3
  import '@voltagent/internal';
4
4
  import 'ai';
package/dist/edge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, x as executeA2ARequest, ai as getConversationMessagesHandler, aj as getConversationStepsHandler, aq as getOrCreateLogger, ak as getWorkingMemoryHandler, $ as handleChatStream, a6 as handleExecuteWorkflow, a0 as handleGenerateObject, Z as handleGenerateText, a2 as handleGetAgent, a3 as handleGetAgentHistory, Y as handleGetAgents, af as handleGetLogs, a5 as handleGetWorkflow, ac as handleGetWorkflowState, a4 as handleGetWorkflows, ab as handleListWorkflowRuns, aa as handleResumeWorkflow, a1 as handleStreamObject, _ as handleStreamText, a7 as handleStreamWorkflow, a8 as handleSuspendWorkflow, i as isErrorResponse, ah as listMemoryConversationsHandler, ag as listMemoryUsersHandler, al as mapLogResponse, v as parseJsonRpcRequest, w as resolveAgentCard } from './edge-YtITyx6y.js';
1
+ export { F as A2ARequestContext, t as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, x as executeA2ARequest, aj as getConversationMessagesHandler, ak as getConversationStepsHandler, ar as getOrCreateLogger, al as getWorkingMemoryHandler, $ as handleChatStream, a7 as handleExecuteWorkflow, a1 as handleGenerateObject, Z as handleGenerateText, a3 as handleGetAgent, a4 as handleGetAgentHistory, Y as handleGetAgents, ag as handleGetLogs, a6 as handleGetWorkflow, ad as handleGetWorkflowState, a5 as handleGetWorkflows, ac as handleListWorkflowRuns, a0 as handleResumeChatStream, ab as handleResumeWorkflow, a2 as handleStreamObject, _ as handleStreamText, a8 as handleStreamWorkflow, a9 as handleSuspendWorkflow, i as isErrorResponse, ai as listMemoryConversationsHandler, ah as listMemoryUsersHandler, am as mapLogResponse, v as parseJsonRpcRequest, w as resolveAgentCard } from './edge-B9hEI2RV.js';
2
2
  import '@voltagent/core';
3
3
  import '@voltagent/internal';
4
4
  import 'ai';
package/dist/edge.js CHANGED
@@ -44,6 +44,7 @@ __export(edge_exports, {
44
44
  handleGetWorkflowState: () => handleGetWorkflowState,
45
45
  handleGetWorkflows: () => handleGetWorkflows,
46
46
  handleListWorkflowRuns: () => handleListWorkflowRuns,
47
+ handleResumeChatStream: () => handleResumeChatStream,
47
48
  handleResumeWorkflow: () => handleResumeWorkflow,
48
49
  handleStreamObject: () => handleStreamObject,
49
50
  handleStreamText: () => handleStreamText,
@@ -185,6 +186,36 @@ var AGENT_ROUTES = {
185
186
  }
186
187
  }
187
188
  },
189
+ resumeChatStream: {
190
+ method: "get",
191
+ path: "/agents/:id/chat/:conversationId/stream",
192
+ summary: "Resume chat stream",
193
+ description: "Resume an in-progress UI message stream for a chat conversation. Requires userId query parameter. Returns 204 if no active stream is found.",
194
+ tags: ["Agent Generation"],
195
+ operationId: "resumeChatStream",
196
+ responses: {
197
+ 200: {
198
+ description: "Successfully resumed SSE stream for chat generation",
199
+ contentType: "text/event-stream"
200
+ },
201
+ 400: {
202
+ description: "Missing or invalid userId",
203
+ contentType: "application/json"
204
+ },
205
+ 204: {
206
+ description: "No active stream found for the conversation",
207
+ contentType: "text/plain"
208
+ },
209
+ 404: {
210
+ description: "Resumable streams not configured",
211
+ contentType: "application/json"
212
+ },
213
+ 500: {
214
+ description: "Failed to resume chat stream due to server error",
215
+ contentType: "application/json"
216
+ }
217
+ }
218
+ },
188
219
  generateObject: {
189
220
  method: "post",
190
221
  path: "/agents/:id/object",
@@ -948,6 +979,7 @@ var A2A_ROUTES = {
948
979
  var import_core2 = require("@voltagent/core");
949
980
  var import_core3 = require("@voltagent/core");
950
981
  var import_internal = require("@voltagent/internal");
982
+ var import_ai2 = require("ai");
951
983
  var import_zod2 = require("zod");
952
984
  var import_zod_from_json_schema2 = require("zod-from-json-schema");
953
985
  var import_zod_from_json_schema_v32 = require("zod-from-json-schema-v3");
@@ -1170,11 +1202,99 @@ async function handleChatStream(agentId, body, deps, logger, signal) {
1170
1202
  );
1171
1203
  }
1172
1204
  const { input } = body;
1205
+ const originalMessages = Array.isArray(input) && input.length > 0 && input.every((message) => Array.isArray(message.parts)) ? input : void 0;
1206
+ let resumableStreamRequested = typeof body?.options?.resumableStream === "boolean" ? body.options.resumableStream : deps.resumableStreamDefault ?? false;
1173
1207
  const options = processAgentOptions(body, signal);
1208
+ const conversationId = typeof options.conversationId === "string" ? options.conversationId : void 0;
1209
+ const userId = typeof options.userId === "string" && options.userId.trim().length > 0 ? options.userId : void 0;
1210
+ const resumableEnabled = Boolean(deps.resumableStream);
1211
+ const resumableStreamEnabled = resumableEnabled && resumableStreamRequested === true && Boolean(conversationId) && Boolean(userId);
1212
+ if (resumableStreamRequested === true && !resumableEnabled) {
1213
+ logger.warn(
1214
+ "Resumable streams requested but not configured. Falling back to non-resumable streams.",
1215
+ {
1216
+ docsUrl: "https://voltagent.dev/docs/agents/resumable-streaming/"
1217
+ }
1218
+ );
1219
+ resumableStreamRequested = false;
1220
+ }
1221
+ if (resumableStreamRequested === true && !conversationId) {
1222
+ return new Response(
1223
+ (0, import_internal.safeStringify)({
1224
+ error: "conversationId is required for resumable streams",
1225
+ message: "conversationId is required for resumable streams"
1226
+ }),
1227
+ {
1228
+ status: 400,
1229
+ headers: {
1230
+ "Content-Type": "application/json"
1231
+ }
1232
+ }
1233
+ );
1234
+ }
1235
+ if (resumableStreamRequested === true && !userId) {
1236
+ return new Response(
1237
+ (0, import_internal.safeStringify)({
1238
+ error: "userId is required for resumable streams",
1239
+ message: "userId is required for resumable streams"
1240
+ }),
1241
+ {
1242
+ status: 400,
1243
+ headers: {
1244
+ "Content-Type": "application/json"
1245
+ }
1246
+ }
1247
+ );
1248
+ }
1249
+ if (resumableStreamEnabled) {
1250
+ options.abortSignal = void 0;
1251
+ }
1252
+ options.resumableStream = resumableStreamEnabled;
1253
+ const resumableStreamAdapter = deps.resumableStream;
1254
+ if (resumableStreamEnabled && resumableStreamAdapter && conversationId && userId) {
1255
+ try {
1256
+ await resumableStreamAdapter.clearActiveStream({ conversationId, agentId, userId });
1257
+ } catch (error) {
1258
+ logger.warn("Failed to clear active resumable stream", { error });
1259
+ }
1260
+ }
1174
1261
  const result = await agent.streamText(input, options);
1262
+ let activeStreamId = null;
1175
1263
  return result.toUIMessageStreamResponse({
1264
+ originalMessages,
1265
+ generateMessageId: import_ai2.generateId,
1176
1266
  sendReasoning: true,
1177
- sendSources: true
1267
+ sendSources: true,
1268
+ consumeSseStream: /* @__PURE__ */ __name(async ({ stream }) => {
1269
+ if (!resumableStreamEnabled || !resumableStreamAdapter || !conversationId || !userId) {
1270
+ return;
1271
+ }
1272
+ try {
1273
+ activeStreamId = await resumableStreamAdapter.createStream({
1274
+ conversationId,
1275
+ agentId,
1276
+ userId,
1277
+ stream
1278
+ });
1279
+ } catch (error) {
1280
+ logger.error("Failed to persist resumable chat stream", { error });
1281
+ }
1282
+ }, "consumeSseStream"),
1283
+ onFinish: /* @__PURE__ */ __name(async () => {
1284
+ if (!resumableStreamEnabled || !resumableStreamAdapter || !conversationId || !userId) {
1285
+ return;
1286
+ }
1287
+ try {
1288
+ await resumableStreamAdapter.clearActiveStream({
1289
+ conversationId,
1290
+ agentId,
1291
+ userId,
1292
+ streamId: activeStreamId ?? void 0
1293
+ });
1294
+ } catch (error) {
1295
+ logger.error("Failed to clear resumable chat stream", { error });
1296
+ }
1297
+ }, "onFinish")
1178
1298
  });
1179
1299
  } catch (error) {
1180
1300
  logger.error("Failed to handle chat stream request", { error });
@@ -1194,6 +1314,70 @@ async function handleChatStream(agentId, body, deps, logger, signal) {
1194
1314
  }
1195
1315
  }
1196
1316
  __name(handleChatStream, "handleChatStream");
1317
+ async function handleResumeChatStream(agentId, conversationId, deps, logger, userId) {
1318
+ try {
1319
+ if (!deps.resumableStream) {
1320
+ return new Response(null, { status: 204 });
1321
+ }
1322
+ if (!userId) {
1323
+ return new Response(
1324
+ (0, import_internal.safeStringify)({
1325
+ error: "userId is required for resumable streams",
1326
+ message: "userId is required for resumable streams"
1327
+ }),
1328
+ {
1329
+ status: 400,
1330
+ headers: {
1331
+ "Content-Type": "application/json"
1332
+ }
1333
+ }
1334
+ );
1335
+ }
1336
+ const streamId = await deps.resumableStream.getActiveStreamId({
1337
+ conversationId,
1338
+ agentId,
1339
+ userId
1340
+ });
1341
+ if (!streamId) {
1342
+ return new Response(null, { status: 204 });
1343
+ }
1344
+ const stream = await deps.resumableStream.resumeStream(streamId);
1345
+ if (!stream) {
1346
+ try {
1347
+ await deps.resumableStream.clearActiveStream({
1348
+ conversationId,
1349
+ agentId,
1350
+ userId,
1351
+ streamId
1352
+ });
1353
+ } catch (error) {
1354
+ logger.warn("Failed to clear inactive resumable stream", { error });
1355
+ }
1356
+ return new Response(null, { status: 204 });
1357
+ }
1358
+ const encodedStream = stream.pipeThrough(new TextEncoderStream());
1359
+ return new Response(encodedStream, {
1360
+ status: 200,
1361
+ headers: import_ai2.UI_MESSAGE_STREAM_HEADERS
1362
+ });
1363
+ } catch (error) {
1364
+ logger.error("Failed to resume chat stream", { error });
1365
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
1366
+ return new Response(
1367
+ (0, import_internal.safeStringify)({
1368
+ error: errorMessage,
1369
+ message: errorMessage
1370
+ }),
1371
+ {
1372
+ status: 500,
1373
+ headers: {
1374
+ "Content-Type": "application/json"
1375
+ }
1376
+ }
1377
+ );
1378
+ }
1379
+ }
1380
+ __name(handleResumeChatStream, "handleResumeChatStream");
1197
1381
  async function handleGenerateObject(agentId, body, deps, logger, signal) {
1198
1382
  try {
1199
1383
  const agent = deps.agentRegistry.getAgent(agentId);
@@ -2378,6 +2562,7 @@ __name(mapLogResponse, "mapLogResponse");
2378
2562
  handleGetWorkflowState,
2379
2563
  handleGetWorkflows,
2380
2564
  handleListWorkflowRuns,
2565
+ handleResumeChatStream,
2381
2566
  handleResumeWorkflow,
2382
2567
  handleStreamObject,
2383
2568
  handleStreamText,