@lovable.dev/workflows-sdk 0.0.0-dev.43 → 0.0.0-dev.44
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/dist/{branch-metadata-B6uZRRY3.js → branch-metadata-strJDEAy.js} +1 -1
- package/dist/{context-escapes-Bk0DN2MM.js → context-escapes-CNTx3xkk.js} +1 -1
- package/dist/{duplicate-ids-CB-xAZH3.js → duplicate-ids-Cq6Y0pgf.js} +1 -1
- package/dist/{generate-BlCztUNP.js → generate-CqXgNBpN.js} +9 -9
- package/dist/{graph-C34bH2ul.js → graph-3Syx7KCj.js} +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.js +67 -36
- package/dist/{nested-operations-CWaP7rOJ.js → nested-operations-BsAo5V1I.js} +1 -1
- package/dist/{operation-descriptions-Ca6Wprd9.js → operation-descriptions-Dh0T3SnD.js} +1 -1
- package/dist/{step-metadata-nQwvzDPb.js → step-metadata-FnRBeBRd.js} +1 -1
- package/dist/vite.js +1 -1
- package/dist/{wait-deadlines-BHDEShlG.js → wait-deadlines-CPg8h2v1.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
1
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-3Syx7KCj.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.
|
|
6629
|
+
var version = "0.0.0-dev.44";
|
|
6630
6630
|
//#endregion
|
|
6631
6631
|
//#region src/proto/lovable/appworkflows/v1/workflow_manifest_pb.ts
|
|
6632
6632
|
/**
|
|
@@ -6824,15 +6824,15 @@ function serializeSchema(schema, direction, label) {
|
|
|
6824
6824
|
}
|
|
6825
6825
|
}
|
|
6826
6826
|
async function generateManifests(definition, options = {}) {
|
|
6827
|
-
const { extractWorkflowGraph } = await import("./graph-
|
|
6828
|
-
const { findBranchMetadataIssues } = await import("./branch-metadata-
|
|
6829
|
-
const { findWorkflowContextEscapes } = await import("./context-escapes-
|
|
6830
|
-
const { findDuplicateOperationIds } = await import("./duplicate-ids-
|
|
6827
|
+
const { extractWorkflowGraph } = await import("./graph-3Syx7KCj.js");
|
|
6828
|
+
const { findBranchMetadataIssues } = await import("./branch-metadata-strJDEAy.js");
|
|
6829
|
+
const { findWorkflowContextEscapes } = await import("./context-escapes-CNTx3xkk.js");
|
|
6830
|
+
const { findDuplicateOperationIds } = await import("./duplicate-ids-Cq6Y0pgf.js");
|
|
6831
6831
|
const { DURABLE_ID_REQUIRED } = await import("./durable-ids-Cx341nJQ.js").then((n) => n.n);
|
|
6832
|
-
const { findNestedDurableOperations } = await import("./nested-operations-
|
|
6833
|
-
const { findOperationDescriptionIssues } = await import("./operation-descriptions-
|
|
6834
|
-
const { findStepMetadataIssues } = await import("./step-metadata-
|
|
6835
|
-
const { findWaitDeadlineIssues } = await import("./wait-deadlines-
|
|
6832
|
+
const { findNestedDurableOperations } = await import("./nested-operations-BsAo5V1I.js");
|
|
6833
|
+
const { findOperationDescriptionIssues } = await import("./operation-descriptions-Dh0T3SnD.js");
|
|
6834
|
+
const { findStepMetadataIssues } = await import("./step-metadata-FnRBeBRd.js");
|
|
6835
|
+
const { findWaitDeadlineIssues } = await import("./wait-deadlines-CPg8h2v1.js");
|
|
6836
6836
|
const { WAIT_DEADLINE_REQUIRED } = await import("./wait-deadlines-DpK-Fgnd.js");
|
|
6837
6837
|
const collection = registerWorkflows(definition);
|
|
6838
6838
|
const manifests = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as WorkflowManifestStepNodeV1Schema, a as WorkflowManifestGraphEdgeV1Schema, b as WorkflowManifestWaitForEventNodeV1Schema, c as WorkflowManifestLlmNodeV1Schema, d as WorkflowManifestOrderEdgeV1Schema, f as WorkflowManifestParallelNodeV1Schema, g as WorkflowManifestStepExecutionPolicyV1Schema, h as WorkflowManifestSleepUntilNodeV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestLoopNodeV1Schema, m as WorkflowManifestSleepNodeV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphNodeV1Schema, p as WorkflowManifestRepeatedStepV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphV1Schema, u as WorkflowManifestNowNodeV1Schema, v as WorkflowManifestUnknownNodeV1Schema, x as create, y as WorkflowManifestUuidNodeV1Schema } from "./generate-
|
|
1
|
+
import { _ as WorkflowManifestStepNodeV1Schema, a as WorkflowManifestGraphEdgeV1Schema, b as WorkflowManifestWaitForEventNodeV1Schema, c as WorkflowManifestLlmNodeV1Schema, d as WorkflowManifestOrderEdgeV1Schema, f as WorkflowManifestParallelNodeV1Schema, g as WorkflowManifestStepExecutionPolicyV1Schema, h as WorkflowManifestSleepUntilNodeV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestLoopNodeV1Schema, m as WorkflowManifestSleepNodeV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphNodeV1Schema, p as WorkflowManifestRepeatedStepV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphV1Schema, u as WorkflowManifestNowNodeV1Schema, v as WorkflowManifestUnknownNodeV1Schema, x as create, y as WorkflowManifestUuidNodeV1Schema } from "./generate-CqXgNBpN.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
|
@@ -873,6 +873,16 @@ interface MemoEntry {
|
|
|
873
873
|
result?: unknown;
|
|
874
874
|
error?: string;
|
|
875
875
|
}
|
|
876
|
+
type ExternalMemoEntry = Omit<MemoEntry, "kind" | "status" | "result" | "error"> & {
|
|
877
|
+
status: "completed";
|
|
878
|
+
error?: never;
|
|
879
|
+
} & ({
|
|
880
|
+
kind: "now";
|
|
881
|
+
result: number;
|
|
882
|
+
} | {
|
|
883
|
+
kind: "uuid";
|
|
884
|
+
result: string;
|
|
885
|
+
});
|
|
876
886
|
interface StepIntentBase {
|
|
877
887
|
seq: number;
|
|
878
888
|
stepId: string;
|
|
@@ -922,6 +932,7 @@ interface ReplayOutcome {
|
|
|
922
932
|
name: string;
|
|
923
933
|
value: Record<string, unknown>;
|
|
924
934
|
}[];
|
|
935
|
+
llmRequests?: ReadonlyMap<string, LlmRequest>;
|
|
925
936
|
output?: unknown;
|
|
926
937
|
error?: string;
|
|
927
938
|
}
|
|
@@ -978,7 +989,7 @@ type StepsResponse = StepsResponseBase & ({
|
|
|
978
989
|
executed?: StepResult<"step">;
|
|
979
990
|
external?: never;
|
|
980
991
|
} | (ExternalStep & {
|
|
981
|
-
memoDelta: [];
|
|
992
|
+
memoDelta: ExternalMemoEntry[];
|
|
982
993
|
executed?: never;
|
|
983
994
|
}));
|
|
984
995
|
declare function createStepsHandler(collection: WorkflowCollection, options?: StepsHandlerOptions): StepsHandler;
|
|
@@ -990,4 +1001,4 @@ declare function createStepsHandler(collection: WorkflowCollection, options?: St
|
|
|
990
1001
|
*/
|
|
991
1002
|
declare function toServerSentEventsResponse(events: AsyncIterable<WorkflowEvent>): Response;
|
|
992
1003
|
//#endregion
|
|
993
|
-
export { type AnyWorkflowDefinition, type ApproveOptions, type Cadence, type Ctx, type ExternalOperation, type ExternalStep, type LlmRequest, type LlmStep, type LlmStepOptions, type MemoEntry, type NextStep, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type WaitForEventOptions, type Weekday, type WorkflowBranchMetadata, type WorkflowCollection, type WorkflowDefinition, type WorkflowInput, type WorkflowManifest, type WorkflowOperationMetadata, type WorkflowOutput, type WorkflowState, type WorkflowStepGroup, type WorkflowStepMetadata, type WorkflowsDefinition, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
|
|
1004
|
+
export { type AnyWorkflowDefinition, type ApproveOptions, type Cadence, type Ctx, type ExternalMemoEntry, type ExternalOperation, type ExternalStep, type LlmRequest, type LlmStep, type LlmStepOptions, type MemoEntry, type NextStep, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type WaitForEventOptions, type Weekday, type WorkflowBranchMetadata, type WorkflowCollection, type WorkflowDefinition, type WorkflowInput, type WorkflowManifest, type WorkflowOperationMetadata, type WorkflowOutput, type WorkflowState, type WorkflowStepGroup, type WorkflowStepMetadata, type WorkflowsDefinition, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
|
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 createWorkflow, D as daily, E as defineSchedule, O as hourly, S as createMiddleware, T as workflowVersions, k as weekly, t as generateManifests, w as registerWorkflows } from "./generate-
|
|
2
|
+
import { C as createWorkflow, D as daily, E as defineSchedule, O as hourly, S as createMiddleware, T as workflowVersions, k as weekly, t as generateManifests, w as registerWorkflows } from "./generate-CqXgNBpN.js";
|
|
3
3
|
import { WorkflowRequestParseError, inMemoryRunStore, parseWorkflowRequest, runWorkflow } from "@tanstack/workflow-core";
|
|
4
4
|
//#region src/stacks/tanstack/sse.ts
|
|
5
5
|
const HEADERS = {
|
|
@@ -417,7 +417,8 @@ async function replay(options) {
|
|
|
417
417
|
if (pending.length > 0) return {
|
|
418
418
|
...base,
|
|
419
419
|
status: "pending",
|
|
420
|
-
steps: pending
|
|
420
|
+
steps: pending,
|
|
421
|
+
llmRequests: operations.requests
|
|
421
422
|
};
|
|
422
423
|
return {
|
|
423
424
|
...base,
|
|
@@ -479,6 +480,62 @@ async function authorizeProjectRequest(request, getProjectSecret) {
|
|
|
479
480
|
}
|
|
480
481
|
}
|
|
481
482
|
//#endregion
|
|
483
|
+
//#region src/stacks/tanstack/steps-response.ts
|
|
484
|
+
function disposition(outcome) {
|
|
485
|
+
if (outcome.status === "completed") return "completed";
|
|
486
|
+
if (outcome.status === "failed") return "failed";
|
|
487
|
+
if (!outcome.steps.some((step) => step.kind === "step" || step.kind === "llm")) return "waiting";
|
|
488
|
+
return outcome.steps.length > 1 ? "fork" : "advanced";
|
|
489
|
+
}
|
|
490
|
+
function memoDelta(before, after) {
|
|
491
|
+
const existing = new Set(before.map((entry) => entry.stepId));
|
|
492
|
+
return after.filter((entry) => !existing.has(entry.stepId));
|
|
493
|
+
}
|
|
494
|
+
function isExternalMemoEntry(entry) {
|
|
495
|
+
return entry.status === "completed" && entry.error === void 0 && (entry.kind === "now" ? typeof entry.result === "number" && Number.isFinite(entry.result) : entry.kind === "uuid" && typeof entry.result === "string" && entry.result.length > 0);
|
|
496
|
+
}
|
|
497
|
+
function stepsResponse(runId, inputHash, workflowVersion, before, outcome, executed, selected) {
|
|
498
|
+
const { steps, emitted, output, error } = outcome;
|
|
499
|
+
const delta = memoDelta(before, outcome.memo);
|
|
500
|
+
const base = {
|
|
501
|
+
runId,
|
|
502
|
+
inputHash,
|
|
503
|
+
workflowVersion,
|
|
504
|
+
memoDelta: delta,
|
|
505
|
+
next: steps,
|
|
506
|
+
...emitted.length > 0 ? { emitted } : {}
|
|
507
|
+
};
|
|
508
|
+
if (outcome.status === "pending" && executed === void 0) {
|
|
509
|
+
const candidate = selected ? steps.find((step) => selected.kind === "llm" && step.kind === "llm" && step.stepId === selected.stepId) : steps.length === 1 ? steps[0] : void 0;
|
|
510
|
+
if (candidate?.kind === "llm") {
|
|
511
|
+
const aiGateway = outcome.llmRequests?.get(candidate.stepId);
|
|
512
|
+
if (!aiGateway || !delta.every(isExternalMemoEntry)) return {
|
|
513
|
+
...base,
|
|
514
|
+
disposition: "failed",
|
|
515
|
+
error: "external LLM work requires a prepared request and only completed now/uuid memo entries"
|
|
516
|
+
};
|
|
517
|
+
return {
|
|
518
|
+
...base,
|
|
519
|
+
...candidate,
|
|
520
|
+
disposition: "external",
|
|
521
|
+
memoDelta: delta,
|
|
522
|
+
next: steps.filter((step) => step.stepId !== candidate.stepId),
|
|
523
|
+
external: { aiGateway }
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const nextDisposition = disposition(outcome);
|
|
528
|
+
const deferred = executed?.status === "completed" && nextDisposition !== "fork";
|
|
529
|
+
return {
|
|
530
|
+
...base,
|
|
531
|
+
disposition: deferred ? "advanced" : nextDisposition,
|
|
532
|
+
next: deferred && nextDisposition === "waiting" ? [] : steps,
|
|
533
|
+
...executed === void 0 ? {} : { executed },
|
|
534
|
+
...deferred || output === void 0 ? {} : { output },
|
|
535
|
+
...deferred || error === void 0 ? {} : { error }
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
//#endregion
|
|
482
539
|
//#region src/stacks/tanstack/steps.ts
|
|
483
540
|
function json(status, body) {
|
|
484
541
|
return new Response(JSON.stringify(body), {
|
|
@@ -515,7 +572,7 @@ function parseBody(value) {
|
|
|
515
572
|
if (new Set(body.memo.map((entry) => entry.stepId)).size !== body.memo.length) return "memo entries must be unique per stepId";
|
|
516
573
|
}
|
|
517
574
|
if (body.action !== void 0 && body.action !== "advance" && body.action !== "execute") return "action must be \"advance\" or \"execute\"";
|
|
518
|
-
if (body.action === "execute" && !isStepReference(body.step)) return "step must be a { kind: \"step\", stepId } reference when action is \"execute\"";
|
|
575
|
+
if (body.action === "execute" && !isStepReference(body.step)) return "step must be a { kind: \"step\" | \"llm\", stepId } reference when action is \"execute\"";
|
|
519
576
|
if (body.action !== "execute" && body.step !== void 0) return "step is only valid when action is \"execute\"";
|
|
520
577
|
if (body.memo !== void 0 && body.memo.length > 0 && !("input" in value)) return "input must be sent with every call, including a resume";
|
|
521
578
|
return body;
|
|
@@ -527,34 +584,7 @@ async function readBody(request) {
|
|
|
527
584
|
}
|
|
528
585
|
function isStepReference(value) {
|
|
529
586
|
const step = value;
|
|
530
|
-
return typeof step === "object" && step !== null && step.kind === "step" && typeof step.stepId === "string";
|
|
531
|
-
}
|
|
532
|
-
function disposition(outcome) {
|
|
533
|
-
if (outcome.status === "completed") return "completed";
|
|
534
|
-
if (outcome.status === "failed") return "failed";
|
|
535
|
-
if (!outcome.steps.some((step) => step.kind === "step")) return "waiting";
|
|
536
|
-
return outcome.steps.length > 1 ? "fork" : "advanced";
|
|
537
|
-
}
|
|
538
|
-
function memoDelta(before, after) {
|
|
539
|
-
const existing = new Set(before.map((entry) => entry.stepId));
|
|
540
|
-
return after.filter((entry) => !existing.has(entry.stepId));
|
|
541
|
-
}
|
|
542
|
-
function respond(runId, inputHash, workflowVersion, before, outcome, executed) {
|
|
543
|
-
const { steps, emitted, output, error } = outcome;
|
|
544
|
-
const nextDisposition = disposition(outcome);
|
|
545
|
-
const deferred = executed?.status === "completed" && nextDisposition !== "fork";
|
|
546
|
-
return json(200, {
|
|
547
|
-
runId,
|
|
548
|
-
inputHash,
|
|
549
|
-
workflowVersion,
|
|
550
|
-
disposition: deferred ? "advanced" : nextDisposition,
|
|
551
|
-
memoDelta: memoDelta(before, outcome.memo),
|
|
552
|
-
next: deferred && nextDisposition === "waiting" ? [] : steps,
|
|
553
|
-
...executed === void 0 ? {} : { executed },
|
|
554
|
-
...emitted.length > 0 ? { emitted } : {},
|
|
555
|
-
...deferred || output === void 0 ? {} : { output },
|
|
556
|
-
...deferred || error === void 0 ? {} : { error }
|
|
557
|
-
});
|
|
587
|
+
return typeof step === "object" && step !== null && (step.kind === "step" || step.kind === "llm") && typeof step.stepId === "string";
|
|
558
588
|
}
|
|
559
589
|
function prepare(collection, options) {
|
|
560
590
|
return {
|
|
@@ -685,14 +715,15 @@ function createStepsHandler(collection, options = {}) {
|
|
|
685
715
|
input,
|
|
686
716
|
memo: before,
|
|
687
717
|
runId,
|
|
688
|
-
shouldExecute: (intent) => intent.kind !== "step" || intent.stepId === selected.stepId
|
|
718
|
+
shouldExecute: (intent) => intent.kind !== "step" || selected.kind === "step" && intent.stepId === selected.stepId
|
|
689
719
|
}));
|
|
690
720
|
const executed = outcome.results.find((result) => result.kind === "step" && result.stepId === selected.stepId);
|
|
691
|
-
|
|
721
|
+
const pendingLlm = selected.kind === "llm" && outcome.steps.some((intent) => intent.kind === "llm" && intent.stepId === selected.stepId);
|
|
722
|
+
if (executed === void 0 && !pendingLlm && outcome.status !== "failed") return json(409, {
|
|
692
723
|
error: "stale_step",
|
|
693
724
|
message: `step "${selected.stepId}" is not executable from this memo`
|
|
694
725
|
});
|
|
695
|
-
return
|
|
726
|
+
return json(200, stepsResponse(runId, inputHash, workflow.version, before, outcome, executed, selected));
|
|
696
727
|
}
|
|
697
728
|
const described = await validateOutput(workflow, await replay({
|
|
698
729
|
workflow,
|
|
@@ -702,7 +733,7 @@ function createStepsHandler(collection, options = {}) {
|
|
|
702
733
|
shouldExecute: (intent) => intent.kind !== "step"
|
|
703
734
|
}));
|
|
704
735
|
const only = described.steps.length === 1 ? described.steps[0] : void 0;
|
|
705
|
-
if (described.status !== "pending" || only?.kind !== "step") return
|
|
736
|
+
if (described.status !== "pending" || only?.kind !== "step") return json(200, stepsResponse(runId, inputHash, workflow.version, before, described));
|
|
706
737
|
const outcome = await validateOutput(workflow, await replay({
|
|
707
738
|
workflow,
|
|
708
739
|
input,
|
|
@@ -715,7 +746,7 @@ function createStepsHandler(collection, options = {}) {
|
|
|
715
746
|
error: "stale_step",
|
|
716
747
|
message: `step "${only.stepId}" is not executable from this memo`
|
|
717
748
|
});
|
|
718
|
-
return
|
|
749
|
+
return json(200, stepsResponse(runId, inputHash, workflow.version, before, outcome, executed));
|
|
719
750
|
};
|
|
720
751
|
}
|
|
721
752
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
1
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-3Syx7KCj.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-CqXgNBpN.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";
|