@hotmeshio/long-tail 0.7.0 → 0.7.1

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.
@@ -29,18 +29,6 @@ async function handleCompletion(state, result) {
29
29
  ],
30
30
  }
31
31
  : result;
32
- // Publish workflow.completed event
33
- (0, publish_1.publishWorkflowEvent)({
34
- type: 'workflow.completed',
35
- source: 'interceptor',
36
- workflowId: state.workflowId,
37
- workflowName: state.workflowName,
38
- taskQueue: state.taskQueue,
39
- taskId: state.taskId,
40
- originId: state.envelope?.lt?.originId,
41
- status: 'completed',
42
- data: augmentedResult.data,
43
- });
44
32
  // Publish milestone event (non-durable side effect, fire-and-forget)
45
33
  if (augmentedResult.milestones?.length) {
46
34
  (0, publish_1.publishMilestoneEvent)({
@@ -82,6 +70,23 @@ async function handleCompletion(state, result) {
82
70
  taskQueue: state.taskQueue,
83
71
  });
84
72
  }
73
+ // Publish workflow.completed LAST — after every interrupting proxy call.
74
+ // This code is workflow code: each durable activity above interrupts the
75
+ // function on first dispatch and the whole leg replays, so a fire-and-forget
76
+ // publish placed before them fires once per replay (observed live as doubled
77
+ // workflow.completed events). Only the final, uninterrupted execution
78
+ // reaches this point, so the event publishes exactly once per completion.
79
+ (0, publish_1.publishWorkflowEvent)({
80
+ type: 'workflow.completed',
81
+ source: 'interceptor',
82
+ workflowId: state.workflowId,
83
+ workflowName: state.workflowName,
84
+ taskQueue: state.taskQueue,
85
+ taskId: state.taskId,
86
+ originId: state.envelope?.lt?.originId,
87
+ status: 'completed',
88
+ data: augmentedResult.data,
89
+ });
85
90
  return augmentedResult;
86
91
  }
87
92
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -71,7 +71,7 @@
71
71
  "@anthropic-ai/sdk": "^0.92.0",
72
72
  "@aws-sdk/client-s3": "^3.1017.0",
73
73
  "@aws-sdk/s3-request-presigner": "^3.1045.0",
74
- "@hotmeshio/hotmesh": "^0.25.1",
74
+ "@hotmeshio/hotmesh": "^0.25.2",
75
75
  "@modelcontextprotocol/sdk": "^1.27.1",
76
76
  "@opentelemetry/exporter-trace-otlp-proto": "^0.215.0",
77
77
  "@opentelemetry/resources": "^2.5.1",