iteration-fanout-unknown-chain.ts 619 B

123456789101112
  1. // Unknown array calls in a chain before a fan-out: .flat() on a nested tracked array
  2. // and .filter(Boolean) (named callback, non-candidate) must both preserve flow; the
  3. // final map promotes.
  4. // Expected: source -> ask#1, source -> ask#2; ask#1/ask#2 -> fan-out#1;
  5. // ask#1/ask#2 -> ask#3; fan-out#1 -> ask#3; ask#1/ask#2/fan-out#1/ask#3 -> sink.
  6. const a = await agent("a").ask<string>("one");
  7. const b = await agent("b").ask<string>("two");
  8. const nested = [[a], [b]];
  9. const flatv = nested.flat();
  10. const hits = flatv.filter(Boolean);
  11. const outs = hits.map((h) => agent("judge").ask<string>(h));
  12. return outs;