@exaudeus/workrail 1.11.0 → 1.12.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.
|
@@ -14,10 +14,8 @@ export interface CompiledWorkflow {
|
|
|
14
14
|
readonly compiledLoops: ReadonlyMap<string, CompiledLoop>;
|
|
15
15
|
readonly loopBodyStepIds: ReadonlySet<string>;
|
|
16
16
|
}
|
|
17
|
+
export declare function resolveDefinitionSteps(steps: readonly (WorkflowStepDefinition | LoopStepDefinition)[], features: readonly string[]): Result<readonly (WorkflowStepDefinition | LoopStepDefinition)[], DomainError>;
|
|
17
18
|
export declare class WorkflowCompiler {
|
|
18
|
-
private readonly refRegistry;
|
|
19
|
-
private readonly featureRegistry;
|
|
20
|
-
private readonly templateRegistry;
|
|
21
19
|
compile(workflow: Workflow): Result<CompiledWorkflow, DomainError>;
|
|
22
20
|
private deriveConditionSource;
|
|
23
21
|
private resolveLoopBody;
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.WorkflowCompiler = void 0;
|
|
10
|
+
exports.resolveDefinitionSteps = resolveDefinitionSteps;
|
|
10
11
|
const tsyringe_1 = require("tsyringe");
|
|
11
12
|
const workflow_1 = require("../../types/workflow");
|
|
12
13
|
const index_1 = require("../../v2/durable-core/schemas/artifacts/index");
|
|
@@ -19,43 +20,47 @@ const resolve_features_1 = require("./compiler/resolve-features");
|
|
|
19
20
|
const feature_registry_1 = require("./compiler/feature-registry");
|
|
20
21
|
const resolve_templates_1 = require("./compiler/resolve-templates");
|
|
21
22
|
const template_registry_1 = require("./compiler/template-registry");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const _refRegistry = (0, ref_registry_1.createRefRegistry)();
|
|
24
|
+
const _featureRegistry = (0, feature_registry_1.createFeatureRegistry)();
|
|
25
|
+
const _templateRegistry = (0, template_registry_1.createTemplateRegistry)();
|
|
26
|
+
function resolveDefinitionSteps(steps, features) {
|
|
27
|
+
const templatesResult = (0, resolve_templates_1.resolveTemplatesPass)(steps, _templateRegistry);
|
|
28
|
+
if (templatesResult.isErr()) {
|
|
29
|
+
const e = templatesResult.error;
|
|
30
|
+
const message = e.code === 'TEMPLATE_RESOLVE_ERROR'
|
|
31
|
+
? `Step '${e.stepId}': template error — ${e.cause.message}`
|
|
32
|
+
: `Step '${e.stepId}': template expansion error — ${e.cause.message}`;
|
|
33
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
34
|
+
}
|
|
35
|
+
const featuresResult = (0, resolve_features_1.resolveFeaturesPass)(templatesResult.value, features, _featureRegistry);
|
|
36
|
+
if (featuresResult.isErr()) {
|
|
37
|
+
const e = featuresResult.error;
|
|
38
|
+
const message = e.code === 'FEATURE_RESOLVE_ERROR'
|
|
39
|
+
? `Feature error — ${e.cause.message}`
|
|
40
|
+
: e.message;
|
|
41
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
42
|
+
}
|
|
43
|
+
const refsResult = (0, resolve_refs_1.resolveRefsPass)(featuresResult.value, _refRegistry);
|
|
44
|
+
if (refsResult.isErr()) {
|
|
45
|
+
const e = refsResult.error;
|
|
46
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(`Step '${e.stepId}': ref resolution error — ${e.cause.message}`));
|
|
27
47
|
}
|
|
48
|
+
const blocksResult = (0, prompt_blocks_1.resolvePromptBlocksPass)(refsResult.value);
|
|
49
|
+
if (blocksResult.isErr()) {
|
|
50
|
+
const e = blocksResult.error;
|
|
51
|
+
const message = e.code === 'PROMPT_AND_BLOCKS_BOTH_SET'
|
|
52
|
+
? e.message
|
|
53
|
+
: `Step '${e.stepId}': promptBlocks error — ${e.cause.message}`;
|
|
54
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
55
|
+
}
|
|
56
|
+
return (0, neverthrow_1.ok)(blocksResult.value);
|
|
57
|
+
}
|
|
58
|
+
let WorkflowCompiler = class WorkflowCompiler {
|
|
28
59
|
compile(workflow) {
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
? `Step '${e.stepId}': template error — ${e.cause.message}`
|
|
34
|
-
: `Step '${e.stepId}': template expansion error — ${e.cause.message}`;
|
|
35
|
-
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
36
|
-
}
|
|
37
|
-
const featuresResult = (0, resolve_features_1.resolveFeaturesPass)(templatesResult.value, workflow.definition.features ?? [], this.featureRegistry);
|
|
38
|
-
if (featuresResult.isErr()) {
|
|
39
|
-
const e = featuresResult.error;
|
|
40
|
-
const message = e.code === 'FEATURE_RESOLVE_ERROR'
|
|
41
|
-
? `Feature error — ${e.cause.message}`
|
|
42
|
-
: e.message;
|
|
43
|
-
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
44
|
-
}
|
|
45
|
-
const refsResult = (0, resolve_refs_1.resolveRefsPass)(featuresResult.value, this.refRegistry);
|
|
46
|
-
if (refsResult.isErr()) {
|
|
47
|
-
const e = refsResult.error;
|
|
48
|
-
return (0, neverthrow_1.err)(error_1.Err.invalidState(`Step '${e.stepId}': ref resolution error — ${e.cause.message}`));
|
|
49
|
-
}
|
|
50
|
-
const blocksResult = (0, prompt_blocks_1.resolvePromptBlocksPass)(refsResult.value);
|
|
51
|
-
if (blocksResult.isErr()) {
|
|
52
|
-
const e = blocksResult.error;
|
|
53
|
-
const message = e.code === 'PROMPT_AND_BLOCKS_BOTH_SET'
|
|
54
|
-
? e.message
|
|
55
|
-
: `Step '${e.stepId}': promptBlocks error — ${e.cause.message}`;
|
|
56
|
-
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
57
|
-
}
|
|
58
|
-
const steps = blocksResult.value;
|
|
60
|
+
const resolvedResult = resolveDefinitionSteps(workflow.definition.steps, workflow.definition.features ?? []);
|
|
61
|
+
if (resolvedResult.isErr())
|
|
62
|
+
return (0, neverthrow_1.err)(resolvedResult.error);
|
|
63
|
+
const steps = resolvedResult.value;
|
|
59
64
|
const stepById = new Map();
|
|
60
65
|
for (const step of steps) {
|
|
61
66
|
if (stepById.has(step.id)) {
|
package/dist/manifest.json
CHANGED
|
@@ -98,12 +98,12 @@
|
|
|
98
98
|
"bytes": 31038
|
|
99
99
|
},
|
|
100
100
|
"application/services/workflow-compiler.d.ts": {
|
|
101
|
-
"sha256": "
|
|
102
|
-
"bytes":
|
|
101
|
+
"sha256": "41d0643ae2f07e5ce77a6e02344b5ca5b3c26bde828fbb307528a2ae097ac9d5",
|
|
102
|
+
"bytes": 1211
|
|
103
103
|
},
|
|
104
104
|
"application/services/workflow-compiler.js": {
|
|
105
|
-
"sha256": "
|
|
106
|
-
"bytes":
|
|
105
|
+
"sha256": "db74bfe006cf703cc0c32165e09e2c684e24fcf7b538ecbc1273daf67012dc2d",
|
|
106
|
+
"bytes": 8182
|
|
107
107
|
},
|
|
108
108
|
"application/services/workflow-interpreter.d.ts": {
|
|
109
109
|
"sha256": "56b5b5ad06d42096deba9f0abe7642c18a355a1e598749aab1730df4e9847674",
|
|
@@ -2174,8 +2174,8 @@
|
|
|
2174
2174
|
"bytes": 463
|
|
2175
2175
|
},
|
|
2176
2176
|
"v2/read-only/v1-to-v2-shim.js": {
|
|
2177
|
-
"sha256": "
|
|
2178
|
-
"bytes":
|
|
2177
|
+
"sha256": "36a9c3f0faf71c49fc9624f41c26c452e276f4ac15190f2d22d89a003a2bb099",
|
|
2178
|
+
"bytes": 2678
|
|
2179
2179
|
},
|
|
2180
2180
|
"v2/usecases/enumerate-sessions.d.ts": {
|
|
2181
2181
|
"sha256": "6043d64b45360dfc6a15b822d9f013a0832127596706bf81569dfce256236d2d",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileV1WorkflowToV2PreviewSnapshot = compileV1WorkflowToV2PreviewSnapshot;
|
|
4
4
|
exports.compileV1WorkflowToPinnedSnapshot = compileV1WorkflowToPinnedSnapshot;
|
|
5
|
+
const workflow_compiler_js_1 = require("../../application/services/workflow-compiler.js");
|
|
5
6
|
function compileV1WorkflowToV2PreviewSnapshot(workflow) {
|
|
6
7
|
const firstStep = workflow.definition.steps[0];
|
|
7
8
|
if (!firstStep) {
|
|
@@ -20,9 +21,19 @@ function compileV1WorkflowToV2PreviewSnapshot(workflow) {
|
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
const isLoop = firstStep.type === 'loop';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let prompt;
|
|
25
|
+
if (isLoop) {
|
|
26
|
+
prompt = `Loop step '${firstStep.id}' cannot be previewed in v2 Slice 1 (loop execution/compilation not implemented yet).`;
|
|
27
|
+
}
|
|
28
|
+
else if (typeof firstStep.prompt === 'string') {
|
|
29
|
+
prompt = firstStep.prompt;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const resolved = (0, workflow_compiler_js_1.resolveDefinitionSteps)([firstStep], workflow.definition.features ?? []);
|
|
33
|
+
prompt = resolved.isOk() && resolved.value[0]?.prompt
|
|
34
|
+
? resolved.value[0].prompt
|
|
35
|
+
: `Step '${firstStep.id}' has no prompt (promptBlocks resolution failed).`;
|
|
36
|
+
}
|
|
26
37
|
return {
|
|
27
38
|
schemaVersion: 1,
|
|
28
39
|
sourceKind: 'v1_preview',
|
|
@@ -38,6 +49,10 @@ function compileV1WorkflowToV2PreviewSnapshot(workflow) {
|
|
|
38
49
|
};
|
|
39
50
|
}
|
|
40
51
|
function compileV1WorkflowToPinnedSnapshot(workflow) {
|
|
52
|
+
const resolved = (0, workflow_compiler_js_1.resolveDefinitionSteps)(workflow.definition.steps, workflow.definition.features ?? []);
|
|
53
|
+
const resolvedDefinition = resolved.isOk()
|
|
54
|
+
? { ...workflow.definition, steps: resolved.value }
|
|
55
|
+
: workflow.definition;
|
|
41
56
|
return {
|
|
42
57
|
schemaVersion: 1,
|
|
43
58
|
sourceKind: 'v1_pinned',
|
|
@@ -45,6 +60,6 @@ function compileV1WorkflowToPinnedSnapshot(workflow) {
|
|
|
45
60
|
name: workflow.definition.name,
|
|
46
61
|
description: workflow.definition.description,
|
|
47
62
|
version: workflow.definition.version,
|
|
48
|
-
definition:
|
|
63
|
+
definition: resolvedDefinition,
|
|
49
64
|
};
|
|
50
65
|
}
|