@ekairos/tasks

Task domain library.

Durable tasks with typed outcomes for approvals, reviews, handoffs, and any workflow step that must wait for a decision.

install @ekairos/tasks@betaroot task_taskssurface outcome

Schema

task_tasks

Task record with kind, key, state, instructions, context, outcome schema, outcome, error, and timestamps.

Actions

openTask

Creates or reuses a durable task, usually idempotent by key.

getTask

Reads the current task state and stored outcome metadata.

awaitOutcome

Waits until a task has a typed outcome or reaches a terminal state.

decideTask

Stores a typed outcome and closes the task.

cancelTask / failTask

Closes the task without a successful domain outcome.

Open a typed review task.

The task package owns state and outcome validation. Assignment, approvers, notifications, and product links stay in the app/domain layer.

import { Task } from "@ekairos/tasks";
import { z } from "zod";

const reviewOutcome = z.object({
  accepted: z.boolean(),
  comment: z.string().optional(),
});

const task = await Task.open(runtime, {
  kind: "review",
  key: "review:execution_1:step_1",
  outcome: reviewOutcome,
  instructions: "Review the generated supplier response.",
  context: { executionId: "execution_1" },
  outcomeKind: "review",
});

const outcome = await task.outcome();