this-field-read-in-method.ts 502 B

1234567891011121314
  1. // Idiomatic OOP: the constructor stores an artifact in a field, a method reads this.field
  2. // to build a new ask and returns it. Both the this-read edge and the method-return edge
  3. // must survive. Expected: source -> ask#1, ask#1 -> ask#2, ask#2 -> sink.
  4. const seed = await agent("a").ask<string>("seed");
  5. class Pipeline {
  6. seed: string;
  7. constructor(v: string) {
  8. this.seed = v;
  9. }
  10. run() {
  11. return agent("b").ask<string>(`refine ${this.seed}`);
  12. }
  13. }
  14. return await new Pipeline(seed).run();