@synergenius/flow-weaver 0.20.4 → 0.20.5

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.
@@ -9671,7 +9671,7 @@ var VERSION;
9671
9671
  var init_generated_version = __esm({
9672
9672
  "src/generated-version.ts"() {
9673
9673
  "use strict";
9674
- VERSION = "0.20.4";
9674
+ VERSION = "0.20.5";
9675
9675
  }
9676
9676
  });
9677
9677
 
@@ -10646,29 +10646,50 @@ function buildNodeArgumentsWithContext(opts) {
10646
10646
  const isConstSource = isStartNode(sourceNode) || sourceNode === instanceParent;
10647
10647
  const nonNullAssert = isConstSource ? "" : "!";
10648
10648
  const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10649
+ const needsGuard = portConfig.optional && !isConstSource;
10649
10650
  if (portConfig.dataType === "FUNCTION") {
10650
10651
  const rawVarName = `${varName}_raw`;
10651
- lines.push(
10652
- `${indent}const ${rawVarName} = ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} });`
10653
- );
10654
- lines.push(
10655
- `${indent}const ${varName}_resolved = resolveFunction(${rawVarName});`
10656
- );
10657
- lines.push(
10658
- `${indent}const ${varName} = ${varName}_resolved.fn as ${portType};`
10659
- );
10652
+ if (needsGuard) {
10653
+ lines.push(
10654
+ `${indent}const ${rawVarName} = ${sourceIdx} !== undefined ? ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx} }) : undefined;`
10655
+ );
10656
+ lines.push(
10657
+ `${indent}const ${varName}_resolved = ${rawVarName} !== undefined ? resolveFunction(${rawVarName}) : undefined;`
10658
+ );
10659
+ lines.push(
10660
+ `${indent}const ${varName} = ${varName}_resolved?.fn as ${portType};`
10661
+ );
10662
+ } else {
10663
+ lines.push(
10664
+ `${indent}const ${rawVarName} = ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} });`
10665
+ );
10666
+ lines.push(
10667
+ `${indent}const ${varName}_resolved = resolveFunction(${rawVarName});`
10668
+ );
10669
+ lines.push(
10670
+ `${indent}const ${varName} = ${varName}_resolved.fn as ${portType};`
10671
+ );
10672
+ }
10660
10673
  } else {
10661
10674
  const sourceDataType = resolveSourcePortDataType(workflow, sourceNode, sourcePort);
10662
10675
  const coerceExpr = getCoercionWrapper(connection, sourceDataType, portConfig.dataType);
10663
- const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} })`;
10664
- if (coerceExpr) {
10676
+ if (needsGuard) {
10677
+ const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx} })`;
10678
+ const wrappedExpr = coerceExpr ? `${coerceExpr}(${getExpr})` : getExpr;
10665
10679
  lines.push(
10666
- `${indent}const ${varName} = ${coerceExpr}(${getExpr}) as ${portType};`
10680
+ `${indent}const ${varName} = ${sourceIdx} !== undefined ? ${wrappedExpr} as ${portType} : undefined;`
10667
10681
  );
10668
10682
  } else {
10669
- lines.push(
10670
- `${indent}const ${varName} = ${getExpr} as ${portType};`
10671
- );
10683
+ const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} })`;
10684
+ if (coerceExpr) {
10685
+ lines.push(
10686
+ `${indent}const ${varName} = ${coerceExpr}(${getExpr}) as ${portType};`
10687
+ );
10688
+ } else {
10689
+ lines.push(
10690
+ `${indent}const ${varName} = ${getExpr} as ${portType};`
10691
+ );
10692
+ }
10672
10693
  }
10673
10694
  }
10674
10695
  } else {
@@ -106710,7 +106731,7 @@ function displayInstalledPackage(pkg) {
106710
106731
  // src/cli/index.ts
106711
106732
  init_logger();
106712
106733
  init_error_utils();
106713
- var version2 = true ? "0.20.4" : "0.0.0-dev";
106734
+ var version2 = true ? "0.20.5" : "0.0.0-dev";
106714
106735
  var program2 = new Command();
106715
106736
  program2.name("flow-weaver").description("Flow Weaver Annotations - Compile and validate workflow files").option("-v, --version", "Output the current version").option("--no-color", "Disable colors").option("--color", "Force colors").on("option:version", () => {
106716
106737
  logger.banner(version2);
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.20.4";
1
+ export declare const VERSION = "0.20.5";
2
2
  //# sourceMappingURL=generated-version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/generate-version.ts — do not edit manually
2
- export const VERSION = '0.20.4';
2
+ export const VERSION = '0.20.5';
3
3
  //# sourceMappingURL=generated-version.js.map
@@ -255,23 +255,40 @@ export function buildNodeArgumentsWithContext(opts) {
255
255
  const isConstSource = isStartNode(sourceNode) || sourceNode === instanceParent;
256
256
  const nonNullAssert = isConstSource ? '' : '!';
257
257
  const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
258
+ // For optional ports on non-const sources, guard against undefined execution index.
259
+ // This is critical for DISJUNCTION nodes where the source may not have executed.
260
+ const needsGuard = portConfig.optional && !isConstSource;
258
261
  // For FUNCTION type ports, add resolution step to handle registry IDs
259
262
  if (portConfig.dataType === 'FUNCTION') {
260
263
  const rawVarName = `${varName}_raw`;
261
- lines.push(`${indent}const ${rawVarName} = ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} });`);
262
- lines.push(`${indent}const ${varName}_resolved = resolveFunction(${rawVarName});`);
263
- lines.push(`${indent}const ${varName} = ${varName}_resolved.fn as ${portType};`);
264
+ if (needsGuard) {
265
+ lines.push(`${indent}const ${rawVarName} = ${sourceIdx} !== undefined ? ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx} }) : undefined;`);
266
+ lines.push(`${indent}const ${varName}_resolved = ${rawVarName} !== undefined ? resolveFunction(${rawVarName}) : undefined;`);
267
+ lines.push(`${indent}const ${varName} = ${varName}_resolved?.fn as ${portType};`);
268
+ }
269
+ else {
270
+ lines.push(`${indent}const ${rawVarName} = ${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} });`);
271
+ lines.push(`${indent}const ${varName}_resolved = resolveFunction(${rawVarName});`);
272
+ lines.push(`${indent}const ${varName} = ${varName}_resolved.fn as ${portType};`);
273
+ }
264
274
  }
265
275
  else {
266
276
  // Check for coercion (explicit or auto)
267
277
  const sourceDataType = resolveSourcePortDataType(workflow, sourceNode, sourcePort);
268
278
  const coerceExpr = getCoercionWrapper(connection, sourceDataType, portConfig.dataType);
269
- const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} })`;
270
- if (coerceExpr) {
271
- lines.push(`${indent}const ${varName} = ${coerceExpr}(${getExpr}) as ${portType};`);
279
+ if (needsGuard) {
280
+ const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx} })`;
281
+ const wrappedExpr = coerceExpr ? `${coerceExpr}(${getExpr})` : getExpr;
282
+ lines.push(`${indent}const ${varName} = ${sourceIdx} !== undefined ? ${wrappedExpr} as ${portType} : undefined;`);
272
283
  }
273
284
  else {
274
- lines.push(`${indent}const ${varName} = ${getExpr} as ${portType};`);
285
+ const getExpr = `${getCall}({ id: '${sourceNode}', portName: '${sourcePort}', executionIndex: ${sourceIdx}${nonNullAssert} })`;
286
+ if (coerceExpr) {
287
+ lines.push(`${indent}const ${varName} = ${coerceExpr}(${getExpr}) as ${portType};`);
288
+ }
289
+ else {
290
+ lines.push(`${indent}const ${varName} = ${getExpr} as ${portType};`);
291
+ }
275
292
  }
276
293
  }
277
294
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.20.4",
3
+ "version": "0.20.5",
4
4
  "description": "Deterministic workflow compiler for AI agents. Compiles to standalone TypeScript, no runtime dependencies.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -86,6 +86,10 @@
86
86
  "./executor": {
87
87
  "types": "./dist/mcp/workflow-executor.d.ts",
88
88
  "default": "./dist/mcp/workflow-executor.js"
89
+ },
90
+ "./context": {
91
+ "types": "./dist/context/index.d.ts",
92
+ "default": "./dist/context/index.js"
89
93
  }
90
94
  },
91
95
  "bin": {