LEVEL 3 · ENGINEER

Typed Workflow Agent with Mastra

Build a typed approval workflow, then preserve and resume real Mastra suspension through a local SQLite store.

4 stages~8 hoursTypeScriptcore
Validate typed step inputs at runtimeMake the approval invariant explicit in the planSuspend before effects and count failed attemptsPersist real Mastra approval state and resume it
YOU END UP WITH

A scratch HTML/JSON workflow review and a real Mastra run stored in SQLite with a plan-bound approval document.

USEFUL FOR
  • A scratch HTML/JSON workflow review and a real Mastra run stored in SQLite with a plan-bound approval document.
LEARN FIRST
  • TypeScript object types, unions and async functions.
  • Runtime validation of unknown JSON input.
  • An explicit approval decision and a local database file.
PROJECT OUTLINE

Typed Workflow Agent with Mastra in 4 stages

Build a typed approval workflow, then preserve and resume real Mastra suspension through a local SQLite store.

  1. Validate typed step inputs at runtime

    Find the workshop policy produces read intent. Update the workshop label produces write intent. A blank ID fails before a tool is chosen. The word change inside unchanged does not match the mutation-verb word boundary.

    starter · ~2 hours · TypeScript

    runtime contractsintent baselinetyped outputs
  2. Make the approval invariant explicit in the plan

    An update action with requiresApproval=false fails. A lookup-only plan with requiresApproval=true also violates the stated representation. One through ten actions are allowed, and every action has a supported tool and nonempty query.

    core · ~2 hours · TypeScript

    plan validationcapability selectionapproval invariant
  3. Suspend before effects and count failed attempts

    A lookup returning a result completes in one call. A tool returning empty text twice fails after two calls. A write without approval returns a checkpoint and zero calls; resuming that checkpoint with approved=true executes the original query.

    core · ~2 hours · TypeScript

    retry limitscall budgetscheckpoint results
  4. Persist real Mastra approval state and resume it

    Start the authored workshop update and observe status=suspended with zero tool calls. Close the local LibSQL store, create a fresh workflow over the same SQLite file and resume by runId. Matching approval produces success and exactly one observed local tool call in the recovery test; a wrong hash fails with zero calls.

    core · ~2 hours · TypeScript

    Mastra suspensionplan-bound approvalSQLite recovery

All projects · Course catalog · Source on GitHub