@lovable.dev/workflows-sdk 0.0.0-dev.32 → 0.0.0-dev.33

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.
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/branch-metadata.ts
3
3
  const optionsArgument = {
4
4
  step: 2,
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/context-escapes.ts
3
3
  const durableMethods = /* @__PURE__ */ new Set([
4
4
  "step",
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/duplicate-ids.ts
3
3
  /** Where an explicit `{ id }` would sit for each operation. */
4
4
  const optionsArgument = {
@@ -6626,7 +6626,7 @@ function listValueFromJson(listValue, json) {
6626
6626
  }
6627
6627
  //#endregion
6628
6628
  //#region package.json
6629
- var version = "0.0.0-dev.32";
6629
+ var version = "0.0.0-dev.33";
6630
6630
  //#endregion
6631
6631
  //#region src/proto/lovable/appworkflows/v1/workflow_manifest_pb.ts
6632
6632
  /**
@@ -6819,14 +6819,14 @@ function serializeSchema(schema, direction, label) {
6819
6819
  }
6820
6820
  }
6821
6821
  async function generateManifests(definition, options = {}) {
6822
- const { extractWorkflowGraph } = await import("./graph-Cd9aL2HY.js");
6823
- const { findBranchMetadataIssues } = await import("./branch-metadata-DmTc2agd.js");
6824
- const { findWorkflowContextEscapes } = await import("./context-escapes-DjpWclA6.js");
6825
- const { findDuplicateOperationIds } = await import("./duplicate-ids-D7HMDNMh.js");
6822
+ const { extractWorkflowGraph } = await import("./graph-ZthZ8l6y.js");
6823
+ const { findBranchMetadataIssues } = await import("./branch-metadata-6pwT4Ei_.js");
6824
+ const { findWorkflowContextEscapes } = await import("./context-escapes-B66nJs0o.js");
6825
+ const { findDuplicateOperationIds } = await import("./duplicate-ids-CTd1_la_.js");
6826
6826
  const { DURABLE_ID_REQUIRED } = await import("./durable-ids-Cx341nJQ.js").then((n) => n.n);
6827
- const { findNestedDurableOperations } = await import("./nested-operations-DgjRz2Ps.js");
6828
- const { findOperationDescriptionIssues } = await import("./operation-descriptions-5RfHLwu3.js");
6829
- const { findStepMetadataIssues } = await import("./step-metadata-BdT25yO4.js");
6827
+ const { findNestedDurableOperations } = await import("./nested-operations-CuDUxJl4.js");
6828
+ const { findOperationDescriptionIssues } = await import("./operation-descriptions-F6LKn5jJ.js");
6829
+ const { findStepMetadataIssues } = await import("./step-metadata-B3mdzOIH.js");
6830
6830
  const collection = registerWorkflows(definition);
6831
6831
  const manifests = [];
6832
6832
  for (const workflow of collection.workflows.flatMap(workflowVersions)) {
@@ -1,4 +1,4 @@
1
- import { _ as WorkflowManifestUnknownNodeV1Schema, a as WorkflowManifestGraphEdgeV1Schema, b as create, c as WorkflowManifestLoopNodeV1Schema, d as WorkflowManifestParallelNodeV1Schema, f as WorkflowManifestRepeatedStepV1Schema, g as WorkflowManifestStepNodeV1Schema, h as WorkflowManifestStepExecutionPolicyV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestNowNodeV1Schema, m as WorkflowManifestSleepUntilNodeV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphNodeV1Schema, p as WorkflowManifestSleepNodeV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphV1Schema, u as WorkflowManifestOrderEdgeV1Schema, v as WorkflowManifestUuidNodeV1Schema, y as WorkflowManifestWaitForEventNodeV1Schema } from "./generate-D1zt5ZZf.js";
1
+ import { _ as WorkflowManifestUnknownNodeV1Schema, a as WorkflowManifestGraphEdgeV1Schema, b as create, c as WorkflowManifestLoopNodeV1Schema, d as WorkflowManifestParallelNodeV1Schema, f as WorkflowManifestRepeatedStepV1Schema, g as WorkflowManifestStepNodeV1Schema, h as WorkflowManifestStepExecutionPolicyV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestNowNodeV1Schema, m as WorkflowManifestSleepUntilNodeV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphNodeV1Schema, p as WorkflowManifestSleepNodeV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphV1Schema, u as WorkflowManifestOrderEdgeV1Schema, v as WorkflowManifestUuidNodeV1Schema, y as WorkflowManifestWaitForEventNodeV1Schema } from "./generate-CDOP4pMi.js";
2
2
  //#region src/manifests/handler-source.ts
3
3
  const nativeFunctionSource = /\{\s*\[native code\]\s*\}\s*$/;
4
4
  function workflowHandlerSource(handler) {
package/dist/index.d.ts CHANGED
@@ -734,8 +734,6 @@ interface MemoEntry {
734
734
  * branches can order differently on a later pass, so it is not the key. */
735
735
  seq: number;
736
736
  stepId: string;
737
- /** Which call of this `stepId` in the run, from 0. */
738
- occurrence: number;
739
737
  /** Key of the step whose body recorded this, if any; a memoized parent hides it. */
740
738
  parent?: string;
741
739
  kind: StepKind;
@@ -747,7 +745,6 @@ interface MemoEntry {
747
745
  interface StepIntentBase {
748
746
  seq: number;
749
747
  stepId: string;
750
- occurrence: number;
751
748
  /** Kind-specific detail: sleep `ms`, `waitForEvent` name, approval title. */
752
749
  config?: Record<string, unknown>;
753
750
  meta?: WorkflowMetadata;
@@ -761,7 +758,6 @@ type StepIntent = StepIntentBase & ({
761
758
  interface StepResult<K extends StepKind = StepKind> {
762
759
  seq: number;
763
760
  stepId: string;
764
- occurrence: number;
765
761
  kind: K;
766
762
  meta?: WorkflowMetadata;
767
763
  status: "completed" | "failed";
@@ -788,7 +784,6 @@ interface ReplayOutcome {
788
784
  interface StepReference {
789
785
  kind: "step";
790
786
  stepId: string;
791
- occurrence: number;
792
787
  }
793
788
  //#endregion
794
789
  //#region src/stacks/tanstack/project-auth.d.ts
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as DURABLE_ID_REQUIRED } from "./durable-ids-Cx341nJQ.js";
2
- import { C as registerWorkflows, D as hourly, E as daily, O as weekly, S as createWorkflow, T as defineSchedule, t as generateManifests, w as workflowVersions, x as createMiddleware } from "./generate-D1zt5ZZf.js";
2
+ import { C as registerWorkflows, D as hourly, E as daily, O as weekly, S as createWorkflow, T as defineSchedule, t as generateManifests, w as workflowVersions, x as createMiddleware } from "./generate-CDOP4pMi.js";
3
3
  import { WorkflowRequestParseError, inMemoryRunStore, parseWorkflowRequest, runWorkflow } from "@tanstack/workflow-core";
4
4
  //#region src/stacks/tanstack/sse.ts
5
5
  const HEADERS = {
@@ -127,9 +127,6 @@ async function hashInput(input) {
127
127
  //#region src/runtime/replay.ts
128
128
  /** How long a pass waits for handler work that is not a durable operation. */
129
129
  const DEFAULT_SETTLE_MS = 5e3;
130
- function memoKey(stepId, occurrence) {
131
- return `${stepId}#${occurrence}`;
132
- }
133
130
  const EXECUTABLE = /* @__PURE__ */ new Set([
134
131
  "step",
135
132
  "now",
@@ -169,13 +166,13 @@ async function throughMiddleware(middlewares, ctx, handler) {
169
166
  }
170
167
  async function replay(options) {
171
168
  const { workflow, input, runId } = options;
172
- const byKey = new Map(options.memo.map((entry) => [memoKey(entry.stepId, entry.occurrence ?? 0), entry]));
169
+ const byKey = new Map(options.memo.map((entry) => [entry.stepId, entry]));
173
170
  const allow = options.shouldExecute ?? (() => true);
174
171
  const never = new Promise(() => {});
175
172
  const pending = [];
176
173
  const settled = /* @__PURE__ */ new Map();
177
174
  const pass = { stepsSettled: 0 };
178
- const occurrences = /* @__PURE__ */ new Map();
175
+ const reached = /* @__PURE__ */ new Set();
179
176
  const consumed = /* @__PURE__ */ new Set();
180
177
  let lastProgress = Date.now();
181
178
  let currentParent;
@@ -185,13 +182,12 @@ async function replay(options) {
185
182
  let seq = 0;
186
183
  let nonDeterminism;
187
184
  function record(entry) {
188
- settled.set(memoKey(entry.stepId, entry.occurrence), entry);
185
+ settled.set(entry.stepId, entry);
189
186
  lastProgress = Date.now();
190
187
  if (entry.kind === "step") pass.stepsSettled += 1;
191
188
  const result = {
192
189
  seq: entry.seq,
193
190
  stepId: entry.stepId,
194
- occurrence: entry.occurrence,
195
191
  kind: entry.kind,
196
192
  ...entry.meta ? { meta: entry.meta } : {},
197
193
  status: entry.status,
@@ -207,18 +203,16 @@ async function replay(options) {
207
203
  return never;
208
204
  }
209
205
  const index = seq++;
210
- const occurrence = occurrences.get(stepId) ?? 0;
211
- occurrences.set(stepId, occurrence + 1);
212
- if (occurrence > 0) {
206
+ if (reached.has(stepId)) {
213
207
  nonDeterminism = `id "${stepId}" was reached more than once; every durable operation id must be unique within a workflow`;
214
208
  return never;
215
209
  }
216
- const key = memoKey(stepId, occurrence);
217
- consumed.add(key);
218
- const answered = byKey.get(key) ?? settled.get(key);
210
+ reached.add(stepId);
211
+ consumed.add(stepId);
212
+ const answered = byKey.get(stepId) ?? settled.get(stepId);
219
213
  if (answered) {
220
214
  if (answered.kind !== kind) {
221
- nonDeterminism = `memo has ${answered.kind} "${stepId}" (#${occurrence}), replay produced ${kind}`;
215
+ nonDeterminism = `memo has ${answered.kind} "${stepId}", replay produced ${kind}`;
222
216
  return never;
223
217
  }
224
218
  const recordedGroupId = groupId(answered.meta);
@@ -233,7 +227,6 @@ async function replay(options) {
233
227
  const intent = {
234
228
  seq: index,
235
229
  stepId,
236
- occurrence,
237
230
  kind,
238
231
  ...config ? { config } : {},
239
232
  ...meta ? { meta } : {}
@@ -244,7 +237,7 @@ async function replay(options) {
244
237
  }
245
238
  options.onStepStart?.(intent);
246
239
  const enclosing = currentParent;
247
- currentParent = key;
240
+ currentParent = stepId;
248
241
  let body;
249
242
  try {
250
243
  body = run();
@@ -255,7 +248,6 @@ async function replay(options) {
255
248
  record({
256
249
  seq: index,
257
250
  stepId,
258
- occurrence,
259
251
  kind,
260
252
  status: "completed",
261
253
  result,
@@ -267,7 +259,6 @@ async function replay(options) {
267
259
  record({
268
260
  seq: index,
269
261
  stepId,
270
- occurrence,
271
262
  kind,
272
263
  status: "failed",
273
264
  error: describe(error),
@@ -472,7 +463,7 @@ function resolveWorkflowId(ctx, param) {
472
463
  }
473
464
  function isMemoEntry(value) {
474
465
  const entry = value;
475
- return typeof entry === "object" && entry !== null && Number.isInteger(entry.seq) && entry.seq >= 0 && typeof entry.stepId === "string" && Number.isInteger(entry.seq) && Number.isInteger(entry.occurrence) && entry.occurrence >= 0 && (entry.status === "completed" || entry.status === "failed");
466
+ return typeof entry === "object" && entry !== null && Number.isInteger(entry.seq) && entry.seq >= 0 && typeof entry.stepId === "string" && Number.isInteger(entry.seq) && (entry.status === "completed" || entry.status === "failed");
476
467
  }
477
468
  function parseBody(value) {
478
469
  if (value === null || typeof value !== "object") return "body must be a JSON object";
@@ -480,10 +471,10 @@ function parseBody(value) {
480
471
  if (body.workflowVersion !== void 0 && typeof body.workflowVersion !== "string") return "workflowVersion must be a string";
481
472
  if (body.memo !== void 0) {
482
473
  if (!Array.isArray(body.memo) || !body.memo.every(isMemoEntry)) return "memo must be an array of settled step entries";
483
- if (new Set(body.memo.map((entry) => memoKey(entry.stepId, entry.occurrence))).size !== body.memo.length) return "memo entries must be unique per stepId and occurrence";
474
+ if (new Set(body.memo.map((entry) => entry.stepId)).size !== body.memo.length) return "memo entries must be unique per stepId";
484
475
  }
485
476
  if (body.action !== void 0 && body.action !== "advance" && body.action !== "execute") return "action must be \"advance\" or \"execute\"";
486
- if (body.action === "execute" && !isStepReference(body.step)) return "step must be a { kind: \"step\", stepId, occurrence } reference when action is \"execute\"";
477
+ if (body.action === "execute" && !isStepReference(body.step)) return "step must be a { kind: \"step\", stepId } reference when action is \"execute\"";
487
478
  if (body.action !== "execute" && body.step !== void 0) return "step is only valid when action is \"execute\"";
488
479
  if (body.memo !== void 0 && body.memo.length > 0 && !("input" in value)) return "input must be sent with every call, including a resume";
489
480
  return body;
@@ -493,12 +484,9 @@ async function readBody(request) {
493
484
  if (!text.trim()) return {};
494
485
  return JSON.parse(text);
495
486
  }
496
- function operationKey(operation) {
497
- return memoKey(operation.stepId, operation.occurrence);
498
- }
499
487
  function isStepReference(value) {
500
488
  const step = value;
501
- return typeof step === "object" && step !== null && step.kind === "step" && typeof step.stepId === "string" && Number.isInteger(step.occurrence) && step.occurrence >= 0;
489
+ return typeof step === "object" && step !== null && step.kind === "step" && typeof step.stepId === "string";
502
490
  }
503
491
  function disposition(outcome) {
504
492
  if (outcome.status === "completed") return "completed";
@@ -507,8 +495,8 @@ function disposition(outcome) {
507
495
  return outcome.steps.length > 1 ? "fork" : "advanced";
508
496
  }
509
497
  function memoDelta(before, after) {
510
- const existing = new Set(before.map((entry) => memoKey(entry.stepId, entry.occurrence)));
511
- return after.filter((entry) => !existing.has(memoKey(entry.stepId, entry.occurrence)));
498
+ const existing = new Set(before.map((entry) => entry.stepId));
499
+ return after.filter((entry) => !existing.has(entry.stepId));
512
500
  }
513
501
  function respond(runId, inputHash, workflowVersion, before, outcome, executed) {
514
502
  const { steps, emitted, output, error } = outcome;
@@ -654,12 +642,12 @@ function createStepsHandler(collection, options = {}) {
654
642
  input,
655
643
  memo: before,
656
644
  runId,
657
- shouldExecute: (intent) => intent.kind !== "step" || operationKey(intent) === operationKey(selected)
645
+ shouldExecute: (intent) => intent.kind !== "step" || intent.stepId === selected.stepId
658
646
  }));
659
- const executed = outcome.results.find((result) => result.kind === "step" && operationKey(result) === operationKey(selected));
647
+ const executed = outcome.results.find((result) => result.kind === "step" && result.stepId === selected.stepId);
660
648
  if (executed === void 0 && outcome.status !== "failed") return json(409, {
661
649
  error: "stale_step",
662
- message: `step "${selected.stepId}" (#${selected.occurrence}) is not executable from this memo`
650
+ message: `step "${selected.stepId}" is not executable from this memo`
663
651
  });
664
652
  return respond(runId, inputHash, workflow.version, before, outcome, executed);
665
653
  }
@@ -677,12 +665,12 @@ function createStepsHandler(collection, options = {}) {
677
665
  input,
678
666
  memo: described.memo,
679
667
  runId,
680
- shouldExecute: (intent) => intent.kind !== "step" || operationKey(intent) === operationKey(only)
668
+ shouldExecute: (intent) => intent.kind !== "step" || intent.stepId === only.stepId
681
669
  }));
682
- const executed = outcome.results.find((result) => result.kind === "step" && operationKey(result) === operationKey(only));
670
+ const executed = outcome.results.find((result) => result.kind === "step" && result.stepId === only.stepId);
683
671
  if (executed === void 0 && outcome.status !== "failed") return json(409, {
684
672
  error: "stale_step",
685
- message: `step "${only.stepId}" (#${only.occurrence}) is not executable from this memo`
673
+ message: `step "${only.stepId}" is not executable from this memo`
686
674
  });
687
675
  return respond(runId, inputHash, workflow.version, before, outcome, executed);
688
676
  };
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/nested-operations.ts
3
3
  const durableMethods = [
4
4
  "step",
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/operation-descriptions.ts
3
3
  const optionsArgument = {
4
4
  approve: 0,
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-Cd9aL2HY.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-ZthZ8l6y.js";
2
2
  //#region src/manifests/step-metadata.ts
3
3
  async function findStepMetadataIssues(handler) {
4
4
  const api = await loadTypeScript();
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as generateManifests } from "./generate-D1zt5ZZf.js";
1
+ import { t as generateManifests } from "./generate-CDOP4pMi.js";
2
2
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
3
  import { createServer } from "vite";
4
4
  import { lstat, mkdir, mkdtemp, readdir, rename, rm, writeFile } from "node:fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/workflows-sdk",
3
- "version": "0.0.0-dev.32",
3
+ "version": "0.0.0-dev.33",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "dev",