@voltagent/core 2.4.3 → 2.4.4
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.
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -10056,6 +10056,10 @@ interface WorkflowRunOptions {
|
|
|
10056
10056
|
* The user ID, this can be used to track the current user in a workflow
|
|
10057
10057
|
*/
|
|
10058
10058
|
userId?: string;
|
|
10059
|
+
/**
|
|
10060
|
+
* Additional execution metadata persisted with workflow state
|
|
10061
|
+
*/
|
|
10062
|
+
metadata?: Record<string, unknown>;
|
|
10059
10063
|
/**
|
|
10060
10064
|
* The user context, this can be used to track the current user context in a workflow
|
|
10061
10065
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -10056,6 +10056,10 @@ interface WorkflowRunOptions {
|
|
|
10056
10056
|
* The user ID, this can be used to track the current user in a workflow
|
|
10057
10057
|
*/
|
|
10058
10058
|
userId?: string;
|
|
10059
|
+
/**
|
|
10060
|
+
* Additional execution metadata persisted with workflow state
|
|
10061
|
+
*/
|
|
10062
|
+
metadata?: Record<string, unknown>;
|
|
10059
10063
|
/**
|
|
10060
10064
|
* The user context, this can be used to track the current user context in a workflow
|
|
10061
10065
|
*/
|
package/dist/index.js
CHANGED
|
@@ -9701,6 +9701,13 @@ function createWorkflow({
|
|
|
9701
9701
|
} else {
|
|
9702
9702
|
executionId = options?.executionId || randomUUID();
|
|
9703
9703
|
}
|
|
9704
|
+
const mergeExecutionMetadata = /* @__PURE__ */ __name(async (patch) => {
|
|
9705
|
+
const existingState = await executionMemory.getWorkflowState(executionId);
|
|
9706
|
+
return {
|
|
9707
|
+
...existingState?.metadata ?? {},
|
|
9708
|
+
...patch
|
|
9709
|
+
};
|
|
9710
|
+
}, "mergeExecutionMetadata");
|
|
9704
9711
|
const streamController = externalStreamController || null;
|
|
9705
9712
|
const collectedEvents = [];
|
|
9706
9713
|
const emitAndCollectEvent = /* @__PURE__ */ __name((event) => {
|
|
@@ -9725,6 +9732,7 @@ function createWorkflow({
|
|
|
9725
9732
|
}, "emitAndCollectEvent");
|
|
9726
9733
|
const observability = getObservability();
|
|
9727
9734
|
const contextMap = options?.context instanceof Map ? options.context : options?.context ? new Map(Object.entries(options.context)) : /* @__PURE__ */ new Map();
|
|
9735
|
+
const optionMetadata = options?.metadata && typeof options.metadata === "object" && !Array.isArray(options.metadata) ? options.metadata : void 0;
|
|
9728
9736
|
const workflowStateStore = options?.workflowState ?? {};
|
|
9729
9737
|
let resumedFrom;
|
|
9730
9738
|
if (options?.resumeFrom?.executionId) {
|
|
@@ -9818,6 +9826,7 @@ function createWorkflow({
|
|
|
9818
9826
|
userId: options?.userId,
|
|
9819
9827
|
conversationId: options?.conversationId,
|
|
9820
9828
|
metadata: {
|
|
9829
|
+
...optionMetadata ?? {},
|
|
9821
9830
|
traceId: rootSpan.spanContext().traceId,
|
|
9822
9831
|
spanId: rootSpan.spanContext().spanId
|
|
9823
9832
|
},
|
|
@@ -10044,10 +10053,10 @@ function createWorkflow({
|
|
|
10044
10053
|
cancelledAt: /* @__PURE__ */ new Date(),
|
|
10045
10054
|
reason
|
|
10046
10055
|
},
|
|
10047
|
-
metadata: {
|
|
10056
|
+
metadata: await mergeExecutionMetadata({
|
|
10048
10057
|
...stateManager.state?.usage ? { usage: stateManager.state.usage } : {},
|
|
10049
10058
|
cancellationReason: reason
|
|
10050
|
-
},
|
|
10059
|
+
}),
|
|
10051
10060
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10052
10061
|
});
|
|
10053
10062
|
} catch (memoryError) {
|
|
@@ -10580,10 +10589,10 @@ function createWorkflow({
|
|
|
10580
10589
|
await executionMemory.updateWorkflowState(executionId, {
|
|
10581
10590
|
status: "cancelled",
|
|
10582
10591
|
workflowState: stateManager.state.workflowState,
|
|
10583
|
-
metadata: {
|
|
10592
|
+
metadata: await mergeExecutionMetadata({
|
|
10584
10593
|
...stateManager.state?.usage ? { usage: stateManager.state.usage } : {},
|
|
10585
10594
|
cancellationReason
|
|
10586
|
-
},
|
|
10595
|
+
}),
|
|
10587
10596
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10588
10597
|
});
|
|
10589
10598
|
} catch (memoryError) {
|
|
@@ -10659,10 +10668,10 @@ function createWorkflow({
|
|
|
10659
10668
|
workflowState: stateManager.state.workflowState,
|
|
10660
10669
|
events: collectedEvents,
|
|
10661
10670
|
// Store a lightweight error summary in metadata for debugging
|
|
10662
|
-
metadata: {
|
|
10671
|
+
metadata: await mergeExecutionMetadata({
|
|
10663
10672
|
...stateManager.state?.usage ? { usage: stateManager.state.usage } : {},
|
|
10664
10673
|
errorMessage: error instanceof Error ? error.message : String(error)
|
|
10665
|
-
},
|
|
10674
|
+
}),
|
|
10666
10675
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10667
10676
|
});
|
|
10668
10677
|
} catch (memoryError) {
|
|
@@ -10786,6 +10795,7 @@ function createWorkflow({
|
|
|
10786
10795
|
resumedReject = reject;
|
|
10787
10796
|
}
|
|
10788
10797
|
);
|
|
10798
|
+
const resumedSuspendController = createSuspendController();
|
|
10789
10799
|
const executeResume = /* @__PURE__ */ __name(async () => {
|
|
10790
10800
|
if (!execResult.suspension) {
|
|
10791
10801
|
throw new Error("No suspension metadata found");
|
|
@@ -10808,7 +10818,7 @@ function createWorkflow({
|
|
|
10808
10818
|
resumeStepIndex,
|
|
10809
10819
|
resumeData: input3
|
|
10810
10820
|
},
|
|
10811
|
-
suspendController
|
|
10821
|
+
suspendController: resumedSuspendController
|
|
10812
10822
|
};
|
|
10813
10823
|
const resumed = await executeInternal(
|
|
10814
10824
|
originalInput,
|
|
@@ -10851,10 +10861,10 @@ function createWorkflow({
|
|
|
10851
10861
|
return streamResult.resume(input22, opts2);
|
|
10852
10862
|
}, "resume"),
|
|
10853
10863
|
suspend: /* @__PURE__ */ __name((reason) => {
|
|
10854
|
-
|
|
10864
|
+
resumedSuspendController.suspend(reason);
|
|
10855
10865
|
}, "suspend"),
|
|
10856
10866
|
cancel: /* @__PURE__ */ __name((reason) => {
|
|
10857
|
-
|
|
10867
|
+
resumedSuspendController.cancel(reason);
|
|
10858
10868
|
}, "cancel"),
|
|
10859
10869
|
abort: /* @__PURE__ */ __name(() => streamController.abort(), "abort"),
|
|
10860
10870
|
toUIMessageStreamResponse: eventToUIMessageStreamResponse(streamController),
|