Skip to content

wardpeet/temporal-test

Repository files navigation

Mastra + Temporal weather example

This repo contains a Mastra weather agent/workflow wired into a Temporal worker.

What this README covers

Only the Mastra side:

  • src/mastra/index.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/tools/weather-tool.ts
  • src/mastra/workflows/*

It does not cover the older AI SDK demo scripts under src/worker.ts / src/client.ts.

Prerequisites

  • Node.js 22+
  • Temporal CLI installed
  • An OpenAI API key

Setup

npm install
cp .env.example .env

Set your API key in .env:

OPENAI_API_KEY=your-api-key

Run the Mastra worker

Start a local Temporal server:

temporal server start-dev

In another terminal, start the Mastra Temporal worker:

npm run start:mastra

That runs src/mastra/workflows/worker.ts, which:

  • connects to Temporal at localhost:7233
  • registers the weather-workflow task queue
  • loads workflow code from dist/mastra/temporal-workflow.js
  • captures and registers generated activities

Build

Build the TypeScript project:

npm run build

This compiles the project into dist/.

Useful files

  • src/mastra/index.ts — Mastra app entrypoint
  • src/mastra/agents/weather-agent.ts — weather agent
  • src/mastra/tools/weather-tool.ts — weather tool
  • src/mastra/workflows/weather-workflow.ts — workflow definition
  • src/mastra/workflows/worker.ts — Temporal worker bootstrap

Notes

  • 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.js is up to date.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors