mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
1,655 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d60ba71be0 | chore: version - exit prerelease mode | ||
|
|
5c87442ed7 |
chore: version packages (alpha) (#30203)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/auth-auth0@1.3.0-alpha.0 ## @mastra/auth-clerk@1.4.0-alpha.0 ## @mastra/auth-okta@0.3.0-alpha.0 ## @mastra/auth-supabase@1.2.0-alpha.0 ## @mastra/client-js@1.60.0-alpha.13 ## @mastra/auth@1.2.0-alpha.0 ## @mastra/core@1.83.0-alpha.13 ## @mastra/playground-ui@69.0.0-alpha.15 ## @mastra/rag@2.8.0-alpha.3 ## @mastra/server@1.83.0-alpha.13 ## @mastra/server-adapters-test-suite@0.3.0-alpha.5 ## @mastra/auth-better-auth@1.1.11-alpha.2 ## @mastra/auth-cloud@1.2.9-alpha.0 ## @mastra/auth-neon@0.3.6-alpha.1 ## @mastra/auth-workos@1.6.9-alpha.0 ## @mastra/discord@1.3.4-alpha.0 ## @mastra/react@1.15.0-alpha.13 ## @mastra/deployer-cloud@1.83.0-alpha.13 ## @mastra/deployer-cloudflare@1.2.42-alpha.3 ## @mastra/deployer-netlify@1.2.42-alpha.1 ## @mastra/deployer-sandbox@0.3.27-alpha.1 ## @mastra/deployer-vercel@1.2.42-alpha.1 ## @mastra/longmemeval@1.1.42-alpha.13 ## @mastra/opencode@0.1.42-alpha.13 ## @mastra/factory@0.28.0-alpha.15 ## create-factory@0.4.3-alpha.15 ## @mastra/code-sdk@1.19.0-alpha.15 ## mastracode@0.50.0-alpha.14 ## @mastra/agent-builder@1.2.1-alpha.5 ## mastra@1.39.0-alpha.15 ## @mastra/connect@1.4.0-alpha.6 ## @mastra/deployer@1.83.0-alpha.13 ## @mastra/editor@0.17.1-alpha.7 ## @mastra/mcp@2.9.0-alpha.5 ## @mastra/mcp-docs-server@1.3.13-alpha.17 ## @mastra/memory@1.41.1-alpha.5 ## @mastra/schema-compat@1.4.0-alpha.2 ## @mastra/elysia@0.1.23-alpha.13 ## @mastra/express@1.5.27-alpha.13 ## @mastra/fastify@1.5.27-alpha.13 ## @mastra/hono@1.7.25-alpha.13 ## @mastra/koa@1.7.27-alpha.13 ## @mastra/nestjs@0.3.0-alpha.13 ## @mastra/next@0.2.41-alpha.13 ## @mastra/tanstack-start@0.2.41-alpha.13 ## @mastra/voice-google-gemini-live@0.14.19-alpha.2 ## @mastra/voice-openai-realtime@0.14.9-alpha.3 ## @mastra/voice-xai-realtime@0.2.18-alpha.2 ## @mastra/inngest@1.11.2-alpha.9 ## @mastra/temporal@0.6.0-alpha.13 ## create-mastra@1.39.0-alpha.15 ## @internal/playground@1.39.0-alpha.15 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
18168d518c |
feat(playground): show the built-in MCP server in Studio (#29932)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
392c7b69d5 |
feat(server): built-in MCP endpoint for agents, workflows and tools (#29929)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
05a6931471 |
chore: version packages (alpha) (#30172)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases ## @mastra/client-js@1.60.0-alpha.12 ### Minor Changes - Allow `querySpans()` to sort by `model` or `provider`. ([#30096](https://github.com/mastra-ai/mastra/pull/30096)) ```ts orderBy: [{ field: 'model', direction: 'asc' }]; ``` ### Patch Changes - The generated route types for scores now include the `SCORER` and `PROCESSOR` entity types, matching the entity types experiments can emit. ([#30145](https://github.com/mastra-ai/mastra/pull/30145)) - Add span-local error counts. ([#30088](https://github.com/mastra-ai/mastra/pull/30088)) - Updated dependencies [[`56f654f`]( |
||
|
|
72abae68eb |
feat(observability): export span-local originating error counts (#30088)
## Description Export `errorCount` as failures originating directly on each span. Child failures forwarded through a model step, workflow or agent add no parent count; independent parent failures do. Failed retries remain counted after recovery, and replay does not create new occurrences. No parent/child totals or suspend/resume rollup are maintained. Attribution stays in a WeakMap without modifying user errors. Explicit internal serializers and Inngest memoized operations preserve provenance across boundaries; public workflow results and stored workflow state omit transport metadata. Failures before child execution count on their actual originating span. Excluded spans preserve attribution so their failures cannot be misassigned to visible parents, but excluded failures are absent from exported totals. Retry context stays in the server-only context module, while shared origin utilities use global crypto. Guarded cross-package calls preserve mixed-version startup compatibility. Unsupported accounting and older snapshots remain unknown. Error-free spans do not allocate occurrence sets. Validation: 117 focused observability/workflow/compatibility tests, 23 real Inngest error/retry scenarios and 37 Inngest engine/nested-result checks pass. New regressions reproduced resolver undercounting, excluded-child misattribution and public transport-field leakage before the fixes. Real Inngest tests cover an empty execution graph, unavailable remote child, instrumented child errors, nested propagation, retries, public responses and stored state. Core/observability build, Inngest typecheck, changed-file type-aware lint and CI formatting checks pass. The preceding merge also passed 167 core checks and redaction integration coverage. Playground production builds were verified on Node 24. Docs checks with Vale report no errors (three warnings on unchanged API headings); the CI Vale configuration passes. Standalone observability `tsc` previously reported generic union-call errors in untouched `workflow-control-flow-suite.ts`; package builds and focused tests pass. No production rollout or query-table changes. CI reruns on the new head. ## Related issue(s) Fixes https://linear.app/kepler-crm/issue/OBS-901 Follow-ups: https://linear.app/kepler-crm/issue/OBS-902 and https://linear.app/kepler-crm/issue/OBS-903 Nonblocking review follow-up: https://linear.app/kepler-crm/issue/OBS-905 tracks explicit propagated classification on previously untagged errors and reuse of one Error object across separate foreach iterations. Changesets intentionally remain single sentences per maintainer direction. ## Type of change - [x] New feature (non-breaking change that adds functionality) - [x] Documentation update - [x] Test update ## Checklist - [x] I have linked the related issue(s) in the description above - [x] I have made corresponding changes to the documentation (if applicable) - [x] 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 --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This change counts each error on the span where it first happened. It keeps the count correct when errors are wrapped, retried, or rebuilt, so one failure is not counted twice. ## Summary - Adds span-local `errorCount` to exported spans. The count covers failures that start directly on that span. - Adds `claimSpanError`, `BaseSpan.recordError`, and `BaseSpan.restoreErrorCount`. Each claim records one occurrence ID on the span. - Ignores propagated failures on the receiving span. Propagated failures count only on their origin span. - Keeps error origin through cause chains, durable tool serialization, and event codecs. - Stores origin metadata in a `WeakMap` for live errors and formatted results. Omits it from public workflow JSON. - Stores occurrence IDs in span snapshots. Rebuilt spans restore them, so replayed attempts are not counted again. - Records failed attempts for default, evented, and Inngest workflow retries. Each attempt uses an attempt-scoped occurrence ID. - Reports `errorCount` as unknown when the runtime lacks the claim API or when an older snapshot has no accounting history. - Updates tracing types, the span record schema description, the span reference documentation, and changesets for `@mastra/core`, `@mastra/observability`, `@mastra/client-js`, and `@mastra/inngest`. - Adds tests for repeated reports, retry scopes, concurrent async spans, excluded children, cause-linked errors, tool and agent spans, rebuilt and legacy snapshots, codecs, durable serialization, workflow retries, and ESM/CJS compatibility with an older core build. ## Scope - Parent and child totals are not computed. - Suspend and resume rollups are not computed. - Query-time summation, display, filtering, sorting, and aggregate-table integration are not included. These are tracked in [OBS-902](https://linear.app/kepler-crm/issue/OBS-902) and [OBS-903](https://linear.app/kepler-crm/issue/OBS-903). - Counts reflect observed exported failures only. Filtering, sampling, or loss before export can leave counts incomplete. ## Change size - 32 files changed - 862 lines added - 161 lines removed ## Validation - Completed checks on the current head: not available from the supplied evidence. - Author-reported results, not verified here: - Focused observability tests, codec and durable-serialization checks, and engine and Inngest retry scenarios. - Node 24 builds, 167 core checks, 125 observability and redaction tests, and 19 real Inngest scenarios. - Type-aware lint and `lint:format`. - Known limitations: - A prior monorepo E2E attempt did not run application assertions. Fixture dependency installation failed with a pnpm store ENOENT error. - Earlier runtime tests ran on Node 23.11.0, which is outside the supported engine range. - Standalone observability `tsc` reports errors in an untouched test utility. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
f0710446e0 |
feat(observability): sort spans by model and provider (#30096)
Adds ascending/descending `model` and `provider` ordering to
`querySpans()` across Core, server, Client JS, PostgreSQL, DuckDB and
ClickHouse. No schema changes or backfill.
```ts
orderBy: [{ field: 'model', direction: 'asc' }]
```
Sorting uses the dedicated columns before pagination, with
case-sensitive UTF-8 ordering, missing values last, and identity
tie-breakers. String cursors preserve their values and remain bound to
the query and trusted scope. Legacy attribute-based display values
remain available without changing cursor boundaries. Trace/thread sort
fields stay unchanged. The server advertises
`spanQueryModelProviderSort` and rejects unsupported stores.
This PR is API-only. Studio sorting controls and live-refresh changes
are tracked in
[OBS-906](https://linear.app/kepler-crm/issue/OBS-906/add-model-and-provider-sorting-to-spans-explorer).
Enabling those controls needs raw model/provider sorting values
available to the existing head-row merge, including when polls are
ordered by end time; using display values can disagree with database
ordering. The PR has no remaining Playground UI changes or release
entry.
Validation: Core/server tests, real storage conformance across
PostgreSQL, DuckDB and ClickHouse, mixed-core checks, and
Core/server/adapter typechecks passed for the API implementation. After
removing the UI changes, both existing span component/hook suites pass
(52 tests). Changed-file lint and docs checks including CI Vale pass.
A bounded local ClickHouse 26.6.8.7 comparison used 180,000 synthetic
rows, 10,000 matches per tenant, distinct tenants across cases, both
directions and continuation pages, and disabled query/condition caches.
Median CPU was 21.9 ms for start time, 19.4 ms for model, and 21.4 ms
for provider; median query memory was about 4.6 MiB for each (maximum
6.8/8.4/7.2 MiB). These are selection-query measurements on synthetic
OSS data, not a production benchmark.
Part of OBS-896. Platform API support and package pins follow this OSS
merge and snapshot publication. UI enablement is tracked separately in
OBS-906.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
**ELI5:** Trace spans can now be sorted by their model name and provider
name, in both directions. The database does the sorting, so users can
page through the results in the right order.
## Overview
This change adds `model` and `provider` as sort fields for span queries.
It applies to the Core API, the server handlers, and the PostgreSQL,
DuckDB, and ClickHouse stores. The diff has 31 changed files, with 320
lines added and 43 removed.
## Core changes
- `SPAN_QUERY_ORDER_FIELDS` now includes `model` and `provider`.
- `SpanQueryPlanOptions` adds `allowSpanModelProviderOrdering?:
boolean`. Ordering by these fields requires this option.
- Trace and thread queries do not support these fields.
- Cursor validation accepts string or null values for `model` and
`provider`. Timestamp normalization applies only to `startedAt` and
`endedAt`.
- `SpanQuerySelectedRow` adds an optional `cursorSortValue`. Response
construction removes this field from returned spans. It uses the value
for the next-page cursor, and falls back to the row's ordering field
when the value is absent.
- The base storage feature union adds `span-query-model-provider-sort`.
## Server changes
- `assertObservabilitySpanModelProviderSortSupported` returns HTTP 501
with `SPAN_QUERY_UNSUPPORTED` when a store does not declare
`span-query-model-provider-sort`. The check runs before `querySpans` is
called.
- `ObservabilityStorageCapabilities` and its empty default add
`spanQueryModelProviderSort`, which defaults to `false`.
- The capability is reported as supported only when span queries are
supported, the core order fields include both `model` and `provider`,
and the store declares the feature.
- The system capabilities schema adds `spanQueryModelProviderSort:
z.boolean().default(false)`.
- The route handler permits model and provider ordering and performs the
capability check.
## Store changes
- **PostgreSQL:** Sorts by `model` and `provider` use `COLLATE "C"`. The
cursor bounds cast sort values to `text COLLATE "C"` when `stringSort`
is enabled. The feature is advertised only when the core order fields
include both fields.
- **DuckDB:** Sorts by `model` and `provider` use `"C"` collation.
Cursor values cast as strings with the same collation. The feature is
advertised only when the core order fields include both fields.
- **ClickHouse:** `afterCursor` treats `model` and `provider` as
strings. Null rows are included after the cursor for numeric and string
sorts. The feature is advertised only when the core order fields include
both fields.
- Returned `model` and `provider` values may still come from span
attributes. The code comments state that these fallback values are not
used for filtering or sorting.
## Tests and conformance
- Core tests cover ordering gating, rejection in trace and thread
queries, string and null cursor values, and rejection of cursors when
the order, filters, authorization, or scope change.
- Server tests cover the 501 rejection for `durationMs`, `model`, and
`provider` on older stores. They also cover capability parsing and the
capability flag in the system endpoint.
- Shared conformance tests in `stores/_test-utils` cover ascending and
descending pagination at page sizes 1, 2, and 3. They cover empty
strings, missing values, case and Unicode ordering, ties, and filter
exclusion. They also check that missing values sort last and that legacy
attribute values are not treated as dedicated fields.
- Store feature-list tests for ClickHouse, DuckDB, and PostgreSQL expect
the new feature flag.
## Changesets and documentation
- Changesets add minor release notes for `@mastra/core`,
`@mastra/server`, `@mastra/client-js`, `@mastra/duckdb`,
`@mastra/clickhouse`, and `@mastra/pg`.
- The advanced query reference adds the `spanQueryModelProviderSort`
capability row. It documents `model` and `provider` ordering. It states
that the comparison is case-sensitive and that missing values sort last
in both directions.
## Scope and limits
- This diff does not include Studio UI changes. The commit history says
UI enablement is deferred to a separate issue because it needs raw model
and provider values for head-row merging.
- This diff does not include client-js source changes. Its client-js
changeset documents the new sort fields.
- The diff does not include schema changes or backfill.
- The PR description reports these results, which this review did not
run or verify:
- Core and server tests, and real shared-storage conformance and
mixed-core checks, pass.
- Core, server, and adapter typechecks pass. Staged-file lint and docs
checks, including CI Vale, pass.
- 58 Studio and MSW tests pass.
- The full Playground UI typecheck reports four unrelated chart and form
errors, and the library declaration build fails.
- A local ClickHouse 26.6.8.7 comparison with 180,000 synthetic rows
measured median CPU of 21.9 ms for start time, 19.4 ms for model, and
21.4 ms for provider. Median query memory was about 4.6 MiB for each.
These figures are not production measurements.
- Platform backend and UI wiring, and package pins, remain under
OBS-896.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
987566e882 |
fix(core): persist scores for scorer-target experiments (#30145)
Co-authored-by: Abhi Aiyer <abhiaiyer91@gmail.com> |
||
|
|
a4258a989c |
chore: version packages (alpha) (#30127)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
055a8c3b82 | chore: version packages | ||
|
|
7c40bc84b6 |
fix(react): load the Studio review queue page by page (#29291)
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> |
||
|
|
9e82af0237 |
chore: version packages (alpha) (#30074)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
aa49b049d0 |
feat(observability): order completed spans by duration (#30085)
Adds `durationMs` ascending/descending ordering to `querySpans()`, combined with existing duration filters and stable cursor pagination. Duration is the completed span’s elapsed time; zero is valid. Trace ordering and trace runtime semantics are unchanged. The server advertises `spanQueryDurationSort` and rejects unsupported stores before execution. A span-specific field list and default-off planner option protect old servers paired with newer Core. Updated adapters advertise support only when Core understands it. PostgreSQL and DuckDB reuse their numeric ordering paths; ClickHouse handles numeric cursor parameters and normalizes duration values returned as Int64 strings. Includes generated API types, documentation and package changesets. No schema migration. Implements the OSS portion of [OBS-899](https://linear.app/kepler-crm/issue/OBS-899). [OBS-904](https://linear.app/kepler-crm/issue/OBS-904) tracks Platform integration after merge and a snapshot from main. UI is outside this backend change. Validation: 134 Core, 112 server, 125 Client JS, 100 PostgreSQL, 94 DuckDB and 103 ClickHouse tests passed (one existing ClickHouse skip). Shared conformance exercises both directions, filters, zero durations and ties across page sizes. The new Core tests fail before the implementation; reverting the ClickHouse cursor fix makes both new pagination cases fail by skipping rows. Old-Core adapters omit the new feature; old stores receive a structured 501. Core/server/store typechecks, Core/server/SDK builds, changed-file lint/format and required docs checks passed. Vale reports six warnings in unchanged text. Local Node 23.11.0 is outside the supported 22/24 versions; CI must verify supported runtimes. A bounded local ClickHouse 26.6.8.7 experiment used 20,000 synthetic completed spans, the same duration filter and 50-row first/second pages in both directions. Duration ordering peaked at 3.43–3.67 MiB versus 3.42–3.66 MiB for timestamp ordering; both read 20,000 rows/1,488,890 bytes. Duration query CPU was 7–25 ms. These are single-run local measurements, not production capacity evidence; no ingestion or storage layout changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR lets users sort completed spans by how long they took. It keeps pagination stable and enables the feature only when Core and the storage adapter support it. ## Changes - Added ascending and descending `durationMs` ordering to `querySpans()`. - Added duration-aware cursor validation and stable pagination. - Added `spanQueryDurationSort` capability reporting. - Added HTTP 501 handling for unsupported stores. - Added compatibility gates for older Core versions. - Updated PostgreSQL, DuckDB, and ClickHouse adapters. - Converted ClickHouse duration values to numbers. - Added Core, server, adapter, and conformance tests. - Updated generated API types, documentation, and package changesets. - No schema migration was added. ## Validation - Reported passing tests: Core 134, server 112, Client JS 125, PostgreSQL 100, DuckDB 94, and ClickHouse 103. - One existing ClickHouse test remains skipped. - Reported typechecks, builds, lint, formatting, and documentation checks passed. - Vale reported six warnings in unchanged text. - CI verification on supported Node.js versions is not available. - Diff size: 28 files changed, with 220 additions and 8 deletions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
b0ef22e7bf |
feat(schedules): Add bounded one-off schedules (#25131)
> Opened by @abhiaiyer91 Refs #24610 ## Summary Schedules can now fire once or stop after a given time, so you no longer need to pin a cron expression to a date and clean it up yourself. - **New `completed` status**: the scheduler and timing reconciliation set it when no automatic fires remain. It's written in the same atomic `nextFireAt` check-and-set used to claim a run, so a schedule still fires only once across instances. A cron with no future occurrence left also moves to `completed` instead of erroring. `pause`/`resume` on a completed schedule return 409. Changing `runAt`/`endAt` reactivates it only when the resulting timing can still fire. `list()` hides completed schedules unless you pass `status: 'completed'`. - **Declarative workflow schedules**: `createWorkflow({ schedule: { runAt } })` and `{ cron, endAt }` are supported. Past times are accepted so redeploys don't fail, and a completed schedule isn't re-armed unless its timing changes. - **Trigger kind**: one-off fires report `trigger.kind: 'once'`. - `run(id)` doesn't complete a one-off schedule. ## Surfaces - **Core**: types, validation, scheduler claim logic, create/update/pause/resume/list, declarative sync. - **Storage**: new nullable `run_at`/`end_at` columns for libsql, pg, mysql, mongodb, spanner, convex and in-memory. Existing columns are untouched: one-off schedules store `cron` as `''`. `updateScheduleNextFire` takes an optional `newStatus`. - **Server/client-js/CLI**: request bodies accept `runAt`/`endAt` (one-of rule checked in the schema). Responses include the new fields and `completed`. Route types and CLI route metadata regenerated. - **Studio**: shows the run time for one-off schedules, shows the `endAt` bound, adds a `completed` badge and hides pause/resume for completed schedules. - **Docs + changeset.** ## Not in this PR (remaining #24610 work) - ISO 8601 string inputs for `runAt`/`endAt` (numbers and `Date` are accepted today). - The template `schedule_once` tool. ## Test plan - [x] core: schedules, scheduler, cron, schedule-config and scheduler integration tests (260 passing), clean `tsc` - [x] Shared adapter suite gained tests for `runAt`/`endAt` round-trip and atomic status CAS. Passing on libsql, pg, mysql and mongodb (Docker), plus convex server tests. **Not run on Spanner (no emulator available); typecheck only.** - [x] server schedules handler tests (51 passing, including one-off/bounded creation and body validation) - [x] client-js and playground typecheck clean; playground schedules tests passing <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 Schedules can now run once at a chosen time or repeat until a chosen end time. They complete when their planned runs are over, and changing their timing can make them active again. ## Summary - Added `runAt` for one-off agent and workflow schedules. API-created schedules require a future `runAt`; declarative workflow schedules can register past times as `completed`. - Added `endAt` for cron schedules. A schedule becomes `completed` when its next run would occur after `endAt`, or when no future run remains. - Completed schedules cannot be paused or resumed. Timing changes can reactivate a completed schedule when a future run remains. `list()` hides completed schedules unless callers filter with `status: 'completed'`. - Resuming a paused one-off schedule after its `runAt` has passed allows it to fire on the next scheduler tick. Calling `run(id)` manually does not complete a one-off schedule. - Added the `once` trigger kind for scheduled one-off agent fires. Manual runs remain `manual`. - Declarative workflow schedules preserve completed status across redeploys when timing is unchanged. Timing changes can re-arm them. - Updated schedule APIs, storage adapters, Studio, and documentation. Storage persists `runAt` and `endAt` and supports atomic status updates. ## Checks Current-head CI, build, and test results: not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Abhi Aiyer <abhiaiyer91@gmail.com> Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com> Co-authored-by: NikAiyer <nick.aiyer@gmail.com> Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com> Co-authored-by: Ehindero Israel <iehindero419@stu.ui.edu.ng> |
||
|
|
3a6ca42696 |
chore: version packages (alpha) (#30026)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
c860b9bb43 |
feat(observability): support OSS feedback replacement (OBS-887) (#30059)
Implements [OBS-887](https://linear.app/kepler-crm/issue/OBS-887/add-oss-feedback-replacement-and-export). Add OSS `PUT /api/observability/feedback/:feedbackId` with the existing wrapped client request. Replacements retain the original feedback ID, trace ID, timestamp, and tenant; omitted optional fields are cleared. A full replacement can create a missing record. OSS persists locally before responding, then independently notifies supporting exporters. Resolve mode still requires the local anchor. The SDK also exposes optional `replaceFeedback()` for independent exporter delivery without a producer-side storage lookup. Replacement events use a separate optional exporter hook. `MastraPlatformExporter` sends PUT with stable identity across bounded anchor retries, and flush/shutdown drain deliveries. Older exporters skip replacements rather than replaying them as creates. Unsupported storage/package combinations return 501 or skip unavailable export support. No UI changes; review-status PATCH propagation remains tracked in OBS-785. In-memory, PostgreSQL vNext, DuckDB, and ClickHouse vNext support replacement. In-memory, PostgreSQL, and DuckDB enforce replacement identity at the write. PostgreSQL coordinates writes by feedback ID, including duplicates submitted with a different timestamp. Duplicate HTTP creates return the stored identity and timestamp and re-notify exporters with accepted values. Tenant mismatches remain hidden, and an omitted SDK replacement author stays null. HTTP/exporter creates use `onConflict: 'ignore'` so a delayed original create doesn't undo an edit; direct storage calls keep their legacy upsert default. **ClickHouse requires no migration:** it uses the existing schema and read-before-insert protection. Sequential delayed creates are covered, but overlapping writes from separate processes can race; this is not a globally ordered or exactly-once protocol. Latest review fixes: DuckDB's lazy facade delegates replacement to its guarded writer; concurrent coverage runs 20 overlapping request pairs per identity variant. Direct storage replacements normalize an omitted author to null. PostgreSQL single-feedback reads use the primary for read-after-write consistency, while list/aggregate reads retain the configured read client. Batch advisory locks use one ordered query with unchanged lock keys. Validation: the stronger DuckDB regression failed on all four identity variants before the facade fix. Afterward, the entire DuckDB package passed 718 tests across 21 files in three consecutive runs. PostgreSQL passed 57 feedback tests, including a real stale read snapshot and overlapping reversed 1,000-ID batches. Shared replacement tests passed on in-memory (12), and the new author regression passed on ClickHouse without a migration. Core/storage builds and declarations, typed lint, and formatting passed. Earlier HTTP (85 cases on each of four adapters), generic Hono routes (2,848), server/system, exporter, and docs checks remain recorded in the PR history. Local tests use Node 23.11.0; CI validates the supported runtime. The unrelated Traces UI fade assertion failure was fixed in https://github.com/mastra-ai/mastra/pull/30068; this branch includes that fix from main. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR lets users replace feedback without changing its identity. It stores the replacement locally and sends it to supported exporters without allowing delayed creates to overwrite it. ## Changes - Added `PUT /api/observability/feedback/:feedbackId`. - Preserved the feedback ID, trace ID, timestamp, and tenant. - Cleared omitted optional fields. - Added capability detection and `501` responses for unsupported storage. - Added replacement event types, SDK support, client types, route metadata, and documentation. - Added replacement delivery, stable retries, flush handling, and shutdown draining for `MastraPlatformExporter`. - Added replacement support for in-memory, PostgreSQL vNext, DuckDB, and ClickHouse vNext. - Added `onConflict: 'ignore'` for HTTP and exporter creates. Direct storage calls retain their upsert default. - Older exporters skip replacements instead of replaying them as creates. - Added ClickHouse support without a migration. Concurrent writes from separate processes can still race. - No UI changes were included. ## Validation The author reports passing the HTTP route and contract suites, feedback storage suites, partition and SQL tests, server and system tests, record-builder tests, build, typecheck, lint, and documentation checks. For the current head, the available CI result is `2027dev Evals: skipped`. Other listed CI checks target different commits or remain in progress. Current-head CI results are otherwise not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
9751742c44 |
feat(observability): add aggregated trace root contracts (#30054)
Adds the shared contract for the Platform aggregated-roots experiment in [OBS-891](https://linear.app/kepler-crm/issue/OBS-891): optional `rootSource`, `rootKind`, runtime/error totals, and availability reporting. Legacy requests retain their cursor bindings; aggregated cursors are separate and aggregated metadata predicates and delta requests are rejected. The planner requires host opt-in. OSS servers report the capability as false and explicitly reject aggregated requests; storage implementations and UI are outside this prerequisite. Generated client and CLI contracts are updated. Validated with 102 core tests, 146 server tests, core typecheck, core/server/client builds, and formatting/lint checks. A mutation check confirms that removing root-source cursor binding fails the regression test. Platform implementation follows after this merges and a snapshot is published. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR defines how systems can report aggregated trace roots and their totals. Systems without support reject these requests, while existing legacy trace queries continue to work. ## Changes - Added `rootSource` with `legacy` and `aggregated` values. - Added aggregated-root response fields: - `rootKind` - `runtimeDurationMs` - `errorCount` - Bound trace and group cursors to their root source. - Rejected aggregated delta requests. - Rejected metadata predicates for aggregated roots. - Kept `runtimeDurationMs` and `errorCount` response-only. - Added the `traceQueryAggregatedRoots` capability, which defaults to `false`. - Added a `501 TRACE_QUERY_UNSUPPORTED` response for unsupported aggregated requests. - Updated generated client and CLI route contracts. - Added core and server regression tests. - Added release changes for `@mastra/core`, `@mastra/client-js`, `@mastra/server`, and `mastra`. ## Validation Not available from completed checks on the current head. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
8ab6015fb4 |
fix(client-js): support accepted observability deletion responses (#30051)
The JS client accepts HTTP 202 deletion responses at runtime, but its
types only describe OSS success responses. Include `{ accepted: true }`
in the return types of `deleteTraces`, `deleteScores`, and
`deleteFeedback`, with docs and a patch changeset explaining
asynchronous acceptance. Export the three response types from the public
client entry point so downstream packages can emit portable
declarations. OSS server/storage behavior and generated route contracts
are unchanged; Platform endpoints and rollout remain separate work.
Callers that previously read `result.success` directly need to narrow
the response:
```ts
const result = await client.deleteFeedback({ feedbackIds: ['feedback-1'] });
if ('accepted' in result) {
console.log('Deletion requested');
} else {
console.log(result.success);
}
```
Verified 137 focused runtime tests, the new type regression (fails
before the fix), TypeScript checks, the client build, the downstream
React SDK build (including declarations), package lint, formatting, and
documentation checks. The HTTP suite replaces the mocked deletion tests
and covers 200/202 bodies, POST/DELETE JSON preservation, and 400/500
failures. Docs checks have zero errors and three warnings on unchanged
text. No deployed Platform end-to-end flow was tested.
Fixes OBS-889.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Deletion requests can now mean “cleanup accepted and queued” instead of
“cleanup finished.” The JavaScript client now supports both responses
and documents how to handle them safely.
## Changes
- Added `{ accepted: true }` to the response types for `deleteTraces`,
`deleteScores`, and `deleteFeedback`.
- Exported these response types from the public client entry point.
- Added HTTP tests for `200`, `202`, `400`, and `500` responses,
including request details and response-body preservation.
- Added TypeScript regression tests for both client entry points and
response narrowing with `'accepted' in result`.
- Updated client and observability documentation to explain asynchronous
Platform cleanup.
- Added a patch changeset for `@mastra/client-js`.
- Replaced the previous deletion tests with shared deletion coverage.
- No server or storage implementation changes were made.
## Validation
- Test and build execution results: not available.
- The diff includes runtime and type-test coverage for the updated
behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
8bce7717eb |
chore: version packages (alpha) (#29986)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
23cc34a9c5 |
chore: version packages (alpha) (#29938)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/factory@0.28.0-alpha.6 ## @mastra/code-sdk@1.19.0-alpha.6 ## @mastra/playground-ui@69.0.0-alpha.7 ## @mastra/client-js@1.60.0-alpha.6 ## @mastra/react@1.15.0-alpha.6 ## @mastra/deployer-cloud@1.83.0-alpha.6 ## @mastra/longmemeval@1.1.42-alpha.6 ## @mastra/opencode@0.1.42-alpha.6 ## create-factory@0.4.3-alpha.6 ## mastracode@0.50.0-alpha.6 ## @mastra/agent-builder@1.2.1-alpha.3 ## mastra@1.39.0-alpha.6 ## @mastra/core@1.83.0-alpha.6 ## @mastra/deployer@1.83.0-alpha.6 ## @mastra/editor@0.17.1-alpha.4 ## @mastra/mcp@2.9.0-alpha.3 ## @mastra/mcp-docs-server@1.3.13-alpha.9 ## @mastra/memory@1.41.1-alpha.3 ## @mastra/rag@2.7.3-alpha.2 ## @mastra/schema-compat@1.3.18-alpha.0 ## @mastra/server@1.83.0-alpha.6 ## @mastra/elysia@0.1.23-alpha.6 ## @mastra/express@1.5.27-alpha.6 ## @mastra/fastify@1.5.27-alpha.6 ## @mastra/hono@1.7.25-alpha.6 ## @mastra/koa@1.7.27-alpha.6 ## @mastra/nestjs@0.3.0-alpha.6 ## @mastra/next@0.2.41-alpha.6 ## @mastra/server-adapters-test-suite@0.3.0-alpha.3 ## @mastra/tanstack-start@0.2.41-alpha.6 ## @mastra/upstash@1.6.1-alpha.0 ## @mastra/vectorize@1.1.5-alpha.0 ## @mastra/voice-google-gemini-live@0.14.19-alpha.0 ## @mastra/voice-openai-realtime@0.14.9-alpha.0 ## @mastra/voice-xai-realtime@0.2.18-alpha.0 ## @mastra/inngest@1.11.2-alpha.4 ## @mastra/temporal@0.6.0-alpha.6 ## create-mastra@1.39.0-alpha.6 ## @internal/playground@1.39.0-alpha.6 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
779d2875b1 |
chore: version packages (alpha) (#29912)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/auth-studio@1.4.0-alpha.1 ## @mastra/factory@0.28.0-alpha.5 ## @mastra/mcp-apps-components@0.1.0-alpha.5 ## @mastra/playground-ui@69.0.0-alpha.6 ## @mastra/client-js@1.60.0-alpha.5 ## @mastra/react@1.15.0-alpha.5 ## @mastra/deployer-cloud@1.83.0-alpha.5 ## @mastra/longmemeval@1.1.42-alpha.5 ## @mastra/opencode@0.1.42-alpha.5 ## create-factory@0.4.3-alpha.5 ## @mastra/code-sdk@1.19.0-alpha.5 ## mastracode@0.50.0-alpha.5 ## @mastra/agent-builder@1.2.1-alpha.2 ## mastra@1.39.0-alpha.5 ## @mastra/core@1.83.0-alpha.5 ## @mastra/deployer@1.83.0-alpha.5 ## @mastra/editor@0.17.1-alpha.3 ## @mastra/mcp@2.9.0-alpha.2 ## @mastra/mcp-docs-server@1.3.13-alpha.8 ## @mastra/memory@1.41.1-alpha.2 ## @mastra/rag@2.7.3-alpha.1 ## @mastra/server@1.83.0-alpha.5 ## @mastra/elysia@0.1.23-alpha.5 ## @mastra/express@1.5.27-alpha.5 ## @mastra/fastify@1.5.27-alpha.5 ## @mastra/hono@1.7.25-alpha.5 ## @mastra/koa@1.7.27-alpha.5 ## @mastra/nestjs@0.3.0-alpha.5 ## @mastra/next@0.2.41-alpha.5 ## @mastra/server-adapters-test-suite@0.3.0-alpha.2 ## @mastra/tanstack-start@0.2.41-alpha.5 ## @mastra/libsql@1.30.0-alpha.2 ## @mastra/turso@0.1.21-alpha.2 ## @mastra/inngest@1.11.2-alpha.3 ## @mastra/temporal@0.6.0-alpha.5 ## create-mastra@1.39.0-alpha.5 ## @internal/playground@1.39.0-alpha.5 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
bfda77de97 |
fix(core,server): scope experiment comparison by organization and project (#29479)
`mastra.datasets.compareExperiments` had no way to scope by organization or project, and the compare route ignored the tenancy query params the other dataset routes accept. A caller scoped to one tenant could compare experiments from another by ID. `compareExperiments` now takes `organizationId` and `projectId`. When either is set, every experiment must match, otherwise it throws `EXPERIMENT_NOT_FOUND` (same as a missing row, so other tenants' IDs don't leak). The route reads `tenancyQuerySchema` and passes the scope to both the dataset lookup and the comparison. Unscoped calls behave as before. Added manager tests for a cross-tenant pair (rejected, fails without the fix) and a same-tenant pair. Core datasets tests (490), server datasets handler tests (106), tsc and lint pass. Fixes PLTFRM-3165 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 When a caller chooses an organization or project, experiment comparisons now stay within that scope. Experiments outside it are treated as not found, so their results are not exposed. ## Changes - `mastra.datasets.compareExperiments` accepts optional `organizationId` and `projectId` values. - When either scope is set, the manager checks every distinct experiment ID. It throws `EXPERIMENT_NOT_FOUND` if an experiment is missing or outside the scope. - The comparison route reads tenancy query parameters and passes them to the dataset lookup and comparison. - If scoped comparison is requested with a core version that does not advertise tenancy enforcement, the route returns HTTP 501 before reading data. Unscoped comparisons remain unchanged. - Tests cover cross-organization rejection, same-organization comparisons, and the route’s behavior when the core feature is unavailable. - Updated generated route metadata and added patch changesets for `@mastra/core` and `@mastra/server`. ## Validation Current-head test, TypeScript, and lint results are not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|
|
1ac251ba65 |
test(e2e): ensure CI fails when type checking fails (#29605)
## Description Previously the e2e type-check job ran the type tests, ignored the result and stayed green with 33 failures. `test.ts` now fails the job when any run fails. It also runs plain `tsc`, because vitest skips type errors outside test bodies. For example, [E2E Type check in run 42058855421](https://github.com/mastra-ai/mastra/actions/runs/42058855421/job/127363177526) passed with this in its log: ``` Test Files 6 failed | 6 passed (12) Type Errors 33 failed ``` Fixture tests that no longer matched the current types are updated. The zero-argument `bail()` call is removed, since #12211 dropped that overload on purpose. The `network()` tests now expect `undefined` output, because `network()` ignores the agent's `defaultOptions`. client-js `generateLegacy` typed `object` as `never` with `output` and dropped `text` with `experimental_output`. It now infers both from the schema: ```ts const r = await agent.generateLegacy({ messages: 'hi', output: schema }); r.object; // before: never, now: inferred from schema ``` With #29581 merged, all type tests and both `tsc` runs pass. ## Related issue(s) Fixes #29603 Fixes #29604 ## Type of change - [x] 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 - [x] Test update ## Checklist - [x] I have linked the related issue(s) in the description above - [ ] I have made corresponding changes to the documentation (if applicable) - [x] 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 --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR makes the e2e type-check job report failures from all its checks, including errors that test-focused checks can miss. It also updates type tests to match current API types and fixes the result types for `client-js` `generateLegacy()`. ## Changes - The e2e type-check runner now runs two Vitest suites and two `tsc` checks. It continues after a check fails and sets a failing exit status. - The `generateLegacy()` overloads now retain schema types for `output` and `experimental_output`. New type tests check the inferred `object` and `text` types. - Updated e2e type-test expectations for schemas, tools, workflows, and client workflow start results. - Updated `network()` tests to expect `undefined` when no structured output is passed. This does not add inference from the agent’s `TOutput`. - Added a patch Changeset for `@mastra/client-js`. ## Validation Completed CI, build, and test results: not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
7c4dd88400 |
chore: version packages (alpha) (#29889)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
2cfa92405b |
feat(observability): add shared text search query contracts (#29897)
Adds shared text-search query contracts for Platform integration: optional `textSearch` on `querySpans()` and `queryTraces()`, normalization, a 3–256 character limit, and cursor binding. This does not implement or enable text search in OSS stores. Adds capability reporting, request forwarding, and unsupported-store rejection, with generated client types and CLI metadata. Platform search implementation and rollout flags follow in OBS-867. Delta search is rejected for now. Public documentation is unchanged; changesets only describe the contract additions. Validated with 404 focused tests, 5 type tests, and core/server/client typechecks. The 228 core query tests were rerun after reducing the limit to 256. New contract tests also fail against the original implementation. Fixes [OBS-866](https://linear.app/kepler-crm/issue/OBS-866/add-shared-text-search-query-contracts). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR gives span and trace queries a standard way to request text search. It also lets clients check whether a storage provider supports that search, so unsupported searches return an error instead of misleading results. ## Summary - Add optional `textSearch` to span and trace query contracts. Trim outer whitespace, convert input to lowercase, and require 3–256 Unicode code points. - Bind normalized search text to query cursors. Reject `textSearch` for delta trace queries. - Add span and trace text-search capability fields. Default missing fields to `false` for compatibility with older responses. - Forward search input to query planners. Return HTTP 501 when the configured storage provider does not declare support. - Report text-search capability only when Core can parse the field and the storage provider declares the matching feature. - Add tests for validation, normalization, cursor binding, unsupported stores, and compatibility behavior. ## Validation Reported test and typecheck results: not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
6deb16047f |
chore: version packages (alpha) (#29719)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/slack@1.9.0-alpha.0 ## @mastra/factory@0.28.0-alpha.3 ## @mastra/code-sdk@1.19.0-alpha.3 ## mastracode@0.50.0-alpha.3 ## @mastra/observability@1.24.0-alpha.2 ## @mastra/core@1.83.0-alpha.3 ## @mastra/mcp-apps-components@0.1.0-alpha.3 ## @mastra/playground-ui@69.0.0-alpha.4 ## @mastra/server@1.83.0-alpha.3 ## @mastra/server-adapters-test-suite@0.3.0-alpha.1 ## @mastra/platform-workspace@1.13.0-alpha.0 ## @mastra/auth-better-auth@1.1.11-alpha.1 ## @mastra/client-js@1.60.0-alpha.3 ## @mastra/react@1.15.0-alpha.3 ## @mastra/deployer-cloud@1.83.0-alpha.3 ## @mastra/longmemeval@1.1.42-alpha.3 ## @mastra/opencode@0.1.42-alpha.3 ## create-factory@0.4.3-alpha.3 ## @mastra/arize@1.3.30-alpha.2 ## @mastra/arthur@0.4.30-alpha.2 ## @mastra/braintrust@1.3.27-alpha.2 ## @mastra/datadog@1.4.22-alpha.2 ## @mastra/deepeval@0.1.24-alpha.2 ## @mastra/laminar@1.3.32-alpha.2 ## @mastra/langfuse@1.6.6-alpha.2 ## @mastra/langsmith@1.4.3-alpha.2 ## @mastra/otel-bridge@1.5.22-alpha.2 ## @mastra/otel-exporter@1.5.2-alpha.2 ## @mastra/posthog@1.4.7-alpha.2 ## @mastra/sentry@1.2.32-alpha.2 ## @mastra/agent-builder@1.2.1-alpha.1 ## mastra@1.39.0-alpha.3 ## @mastra/connect@1.3.2-alpha.2 ## @mastra/deployer@1.83.0-alpha.3 ## @mastra/editor@0.17.1-alpha.2 ## @mastra/fastembed@1.3.7-alpha.0 ## @mastra/mcp-docs-server@1.3.13-alpha.6 ## @mastra/memory@1.41.1-alpha.1 ## @mastra/elysia@0.1.23-alpha.3 ## @mastra/express@1.5.27-alpha.3 ## @mastra/fastify@1.5.27-alpha.3 ## @mastra/hono@1.7.25-alpha.3 ## @mastra/koa@1.7.27-alpha.3 ## @mastra/nestjs@0.3.0-alpha.3 ## @mastra/next@0.2.41-alpha.3 ## @mastra/tanstack-start@0.2.41-alpha.3 ## @mastra/convex@1.8.1-alpha.0 ## @mastra/pg@1.36.0-alpha.2 ## @mastra/inngest@1.11.2-alpha.2 ## @mastra/temporal@0.6.0-alpha.3 ## create-mastra@1.39.0-alpha.3 ## @internal/playground@1.39.0-alpha.3 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
a836d09a43 |
fix(core, client-js, inngest): accept zod v3 schemas and newer ai v7 messages in public types (#29581)
## Description
zod v3 schemas work at runtime but some public types rejected them or
inferred `unknown`, and `UIMessage[]` from `ai@7.0.163` stopped
type-checking against core's vendored v7 types.
```ts
import { z } from 'zod/v3';
const schema = z.object({ answer: z.string() });
createStep(agent, { structuredOutput: { schema } }); // before: No overload matches this call
new Agent({ ...config, defaultOptions: { structuredOutput: { schema } } }); // before: TS2322
(await agent.generateLegacy('hi', { output: schema })).object; // before: unknown, now { answer: string }
await client.getAgent('a').generate('hi', { structuredOutput: { schema } }); // before: TS2590
import type { UIMessage } from 'ai'; // 7.0.163, has SteeringMessageUIPart
await agent.generate(uiMessages as UIMessage[]); // before: 'SteeringMessageUIPart' is not assignable
```
The zod v3 fixes point the user-facing option types at `PublicSchema` /
`PublicAgentExecutionOptions` (the runtime already converts with
`toStandardSchema`). `inferOutput` gets a zod v3 branch that reads
`_output` structurally, like `InferPublicSchema` in schema-compat, so a
v3 schema from a different zod install than core's is inferred too.
Client-js `StreamParamsBase` is built on `AgentExecutionOptionsBase`,
which avoids the TS2590.
For the v7 messages, `MessageInput` also accepts a v7 `UIMessage` whose
parts only need a string `type`. Core can't know the shape of part types
released after its vendored copy, so those parts are deliberately loose.
Inline object literals are still checked against the known part types,
because excess property checks rule out the loose member for them.
Mastra doesn't process the new part types yet.
`AIV6Adapter.fromUIMessage` paired parts with its v5 bridge output by
index, so a part the bridge drops (an unknown type, or an empty text
part) shifted every later part. It now drops those before pairing.
The PR also fixes two tests that failed CI on `main`: the stored board
runtime test still imported `factoryMemorySettingsUserId` after #29366
renamed it, and the redactor leak check matched `4111` inside a random
message UUID.
Type tests cover each case in the core and inngest type-test files, and
they fail with the fix reverted. The e2e client-js fixture imported
`zod/v3` and `zod/v4`, which don't resolve there, so its schemas were
`any`. This PR fixes those imports. The e2e type-check run still ignores
its exit code (`e2e-tests/type-check/test.ts:45`), which is left for a
separate PR.
## Related issue(s)
Fixes #29574
Fixes #29575
## Type of change
- [x] 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
- [x] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have addressed all Coderabbit comments on this PR
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This PR lets TypeScript accept Zod v3 schemas and newer AI SDK v7
messages in Mastra’s public APIs. It also fixes message-part matching so
ignored parts do not change how later parts are handled.
## Summary
- Updated agent and workflow option types to accept public schemas,
including Zod v3 schemas. Added Zod v3 output inference for
`generateLegacy`.
- Added forward-compatible input types for newer AI SDK v7 UI message
parts. Mastra accepts these messages, but does not yet process unknown
part types.
- Updated the AI v6 adapter to filter unsupported parts and empty text
parts before matching converted message parts.
- Updated client-js stream parameter types to avoid a complex TypeScript
union. Corrected Zod imports in a type-check fixture and added
regression type tests.
- Updated `getLastMessage` to use the last part only when it contains
nonempty string text.
- Added patch changesets for `@mastra/core`, `@mastra/client-js`, and
`@mastra/inngest`.
**Diff:** 19 files changed; 191 additions and 34 deletions.
**CI and test results:** not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
224d51972a |
fix(client-js): run every parallel client tool call in generate() (#29407)
When the model called several client tools in one step, `agent.generate()` and `agent.generateLegacy()` ran the first one and immediately sent its result back, so the other calls never ran and never got a result. `stream()` already handled this. Both methods now run every client tool in the step, then continue once with all the results in a single tool message. Calls for tools that aren't client tools are skipped as before. Added tests for both methods with two parallel calls. client-js agent tests pass (144), and `tsc` and lint are clean. Fixes PLTFRM-3152 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 When an agent asks the client to run several tools at once, the client now runs each eligible tool and sends all their results back together. This lets the agent continue with the full set of results. ## What changed - `agent.generate()` and `agent.generateLegacy()` now collect results from all client tool calls in a step and continue with one tool message. - Both methods stop starting additional client tools if the request is aborted. - Added tests for both methods that cover parallel tool calls, result order, and abort behavior. - Added a patch changeset for `@mastra/client-js`. ## Validation Test, type-check, and lint results are not available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
009f632534 | chore: version packages | ||
|
|
f21e0742ce | chore: version packages | ||
|
|
d6a5f98df3 |
fix: index observe chunks for resume (COR-1506) (#29520)
> Opened by @user_01KNA8J74D4RF84RXSDRX26BS9 Linear: [COR-1506](https://linear.app/kepler-crm/issue/COR-1506/observe-offset-cant-be-used-to-resume-it-counts-log-events-but-clients) ## Problem `observe({ runId, offset })` takes `offset` as a position in the run log. Clients can't compute that position: - Some log entries never reach the client. These include iteration-complete records after every step and ownership markers. - Updates on the wire carried no index. A client that resumes at "number of updates received" lands too early and gets repeated updates. The drift grows by one per completed step, so every tool-using run that reconnects after its first step is affected. On a 3-step tool loop, 16 of 28 cut points repeated 1–2 updates on both durable and evented engines. ## Fix - **Index on updates:** every update now carries `index`, the run-log position it came from. This covers: - `/observe` on every agent - `/stream` on durable and evented agents - core `stream()`/`observe()` chunks and client-js `observe()`/`stream()` - **Resuming:** pass `index + 1` of the last received update that has an index as `offset`. Gaps in the numbering are expected; they're log entries that send nothing. - **Unindexed updates:** the synthesized `abort` update carries no index. Its log position is on the `finish` sent beside it. Client-built structured-output `object` chunks have no index either. An `object-result` logged by a structuring-model run carries one. Unindexed updates don't move the resume point. A client that reconnects between `abort` and `finish` gets the `abort` again. - **`offset` is unchanged:** it still means a run-log position. - Core no longer strips `index` in `DurableAgent.__subscribeToRunStream`. The stream adapter and the server's `toAgentStreamChunks` copy the envelope's index onto each chunk and drop any index a forwarded sub-agent chunk carried. `index` is optional on `BaseChunkType` and `DataChunkType`. - **Also fixed:** on plain agents, `/observe` (HTTP and core `agent.observe()`) with an offset past the end of a finished run used to wait for the idle timeout or hang. It now closes immediately. It reads the log from just before the offset and only falls back to a full read when that window is empty. The check runs in the background, so it never delays returning the stream or its cancel handle. A trailing `error` chunk doesn't count as the end of the run. ## Migration `index` is a new field and `offset` keeps its meaning: - Callers that pass a log position need no change. - Callers that replay from `offset: 0` need no change. They get the same updates in the same order, now with `index` set. - Only callers that passed a count of updates received need to change. They were already getting repeats after step boundaries; switch them to `index + 1` of the last indexed update. ## Evidence | Check | Result | | --- | --- | | Red/green | With `main`'s core and server, 15 tests on numbering and `/stream`–`/observe` matching fail; with this change all pass. | | Cut points | Every cut point of a 3-step tool loop on durable and evented engines resumes from the first `/stream` connection at last index + 1. Covers the HTTP route and client-js `stream()` → `observe()`. | | `/stream` vs `/observe` match | Frames are identical JSON, including `index`. Replay from 0 equals the first `/stream`. | | End of run | Resume after finish or past the end returns the rest and closes, including far past the end (offset 100). | | Adapters | Hono 98/98, Fastify 98/98, Express 90 passed + 8 skipped (see bug 1 below). The shared suite is now wired into Express and Fastify. | | Redis restart | Real-Redis split-deploy test (in `pubsub/redis-streams/src/observe-cross-process.test.ts`) passes on both engines. The client resumes on a freshly booted API process at last index + 1 with nothing repeated or missing. Evented: the worker executes the run and the API is killed with SIGKILL. Durable runs execute in the API that started them, so that API stays up; the client drops its connection and resumes on a second API. | | Suspend | After tool approval, indexes keep increasing. Observers parked mid-suspend and every cut across the suspend resume correctly on both engines. | | Unit suites | server `agents.test.ts` 289, core `src/stream` + `src/agent/streams` 481 | | Static | tsc clean on core, server, client-js, the test suite, the Hono/Express/Fastify adapters and redis-streams. oxlint 0 warnings. | ## Scope Plain (non-durable) agents' `/stream` updates aren't numbered yet. The caller receives each update before the cache assigns its number. That's tracked in COR-1510. Plain agents' `/observe` is covered here. ## Existing bugs found (not fixed here) 1. **Express untilIdle 404:** after a client drops an untilIdle stream on a durable or evented agent, Express answers `/observe` with 404 "Run not found". It fails the same way on `main`. Those 8 cases are skipped on Express only, via `skipUntilIdleDisconnectReplay`. 2. **Finished durable run, other API:** a finished durable run returns 404 on `/observe` from any API process except the one that executed it (`authorizeDurableRun`, `handlers/agents.ts`). Resuming while the run is live works from any API. 3. **Plain replay mismatch:** on plain agents, replayed `step-finish`/`finish` payloads differ from the live ones (for example `timestamp` and `processorRetryCount`). Related to COR-1510. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 When a connection drops, clients need to know which updates they already received. This change adds positions to many updates so clients can resume from the right place. It also closes observations of finished runs when the requested position is past the end. ## Summary - Added optional `index` values to chunks from durable and evented agent streams, `observe()` streams, and corresponding HTTP routes. Clients can resume by passing the last indexed chunk’s `index + 1`. - Preserved run-log indexes through core stream adapters and server frame conversion. Sub-agent data chunks do not carry a child run’s index into the parent stream. - Some chunks remain unindexed, including synthesized `abort` chunks and client-built structured-output `object` chunks. Failed cache writes and non-atomic custom-cache indexing can affect replay. - Updated API schemas and documentation to explain index gaps, replay limits, and resumption. - Added past-end handling for finished plain-agent observations in core and HTTP `/observe`. History checks do not delay stream return or prevent cancellation. - Added tests for indexed replay, past-end closure, cancellation during history reads, sub-agent index isolation, and observation across API restarts. **Validation:** Current-head CI, build, and test results are not available. <!-- 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> Co-authored-by: NikAiyer <nick.aiyer@gmail.com> |
||
|
|
23308f9c19 |
feat(observability): add single score and feedback reads (#29529)
## Description
Add `GET /observability/feedback/:feedbackId` and typed client getters
for individual scores and feedback. Missing records return HTTP 200 with
`{ score: null }` or `{ feedback: null }`, preserving the existing score
endpoint contract.
```ts
const { score } = await client.getScore(scoreId);
const { feedback } = await client.getFeedback(feedbackId);
```
Client getters encode path IDs and preserve configured API prefixes,
credentials, and headers. Feedback reads use direct lookups in
in-memory, PostgreSQL, ClickHouse, and DuckDB storage. Includes
generated route types/CLI metadata, public API documentation, and
changesets.
Validation: package builds passed; 30 single-record HTTP cases passed
across five server adapters; 6 client transport tests, 341 server tests,
and 9 focused database cases passed across PostgreSQL/TimescaleDB,
ClickHouse, and DuckDB. Removing the feedback route caused the new
feedback HTTP cases to fail. Permission generation/checks, scoped
implementation lint, MDX formatting, Remark, and Vale passed.
Broader validation limitations: existing POST cases fail with
body-parser dependency errors in Express, Koa, and NestJS; the new GET
cases pass in all five adapters. The shared storage test helper also has
existing import-order lint errors outside the changed lines.
## Related issue(s)
Fixes
[OBS-790](https://linear.app/kepler-crm/issue/OBS-790/add-oss-single-score-and-feedback-reads),
under [OBS-792](https://linear.app/kepler-crm/issue/OBS-792). Platform
single-record endpoints remain scoped to OBS-791.
## Type of change
- [x] New feature (non-breaking change that adds functionality)
- [x] Documentation update
- [x] Test update
## Checklist
- [x] I have linked the related issue(s) in the description above
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] 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
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Applications can now look up a score or feedback record by its ID. If no
feedback record exists, the server returns `null`; it can also add
available author details to feedback.
## Summary
- Added `GET /observability/feedback/:feedbackId`. The route uses
existing observability authorization and returns `{ feedback: record }`
or `{ feedback: null }`.
- The feedback route adds author details when available. It returns HTTP
501 when the storage provider does not support single-feedback reads.
- Added `getScore(id)` and `getFeedback(id)` to the JavaScript client.
These methods encode IDs in the URL and use the client’s configured
request options.
- Added direct feedback lookups to in-memory, PostgreSQL, ClickHouse,
and DuckDB storage.
- Added response types, generated route metadata, API documentation,
tests, and changesets.
## Validation
Test and CI results: not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
ea37ef0386 |
fix(client-js): accept plain-object requestContext in agent.generate and agent.stream (#29577) | ||
|
|
2f93851c37 |
fix(core): make Agent.durable configure resumable streams only (#29503)
Co-authored-by: NikAiyer <nick.aiyer@gmail.com> |
||
|
|
675caf0613 |
chore: version packages (alpha) (#29336)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/client-js@1.60.0-alpha.0 ## @mastra/react@1.15.0-alpha.0 ## @mastra/factory@0.28.0-alpha.0 ## @mastra/code-sdk@1.19.0-alpha.0 ## mastra@1.39.0-alpha.0 ## @mastra/core@1.83.0-alpha.0 ## @mastra/mcp@2.9.0-alpha.0 ## @mastra/mcp-apps-components@0.1.0-alpha.0 ## @mastra/playground-ui@69.0.0-alpha.0 ## @mastra/server@1.83.0-alpha.0 ## @mastra/nestjs@0.3.0-alpha.0 ## @mastra/clickhouse@1.30.0-alpha.0 ## @mastra/duckdb@1.19.0-alpha.0 ## @mastra/libsql@1.30.0-alpha.0 ## @mastra/pg@1.36.0-alpha.0 ## @mastra/temporal@0.6.0-alpha.0 ## @mastra/auth-better-auth@1.1.11-alpha.0 ## @mastra/deployer-cloud@1.83.0-alpha.0 ## @mastra/deployer-cloudflare@1.2.42-alpha.0 ## @mastra/deployer-netlify@1.2.42-alpha.0 ## @mastra/deployer-sandbox@0.3.27-alpha.0 ## @mastra/deployer-vercel@1.2.42-alpha.0 ## @mastra/longmemeval@1.1.42-alpha.0 ## @mastra/opencode@0.1.42-alpha.0 ## create-factory@0.4.3-alpha.0 ## mastracode@0.49.1-alpha.0 ## @mastra/arize@1.3.30-alpha.0 ## @mastra/arthur@0.4.30-alpha.0 ## @mastra/braintrust@1.3.27-alpha.0 ## @mastra/datadog@1.4.22-alpha.0 ## @mastra/deepeval@0.1.24-alpha.0 ## @mastra/laminar@1.3.32-alpha.0 ## @mastra/langfuse@1.6.6-alpha.0 ## @mastra/langsmith@1.4.3-alpha.0 ## @mastra/observability@1.23.2-alpha.0 ## @mastra/otel-bridge@1.5.22-alpha.0 ## @mastra/otel-exporter@1.5.2-alpha.0 ## @mastra/posthog@1.4.7-alpha.0 ## @mastra/sentry@1.2.32-alpha.0 ## @mastra/agent-builder@1.2.1-alpha.0 ## @mastra/connect@1.3.2-alpha.0 ## create-mastra@1.39.0-alpha.0 ## @mastra/deployer@1.83.0-alpha.0 ## @mastra/editor@0.17.1-alpha.0 ## @mastra/mcp-docs-server@1.3.13-alpha.0 ## @mastra/memory@1.41.1-alpha.0 ## @mastra/rag@2.7.3-alpha.0 ## @mastra/redis-streams@0.8.1-alpha.0 ## @mastra/elysia@0.1.23-alpha.0 ## @mastra/express@1.5.27-alpha.0 ## @mastra/fastify@1.5.27-alpha.0 ## @mastra/hono@1.7.25-alpha.0 ## @mastra/koa@1.7.27-alpha.0 ## @mastra/next@0.2.41-alpha.0 ## @mastra/tanstack-start@0.2.41-alpha.0 ## @mastra/spanner@1.11.2-alpha.0 ## @mastra/turso@0.1.21-alpha.0 ## @mastra/inngest@1.11.2-alpha.0 ## @mastra/gcs@0.3.6-alpha.0 ## @internal/playground@1.39.0-alpha.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
8ad7773cd4 |
feat(observability): align signal writes and context modes (#29289) | ||
|
|
a7c4069df2 |
fix(observability): require trace IDs on feedback and score POSTs (#29287)
Requires a nonblank `feedback.traceId` and `score.traceId` on the OSS
observability POST endpoints, with `spanId` still optional. Missing,
null, empty, whitespace-only, and span-only requests return 400 before
storage is called. The generated JavaScript client types now require the
trace ID too.
Previously accepted:
```ts
await client.createFeedback({ feedback: { feedbackType: 'thumbs', value: 1 } });
```
Now:
```ts
await client.createFeedback({
feedback: { traceId: 'trace-123', feedbackType: 'thumbs', value: 1 },
});
await client.createScore({
score: { traceId: 'trace-123', scorerId: 'accuracy', score: 0.9 },
});
```
This tightens the HTTP/type contract and uses minor changesets for core,
server, and client. Callers that previously omitted the trace ID must
now supply it. It does not add a trace-existence lookup or change
storage/batch APIs, historical nullable records, generated IDs, server
timestamps, or response shapes. The existing React feedback caller
already supplies a trace ID. Documentation describes the required trace
ID and optional span ID. Client types and CLI metadata were regenerated,
with no CLI metadata diff.
Validation: 398 tests pass, including shared real-HTTP regressions
across Hono, Express, Fastify, Koa, and NestJS, plus schema and existing
server/client tests. The new rejection cases failed before the fix with
200 responses. Focused client route-type checks, package builds,
type-aware lint, formatting, and documentation checks pass. The broader
client type suite still reports four errors in
`type-tests/trace-query.test-d.ts`; these were reproduced with the
unchanged main files.
Fixes
[OBS-788](https://linear.app/kepler-crm/issue/OBS-788/require-trace-ids-on-oss-score-and-feedback-posts).
Part of [OBS-792](https://linear.app/kepler-crm/issue/OBS-792); aligns
the required trace-ID contract with
[platform#3752](https://github.com/mastra-ai/platform/pull/3752).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
Feedback and score requests must now identify the trace they belong to.
This prevents new requests without a usable trace ID from being saved,
while older records remain readable.
## Summary
- Require a nonblank `traceId` in feedback and score HTTP POST bodies.
Keep `spanId` optional.
- Reject requests with missing, null, empty, or whitespace-only
`traceId` values before calling storage.
- Keep nullable `traceId` values valid in storage and record schemas so
historical records remain readable.
- Update client request types, documentation, and the CLI score-create
example to include the required `traceId`.
- Add shared HTTP contract tests for the Hono, Express, Fastify, Koa,
and NestJS adapters.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
314e6bca25 |
fix(client-js): use consistent tool-result format in stream continuations (#29384)
## Summary
Fixes client tool continuations created by `agent.stream()` to send a
consistent tool-result message format.
The continuation previously mixed fields from two AI SDK message
formats:
```ts
{
input: toolCall.args,
result,
}
```
Core detected the message as AI SDK v4 because it contained `result`.
The v4 adapter expects arguments in `args`, not `input`, so the original
tool arguments could be stored as `{}`.
The continuation now uses the consistent current shape:
```ts
{
input: toolCall.args,
output: {
type: 'json',
value: result,
},
}
```
`agent.stream()` continues accepting all message formats supported by
Core; this change only corrects the format generated internally by
Client JS.
## Test plan
- Added coverage for the recursive public `agent.stream()` request.
- Verified the tool result contains the original `input`.
- Verified the result is sent through `output`, with no legacy `result`
field.
- Updated multi-tool, thread continuation, `toModelOutput`, and
provider-options coverage.
- Ran the complete Client JS client-tool test suite: 48/48 passed.
- Ran Client JS lint and CJS/ESM builds.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
When a tool finishes during a streamed conversation, Client JS now sends
its answer in the format Core expects. This keeps the tool’s original
input intact so the conversation can continue correctly.
## Changes
- Client JS continuation messages now use `output: { type: 'json',
value: result }` instead of the legacy `result` field.
- Tests cover the updated result format, original tool input,
observability metadata, transformed output, and multiple tool calls.
- A changeset marks `@mastra/client-js` for a patch release.
- Combobox story placeholders no longer end with ellipses.
- Playground trace tests now use explicit labels to find delegated
workflow and agent tool calls.
## Validation
Test and build results are not established by the available evidence.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
6e8dfcb83f | chore: version - exit prerelease mode | ||
|
|
4bc3aa672f |
chore: version packages (alpha) (#29255)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/factory@0.27.0-alpha.3 ## @mastra/agent-builder@1.2.0-alpha.3 ## @mastra/core@1.82.0-alpha.3 ## @mastra/mcp@2.8.0-alpha.2 ## @mastra/memory@1.41.0-alpha.3 ## @mastra/playground-ui@68.0.0-alpha.3 ## @mastra/ring-signals@0.1.0-alpha.0 ## @mastra/libsql@1.29.0-alpha.2 ## @mastra/mongodb@1.26.0-alpha.2 ## @mastra/mysql@0.16.0-alpha.3 ## @mastra/pg@1.35.0-alpha.3 ## @mastra/discord@1.3.3-alpha.0 ## @mastra/slack@1.8.1-alpha.0 ## @mastra/teams@0.1.4-alpha.0 ## @mastra/telegram@0.2.5-alpha.0 ## @mastra/client-js@1.59.0-alpha.3 ## @mastra/react@1.14.1-alpha.3 ## @mastra/deployer-cloud@1.82.0-alpha.3 ## @mastra/longmemeval@1.1.41-alpha.3 ## @mastra/opencode@0.1.41-alpha.3 ## create-factory@0.4.2-alpha.3 ## @mastra/code-sdk@1.18.0-alpha.3 ## mastracode@0.49.0-alpha.3 ## @mastra/arize@1.3.29-alpha.2 ## @mastra/arthur@0.4.29-alpha.2 ## @mastra/laminar@1.3.31-alpha.2 ## @mastra/langfuse@1.6.5-alpha.2 ## @mastra/otel-bridge@1.5.21-alpha.2 ## @mastra/otel-exporter@1.5.1-alpha.2 ## @mastra/sentry@1.2.31-alpha.3 ## mastra@1.38.0-alpha.3 ## @mastra/connect@1.3.1-alpha.1 ## @mastra/deployer@1.82.0-alpha.3 ## @mastra/editor@0.17.0-alpha.3 ## @mastra/evals@1.10.11-alpha.0 ## @mastra/mcp-docs-server@1.3.12-alpha.4 ## @mastra/server@1.82.0-alpha.3 ## @mastra/elysia@0.1.22-alpha.3 ## @mastra/express@1.5.26-alpha.3 ## @mastra/fastify@1.5.26-alpha.3 ## @mastra/hono@1.7.24-alpha.3 ## @mastra/koa@1.7.26-alpha.3 ## @mastra/nestjs@0.2.41-alpha.3 ## @mastra/next@0.2.40-alpha.3 ## @mastra/tanstack-start@0.2.40-alpha.3 ## @mastra/turso@0.1.20-alpha.2 ## @mastra/inngest@1.11.1-alpha.2 ## @mastra/temporal@0.5.0-alpha.3 ## create-mastra@1.38.0-alpha.3 ## @internal/playground@1.38.0-alpha.3 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
01524b22db |
feat(core,stores,server): Knowledge page link index and alpha review follow-ups (#29260)
## Summary Follow-ups to the Knowledge alpha (#29159, #29207, #29218, #29256), in one PR: **Page link index** - Knowledge keeps an index of `[[links]]` in page bodies. `countPageLinks` / `listPageLinks` on the Knowledge store return in and out links for a set of pages, gated by the reader's scopes like every other read; note `[[mentions]]` show up as `note` links. - Links resolve when a page is written through the tools, `upsertPage` or `removePage` (id, `scope#key/key` path, scope address, then page name in the page's own scope, then store-wide). Dangling links resolve once their target is created and follow renames, moves, merges and deletes. `knowledge.reindexLinks()` backfills pages written before this release. - Implemented in the in-memory, LibSQL, PostgreSQL, MySQL and MongoDB stores (additive table/collection, no schema bump). Refs over 512 characters stay plain text; the per-request link cap comes from core through the store loader. - Server routes `GET /knowledge/:knowledgeKey/link-counts` and `GET /knowledge/:knowledgeKey/pages/:pageId/links`, client-js methods, and FGA coverage (`knowledge:read` on the knowledge key, denied caller gets 403). **Review follow-ups** - Fenced code and headings parse like CommonMark (closing fence must match the opener; `## Use C#` keeps its `#`); reading the last part of a page that ends in a newline works. - Chunk embedding runs 4 at a time and semantic search stops at its candidate cap. - PostgreSQL and MongoDB refuse to remove a note that's already removed, like the other stores. - Search queries use at most 16 words. - Changeset for the `reindex()` removal scoped correctly. ## Child scopes filtered by reader in the store - `listChildScopes` takes an optional `read` scope and leaves out child scopes the reader can't see before applying the limit and cursor. New `countChildScopes` counts readable child scopes for many parents in one call. All five stores implement both. - `knowledge_list` uses them: it used to page through every child scope under a scope and drop the unreadable ones afterwards, and list each scope's child scopes just to count them. Under a scope with many private child scopes that meant loading all of them. - This changes cost only, not access: `knowledge_list` already removed unreadable scopes before returning anything, so agents see the same entries and counts. Without `read`, the host's full list (Studio, link resolution, `knowledge_read`'s restricted entries) is unchanged. ## Test plan - Core Knowledge + storage: 274 tests pass; tsc 0; oxlint 0/0; oxfmt clean. - Real stores (Docker): LibSQL 77, PostgreSQL 87, MySQL 78, MongoDB 81 pass. - Server Knowledge handlers + adapter FGA: 143 pass. client-js Knowledge: 6 pass. - New tests fail without their fixes (link hooks, host-write links, ref length, fences/headings, candidate cap, embed concurrency, double note removal, FGA route mapping, child scopes filtered before the limit, knowledge_list never receiving unreadable scopes). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 Knowledge pages can now keep track of links to other pages, including when those pages are added, renamed, moved, or removed. Readers can see only links they are allowed to access, and page listings avoid loading child scopes they cannot read. ## What changed - Added a page-link index for `[[links]]` across in-memory, LibSQL, PostgreSQL, MySQL, and MongoDB stores. `knowledge.reindexLinks()` can backfill the index for existing pages. - Added scope-filtered link counts and link-list APIs, server routes, and client-js methods. - Added child-scope filtering before pagination and child-scope counts for readable scopes. - Improved Markdown fence and heading parsing, page-range handling for trailing newlines, embedding concurrency, and semantic-search candidate limits. - Made repeated removal of an already-removed note return `KnowledgeNotFoundError` in PostgreSQL and MongoDB. Updated the `reindex()` changeset. ## Validation Author-reported test and tooling results are available in the PR objectives; they were not independently verified here. Review finding counts are unavailable. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: remy-builder[bot] <324360501+remy-builder[bot]@users.noreply.github.com> |
||
|
|
886679eb10 |
chore: version packages (alpha) (#29205)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. ## @mastra/client-js@1.59.0-alpha.2 ## @mastra/factory@0.27.0-alpha.2 ## @mastra/code-sdk@1.18.0-alpha.2 ## mastra@1.38.0-alpha.2 ## @mastra/core@1.82.0-alpha.2 ## @mastra/editor@0.17.0-alpha.2 ## @mastra/server@1.82.0-alpha.2 ## @mastra/clickhouse@1.29.0-alpha.1 ## @mastra/duckdb@1.18.0-alpha.1 ## @mastra/pg@1.35.0-alpha.2 ## @mastra/platform-workspace@1.12.0-alpha.1 ## @mastra/react@1.14.1-alpha.2 ## @mastra/deployer-cloud@1.82.0-alpha.2 ## @mastra/deployer-sandbox@0.3.26-alpha.1 ## @mastra/longmemeval@1.1.41-alpha.2 ## @mastra/opencode@0.1.41-alpha.2 ## @mastra/parallel@0.1.5-alpha.0 ## create-factory@0.4.2-alpha.2 ## mastracode@0.49.0-alpha.2 ## @mastra/arize@1.3.29-alpha.1 ## @mastra/arthur@0.4.29-alpha.1 ## @mastra/braintrust@1.3.26-alpha.1 ## @mastra/datadog@1.4.21-alpha.1 ## @mastra/deepeval@0.1.23-alpha.1 ## @mastra/laminar@1.3.31-alpha.1 ## @mastra/langfuse@1.6.5-alpha.1 ## @mastra/langsmith@1.4.2-alpha.1 ## @mastra/observability@1.23.1-alpha.1 ## @mastra/otel-bridge@1.5.21-alpha.1 ## @mastra/otel-exporter@1.5.1-alpha.1 ## @mastra/posthog@1.4.6-alpha.1 ## @mastra/sentry@1.2.31-alpha.2 ## @mastra/agent-builder@1.1.33-alpha.2 ## @mastra/deployer@1.82.0-alpha.2 ## @mastra/mcp@2.8.0-alpha.1 ## @mastra/mcp-docs-server@1.3.12-alpha.3 ## @mastra/memory@1.41.0-alpha.2 ## @mastra/playground-ui@68.0.0-alpha.2 ## @mastra/rag@2.7.2-alpha.0 ## @mastra/elysia@0.1.22-alpha.2 ## @mastra/express@1.5.26-alpha.2 ## @mastra/fastify@1.5.26-alpha.2 ## @mastra/hono@1.7.24-alpha.2 ## @mastra/koa@1.7.26-alpha.2 ## @mastra/nestjs@0.2.41-alpha.2 ## @mastra/next@0.2.40-alpha.2 ## @mastra/tanstack-start@0.2.40-alpha.2 ## @mastra/dsql@1.5.6-alpha.0 ## @mastra/libsql@1.29.0-alpha.1 ## @mastra/mongodb@1.26.0-alpha.1 ## @mastra/mssql@1.11.1-alpha.0 ## @mastra/mysql@0.16.0-alpha.2 ## @mastra/oracledb@0.5.6-alpha.0 ## @mastra/spanner@1.11.1-alpha.0 ## @mastra/turso@0.1.20-alpha.1 ## @mastra/voice-google@0.14.5-alpha.0 ## @mastra/inngest@1.11.1-alpha.1 ## @mastra/temporal@0.5.0-alpha.2 ## @mastra/e2b@0.16.1-alpha.1 ## create-mastra@1.38.0-alpha.2 ## @internal/playground@1.38.0-alpha.2 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
642c62fee3 |
feat(core,server,client-js): answer a suspended background task from a chat (#28998)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |
||
|
|
c7d27f650b |
feat(editor): make model fallback lists editable and persistent (#27287)
Adds opt-in Editor ownership for static model fallback lists on
code-defined agents.
```ts
new Agent({
id: 'support-agent',
model: [
{ id: 'primary', model: 'openai/gpt-5.4-mini' },
{ id: 'fallback', model: 'anthropic/claude-sonnet-4-5' },
],
editor: { model: true },
})
```
Studio can reorder models, change provider/model selections, and enable
or disable entries. These changes follow the configured Editor
persistence workflow:
- Database-backed Editor storage creates versioned drafts that can be
published.
- Code-backed Editor storage saves overrides to the filesystem or
through the configured pull-request workflow.
Persisted entries include their order, provider, model ID, enabled
state, and `maxRetries`. Immutable model IDs reconnect stored values to
code-defined entries while preserving non-serializable code
configuration.
Function-valued model configurations remain code-owned and read-only in
Studio.
This also adds storage support, model-list persistence through the
existing server mutation routes, generated client types, regression
coverage, documentation, and a changeset.
Closes #27089.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This lets teams edit and save an agent’s model fallback list in Studio
without changing code. The feature is opt-in, so existing agents keep
their current behavior by default.
## Summary
- Added `editor: { model: true }` support for code-defined agents.
- Added persistent `modelList` storage with entry IDs, provider, model
ID, enabled state, and `maxRetries`.
- Applied stored overrides by matching immutable entry IDs while
preserving code-owned configuration.
- Persisted reorder and update actions through Editor drafts and
publishing workflows.
- Added filesystem, LibSQL, server route, export, versioning, and client
cache support.
- Kept function-valued model configurations code-owned and read-only in
Studio.
- Updated ownership logic, API schemas, client behavior, and
documentation.
- Added regression coverage for runtime overrides, persistence, exports,
ownership, draft activation, storage compatibility, and query
invalidation.
- Added changesets for the affected packages.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
96853ee84f |
feat(observability): add requestId, serviceName and experimentId trace filters (#29194)
## Description Advanced trace queries can now filter by `requestId`, `serviceName`, and `experimentId`, at trace scope and inside `spans.some` / `spans.none`, on PostgreSQL, ClickHouse, and DuckDB. Direct span queries already supported these fields; the trace query path dropped them, so the matching Studio filter chips did nothing. - Registers the three fields in the trace and spans scopes of the trace query registry with `eq`, `ne`, `in`, `notIn`, `exists`, and `notExists`, following the context-ID recipe from #24935. - Adds the `trace-query-context-fields` storage feature. The server reports it as `traceQueryContextFields` in `/observability/capabilities`, returns a structured `501` for a predicate on one of the fields when the store lacks the feature, and omits the fields from field discovery for that store. - Maps the columns in the PostgreSQL, ClickHouse, and DuckDB trace query compilers and adds them to the span projection used by `spans.some` / `spans.none`. No migration: every store already records the columns. - Each store declares the feature only when the installed `@mastra/core` plans the fields, so a new store on an older core does not advertise what the planner rejects. - Server gates for the four context IDs and the three new fields now share one field-to-feature table instead of two if-chains. - Shared conformance cases cover all three stores, including `notExists` on roots that never recorded the field and span-scope binding. - Docs and changesets for `@mastra/core`, `@mastra/server`, `@mastra/client-js`, `@mastra/pg`, `@mastra/clickhouse`, and `@mastra/duckdb`. - Out of scope: the Studio chip list (OBS-495) and Platform parity in mobs-query (OBS-494). `serviceName` is read from span metadata, as today; the observability `serviceName` config value is not written to the span column. ## Related Issue(s) Linear OBS-492. Follows #24935 (OBS-401). ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [x] 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 - [x] I have made corresponding changes to the documentation (if applicable) - [x] 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 --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 Trace queries can now find traces by request, service, and experiment details. The PostgreSQL, ClickHouse, and DuckDB stores support these filters, and the server reports when a store does not. ## Changes - Added `requestId`, `serviceName`, and `experimentId` as trace- and span-query fields. They support `eq`, `ne`, `in`, `notIn`, `exists`, and `notExists` at trace scope and within `spans.some` and `spans.none`. - Added the fields to PostgreSQL, ClickHouse, and DuckDB query mappings and span projections. - Added the `trace-query-context-fields` storage feature. Stores advertise it when the installed core field registry includes the new fields. - Added the `traceQueryContextFields` observability capability. The server omits unsupported fields from discovery and returns a structured `501` for unsupported predicates. - Added shared conformance cases and documentation. Changesets cover `@mastra/core`, `@mastra/server`, `@mastra/client-js`, and the three stores. ## Validation The supplied summary describes new conformance and handler tests, but does not report test execution results. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
30046969ad |
chore: version packages (alpha) (#29146)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases ## @mastra/client-js@1.59.0-alpha.1 ### Minor Changes - Added the `aggregateTimeToFirstMeasures` observability capability. Trace and span aggregate requests for `timeToFirstToken.*` or `timeToFirstChunk.*` measures now return `501` against stores that can't compute them, and field discovery omits those measures for such stores. ([#29055](https://github.com/mastra-ai/mastra/pull/29055)) ```typescript const { capabilities } = await mastraClient.getObservabilityCapabilities(); if (capabilities.traceAggregate && capabilities.aggregateTimeToFirstMeasures) { const { rows } = await mastraClient.aggregateTraces({ timeRange: { from: '2026-08-01T00:00:00.000Z', to: '2026-08-02T00:00:00.000Z' }, groupBy: ['entityName'], measures: ['timeToFirstChunk.p95', 'timeToFirstChunk.count'], }); } ``` ### Patch Changes - Updated dependencies [[`8751dd7`]( |
||
|
|
0900c20592 |
feat(observability): time to first token and chunk measures in trace and span aggregates (#29055)
Part of OBS-773
## What
`aggregateTraces()` and `aggregateSpans()` can now compute streaming
latency, not just duration. Adds 16 measures:
- `timeToFirstToken.{avg,min,max,p50,p90,p95,p99,count}`
- `timeToFirstChunk.{avg,min,max,p50,p90,p95,p99,count}`
Previously `timeToFirstTokenMs` / `timeToFirstChunkMs` could be filtered
and sorted in `queryTraces()` but not charted or compared across groups.
## Semantics
- **Traces** read the root span's value, the same value `queryTraces()`
returns. An agent run copies both values from the first model generation
of its own loop, so trace TTFC is measured from the agent run's start
(includes input processors, memory recall, etc.). Workflow-rooted traces
have neither value and contribute nothing.
- **Spans** read each span's own value. Filter `spanType` to
`model_generation` for per-model-call latency or `agent_run` for
caller-perceived latency.
- **Nulls are skipped, never read as 0.** `avg`/`min`/`max`/percentiles
are `null` for a group with no values; `.count` is the number of rows
that have one. `having` / `orderBy` follow the existing null rules (null
fails comparisons, sorts last).
- Percentiles are approximate where `duration.p*` already is (ClickHouse
`quantileDeterministic`, seeded the same way).
## Gating
- New store feature `aggregate-time-to-first-measures`, declared by
`@mastra/pg`, `@mastra/clickhouse`, `@mastra/duckdb` only when the
installed core has the measures.
- New server capability `aggregateTimeToFirstMeasures`.
- Against a store without the feature, a request using any of these
measures returns `501` (`TRACE_AGGREGATE_UNSUPPORTED` /
`SPAN_AGGREGATE_UNSUPPORTED`) before storage runs, and field discovery
omits them.
## Out of scope / follow-ups
- **Experiments**: recording/summarizing TTFT/TTFC per experiment item
and showing it on the compare page is a follow-up.
- **Platform mobs-query** support (and its benchmark) lands in a
separate Platform PR after a snapshot of this one.
## Test plan
- Core registry/planner unit tests: measure list, rules, approximate
flags, `having`/`orderBy` on new measures.
- Shared conformance cases (fixtures with mixed present/absent values, a
superseded root copy carrying outlier values to prove dedup, percentiles
with tolerance, groups with no values → null/0, ordering of null groups)
run against:
- DuckDB: `stores/duckdb` `src/storage` — 554/554
- PostgreSQL: `index.vnext.test.ts` — 276/276
- ClickHouse: `v-next` — 726 passed, 1 skipped
- Server: 501 for each new measure on stores without the feature,
success with it, capability derivation, discovery filtering.
- `@mastra/client-js` route types regenerated and typechecked.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
This PR lets trace and span reports show how long it takes to produce
the first token or chunk. Supported storage systems can calculate these
measures; unsupported systems tell clients that the measures are
unavailable.
## Summary
- Adds average, minimum, maximum, p50, p90, p95, p99, and count measures
for `timeToFirstToken` and `timeToFirstChunk` in `aggregateTraces()` and
`aggregateSpans()`.
- Trace measures use root-span values. Span measures use each span’s own
values.
- Calculations skip null values. Groups without values return `null` for
statistical measures and `0` for counts.
- PostgreSQL, ClickHouse, and DuckDB advertise support when the core
measure registry provides the required measures.
- Adds the `aggregateTimeToFirstMeasures` server capability. When a
store lacks support, the server returns `501` for requests using these
measures and omits them from field discovery.
## Testing
The PR description reports passing tests for DuckDB (554/554),
PostgreSQL (276/276), and ClickHouse (726 passed, 1 skipped). It also
reports tests for capability gating and field discovery, plus
regenerated and typechecked `@mastra/client-js` route types.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
|
||
|
|
eed9cc214e | chore: version packages | ||
|
|
3975787ca3 |
fix(client-js): let request headers replace client headers regardless of casing (#29073) | ||
|
|
ba602f5f46 |
feat(server): read-only Knowledge routes and client methods so Studio can browse a Knowledge instance (#29069)
Replaces #28363, which the triage bot closed. > Stacked on #28362 (core Knowledge page readers), which is stacked on #28361 (shared Knowledge explorer UI), on the Knowledge alpha branch (#28353). Experimental: depends on the alpha's schema-4 page store. ## What this adds **Read-only Knowledge routes in `@mastra/server`**, opt-in via `KNOWLEDGE_ROUTES`: | Route | Returns | | - | - | | `GET /knowledge` | Instances the caller can read | | `GET /knowledge/:key/tree` | Root scopes, or child scopes and pages under `parentId` (paged) | | `GET /knowledge/:key/pages/:pageId` | Page with ancestors, notes, pin, referenced pages, mentioned-by | | `GET /knowledge/:key/graph` | Bounded page graph with parent and mention edges | | `GET /knowledge/:key/search` | Pages and notes matching a query | | `GET /knowledge/:key/activity` | Recent changes, optionally per scope or page | Matching `listKnowledge()` / `getKnowledge(key)` methods in `@mastra/client-js`. **A Knowledge page in Studio**: page tree beside the graph with synced selection, a detail pane for the selected page, search, and a Tree/Graph toggle below 1024px. When the routes aren't registered the page explains how to enable them. ## Access model What a caller reads depends on whether the app configures auth (`server.auth` or `studio.auth`). - **No auth** (a local or test project): the routes read the whole instance (`read: 'all'`). - **Auth:** the routes read only what the signed-in caller can read. The app maps the user to Knowledge principals in `authorize` by setting the reserved request-context key `MASTRA_KNOWLEDGE_PRINCIPALS_KEY` (or `'all'` for an admin). The instance resolves them with `readScopeFor`, and every reader gets the resulting read scope. A caller with no mapping gets 403. A malformed mapping, or a principal that matches no declared scope type, returns 500 because it's a host configuration error. On top of that: `knowledge:read`, and with FGA, per-instance checks keyed by the registered Knowledge key (`GET /knowledge` filtered, other routes 403 for other instances). ## Known limits - `GET /knowledge` has no route FGA metadata, like every other list route (`GET /agents`, `/workflows`, `/tools`), so `requireForProtectedRoutes` refuses it and `auditProtectedRoutes` lists it; the handler still filters instances per caller. This replaces the earlier caller-supplied scope tags and `MASTRA_KNOWLEDGE_SCOPE_KEY` binding. The `authorize` context change from that work stays (adapters now expose `requestContext` to `authorize`, and Elysia keeps repeated query values). ## Tests - Server suite 3,098 passed; permission generator check passes. - Shared adapter suite (`knowledge-routes`) on Hono, Express, Fastify, Koa, Elysia: 200 with `knowledge:read`, 403 without, 401 with no token, repeated `scopeId` honoured. - Studio page MSW tests 10/10; 7 of them fail against the previous scope-form page. - Playground and server `tsc` clean; oxlint clean. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 This PR lets Studio browse Knowledge data without changing it. It adds optional server routes, matching client methods, and a Studio page to view and search that data. ## What changed - Added opt-in, read-only Knowledge routes for listing instances, browsing trees and pages, viewing graphs, searching, reading activity, and receiving change events. These routes are not mounted by default. - Added `MastraClient.listKnowledge()` and `MastraClient.getKnowledge(key)`, plus Knowledge methods for read requests and event streams. - Added a Studio Knowledge page with instance selection, tree and graph views, page details, search, and live updates. Polling is the fallback when streaming is unavailable. - Added `knowledge:read` permission handling and auth-based access controls. When auth is configured, the host must map callers to Knowledge principals. - Updated route tooling to include opt-in routes. Updated the Elysia adapter to preserve repeated query parameters and authorization context handling so `authorize` can access `requestContext` and `mastra`. - Added documentation, changesets, and tests for Knowledge routes, client methods, Studio behavior, and server adapters. ## Tests The PR description reports 3,098 server tests and 10/10 Studio MSW tests passing. It also reports that the permission-generator check, Playground and server TypeScript checks, and oxlint completed cleanly. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: remy-builder[bot] <324360501+remy-builder[bot]@users.noreply.github.com> Co-authored-by: avis-reader[bot] <332681745+avis-reader[bot]@users.noreply.github.com> Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com> |