mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
24 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c22107fce3 |
chore(deps): update dependency @ai-sdk/provider-utils@>=3.0.0 <3.0.38 to v3.0.45 (#29844) | ||
|
|
4bd4b7f48e |
chore(deps): update better-auth monorepo to v1.7.18 (#29714)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
||
|
|
bfe3af4ae1 |
chore(deps): update better-auth monorepo to v1.7.15 (#29497) | ||
|
|
9ce7e350ea |
chore(deps): lock file maintenance (#29341)
Co-authored-by: wardpeet <ward@coding-tech.com> Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
f6cd11f348 |
chore(deps): lock file maintenance (#28672)
This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/9505) for more information. 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - "before 6am on wednesday" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://redirect.github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xOTAuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE5MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0aW9uIl19--> --------- Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
07c1bf2362 |
chore(deps): update dependency @ai-sdk/provider-utils@>=3.0.0 <3.0.38 to v3.0.42 (#28773) | ||
|
|
f2ad3844f3 |
chore(deps): update opentelemetry (#28581)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
29747ebd1d |
chore(deps): update better-auth monorepo to v1.7.13 (#28538)
This PR contains the following updates: | Package | Type | Update | Change | Pending | |---|---|---|---|---| | [@better-auth/drizzle-adapter@<1.7.7](https://www.better-auth.com/docs/adapters/drizzle) ([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/drizzle-adapter)) | pnpm-workspace.overrides | patch | [`1.7.7` → `1.7.13`](https://renovatebot.com/diffs/npm/@better-auth%2fdrizzle-adapter@<1.7.7/1.7.7/1.7.13) | `1.7.14` | | [better-auth](https://better-auth.com) ([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth)) | pnpm-workspace.overrides | patch | [`^1.7.7` → `^1.7.13`](https://renovatebot.com/diffs/npm/better-auth/1.7.7/1.7.13) | `1.7.14` | | [better-auth](https://better-auth.com) ([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth)) | dependencies | patch | [`^1.7.12` → `^1.7.13`](https://renovatebot.com/diffs/npm/better-auth/1.7.12/1.7.13) | `1.7.14` | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/9505) for more information. --- ### Release Notes <details> <summary>better-auth/better-auth (@​better-auth/drizzle-adapter@<1.7.7)</summary> ### [`v1.7.13`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1713) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.12...v1.7.13) ### [`v1.7.12`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1712) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.11...v1.7.12) ### [`v1.7.11`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1711) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.10...v1.7.11) ### [`v1.7.10`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1710) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.9...v1.7.10) ### [`v1.7.9`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#179) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.8...v1.7.9) ### [`v1.7.8`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#178) [Compare Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.7...v1.7.8) ##### Patch Changes - [#​11512](https://redirect.github.com/better-auth/better-auth/pull/11512) [`4175b34`]( |
||
|
|
82e82fb5a7 |
chore(deps): update security updates [security] (#27869)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
||
|
|
4f60903242 |
chore(deps): lock file maintenance (#27013) | ||
|
|
fa409d430b |
security: Vanta remediation pass 2026-10-14/15/19 (zod 4.6.7, @ai-sdk/provider-utils, @copilotkit template) (#27023) | ||
|
|
7aec8b0d95 |
security: Vanta remediation pass 2026-10-12 (better-auth, MCP SDK) (#26773)
## Summary Vanta remediation for 2026-10-12. Target list is today's live export (77 findings, 44 unique IDs). Platform findings are handled in mastra-ai/platform#3317. ### What changed | Package | From → To | Findings | Where | How | |---|---|---|---|---| | better-auth | 1.7.5 → 1.7.7 | AIKIDO-2026-373183 (Critical) | root + `examples/agent` | raise override `better-auth: ^1.7.7`; direct dep `@mastra/auth-better-auth` ^1.7.7 | | @better-auth/drizzle-adapter | 1.7.5 → 1.7.7 | AIKIDO-2026-261025 (Low) | root + `examples/agent` | floor `'@better-auth/drizzle-adapter@<1.7.7': 1.7.7` (also pulled by better-auth 1.7.7) | | @modelcontextprotocol/sdk | 1.31.0 → 1.32.1 | AIKIDO-2026-365378 (High), -156139, -344432 | root, nested locks, `scripts/gh-issue-triage` | raise floor to `<1.32.0 → 1.32.1`; bump direct pins/ranges | Nested `pnpm-workspace.yaml` floors raised in e2e-tests/*, examples/*, integration-tests, etc., and those lockfiles regenerated. Versions used were published >24h ago (minimumReleaseAge). Patch changeset included for published packages whose dependency ranges changed. Aikido lens on this branch: better-auth and MCP SDK findings are gone. OSV: handlebars already clear on main; remaining high are braces/extract-zip (no patch). ### Left as-is (no patch, or major-only) - extract-zip ≤2.0.1: no fix (overdue; removed by #25855 when that lands). Needs Vanta risk acceptance. - braces 3.0.3, sprintf-js 1.0.3/1.1.3: no patched release - postcss-selector-parser 6.x: @tailwindcss/typography pins 6.0.10 - katex 0.16: mermaid declares ^0.16.47 - @ag-ui/client 0.0.59: fix only in 1.0.0 (major). Parent `@copilotkit/channels-*` 0.11.0 pins 0.0.59 exactly (template-genui-data-explorer) - @hono/node-server 1.19 (fix 2.1.3), undici 6.29 (fix 7.23/8.10), raw-body 3 in templates (fix 4), bundle-name 3 (fix 4.1.1), got 15 (fix 16), zod 3.25 (fix 4.x), @bufbuild/protobuf 1.10 (fix 2.x), openai 6.49 (fix 7.x), jose 5.10 via @segment/analytics-node in template (fix 6.x), @ai-sdk/provider-utils 2.2.8 / 3.0.x Aikido ranges wanting 4.0.18+: major-only or scanner range noise Do not merge unless reviewed. No CI weakened. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR updates shared dependency versions so the project uses newer releases of Better Auth and the MCP SDK. It also updates workspace rules to keep older versions from being selected. ## Changes - Updated Better Auth requirements and workspace overrides to `^1.7.7`. - Updated `@modelcontextprotocol/sdk` requirements and overrides to `1.32.1` across affected packages and workspaces. - Added overrides for older `@better-auth/drizzle-adapter` versions to use `1.7.7`. - Added a patch changeset for `@mastra/auth-better-auth`, `@mastra/mcp-registry-registry`, and `@mastra/playground-ui`. Test results and review findings were not provided. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
84143a892e |
feat(livekit)!: prepare 0.5.0 with recording and speech metrics (#24674)
Prepare the LiveKit 0.5.0 release with opt-in call recording and Studio
playback. `dispatchVoiceSession()` and `liveKitConnectionRoute()` can
create a fresh room with LiveKit auto egress before dispatching the
agent. The recording route resolves an authorized trace to a short-lived
playback URL, and Studio exposes it through **Review Audio**.
```ts
await dispatchVoiceSession({
roomName: `call-${crypto.randomUUID()}`,
metadata: { agentId: 'support' },
recording, // Server-side LiveKit output settings.
});
```
Recording review requires an explicit `authorize({ traceId, context })`
callback. Only `true` permits trace lookup and playback URL resolution;
missing policies fail at registration. Recording room conflicts return
HTTP 409. The example and documentation cover S3 configuration, scoped
permissions, consent, and recording lifecycle implications. Browser
recording creation and playback in the unauthenticated example require
an explicit local-demo opt-in and are disabled in production.
The browser-safe `@mastra/livekit/client` entry point provides
`getLiveKitRecording(client, traceId)`, preserving the client's
authentication and request configuration. Studio uses the supported
React hook subpaths from main.
The integration also adds common per-turn metrics, speech-flush
boundaries, and an `onSpeechComplete` hook. `onTurnComplete` retains its
generation-only behavior. Custom reply-generator consumers must handle
flush boundaries, and `MastraLLM` integrations should use
`mastraLLMNode`. Playback completion describes server delivery, not
proof that the listener heard the audio.
The VAD opt-out is fixed. LiveKit Agents 1.7.1 is the supported minimum
and migration target, with matching plugin peer ranges and upgrade
instructions. The planned stable release remains **0.5.0**.
### Validation
- All 280 LiveKit tests across 22 files passed.
- All 18 Studio voice and recording-review tests passed.
- A local synthetic probe passed 96 example route-policy cases covering
room creation, dispatch, unrecorded tokens, storage access, and denied
playback.
- LiveKit, React SDK, shared Studio UI, and production Studio builds
passed.
- LiveKit, Studio, and voice-agent example typechecks passed; focused
lint and documentation checks passed.
- Production bundle inspection confirmed that the recording client adds
no LiveKit server or worker modules to the browser bundle.
- Changeset planning retains the 0.5.0 release target.
The core working-memory configuration fix and its regression tests are
in #26090 for separate review.
|
||
|
|
bf0dd07091 |
security: Vanta remediation pass 2026-10-05 (#25966)
Update 2026-10-06 (commits added on this branch; origin/main merged in to clear the lockfile conflict) Dependabot opened new alerts overnight (4 critical). This pass adds: - braintrust ^3.24.0 -> ^3.36.0 in @mastra/braintrust. braintrust 3.27 pulled in simple-git 3.36.0, which has critical and high advisories (GHSA-x6jw-m9v5-85vh, GHSA-v5rq-49vh-5v5c via @simple-git/argv-parser 1.1.1, GHSA-858h-whjf-mvg5, GHSA-g4wm-2vf7-vfgr). Those are only fixed in simple-git 4. braintrust 3.36 no longer depends on simple-git, so simple-git drops out of the lockfile. @mastra/braintrust only uses initLogger and currentSpan. - wrangler ^4.110.0 -> ^4.147.0 (devDependency of @mastra/deployer-cloudflare, type-only import). This moves workerd 1.20260708.1 -> 1.20261001.1 on that chain (Aikido medium). workerd 1.20260714.1 is still there through the miniflare 4 devDependency in stores/cloudflare and stores/cloudflare-d1. - source-map-js 1.2.1 -> 1.2.2 (GHSA-68fv-2mgg-jv7q, high). Added the floor `source-map-js@>=1.0.0 <1.2.2: 1.2.2` in the root and in 15 nested pnpm workspaces (9 e2e projects, mastracode/web, otel-bridge agent-hub and hono-multi, agent-builder, mcp and memory integration-tests). postcss, css-tree, magicast and @tailwindcss/node all declare ^1.2.x. In the customer-refund template, a plain npm lock refresh was enough (no override). - postcss-selector-parser: raised the existing floor from `>=7.1.0 <7.1.3: 7.1.3` to `>=7.1.0 <7.1.6: 7.1.6` (GHSA-rj75-hqrm-r3gf, medium). - observability/_examples/otel-bridge/hono-multi: tsx catalog ^4.21.0 -> ^4.23.15. tsx 4.23 uses esbuild ~0.28, so esbuild 0.27.2 is gone (Aikido high and low, fixed in 0.28.1). - Changeset `.changeset/vanta-2026-10-06.md`: patch for @mastra/braintrust. Still not fixed (as of 2026-10-06) - sprintf-js 1.0.3/1.1.3 (GHSA-hp3w-g68c-fv3c): no patched release. - postcss-selector-parser 6.0.10/6.1.3: the fix is only in 7.1.6. @tailwindcss/typography 0.5.20 pins 6.0.10 exactly, and cssnano 6/postcss-calc 9 use ^6. - katex 0.16.47 (GHSA-238p-pmpm-9mq7, low): the fix is in 0.18.2. mermaid 12.1.0 still declares ^0.16.47. - http-cache-semantics: 4.3.0 is now older than 24h, but it still doesn't touch the max-stale path, and the advisory still lists no patched version. - braces 3.0.3 has no new release. - The rest of the deferred list below is unchanged. --- Vanta remediation for 2026-10-05. The finding list was rebuilt from GitHub Dependabot, OSV-scanner on every tracked lockfile, and Aikido intel (full intel.aikido.dev feed re-pulled today). It is not a Vanta export. What changed Package bumps - probe-image-size ^7.2.3 -> ^7.4.0 in @mastra/memory (GHSA-gjj5-9665-rwrc, high). - verdaccio ^6.10.4 -> ^6.10.5 in the 9 e2e projects. That moves @verdaccio/core to 8.3.2 and js-yaml 5.2.2 -> 5.4.1 (GHSA-r3ph-w7gj-g6xm, medium). - smol-toml 1.8.0 -> 1.9.0 pin in @mastra/code-sdk. Root lockfile refresh (no range changes) - serialize-javascript 7.0.5 -> 7.1.2, shell-quote 1.10.0 -> 1.12.0, ws 7.5.11 -> 7.5.13, enhanced-resolve -> 5.26.0, fs-extra 11.3.5 -> 11.4.1, @sinclair/typebox 0.27.8 -> 0.27.12, @zip.js/zip.js 2.8.26 -> 2.23.0, memfs/@jsonjoy.com/fs-snapshot 4.57.2 -> 4.80.0, @vue/* 3.5.38 -> 3.5.43. pnpm overrides, for parents that pin an exact vulnerable version. All stay in the same major. - modern-tar 0.7.7 (just-bash), smol-toml 1.9.0 (just-bash, @blaxel/core, @react-grab/cli, modal), strnum 2.4.2 (fast-xml-parser 5.10.1), inline-style-parser 0.2.9 (style-to-object 1.0.11), `@opentelemetry/configuration>yaml` 2.9.1 (sdk-node 0.221). Nested lockfiles - shell-quote floor raised from <1.10.0 to <1.11.0 in examples/agent, examples/voice-agent and otel-bridge/agent-hub. - yaml 2.9.0 -> 2.9.1 in e2e-tests/pkg-outputs, examples/durable-agents, mastracode/web, packages/mcp/integration-tests and the customer-refund template. - next 16.3.6 -> 16.3.8 in packages/memory/integration-tests. - customer-refund template: tinypool 2.1.0 -> 2.1.2 through an override scoped to oxfmt. oxfmt 0.59 pins it exactly, and bumping oxfmt would change the template's format check. Not fixed here - braces 3.0.3 (GHSA-vfj7-8cjw-p6xm) and http-cache-semantics 4.2.0 (GHSA-ch52-4w7c-c8xp): no patched release. http-cache-semantics 4.3.0 is outside the advisory range, but it doesn't change the max-stale code path, so bumping to it would only hide the alert. - extract-zip 2.0.1: no patched release. It comes from the webdriverio chain that #25855 removes. - workerd 1.20260708/1.20260714 (Aikido medium): miniflare 4.x stops at workerd 1.20260730. The fix needs miniflare 5, which is only published as an alpha. - Major-only: @ai-sdk/provider-utils 2.2.8 / ai 4.3.19 (AI SDK v4), @opentelemetry/core 1.30.1, esbuild 0.18/0.25/0.27.0 (convex pins 0.27.0 exactly), js-yaml 3, brace-expansion 1/2, uuid 11, zod 3, pino 8/9, undici 6, plus other Aikido lows. - websocket-driver 0.7.5: Aikido says the fix is 0.8.x, but no 0.8 is published on npm. The changeset is a patch for @mastra/memory and @mastra/code-sdk. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR updates several dependencies that have security fixes. It also adds version rules so nested projects use safer versions of related packages. ## Changes - Updates `probe-image-size` in `@mastra/memory` to `^7.4.0` and pins `smol-toml` in `@mastra/code-sdk` to `1.9.0`. - Updates Verdaccio to `^6.10.5` in nine end-to-end test projects. - Raises `shell-quote` overrides to `1.11.0` and adds overrides for transitive dependencies, including `yaml`, `source-map-js`, `postcss-selector-parser`, `modern-tar`, `smol-toml`, `strnum`, `inline-style-parser`, and `tinypool`. - Updates `braintrust` to `^3.36.0`, `wrangler` to `^4.147.0`, and `tsx` to `^4.23.15`. - Adds patch changesets for `@mastra/memory`, `@mastra/code-sdk`, and `@mastra/braintrust`. The changesets report no API changes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
4358322b7b |
chore(deps): override upstream-blocked vulnerable transitive deps (#25853) | ||
|
|
aeddbc9909 |
security: Vanta 2026-09-28 residuals (template proxy-addr, nested undici/next/shell-quote/form-data, OTEL, onnxruntime) (#25344) | ||
|
|
7b777d38d9 |
security: Vanta zero pass 2026-09-23 (grpc/compression/provider-utils floors) (#24848) | ||
|
|
2592c7226a |
chore(deps): lock file maintenance (#19457)
This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - "before 6am on wednesday" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://redirect.github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjMuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0aW9uIl19--> |
||
|
|
3356bf3dd0 |
chore(docs): AX improvements (#19631) | ||
|
|
2e858270c6 |
chore(deps): lock file maintenance (#19080)
Co-authored-by: wardpeet <ward@coding-tech.com> |
||
|
|
f701530e7a |
docs(react): add narrow API responsibility rule (#19336)
Adds a React best-practices rule for components, hooks, functions, and utilities with oversized input or output APIs. It clarifies that wrapping the same values in one object does not reduce responsibility and shows how to split broad hooks into focused units composed at the component level.\n\nThe rule catalog and quick reference now include the new guidance and updated rule counts. Documentation structure, links, counts, and fenced examples were validated. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR adds a new React “best practice” rule: if a component/hook/function is taking in (or returning) too much at once, you should split it into smaller, clearer pieces and then combine them where it’s used. It also updates the rule catalog and adds a bit of formatting/coverage cleanup in the voice-agent example tests. ## Changes - Added a new React best-practices rule: `structure-narrow-apis` (“Keep Input and Output APIs Narrow”) for components, hooks, functions, and utilities. - Clarified that wrapping unrelated things into a single parameter/return object doesn’t truly narrow responsibility. - Included incorrect vs. correct examples showing how to split an oversized “mega-hook” into focused hooks and compose them in a container/component. - Updated the React best-practices rule catalog/quick reference (version and rule/category counts), adding the new rule entry and revising totals from 25 to 26 rules. - Reformatted and lightly adjusted voice-agent example smoke coverage and related example code without changing core behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
25c1a4f6c0 |
feat(livekit): grouped worker configuration + MastraLLM plugin + voice-agent example (#19136)
## Description This is the final PR of the stack split from #19019: memory summarization (#19135, merged) → **livekit worker configuration + MastraLLM plugin + voice-agent example (this PR)**. The example PR (#19137) was consolidated into this one after review feedback landed, so the package changes and the runnable example that exercises them ship and get reviewed together. > **Note for reviewers:** Tyler's split request listed the worker `configuration` surface; the `MastraLLM` plugin work landed on the original branch after that comment. Both are `@mastra/livekit` package code, so they ride together here — happy to split the plugin into its own 4th PR if you'd rather review it separately. ### `@mastra/livekit` — new grouped `configuration` worker option One home for conversation & compliance policy on `createLiveKitWorker`, so each control doesn't become another top-level option: - **`configuration.greeting` — AI disclosure controls.** `text` spoken at call start; `allowInterruptions: false` so a legally-required AI disclosure plays through and can't be barged over (EU AI Act Art. 50); `awaitPlayout: true` holds post-greeting work (persistence, `onSessionStart`) until it finishes; `persist` saves it to the memory thread; `repeatEvery`/`repeatText` re-disclose periodically on long calls, spoken at the next turn boundary, never mid-sentence (CA SB 243-style requirements). - **Per-tenant dynamic greeting.** `greeting.text` also accepts a resolver `({ metadata, requestContext, roomName, ctx }) => string | undefined`, resolved once per call *post-connect* — so one shared multi-tenant agent opens with each tenant's own brand/disclosure phrasing keyed off dispatch metadata / request context. - **`configuration.stt` / `configuration.tts` — per-call resolvers.** Pick the transcriber and voice per call — one voice or language per tenant — falling back to the top-level `stt`/`tts` when they return `undefined`. - **`configuration.consentPolicy` — named consent model.** (Renamed from `requireConsent` per review — it is declarative only; the worker enforces nothing by itself.) Declares the data-use consents a call needs as an extensible named set (starting with `summaryStorage`); requirements are surfaced on `onCallEnd` for enforcement. Paired with **`createConsentTool`** (new server-safe root export): captures each `{ item, granted }` decision at runtime with the caller identity from tool context and hands it to an app-owned store. - **`configuration.endCall` — agent-initiated hang-up.** Paired with **`createEndCallTool`** (new server-safe root export). The worker waits for the goodbye to finish playing out (`waitForAgentDoneSpeaking`, capped by `maxWaitMs`), optionally speaks a non-interruptible closing `message`, then deletes the room and shuts down the job — running `onCallEnd` exactly as a caller hang-up does. Works on both the agent and workflow reply paths. - **Backwards compatible.** The released top-level `greeting` / `persistGreeting` options remain as deprecated aliases; `configuration.greeting` wins field-by-field. ### `@mastra/livekit/plugin` — `MastraLLM`, use Mastra as the LLM inside a customer-owned LiveKit session Until now, using Mastra for voice meant Mastra ran the *whole* call. `MastraLLM` flips the ownership: the customer keeps their own LiveKit `AgentSession` — their STT/TTS vendors, turn detection, deployment — and drops Mastra into the LLM slot as a standard `llm.LLM` plugin. - **New `@mastra/livekit/plugin` subpath export** (root stays server-safe): `MastraLLM extends llm.LLM`, plugs straight into `voice.AgentSession({ llm: new MastraLLM(...) })`. - **Three interchangeable brain sources** (exactly one required): `remote` (HTTP/SSE to a running Mastra server via `createRemoteAgentReplyGenerator`, with abort propagation and configurable timeouts), `agent` (in-process), or `generate` (fully custom). - **Mastra features surface cleanly:** thread/resource memory plumbed per call; shared message ids dedupe what the server already persisted; LiveKit-side `instructions` filtered rather than double-applied; `memory` + LiveKit's preemptive generation guarded and documented. - **Interrupted turns self-heal:** on barge-in the server skips persisting the unheard reply; the plugin records only what the caller actually heard, flags it interrupted, and reconciles it into memory on the next turn. - **Hooks:** `toolFeedback` (spoken filler while a tool runs), `onToolCall`, `onTurnComplete` (per-turn text/tool-calls/interrupted/usage, off the audio path). `createLiveKitWorker` gained the same `onToolCall`/`onTurnComplete` hooks, since both paths now share one reply seam. ### Drift fix vs the original branch `main` bumped `@livekit/agents` 1.4.11 → 1.5.0 after #19019 branched. 1.5.0 turns `ToolContext` into a class that `AgentSession` always passes to `llm.chat()` — `Object.keys()` on it saw only private fields, so `MastraLLM`'s ignored-tools warning fired on every session (even tool-less) with garbage names. Fixed in a dedicated commit (262d90d7fc): tool names now come from the instance's `flatten()`, with plain-map fallback for 1.4; two regression tests added. ## Scope - All `integrations/livekit` changes: `configuration` (greeting/consent/endCall/stt/tts), consent + end-call tools, `MastraLLM` plugin, remote SSE transport, reply-seam hooks, README - Docs: LiveKit voice guide (wrapper-vs-plugin comparison, preemptive-generation warning) + full reference entries - Changesets: 3 × `@mastra/livekit` minor (configuration, stt/tts resolvers, plugin) ## Also included (consolidated from #19137) - `examples/voice-agent`: permissive default worker + regulated demo (consent-gated summarization) + customer-owned-session plugin worker - `@mastra/memory` summarization — PR 1 (#19135); the README's `memory.summarizeThread()` mentions depend on it, hence the stack order ## Verification - `pnpm vitest run` in `integrations/livekit` — 186/186 passing across 15 files (was 184; +2 regression tests for the 1.5.0 ToolContext fix) - `tsc --noEmit`, `pnpm build:lib`, `pnpm lint` — clean - Verified live over LiveKit + Studio voice mode on the original branch: disclosure playout, consent capture, agent-initiated hang-up, and the plugin end-to-end against a remote Mastra server (barge-in reconciliation, spoken tool feedback, `onTurnComplete` usage) ## Type of change - [x] New feature (non-breaking change that adds functionality) - [x] Documentation update 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR upgrades the LiveKit voice agent so you can control—per call—how it introduces itself, when/what consent it asks for, and how it ends (including letting the agent hang up). It also adds a new `@mastra/livekit/plugin` entry so customers can plug Mastra (`MastraLLM`) into their own LiveKit `AgentSession`, plus tools to record consent and trigger a safe end-call flow. ## Summary - Updated `createLiveKitWorker` with a grouped per-call `configuration` option for: - greeting / AI disclosure behavior, - consent via a named `consentPolicy` model, - optional agent-initiated hang-up via `endCall`, - per-call `stt`/`tts` resolvers (run once per call) with fallback to legacy top-level `stt`/`tts`. - Kept legacy top-level `greeting` and `persistGreeting` as deprecated aliases, with `configuration.greeting.*` taking precedence. - Added new server-safe root exports: - `createConsentTool` to record runtime consent decisions (including caller identity fields) using schema validation and an `onGrant` persistence callback. - `createEndCallTool` to let the agent end the call after an optional goodbye/closing workflow, while ensuring shutdown flow continues even if bookkeeping fails (warns instead of breaking execution). - Introduced `@mastra/livekit/plugin` with `MastraLLM`, a LiveKit LLM-component for customer-owned `AgentSession`s, supporting exactly one reply source: `remote`, `agent`, or `generate`. - Includes remote HTTP/SSE reply generation, interrupted-turn “self-healing” memory reconciliation, tool activity hooks (`toolFeedback`, `onToolCall`, `onTurnComplete`), and token usage surfaced via `result.usage`. - Improved worker robustness and observability: - AI re-disclosure reminders, - mid-stream `onToolCall` notifications, - stable message `id` propagation and filtering of LiveKit-injected instruction messages, - wired `configuration.endCall` into the workflow reply path, - tightened watchdog + hook error handling, plus regression tests. - Consolidated and refreshed `examples/voice-agent` (including new regulated and plugin worker scripts) and updated LiveKit docs/reference to reflect the new grouped configuration, `consentPolicy` rename, and `@mastra/livekit/plugin` entrypoint. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
e6a087d975 |
refactor(mastracode): remove web memo hooks (#19107)
Replaces useCallback and useMemo usage in the Mastra Code web UI with plain functions and per-render computations. The agent controller client hook is now a service helper, and effect-driven chat/session synchronization uses effect events so callback identity is no longer required. Verified with: - pnpm --filter ./mastracode check - pnpm --filter ./mastracode lint - pnpm --filter ./mastracode exec vitest run --reporter=dot - pnpm --filter ./mastracode web:ui:build <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR makes the Mastra Code web UI simpler by removing “remember this across renders” React memo/callback patterns and instead using straightforward per-render calculations. It also reorganizes chat/session logic into smaller hooks/services so updates are driven directly by current state, keeping streaming/SSE subscriptions stable without relying on callback identity. ## Summary - Removed most `useMemo`/`useCallback` usage across the web UI, replacing them with plain inline calculations/functions. - Replaced the old “agent controller session” hook usage with a service + smaller, purpose-built agent-controller hooks: - session init/sync/connection status - SSE event subscription + transcript hydration - thread message fetching/hydration - modes/models/settings/permissions fetching - thread/goal/run mutations (send/steer/follow-up/abort/approve/respond) - Refactored core chat UI components (`Composer`, `ComposerPanel`, `ChatOverlays`, `ChatMessageList`, `ThreadPage`, `ThreadList`, transcript components) to drive behavior via agent-controller query/mutation hooks rather than `useChatSession()` methods. - Updated chat/session synchronization to use effect-safe mechanisms (`useEffectEvent`) so callback identity is no longer required. - Moved thread switch logic to query + mutation flow with “latest request” guarding; failures now route to `/new` with `routeErrorNotice`. - Adjusted routing/tests to center on `/new` (draft) rather than `/chat`, and updated MSW-driven tests accordingly. - Updated agent-controller cache keying to include `projectPath` for connection-state keys (to avoid unintended transcript-related refetch side effects). - Added infrastructure/support changes: agent-controller client helper caching + enable/disable behavior, removed old query module, updated markdown/toast/overlays utilities, and improved workspace project `resourceId` resolution. ## Testing - `pnpm --filter ./mastracode check` - `pnpm --filter ./mastracode lint` - `pnpm --filter ./mastracode exec vitest run --reporter=dot` - `pnpm --filter ./mastracode web:ui:build` <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai> |
||
|
|
5e7f09c4b3 |
feat(livekit): add @mastra/livekit voice integration with Studio voice mode (#17896)
LiveKit runs the audio loop (WebRTC, streaming STT, semantic turn detection, barge-in, TTS); the Mastra agent generates every reply with its own model, tools, and memory via an llmNode bridge. Includes a Studio voice mode (phone button, live captions, per-call memory threads), a call-center example app, docs, and changesets. **@mikhael28 -** Building on Shane's foundation, the integration picked up several capabilities during development to bring it closer to production-ready: - **Workflow-driven replies.** Beyond the agent path, a turn's reply can now be generated by a Mastra workflow that runs once to completion per detected turn (`createWorkflowReplyGenerator`), with a `pipeAgentReplyToWriter` helper that streams the agent's text *and* forwards its tool calls into a workflow step. The workflow path is at full feature parity with the agent path. - **Per-turn and end-of-call lifecycle hooks.** `onTurnComplete` runs after each reply finishes streaming (off the audio path, fire-and-forget) and `onCallEnd` runs once when the call ends (awaited within LiveKit's shutdown grace window). Together they give a clean seam for memory maintenance, CRM writes, analytics, and flushing observational memory once per call — none of it adding to the caller's latency. - **Voice-call observability.** Each session opens a root "voice call" trace: LiveKit's STT/TTS/turn-detection/VAD metrics attach as child spans, per-turn agent runs nest underneath, and the call closes with a token/audio usage roll-up. - **Working + observational memory showcase.** The example app demonstrates layering per-caller working memory and observational memory into a live voice agent, with a deterministic end-of-call reconciliation pass. - **Production hardening from review.** Config-validation guards (mutually-exclusive reply sources, dispatch credential checks), structured logging through the Mastra logger, backpressure and cancellation safety on barge-in, and two full rounds of CodeRabbit feedback addressed. ## Description <!-- Required: Provide a brief description of the changes in this PR. --> ## Related issue(s) <!-- Required: Link to the issue(s) this PR addresses, e.g. with: Fixes #123. PRs without linked issues may be closed. --> ## Type of change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test update ## Checklist - [ ] I have linked the related issue(s) in the description above - [ ] I have made corresponding changes to the documentation (if applicable) - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have addressed all Coderabbit comments on this PR <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR adds a “talk by phone” voice mode to Mastra Studio. When you click the phone button, LiveKit handles the audio + live captions, and Mastra decides what to say back—without waiting for the caller to finish (you can interrupt/“barge in” mid-sentence). ## Overview Introduces a new `@mastra/livekit` integration that turns Mastra agents into realtime, interruptible voice agents by wiring LiveKit’s audio loop (WebRTC, STT, VAD/turn detection, barge-in, TTS) to Mastra’s normal reply generation. Studio/Playground adds a voice call UI with a phone button, live captions, agent state indicators, and per-call “voice thread” continuity alongside text chat. ## Core integration: `@mastra/livekit` - **LiveKit ↔ Mastra bridge (`bridge.ts`)**: `MastraVoiceAgent` / `createMastraVoiceAgent` streams Mastra outputs into LiveKit voice responses, supports tool-call “spoken feedback”, and implements barge-in by canceling/aborting the active Mastra generation. - **Worker support (`worker.ts`, `worker-setup.ts`, `run.ts`)**: `createLiveKitWorker` + `runLiveKitWorker` configure STT/TTS/VAD/turn detection, end-of-utterance (turn) handling, optional greetings, and per-call lifecycle hooks. When memory is enabled, the worker ensures a dedicated voice thread and can persist spoken greetings. - **Reply generation options (agent or workflow)**: per-turn replies can be produced via a Mastra **agent stream** or a **workflow** (run-to-completion per detected turn), with a shared generation seam for streaming text + tool calls. - **Server routing + dispatch** - `liveKitConnectionRoute()` mints LiveKit connection-details tokens and embeds typed session metadata (e.g., `agentId`, `threadId`, `resourceId`). - `dispatchVoiceSession()` programmatically creates LiveKit dispatches (server-side), reading `LIVEKIT_*` env vars when not provided. - **Session/message helpers** - `metadata.ts` provides typed parse/serialize helpers for session metadata. - `messages.ts` converts LiveKit chat context into Mastra “turn” messages and can extract only “new turns” to avoid duplicating persisted history. - `voice-thread.ts` creates/ensures the per-call “Voice call” memory thread and persists the spoken greeting (skipping empty greetings). - **Observability (`observability.ts`)**: optional voice-call tracing with a root “voice call” span, nested turn metrics, and per-model usage rollups. ## Studio/Playground voice mode (UI) - Adds a voice domain with `useVoiceCall()` to fetch connection details, connect to a LiveKit room, enable the microphone, and stream/aggregate captions into UI state (with stale-async protection via epochs/abort). - Adds: - `VoiceCallButton` (idle/connecting/active + start/stop) - `VoiceCallPanel` (agent state + latest user/agent caption) - Wires the phone button into the chat composer so starting a call refreshes the correct thread/messages and keeps voice + text in the same memory continuity. ## Example app: Meridian Trades call center Adds `examples/voice-agent`, a working call-center voice demo using `@mastra/livekit`, including: - A caller-facing `callCenterAgent` plus a fast `triageAgent` intent classifier. - Call-center CRM-style tools (customer lookup, availability, booking/rescheduling/cancellation) and intake reconciliation. - Two interchangeable voice worker entrypoints (agent-driven vs workflow-driven) with feature parity. - Seeded in-memory scheduling data, deterministic end-of-call reconciliation, per-caller memory layers, and a single-file SQLite trace output. ## Tests, docs, and release notes - Adds unit tests for the LiveKit↔Mastra bridge (streaming, tool feedback, barge-in/abort behavior), message extraction, session metadata parsing/round-trips, route token minting, worker/session setup, workflow reply generation, observability, and the Playground voice call lifecycle. - Adds LiveKit documentation (guide + API reference) and sidebar entries. - Adds Changesets for the new `@mastra/livekit` package and for Studio voice mode changes (including new per-turn/per-call lifecycle hook coverage). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: mikhael28 <mikhael@hey.com> |