0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/templates
mastra-platform[bot] b02659fcf1
fix(templates): upgrade mongodb-bedrock-agent to AI SDK v6 to resolve vulnerable dependencies (#30574)
## Summary

Upgrades `templates/template-mongodb-bedrock-agent` to the AI SDK v6
stack used by the other templates, which clears the vulnerable
dependencies we'd held back because the fixes needed major upgrades.

- `ai` ^5.0.289 → ^6.0.332, `@ai-sdk/amazon-bedrock` 3.0.146 (exact pin)
→ ^4.0.216. ai v5's `@ai-sdk/provider-utils@3` pins `undici` 5.x, which
has no patched release. v4 brings `undici` 6.29.1 and drops
`@fastify/busboy`.
- Removes `patch-package`, the `postinstall` script, the `patches/`
directory and the Dockerfile `COPY patches` step. Bedrock v4 already
ships the upstream fix (`BedrockToolUseSchema.input` is optional), and
the patch only existed because that fix wasn't available on ai v5.
Removed the matching notes from CONTRIBUTING.md and AGENTS.md.
- Bumps Mastra packages to current versions (`@mastra/core` ^1.83.0,
memory, mongodb, rag, observability, editor, `mastra` CLI).
- Bumps `@opentelemetry/auto-instrumentations-node` ^0.79 → ^0.83.1 to
fix GHSA-3v2p-hm54-8qcq (moderate). That package needs Node ≥22.15, so
`engines.node` goes from `>=22.13.0` to `>=22.15.0`. The Dockerfile
already uses `node:22-slim`.
- Regenerated `package-lock.json` with npm.

No source code changes were needed. `embed`/`embedMany`,
`createAmazonBedrock`, and the Bedrock `dimensions` provider option work
the same on v6/v4.

## Verification

- `npm ls undici @fastify/busboy shell-quote image-size uuid
follow-redirects proxy-addr`: `undici` 6.29.1 / 7.30.2 and `uuid` 11.1.1
only. No `@fastify/busboy`, and `shell-quote`, `image-size`,
`follow-redirects` and `proxy-addr` are no longer in the tree.
- `npm audit --omit=dev` and `npm audit`: **0 vulnerabilities** (before:
9, 2 high).
- `npx tsc --noEmit` and `npm run build` pass.
- `npx mastra build` succeeds.
- `npm test`: 8 passed, 6 skipped. The skipped tests need
`TEST_MONGODB_URI`, the same as before this change.
- `npm ci --omit=dev` installs cleanly without the postinstall.

Closes Dependabot alerts #3517–#3534 (undici / @fastify/busboy).

Ref SEC-315
Ref SEC-263
Ref SEC-264
Ref SEC-252


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

**ELI5:** This change updates a MongoDB Bedrock agent template to newer
libraries. It removes a patch that is no longer needed, because the
newer Bedrock library includes the fix. It also raises the minimum
Node.js version.

## Summary

This change upgrades the `templates/template-mongodb-bedrock-agent`
template to the AI SDK v6 stack. The `ai` package moves from `^5.0.289`
to `^6.0.332`. `@ai-sdk/amazon-bedrock` moves from the exact version
`3.0.146` to `^4.0.216`. The change also updates Mastra packages,
`@opentelemetry/auto-instrumentations-node` (now `^0.83.1`), and the
`mastra` CLI.

The change removes the Bedrock tool-use workaround. That workaround used
`patch-package`. The author states that Bedrock v4 includes the upstream
fix, so the workaround is no longer needed. The change includes no
source code changes.

### Changes by file

- `package.json`:
- Raises the Node.js requirement (`engines.node`) from `>=22.13.0` to
`>=22.15.0`.
  - Removes the `postinstall` script and the `patch-package` dependency.
- Updates the `ai`, `@ai-sdk/amazon-bedrock`, Mastra, OpenTelemetry
instrumentation, and `mastra` CLI versions.
- `patches/@ai-sdk+amazon-bedrock+3.0.146.patch`: Deleted. The patch
made `input` optional in `BedrockToolUseSchema` in the CommonJS and ESM
bundles.
- `Dockerfile`: Removes the step that copies the `patches` directory
into `/app` before `npm install`.
- `CONTRIBUTING.md`: Removes the section on the pinned
`@ai-sdk/amazon-bedrock` dependency, the `patch-package` workaround, the
`ai` v5 constraint, and the rule that `patch-package` remain a runtime
dependency for `npm ci --omit=dev`.
- `AGENTS.md`: Removes the instruction to keep the pinned Bedrock
provider version and its `patch-package` fix until a deliberate
migration.
- `README.md`: The Prerequisites section now states Node.js 22.15 or
later.

The diff reports 7 changed files, with 1,685 lines added and 2,071
removed. The per-file summaries cover 6 files. The summaries report
about 12 added lines in total, so most of the added lines come from a
file that is not described. That file is probably a lockfile, but this
summary does not confirm it.

### Reported verification (author-reported, not independently confirmed)

- `npm audit --omit=dev` and `npm audit`: 0 vulnerabilities.
- `npx tsc --noEmit`, `npm run build`, and `npx mastra build`:
succeeded.
- `npm ci --omit=dev`: installed without the postinstall script.
- `npm test`: 8 passed, 6 skipped. The skipped tests require
`TEST_MONGODB_URI`.
- `npm ls undici @fastify/busboy shell-quote image-size uuid
follow-redirects proxy-addr`: results reported by the author, not
summarized here.

The PR states that it closes Dependabot alerts `#3517`–#3534. It
references SEC-315, SEC-263, SEC-264, and SEC-252.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
History 2026-11-16 16:33:34 -05:00
..
template-accounts-payable-invoice-processing feat(templates): add accounts payable invoice processing (#28532) 2026-10-27 22:49:27 +00:00
template-agent-builder docs: declare node types in tsconfig examples (#27974) 2026-10-21 11:51:24 +02:00
template-agent-harness chore(templates): make template-agent-harness AGENTS.md concise and warn about outdated training data (#29834) 2026-11-09 16:29:40 -07:00
template-browser-agent feat(templates): read the model from AGENT_MODEL in Browser Agent (#29748) 2026-11-09 18:02:27 +00:00
template-browsing-agent docs(templates): surface browsing-agent demo video and remove stray README header images (#23983) 2026-09-15 13:20:37 +02:00
template-chat-with-pdf docs(templates): surface browsing-agent demo video and remove stray README header images (#23983) 2026-09-15 13:20:37 +02:00
template-chat-with-youtube chore: migrate workspace to pnpm v11 (#17038) 2026-05-28 09:45:07 -07:00
template-claw-assistant feat(templates): read the model from AGENT_MODEL in Claw Assistant (#29747) 2026-11-09 18:02:00 +00:00
template-company-knowledge feat(templates): use Mastra Connect in the company knowledge template (#29745) 2026-11-09 18:02:19 +00:00
template-competitor-monitor-jev security: Vanta remediation pass 2026-10-14/15/19 (zod 4.6.7, @ai-sdk/provider-utils, @copilotkit template) (#27023) 2026-10-19 11:32:32 -07:00
template-connect-agent feat(templates): read the model from AGENT_MODEL in Personal Agent (#29749) 2026-11-09 18:02:10 +00:00
template-csv-to-questions draft: Add MastraPlatformExporter and MastraStorageExporter, deprecate CloudExporter and DefaultExporter (#16223) 2026-05-11 15:51:43 +02:00
template-customer-feedback-summarization chore: migrate workspace to pnpm v11 (#17038) 2026-05-28 09:45:07 -07:00
template-customer-refund-agent chore(deps): Vanta 2026-11-12 — raise undici to 8.12.4 / 7.30.2 (#30205) 2026-11-12 07:20:12 -08:00
template-deep-search docs(templates): surface browsing-agent demo video and remove stray README header images (#23983) 2026-09-15 13:20:37 +02:00
template-docs-chatbot docs(templates): update template READMEs (#25469) 2026-09-29 23:14:55 -07:00
template-docs-expert feat(templates): read the model from AGENT_MODEL in Docs Expert (#29746) 2026-11-09 18:01:54 +00:00
template-factory chore(templates): tighten Factory template .env.example comments (#28749) 2026-11-10 21:24:55 -08:00
template-factory-self-hosted chore(templates): tighten Factory template .env.example comments (#28749) 2026-11-10 21:24:55 -08:00
template-flash-cards-from-pdf draft: Add MastraPlatformExporter and MastraStorageExporter, deprecate CloudExporter and DefaultExporter (#16223) 2026-05-11 15:51:43 +02:00
template-genui-data-explorer chore(deps): Vanta 2026-11-11 fixes (effect, fast-xml-parser, react-router-dom, @whatwg-node/fetch) (#30061) 2026-11-11 08:19:18 -08:00
template-github-review-agent docs(templates): update template READMEs (#25469) 2026-09-29 23:14:55 -07:00
template-google-sheets fix: bump vulnerable dependencies to patched releases (#24027) 2026-09-15 13:58:48 -07:00
template-insurance-policy-checking chore(deps): update build tools (major) (#29026) 2026-11-03 20:18:21 +01:00
template-kyc-customer-onboarding chore(deps): template updates for the MongoDB Bedrock pins and @hono/node-server 2.1.6 (#30218) 2026-11-12 16:16:58 -08:00
template-lead-qualification feat(templates): add lead qualification template (#27839) 2026-10-21 09:44:58 +01:00
template-meeting-notes chore: unify built-in Gateway naming (#18691) 2026-07-13 17:26:20 +02:00
template-mongodb-bedrock-agent fix(templates): upgrade mongodb-bedrock-agent to AI SDK v6 to resolve vulnerable dependencies (#30574) 2026-11-16 16:33:34 -05:00
template-organization-intelligence chore(deps): Vanta 2026-11-11 fixes (effect, fast-xml-parser, react-router-dom, @whatwg-node/fetch) (#30061) 2026-11-11 08:19:18 -08:00
template-personal-assistant feat(templates): Add personal assistant template (#29886) 2026-11-11 08:23:18 -08:00
template-security-incident-triage chore(deps): template updates for the MongoDB Bedrock pins and @hono/node-server 2.1.6 (#30218) 2026-11-12 16:16:58 -08:00
template-starter-agent feat(templates): read AGENT_INSTRUCTIONS and AGENT_MODEL in starter agent (#27282) 2026-10-16 10:48:12 -04:00
template-text-to-sql chore(repo): Use tsx catalog dep (#17605) 2026-06-05 13:44:28 +02:00
template-vendor-risk-questionnaire chore(deps): Vanta 2026-11-11 fixes (effect, fast-xml-parser, react-router-dom, @whatwg-node/fetch) (#30061) 2026-11-11 08:19:18 -08:00
weather-agent docs: fix onboarding quickstart, pnpm version, and template metadata (#23754) 2026-09-15 09:40:58 +02:00
.gitignore update pdf-to-audio-template (#7512) 2025-09-10 11:34:50 +01:00
README.md feat(templates): add template-starter-agent (#25451) 2026-09-30 10:01:12 -07:00

Mastra templates

This directory contains standalone Mastra project templates.

New Gateway-first templates

  • template-docs-expert: Answers documentation questions with Gateway web search, citations, memory, and structured responses.
  • template-browser-agent: Uses AgentBrowser to browse, inspect, and interact with web pages.
  • template-meeting-notes: Turns Zoom transcripts or uploaded transcripts into structured notes with decisions and action items.
  • template-company-knowledge: Indexes Linear and Notion content into pgvector and answers internal knowledge questions.
  • template-claw-assistant: Operates a workspace with filesystem, sandbox, browser, and web-search tools.
  • template-connect-agent: Turns Mastra platform integration connections into live agent tools with @mastra/connect, plus a cross-integration activity-digest workflow.
  • template-starter-agent: Starter Agent — durable agent harness with @mastra/connect tools and channels, a platform-backed workspace, Studio agent/workflow editing via @mastra/editor, Postgres storage, and Redis-backed resumable streams.

How to add a new template

To add a new template to the templates/ directory, follow these steps:

1. Create a new template folder

  • Inside the templates/ directory, create a new folder named after your template (e.g., my-new-template/).

2. Required files

Your template folder must include the following files:

a. package.json

  • Use OpenAI as the LLM provider in your code/config.
  • All @mastra/* dependencies should be set to "latest" in the dependencies section.
  • mastra devDependency should be set to "latest" in the devDependencies section.
  • The description field should clearly describe what the template does.

b. .env.example

  • List all required environment variables, such as API keys and configuration values.

c. README.md

Follow this template for your README.md:

# Title

Introductory paragraph describing what this template does.

## Why we built this

Explain the motivation behind creating this template and the problem it solves. And which features of Mastra it demonstrates.

## Demo

This demo runs in Mastra Studio, but you can connect this workflow to your React, Next.js, or Vue app using the [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) or agentic UI libraries like [AI SDK UI](https://mastra.ai/guides/build-your-ui/ai-sdk-ui), [CopilotKit](https://mastra.ai/guides/build-your-ui/copilotkit), or [Assistant UI](https://mastra.ai/guides/build-your-ui/assistant-ui).

## Prerequisites

- [OpenAI API key](https://platform.openai.com/api-keys): Used by default, but you can swap in any model

## Quickstart 🚀

1. **Clone the template**
   - Run `npx create-mastra@latest --template TEMPLATE_NAME` to scaffold the project locally.
2. **Add your API keys**
   - Copy `.env.example` to `.env` and fill in your keys.
3. **Start the dev server**
   - Run `npm run dev` and open [localhost:4111](http://localhost:4111) to try it out.

## Making it yours

Explain how they can use it and how they can customize it for their needs.

## About Mastra templates

[Mastra templates](https://mastra.ai/templates) are ready-to-use projects that show off what you can build — clone one, poke around, and make it yours. They live in the [Mastra monorepo](https://github.com/mastra-ai/mastra) and are automatically synced to standalone repositories for easier cloning.

Want to contribute? See [CONTRIBUTING.md](./CONTRIBUTING.md).

d. CONTRIBUTING.md

Create a CONTRIBUTING.md file:

# Contributing

This repository is auto-generated from the [Mastra monorepo](https://github.com/mastra-ai/mastra). Pull requests opened here will be ignored.

To contribute:

1. Fork the [Mastra monorepo](https://github.com/mastra-ai/mastra)
2. Find this template in `templates/TEMPLATE_NAME`
3. Make your changes
4. Open a pull request against the monorepo

A bot syncs accepted changes to this repository.