Docs/Steps & composition

Steps & composition

Build readable pipelines from focused units of work.

Named steps

A step is the atomic unit inside an action. Its return value is available to every later step on this, under the camel-cased step name.

taskwish.ts
.run(
  Step("normalizeRequest", function () {
    return this.input.request.trim();
  }),

  Step("createAnswer", function () {
    return { answer: this.normalizeRequest.toUpperCase() };
  }),
);

Dependencies

Use .use(...) to declare another service or provider. Call its actions through this.actions. This keeps dependencies explicit and easy to replace in tests.

taskwish.ts
export const { reviewChange } = actor()
  .use(Slack, CodingAgent)

  .on("Command", "reviewChange")

  .input({ changeId: "string" })

  .run(
    Step("loadChange", function () {
      return this.actions.codingAgent.getChange({
        id: this.input.changeId,
      });
    }),

    Step("notify", function () {
      return this.actions.slack.postMessage({
        text: `Reviewed ${this.loadChange.title}`,
      });
    }),
  );

Control flow

Use normal TypeScript for simple decisions and TaskWish composition primitives for observable workflow structure. Agent loop and graph starters demonstrate sequential, parallel, routing, map-reduce, retry, and human-in-the-loop patterns.