@synergenius/flow-weaver 0.22.3 → 0.22.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.
@@ -9886,7 +9886,7 @@ var VERSION;
9886
9886
  var init_generated_version = __esm({
9887
9887
  "src/generated-version.ts"() {
9888
9888
  "use strict";
9889
- VERSION = "0.22.3";
9889
+ VERSION = "0.22.5";
9890
9890
  }
9891
9891
  });
9892
9892
 
@@ -10108,6 +10108,9 @@ function mapToTypeScript(portType, tsType) {
10108
10108
  return "unknown";
10109
10109
  }
10110
10110
  if (tsType && (portType === "OBJECT" || portType === "ANY" || portType === "ARRAY" || portType === "FUNCTION")) {
10111
+ if (tsType.includes("import(")) {
10112
+ return mapping.typescript;
10113
+ }
10111
10114
  return tsType;
10112
10115
  }
10113
10116
  return mapping.typescript;
@@ -10863,7 +10866,10 @@ function buildNodeArgumentsWithContext(opts) {
10863
10866
  const sourceIdx = isStartNode(sourceNode) ? "startIdx" : `${toValidIdentifier(sourceNode)}Idx`;
10864
10867
  const isConstSource = isStartNode(sourceNode) || sourceNode === instanceParent;
10865
10868
  const nonNullAssert = isConstSource ? "" : "!";
10866
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10869
+ const rawPortType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10870
+ const isPrimitive = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType);
10871
+ const paramIndex = args.length;
10872
+ const portType = isPrimitive ? rawPortType : `Parameters<typeof ${node.functionName}>[${paramIndex}]`;
10867
10873
  const needsGuard = portConfig.optional && !isConstSource;
10868
10874
  if (portConfig.dataType === "FUNCTION") {
10869
10875
  lines.push(`${indent}const __resolveFunction = typeof resolveFunction === 'function' ? resolveFunction : (p: unknown) => ({ fn: typeof p === 'function' ? p : () => { throw new Error('Cannot resolve function reference'); }, source: 'direct' as const });`);
@@ -10938,7 +10944,10 @@ function buildNodeArgumentsWithContext(opts) {
10938
10944
  }
10939
10945
  });
10940
10946
  const ternary = attempts.join(" ?? ");
10941
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10947
+ const rawPortType2 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10948
+ const isPrimitive2 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType2);
10949
+ const paramIndex2 = args.length;
10950
+ const portType = isPrimitive2 ? rawPortType2 : `Parameters<typeof ${node.functionName}>[${paramIndex2}]`;
10942
10951
  if (portConfig.dataType === "FUNCTION") {
10943
10952
  lines.push(`${indent}const __resolveFunction = typeof resolveFunction === 'function' ? resolveFunction : (p: unknown) => ({ fn: typeof p === 'function' ? p : () => { throw new Error('Cannot resolve function reference'); }, source: 'direct' as const });`);
10944
10953
  const rawVarName = `${varName}_raw`;
@@ -10958,7 +10967,10 @@ function buildNodeArgumentsWithContext(opts) {
10958
10967
  } else if (portConfig.expression) {
10959
10968
  const expression = portConfig.expression;
10960
10969
  const isFunction2 = expression.includes("=>") || expression.trim().startsWith("function");
10961
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10970
+ const rawPortType3 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10971
+ const isPrimitive3 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType3);
10972
+ const paramIndex3 = args.length;
10973
+ const portType = isPrimitive3 ? rawPortType3 : `Parameters<typeof ${node.functionName}>[${paramIndex3}]`;
10962
10974
  if (isFunction2) {
10963
10975
  lines.push(`${indent}const ${varName} = ${isAsync2 ? "await " : ""}(${expression})(ctx) as ${portType};`);
10964
10976
  } else {
@@ -10976,7 +10988,10 @@ function buildNodeArgumentsWithContext(opts) {
10976
10988
  args.push(varName);
10977
10989
  emitSetEvent();
10978
10990
  } else {
10979
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10991
+ const rawPortType4 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
10992
+ const isPrimitive4 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType4);
10993
+ const paramIndex4 = args.length;
10994
+ const portType = isPrimitive4 ? rawPortType4 : `Parameters<typeof ${node.functionName}>[${paramIndex4}]`;
10980
10995
  lines.push(
10981
10996
  `${indent}let ${varName}: ${portType} = undefined as unknown as ${portType}; // Required port '${portName}' has no connection`
10982
10997
  );
@@ -11091,7 +11106,7 @@ function generateControlFlowWithExecutionContext(workflow, nodeTypes, isAsync2,
11091
11106
  lines.push(` typeof globalThis !== 'undefined' && (globalThis as unknown as { __fw_debug_controller__?: TDebugController }).__fw_debug_controller__`);
11092
11107
  lines.push(` ? (globalThis as unknown as { __fw_debug_controller__?: TDebugController }).__fw_debug_controller__`);
11093
11108
  lines.push(` : { beforeNode: () => true, afterNode: () => {} }`);
11094
- lines.push(` );`);
11109
+ lines.push(` )!;`);
11095
11110
  lines.push("");
11096
11111
  }
11097
11112
  lines.push(` const startIdx = ctx.addExecution('${RESERVED_NODE_NAMES.START}');`);
@@ -94905,7 +94920,7 @@ var {
94905
94920
  // src/cli/index.ts
94906
94921
  init_logger();
94907
94922
  init_error_utils();
94908
- var version2 = true ? "0.22.3" : "0.0.0-dev";
94923
+ var version2 = true ? "0.22.5" : "0.0.0-dev";
94909
94924
  var program2 = new Command();
94910
94925
  program2.name("fw").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", () => {
94911
94926
  logger.banner(version2);
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.22.3";
1
+ export declare const VERSION = "0.22.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.22.3';
2
+ export const VERSION = '0.22.5';
3
3
  //# sourceMappingURL=generated-version.js.map
@@ -254,7 +254,13 @@ export function buildNodeArgumentsWithContext(opts) {
254
254
  const sourceIdx = isStartNode(sourceNode) ? 'startIdx' : `${toValidIdentifier(sourceNode)}Idx`;
255
255
  const isConstSource = isStartNode(sourceNode) || sourceNode === instanceParent;
256
256
  const nonNullAssert = isConstSource ? '' : '!';
257
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
257
+ const rawPortType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
258
+ // Use Parameters<typeof fn>[N] for non-primitive types to avoid bare
259
+ // type names from external modules that aren't in scope. The function
260
+ // IS always imported and in scope, so this is always safe.
261
+ const isPrimitive = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType);
262
+ const paramIndex = args.length; // Current position in the function's parameter list
263
+ const portType = isPrimitive ? rawPortType : `Parameters<typeof ${node.functionName}>[${paramIndex}]`;
258
264
  // For optional ports on non-const sources, guard against undefined execution index.
259
265
  // This is critical for DISJUNCTION nodes where the source may not have executed.
260
266
  const needsGuard = portConfig.optional && !isConstSource;
@@ -326,7 +332,10 @@ export function buildNodeArgumentsWithContext(opts) {
326
332
  }
327
333
  });
328
334
  const ternary = attempts.join(' ?? ');
329
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
335
+ const rawPortType2 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
336
+ const isPrimitive2 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType2);
337
+ const paramIndex2 = args.length;
338
+ const portType = isPrimitive2 ? rawPortType2 : `Parameters<typeof ${node.functionName}>[${paramIndex2}]`;
330
339
  // For FUNCTION type ports, add resolution step to handle registry IDs
331
340
  if (portConfig.dataType === 'FUNCTION') {
332
341
  lines.push(`${indent}const __resolveFunction = typeof resolveFunction === 'function' ? resolveFunction : (p: unknown) => ({ fn: typeof p === 'function' ? p : () => { throw new Error('Cannot resolve function reference'); }, source: 'direct' as const });`);
@@ -345,7 +354,10 @@ export function buildNodeArgumentsWithContext(opts) {
345
354
  else if (portConfig.expression) {
346
355
  const expression = portConfig.expression;
347
356
  const isFunction = expression.includes('=>') || expression.trim().startsWith('function');
348
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
357
+ const rawPortType3 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
358
+ const isPrimitive3 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType3);
359
+ const paramIndex3 = args.length;
360
+ const portType = isPrimitive3 ? rawPortType3 : `Parameters<typeof ${node.functionName}>[${paramIndex3}]`;
349
361
  if (isFunction) {
350
362
  lines.push(`${indent}const ${varName} = ${isAsync ? 'await ' : ''}(${expression})(ctx) as ${portType};`);
351
363
  }
@@ -368,7 +380,10 @@ export function buildNodeArgumentsWithContext(opts) {
368
380
  }
369
381
  else {
370
382
  // Required port has no connection, expression, or default - use typed undefined fallback
371
- const portType = mapToTypeScript(portConfig.dataType, portConfig.tsType);
383
+ const rawPortType4 = mapToTypeScript(portConfig.dataType, portConfig.tsType);
384
+ const isPrimitive4 = /^(string|number|boolean|void|unknown|any|never|null|undefined)(\[\])?$/.test(rawPortType4);
385
+ const paramIndex4 = args.length;
386
+ const portType = isPrimitive4 ? rawPortType4 : `Parameters<typeof ${node.functionName}>[${paramIndex4}]`;
372
387
  lines.push(`${indent}let ${varName}: ${portType} = undefined as unknown as ${portType}; // Required port '${portName}' has no connection`);
373
388
  args.push(varName);
374
389
  emitSetEvent();
@@ -118,7 +118,7 @@ export function generateControlFlowWithExecutionContext(workflow, nodeTypes, isA
118
118
  lines.push(` typeof globalThis !== 'undefined' && (globalThis as unknown as { __fw_debug_controller__?: TDebugController }).__fw_debug_controller__`);
119
119
  lines.push(` ? (globalThis as unknown as { __fw_debug_controller__?: TDebugController }).__fw_debug_controller__`);
120
120
  lines.push(` : { beforeNode: () => true, afterNode: () => {} }`);
121
- lines.push(` );`);
121
+ lines.push(` )!;`);
122
122
  lines.push('');
123
123
  }
124
124
  lines.push(` const startIdx = ctx.addExecution('${RESERVED_NODE_NAMES.START}');`);
@@ -38,9 +38,15 @@ export function mapToTypeScript(portType, tsType) {
38
38
  console.warn(`Unknown port type: ${portType}, defaulting to 'unknown'`);
39
39
  return 'unknown';
40
40
  }
41
- // For non-primitive types, use tsType if provided
41
+ // For non-primitive types, use tsType if provided — BUT strip types
42
+ // that contain absolute paths (import("/absolute/path").Type) which
43
+ // break when the file is compiled on a different machine or moved.
42
44
  if (tsType &&
43
45
  (portType === 'OBJECT' || portType === 'ANY' || portType === 'ARRAY' || portType === 'FUNCTION')) {
46
+ // Strip types with absolute import paths — they break on other machines
47
+ if (tsType.includes('import(')) {
48
+ return mapping.typescript;
49
+ }
44
50
  return tsType;
45
51
  }
46
52
  return mapping.typescript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.22.3",
3
+ "version": "0.22.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",