Docs/Actors & actions

Actors & actions

Define domain boundaries and callable, typed behavior.

Actor

An actor owns one domain. Calling Actor("Greeter") creates a reusable actor factory. Define public behavior as actions and export the finished service.

src/greeter/greeter.ts
import { Actor } from "taskwish";

export const { actor } = Actor("Greeter");

Command actions

Use .on("Command", name) for public actions. Inputs are runtime-validated and inferred inside every step. Metadata powers labels, descriptions, examples, and controls in Console.

src/greeter/greet.ts
import { Step } from "taskwish";
import { actor } from "./greeter";

export const { greet } = actor()
  .on("Command", "greet")

  .input({ name: "string" })

  .run(
    Step("createGreeting", function () {
      return `Hello, ${this.input.name.trim()}!`;
    }),
  )

  .meta({
    description: "Greet a person by name",
    input: { name: { example: "Ada" } },
  });

Service export

src/greeter/index.ts
import { actor } from "./greeter";
import { greet } from "./greet";

export const { Greeter } = actor().service({ greet });