@lovable.dev/workflows-sdk 0.0.0-dev.58 → 0.0.0-dev.59

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/README.md CHANGED
@@ -53,9 +53,10 @@ Steps responses include `workflowVersion`. Persist it with the run and send it
53
53
  on every later request, including an empty memo. A missing version on a
54
54
  resume or an unavailable version fails before replay.
55
55
 
56
- Keep old definitions and their relevant helpers unchanged until their runs and
57
- pending execution attempts drain. Removing a definition makes its version
58
- unavailable; existing runs never switch to the current version automatically.
56
+ Keep an old definition and its relevant helpers unchanged while the published
57
+ app still uses that version: it is the published version, or it has open runs.
58
+ Remove them after that. Removing a definition makes its version unavailable;
59
+ existing runs never switch to the current version automatically.
59
60
 
60
61
  ## Durable operations
61
62
 
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.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-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.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-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.js";
2
2
  //#region src/manifests/duplicate-ids.ts
3
3
  /** Where an explicit `{ id }` would sit for each operation. */
4
4
  const optionsArgument = {
@@ -6644,7 +6644,7 @@ function listValueFromJson(listValue, json) {
6644
6644
  }
6645
6645
  //#endregion
6646
6646
  //#region package.json
6647
- var version = "0.0.0-dev.58";
6647
+ var version = "0.0.0-dev.59";
6648
6648
  //#endregion
6649
6649
  //#region src/proto/lovable/appworkflows/v1/workflow_manifest_pb.ts
6650
6650
  /**
@@ -6866,15 +6866,15 @@ function serializeSchema(schema, direction, label) {
6866
6866
  }
6867
6867
  }
6868
6868
  async function generateManifests(definition, options = {}) {
6869
- const { extractWorkflowGraph } = await import("./graph-DNM6HACw.js");
6870
- const { findBranchMetadataIssues } = await import("./branch-metadata-DR6L1610.js");
6871
- const { findWorkflowContextEscapes } = await import("./context-escapes-DhO7d5UB.js");
6872
- const { findDuplicateOperationIds } = await import("./duplicate-ids-C3J0tTFi.js");
6869
+ const { extractWorkflowGraph } = await import("./graph-CwRl2SGh.js");
6870
+ const { findBranchMetadataIssues } = await import("./branch-metadata-D1b9OmsG.js");
6871
+ const { findWorkflowContextEscapes } = await import("./context-escapes-CcYvmmKH.js");
6872
+ const { findDuplicateOperationIds } = await import("./duplicate-ids-BZhMnS7n.js");
6873
6873
  const { DURABLE_ID_REQUIRED } = await import("./durable-ids-Cx341nJQ.js").then((n) => n.n);
6874
- const { findNestedDurableOperations } = await import("./nested-operations-DroMYJeg.js");
6875
- const { findOperationDescriptionIssues } = await import("./operation-descriptions-CA9zrZ3y.js");
6876
- const { findStepMetadataIssues } = await import("./step-metadata-BsrM_6XU.js");
6877
- const { findWaitDeadlineIssues } = await import("./wait-deadlines-9IpZV-qZ.js");
6874
+ const { findNestedDurableOperations } = await import("./nested-operations-CoaLLZl0.js");
6875
+ const { findOperationDescriptionIssues } = await import("./operation-descriptions-DlYyD27h.js");
6876
+ const { findStepMetadataIssues } = await import("./step-metadata-CCsEws4V.js");
6877
+ const { findWaitDeadlineIssues } = await import("./wait-deadlines-CCgWwxqQ.js");
6878
6878
  const { WAIT_DEADLINE_REQUIRED } = await import("./wait-deadlines-DpK-Fgnd.js");
6879
6879
  const collection = registerWorkflows(definition);
6880
6880
  const manifests = [];
@@ -1,4 +1,4 @@
1
- import { C as WorkflowManifestWaitForEventNodeV1Schema, S as WorkflowManifestUuidNodeV1Schema, _ as WorkflowManifestSleepNodeV1Schema, a as WorkflowManifestConnectorNodeV1Schema, b as WorkflowManifestStepNodeV1Schema, c as WorkflowManifestGraphV1Schema, d as WorkflowManifestNowNodeV1Schema, f as WorkflowManifestOrderEdgeV1Schema, g as WorkflowManifestRepeatedStepV1Schema, h as WorkflowManifestRepeatedLlmV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestLlmNodeV1Schema, m as WorkflowManifestRepeatedConnectorV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphEdgeV1Schema, p as WorkflowManifestParallelNodeV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphNodeV1Schema, u as WorkflowManifestLoopNodeV1Schema, v as WorkflowManifestSleepUntilNodeV1Schema, w as create, x as WorkflowManifestUnknownNodeV1Schema, y as WorkflowManifestStepExecutionPolicyV1Schema } from "./generate-sHCzFBzN.js";
1
+ import { C as WorkflowManifestWaitForEventNodeV1Schema, S as WorkflowManifestUuidNodeV1Schema, _ as WorkflowManifestSleepNodeV1Schema, a as WorkflowManifestConnectorNodeV1Schema, b as WorkflowManifestStepNodeV1Schema, c as WorkflowManifestGraphV1Schema, d as WorkflowManifestNowNodeV1Schema, f as WorkflowManifestOrderEdgeV1Schema, g as WorkflowManifestRepeatedStepV1Schema, h as WorkflowManifestRepeatedLlmV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestLlmNodeV1Schema, m as WorkflowManifestRepeatedConnectorV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphEdgeV1Schema, p as WorkflowManifestParallelNodeV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphNodeV1Schema, u as WorkflowManifestLoopNodeV1Schema, v as WorkflowManifestSleepUntilNodeV1Schema, w as create, x as WorkflowManifestUnknownNodeV1Schema, y as WorkflowManifestStepExecutionPolicyV1Schema } from "./generate-DI9qaUrI.js";
2
2
  import { n as assertLlmOptions, t as assertLlmModel } from "./llm-validation-DdDO6csU.js";
3
3
  //#region src/manifests/handler-source.ts
4
4
  const nativeFunctionSource = /\{\s*\[native code\]\s*\}\s*$/;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as DURABLE_ID_REQUIRED } from "./durable-ids-Cx341nJQ.js";
2
- import { A as daily, D as registerWorkflows, E as createWorkflow, M as hourly, N as weekly, O as workflowVersions, P as WORKFLOW_ID_PATTERN, T as createMiddleware, j as every, k as defineSchedule, t as generateManifests } from "./generate-sHCzFBzN.js";
2
+ import { A as daily, D as registerWorkflows, E as createWorkflow, M as hourly, N as weekly, O as workflowVersions, P as WORKFLOW_ID_PATTERN, T as createMiddleware, j as every, k as defineSchedule, t as generateManifests } from "./generate-DI9qaUrI.js";
3
3
  import { n as assertLlmOptions, r as assertLlmRequest } from "./llm-validation-DdDO6csU.js";
4
4
  import { WorkflowRequestParseError, inMemoryRunStore, parseWorkflowRequest, runWorkflow } from "@tanstack/workflow-core";
5
5
  import { generateChatCompletion, generateMessage } from "@lovable.dev/ai-gateway";
@@ -299,6 +299,7 @@ async function throughMiddleware(middlewares, ctx, handler) {
299
299
  }
300
300
  async function replay(options) {
301
301
  const { workflow, input, runId } = options;
302
+ const attempt = options.attempt ?? 1;
302
303
  const byKey = new Map(options.memo.map((entry) => [entry.stepId, entry]));
303
304
  const allow = options.shouldExecute ?? (() => true);
304
305
  const settled = /* @__PURE__ */ new Map();
@@ -386,7 +387,7 @@ async function replay(options) {
386
387
  return durable("connector", id, async () => {
387
388
  const result = await callback({
388
389
  id,
389
- attempt: 1,
390
+ attempt,
390
391
  runtime,
391
392
  signal
392
393
  });
@@ -418,7 +419,7 @@ async function replay(options) {
418
419
  llm,
419
420
  step: (id, fn, stepOptions) => durable("step", id, async () => fn({
420
421
  id,
421
- attempt: 1,
422
+ attempt,
422
423
  runtime,
423
424
  signal
424
425
  }), void 0, stepOptions?.meta),
@@ -617,6 +618,11 @@ function stepsResponse(runId, inputHash, workflowVersion, before, outcome, execu
617
618
  }
618
619
  //#endregion
619
620
  //#region src/stacks/tanstack/steps.ts
621
+ const ATTEMPT_HEADER = "x-lovable-workflow-attempt";
622
+ function attemptOf(request) {
623
+ const attempt = Number(request.headers.get(ATTEMPT_HEADER));
624
+ return Number.isInteger(attempt) && attempt > 0 ? attempt : 1;
625
+ }
620
626
  function json(status, body) {
621
627
  return new Response(JSON.stringify(body), {
622
628
  status,
@@ -789,6 +795,7 @@ function createStepsHandler(collection, options = {}) {
789
795
  if (resolved instanceof Response) return resolved;
790
796
  const { workflow, body, input, runId, inputHash } = resolved;
791
797
  const before = body.memo ?? [];
798
+ const attempt = attemptOf(ctx.request);
792
799
  if (body.action === "execute") {
793
800
  const selected = body.step;
794
801
  const outcome = await validateOutput(workflow, await replay({
@@ -797,6 +804,7 @@ function createStepsHandler(collection, options = {}) {
797
804
  memo: before,
798
805
  runId,
799
806
  signal: ctx.request.signal,
807
+ attempt,
800
808
  shouldExecute: (intent) => !isRunnableKind(intent.kind) || intent.kind === selected.kind && intent.stepId === selected.stepId
801
809
  }));
802
810
  const executed = outcome.results.find((result) => result.kind === selected.kind && result.stepId === selected.stepId);
@@ -812,6 +820,7 @@ function createStepsHandler(collection, options = {}) {
812
820
  memo: before,
813
821
  runId,
814
822
  signal: ctx.request.signal,
823
+ attempt,
815
824
  shouldExecute: (intent) => !isRunnableKind(intent.kind)
816
825
  }));
817
826
  const only = described.steps.length === 1 ? described.steps[0] : void 0;
@@ -822,6 +831,7 @@ function createStepsHandler(collection, options = {}) {
822
831
  memo: described.memo,
823
832
  runId,
824
833
  signal: ctx.request.signal,
834
+ attempt,
825
835
  shouldExecute: (intent) => !isRunnableKind(intent.kind) || intent.kind === only.kind && intent.stepId === only.stepId
826
836
  }));
827
837
  const executed = outcome.results.find((result) => result.kind === only.kind && result.stepId === only.stepId);
@@ -1113,7 +1123,7 @@ async function send(request) {
1113
1123
  const headers = new Headers(request.headers);
1114
1124
  headers.set("Authorization", `Bearer ${connection.apiKey}`);
1115
1125
  headers.set("Accept", "application/json");
1116
- headers.set("User-Agent", `lovable-workflows-sdk/0.0.0-dev.58`);
1126
+ headers.set("User-Agent", `lovable-workflows-sdk/0.0.0-dev.59`);
1117
1127
  if (request.body !== void 0) headers.set("Content-Type", "application/json");
1118
1128
  let response;
1119
1129
  try {
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.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-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.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-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.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-sHCzFBzN.js";
1
+ import { t as generateManifests } from "./generate-DI9qaUrI.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";
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-DNM6HACw.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CwRl2SGh.js";
2
2
  //#region src/manifests/wait-deadlines.ts
3
3
  const optionsArgument = {
4
4
  approve: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/workflows-sdk",
3
- "version": "0.0.0-dev.58",
3
+ "version": "0.0.0-dev.59",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "dev",