helper-flow-through.ts 560 B

1234567891011121314
  1. // Context-sensitive returns: `relay` returns its argument. Called with two distinct
  2. // ask results, each feeding a distinct downstream ask. The two chains must NOT
  3. // cross-contaminate: ask#1 -> ask#3 and ask#2 -> ask#4 only (no ask#1 -> ask#4).
  4. function relay(v: string): string {
  5. return v;
  6. }
  7. const a = await agent("a1").ask<string>("A");
  8. const b = await agent("b1").ask<string>("B");
  9. const ra = relay(a);
  10. const rb = relay(b);
  11. const c = await agent("c1").ask<string>(`use ${ra}`);
  12. const d = await agent("d1").ask<string>(`use ${rb}`);
  13. return `${c} ${d}`;