@voltagent/server-core 2.1.4 → 2.1.5

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.
@@ -499,7 +499,7 @@ declare const WORKFLOW_ROUTES: {
499
499
  readonly method: "get";
500
500
  readonly path: "/workflows/executions";
501
501
  readonly summary: "List workflow executions (query-driven)";
502
- readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset) without path parameters.";
502
+ readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset, userId) without path parameters. You can also filter metadata with `metadata` (JSON object) or key-based params such as `metadata.tenantId=acme`.";
503
503
  readonly tags: readonly ["Workflow Management"];
504
504
  readonly operationId: "listWorkflowRuns";
505
505
  readonly responses: {
@@ -2105,7 +2105,7 @@ declare const ALL_ROUTES: {
2105
2105
  readonly method: "get";
2106
2106
  readonly path: "/workflows/executions";
2107
2107
  readonly summary: "List workflow executions (query-driven)";
2108
- readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset) without path parameters.";
2108
+ readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset, userId) without path parameters. You can also filter metadata with `metadata` (JSON object) or key-based params such as `metadata.tenantId=acme`.";
2109
2109
  readonly tags: readonly ["Workflow Management"];
2110
2110
  readonly operationId: "listWorkflowRuns";
2111
2111
  readonly responses: {
@@ -3118,17 +3118,20 @@ declare function handleCancelWorkflow(executionId: string, body: any, deps: Serv
3118
3118
  * Returns resume result
3119
3119
  */
3120
3120
  declare function handleResumeWorkflow(workflowId: string, executionId: string, body: any, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3121
+ type WorkflowRunsQuery = {
3122
+ status?: string | number;
3123
+ from?: string | number;
3124
+ to?: string | number;
3125
+ limit?: string | number;
3126
+ offset?: string | number;
3127
+ workflowId?: string | number;
3128
+ userId?: string | number;
3129
+ metadata?: string;
3130
+ } & Record<string, string | number | undefined>;
3121
3131
  /**
3122
3132
  * Handler for listing workflow execution runs
3123
3133
  */
3124
- declare function handleListWorkflowRuns(workflowId: string | undefined, query: {
3125
- status?: string;
3126
- from?: string;
3127
- to?: string;
3128
- limit?: string;
3129
- offset?: string;
3130
- workflowId?: string;
3131
- } | undefined, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3134
+ declare function handleListWorkflowRuns(workflowId: string | undefined, query: WorkflowRunsQuery | undefined, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3132
3135
  /**
3133
3136
  * Handler for getting workflow execution state
3134
3137
  * Returns workflow state from Memory V2
@@ -499,7 +499,7 @@ declare const WORKFLOW_ROUTES: {
499
499
  readonly method: "get";
500
500
  readonly path: "/workflows/executions";
501
501
  readonly summary: "List workflow executions (query-driven)";
502
- readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset) without path parameters.";
502
+ readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset, userId) without path parameters. You can also filter metadata with `metadata` (JSON object) or key-based params such as `metadata.tenantId=acme`.";
503
503
  readonly tags: readonly ["Workflow Management"];
504
504
  readonly operationId: "listWorkflowRuns";
505
505
  readonly responses: {
@@ -2105,7 +2105,7 @@ declare const ALL_ROUTES: {
2105
2105
  readonly method: "get";
2106
2106
  readonly path: "/workflows/executions";
2107
2107
  readonly summary: "List workflow executions (query-driven)";
2108
- readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset) without path parameters.";
2108
+ readonly description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset, userId) without path parameters. You can also filter metadata with `metadata` (JSON object) or key-based params such as `metadata.tenantId=acme`.";
2109
2109
  readonly tags: readonly ["Workflow Management"];
2110
2110
  readonly operationId: "listWorkflowRuns";
2111
2111
  readonly responses: {
@@ -3118,17 +3118,20 @@ declare function handleCancelWorkflow(executionId: string, body: any, deps: Serv
3118
3118
  * Returns resume result
3119
3119
  */
3120
3120
  declare function handleResumeWorkflow(workflowId: string, executionId: string, body: any, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3121
+ type WorkflowRunsQuery = {
3122
+ status?: string | number;
3123
+ from?: string | number;
3124
+ to?: string | number;
3125
+ limit?: string | number;
3126
+ offset?: string | number;
3127
+ workflowId?: string | number;
3128
+ userId?: string | number;
3129
+ metadata?: string;
3130
+ } & Record<string, string | number | undefined>;
3121
3131
  /**
3122
3132
  * Handler for listing workflow execution runs
3123
3133
  */
3124
- declare function handleListWorkflowRuns(workflowId: string | undefined, query: {
3125
- status?: string;
3126
- from?: string;
3127
- to?: string;
3128
- limit?: string;
3129
- offset?: string;
3130
- workflowId?: string;
3131
- } | undefined, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3134
+ declare function handleListWorkflowRuns(workflowId: string | undefined, query: WorkflowRunsQuery | undefined, deps: ServerProviderDeps, logger: Logger): Promise<ApiResponse>;
3132
3135
  /**
3133
3136
  * Handler for getting workflow execution state
3134
3137
  * Returns workflow state from Memory V2
package/dist/edge.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as A2ARequestContext, u as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, q as MEMORY_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, y as executeA2ARequest, aB as getConversationMessagesHandler, aC as getConversationStepsHandler, aJ as getOrCreateLogger, aD as getWorkingMemoryHandler, a0 as handleChatStream, av as handleCloneMemoryConversation, as as handleCreateMemoryConversation, au as handleDeleteMemoryConversation, ax as handleDeleteMemoryMessages, ad as handleExecuteWorkflow, a2 as handleGenerateObject, _ as handleGenerateText, a4 as handleGetAgent, a5 as handleGetAgentHistory, Z as handleGetAgents, am as handleGetLogs, ao as handleGetMemoryConversation, aq as handleGetMemoryWorkingMemory, ac as handleGetWorkflow, aj as handleGetWorkflowState, ab as handleGetWorkflows, ap as handleListMemoryConversationMessages, an as handleListMemoryConversations, ai as handleListWorkflowRuns, a1 as handleResumeChatStream, ah as handleResumeWorkflow, ar as handleSaveMemoryMessages, ay as handleSearchMemory, a3 as handleStreamObject, $ as handleStreamText, ae as handleStreamWorkflow, af as handleSuspendWorkflow, at as handleUpdateMemoryConversation, aw as handleUpdateMemoryWorkingMemory, i as isErrorResponse, aA as listMemoryConversationsHandler, az as listMemoryUsersHandler, aE as mapLogResponse, w as parseJsonRpcRequest, x as resolveAgentCard } from './edge-C2G_rHKs.mjs';
1
+ export { G as A2ARequestContext, u as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, q as MEMORY_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, y as executeA2ARequest, aB as getConversationMessagesHandler, aC as getConversationStepsHandler, aJ as getOrCreateLogger, aD as getWorkingMemoryHandler, a0 as handleChatStream, av as handleCloneMemoryConversation, as as handleCreateMemoryConversation, au as handleDeleteMemoryConversation, ax as handleDeleteMemoryMessages, ad as handleExecuteWorkflow, a2 as handleGenerateObject, _ as handleGenerateText, a4 as handleGetAgent, a5 as handleGetAgentHistory, Z as handleGetAgents, am as handleGetLogs, ao as handleGetMemoryConversation, aq as handleGetMemoryWorkingMemory, ac as handleGetWorkflow, aj as handleGetWorkflowState, ab as handleGetWorkflows, ap as handleListMemoryConversationMessages, an as handleListMemoryConversations, ai as handleListWorkflowRuns, a1 as handleResumeChatStream, ah as handleResumeWorkflow, ar as handleSaveMemoryMessages, ay as handleSearchMemory, a3 as handleStreamObject, $ as handleStreamText, ae as handleStreamWorkflow, af as handleSuspendWorkflow, at as handleUpdateMemoryConversation, aw as handleUpdateMemoryWorkingMemory, i as isErrorResponse, aA as listMemoryConversationsHandler, az as listMemoryUsersHandler, aE as mapLogResponse, w as parseJsonRpcRequest, x as resolveAgentCard } from './edge-pCgIZLUz.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 { G as A2ARequestContext, u as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, q as MEMORY_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, y as executeA2ARequest, aB as getConversationMessagesHandler, aC as getConversationStepsHandler, aJ as getOrCreateLogger, aD as getWorkingMemoryHandler, a0 as handleChatStream, av as handleCloneMemoryConversation, as as handleCreateMemoryConversation, au as handleDeleteMemoryConversation, ax as handleDeleteMemoryMessages, ad as handleExecuteWorkflow, a2 as handleGenerateObject, _ as handleGenerateText, a4 as handleGetAgent, a5 as handleGetAgentHistory, Z as handleGetAgents, am as handleGetLogs, ao as handleGetMemoryConversation, aq as handleGetMemoryWorkingMemory, ac as handleGetWorkflow, aj as handleGetWorkflowState, ab as handleGetWorkflows, ap as handleListMemoryConversationMessages, an as handleListMemoryConversations, ai as handleListWorkflowRuns, a1 as handleResumeChatStream, ah as handleResumeWorkflow, ar as handleSaveMemoryMessages, ay as handleSearchMemory, a3 as handleStreamObject, $ as handleStreamText, ae as handleStreamWorkflow, af as handleSuspendWorkflow, at as handleUpdateMemoryConversation, aw as handleUpdateMemoryWorkingMemory, i as isErrorResponse, aA as listMemoryConversationsHandler, az as listMemoryUsersHandler, aE as mapLogResponse, w as parseJsonRpcRequest, x as resolveAgentCard } from './edge-C2G_rHKs.js';
1
+ export { G as A2ARequestContext, u as A2A_ROUTES, o as AGENT_ROUTES, L as LOG_ROUTES, q as MEMORY_ROUTES, p as OBSERVABILITY_MEMORY_ROUTES, O as OBSERVABILITY_ROUTES, W as WORKFLOW_ROUTES, y as executeA2ARequest, aB as getConversationMessagesHandler, aC as getConversationStepsHandler, aJ as getOrCreateLogger, aD as getWorkingMemoryHandler, a0 as handleChatStream, av as handleCloneMemoryConversation, as as handleCreateMemoryConversation, au as handleDeleteMemoryConversation, ax as handleDeleteMemoryMessages, ad as handleExecuteWorkflow, a2 as handleGenerateObject, _ as handleGenerateText, a4 as handleGetAgent, a5 as handleGetAgentHistory, Z as handleGetAgents, am as handleGetLogs, ao as handleGetMemoryConversation, aq as handleGetMemoryWorkingMemory, ac as handleGetWorkflow, aj as handleGetWorkflowState, ab as handleGetWorkflows, ap as handleListMemoryConversationMessages, an as handleListMemoryConversations, ai as handleListWorkflowRuns, a1 as handleResumeChatStream, ah as handleResumeWorkflow, ar as handleSaveMemoryMessages, ay as handleSearchMemory, a3 as handleStreamObject, $ as handleStreamText, ae as handleStreamWorkflow, af as handleSuspendWorkflow, at as handleUpdateMemoryConversation, aw as handleUpdateMemoryWorkingMemory, i as isErrorResponse, aA as listMemoryConversationsHandler, az as listMemoryUsersHandler, aE as mapLogResponse, w as parseJsonRpcRequest, x as resolveAgentCard } from './edge-pCgIZLUz.js';
2
2
  import '@voltagent/core';
3
3
  import '@voltagent/internal';
4
4
  import 'ai';
package/dist/edge.js CHANGED
@@ -467,7 +467,7 @@ var WORKFLOW_ROUTES = {
467
467
  method: "get",
468
468
  path: "/workflows/executions",
469
469
  summary: "List workflow executions (query-driven)",
470
- description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset) without path parameters.",
470
+ description: "Retrieve workflow executions using query params (workflowId, status, from, to, limit, offset, userId) without path parameters. You can also filter metadata with `metadata` (JSON object) or key-based params such as `metadata.tenantId=acme`.",
471
471
  tags: ["Workflow Management"],
472
472
  operationId: "listWorkflowRuns",
473
473
  responses: {
@@ -2305,27 +2305,108 @@ function formatWorkflowState(workflowState) {
2305
2305
  };
2306
2306
  }
2307
2307
  __name(formatWorkflowState, "formatWorkflowState");
2308
+ var WORKFLOW_RUN_STATUSES = /* @__PURE__ */ new Set([
2309
+ "running",
2310
+ "suspended",
2311
+ "completed",
2312
+ "cancelled",
2313
+ "error"
2314
+ ]);
2315
+ var WORKFLOW_RUN_STATUS_ALIASES = {
2316
+ success: "completed",
2317
+ pending: "running"
2318
+ };
2319
+ function normalizeWorkflowRunStatus(value) {
2320
+ if (value === void 0) {
2321
+ return void 0;
2322
+ }
2323
+ const normalized = String(value).trim().toLowerCase();
2324
+ const resolved = WORKFLOW_RUN_STATUS_ALIASES[normalized] ?? normalized;
2325
+ if (WORKFLOW_RUN_STATUSES.has(resolved)) {
2326
+ return resolved;
2327
+ }
2328
+ return void 0;
2329
+ }
2330
+ __name(normalizeWorkflowRunStatus, "normalizeWorkflowRunStatus");
2331
+ function parseQueryNumber(value, options) {
2332
+ if (value === void 0) {
2333
+ return void 0;
2334
+ }
2335
+ const parsed = typeof value === "number" ? value : Number(value);
2336
+ if (!Number.isFinite(parsed)) {
2337
+ return void 0;
2338
+ }
2339
+ if (options?.min !== void 0 && parsed < options.min) {
2340
+ return void 0;
2341
+ }
2342
+ return parsed;
2343
+ }
2344
+ __name(parseQueryNumber, "parseQueryNumber");
2345
+ function parseQueryDate(value) {
2346
+ if (value === void 0) {
2347
+ return void 0;
2348
+ }
2349
+ const parsed = new Date(String(value));
2350
+ if (Number.isNaN(parsed.getTime())) {
2351
+ return void 0;
2352
+ }
2353
+ return parsed;
2354
+ }
2355
+ __name(parseQueryDate, "parseQueryDate");
2356
+ function parseMetadataFilterValue(value) {
2357
+ if (typeof value === "number") {
2358
+ return value;
2359
+ }
2360
+ try {
2361
+ return JSON.parse(value);
2362
+ } catch {
2363
+ return value;
2364
+ }
2365
+ }
2366
+ __name(parseMetadataFilterValue, "parseMetadataFilterValue");
2367
+ function parseMetadataFilters(query, logger) {
2368
+ const metadataFilters = {};
2369
+ const rawMetadata = query?.metadata;
2370
+ if (typeof rawMetadata === "string") {
2371
+ try {
2372
+ const parsed = JSON.parse(rawMetadata);
2373
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
2374
+ Object.assign(metadataFilters, parsed);
2375
+ }
2376
+ } catch (error) {
2377
+ logger.warn("Ignoring invalid workflow metadata filter payload", {
2378
+ metadata: rawMetadata,
2379
+ error
2380
+ });
2381
+ }
2382
+ }
2383
+ for (const [key, value] of Object.entries(query ?? {})) {
2384
+ if (!key.startsWith("metadata.") || value === void 0) {
2385
+ continue;
2386
+ }
2387
+ const metadataKey = key.slice("metadata.".length).trim();
2388
+ if (!metadataKey) {
2389
+ continue;
2390
+ }
2391
+ metadataFilters[metadataKey] = parseMetadataFilterValue(value);
2392
+ }
2393
+ return Object.keys(metadataFilters).length > 0 ? metadataFilters : void 0;
2394
+ }
2395
+ __name(parseMetadataFilters, "parseMetadataFilters");
2308
2396
  async function handleListWorkflowRuns(workflowId, query, deps, logger) {
2309
2397
  try {
2310
- const effectiveWorkflowId = query?.workflowId ?? workflowId;
2398
+ const effectiveWorkflowId = query?.workflowId !== void 0 ? String(query.workflowId) : workflowId;
2399
+ const metadataFilters = parseMetadataFilters(query, logger);
2311
2400
  const filters = {
2312
2401
  workflowId: effectiveWorkflowId,
2313
- status: query?.status,
2314
- limit: query?.limit ? Number(query.limit) : void 0,
2315
- offset: query?.offset ? Number(query.offset) : void 0
2402
+ status: normalizeWorkflowRunStatus(query?.status),
2403
+ limit: parseQueryNumber(query?.limit, { min: 1 }),
2404
+ offset: parseQueryNumber(query?.offset, { min: 0 }),
2405
+ userId: query?.userId !== void 0 ? String(query.userId) : void 0,
2406
+ metadata: metadataFilters
2316
2407
  };
2317
- if (query?.from) {
2318
- const fromDate = new Date(query.from);
2319
- if (!Number.isNaN(fromDate.getTime())) {
2320
- filters.from = fromDate;
2321
- }
2322
- }
2323
- if (query?.to) {
2324
- const toDate = new Date(query.to);
2325
- if (!Number.isNaN(toDate.getTime())) {
2326
- filters.to = toDate;
2327
- }
2328
- }
2408
+ filters.from = parseQueryDate(query?.from);
2409
+ filters.to = parseQueryDate(query?.to);
2329
2410
  if (effectiveWorkflowId) {
2330
2411
  const registeredWorkflow = deps.workflowRegistry.getWorkflow(effectiveWorkflowId);
2331
2412
  if (!registeredWorkflow) {