Skip to content

Repository files navigation

mastra-on-compute

A Mastra v1 general chat agent running on Fireworks-hosted GLM 5.2, with conversation memory in Prisma Postgres, deployed to Prisma Compute.

Stack

  1. Mastra v1 for the agent runtime and HTTP server.
  2. Fireworks AI GLM 5.2 (accounts/fireworks/models/glm-5p2) as the model, via @ai-sdk/fireworks.
  3. Prisma Postgres as the storage backend for agent memory and telemetry, via @mastra/pg.
  4. Prisma Compute as the deployment target.
  5. Bun as the runtime and script runner, pnpm for package management.

Layout

  1. src/mastra/index.ts registers the Mastra instance, storage, and logger.
  2. src/mastra/agents/chat-agent.ts defines the chat agent.
  3. src/mastra/storage.ts wires PostgresStore to DATABASE_URL.
  4. scripts/chat.ts is a Bun smoke test for the agent.
  5. prisma.compute.ts configures the Compute deployment.

Environment

Copy .env.example to .env and fill in:

  1. FIREWORKS_API_KEY from fireworks.ai.
  2. DATABASE_URL, a Prisma Postgres direct connection string (db.prisma.io, not the pooled endpoint, because the store runs DDL on first boot).

Local development

  1. pnpm install
  2. pnpm dev starts Mastra Studio + the REST API on http://localhost:4111.
  3. pnpm chat "your message" runs a one-shot chat through the agent.

Build

pnpm build runs mastra build, producing a self-contained Hono server in .mastra/output/. Run it with node .mastra/output/index.mjs.

Deploy to Prisma Compute

Mastra is deployed as a generic bun app. Compute runs the build.command from prisma.compute.ts (mastra build), then bundles the resulting .mastra/output/index.mjs entry with its Bun bundler.

  1. pnpm dlx @prisma/cli@latest auth login (browser flow).
  2. Set the deployed app's env vars (DATABASE_URL, FIREWORKS_API_KEY).
  3. pnpm dlx @prisma/cli@latest app deploy for a preview, or app deploy --prod --yes for production.

DATABASE_URL must be set and reachable at deploy time: storage initialises eagerly on boot and the server will not start without it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages