callback-promise-executor.ts 503 B

12345678910
  1. // Callback invocation family: a `new Promise(executor)` whose executor issues an ask. The
  2. // registry says a Promise executor runs once, synchronously and certainly, so the body
  3. // inlines as an entered `call` labelled "Promise" and the ask keeps `always` certainty.
  4. phase("gate");
  5. const gate = await new Promise<string>((resolve) => {
  6. agent("gatekeeper").ask<string>("may we proceed?").then(resolve);
  7. });
  8. phase("act");
  9. const done = await agent("actor").ask<string>(`proceed: ${gate}`);
  10. return done;