then-callback.ts 570 B

12345678
  1. // .then callback on a Node<T> result (Node<T> extends PromiseLike<T>). Runtime:
  2. // writer produces a draft; the .then callback runs the editor ask with text =
  3. // draft's resolved output; editor's result becomes `edited` and is returned.
  4. // The keystone rule (unknown calls apply their function arguments) must route
  5. // draft's taint INTO the callback param and the callback's return OUT to the sink.
  6. const draft = agent("writer").ask<string>("write a draft");
  7. const edited = await draft.then((text) => agent("editor").ask<string>(`edit this: ${text}`));
  8. return edited;