This repo contains a Mastra weather agent/workflow wired into a Temporal worker.
Only the Mastra side:
src/mastra/index.tssrc/mastra/agents/weather-agent.tssrc/mastra/tools/weather-tool.tssrc/mastra/workflows/*
It does not cover the older AI SDK demo scripts under src/worker.ts / src/client.ts.
- Node.js 22+
- Temporal CLI installed
- An OpenAI API key
npm install
cp .env.example .envSet your API key in .env:
OPENAI_API_KEY=your-api-keyStart a local Temporal server:
temporal server start-devIn another terminal, start the Mastra Temporal worker:
npm run start:mastraThat runs src/mastra/workflows/worker.ts, which:
- connects to Temporal at
localhost:7233 - registers the
weather-workflowtask queue - loads workflow code from
dist/mastra/temporal-workflow.js - captures and registers generated activities
Build the TypeScript project:
npm run buildThis compiles the project into dist/.
src/mastra/index.ts— Mastra app entrypointsrc/mastra/agents/weather-agent.ts— weather agentsrc/mastra/tools/weather-tool.ts— weather toolsrc/mastra/workflows/weather-workflow.ts— workflow definitionsrc/mastra/workflows/worker.ts— Temporal worker bootstrap
- The Mastra agent uses
openai/gpt-5-mini. - The worker expects Temporal on
localhost:7233. - If you change workflow code, rebuild before restarting the worker so
dist/mastra/temporal-workflow.jsis up to date.