@synergenius/flow-weaver 0.8.0 → 0.8.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.
|
@@ -15,6 +15,10 @@ export async function waitForAgent(execute, agentId, context, prompt) {
|
|
|
15
15
|
if (mockResult !== undefined) {
|
|
16
16
|
return { onSuccess: true, onFailure: false, agentResult: mockResult };
|
|
17
17
|
}
|
|
18
|
+
// Mocks section exists but key not found — fail like waitForEvent/invokeWorkflow
|
|
19
|
+
if (mocks?.agents) {
|
|
20
|
+
return { onSuccess: false, onFailure: true, agentResult: {} };
|
|
21
|
+
}
|
|
18
22
|
// 2. Check agent channel (set by executor for pause/resume)
|
|
19
23
|
const channel = globalThis.__fw_agent_channel__;
|
|
20
24
|
if (channel) {
|
package/dist/cli/flow-weaver.mjs
CHANGED
|
@@ -45439,7 +45439,7 @@ var AnnotationParser = class {
|
|
|
45439
45439
|
const config2 = jsdocParser.parseNodeType(fn, warnings);
|
|
45440
45440
|
if (!config2) {
|
|
45441
45441
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join("");
|
|
45442
|
-
if (jsdocText.includes("@flowWeaver
|
|
45442
|
+
if (jsdocText.includes("@flowWeaver nodeType")) {
|
|
45443
45443
|
warnings.push(
|
|
45444
45444
|
`Function "${fn.getName() || "anonymous"}" has @flowWeaver annotation but could not be parsed. Check for special characters (---) or malformed JSDoc syntax.`
|
|
45445
45445
|
);
|
|
@@ -45650,7 +45650,7 @@ ${fn.getText()}` : fn.getText();
|
|
|
45650
45650
|
const config2 = jsdocParser.parseWorkflow(fn, warnings);
|
|
45651
45651
|
if (!config2) {
|
|
45652
45652
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join("");
|
|
45653
|
-
if (jsdocText.includes("@flowWeaver
|
|
45653
|
+
if (jsdocText.includes("@flowWeaver workflow")) {
|
|
45654
45654
|
warnings.push(
|
|
45655
45655
|
`Function "${fn.getName() || "anonymous"}" has @flowWeaver annotation but could not be parsed. Check for special characters (---) or malformed JSDoc syntax.`
|
|
45656
45656
|
);
|
|
@@ -45838,7 +45838,7 @@ ${fn.getText()}` : fn.getText();
|
|
|
45838
45838
|
const config2 = jsdocParser.parsePattern(fn, warnings);
|
|
45839
45839
|
if (!config2) {
|
|
45840
45840
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join("");
|
|
45841
|
-
if (jsdocText.includes("@flowWeaver
|
|
45841
|
+
if (jsdocText.includes("@flowWeaver pattern")) {
|
|
45842
45842
|
warnings.push(
|
|
45843
45843
|
`Function "${fn.getName() || "anonymous"}" has @flowWeaver annotation but could not be parsed. Check for special characters (---) or malformed JSDoc syntax.`
|
|
45844
45844
|
);
|
|
@@ -95127,7 +95127,7 @@ function displayInstalledPackage(pkg) {
|
|
|
95127
95127
|
}
|
|
95128
95128
|
|
|
95129
95129
|
// src/cli/index.ts
|
|
95130
|
-
var version2 = true ? "0.8.
|
|
95130
|
+
var version2 = true ? "0.8.1" : "0.0.0-dev";
|
|
95131
95131
|
var program2 = new Command();
|
|
95132
95132
|
program2.name("flow-weaver").description("Flow Weaver Annotations - Compile and validate workflow files").version(version2, "-v, --version", "Output the current version");
|
|
95133
95133
|
program2.configureOutput({
|
|
@@ -95331,7 +95331,7 @@ patternCmd.command("extract <source-file>").description("Extract a pattern from
|
|
|
95331
95331
|
process.exit(1);
|
|
95332
95332
|
}
|
|
95333
95333
|
});
|
|
95334
|
-
program2.command("run <input>").description("Execute a workflow file directly").option("-w, --workflow <name>", "Specific workflow name to run").option("--params <json>", "Input parameters as JSON string").option("--params-file <path>", "Path to JSON file with input parameters").option("-p, --production", "Production mode (no trace events)", false).option("-t, --trace", "Include execution trace events").option("-s, --stream", "Stream trace events in real-time").option("--json", "Output result as JSON", false).option("--timeout <ms>", "Execution timeout in milliseconds", parseInt).option("--mocks <json>", "Mock config for built-in nodes (events, invocations, fast) as JSON").option("--mocks-file <path>", "Path to JSON file with mock config for built-in nodes").action(async (input, options) => {
|
|
95334
|
+
program2.command("run <input>").description("Execute a workflow file directly").option("-w, --workflow <name>", "Specific workflow name to run").option("--params <json>", "Input parameters as JSON string").option("--params-file <path>", "Path to JSON file with input parameters").option("-p, --production", "Production mode (no trace events)", false).option("-t, --trace", "Include execution trace events").option("-s, --stream", "Stream trace events in real-time").option("--json", "Output result as JSON", false).option("--timeout <ms>", "Execution timeout in milliseconds", parseInt).option("--mocks <json>", "Mock config for built-in nodes (events, invocations, agents, fast) as JSON").option("--mocks-file <path>", "Path to JSON file with mock config for built-in nodes").action(async (input, options) => {
|
|
95335
95335
|
try {
|
|
95336
95336
|
await runCommand(input, options);
|
|
95337
95337
|
} catch (error2) {
|
package/dist/cli/index.js
CHANGED
|
@@ -459,7 +459,7 @@ program
|
|
|
459
459
|
.option('-s, --stream', 'Stream trace events in real-time')
|
|
460
460
|
.option('--json', 'Output result as JSON', false)
|
|
461
461
|
.option('--timeout <ms>', 'Execution timeout in milliseconds', parseInt)
|
|
462
|
-
.option('--mocks <json>', 'Mock config for built-in nodes (events, invocations, fast) as JSON')
|
|
462
|
+
.option('--mocks <json>', 'Mock config for built-in nodes (events, invocations, agents, fast) as JSON')
|
|
463
463
|
.option('--mocks-file <path>', 'Path to JSON file with mock config for built-in nodes')
|
|
464
464
|
.action(async (input, options) => {
|
|
465
465
|
try {
|
package/dist/parser.js
CHANGED
|
@@ -594,7 +594,7 @@ export class AnnotationParser {
|
|
|
594
594
|
const config = jsdocParser.parseNodeType(fn, warnings);
|
|
595
595
|
if (!config) {
|
|
596
596
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join('');
|
|
597
|
-
if (jsdocText.includes('@flowWeaver
|
|
597
|
+
if (jsdocText.includes('@flowWeaver nodeType')) {
|
|
598
598
|
warnings.push(`Function "${fn.getName() || 'anonymous'}" has @flowWeaver annotation but could not be parsed. ` +
|
|
599
599
|
`Check for special characters (---) or malformed JSDoc syntax.`);
|
|
600
600
|
}
|
|
@@ -818,7 +818,7 @@ export class AnnotationParser {
|
|
|
818
818
|
const config = jsdocParser.parseWorkflow(fn, warnings);
|
|
819
819
|
if (!config) {
|
|
820
820
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join('');
|
|
821
|
-
if (jsdocText.includes('@flowWeaver
|
|
821
|
+
if (jsdocText.includes('@flowWeaver workflow')) {
|
|
822
822
|
warnings.push(`Function "${fn.getName() || 'anonymous'}" has @flowWeaver annotation but could not be parsed. ` +
|
|
823
823
|
`Check for special characters (---) or malformed JSDoc syntax.`);
|
|
824
824
|
}
|
|
@@ -1007,7 +1007,7 @@ export class AnnotationParser {
|
|
|
1007
1007
|
const config = jsdocParser.parsePattern(fn, warnings);
|
|
1008
1008
|
if (!config) {
|
|
1009
1009
|
const jsdocText = fn.getJsDocs().map((d) => d.getFullText()).join('');
|
|
1010
|
-
if (jsdocText.includes('@flowWeaver
|
|
1010
|
+
if (jsdocText.includes('@flowWeaver pattern')) {
|
|
1011
1011
|
warnings.push(`Function "${fn.getName() || 'anonymous'}" has @flowWeaver annotation but could not be parsed. ` +
|
|
1012
1012
|
`Check for special characters (---) or malformed JSDoc syntax.`);
|
|
1013
1013
|
}
|
|
@@ -127,6 +127,8 @@ interface FwMockConfig {
|
|
|
127
127
|
events?: Record<string, object>;
|
|
128
128
|
/** Mock invocation results keyed by functionId. Used by invokeWorkflow. */
|
|
129
129
|
invocations?: Record<string, object>;
|
|
130
|
+
/** Mock agent results keyed by agentId. Used by waitForAgent. */
|
|
131
|
+
agents?: Record<string, object>;
|
|
130
132
|
/** When true, delay nodes skip the real sleep (1ms instead of full duration). */
|
|
131
133
|
fast?: boolean;
|
|
132
134
|
}
|
|
@@ -156,6 +158,9 @@ flow-weaver run workflow.ts --mocks-file mocks.json
|
|
|
156
158
|
},
|
|
157
159
|
"invocations": {
|
|
158
160
|
"my-service/payment-processor": { "transactionId": "tx-123", "success": true }
|
|
161
|
+
},
|
|
162
|
+
"agents": {
|
|
163
|
+
"human-reviewer": { "approved": true, "note": "Looks good" }
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
```
|
|
@@ -172,6 +177,9 @@ Set mocks on `globalThis` before running the workflow:
|
|
|
172
177
|
},
|
|
173
178
|
invocations: {
|
|
174
179
|
'my-service/sub-workflow': { result: 'success' }
|
|
180
|
+
},
|
|
181
|
+
agents: {
|
|
182
|
+
'human-reviewer': { approved: true }
|
|
175
183
|
}
|
|
176
184
|
};
|
|
177
185
|
|
|
@@ -250,7 +250,7 @@ Scoped ports use direction inversion: scoped OUTPUTS = data parent sends to chil
|
|
|
250
250
|
|
|
251
251
|
## Mock System for Built-in Nodes
|
|
252
252
|
|
|
253
|
-
When testing workflows that use `delay`, `waitForEvent`, or `
|
|
253
|
+
When testing workflows that use `delay`, `waitForEvent`, `invokeWorkflow`, or `waitForAgent`, use mocks to avoid real side effects:
|
|
254
254
|
|
|
255
255
|
```bash
|
|
256
256
|
flow-weaver run workflow.ts --mocks '{"fast": true, "events": {"app/approved": {"status": "ok"}}}'
|
|
@@ -261,6 +261,9 @@ Mock config structure:
|
|
|
261
261
|
- `fast: true` — Skip real sleep in `delay` nodes (1ms instead)
|
|
262
262
|
- `events: { "event-name": data }` — Mock event data for `waitForEvent`
|
|
263
263
|
- `invocations: { "function-id": result }` — Mock results for `invokeWorkflow`
|
|
264
|
+
- `agents: { "agent-id": result }` — Mock results for `waitForAgent`
|
|
265
|
+
|
|
266
|
+
Use `--timeout <ms>` as a safeguard when running workflows that may block on unresolved `waitForAgent` or `waitForEvent` nodes. In non-interactive environments (piped stdin), `waitForAgent` will fail fast with an error if no mock is provided.
|
|
264
267
|
|
|
265
268
|
See `built-in-nodes` for full documentation on mock configuration and testing patterns.
|
|
266
269
|
|
package/package.json
CHANGED