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.
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.
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" } }, });
Scheduled actions
Use a Schedule action for recurring work. It exports as onSchedule by default; add command when the job needs a domain-specific name. The server validates the expression, starts the job, prevents overlapping runs by default, and stops it during shutdown.
export const { revenueMonitor } = actor() .on("Schedule", "0 9 1 * *") .command("revenueMonitor") .run( Step("refreshRevenue", function () { return refreshFor(this.input.at); }), );
Service export
import { actor } from "./greeter"; import { greet } from "./greet"; export const { Greeter } = actor().service({ greet });