@orbytautomation/engine 0.1.2 → 0.2.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/dist/core/EngineConfig.d.ts +5 -0
- package/dist/core/EngineConfig.d.ts.map +1 -1
- package/dist/core/EngineConfig.js +4 -0
- package/dist/core/EngineConfig.js.map +1 -1
- package/dist/core/OrbytEngine.d.ts +207 -76
- package/dist/core/OrbytEngine.d.ts.map +1 -1
- package/dist/core/OrbytEngine.js +395 -63
- package/dist/core/OrbytEngine.js.map +1 -1
- package/dist/errors/SecurityErrors.d.ts +75 -0
- package/dist/errors/SecurityErrors.d.ts.map +1 -0
- package/dist/errors/SecurityErrors.js +145 -0
- package/dist/errors/SecurityErrors.js.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/execution/ExecutionLimits.d.ts +116 -0
- package/dist/execution/ExecutionLimits.d.ts.map +1 -0
- package/dist/execution/ExecutionLimits.js +280 -0
- package/dist/execution/ExecutionLimits.js.map +1 -0
- package/dist/execution/ExecutionStrategyResolver.d.ts +140 -0
- package/dist/execution/ExecutionStrategyResolver.d.ts.map +1 -0
- package/dist/execution/ExecutionStrategyResolver.js +332 -0
- package/dist/execution/ExecutionStrategyResolver.js.map +1 -0
- package/dist/execution/IntentAnalyzer.d.ts +101 -0
- package/dist/execution/IntentAnalyzer.d.ts.map +1 -0
- package/dist/execution/IntentAnalyzer.js +348 -0
- package/dist/execution/IntentAnalyzer.js.map +1 -0
- package/dist/execution/InternalExecutionContext.d.ts +255 -0
- package/dist/execution/InternalExecutionContext.d.ts.map +1 -0
- package/dist/execution/InternalExecutionContext.js +175 -0
- package/dist/execution/InternalExecutionContext.js.map +1 -0
- package/dist/execution/index.d.ts +5 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +6 -0
- package/dist/execution/index.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/loader/WorkflowLoader.d.ts +154 -0
- package/dist/loader/WorkflowLoader.d.ts.map +1 -0
- package/dist/loader/WorkflowLoader.js +239 -0
- package/dist/loader/WorkflowLoader.js.map +1 -0
- package/dist/loader/index.d.ts +10 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +10 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/parser/SchemaValidator.d.ts.map +1 -1
- package/dist/parser/SchemaValidator.js +14 -2
- package/dist/parser/SchemaValidator.js.map +1 -1
- package/dist/parser/WorkflowParser.d.ts +8 -0
- package/dist/parser/WorkflowParser.d.ts.map +1 -1
- package/dist/parser/WorkflowParser.js +6 -0
- package/dist/parser/WorkflowParser.js.map +1 -1
- package/dist/security/ReservedFields.d.ts +64 -0
- package/dist/security/ReservedFields.d.ts.map +1 -0
- package/dist/security/ReservedFields.js +253 -0
- package/dist/security/ReservedFields.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/types/core-types.d.ts +59 -0
- package/dist/types/core-types.d.ts.map +1 -0
- package/dist/types/core-types.js +2 -0
- package/dist/types/core-types.js.map +1 -0
- package/package.json +1 -1
|
@@ -44,6 +44,11 @@ export interface OrbytEngineConfig {
|
|
|
44
44
|
* @default 10
|
|
45
45
|
*/
|
|
46
46
|
maxConcurrentWorkflows?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum number of steps that can execute concurrently within a workflow
|
|
49
|
+
* @default 10
|
|
50
|
+
*/
|
|
51
|
+
maxConcurrentSteps?: number;
|
|
47
52
|
/**
|
|
48
53
|
* Default timeout for workflows (milliseconds)
|
|
49
54
|
* @default 300000 (5 minutes)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineCon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GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,iBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC,CAuB/R;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAwB9D"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
export function applyConfigDefaults(config = {}) {
|
|
16
16
|
return {
|
|
17
17
|
maxConcurrentWorkflows: config.maxConcurrentWorkflows ?? 10,
|
|
18
|
+
maxConcurrentSteps: config.maxConcurrentSteps ?? 10,
|
|
18
19
|
defaultTimeout: config.defaultTimeout ?? 300000, // 5 minutes
|
|
19
20
|
mode: config.mode ?? 'local',
|
|
20
21
|
enableScheduler: config.enableScheduler ?? true,
|
|
@@ -45,6 +46,9 @@ export function validateConfig(config) {
|
|
|
45
46
|
if (config.maxConcurrentWorkflows !== undefined && config.maxConcurrentWorkflows < 1) {
|
|
46
47
|
throw new Error('maxConcurrentWorkflows must be at least 1');
|
|
47
48
|
}
|
|
49
|
+
if (config.maxConcurrentSteps !== undefined && config.maxConcurrentSteps < 1) {
|
|
50
|
+
throw new Error('maxConcurrentSteps must be at least 1');
|
|
51
|
+
}
|
|
48
52
|
if (config.defaultTimeout !== undefined && config.defaultTimeout < 1) {
|
|
49
53
|
throw new Error('defaultTimeout must be positive');
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineConfig.js","sourceRoot":"","sources":["../../src/core/EngineConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"EngineConfig.js","sourceRoot":"","sources":["../../src/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
|
2
2
|
* Orbyt Engine - Main Public API
|
|
3
3
|
*
|
|
4
|
+
* ============================================================================
|
|
5
|
+
* ARCHITECTURE & TRUST BOUNDARIES
|
|
6
|
+
* ============================================================================
|
|
7
|
+
*
|
|
8
|
+
* This class defines the ONLY public API surface for the Orbyt Engine.
|
|
9
|
+
* It establishes clear trust boundaries between different consumers:
|
|
10
|
+
*
|
|
11
|
+
* TRUSTED FIRST-PARTY CONSUMERS (Direct Access):
|
|
12
|
+
* -----------------------------------------------
|
|
13
|
+
* - @orbytautomation/cli (Official CLI)
|
|
14
|
+
* - @orbytautomation/api (Official API Server)
|
|
15
|
+
*
|
|
16
|
+
* These components may import and use:
|
|
17
|
+
* - OrbytEngine class
|
|
18
|
+
* - Public types (WorkflowResult, WorkflowRunOptions)
|
|
19
|
+
* - Event bus for observability
|
|
20
|
+
*
|
|
21
|
+
* They MUST NOT:
|
|
22
|
+
* - Import internal execution modules
|
|
23
|
+
* - Bypass security validation
|
|
24
|
+
* - Directly manipulate internal state
|
|
25
|
+
*
|
|
26
|
+
* EXTERNAL ECOSYSTEM COMPONENTS (Adapter/SDK Access):
|
|
27
|
+
* ----------------------------------------------------
|
|
28
|
+
* - MediaProc, DevForge, Voxa, etc.
|
|
29
|
+
* - Third-party plugins
|
|
30
|
+
* - Marketplace extensions
|
|
31
|
+
*
|
|
32
|
+
* These components must integrate via:
|
|
33
|
+
* - Custom adapters (Adapter interface)
|
|
34
|
+
* - Workflow definitions (YAML)
|
|
35
|
+
* - SDK/client libraries
|
|
36
|
+
*
|
|
37
|
+
* They CANNOT:
|
|
38
|
+
* - Import engine internals
|
|
39
|
+
* - Access ExecutionEngine directly
|
|
40
|
+
* - Manipulate billing/security context
|
|
41
|
+
*
|
|
42
|
+
* SECURITY GUARANTEES:
|
|
43
|
+
* --------------------
|
|
44
|
+
* 1. Users cannot specify reserved internal fields in workflows
|
|
45
|
+
* (Validated at parse time - workflow is rejected if found)
|
|
46
|
+
*
|
|
47
|
+
* 2. Internal context is ALWAYS engine-generated
|
|
48
|
+
* (executionId, billing, ownership, audit fields)
|
|
49
|
+
*
|
|
50
|
+
* 3. CLI/API can pass ownership context but cannot forge billing
|
|
51
|
+
* (Ownership from trusted auth, billing from engine pricing snapshot)
|
|
52
|
+
*
|
|
53
|
+
* 4. All workflow execution goes through this single entry point
|
|
54
|
+
* (No backdoor execution paths)
|
|
55
|
+
*
|
|
56
|
+
* WHY THIS MATTERS:
|
|
57
|
+
* -----------------
|
|
58
|
+
* - Billing integrity: Users cannot manipulate usage tracking
|
|
59
|
+
* - Audit trail: All executions are properly logged
|
|
60
|
+
* - Refactor safety: Internal changes don't break integrations
|
|
61
|
+
* - Security: Clear separation of trusted vs untrusted code
|
|
62
|
+
*
|
|
4
63
|
* User-facing engine class that provides a clean, intuitive API for running workflows.
|
|
5
64
|
* Wraps the internal ExecutionEngine with a simpler interface.
|
|
6
65
|
*
|
|
@@ -13,64 +72,98 @@ import type { WorkflowResult } from '../execution/WorkflowExecutor.js';
|
|
|
13
72
|
import { EventBus } from '../events/EventBus.js';
|
|
14
73
|
import type { Adapter } from '@dev-ecosystem/core';
|
|
15
74
|
import type { LifecycleHook } from '../hooks/LifecycleHooks.js';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* User-friendly options for running a workflow
|
|
19
|
-
*/
|
|
20
|
-
export interface WorkflowRunOptions {
|
|
21
|
-
/**
|
|
22
|
-
* Workflow input variables
|
|
23
|
-
*/
|
|
24
|
-
variables?: Record<string, any>;
|
|
25
|
-
/**
|
|
26
|
-
* Environment variables for workflow execution
|
|
27
|
-
*/
|
|
28
|
-
env?: Record<string, any>;
|
|
29
|
-
/**
|
|
30
|
-
* Secrets (will not be logged)
|
|
31
|
-
*/
|
|
32
|
-
secrets?: Record<string, any>;
|
|
33
|
-
/**
|
|
34
|
-
* Additional execution context
|
|
35
|
-
*/
|
|
36
|
-
context?: Record<string, any>;
|
|
37
|
-
/**
|
|
38
|
-
* Execution timeout in milliseconds
|
|
39
|
-
*/
|
|
40
|
-
timeout?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Continue execution even if steps fail
|
|
43
|
-
*/
|
|
44
|
-
continueOnError?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Dry run mode - validate and plan but don't execute
|
|
47
|
-
*/
|
|
48
|
-
dryRun?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Who/what triggered this execution
|
|
51
|
-
*/
|
|
52
|
-
triggeredBy?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Workflow load options
|
|
56
|
-
* Options for loading a workflow from file
|
|
57
|
-
*/
|
|
58
|
-
export interface WorkflowLoadOptions {
|
|
59
|
-
/**
|
|
60
|
-
* Base directory for resolving relative paths
|
|
61
|
-
*/
|
|
62
|
-
baseDir?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Variables to inject during parsing
|
|
65
|
-
*/
|
|
66
|
-
variables?: Record<string, any>;
|
|
67
|
-
}
|
|
75
|
+
import { type OwnershipContext } from '../execution/InternalExecutionContext.js';
|
|
76
|
+
import { WorkflowRunOptions } from '../types/core-types.js';
|
|
68
77
|
/**
|
|
69
78
|
* OrbytEngine - Main public API
|
|
70
79
|
*
|
|
80
|
+
* ARCHITECTURE & TRUST BOUNDARIES
|
|
81
|
+
* =================
|
|
82
|
+
*
|
|
83
|
+
* This class defines the ONLY public API surface for the Orbyt Engine.
|
|
84
|
+
* It establishes clear trust boundaries between different consumers:
|
|
85
|
+
*
|
|
86
|
+
* TRUSTED FIRST-PARTY CONSUMERS (Direct Access):
|
|
87
|
+
* -----------------------------------------------
|
|
88
|
+
* - @orbyt/cli (Official CLI)
|
|
89
|
+
* - @orbyt/api (Official API Server)
|
|
90
|
+
*
|
|
91
|
+
* These components may import and use:
|
|
92
|
+
* - OrbytEngine class
|
|
93
|
+
* - Public types (WorkflowResult, WorkflowRunOptions)
|
|
94
|
+
* - Event bus for observability
|
|
95
|
+
*
|
|
96
|
+
* They MUST NOT:
|
|
97
|
+
* - Import internal execution modules
|
|
98
|
+
* - Bypass security validation
|
|
99
|
+
* - Directly manipulate internal state
|
|
100
|
+
*
|
|
101
|
+
* EXTERNAL ECOSYSTEM COMPONENTS (Adapter/SDK Access):
|
|
102
|
+
* ----------------------------------------------------
|
|
103
|
+
* - MediaProc, DevForge, Voxa, etc.
|
|
104
|
+
* - Third-party plugins
|
|
105
|
+
* - Marketplace extensions
|
|
106
|
+
*
|
|
107
|
+
* These components must integrate via:
|
|
108
|
+
* - Custom adapters (Adapter interface)
|
|
109
|
+
* - Workflow definitions (YAML)
|
|
110
|
+
* - SDK/client libraries
|
|
111
|
+
*
|
|
112
|
+
* They CANNOT:
|
|
113
|
+
* - Import engine internals
|
|
114
|
+
* - Access ExecutionEngine directly
|
|
115
|
+
* - Manipulate billing/security context
|
|
116
|
+
*
|
|
117
|
+
* SECURITY GUARANTEES:
|
|
118
|
+
* --------------------
|
|
119
|
+
* 1. Users cannot specify reserved internal fields in workflows
|
|
120
|
+
* (Validated at parse time - workflow is rejected if found)
|
|
121
|
+
*
|
|
122
|
+
* 2. Internal context is ALWAYS engine-generated
|
|
123
|
+
* (executionId, billing, ownership, audit fields)
|
|
124
|
+
*
|
|
125
|
+
* 3. CLI/API can pass ownership context but cannot forge billing
|
|
126
|
+
* (Ownership from trusted auth, billing from engine pricing snapshot)
|
|
127
|
+
*
|
|
128
|
+
* 4. All workflow execution goes through this single entry point
|
|
129
|
+
* (No backdoor execution paths)
|
|
130
|
+
*
|
|
131
|
+
* WHY THIS MATTERS:
|
|
132
|
+
* -----------------
|
|
133
|
+
* - Billing integrity: Users cannot manipulate usage tracking
|
|
134
|
+
* - Audit trail: All executions are properly logged
|
|
135
|
+
* - Refactor safety: Internal changes don't break integrations
|
|
136
|
+
* - Security: Clear separation of trusted vs untrusted code
|
|
137
|
+
*
|
|
138
|
+
* User-facing engine class that provides a clean, intuitive API for running workflows.
|
|
139
|
+
* Wraps the internal ExecutionEngine with a simpler interface.
|
|
140
|
+
*
|
|
71
141
|
* This is the primary interface for working with Orbyt workflows.
|
|
72
142
|
* Provides a clean, user-friendly API that abstracts internal complexity.
|
|
73
143
|
*
|
|
144
|
+
* SECURITY & ARCHITECTURE:
|
|
145
|
+
* =================
|
|
146
|
+
* This class is the SINGLE ENTRY POINT for all workflow execution.
|
|
147
|
+
* All execution paths (run, validate, dryRun) go through this engine.
|
|
148
|
+
*
|
|
149
|
+
* INTERNAL CONTEXT INJECTION:
|
|
150
|
+
* - Engine ALWAYS creates internal execution context
|
|
151
|
+
* - Users CANNOT override billing, identity, or ownership fields
|
|
152
|
+
* - Context sanitization removes any injection attempts
|
|
153
|
+
* - Billing tracking is engine-controlled, never user-controlled
|
|
154
|
+
*
|
|
155
|
+
* FIELDS THAT ARE NEVER USER-CONTROLLED:
|
|
156
|
+
* - executionId, runId, traceId (identity)
|
|
157
|
+
* - userId, workspaceId, subscriptionId (ownership)
|
|
158
|
+
* - billingId, pricingTier, costCalculated (billing)
|
|
159
|
+
* - usage counters, step counts, duration (metrics)
|
|
160
|
+
* - security policies, permissions (access control)
|
|
161
|
+
*
|
|
162
|
+
* WORKFLOW YAML vs ENGINE RUNTIME:
|
|
163
|
+
* - User controls: business logic, step definitions, parameters
|
|
164
|
+
* - Engine controls: billing, identity, execution tracking, security
|
|
165
|
+
* - Clear separation prevents billing manipulation and security bypass
|
|
166
|
+
*
|
|
74
167
|
* @example
|
|
75
168
|
* ```ts
|
|
76
169
|
* // Basic usage
|
|
@@ -91,6 +184,17 @@ export interface WorkflowLoadOptions {
|
|
|
91
184
|
* timeout: 60000,
|
|
92
185
|
* dryRun: false
|
|
93
186
|
* });
|
|
187
|
+
*
|
|
188
|
+
* // From bridge/API with ownership context
|
|
189
|
+
* const result = await engine.run('./workflow.yaml', {
|
|
190
|
+
* variables: { input: 'data' },
|
|
191
|
+
* _ownershipContext: {
|
|
192
|
+
* userId: 'user_123',
|
|
193
|
+
* workspaceId: 'ws_456',
|
|
194
|
+
* subscriptionTier: 'pro',
|
|
195
|
+
* billingMode: 'ecosystem',
|
|
196
|
+
* }
|
|
197
|
+
* });
|
|
94
198
|
* ```
|
|
95
199
|
*/
|
|
96
200
|
export declare class OrbytEngine {
|
|
@@ -103,6 +207,7 @@ export declare class OrbytEngine {
|
|
|
103
207
|
private adapterRegistry;
|
|
104
208
|
private context;
|
|
105
209
|
private isStarted;
|
|
210
|
+
private readonly version;
|
|
106
211
|
constructor(config?: OrbytEngineConfig);
|
|
107
212
|
/**
|
|
108
213
|
* Wire engine components together
|
|
@@ -126,48 +231,70 @@ export declare class OrbytEngine {
|
|
|
126
231
|
/**
|
|
127
232
|
* Run a workflow
|
|
128
233
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
234
|
+
* ARCHITECTURE NOTE:
|
|
235
|
+
* ==================
|
|
236
|
+
* This method is I/O-AGNOSTIC - it does NOT read files or touch filesystem.
|
|
237
|
+
* File loading is handled byWorkflowLoader (separate utility layer).
|
|
131
238
|
*
|
|
132
|
-
*
|
|
239
|
+
* This keeps the engine:
|
|
240
|
+
* - Testable (no file dependencies)
|
|
241
|
+
* - Embeddable (works in browsers, workers, distributed systems)
|
|
242
|
+
* - API-safe (can accept workflows from any source)
|
|
243
|
+
*
|
|
244
|
+
* Main method for executing workflows.
|
|
245
|
+
*
|
|
246
|
+
* @param workflow - Parsed workflow object OR YAML string content
|
|
133
247
|
* @param options - Execution options
|
|
134
248
|
* @returns Workflow execution result
|
|
135
249
|
*
|
|
136
250
|
* @example
|
|
137
251
|
* ```ts
|
|
138
|
-
*
|
|
139
|
-
* const result = await engine.run('./workflow.yaml');
|
|
252
|
+
* import { WorkflowLoader } from '@orbytautomation/engine';
|
|
140
253
|
*
|
|
141
|
-
* //
|
|
142
|
-
* const
|
|
143
|
-
*
|
|
144
|
-
* timeout: 30000
|
|
145
|
-
* });
|
|
254
|
+
* // Load from file (use WorkflowLoader)
|
|
255
|
+
* const workflow = await WorkflowLoader.fromFile('./workflow.yaml');
|
|
256
|
+
* const result = await engine.run(workflow);
|
|
146
257
|
*
|
|
147
|
-
* // Run from string
|
|
258
|
+
* // Run from YAML string
|
|
148
259
|
* const yaml = `
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
260
|
+
* version: "1.0"
|
|
261
|
+
* kind: workflow
|
|
262
|
+
* workflow:
|
|
263
|
+
* steps:
|
|
264
|
+
* - id: step1
|
|
265
|
+
* uses: shell.exec
|
|
266
|
+
* with:
|
|
267
|
+
* command: echo "Hello"
|
|
155
268
|
* `;
|
|
156
269
|
* const result = await engine.run(yaml);
|
|
270
|
+
*
|
|
271
|
+
* // Run from object (testing)
|
|
272
|
+
* const result = await engine.run(mockWorkflowObject);
|
|
157
273
|
* ```
|
|
158
274
|
*/
|
|
159
275
|
run(workflow: string | ParsedWorkflow, options?: WorkflowRunOptions): Promise<WorkflowResult>;
|
|
160
276
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
277
|
+
* Sanitize user-provided options to prevent injection attacks
|
|
278
|
+
* SECURITY: Users should never be able to override internal fields
|
|
279
|
+
*/
|
|
280
|
+
private sanitizeUserOptions;
|
|
281
|
+
/**
|
|
282
|
+
* Billing lifecycle hook - called after workflow completes
|
|
283
|
+
* INTERNAL: Used to track usage and send billing data to analytics bridge
|
|
166
284
|
*/
|
|
167
|
-
|
|
285
|
+
private onWorkflowBillingComplete;
|
|
168
286
|
/**
|
|
169
287
|
* Parse a workflow from YAML string
|
|
170
288
|
*
|
|
289
|
+
* WORKFLOW PARSING PIPELINE:
|
|
290
|
+
* ==========================
|
|
291
|
+
* 1. Validate YAML syntax (catch malformed YAML early)
|
|
292
|
+
* 2. Parse YAML to object
|
|
293
|
+
* 3. Security validation (reject reserved internal fields)
|
|
294
|
+
* 4. Schema validation (validate against Zod schema)
|
|
295
|
+
* 5. Step parsing and validation
|
|
296
|
+
* 6. Return parsed workflow ready for execution
|
|
297
|
+
*
|
|
171
298
|
* @param yaml - YAML workflow definition
|
|
172
299
|
* @returns Parsed workflow
|
|
173
300
|
*/
|
|
@@ -176,12 +303,16 @@ export declare class OrbytEngine {
|
|
|
176
303
|
* Validate a workflow without executing it
|
|
177
304
|
*
|
|
178
305
|
* @param workflow - Workflow to validate
|
|
306
|
+
* @param options - Validation options (optional ownership context for tracking)
|
|
179
307
|
* @returns True if valid, throws if invalid
|
|
180
308
|
*/
|
|
181
|
-
validate(workflow: string | ParsedWorkflow
|
|
309
|
+
validate(workflow: string | ParsedWorkflow, options?: {
|
|
310
|
+
_ownershipContext?: Partial<OwnershipContext>;
|
|
311
|
+
}): Promise<boolean>;
|
|
182
312
|
/**
|
|
183
313
|
* Perform a dry run of a workflow
|
|
184
314
|
* Validates and plans execution without running steps
|
|
315
|
+
* INTERNAL: Creates internal context for tracking (non-billable)
|
|
185
316
|
*/
|
|
186
317
|
private dryRun;
|
|
187
318
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrbytEngine.d.ts","sourceRoot":"","sources":["../../src/core/OrbytEngine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OrbytEngine.d.ts","sourceRoot":"","sources":["../../src/core/OrbytEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAY,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAq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