handoff-family-to-family.ts 795 B

12345678910111213
  1. // Two literal fan-outs in one script, the second consuming the first's results. The
  2. // analyzer cannot pair member i with member i, so the hand-off is the honest complete
  3. // bipartite may-relation: 2 writers × 2 critics = 4 edges. A third fan-out iterates the
  4. // drafts themselves (an ask result) — unknowable length, so one `many` card.
  5. interface Draft {
  6. text: string;
  7. }
  8. const PAIR = ["a", "b"];
  9. const CRITICS = ["x", "y"] as const;
  10. const drafts = await Promise.all(PAIR.map((t) => agent(`writer-${t}`).ask<Draft>(`write ${t}`)));
  11. const reviews = await Promise.all(CRITICS.map((c) => agent(`critic-${c}`).ask<string>(`critique ${JSON.stringify(drafts)}`)));
  12. const echoes = await Promise.all(drafts.map((d) => agent("echo").ask<string>(`echo ${d.text}`)));
  13. return [...reviews, ...echoes];