@lovable.dev/workflows-sdk 0.0.0-dev.29 → 0.0.0-dev.30
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 +27 -1
- package/dist/{branch-metadata-BwC-Y91L.js → branch-metadata-BnVM2yPm.js} +1 -1
- package/dist/{context-escapes-BmELHeno.js → context-escapes-CLL2S7Vr.js} +1 -1
- package/dist/{duplicate-ids-CBr6MOcX.js → duplicate-ids-B5mscTGQ.js} +1 -1
- package/dist/{generate-8zrMa_JP.js → generate-CLO-2Lt_.js} +41 -13
- package/dist/{graph-qlzsioFa.js → graph-B4buEqEJ.js} +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +34 -8
- package/dist/{nested-operations-Cgi3pKC3.js → nested-operations-DfeMhajo.js} +1 -1
- package/dist/{operation-descriptions-CRYNG0O4.js → operation-descriptions-DN-BMvf_.js} +1 -1
- package/dist/{step-metadata-QCEJQPtp.js → step-metadata-DTGBBFyb.js} +1 -1
- package/dist/vite.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @lovable.dev/workflows-sdk
|
|
|
12
12
|
|
|
13
13
|
## Define workflows
|
|
14
14
|
|
|
15
|
-
Use `createWorkflow({ id, input, output }).handler(...)` to define a workflow
|
|
15
|
+
Use `createWorkflow({ id, version, input, output }).handler(...)` to define a workflow
|
|
16
16
|
and `createMiddleware` to extend its typed context. Standard Schema libraries
|
|
17
17
|
such as Zod provide input and output inference.
|
|
18
18
|
|
|
@@ -31,6 +31,32 @@ starting with a letter or digit. They must be unique within the collection.
|
|
|
31
31
|
See the [authoring example](examples/src/lib/workflows/greet/index.ts) for
|
|
32
32
|
schemas, typed middleware, and a durable step.
|
|
33
33
|
|
|
34
|
+
## Workflow versions
|
|
35
|
+
|
|
36
|
+
Every workflow requires an explicit `version`, including retained definitions.
|
|
37
|
+
Start with `"v1"`; introduce a new label when changing behavior, schemas, or
|
|
38
|
+
relevant helpers. Keep existing version implementations unchanged while runs drain.
|
|
39
|
+
Registration rejects missing, empty, and invalid labels. Existing unversioned
|
|
40
|
+
runs must drain on their original SDK deployment before upgrading.
|
|
41
|
+
|
|
42
|
+
Keep the current definition in `workflows` and attach older definitions with
|
|
43
|
+
`.previousVersions([v1])` before `.handler(...)`. Each definition has the same
|
|
44
|
+
workflow ID and a distinct `version` passed to `createWorkflow`. Versions accept
|
|
45
|
+
1–128 letters, digits, dots, hyphens, or underscores, starting with a letter or
|
|
46
|
+
digit. The combined manifest filename must fit 255 characters. See the [versioned example](examples/src/lib/workflows/versioned/index.ts).
|
|
47
|
+
|
|
48
|
+
The build emits one manifest per version. The top-level definition has
|
|
49
|
+
`current: true`; retained definitions have `current: false` and no triggers.
|
|
50
|
+
Schedules reference the top-level definition and start its version.
|
|
51
|
+
|
|
52
|
+
Steps responses include `workflowVersion`. Persist it with the run and send it
|
|
53
|
+
on every later request, including an empty memo. A missing version on a
|
|
54
|
+
resume or an unavailable version fails before replay.
|
|
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.
|
|
59
|
+
|
|
34
60
|
## Durable operations
|
|
35
61
|
|
|
36
62
|
Every durable operation needs a static, user-facing description:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
2
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
2
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-B4buEqEJ.js";
|
|
3
3
|
//#region src/manifests/duplicate-ids.ts
|
|
4
4
|
/** Where an explicit `{ id }` would sit for each operation. */
|
|
5
5
|
const optionsArgument = {
|
|
@@ -121,6 +121,29 @@ function defineSchedule(schedule) {
|
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/core/workflow.ts
|
|
124
|
+
function createWorkflow$1(config) {
|
|
125
|
+
return createWorkflow(config);
|
|
126
|
+
}
|
|
127
|
+
function workflowVersions(current) {
|
|
128
|
+
const versions = /* @__PURE__ */ new Map();
|
|
129
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
130
|
+
const visit = (workflow) => {
|
|
131
|
+
if (visiting.has(workflow)) throw new Error(`@lovable.dev/workflows-sdk: workflow "${current.id}" has cyclic previousVersions`);
|
|
132
|
+
if (workflow.__kind !== "workflow" || typeof workflow.handler !== "function" || workflow.id !== current.id) throw new Error(`@lovable.dev/workflows-sdk: previousVersions must be completed definitions of workflow "${current.id}"`);
|
|
133
|
+
if (typeof workflow.version !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(workflow.version)) throw new Error(`@lovable.dev/workflows-sdk: workflow "${current.id}" version must be 1–128 letters, digits, dots, hyphens or underscores, starting with a letter or digit`);
|
|
134
|
+
if (`${workflow.id}.${workflow.version}.json`.length > 255) throw new Error(`@lovable.dev/workflows-sdk: workflow "${current.id}" and version exceed the 255-character manifest filename limit`);
|
|
135
|
+
const version = workflow.version;
|
|
136
|
+
const existing = versions.get(version);
|
|
137
|
+
if (existing === workflow) return;
|
|
138
|
+
if (existing) throw new Error(`@lovable.dev/workflows-sdk: duplicate workflow version "${version}" for "${current.id}"`);
|
|
139
|
+
versions.set(version, workflow);
|
|
140
|
+
visiting.add(workflow);
|
|
141
|
+
for (const previous of workflow.previousVersions ?? []) visit(previous);
|
|
142
|
+
visiting.delete(workflow);
|
|
143
|
+
};
|
|
144
|
+
visit(current);
|
|
145
|
+
return [...versions.values()];
|
|
146
|
+
}
|
|
124
147
|
function registerWorkflows(definition) {
|
|
125
148
|
for (const key of Object.keys(definition)) {
|
|
126
149
|
if (key === "workflows" || key === "triggers") continue;
|
|
@@ -134,6 +157,7 @@ function registerWorkflows(definition) {
|
|
|
134
157
|
if (!/^[a-z0-9][a-z0-9_-]{0,127}$/.test(workflow.id)) throw new Error("@lovable.dev/workflows-sdk: workflow names must be 1–128 lowercase letters, digits, hyphens or underscores, starting with a letter or digit");
|
|
135
158
|
if (ids.has(workflow.id)) throw new Error(`@lovable.dev/workflows-sdk: duplicate workflow ID "${workflow.id}"`);
|
|
136
159
|
ids.add(workflow.id);
|
|
160
|
+
workflowVersions(workflow);
|
|
137
161
|
}
|
|
138
162
|
const scheduleIds = /* @__PURE__ */ new Set();
|
|
139
163
|
const registeredTriggers = triggers.map((trigger) => {
|
|
@@ -6602,7 +6626,7 @@ function listValueFromJson(listValue, json) {
|
|
|
6602
6626
|
}
|
|
6603
6627
|
//#endregion
|
|
6604
6628
|
//#region package.json
|
|
6605
|
-
var version = "0.0.0-dev.
|
|
6629
|
+
var version = "0.0.0-dev.30";
|
|
6606
6630
|
//#endregion
|
|
6607
6631
|
//#region src/proto/lovable/appworkflows/v1/workflow_manifest_pb.ts
|
|
6608
6632
|
/**
|
|
@@ -6795,17 +6819,16 @@ function serializeSchema(schema, direction, label) {
|
|
|
6795
6819
|
}
|
|
6796
6820
|
}
|
|
6797
6821
|
async function generateManifests(definition) {
|
|
6798
|
-
const { extractWorkflowGraph } = await import("./graph-
|
|
6799
|
-
const { findBranchMetadataIssues } = await import("./branch-metadata-
|
|
6800
|
-
const { findWorkflowContextEscapes } = await import("./context-escapes-
|
|
6801
|
-
const { findDuplicateOperationIds } = await import("./duplicate-ids-
|
|
6802
|
-
const { findNestedDurableOperations } = await import("./nested-operations-
|
|
6803
|
-
const { findOperationDescriptionIssues } = await import("./operation-descriptions-
|
|
6804
|
-
const { findStepMetadataIssues } = await import("./step-metadata-
|
|
6822
|
+
const { extractWorkflowGraph } = await import("./graph-B4buEqEJ.js");
|
|
6823
|
+
const { findBranchMetadataIssues } = await import("./branch-metadata-BnVM2yPm.js");
|
|
6824
|
+
const { findWorkflowContextEscapes } = await import("./context-escapes-CLL2S7Vr.js");
|
|
6825
|
+
const { findDuplicateOperationIds } = await import("./duplicate-ids-B5mscTGQ.js");
|
|
6826
|
+
const { findNestedDurableOperations } = await import("./nested-operations-DfeMhajo.js");
|
|
6827
|
+
const { findOperationDescriptionIssues } = await import("./operation-descriptions-DN-BMvf_.js");
|
|
6828
|
+
const { findStepMetadataIssues } = await import("./step-metadata-DTGBBFyb.js");
|
|
6805
6829
|
const collection = registerWorkflows(definition);
|
|
6806
6830
|
const manifests = [];
|
|
6807
|
-
for (const workflow of collection.workflows) {
|
|
6808
|
-
if (workflow.previousVersions?.length) throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" previousVersions are not supported yet`);
|
|
6831
|
+
for (const workflow of collection.workflows.flatMap(workflowVersions)) {
|
|
6809
6832
|
const contextEscape = (await findWorkflowContextEscapes(workflow.handler))[0];
|
|
6810
6833
|
if (contextEscape?.kind === "destructured") throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" destructures its workflow context parameter; accept one context identifier and read its properties directly in the workflow handler`);
|
|
6811
6834
|
if (contextEscape?.kind === "method") throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" uses ${contextEscape.context}.${contextEscape.method} as a value; durable context methods must be called directly in the workflow handler`);
|
|
@@ -6853,7 +6876,7 @@ async function generateManifests(definition) {
|
|
|
6853
6876
|
const metadata = {
|
|
6854
6877
|
workflowId: workflow.id,
|
|
6855
6878
|
...workflow.description === void 0 ? {} : { description: workflow.description },
|
|
6856
|
-
|
|
6879
|
+
workflowVersion: workflow.version,
|
|
6857
6880
|
...workflow.inputSchema ? { inputSchema: serializeSchema(workflow.inputSchema, "input", `${workflow.id}.input`) } : {},
|
|
6858
6881
|
...workflow.outputSchema ? { outputSchema: serializeSchema(workflow.outputSchema, "output", `${workflow.id}.output`) } : {},
|
|
6859
6882
|
...workflow.stateSchema ? { stateSchema: serializeSchema(workflow.stateSchema, "output", `${workflow.id}.state`) } : {}
|
|
@@ -6886,13 +6909,18 @@ async function generateManifests(definition) {
|
|
|
6886
6909
|
const manifest = toJson$1(WorkflowManifestV1Schema, create(WorkflowManifestV1Schema, {
|
|
6887
6910
|
manifestVersion: 1,
|
|
6888
6911
|
sdkVersion: version,
|
|
6912
|
+
current: collection.workflows.includes(workflow),
|
|
6889
6913
|
...metadata,
|
|
6890
6914
|
triggers,
|
|
6891
6915
|
graph: await extractWorkflowGraph(workflow)
|
|
6892
6916
|
}), { alwaysEmitImplicit: true });
|
|
6893
6917
|
manifests.push(manifest);
|
|
6894
6918
|
}
|
|
6895
|
-
return manifests.sort((a, b) =>
|
|
6919
|
+
return manifests.sort((a, b) => {
|
|
6920
|
+
const left = `${a.workflowId}.${a.workflowVersion}`;
|
|
6921
|
+
const right = `${b.workflowId}.${b.workflowVersion}`;
|
|
6922
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
6923
|
+
});
|
|
6896
6924
|
}
|
|
6897
6925
|
//#endregion
|
|
6898
|
-
export { registerWorkflows as C,
|
|
6926
|
+
export { registerWorkflows as C, hourly as D, daily as E, weekly as O, createWorkflow$1 as S, defineSchedule as T, WorkflowManifestUnknownNodeV1Schema as _, WorkflowManifestGraphEdgeV1Schema as a, create as b, WorkflowManifestLoopNodeV1Schema as c, WorkflowManifestParallelNodeV1Schema as d, WorkflowManifestRepeatedStepV1Schema as f, WorkflowManifestStepNodeV1Schema as g, WorkflowManifestStepExecutionPolicyV1Schema as h, WorkflowManifestBranchNodeV1Schema as i, WorkflowManifestNowNodeV1Schema as l, WorkflowManifestSleepUntilNodeV1Schema as m, WorkflowManifestApproveNodeV1Schema as n, WorkflowManifestGraphNodeV1Schema as o, WorkflowManifestSleepNodeV1Schema as p, WorkflowManifestBranchEdgeV1Schema as r, WorkflowManifestGraphV1Schema as s, generateManifests as t, WorkflowManifestOrderEdgeV1Schema as u, WorkflowManifestUuidNodeV1Schema as v, workflowVersions as w, createMiddleware as x, WorkflowManifestWaitForEventNodeV1Schema as y };
|
|
@@ -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-
|
|
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-CLO-2Lt_.js";
|
|
2
2
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
3
3
|
//#region src/manifests/handler-source.ts
|
|
4
4
|
const nativeFunctionSource = /\{\s*\[native code\]\s*\}\s*$/;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, Ctx, RunStore, StepContext, StepOptions, WorkflowDefinition, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowMetadata, WorkflowOutput, WorkflowState, createMiddleware
|
|
1
|
+
import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, CreateWorkflowConfig, Ctx, RunStore, SchemaInput, StepContext, StepOptions, WorkflowDefinition, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowMetadata, WorkflowOutput, WorkflowState, createMiddleware } from "@tanstack/workflow-core";
|
|
2
2
|
//#region src/core/cadence.d.ts
|
|
3
3
|
type Weekday = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
|
|
4
4
|
type Cadence = {
|
|
@@ -43,6 +43,9 @@ type TriggerDefinition = ScheduleDefinition;
|
|
|
43
43
|
type ResolvedTrigger = ResolvedSchedule;
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/core/workflow.d.ts
|
|
46
|
+
declare function createWorkflow<TInputSchema extends SchemaInput | undefined = undefined, TOutputSchema extends SchemaInput | undefined = undefined, TStateSchema extends SchemaInput | undefined = undefined>(config: CreateWorkflowConfig<TInputSchema, TOutputSchema, TStateSchema> & {
|
|
47
|
+
version: string;
|
|
48
|
+
}): import("@tanstack/workflow-core").WorkflowBuilder<TInputSchema, TOutputSchema, TStateSchema, unknown>;
|
|
46
49
|
interface WorkflowsDefinition<TWorkflow extends AnyWorkflowDefinition$1 = AnyWorkflowDefinition$1> {
|
|
47
50
|
readonly workflows: readonly TWorkflow[];
|
|
48
51
|
readonly triggers: readonly ResolvedTrigger[];
|
|
@@ -679,6 +682,8 @@ type WorkflowManifest = WorkflowManifestV1Json & {
|
|
|
679
682
|
manifestVersion: 1;
|
|
680
683
|
sdkVersion: string;
|
|
681
684
|
workflowId: string;
|
|
685
|
+
workflowVersion: string;
|
|
686
|
+
current: boolean;
|
|
682
687
|
triggers: NonNullable<WorkflowManifestV1Json["triggers"]>;
|
|
683
688
|
graph: NonNullable<WorkflowManifestV1Json["graph"]>;
|
|
684
689
|
};
|
|
@@ -791,6 +796,7 @@ interface RouteCtx {
|
|
|
791
796
|
}
|
|
792
797
|
type StepsHandler = (ctx: RouteCtx) => Promise<Response>;
|
|
793
798
|
interface StepsRequestBase {
|
|
799
|
+
workflowVersion?: string;
|
|
794
800
|
input?: unknown;
|
|
795
801
|
memo?: MemoEntry[];
|
|
796
802
|
runId?: string;
|
|
@@ -805,6 +811,7 @@ type StepsRequest = StepsRequestBase & ({
|
|
|
805
811
|
});
|
|
806
812
|
type StepsDisposition = "advanced" | "fork" | "waiting" | "completed" | "failed";
|
|
807
813
|
interface StepsResponse {
|
|
814
|
+
workflowVersion: string;
|
|
808
815
|
runId: string;
|
|
809
816
|
inputHash: string;
|
|
810
817
|
disposition: StepsDisposition;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as registerWorkflows, D as
|
|
1
|
+
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-CLO-2Lt_.js";
|
|
2
2
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
3
3
|
import { WorkflowRequestParseError, inMemoryRunStore, parseWorkflowRequest, runWorkflow } from "@tanstack/workflow-core";
|
|
4
4
|
//#region src/stacks/tanstack/sse.ts
|
|
@@ -90,8 +90,17 @@ function createTanStackWorkflowHandler(collection, options = {}) {
|
|
|
90
90
|
error: "abort_unsupported",
|
|
91
91
|
message: "Cancelling an in-flight run needs a shared run registry (WOR-53)."
|
|
92
92
|
});
|
|
93
|
+
const state = params.runId ? await runStore.getRunState(params.runId) : void 0;
|
|
94
|
+
if (state && state.workflowId !== workflow.id) return json$1(409, { error: "workflow_version_unavailable" });
|
|
95
|
+
const readOnly = state && [
|
|
96
|
+
"finished",
|
|
97
|
+
"errored",
|
|
98
|
+
"aborted"
|
|
99
|
+
].includes(state.status);
|
|
100
|
+
const selected = state && !readOnly ? workflowVersions(workflow).find((candidate) => candidate.version === state.workflowVersion) : workflow;
|
|
101
|
+
if (!selected) return json$1(409, { error: "workflow_version_unavailable" });
|
|
93
102
|
return toServerSentEventsResponse(runWorkflow({
|
|
94
|
-
workflow,
|
|
103
|
+
workflow: selected,
|
|
95
104
|
runStore,
|
|
96
105
|
...params
|
|
97
106
|
}));
|
|
@@ -480,6 +489,7 @@ function isMemoEntry(value) {
|
|
|
480
489
|
function parseBody(value) {
|
|
481
490
|
if (value === null || typeof value !== "object") return "body must be a JSON object";
|
|
482
491
|
const body = value;
|
|
492
|
+
if (body.workflowVersion !== void 0 && typeof body.workflowVersion !== "string") return "workflowVersion must be a string";
|
|
483
493
|
if (body.memo !== void 0) {
|
|
484
494
|
if (!Array.isArray(body.memo) || !body.memo.every(isMemoEntry)) return "memo must be an array of settled step entries";
|
|
485
495
|
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";
|
|
@@ -512,11 +522,12 @@ function memoDelta(before, after) {
|
|
|
512
522
|
const existing = new Set(before.map((entry) => memoKey(entry.stepId, entry.occurrence)));
|
|
513
523
|
return after.filter((entry) => !existing.has(memoKey(entry.stepId, entry.occurrence)));
|
|
514
524
|
}
|
|
515
|
-
function respond(runId, inputHash, before, outcome, executed) {
|
|
525
|
+
function respond(runId, inputHash, workflowVersion, before, outcome, executed) {
|
|
516
526
|
const { steps, emitted, output, error } = outcome;
|
|
517
527
|
return json(200, {
|
|
518
528
|
runId,
|
|
519
529
|
inputHash,
|
|
530
|
+
workflowVersion,
|
|
520
531
|
disposition: disposition(outcome),
|
|
521
532
|
memoDelta: memoDelta(before, outcome.memo),
|
|
522
533
|
next: steps,
|
|
@@ -587,8 +598,8 @@ async function validateOutput(workflow, outcome) {
|
|
|
587
598
|
}
|
|
588
599
|
async function resolve(ctx, param, byId) {
|
|
589
600
|
const workflowId = resolveWorkflowId(ctx, param);
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
601
|
+
const current = workflowId === void 0 ? void 0 : byId.get(workflowId);
|
|
602
|
+
if (!current) return json(404, {
|
|
592
603
|
error: "unknown_workflow",
|
|
593
604
|
workflowId: workflowId ?? ""
|
|
594
605
|
});
|
|
@@ -606,6 +617,21 @@ async function resolve(ctx, param, byId) {
|
|
|
606
617
|
error: "invalid_request",
|
|
607
618
|
message: body
|
|
608
619
|
});
|
|
620
|
+
const versions = workflowVersions(current);
|
|
621
|
+
if (body.workflowVersion === void 0 && (body.runId !== void 0 || body.memo !== void 0 || body.action === "execute")) return json(400, {
|
|
622
|
+
error: "workflow_version_required",
|
|
623
|
+
message: "Resuming a run requires its pinned workflowVersion"
|
|
624
|
+
});
|
|
625
|
+
const workflow = body.workflowVersion === void 0 ? versions[0] : versions.find((candidate) => candidate.version === body.workflowVersion);
|
|
626
|
+
if (!workflow) return json(409, {
|
|
627
|
+
error: "workflow_version_unavailable",
|
|
628
|
+
workflowId,
|
|
629
|
+
workflowVersion: body.workflowVersion
|
|
630
|
+
});
|
|
631
|
+
if (workflow !== current && !body.runId) return json(400, {
|
|
632
|
+
error: "retained_version_requires_run",
|
|
633
|
+
message: "Retained versions can only resume an existing run"
|
|
634
|
+
});
|
|
609
635
|
const wireInput = body.input ?? null;
|
|
610
636
|
const validated = await validateInput(workflow, wireInput);
|
|
611
637
|
if (validated instanceof Response) return validated;
|
|
@@ -647,7 +673,7 @@ function createStepsHandler(collection, options = {}) {
|
|
|
647
673
|
error: "stale_step",
|
|
648
674
|
message: `step "${selected.stepId}" (#${selected.occurrence}) is not executable from this memo`
|
|
649
675
|
});
|
|
650
|
-
return respond(runId, inputHash, before, outcome, executed);
|
|
676
|
+
return respond(runId, inputHash, workflow.version, before, outcome, executed);
|
|
651
677
|
}
|
|
652
678
|
const described = await validateOutput(workflow, await replay({
|
|
653
679
|
workflow,
|
|
@@ -657,7 +683,7 @@ function createStepsHandler(collection, options = {}) {
|
|
|
657
683
|
shouldExecute: (intent) => intent.kind !== "step"
|
|
658
684
|
}));
|
|
659
685
|
const only = described.steps.length === 1 ? described.steps[0] : void 0;
|
|
660
|
-
if (described.status !== "pending" || only?.kind !== "step") return respond(runId, inputHash, before, described);
|
|
686
|
+
if (described.status !== "pending" || only?.kind !== "step") return respond(runId, inputHash, workflow.version, before, described);
|
|
661
687
|
const outcome = await validateOutput(workflow, await replay({
|
|
662
688
|
workflow,
|
|
663
689
|
input,
|
|
@@ -670,7 +696,7 @@ function createStepsHandler(collection, options = {}) {
|
|
|
670
696
|
error: "stale_step",
|
|
671
697
|
message: `step "${only.stepId}" (#${only.occurrence}) is not executable from this memo`
|
|
672
698
|
});
|
|
673
|
-
return respond(runId, inputHash, before, outcome, executed);
|
|
699
|
+
return respond(runId, inputHash, workflow.version, before, outcome, executed);
|
|
674
700
|
};
|
|
675
701
|
}
|
|
676
702
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
1
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-B4buEqEJ.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-
|
|
1
|
+
import { t as generateManifests } from "./generate-CLO-2Lt_.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";
|
|
@@ -18,9 +18,10 @@ async function writeManifests(root, manifests) {
|
|
|
18
18
|
const directory = join(lovable, "workflows");
|
|
19
19
|
await ensureDirectory(directory);
|
|
20
20
|
const staging = await mkdtemp(join(directory, ".tmp-"));
|
|
21
|
-
const
|
|
21
|
+
const nameOf = (manifest) => `${manifest.workflowId}.${manifest.workflowVersion}.json`;
|
|
22
|
+
const names = new Set(manifests.map(nameOf));
|
|
22
23
|
try {
|
|
23
|
-
for (const manifest of manifests) await writeFile(join(staging,
|
|
24
|
+
for (const manifest of manifests) await writeFile(join(staging, nameOf(manifest)), JSON.stringify(manifest, null, 2) + "\n");
|
|
24
25
|
for (const name of names) await rename(join(staging, name), join(directory, name));
|
|
25
26
|
for (const entry of await readdir(directory, { withFileTypes: true })) if (entry.name.endsWith(".json") && !names.has(entry.name) && !entry.isDirectory()) await rm(join(directory, entry.name), { force: true });
|
|
26
27
|
} finally {
|