@lovable.dev/workflows-sdk 0.0.0-dev.57 → 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-qDFxy3v5.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-qDFxy3v5.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-qDFxy3v5.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.57";
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-qDFxy3v5.js");
6870
- const { findBranchMetadataIssues } = await import("./branch-metadata-11JARM_f.js");
6871
- const { findWorkflowContextEscapes } = await import("./context-escapes-CCFe2Xly.js");
6872
- const { findDuplicateOperationIds } = await import("./duplicate-ids-C-UQFcg0.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-CrF-T-F3.js");
6875
- const { findOperationDescriptionIssues } = await import("./operation-descriptions-YWlxdFR4.js");
6876
- const { findStepMetadataIssues } = await import("./step-metadata-C2Gq6_oU.js");
6877
- const { findWaitDeadlineIssues } = await import("./wait-deadlines-DjYbGO09.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-CzKPbFyR.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.d.ts CHANGED
@@ -1014,9 +1014,12 @@ interface StepsRequestBase {
1014
1014
  type StepsRequest = StepsRequestBase & ({
1015
1015
  action?: "advance";
1016
1016
  step?: never;
1017
+ /** Name the one ready step and run nothing; the caller then runs it with `execute`. */
1018
+ describe?: boolean;
1017
1019
  } | {
1018
1020
  action: "execute";
1019
1021
  step: StepReference;
1022
+ describe?: never;
1020
1023
  });
1021
1024
  type StepsDisposition = "advanced" | "fork" | "waiting" | "completed" | "failed";
1022
1025
  interface StepsResponse {
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-CzKPbFyR.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,
@@ -654,6 +660,7 @@ function parseBody(value) {
654
660
  if (body.action !== void 0 && body.action !== "advance" && body.action !== "execute") return "action must be \"advance\" or \"execute\"";
655
661
  if (body.action === "execute" && !isStepReference(body.step)) return "step must be a { kind: \"step\" | \"llm\" | \"connector\", stepId } reference when action is \"execute\"";
656
662
  if (body.action !== "execute" && body.step !== void 0) return "step is only valid when action is \"execute\"";
663
+ if (body.describe !== void 0 && typeof body.describe !== "boolean") return "describe must be a boolean";
657
664
  if (body.memo !== void 0 && body.memo.length > 0 && !("input" in value)) return "input must be sent with every call, including a resume";
658
665
  return body;
659
666
  }
@@ -788,6 +795,7 @@ function createStepsHandler(collection, options = {}) {
788
795
  if (resolved instanceof Response) return resolved;
789
796
  const { workflow, body, input, runId, inputHash } = resolved;
790
797
  const before = body.memo ?? [];
798
+ const attempt = attemptOf(ctx.request);
791
799
  if (body.action === "execute") {
792
800
  const selected = body.step;
793
801
  const outcome = await validateOutput(workflow, await replay({
@@ -796,6 +804,7 @@ function createStepsHandler(collection, options = {}) {
796
804
  memo: before,
797
805
  runId,
798
806
  signal: ctx.request.signal,
807
+ attempt,
799
808
  shouldExecute: (intent) => !isRunnableKind(intent.kind) || intent.kind === selected.kind && intent.stepId === selected.stepId
800
809
  }));
801
810
  const executed = outcome.results.find((result) => result.kind === selected.kind && result.stepId === selected.stepId);
@@ -811,16 +820,18 @@ function createStepsHandler(collection, options = {}) {
811
820
  memo: before,
812
821
  runId,
813
822
  signal: ctx.request.signal,
823
+ attempt,
814
824
  shouldExecute: (intent) => !isRunnableKind(intent.kind)
815
825
  }));
816
826
  const only = described.steps.length === 1 ? described.steps[0] : void 0;
817
- if (described.status !== "pending" || !only || !isRunnableKind(only.kind)) return json(200, stepsResponse(runId, inputHash, workflow.version, before, described));
827
+ if (described.status !== "pending" || !only || !isRunnableKind(only.kind) || body.describe === true) return json(200, stepsResponse(runId, inputHash, workflow.version, before, described));
818
828
  const outcome = await validateOutput(workflow, await replay({
819
829
  workflow,
820
830
  input,
821
831
  memo: described.memo,
822
832
  runId,
823
833
  signal: ctx.request.signal,
834
+ attempt,
824
835
  shouldExecute: (intent) => !isRunnableKind(intent.kind) || intent.kind === only.kind && intent.stepId === only.stepId
825
836
  }));
826
837
  const executed = outcome.results.find((result) => result.kind === only.kind && result.stepId === only.stepId);
@@ -1112,7 +1123,7 @@ async function send(request) {
1112
1123
  const headers = new Headers(request.headers);
1113
1124
  headers.set("Authorization", `Bearer ${connection.apiKey}`);
1114
1125
  headers.set("Accept", "application/json");
1115
- headers.set("User-Agent", `lovable-workflows-sdk/0.0.0-dev.57`);
1126
+ headers.set("User-Agent", `lovable-workflows-sdk/0.0.0-dev.59`);
1116
1127
  if (request.body !== void 0) headers.set("Content-Type", "application/json");
1117
1128
  let response;
1118
1129
  try {
@@ -1,4 +1,4 @@
1
- import { loadTypeScript, t as workflowHandlerSource } from "./graph-qDFxy3v5.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-qDFxy3v5.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-qDFxy3v5.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-CzKPbFyR.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-qDFxy3v5.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.57",
3
+ "version": "0.0.0-dev.59",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "dev",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@standard-schema/spec": "^1.1.0",
33
33
  "@tanstack/workflow-core": "0.0.4",
34
- "@lovable.dev/ai-gateway": "0.1.11"
34
+ "@lovable.dev/ai-gateway": "0.1.13"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@bufbuild/protobuf": "^2.10.1",