@gobing-ai/ts-dual-workflow-engine 0.4.30 → 0.4.32
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 +47 -4
- package/dist/extensions.d.ts +11 -0
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +20 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/schema.d.ts +25 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +34 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/schemas/state-machine-workflow.schema.json +23 -1
- package/schemas/transition-flow-workflow.schema.json +23 -1
- package/src/extensions.ts +25 -1
- package/src/index.ts +3 -0
- package/src/schema.ts +35 -0
- package/src/types.ts +13 -0
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ The package exposes:
|
|
|
49
49
|
|--------|---------|
|
|
50
50
|
| `loadWorkflowDef()` / `loadWorkflowDefFromText()` | YAML/JSON workflow loading and validation |
|
|
51
51
|
| `validateWorkflowDef()` | Semantic invariant checking beyond Zod schema |
|
|
52
|
-
| `StateMachineWorkflowDefSchema` / `TransitionFlowWorkflowDefSchema` / `WorkflowDefSchema` | Zod schemas for workflow definition validation |
|
|
52
|
+
| `StateMachineWorkflowDefSchema` / `TransitionFlowWorkflowDefSchema` / `WorkflowDefSchema` / `WorkflowExtensionsSchema` | Zod schemas for workflow definition validation |
|
|
53
53
|
| `ActionDefSchema` / `GuardDefSchema` | Zod schemas for action and guard definitions |
|
|
54
54
|
|
|
55
55
|
### Extensions
|
|
@@ -57,7 +57,8 @@ The package exposes:
|
|
|
57
57
|
| Export | Purpose |
|
|
58
58
|
|--------|---------|
|
|
59
59
|
| `loadWorkflowExtensionsIntoHost()` | Trust-gated extension module loading for actions and guards |
|
|
60
|
-
| `
|
|
60
|
+
| `collectWorkflowExtensions()` | Map a YAML `extensions` block to `WorkflowExtensionRef[]` (no import) |
|
|
61
|
+
| `WorkflowExtensions` / `WorkflowExtensionRef` / `LoadWorkflowExtensionsOptions` / `WorkflowExtensionKind` | Extension block and loading types |
|
|
61
62
|
|
|
62
63
|
### Runtime
|
|
63
64
|
|
|
@@ -706,7 +707,7 @@ const host = new WorkflowEngineHost();
|
|
|
706
707
|
|
|
707
708
|
await loadWorkflowExtensionsIntoHost(
|
|
708
709
|
host,
|
|
709
|
-
[{ kind: 'actions',
|
|
710
|
+
[{ kind: 'actions', path: './exts/audit.ts', baseDir: '/project/workflows', sourceName: 'my-config' }],
|
|
710
711
|
{
|
|
711
712
|
allowExtensions: true, // required — disabled by default
|
|
712
713
|
moduleLoader: (absPath) => import(absPath),
|
|
@@ -716,12 +717,54 @@ await loadWorkflowExtensionsIntoHost(
|
|
|
716
717
|
|
|
717
718
|
When a ref has `kind: 'actions'`, only the module's `actions[]` entries are registered; `guards[]` in the same module are ignored (and vice versa). Override warnings are emitted through an optional `logger.warn` callback when an extension replaces a built-in capability.
|
|
718
719
|
|
|
720
|
+
### Declaring extensions in YAML
|
|
721
|
+
|
|
722
|
+
Like rule presets, a workflow file can declare relative extension modules inline. Both dialects accept an optional top-level `extensions` block with `actions` and/or `guards` arrays; the paths are resolved against the declaring YAML's directory and must be relative (absolute paths and `..` traversal are rejected at parse time):
|
|
723
|
+
|
|
724
|
+
```yaml
|
|
725
|
+
# workflows/approval.yaml
|
|
726
|
+
kind: state-machine
|
|
727
|
+
name: approval
|
|
728
|
+
extensions:
|
|
729
|
+
actions: ["./exts/audit.ts"]
|
|
730
|
+
guards: ["./exts/flag.ts"]
|
|
731
|
+
initialState: draft
|
|
732
|
+
terminalStates: [done]
|
|
733
|
+
states:
|
|
734
|
+
- id: draft
|
|
735
|
+
- id: done
|
|
736
|
+
transitions:
|
|
737
|
+
- from: draft
|
|
738
|
+
to: done
|
|
739
|
+
guard:
|
|
740
|
+
kind: feature-flag
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
```ts
|
|
744
|
+
import {
|
|
745
|
+
collectWorkflowExtensions,
|
|
746
|
+
loadWorkflowDefFromText,
|
|
747
|
+
loadWorkflowExtensionsIntoHost,
|
|
748
|
+
WorkflowEngineHost,
|
|
749
|
+
} from '@gobing-ai/ts-dual-workflow-engine';
|
|
750
|
+
import { dirnamePath } from '@gobing-ai/ts-runtime';
|
|
751
|
+
|
|
752
|
+
const def = loadWorkflowDefFromText(yamlText);
|
|
753
|
+
const refs = collectWorkflowExtensions(def.name, dirnamePath(workflowPath), def.extensions);
|
|
754
|
+
await loadWorkflowExtensionsIntoHost(host, refs, {
|
|
755
|
+
allowExtensions: true,
|
|
756
|
+
moduleLoader: (absPath) => import(absPath),
|
|
757
|
+
});
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
`collectWorkflowExtensions` maps the block to `WorkflowExtensionRef[]` (kind order `actions` then `guards`) without importing or resolving anything; it is the workflow analog of rule-engine's `collectExtensions`.
|
|
761
|
+
|
|
719
762
|
### Security
|
|
720
763
|
|
|
721
764
|
**Extension modules execute arbitrary code.** The trust gate is fail-closed:
|
|
722
765
|
|
|
723
766
|
- `allowExtensions` defaults to `false`. When refs are present and loading is not explicitly allowed, the loader throws **before any import** — a declared extension is never silently dropped.
|
|
724
|
-
- Extension paths are
|
|
767
|
+
- Extension paths are rejected at schema parse time (absolute paths and `..` traversal) and again at load time by `assertRelativeExtensionPath`.
|
|
725
768
|
- The caller controls the `moduleLoader` function. Tests use a stub; production callers use `(absPath) => import(absPath)`. The loader itself has no ambient code-loading capability.
|
|
726
769
|
|
|
727
770
|
## Zod Schemas
|
package/dist/extensions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@gobing-ai/ts-infra';
|
|
2
2
|
import type { WorkflowEngineHost } from './host';
|
|
3
|
+
import type { WorkflowExtensions } from './types';
|
|
3
4
|
/** Minimal warning sink accepted for non-fatal extension diagnostics; a full {@link Logger} satisfies it. */
|
|
4
5
|
export type WorkflowExtensionLogger = Pick<Logger, 'warn'>;
|
|
5
6
|
/**
|
|
@@ -51,6 +52,16 @@ export interface LoadWorkflowExtensionsOptions {
|
|
|
51
52
|
*/
|
|
52
53
|
readonly realPath?: (absPath: string) => string;
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Build `WorkflowExtensionRef[]` from a YAML `extensions` block without importing
|
|
57
|
+
* or resolving anything.
|
|
58
|
+
*
|
|
59
|
+
* Kind order is `actions` then `guards`. Paths are kept **as authored** (no
|
|
60
|
+
* basename smash, no `resolve(sourceDir, path)`) so the shared loader sees the
|
|
61
|
+
* real declaration — a `..` segment or absolute path is rejected there by
|
|
62
|
+
* `assertRelativeExtensionPath`, not after a rewrite here.
|
|
63
|
+
*/
|
|
64
|
+
export declare function collectWorkflowExtensions(sourceName: string, sourceDir: string, extensions: WorkflowExtensions | undefined): WorkflowExtensionRef[];
|
|
54
65
|
/**
|
|
55
66
|
* Import each extension module behind an explicit trust gate and register
|
|
56
67
|
* its actions and/or guards on the workflow host.
|
package/dist/extensions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7E,6GAA6G;AAC7G,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7E;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACrC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAC3C,oBAAoB,EAAE,CASxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,8BAA8B,CAChD,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,SAAS,oBAAoB,EAAE,EACrC,OAAO,EAAE,6BAA6B,GACvC,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
package/dist/extensions.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { loadExtensionModules } from '@gobing-ai/ts-runtime/extension';
|
|
2
2
|
import { WorkflowValidationError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build `WorkflowExtensionRef[]` from a YAML `extensions` block without importing
|
|
5
|
+
* or resolving anything.
|
|
6
|
+
*
|
|
7
|
+
* Kind order is `actions` then `guards`. Paths are kept **as authored** (no
|
|
8
|
+
* basename smash, no `resolve(sourceDir, path)`) so the shared loader sees the
|
|
9
|
+
* real declaration — a `..` segment or absolute path is rejected there by
|
|
10
|
+
* `assertRelativeExtensionPath`, not after a rewrite here.
|
|
11
|
+
*/
|
|
12
|
+
export function collectWorkflowExtensions(sourceName, sourceDir, extensions) {
|
|
13
|
+
if (extensions === undefined)
|
|
14
|
+
return [];
|
|
15
|
+
const refs = [];
|
|
16
|
+
for (const kind of ['actions', 'guards']) {
|
|
17
|
+
for (const path of extensions[kind] ?? []) {
|
|
18
|
+
refs.push({ kind, sourceName, path, baseDir: sourceDir });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return refs;
|
|
22
|
+
}
|
|
3
23
|
/**
|
|
4
24
|
* Import each extension module behind an explicit trust gate and register
|
|
5
25
|
* its actions and/or guards on the workflow host.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { loadWorkflowDef, loadWorkflowDefFromText, validateWorkflowDef } from './config';
|
|
2
2
|
export { FSMError, RunCollisionError, WorkflowResumeError, WorkflowValidationError } from './errors';
|
|
3
3
|
export type { WorkflowEngineEvents } from './events';
|
|
4
|
-
export { type LoadWorkflowExtensionsOptions, loadWorkflowExtensionsIntoHost, type WorkflowExtensionKind, type WorkflowExtensionLogger, type WorkflowExtensionRef, } from './extensions';
|
|
4
|
+
export { collectWorkflowExtensions, type LoadWorkflowExtensionsOptions, loadWorkflowExtensionsIntoHost, type WorkflowExtensionKind, type WorkflowExtensionLogger, type WorkflowExtensionRef, } from './extensions';
|
|
5
5
|
export type { HitlAnswer, HitlRequest, HitlRequestKind, HitlResponder } from './hitl';
|
|
6
6
|
export { createDefaultWorkflowEngineHost, EventEmitActionRunner, NoteActionRunner, ShellActionRunner, ShellGuardRunner, WorkflowEngineHost, } from './host';
|
|
7
7
|
export { applyWorkflowEngineSchema, DbWorkflowPersistenceAdapter, MemoryWorkflowPersistenceAdapter, } from './persistence';
|
|
8
8
|
export { allowedEnv, RUNTIME_BUILTIN_KEYS, RunLifecycle, type RunLifecycleDeps, runtimeBuiltins, type WorkflowMode, } from './run-lifecycle';
|
|
9
|
-
export { ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema, } from './schema';
|
|
9
|
+
export { ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema, WorkflowExtensionsSchema, } from './schema';
|
|
10
10
|
export { WORKFLOW_ENGINE_SCHEMA_SQL } from './schema-sql';
|
|
11
11
|
export { WorkflowService } from './service';
|
|
12
12
|
export { StateMachineDriver, type StateMachineDriverOptions } from './state-machine';
|
|
13
13
|
export { TransitionFlowDriver, type TransitionFlowDriverOptions } from './transition-flow';
|
|
14
|
-
export type { ActionDef, ActionRedactor, ActionResult, ActionRunContext, ActionRunner, ActionRunRecord, Env, FlowEdgeDef, FlowNodeDef, GuardContext, GuardDef, GuardEvaluationResult, GuardRunner, OnErrorPolicy, StateDef, StateMachineWorkflowDef, TransitionAllowed, TransitionDef, TransitionDenied, TransitionDeniedReason, TransitionFlowWorkflowDef, TransitionRequestResult, Vars, WorkflowDef, WorkflowPersistenceAdapter, WorkflowRunOptions, WorkflowRunRecord, WorkflowRunResult, WorkflowStatus, } from './types';
|
|
14
|
+
export type { ActionDef, ActionRedactor, ActionResult, ActionRunContext, ActionRunner, ActionRunRecord, Env, FlowEdgeDef, FlowNodeDef, GuardContext, GuardDef, GuardEvaluationResult, GuardRunner, OnErrorPolicy, StateDef, StateMachineWorkflowDef, TransitionAllowed, TransitionDef, TransitionDenied, TransitionDeniedReason, TransitionFlowWorkflowDef, TransitionRequestResult, Vars, WorkflowDef, WorkflowExtensions, WorkflowPersistenceAdapter, WorkflowRunOptions, WorkflowRunRecord, WorkflowRunResult, WorkflowStatus, } from './types';
|
|
15
15
|
export { mergeSetVars, mergeVars, resolveOnErrorPolicy, resolveTemplateString, resolveTemplates, type VariableContext, } from './variables';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACrG,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACH,KAAK,6BAA6B,EAClC,8BAA8B,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,GAC5B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACtF,OAAO,EACH,+BAA+B,EAC/B,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACH,yBAAyB,EACzB,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,KAAK,gBAAgB,EACrB,eAAe,EACf,KAAK,YAAY,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,eAAe,EACf,cAAc,EACd,6BAA6B,EAC7B,+BAA+B,EAC/B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/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ChB,YAAY,EACZ,eAAe,EACf,GAAG,EACH,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,IAAI,EACJ,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EACH,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,eAAe,GACvB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { loadWorkflowDef, loadWorkflowDefFromText, validateWorkflowDef } from './config.js';
|
|
2
2
|
export { FSMError, RunCollisionError, WorkflowResumeError, WorkflowValidationError } from './errors.js';
|
|
3
|
-
export { loadWorkflowExtensionsIntoHost, } from './extensions.js';
|
|
3
|
+
export { collectWorkflowExtensions, loadWorkflowExtensionsIntoHost, } from './extensions.js';
|
|
4
4
|
export { createDefaultWorkflowEngineHost, EventEmitActionRunner, NoteActionRunner, ShellActionRunner, ShellGuardRunner, WorkflowEngineHost, } from './host.js';
|
|
5
5
|
export { applyWorkflowEngineSchema, DbWorkflowPersistenceAdapter, MemoryWorkflowPersistenceAdapter, } from './persistence.js';
|
|
6
6
|
export { allowedEnv, RUNTIME_BUILTIN_KEYS, RunLifecycle, runtimeBuiltins, } from './run-lifecycle.js';
|
|
7
|
-
export { ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema, } from './schema.js';
|
|
7
|
+
export { ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema, WorkflowExtensionsSchema, } from './schema.js';
|
|
8
8
|
export { WORKFLOW_ENGINE_SCHEMA_SQL } from './schema-sql.js';
|
|
9
9
|
export { WorkflowService } from './service.js';
|
|
10
10
|
export { StateMachineDriver } from './state-machine.js';
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Rule-style `extensions` block for workflow YAML: relative module paths for
|
|
4
|
+
* the two extension-loadable capability kinds. `.strict()` rejects unknown keys
|
|
5
|
+
* (e.g. `evaluators` or `plugins`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const WorkflowExtensionsSchema: z.ZodObject<{
|
|
8
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
2
11
|
/** Zod schema for workflow action definitions. */
|
|
3
12
|
export declare const ActionDefSchema: z.ZodObject<{
|
|
4
13
|
kind: z.ZodString;
|
|
@@ -63,6 +72,10 @@ export declare const StateMachineWorkflowDefSchema: z.ZodObject<{
|
|
|
63
72
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
73
|
}, z.core.$strip>>;
|
|
65
74
|
}, z.core.$strict>>;
|
|
75
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
+
}, z.core.$strict>>;
|
|
66
79
|
}, z.core.$strict>;
|
|
67
80
|
/** Zod schema for transition-flow workflow definitions. */
|
|
68
81
|
export declare const TransitionFlowWorkflowDefSchema: z.ZodObject<{
|
|
@@ -110,6 +123,10 @@ export declare const TransitionFlowWorkflowDefSchema: z.ZodObject<{
|
|
|
110
123
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
111
124
|
}, z.core.$strip>>;
|
|
112
125
|
}, z.core.$strict>>;
|
|
126
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
129
|
+
}, z.core.$strict>>;
|
|
113
130
|
}, z.core.$strict>;
|
|
114
131
|
/** Zod schema for either supported workflow definition shape. */
|
|
115
132
|
export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -161,6 +178,10 @@ export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
161
178
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
162
179
|
}, z.core.$strip>>;
|
|
163
180
|
}, z.core.$strict>>;
|
|
181
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
182
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
183
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
184
|
+
}, z.core.$strict>>;
|
|
164
185
|
}, z.core.$strict>, z.ZodObject<{
|
|
165
186
|
$schema: z.ZodOptional<z.ZodString>;
|
|
166
187
|
kind: z.ZodLiteral<"transition-flow">;
|
|
@@ -206,5 +227,9 @@ export declare const WorkflowDefSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
206
227
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
207
228
|
}, z.core.$strip>>;
|
|
208
229
|
}, z.core.$strict>>;
|
|
230
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
231
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
232
|
+
guards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
|
+
}, z.core.$strict>>;
|
|
209
234
|
}, z.core.$strict>]>;
|
|
210
235
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6CxB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;kBAKxB,CAAC;AAEd,kDAAkD;AAClD,eAAO,MAAM,eAAe;;;;;;;iBAI1B,CAAC;AAEH,iDAAiD;AACjD,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAwC7B,CAAC;AAEd,2DAA2D;AAC3D,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsC/B,CAAC;AAEd,iEAAiE;AACjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAA4E,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertRelativeExtensionPath } from '@gobing-ai/ts-runtime/extension';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
/** Identifier names reserved for runtime template namespaces; not allowed as user vars. */
|
|
3
4
|
const RESERVED_VAR_NAMES = new Set(['task', 'state', 'node', 'iteration', 'run', 'runtime']);
|
|
@@ -18,6 +19,37 @@ const VarsSchema = z.record(z.string(), z.string()).superRefine((vars, ctx) => {
|
|
|
18
19
|
const EnvSchema = z.object({
|
|
19
20
|
allow: z.array(z.string().regex(IDENTIFIER, 'env.allow entries must be valid identifiers')).optional(),
|
|
20
21
|
});
|
|
22
|
+
/**
|
|
23
|
+
* Extension module paths must be relative and must not escape the declaring
|
|
24
|
+
* directory. Mirrors rule-engine's private helper; the real guard is the shared
|
|
25
|
+
* `assertRelativeExtensionPath` (ADR-010) so schema-time and load-time
|
|
26
|
+
* validation share one source of truth.
|
|
27
|
+
*/
|
|
28
|
+
const relativeExtensionPath = z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.superRefine((value, ctx) => {
|
|
32
|
+
try {
|
|
33
|
+
assertRelativeExtensionPath(value);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
ctx.addIssue({
|
|
37
|
+
code: 'custom',
|
|
38
|
+
message: error instanceof Error ? error.message : 'invalid extension path',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Rule-style `extensions` block for workflow YAML: relative module paths for
|
|
44
|
+
* the two extension-loadable capability kinds. `.strict()` rejects unknown keys
|
|
45
|
+
* (e.g. `evaluators` or `plugins`).
|
|
46
|
+
*/
|
|
47
|
+
export const WorkflowExtensionsSchema = z
|
|
48
|
+
.object({
|
|
49
|
+
actions: z.array(relativeExtensionPath).optional(),
|
|
50
|
+
guards: z.array(relativeExtensionPath).optional(),
|
|
51
|
+
})
|
|
52
|
+
.strict();
|
|
21
53
|
/** Zod schema for workflow action definitions. */
|
|
22
54
|
export const ActionDefSchema = z.object({
|
|
23
55
|
kind: z.string().min(1),
|
|
@@ -64,6 +96,7 @@ export const StateMachineWorkflowDefSchema = z
|
|
|
64
96
|
guard: GuardDefSchema.optional(),
|
|
65
97
|
})
|
|
66
98
|
.strict()),
|
|
99
|
+
extensions: WorkflowExtensionsSchema.optional(),
|
|
67
100
|
})
|
|
68
101
|
.strict();
|
|
69
102
|
/** Zod schema for transition-flow workflow definitions. */
|
|
@@ -99,6 +132,7 @@ export const TransitionFlowWorkflowDefSchema = z
|
|
|
99
132
|
condition: GuardDefSchema.optional(),
|
|
100
133
|
})
|
|
101
134
|
.strict()),
|
|
135
|
+
extensions: WorkflowExtensionsSchema.optional(),
|
|
102
136
|
})
|
|
103
137
|
.strict();
|
|
104
138
|
/** Zod schema for either supported workflow definition shape. */
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,16 @@ export interface GuardDef {
|
|
|
22
22
|
readonly kind: string;
|
|
23
23
|
readonly options?: Record<string, unknown>;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Rule-style `extensions` block: relative module paths for the two
|
|
27
|
+
* extension-loadable capability kinds (`actions`, `guards`). Mirrors
|
|
28
|
+
* rule-engine's preset extensions; paths are resolved by the caller against
|
|
29
|
+
* the declaring YAML directory.
|
|
30
|
+
*/
|
|
31
|
+
export interface WorkflowExtensions {
|
|
32
|
+
readonly actions?: readonly string[];
|
|
33
|
+
readonly guards?: readonly string[];
|
|
34
|
+
}
|
|
25
35
|
/** One state in a state-machine workflow. */
|
|
26
36
|
export interface StateDef {
|
|
27
37
|
readonly id: string;
|
|
@@ -63,6 +73,7 @@ export interface StateMachineWorkflowDef {
|
|
|
63
73
|
readonly env?: Env;
|
|
64
74
|
readonly states: readonly StateDef[];
|
|
65
75
|
readonly transitions: readonly TransitionDef[];
|
|
76
|
+
readonly extensions?: WorkflowExtensions;
|
|
66
77
|
}
|
|
67
78
|
/** Transition-flow node definition. */
|
|
68
79
|
export interface FlowNodeDef {
|
|
@@ -99,6 +110,7 @@ export interface TransitionFlowWorkflowDef {
|
|
|
99
110
|
readonly env?: Env;
|
|
100
111
|
readonly nodes: readonly FlowNodeDef[];
|
|
101
112
|
readonly edges: readonly FlowEdgeDef[];
|
|
113
|
+
readonly extensions?: WorkflowExtensions;
|
|
102
114
|
}
|
|
103
115
|
/** Discriminated workflow definition union. */
|
|
104
116
|
export type WorkflowDef = StateMachineWorkflowDef | TransitionFlowWorkflowDef;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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A;KAAE,GAAG,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC;CAC9G"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-dual-workflow-engine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"description": "@gobing-ai/ts-dual-workflow-engine — State-machine and transition-flow workflow runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-dual-workflow-engine-v<version> && git push --tags' && exit 1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@gobing-ai/ts-db": "^0.4.
|
|
52
|
-
"@gobing-ai/ts-infra": "^0.4.
|
|
53
|
-
"@gobing-ai/ts-runtime": "^0.4.
|
|
51
|
+
"@gobing-ai/ts-db": "^0.4.32",
|
|
52
|
+
"@gobing-ai/ts-infra": "^0.4.32",
|
|
53
|
+
"@gobing-ai/ts-runtime": "^0.4.32",
|
|
54
54
|
"zod": "^4.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"guard": { "$ref": "#/$defs/guard" }
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"extensions": { "$ref": "#/$defs/extensions" }
|
|
67
68
|
},
|
|
68
69
|
"$defs": {
|
|
69
70
|
"action": {
|
|
@@ -83,6 +84,27 @@
|
|
|
83
84
|
"kind": { "type": "string", "minLength": 1 },
|
|
84
85
|
"options": { "type": "object", "additionalProperties": true }
|
|
85
86
|
}
|
|
87
|
+
},
|
|
88
|
+
"relativeExtensionPath": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"minLength": 1,
|
|
91
|
+
"description": "Relative module path; absolute paths and '..' traversal are forbidden.",
|
|
92
|
+
"not": {
|
|
93
|
+
"anyOf": [
|
|
94
|
+
{ "pattern": "^[/\\\\]" },
|
|
95
|
+
{ "pattern": "^[A-Za-z]:[/\\\\]" },
|
|
96
|
+
{ "pattern": "(^|[/\\\\])\\.\\.([/\\\\]|$)" }
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"extensions": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"additionalProperties": false,
|
|
103
|
+
"description": "Rule-style relative extension module paths (actions / guards).",
|
|
104
|
+
"properties": {
|
|
105
|
+
"actions": { "type": "array", "items": { "$ref": "#/$defs/relativeExtensionPath" } },
|
|
106
|
+
"guards": { "type": "array", "items": { "$ref": "#/$defs/relativeExtensionPath" } }
|
|
107
|
+
}
|
|
86
108
|
}
|
|
87
109
|
}
|
|
88
110
|
}
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"condition": { "$ref": "#/$defs/guard" }
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"extensions": { "$ref": "#/$defs/extensions" }
|
|
61
62
|
},
|
|
62
63
|
"$defs": {
|
|
63
64
|
"action": {
|
|
@@ -77,6 +78,27 @@
|
|
|
77
78
|
"kind": { "type": "string", "minLength": 1 },
|
|
78
79
|
"options": { "type": "object", "additionalProperties": true }
|
|
79
80
|
}
|
|
81
|
+
},
|
|
82
|
+
"relativeExtensionPath": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"minLength": 1,
|
|
85
|
+
"description": "Relative module path; absolute paths and '..' traversal are forbidden.",
|
|
86
|
+
"not": {
|
|
87
|
+
"anyOf": [
|
|
88
|
+
{ "pattern": "^[/\\\\]" },
|
|
89
|
+
{ "pattern": "^[A-Za-z]:[/\\\\]" },
|
|
90
|
+
{ "pattern": "(^|[/\\\\])\\.\\.([/\\\\]|$)" }
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"extensions": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"description": "Rule-style relative extension module paths (actions / guards).",
|
|
98
|
+
"properties": {
|
|
99
|
+
"actions": { "type": "array", "items": { "$ref": "#/$defs/relativeExtensionPath" } },
|
|
100
|
+
"guards": { "type": "array", "items": { "$ref": "#/$defs/relativeExtensionPath" } }
|
|
101
|
+
}
|
|
80
102
|
}
|
|
81
103
|
}
|
|
82
104
|
}
|
package/src/extensions.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ExtensionRef, LoadExtensionsOptions } from '@gobing-ai/ts-runtime/
|
|
|
3
3
|
import { loadExtensionModules } from '@gobing-ai/ts-runtime/extension';
|
|
4
4
|
import { WorkflowValidationError } from './errors';
|
|
5
5
|
import type { WorkflowEngineHost } from './host';
|
|
6
|
-
import type { ActionRunner, GuardRunner } from './types';
|
|
6
|
+
import type { ActionRunner, GuardRunner, WorkflowExtensions } from './types';
|
|
7
7
|
|
|
8
8
|
/** Minimal warning sink accepted for non-fatal extension diagnostics; a full {@link Logger} satisfies it. */
|
|
9
9
|
export type WorkflowExtensionLogger = Pick<Logger, 'warn'>;
|
|
@@ -60,6 +60,30 @@ export interface LoadWorkflowExtensionsOptions {
|
|
|
60
60
|
readonly realPath?: (absPath: string) => string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Build `WorkflowExtensionRef[]` from a YAML `extensions` block without importing
|
|
65
|
+
* or resolving anything.
|
|
66
|
+
*
|
|
67
|
+
* Kind order is `actions` then `guards`. Paths are kept **as authored** (no
|
|
68
|
+
* basename smash, no `resolve(sourceDir, path)`) so the shared loader sees the
|
|
69
|
+
* real declaration — a `..` segment or absolute path is rejected there by
|
|
70
|
+
* `assertRelativeExtensionPath`, not after a rewrite here.
|
|
71
|
+
*/
|
|
72
|
+
export function collectWorkflowExtensions(
|
|
73
|
+
sourceName: string,
|
|
74
|
+
sourceDir: string,
|
|
75
|
+
extensions: WorkflowExtensions | undefined,
|
|
76
|
+
): WorkflowExtensionRef[] {
|
|
77
|
+
if (extensions === undefined) return [];
|
|
78
|
+
const refs: WorkflowExtensionRef[] = [];
|
|
79
|
+
for (const kind of ['actions', 'guards'] as const) {
|
|
80
|
+
for (const path of extensions[kind] ?? []) {
|
|
81
|
+
refs.push({ kind, sourceName, path, baseDir: sourceDir });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return refs;
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
/**
|
|
64
88
|
* Import each extension module behind an explicit trust gate and register
|
|
65
89
|
* its actions and/or guards on the workflow host.
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { loadWorkflowDef, loadWorkflowDefFromText, validateWorkflowDef } from '.
|
|
|
2
2
|
export { FSMError, RunCollisionError, WorkflowResumeError, WorkflowValidationError } from './errors';
|
|
3
3
|
export type { WorkflowEngineEvents } from './events';
|
|
4
4
|
export {
|
|
5
|
+
collectWorkflowExtensions,
|
|
5
6
|
type LoadWorkflowExtensionsOptions,
|
|
6
7
|
loadWorkflowExtensionsIntoHost,
|
|
7
8
|
type WorkflowExtensionKind,
|
|
@@ -36,6 +37,7 @@ export {
|
|
|
36
37
|
StateMachineWorkflowDefSchema,
|
|
37
38
|
TransitionFlowWorkflowDefSchema,
|
|
38
39
|
WorkflowDefSchema,
|
|
40
|
+
WorkflowExtensionsSchema,
|
|
39
41
|
} from './schema';
|
|
40
42
|
export { WORKFLOW_ENGINE_SCHEMA_SQL } from './schema-sql';
|
|
41
43
|
export { WorkflowService } from './service';
|
|
@@ -66,6 +68,7 @@ export type {
|
|
|
66
68
|
TransitionRequestResult,
|
|
67
69
|
Vars,
|
|
68
70
|
WorkflowDef,
|
|
71
|
+
WorkflowExtensions,
|
|
69
72
|
WorkflowPersistenceAdapter,
|
|
70
73
|
WorkflowRunOptions,
|
|
71
74
|
WorkflowRunRecord,
|
package/src/schema.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertRelativeExtensionPath } from '@gobing-ai/ts-runtime/extension';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
/** Identifier names reserved for runtime template namespaces; not allowed as user vars. */
|
|
@@ -23,6 +24,38 @@ const EnvSchema = z.object({
|
|
|
23
24
|
allow: z.array(z.string().regex(IDENTIFIER, 'env.allow entries must be valid identifiers')).optional(),
|
|
24
25
|
});
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Extension module paths must be relative and must not escape the declaring
|
|
29
|
+
* directory. Mirrors rule-engine's private helper; the real guard is the shared
|
|
30
|
+
* `assertRelativeExtensionPath` (ADR-010) so schema-time and load-time
|
|
31
|
+
* validation share one source of truth.
|
|
32
|
+
*/
|
|
33
|
+
const relativeExtensionPath = z
|
|
34
|
+
.string()
|
|
35
|
+
.min(1)
|
|
36
|
+
.superRefine((value, ctx) => {
|
|
37
|
+
try {
|
|
38
|
+
assertRelativeExtensionPath(value);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
ctx.addIssue({
|
|
41
|
+
code: 'custom',
|
|
42
|
+
message: error instanceof Error ? error.message : 'invalid extension path',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Rule-style `extensions` block for workflow YAML: relative module paths for
|
|
49
|
+
* the two extension-loadable capability kinds. `.strict()` rejects unknown keys
|
|
50
|
+
* (e.g. `evaluators` or `plugins`).
|
|
51
|
+
*/
|
|
52
|
+
export const WorkflowExtensionsSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
actions: z.array(relativeExtensionPath).optional(),
|
|
55
|
+
guards: z.array(relativeExtensionPath).optional(),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
58
|
+
|
|
26
59
|
/** Zod schema for workflow action definitions. */
|
|
27
60
|
export const ActionDefSchema = z.object({
|
|
28
61
|
kind: z.string().min(1),
|
|
@@ -75,6 +108,7 @@ export const StateMachineWorkflowDefSchema = z
|
|
|
75
108
|
})
|
|
76
109
|
.strict(),
|
|
77
110
|
),
|
|
111
|
+
extensions: WorkflowExtensionsSchema.optional(),
|
|
78
112
|
})
|
|
79
113
|
.strict();
|
|
80
114
|
|
|
@@ -115,6 +149,7 @@ export const TransitionFlowWorkflowDefSchema = z
|
|
|
115
149
|
})
|
|
116
150
|
.strict(),
|
|
117
151
|
),
|
|
152
|
+
extensions: WorkflowExtensionsSchema.optional(),
|
|
118
153
|
})
|
|
119
154
|
.strict();
|
|
120
155
|
|
package/src/types.ts
CHANGED
|
@@ -29,6 +29,17 @@ export interface GuardDef {
|
|
|
29
29
|
readonly options?: Record<string, unknown>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Rule-style `extensions` block: relative module paths for the two
|
|
34
|
+
* extension-loadable capability kinds (`actions`, `guards`). Mirrors
|
|
35
|
+
* rule-engine's preset extensions; paths are resolved by the caller against
|
|
36
|
+
* the declaring YAML directory.
|
|
37
|
+
*/
|
|
38
|
+
export interface WorkflowExtensions {
|
|
39
|
+
readonly actions?: readonly string[];
|
|
40
|
+
readonly guards?: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
/** One state in a state-machine workflow. */
|
|
33
44
|
export interface StateDef {
|
|
34
45
|
readonly id: string;
|
|
@@ -72,6 +83,7 @@ export interface StateMachineWorkflowDef {
|
|
|
72
83
|
readonly env?: Env;
|
|
73
84
|
readonly states: readonly StateDef[];
|
|
74
85
|
readonly transitions: readonly TransitionDef[];
|
|
86
|
+
readonly extensions?: WorkflowExtensions;
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
/** Transition-flow node definition. */
|
|
@@ -111,6 +123,7 @@ export interface TransitionFlowWorkflowDef {
|
|
|
111
123
|
readonly env?: Env;
|
|
112
124
|
readonly nodes: readonly FlowNodeDef[];
|
|
113
125
|
readonly edges: readonly FlowEdgeDef[];
|
|
126
|
+
readonly extensions?: WorkflowExtensions;
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
/** Discriminated workflow definition union. */
|