@decocms/runtime 1.2.15 → 1.3.1

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/src/workflows.ts CHANGED
@@ -24,6 +24,12 @@ export interface WorkflowDefinition {
24
24
  * Defaults to START_WORKFLOW_<TITLE_SLUG> (e.g. START_WORKFLOW_FETCH_USERS).
25
25
  */
26
26
  toolId?: string;
27
+ /**
28
+ * JSON Schema describing the expected input for this workflow.
29
+ * When set, the mesh validates execution input against this schema
30
+ * before creating an execution.
31
+ */
32
+ inputSchema?: Record<string, unknown> | null;
27
33
  }
28
34
 
29
35
  interface WorkflowCollectionItem {
@@ -67,6 +73,7 @@ interface MeshWorkflowClient {
67
73
  description?: string;
68
74
  virtual_mcp_id?: string;
69
75
  steps: Step[];
76
+ input_schema?: Record<string, unknown> | null;
70
77
  };
71
78
  }) => Promise<{ item: WorkflowCollectionItem }>;
72
79
  COLLECTION_WORKFLOW_UPDATE: (input: {
@@ -76,6 +83,7 @@ interface MeshWorkflowClient {
76
83
  description?: string;
77
84
  virtual_mcp_id?: string;
78
85
  steps?: Step[];
86
+ input_schema?: Record<string, unknown> | null;
79
87
  };
80
88
  }) => Promise<{ success: boolean; error?: string }>;
81
89
  COLLECTION_WORKFLOW_DELETE: (input: {
@@ -254,10 +262,11 @@ function fingerprintWorkflows(declared: WorkflowDefinition[]): string {
254
262
  return JSON.stringify(
255
263
  declared.map((w) => ({
256
264
  title: w.title,
257
- description: w.description ?? null,
258
- virtual_mcp_id: w.virtual_mcp_id ?? null,
265
+ description: w.description ?? undefined,
266
+ virtual_mcp_id: w.virtual_mcp_id ?? undefined,
259
267
  steps: w.steps,
260
- toolId: w.toolId ?? null,
268
+ toolId: w.toolId ?? undefined,
269
+ inputSchema: w.inputSchema ?? undefined,
261
270
  })),
262
271
  );
263
272
  }
@@ -383,6 +392,10 @@ async function doSyncWorkflows(
383
392
  virtual_mcp_id: resolvedVmcpId,
384
393
  }),
385
394
  steps: wf.steps,
395
+ input_schema:
396
+ wf.inputSchema === undefined
397
+ ? undefined
398
+ : (wf.inputSchema ?? null),
386
399
  },
387
400
  });
388
401
  if (!result.success) {
@@ -402,6 +415,7 @@ async function doSyncWorkflows(
402
415
  description: wf.description,
403
416
  virtual_mcp_id: resolvedVmcpId,
404
417
  steps: wf.steps,
418
+ input_schema: wf.inputSchema ?? null,
405
419
  },
406
420
  });
407
421
  console.log(`${tag} CREATE "${wf.title}" OK`);
@@ -596,8 +610,30 @@ type InputForTool<
596
610
  : StepInput<TSteps>
597
611
  : StepInput<TSteps>;
598
612
 
599
- type BaseStepFields = Omit<Step, "name" | "input" | "action">;
600
- type BaseForEachFields = Omit<Step, "name" | "forEach" | "input" | "action">;
613
+ /**
614
+ * Typed bail condition with @ref autocomplete.
615
+ * Self-references (e.g. `@thisStep.field` on step "thisStep") are valid for
616
+ * bail — the condition is evaluated after the step completes — but the current
617
+ * step name isn't in TSteps yet. Use the `(string & {})` escape hatch.
618
+ */
619
+ type TypedBail<TSteps extends string> =
620
+ | true
621
+ | {
622
+ ref: KnownRefs<TSteps>;
623
+ eq?: unknown;
624
+ neq?: unknown;
625
+ gt?: number;
626
+ lt?: number;
627
+ };
628
+
629
+ type BaseStepFields<TSteps extends string> = Omit<
630
+ Step,
631
+ "name" | "input" | "action" | "bail"
632
+ > & { bail?: TypedBail<TSteps> };
633
+ type BaseForEachFields<TSteps extends string> = Omit<
634
+ Step,
635
+ "name" | "forEach" | "input" | "action" | "bail"
636
+ > & { bail?: TypedBail<TSteps> };
601
637
 
602
638
  /**
603
639
  * Tool-call variants of StepOpts — one discriminated member per tool ID so
@@ -608,12 +644,12 @@ type ToolCallStepOpts<
608
644
  TSteps extends string,
609
645
  TTools extends readonly ToolLike[],
610
646
  > = [TTools[number]] extends [never]
611
- ? BaseStepFields & {
647
+ ? BaseStepFields<TSteps> & {
612
648
  action: { toolName: string & {}; transformCode?: string };
613
649
  input?: StepInput<TSteps>;
614
650
  }
615
651
  : {
616
- [TId in TTools[number]["id"]]: BaseStepFields & {
652
+ [TId in TTools[number]["id"]]: BaseStepFields<TSteps> & {
617
653
  action: { toolName: TId; transformCode?: string };
618
654
  input?: InputForTool<TTools, TId, TSteps>;
619
655
  };
@@ -621,19 +657,22 @@ type ToolCallStepOpts<
621
657
 
622
658
  type StepOpts<TSteps extends string, TTools extends readonly ToolLike[]> =
623
659
  | ToolCallStepOpts<TSteps, TTools>
624
- | (BaseStepFields & { action: { code: string }; input?: StepInput<TSteps> });
660
+ | (BaseStepFields<TSteps> & {
661
+ action: { code: string };
662
+ input?: StepInput<TSteps>;
663
+ });
625
664
 
626
665
  type ToolCallForEachOpts<
627
666
  TSteps extends string,
628
667
  TTools extends readonly ToolLike[],
629
668
  > = [TTools[number]] extends [never]
630
- ? BaseForEachFields & {
669
+ ? BaseForEachFields<TSteps> & {
631
670
  action: { toolName: string & {}; transformCode?: string };
632
671
  input?: StepInput<TSteps>;
633
672
  concurrency?: number;
634
673
  }
635
674
  : {
636
- [TId in TTools[number]["id"]]: BaseForEachFields & {
675
+ [TId in TTools[number]["id"]]: BaseForEachFields<TSteps> & {
637
676
  action: { toolName: TId; transformCode?: string };
638
677
  input?: InputForTool<TTools, TId, TSteps>;
639
678
  concurrency?: number;
@@ -645,7 +684,7 @@ type ForEachItemOpts<
645
684
  TTools extends readonly ToolLike[],
646
685
  > =
647
686
  | ToolCallForEachOpts<TSteps, TTools>
648
- | (BaseForEachFields & {
687
+ | (BaseForEachFields<TSteps> & {
649
688
  action: { code: string };
650
689
  input?: StepInput<TSteps>;
651
690
  concurrency?: number;