@exaudeus/workrail 1.7.5 → 1.9.0
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/application/services/compiler/prompt-blocks.d.ts +36 -0
- package/dist/application/services/compiler/prompt-blocks.js +133 -0
- package/dist/application/services/compiler/ref-registry.d.ts +12 -0
- package/dist/application/services/compiler/ref-registry.js +47 -0
- package/dist/application/services/compiler/resolve-refs.d.ts +9 -0
- package/dist/application/services/compiler/resolve-refs.js +113 -0
- package/dist/application/services/workflow-compiler.d.ts +1 -0
- package/dist/application/services/workflow-compiler.js +20 -1
- package/dist/application/services/workflow-interpreter.js +1 -1
- package/dist/manifest.json +34 -10
- package/dist/mcp/output-schemas.d.ts +40 -40
- package/dist/types/workflow-definition.d.ts +3 -1
- package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +16 -16
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
export type PromptPart = {
|
|
3
|
+
readonly kind: 'text';
|
|
4
|
+
readonly text: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'ref';
|
|
7
|
+
readonly refId: string;
|
|
8
|
+
};
|
|
9
|
+
export type PromptValue = string | readonly PromptPart[];
|
|
10
|
+
export interface PromptBlocks {
|
|
11
|
+
readonly goal?: PromptValue;
|
|
12
|
+
readonly constraints?: readonly PromptValue[];
|
|
13
|
+
readonly procedure?: readonly PromptValue[];
|
|
14
|
+
readonly outputRequired?: Readonly<Record<string, string>>;
|
|
15
|
+
readonly verify?: readonly PromptValue[];
|
|
16
|
+
}
|
|
17
|
+
export type PromptBlocksRenderError = {
|
|
18
|
+
readonly code: 'EMPTY_BLOCKS';
|
|
19
|
+
readonly message: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly code: 'UNRESOLVED_REF';
|
|
22
|
+
readonly refId: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function renderPromptBlocks(blocks: PromptBlocks): Result<string, PromptBlocksRenderError>;
|
|
26
|
+
import type { WorkflowStepDefinition, LoopStepDefinition } from '../../../types/workflow-definition.js';
|
|
27
|
+
export type PromptBlocksPassError = {
|
|
28
|
+
readonly code: 'PROMPT_BLOCKS_ERROR';
|
|
29
|
+
readonly stepId: string;
|
|
30
|
+
readonly cause: PromptBlocksRenderError;
|
|
31
|
+
} | {
|
|
32
|
+
readonly code: 'PROMPT_AND_BLOCKS_BOTH_SET';
|
|
33
|
+
readonly stepId: string;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function resolvePromptBlocksPass(steps: readonly (WorkflowStepDefinition | LoopStepDefinition)[]): Result<readonly (WorkflowStepDefinition | LoopStepDefinition)[], PromptBlocksPassError>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderPromptBlocks = renderPromptBlocks;
|
|
4
|
+
exports.resolvePromptBlocksPass = resolvePromptBlocksPass;
|
|
5
|
+
const neverthrow_1 = require("neverthrow");
|
|
6
|
+
function resolvePromptValue(value) {
|
|
7
|
+
if (typeof value === 'string')
|
|
8
|
+
return (0, neverthrow_1.ok)(value);
|
|
9
|
+
const parts = [];
|
|
10
|
+
for (const part of value) {
|
|
11
|
+
switch (part.kind) {
|
|
12
|
+
case 'text':
|
|
13
|
+
parts.push(part.text);
|
|
14
|
+
break;
|
|
15
|
+
case 'ref':
|
|
16
|
+
return (0, neverthrow_1.err)({
|
|
17
|
+
code: 'UNRESOLVED_REF',
|
|
18
|
+
refId: part.refId,
|
|
19
|
+
message: `Unresolved ref '${part.refId}' in prompt blocks. Refs must be resolved before rendering.`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return (0, neverthrow_1.ok)(parts.join(''));
|
|
24
|
+
}
|
|
25
|
+
function resolvePromptValues(values) {
|
|
26
|
+
const resolved = [];
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
const res = resolvePromptValue(value);
|
|
29
|
+
if (res.isErr())
|
|
30
|
+
return (0, neverthrow_1.err)(res.error);
|
|
31
|
+
resolved.push(res.value);
|
|
32
|
+
}
|
|
33
|
+
return (0, neverthrow_1.ok)(resolved);
|
|
34
|
+
}
|
|
35
|
+
function renderPromptBlocks(blocks) {
|
|
36
|
+
const sections = [];
|
|
37
|
+
if (blocks.goal !== undefined) {
|
|
38
|
+
const res = resolvePromptValue(blocks.goal);
|
|
39
|
+
if (res.isErr())
|
|
40
|
+
return (0, neverthrow_1.err)(res.error);
|
|
41
|
+
sections.push(`## Goal\n${res.value}`);
|
|
42
|
+
}
|
|
43
|
+
if (blocks.constraints !== undefined && blocks.constraints.length > 0) {
|
|
44
|
+
const res = resolvePromptValues(blocks.constraints);
|
|
45
|
+
if (res.isErr())
|
|
46
|
+
return (0, neverthrow_1.err)(res.error);
|
|
47
|
+
sections.push(`## Constraints\n${res.value.map(c => `- ${c}`).join('\n')}`);
|
|
48
|
+
}
|
|
49
|
+
if (blocks.procedure !== undefined && blocks.procedure.length > 0) {
|
|
50
|
+
const res = resolvePromptValues(blocks.procedure);
|
|
51
|
+
if (res.isErr())
|
|
52
|
+
return (0, neverthrow_1.err)(res.error);
|
|
53
|
+
sections.push(`## Procedure\n${res.value.map((p, i) => `${i + 1}. ${p}`).join('\n')}`);
|
|
54
|
+
}
|
|
55
|
+
if (blocks.outputRequired !== undefined && Object.keys(blocks.outputRequired).length > 0) {
|
|
56
|
+
const entries = Object.entries(blocks.outputRequired)
|
|
57
|
+
.map(([key, value]) => `- **${key}**: ${value}`)
|
|
58
|
+
.join('\n');
|
|
59
|
+
sections.push(`## Output Required\n${entries}`);
|
|
60
|
+
}
|
|
61
|
+
if (blocks.verify !== undefined && blocks.verify.length > 0) {
|
|
62
|
+
const res = resolvePromptValues(blocks.verify);
|
|
63
|
+
if (res.isErr())
|
|
64
|
+
return (0, neverthrow_1.err)(res.error);
|
|
65
|
+
sections.push(`## Verify\n${res.value.map(v => `- ${v}`).join('\n')}`);
|
|
66
|
+
}
|
|
67
|
+
if (sections.length === 0) {
|
|
68
|
+
return (0, neverthrow_1.err)({
|
|
69
|
+
code: 'EMPTY_BLOCKS',
|
|
70
|
+
message: 'promptBlocks must contain at least one non-empty section.',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return (0, neverthrow_1.ok)(sections.join('\n\n'));
|
|
74
|
+
}
|
|
75
|
+
const workflow_definition_js_1 = require("../../../types/workflow-definition.js");
|
|
76
|
+
function resolveStepPromptBlocks(step) {
|
|
77
|
+
if (step.prompt && step.promptBlocks) {
|
|
78
|
+
return (0, neverthrow_1.err)({
|
|
79
|
+
code: 'PROMPT_AND_BLOCKS_BOTH_SET',
|
|
80
|
+
stepId: step.id,
|
|
81
|
+
message: `Step '${step.id}' declares both prompt and promptBlocks. Use exactly one.`,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (!step.promptBlocks)
|
|
85
|
+
return (0, neverthrow_1.ok)(step);
|
|
86
|
+
const renderResult = renderPromptBlocks(step.promptBlocks);
|
|
87
|
+
if (renderResult.isErr()) {
|
|
88
|
+
return (0, neverthrow_1.err)({
|
|
89
|
+
code: 'PROMPT_BLOCKS_ERROR',
|
|
90
|
+
stepId: step.id,
|
|
91
|
+
cause: renderResult.error,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return (0, neverthrow_1.ok)({
|
|
95
|
+
...step,
|
|
96
|
+
prompt: renderResult.value,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function resolvePromptBlocksPass(steps) {
|
|
100
|
+
const resolved = [];
|
|
101
|
+
for (const step of steps) {
|
|
102
|
+
if ((0, workflow_definition_js_1.isLoopStepDefinition)(step)) {
|
|
103
|
+
const loopRes = resolveStepPromptBlocks(step);
|
|
104
|
+
if (loopRes.isErr())
|
|
105
|
+
return (0, neverthrow_1.err)(loopRes.error);
|
|
106
|
+
if (Array.isArray(step.body)) {
|
|
107
|
+
const bodyResolved = [];
|
|
108
|
+
for (const bodyStep of step.body) {
|
|
109
|
+
const bodyRes = resolveStepPromptBlocks(bodyStep);
|
|
110
|
+
if (bodyRes.isErr())
|
|
111
|
+
return (0, neverthrow_1.err)(bodyRes.error);
|
|
112
|
+
bodyResolved.push(bodyRes.value);
|
|
113
|
+
}
|
|
114
|
+
const resolvedLoop = {
|
|
115
|
+
...step,
|
|
116
|
+
...(loopRes.value.prompt !== undefined ? { prompt: loopRes.value.prompt } : {}),
|
|
117
|
+
body: bodyResolved,
|
|
118
|
+
};
|
|
119
|
+
resolved.push(resolvedLoop);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
resolved.push({ ...step, ...(loopRes.value.prompt !== undefined ? { prompt: loopRes.value.prompt } : {}) });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const res = resolveStepPromptBlocks(step);
|
|
127
|
+
if (res.isErr())
|
|
128
|
+
return (0, neverthrow_1.err)(res.error);
|
|
129
|
+
resolved.push(res.value);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return (0, neverthrow_1.ok)(resolved);
|
|
133
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
export type RefResolveError = {
|
|
3
|
+
readonly code: 'UNKNOWN_REF';
|
|
4
|
+
readonly refId: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
};
|
|
7
|
+
export interface RefRegistry {
|
|
8
|
+
readonly resolve: (refId: string) => Result<string, RefResolveError>;
|
|
9
|
+
readonly has: (refId: string) => boolean;
|
|
10
|
+
readonly knownIds: () => readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createRefRegistry(): RefRegistry;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRefRegistry = createRefRegistry;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const REF_CONTENT = {
|
|
6
|
+
'wr.refs.memory_usage': [
|
|
7
|
+
'If Memory MCP tools are available (memory_briefing, memory_store, memory_query):',
|
|
8
|
+
'- Query Memory for relevant prior knowledge about this workspace before beginning work',
|
|
9
|
+
'- After completing significant work, store key discoveries and decisions',
|
|
10
|
+
'- Use descriptive topics and titles so future sessions can find them',
|
|
11
|
+
'- Do not block on Memory failures — it is advisory, not load-bearing',
|
|
12
|
+
].join('\n'),
|
|
13
|
+
'wr.refs.memory_store': [
|
|
14
|
+
'If Memory MCP tools are available (memory_store):',
|
|
15
|
+
'- Store the key findings from this phase with a descriptive topic and title',
|
|
16
|
+
'- Include file paths, decisions made, and rationale',
|
|
17
|
+
'- Do not block on Memory failures — continue regardless',
|
|
18
|
+
].join('\n'),
|
|
19
|
+
'wr.refs.memory_query': [
|
|
20
|
+
'If Memory MCP tools are available (memory_briefing, memory_query):',
|
|
21
|
+
'- Check Memory for prior context relevant to this task',
|
|
22
|
+
'- Use workspace-scoped queries to find related past work',
|
|
23
|
+
'- Do not block on Memory failures — proceed without prior context if unavailable',
|
|
24
|
+
].join('\n'),
|
|
25
|
+
};
|
|
26
|
+
function createRefRegistry() {
|
|
27
|
+
const knownIds = Object.keys(REF_CONTENT);
|
|
28
|
+
return {
|
|
29
|
+
resolve(refId) {
|
|
30
|
+
const content = REF_CONTENT[refId];
|
|
31
|
+
if (content === undefined) {
|
|
32
|
+
return (0, neverthrow_1.err)({
|
|
33
|
+
code: 'UNKNOWN_REF',
|
|
34
|
+
refId,
|
|
35
|
+
message: `Unknown ref '${refId}'. Known refs: ${knownIds.join(', ')}`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return (0, neverthrow_1.ok)(content);
|
|
39
|
+
},
|
|
40
|
+
has(refId) {
|
|
41
|
+
return refId in REF_CONTENT;
|
|
42
|
+
},
|
|
43
|
+
knownIds() {
|
|
44
|
+
return knownIds;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { RefRegistry, RefResolveError } from './ref-registry.js';
|
|
3
|
+
import type { WorkflowStepDefinition, LoopStepDefinition } from '../../../types/workflow-definition.js';
|
|
4
|
+
export type ResolveRefsPassError = {
|
|
5
|
+
readonly code: 'REF_RESOLVE_ERROR';
|
|
6
|
+
readonly stepId: string;
|
|
7
|
+
readonly cause: RefResolveError;
|
|
8
|
+
};
|
|
9
|
+
export declare function resolveRefsPass(steps: readonly (WorkflowStepDefinition | LoopStepDefinition)[], registry: RefRegistry): Result<readonly (WorkflowStepDefinition | LoopStepDefinition)[], ResolveRefsPassError>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRefsPass = resolveRefsPass;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const workflow_definition_js_1 = require("../../../types/workflow-definition.js");
|
|
6
|
+
function resolvePromptValueRefs(value, registry) {
|
|
7
|
+
if (typeof value === 'string')
|
|
8
|
+
return (0, neverthrow_1.ok)(value);
|
|
9
|
+
const resolved = [];
|
|
10
|
+
for (const part of value) {
|
|
11
|
+
switch (part.kind) {
|
|
12
|
+
case 'text':
|
|
13
|
+
resolved.push(part);
|
|
14
|
+
break;
|
|
15
|
+
case 'ref': {
|
|
16
|
+
const res = registry.resolve(part.refId);
|
|
17
|
+
if (res.isErr())
|
|
18
|
+
return (0, neverthrow_1.err)(res.error);
|
|
19
|
+
resolved.push({ kind: 'text', text: res.value });
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return (0, neverthrow_1.ok)(resolved);
|
|
25
|
+
}
|
|
26
|
+
function resolvePromptValuesRefs(values, registry) {
|
|
27
|
+
const resolved = [];
|
|
28
|
+
for (const value of values) {
|
|
29
|
+
const res = resolvePromptValueRefs(value, registry);
|
|
30
|
+
if (res.isErr())
|
|
31
|
+
return (0, neverthrow_1.err)(res.error);
|
|
32
|
+
resolved.push(res.value);
|
|
33
|
+
}
|
|
34
|
+
return (0, neverthrow_1.ok)(resolved);
|
|
35
|
+
}
|
|
36
|
+
function resolveBlockRefs(blocks, registry) {
|
|
37
|
+
let result = { ...blocks };
|
|
38
|
+
if (blocks.goal !== undefined) {
|
|
39
|
+
const res = resolvePromptValueRefs(blocks.goal, registry);
|
|
40
|
+
if (res.isErr())
|
|
41
|
+
return (0, neverthrow_1.err)(res.error);
|
|
42
|
+
result = { ...result, goal: res.value };
|
|
43
|
+
}
|
|
44
|
+
if (blocks.constraints !== undefined) {
|
|
45
|
+
const res = resolvePromptValuesRefs(blocks.constraints, registry);
|
|
46
|
+
if (res.isErr())
|
|
47
|
+
return (0, neverthrow_1.err)(res.error);
|
|
48
|
+
result = { ...result, constraints: res.value };
|
|
49
|
+
}
|
|
50
|
+
if (blocks.procedure !== undefined) {
|
|
51
|
+
const res = resolvePromptValuesRefs(blocks.procedure, registry);
|
|
52
|
+
if (res.isErr())
|
|
53
|
+
return (0, neverthrow_1.err)(res.error);
|
|
54
|
+
result = { ...result, procedure: res.value };
|
|
55
|
+
}
|
|
56
|
+
if (blocks.verify !== undefined) {
|
|
57
|
+
const res = resolvePromptValuesRefs(blocks.verify, registry);
|
|
58
|
+
if (res.isErr())
|
|
59
|
+
return (0, neverthrow_1.err)(res.error);
|
|
60
|
+
result = { ...result, verify: res.value };
|
|
61
|
+
}
|
|
62
|
+
return (0, neverthrow_1.ok)(result);
|
|
63
|
+
}
|
|
64
|
+
function resolveStepRefs(step, registry) {
|
|
65
|
+
if (!step.promptBlocks)
|
|
66
|
+
return (0, neverthrow_1.ok)(step);
|
|
67
|
+
const res = resolveBlockRefs(step.promptBlocks, registry);
|
|
68
|
+
if (res.isErr()) {
|
|
69
|
+
return (0, neverthrow_1.err)({
|
|
70
|
+
code: 'REF_RESOLVE_ERROR',
|
|
71
|
+
stepId: step.id,
|
|
72
|
+
cause: res.error,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return (0, neverthrow_1.ok)({ ...step, promptBlocks: res.value });
|
|
76
|
+
}
|
|
77
|
+
function resolveRefsPass(steps, registry) {
|
|
78
|
+
const resolved = [];
|
|
79
|
+
for (const step of steps) {
|
|
80
|
+
if ((0, workflow_definition_js_1.isLoopStepDefinition)(step)) {
|
|
81
|
+
const loopRes = resolveStepRefs(step, registry);
|
|
82
|
+
if (loopRes.isErr())
|
|
83
|
+
return (0, neverthrow_1.err)(loopRes.error);
|
|
84
|
+
if (Array.isArray(step.body)) {
|
|
85
|
+
const bodyResolved = [];
|
|
86
|
+
for (const bodyStep of step.body) {
|
|
87
|
+
const bodyRes = resolveStepRefs(bodyStep, registry);
|
|
88
|
+
if (bodyRes.isErr())
|
|
89
|
+
return (0, neverthrow_1.err)(bodyRes.error);
|
|
90
|
+
bodyResolved.push(bodyRes.value);
|
|
91
|
+
}
|
|
92
|
+
resolved.push({
|
|
93
|
+
...step,
|
|
94
|
+
...(loopRes.value.promptBlocks ? { promptBlocks: loopRes.value.promptBlocks } : {}),
|
|
95
|
+
body: bodyResolved,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
resolved.push({
|
|
100
|
+
...step,
|
|
101
|
+
...(loopRes.value.promptBlocks ? { promptBlocks: loopRes.value.promptBlocks } : {}),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const res = resolveStepRefs(step, registry);
|
|
107
|
+
if (res.isErr())
|
|
108
|
+
return (0, neverthrow_1.err)(res.error);
|
|
109
|
+
resolved.push(res.value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return (0, neverthrow_1.ok)(resolved);
|
|
113
|
+
}
|
|
@@ -15,6 +15,7 @@ export interface CompiledWorkflow {
|
|
|
15
15
|
readonly loopBodyStepIds: ReadonlySet<string>;
|
|
16
16
|
}
|
|
17
17
|
export declare class WorkflowCompiler {
|
|
18
|
+
private readonly refRegistry;
|
|
18
19
|
compile(workflow: Workflow): Result<CompiledWorkflow, DomainError>;
|
|
19
20
|
private deriveConditionSource;
|
|
20
21
|
private resolveLoopBody;
|
|
@@ -12,9 +12,28 @@ const workflow_1 = require("../../types/workflow");
|
|
|
12
12
|
const index_1 = require("../../v2/durable-core/schemas/artifacts/index");
|
|
13
13
|
const neverthrow_1 = require("neverthrow");
|
|
14
14
|
const error_1 = require("../../domain/execution/error");
|
|
15
|
+
const prompt_blocks_1 = require("./compiler/prompt-blocks");
|
|
16
|
+
const resolve_refs_1 = require("./compiler/resolve-refs");
|
|
17
|
+
const ref_registry_1 = require("./compiler/ref-registry");
|
|
15
18
|
let WorkflowCompiler = class WorkflowCompiler {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.refRegistry = (0, ref_registry_1.createRefRegistry)();
|
|
21
|
+
}
|
|
16
22
|
compile(workflow) {
|
|
17
|
-
const
|
|
23
|
+
const refsResult = (0, resolve_refs_1.resolveRefsPass)(workflow.definition.steps, this.refRegistry);
|
|
24
|
+
if (refsResult.isErr()) {
|
|
25
|
+
const e = refsResult.error;
|
|
26
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(`Step '${e.stepId}': ref resolution error — ${e.cause.message}`));
|
|
27
|
+
}
|
|
28
|
+
const blocksResult = (0, prompt_blocks_1.resolvePromptBlocksPass)(refsResult.value);
|
|
29
|
+
if (blocksResult.isErr()) {
|
|
30
|
+
const e = blocksResult.error;
|
|
31
|
+
const message = e.code === 'PROMPT_AND_BLOCKS_BOTH_SET'
|
|
32
|
+
? e.message
|
|
33
|
+
: `Step '${e.stepId}': promptBlocks error — ${e.cause.message}`;
|
|
34
|
+
return (0, neverthrow_1.err)(error_1.Err.invalidState(message));
|
|
35
|
+
}
|
|
36
|
+
const steps = blocksResult.value;
|
|
18
37
|
const stepById = new Map();
|
|
19
38
|
for (const step of steps) {
|
|
20
39
|
if (stepById.has(step.id)) {
|
|
@@ -386,7 +386,7 @@ let WorkflowInterpreter = class WorkflowInterpreter {
|
|
|
386
386
|
if (step.guidance && step.guidance.length > 0) {
|
|
387
387
|
promptParts.push(`## Step Guidance\n${step.guidance.map((g) => `- ${g}`).join('\n')}\n`);
|
|
388
388
|
}
|
|
389
|
-
promptParts.push(step.prompt);
|
|
389
|
+
promptParts.push(step.prompt ?? '');
|
|
390
390
|
if (instance.loopPath.length > 0) {
|
|
391
391
|
const current = instance.loopPath[instance.loopPath.length - 1];
|
|
392
392
|
promptParts.push(`\n\n## Loop Context\n- Loop: ${current.loopId}\n- Iteration: ${current.iteration + 1}`);
|
package/dist/manifest.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"distDir": "dist",
|
|
3
3
|
"files": {
|
|
4
|
+
"application/services/compiler/prompt-blocks.d.ts": {
|
|
5
|
+
"sha256": "2f40fd7599bd351584505152e9916fdea60891833d22c774c8ac9955f01ccf66",
|
|
6
|
+
"bytes": 1416
|
|
7
|
+
},
|
|
8
|
+
"application/services/compiler/prompt-blocks.js": {
|
|
9
|
+
"sha256": "8ee0e8f7f23f0b298602b97af71a49eaf4fbdc8e7a2bb588c607c2f36e81ef1a",
|
|
10
|
+
"bytes": 5201
|
|
11
|
+
},
|
|
12
|
+
"application/services/compiler/ref-registry.d.ts": {
|
|
13
|
+
"sha256": "b93074634a3a26097b9ed35d72351272c567dff184401a95e9f80ea7ae8724a5",
|
|
14
|
+
"bytes": 428
|
|
15
|
+
},
|
|
16
|
+
"application/services/compiler/ref-registry.js": {
|
|
17
|
+
"sha256": "075b14ab0efd34df85eb9b564362d2415eacffc13f44f1ba54bdc5e8229a7d2e",
|
|
18
|
+
"bytes": 2008
|
|
19
|
+
},
|
|
20
|
+
"application/services/compiler/resolve-refs.d.ts": {
|
|
21
|
+
"sha256": "64ed63007495f8b95baeb5f867a6b6ac39f097ad5976803b2642defa80ed31bf",
|
|
22
|
+
"bytes": 581
|
|
23
|
+
},
|
|
24
|
+
"application/services/compiler/resolve-refs.js": {
|
|
25
|
+
"sha256": "9f9e2a44cec6dfd6d870a645b38e4faf52e17c9ef3654fd600ebcd9943f532c5",
|
|
26
|
+
"bytes": 4214
|
|
27
|
+
},
|
|
4
28
|
"application/services/enhanced-error-service.d.ts": {
|
|
5
29
|
"sha256": "b6fe8fad92717f0962f87aa9c0f88277bf28fe2b5e3cfd7875612ee57eb8c684",
|
|
6
30
|
"bytes": 601
|
|
@@ -42,20 +66,20 @@
|
|
|
42
66
|
"bytes": 31038
|
|
43
67
|
},
|
|
44
68
|
"application/services/workflow-compiler.d.ts": {
|
|
45
|
-
"sha256": "
|
|
46
|
-
"bytes":
|
|
69
|
+
"sha256": "65d65befc721926c125836692a0982f3cdef57f429326cde1b48e2fbc8593c98",
|
|
70
|
+
"bytes": 1024
|
|
47
71
|
},
|
|
48
72
|
"application/services/workflow-compiler.js": {
|
|
49
|
-
"sha256": "
|
|
50
|
-
"bytes":
|
|
73
|
+
"sha256": "7d03802161c8802553122be3132efb77dc42214f232d333df73230012a7ff9b5",
|
|
74
|
+
"bytes": 6581
|
|
51
75
|
},
|
|
52
76
|
"application/services/workflow-interpreter.d.ts": {
|
|
53
77
|
"sha256": "56b5b5ad06d42096deba9f0abe7642c18a355a1e598749aab1730df4e9847674",
|
|
54
78
|
"bytes": 1507
|
|
55
79
|
},
|
|
56
80
|
"application/services/workflow-interpreter.js": {
|
|
57
|
-
"sha256": "
|
|
58
|
-
"bytes":
|
|
81
|
+
"sha256": "0ea1861801d095d27e1e4c7c97978941b9d48613e28ce3a4c2efe64342814f5c",
|
|
82
|
+
"bytes": 21402
|
|
59
83
|
},
|
|
60
84
|
"application/services/workflow-service.d.ts": {
|
|
61
85
|
"sha256": "b92da17c6d91c90758ec42b4ee3bc448e5d5b1dfe7351f2fe0f5e1d10a715ec6",
|
|
@@ -746,7 +770,7 @@
|
|
|
746
770
|
"bytes": 7535
|
|
747
771
|
},
|
|
748
772
|
"mcp/output-schemas.d.ts": {
|
|
749
|
-
"sha256": "
|
|
773
|
+
"sha256": "484a853815de731053618d7d710b6608392aef935239d899824f6a30a16ec3b7",
|
|
750
774
|
"bytes": 51242
|
|
751
775
|
},
|
|
752
776
|
"mcp/output-schemas.js": {
|
|
@@ -1058,8 +1082,8 @@
|
|
|
1058
1082
|
"bytes": 395
|
|
1059
1083
|
},
|
|
1060
1084
|
"types/workflow-definition.d.ts": {
|
|
1061
|
-
"sha256": "
|
|
1062
|
-
"bytes":
|
|
1085
|
+
"sha256": "cb7d6be7e9aa0d4b7b17323cd167edad2f616b6a8c2149df6c40e4d965e7d9b8",
|
|
1086
|
+
"bytes": 3744
|
|
1063
1087
|
},
|
|
1064
1088
|
"types/workflow-definition.js": {
|
|
1065
1089
|
"sha256": "e269d62f27b7f37f870183d6b77800b7aa1e22dabc894374bab8f34db049a55b",
|
|
@@ -1490,7 +1514,7 @@
|
|
|
1490
1514
|
"bytes": 2099
|
|
1491
1515
|
},
|
|
1492
1516
|
"v2/durable-core/schemas/compiled-workflow/index.d.ts": {
|
|
1493
|
-
"sha256": "
|
|
1517
|
+
"sha256": "d909c13d0d46bba1dcd411a0c53e767cf7e4c8bc5206581344ca1e7315552d95",
|
|
1494
1518
|
"bytes": 3645
|
|
1495
1519
|
},
|
|
1496
1520
|
"v2/durable-core/schemas/compiled-workflow/index.js": {
|
|
@@ -237,13 +237,13 @@ export declare const V2PendingStepSchema: z.ZodObject<{
|
|
|
237
237
|
title: z.ZodString;
|
|
238
238
|
prompt: z.ZodString;
|
|
239
239
|
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
title: string;
|
|
241
|
-
prompt: string;
|
|
242
240
|
stepId: string;
|
|
243
|
-
}, {
|
|
244
|
-
title: string;
|
|
245
241
|
prompt: string;
|
|
242
|
+
title: string;
|
|
243
|
+
}, {
|
|
246
244
|
stepId: string;
|
|
245
|
+
prompt: string;
|
|
246
|
+
title: string;
|
|
247
247
|
}>;
|
|
248
248
|
export declare const V2PreferencesSchema: z.ZodObject<{
|
|
249
249
|
autonomy: z.ZodEnum<["guided", "full_auto_stop_on_user_deps", "full_auto_never_stop"]>;
|
|
@@ -484,13 +484,13 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
484
484
|
title: z.ZodString;
|
|
485
485
|
prompt: z.ZodString;
|
|
486
486
|
}, "strip", z.ZodTypeAny, {
|
|
487
|
-
title: string;
|
|
488
|
-
prompt: string;
|
|
489
487
|
stepId: string;
|
|
490
|
-
}, {
|
|
491
|
-
title: string;
|
|
492
488
|
prompt: string;
|
|
489
|
+
title: string;
|
|
490
|
+
}, {
|
|
493
491
|
stepId: string;
|
|
492
|
+
prompt: string;
|
|
493
|
+
title: string;
|
|
494
494
|
}>>;
|
|
495
495
|
preferences: z.ZodObject<{
|
|
496
496
|
autonomy: z.ZodEnum<["guided", "full_auto_stop_on_user_deps", "full_auto_never_stop"]>;
|
|
@@ -551,9 +551,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
551
551
|
}, "strip", z.ZodTypeAny, {
|
|
552
552
|
kind: "ok";
|
|
553
553
|
pending: {
|
|
554
|
-
title: string;
|
|
555
|
-
prompt: string;
|
|
556
554
|
stepId: string;
|
|
555
|
+
prompt: string;
|
|
556
|
+
title: string;
|
|
557
557
|
} | null;
|
|
558
558
|
isComplete: boolean;
|
|
559
559
|
stateToken: string;
|
|
@@ -578,9 +578,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
578
578
|
}, {
|
|
579
579
|
kind: "ok";
|
|
580
580
|
pending: {
|
|
581
|
-
title: string;
|
|
582
|
-
prompt: string;
|
|
583
581
|
stepId: string;
|
|
582
|
+
prompt: string;
|
|
583
|
+
title: string;
|
|
584
584
|
} | null;
|
|
585
585
|
isComplete: boolean;
|
|
586
586
|
stateToken: string;
|
|
@@ -613,13 +613,13 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
613
613
|
title: z.ZodString;
|
|
614
614
|
prompt: z.ZodString;
|
|
615
615
|
}, "strip", z.ZodTypeAny, {
|
|
616
|
-
title: string;
|
|
617
|
-
prompt: string;
|
|
618
616
|
stepId: string;
|
|
619
|
-
}, {
|
|
620
|
-
title: string;
|
|
621
617
|
prompt: string;
|
|
618
|
+
title: string;
|
|
619
|
+
}, {
|
|
622
620
|
stepId: string;
|
|
621
|
+
prompt: string;
|
|
622
|
+
title: string;
|
|
623
623
|
}>>;
|
|
624
624
|
preferences: z.ZodObject<{
|
|
625
625
|
autonomy: z.ZodEnum<["guided", "full_auto_stop_on_user_deps", "full_auto_never_stop"]>;
|
|
@@ -886,9 +886,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
886
886
|
}[];
|
|
887
887
|
};
|
|
888
888
|
pending: {
|
|
889
|
-
title: string;
|
|
890
|
-
prompt: string;
|
|
891
889
|
stepId: string;
|
|
890
|
+
prompt: string;
|
|
891
|
+
title: string;
|
|
892
892
|
} | null;
|
|
893
893
|
isComplete: boolean;
|
|
894
894
|
stateToken: string;
|
|
@@ -941,9 +941,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
941
941
|
}[];
|
|
942
942
|
};
|
|
943
943
|
pending: {
|
|
944
|
-
title: string;
|
|
945
|
-
prompt: string;
|
|
946
944
|
stepId: string;
|
|
945
|
+
prompt: string;
|
|
946
|
+
title: string;
|
|
947
947
|
} | null;
|
|
948
948
|
isComplete: boolean;
|
|
949
949
|
stateToken: string;
|
|
@@ -974,9 +974,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
974
974
|
}>]>, {
|
|
975
975
|
kind: "ok";
|
|
976
976
|
pending: {
|
|
977
|
-
title: string;
|
|
978
|
-
prompt: string;
|
|
979
977
|
stepId: string;
|
|
978
|
+
prompt: string;
|
|
979
|
+
title: string;
|
|
980
980
|
} | null;
|
|
981
981
|
isComplete: boolean;
|
|
982
982
|
stateToken: string;
|
|
@@ -1023,9 +1023,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
1023
1023
|
}[];
|
|
1024
1024
|
};
|
|
1025
1025
|
pending: {
|
|
1026
|
-
title: string;
|
|
1027
|
-
prompt: string;
|
|
1028
1026
|
stepId: string;
|
|
1027
|
+
prompt: string;
|
|
1028
|
+
title: string;
|
|
1029
1029
|
} | null;
|
|
1030
1030
|
isComplete: boolean;
|
|
1031
1031
|
stateToken: string;
|
|
@@ -1056,9 +1056,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
1056
1056
|
}, {
|
|
1057
1057
|
kind: "ok";
|
|
1058
1058
|
pending: {
|
|
1059
|
-
title: string;
|
|
1060
|
-
prompt: string;
|
|
1061
1059
|
stepId: string;
|
|
1060
|
+
prompt: string;
|
|
1061
|
+
title: string;
|
|
1062
1062
|
} | null;
|
|
1063
1063
|
isComplete: boolean;
|
|
1064
1064
|
stateToken: string;
|
|
@@ -1105,9 +1105,9 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
|
|
|
1105
1105
|
}[];
|
|
1106
1106
|
};
|
|
1107
1107
|
pending: {
|
|
1108
|
-
title: string;
|
|
1109
|
-
prompt: string;
|
|
1110
1108
|
stepId: string;
|
|
1109
|
+
prompt: string;
|
|
1110
|
+
title: string;
|
|
1111
1111
|
} | null;
|
|
1112
1112
|
isComplete: boolean;
|
|
1113
1113
|
stateToken: string;
|
|
@@ -1263,13 +1263,13 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1263
1263
|
title: z.ZodString;
|
|
1264
1264
|
prompt: z.ZodString;
|
|
1265
1265
|
}, "strip", z.ZodTypeAny, {
|
|
1266
|
-
title: string;
|
|
1267
|
-
prompt: string;
|
|
1268
1266
|
stepId: string;
|
|
1269
|
-
}, {
|
|
1270
|
-
title: string;
|
|
1271
1267
|
prompt: string;
|
|
1268
|
+
title: string;
|
|
1269
|
+
}, {
|
|
1272
1270
|
stepId: string;
|
|
1271
|
+
prompt: string;
|
|
1272
|
+
title: string;
|
|
1273
1273
|
}>>;
|
|
1274
1274
|
preferences: z.ZodObject<{
|
|
1275
1275
|
autonomy: z.ZodEnum<["guided", "full_auto_stop_on_user_deps", "full_auto_never_stop"]>;
|
|
@@ -1329,9 +1329,9 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1329
1329
|
}>>;
|
|
1330
1330
|
}, "strip", z.ZodTypeAny, {
|
|
1331
1331
|
pending: {
|
|
1332
|
-
title: string;
|
|
1333
|
-
prompt: string;
|
|
1334
1332
|
stepId: string;
|
|
1333
|
+
prompt: string;
|
|
1334
|
+
title: string;
|
|
1335
1335
|
} | null;
|
|
1336
1336
|
isComplete: boolean;
|
|
1337
1337
|
stateToken: string;
|
|
@@ -1355,9 +1355,9 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1355
1355
|
checkpointToken?: string | undefined;
|
|
1356
1356
|
}, {
|
|
1357
1357
|
pending: {
|
|
1358
|
-
title: string;
|
|
1359
|
-
prompt: string;
|
|
1360
1358
|
stepId: string;
|
|
1359
|
+
prompt: string;
|
|
1360
|
+
title: string;
|
|
1361
1361
|
} | null;
|
|
1362
1362
|
isComplete: boolean;
|
|
1363
1363
|
stateToken: string;
|
|
@@ -1381,9 +1381,9 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1381
1381
|
checkpointToken?: string | undefined;
|
|
1382
1382
|
}>, {
|
|
1383
1383
|
pending: {
|
|
1384
|
-
title: string;
|
|
1385
|
-
prompt: string;
|
|
1386
1384
|
stepId: string;
|
|
1385
|
+
prompt: string;
|
|
1386
|
+
title: string;
|
|
1387
1387
|
} | null;
|
|
1388
1388
|
isComplete: boolean;
|
|
1389
1389
|
stateToken: string;
|
|
@@ -1407,9 +1407,9 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1407
1407
|
checkpointToken?: string | undefined;
|
|
1408
1408
|
}, {
|
|
1409
1409
|
pending: {
|
|
1410
|
-
title: string;
|
|
1411
|
-
prompt: string;
|
|
1412
1410
|
stepId: string;
|
|
1411
|
+
prompt: string;
|
|
1412
|
+
title: string;
|
|
1413
1413
|
} | null;
|
|
1414
1414
|
isComplete: boolean;
|
|
1415
1415
|
stateToken: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ValidationCriteria } from './validation';
|
|
2
2
|
import type { ArtifactContractRef } from '../v2/durable-core/schemas/artifacts/index';
|
|
3
|
+
import type { PromptBlocks } from '../application/services/compiler/prompt-blocks.js';
|
|
3
4
|
export interface OutputContract {
|
|
4
5
|
readonly contractRef: ArtifactContractRef;
|
|
5
6
|
readonly required?: boolean;
|
|
@@ -7,7 +8,8 @@ export interface OutputContract {
|
|
|
7
8
|
export interface WorkflowStepDefinition {
|
|
8
9
|
readonly id: string;
|
|
9
10
|
readonly title: string;
|
|
10
|
-
readonly prompt
|
|
11
|
+
readonly prompt?: string;
|
|
12
|
+
readonly promptBlocks?: PromptBlocks;
|
|
11
13
|
readonly agentRole?: string;
|
|
12
14
|
readonly guidance?: readonly string[];
|
|
13
15
|
readonly askForFiles?: boolean;
|
|
@@ -11,13 +11,13 @@ export declare const CompiledWorkflowSnapshotV1Schema: z.ZodDiscriminatedUnion<"
|
|
|
11
11
|
title: z.ZodString;
|
|
12
12
|
prompt: z.ZodString;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
title: string;
|
|
15
|
-
prompt: string;
|
|
16
14
|
stepId: string;
|
|
17
|
-
}, {
|
|
18
|
-
title: string;
|
|
19
15
|
prompt: string;
|
|
16
|
+
title: string;
|
|
17
|
+
}, {
|
|
20
18
|
stepId: string;
|
|
19
|
+
prompt: string;
|
|
20
|
+
title: string;
|
|
21
21
|
}>;
|
|
22
22
|
}, "strip", z.ZodTypeAny, {
|
|
23
23
|
name: string;
|
|
@@ -27,9 +27,9 @@ export declare const CompiledWorkflowSnapshotV1Schema: z.ZodDiscriminatedUnion<"
|
|
|
27
27
|
schemaVersion: 1;
|
|
28
28
|
sourceKind: "v1_preview";
|
|
29
29
|
preview: {
|
|
30
|
-
title: string;
|
|
31
|
-
prompt: string;
|
|
32
30
|
stepId: string;
|
|
31
|
+
prompt: string;
|
|
32
|
+
title: string;
|
|
33
33
|
};
|
|
34
34
|
}, {
|
|
35
35
|
name: string;
|
|
@@ -39,9 +39,9 @@ export declare const CompiledWorkflowSnapshotV1Schema: z.ZodDiscriminatedUnion<"
|
|
|
39
39
|
schemaVersion: 1;
|
|
40
40
|
sourceKind: "v1_preview";
|
|
41
41
|
preview: {
|
|
42
|
-
title: string;
|
|
43
|
-
prompt: string;
|
|
44
42
|
stepId: string;
|
|
43
|
+
prompt: string;
|
|
44
|
+
title: string;
|
|
45
45
|
};
|
|
46
46
|
}>, z.ZodObject<{
|
|
47
47
|
schemaVersion: z.ZodLiteral<1>;
|
|
@@ -81,13 +81,13 @@ export declare const CompiledWorkflowSnapshotSchema: z.ZodDiscriminatedUnion<"so
|
|
|
81
81
|
title: z.ZodString;
|
|
82
82
|
prompt: z.ZodString;
|
|
83
83
|
}, "strip", z.ZodTypeAny, {
|
|
84
|
-
title: string;
|
|
85
|
-
prompt: string;
|
|
86
84
|
stepId: string;
|
|
87
|
-
}, {
|
|
88
|
-
title: string;
|
|
89
85
|
prompt: string;
|
|
86
|
+
title: string;
|
|
87
|
+
}, {
|
|
90
88
|
stepId: string;
|
|
89
|
+
prompt: string;
|
|
90
|
+
title: string;
|
|
91
91
|
}>;
|
|
92
92
|
}, "strip", z.ZodTypeAny, {
|
|
93
93
|
name: string;
|
|
@@ -97,9 +97,9 @@ export declare const CompiledWorkflowSnapshotSchema: z.ZodDiscriminatedUnion<"so
|
|
|
97
97
|
schemaVersion: 1;
|
|
98
98
|
sourceKind: "v1_preview";
|
|
99
99
|
preview: {
|
|
100
|
-
title: string;
|
|
101
|
-
prompt: string;
|
|
102
100
|
stepId: string;
|
|
101
|
+
prompt: string;
|
|
102
|
+
title: string;
|
|
103
103
|
};
|
|
104
104
|
}, {
|
|
105
105
|
name: string;
|
|
@@ -109,9 +109,9 @@ export declare const CompiledWorkflowSnapshotSchema: z.ZodDiscriminatedUnion<"so
|
|
|
109
109
|
schemaVersion: 1;
|
|
110
110
|
sourceKind: "v1_preview";
|
|
111
111
|
preview: {
|
|
112
|
-
title: string;
|
|
113
|
-
prompt: string;
|
|
114
112
|
stepId: string;
|
|
113
|
+
prompt: string;
|
|
114
|
+
title: string;
|
|
115
115
|
};
|
|
116
116
|
}>, z.ZodObject<{
|
|
117
117
|
schemaVersion: z.ZodLiteral<1>;
|