0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

Compare commits

..

24 commits

Author SHA1 Message Date
mastra-platform[bot]
30852ab5fe
docs(client-js): align retry docs with the write default (#30435)
Co-authored-by: sdivyanshu90 <97019230+sdivyanshu90@users.noreply.github.com>
2026-11-17 09:22:33 +01:00
mastra-platform[bot]
657d2e2127
docs: clarify DurableAgent.abortThreadStream returns false while still forwarding the abort (#30439) 2026-11-17 09:01:13 +01:00
mastra-platform[bot]
cf6f1b0459
docs(otel): sort vendors alphabetically on OpenTelemetry integration page (#30670) 2026-11-17 08:58:25 +01:00
mastra-platform[bot]
3ff2824bd4
fix(factory-ui): show notification summaries as a readable inline line (#30662)
> Opened by @damien-schneider

## Description

When pending notifications are rolled into a summary, Factory chat
showed them as a row labeled "Notification summary" followed by the raw
summary text, e.g. `factory-session: 1`. The row also used the padded,
caption-sized activity style. It sat between inline signal lines like
"Factory sessions snapshot", so it looked out of place and read like
debug output.

The summary now renders like those inline lines and is built from the
structured fields every summary carries (`pending`, `bySource`,
`byPriority`):

- **Label and count:** "Notifications" followed by "1 new" / "4 new".
- **Sources:** one badge per source. With a single source it shows just
the name (`Factory session`). With several, each badge has its count
(`GitHub 3`, `My webhook 1`).
- **Source names:** a small map gives readable names for known sources
(`factory-session`, `github`, `gitlab`, `linear`, `jira`, `slack`). Any
other source shows its id in sentence case (`my-webhook` → "My
webhook"), so new sources need no code change.
- **Priority:** the bell is tinted only when something high or urgent is
pending.
- **Fallback:** a summary with no counts shows its original text.

The change is limited to `NotificationSummaryCard` in factory-ui. The
shared `NotificationActivity` component and individual notification rows
are unchanged.

## Test plan

- `TranscriptNotifications.msw.test.tsx` covers a single Factory session
summary (no raw `factory-session: 1` text), several sources including an
unmapped one, and the fallback with no counts.
- `pnpm typecheck`, oxlint and prettier pass on factory-ui.

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

ELI5: When many alerts are waiting, the app used to show a plain block
of raw text. Now it shows one short line that says how many are new and
where they came from.

## Summary

This PR changes how `NotificationSummaryCard` renders notification
summaries in factory-ui. The card now shows an inline activity line
instead of a padded row with raw summary text.

### Changes

**`TranscriptNotifications.tsx`** (+47/-2)

- Replaces the `NotificationActivity` call in `NotificationSummaryCard`
with an `Activity` line. The line contains a bell icon, a
"Notifications" label, and a status label.
- Shows `"<pending> new"` when `pending > 0` and at least one source has
a count above zero. Otherwise, shows `entry.message`.
- Adds one `Badge` per source with a positive count. With one source,
the badge shows the source name. With several sources, the badge shows
the name and count, for example `GitHub 3`.
- Tints the bell only when `byPriority` has an `urgent` or `high` count
above zero.
- Adds a `NOTIFICATION_SOURCE_NAMES` map for `factory-session`,
`github`, `gitlab`, `linear`, `jira`, and `slack`.
- Adds exported `notificationSourceName(source: string): string`. It
returns the mapped name for a known source. For an unknown source, it
replaces `-` and `_` with spaces and applies sentence case. An empty ID
is returned unchanged.
- Adds an own-key check when it looks up source names. IDs such as
`__proto__` do not match inherited object properties. These IDs use the
sentence-case fallback, so the component does not render an invalid
React child.
- Imports the `Activity`, `ActivityHeader`, `ActivityIcon`, and
`ActivityLabel` primitives and `Badge`.

**`TranscriptNotifications.msw.test.tsx`** (+67/-9)

- Replaces the test that checked for the summary under its own label.
- Adds a test for one pending `factory-session` notification. It checks
for `Notifications`, `1 new`, and `Factory session`. It checks that the
raw `factory-session: 1` text and any button are absent.
- Adds a test for multiple sources, including an unnamed source. It
checks the total and the per-source counts.
- Adds a test for a summary with no counts. It checks that the summary
message is shown.
- Adds a test that a source named `__proto__` displays as `Proto`.

### Scope

- The shared `NotificationActivity` component is not changed by this
diff.
- Individual notification rows are not changed by this diff.
- The diff touches only these two files under `mastracode/factory-ui/`.

### Verification

- The PR author reports that `pnpm typecheck`, oxlint, and prettier pass
on factory-ui. These results were not re-run for this summary.
- The new tests exist in the diff. Their pass or fail status was not
checked.
<!-- 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>
2026-11-16 23:52:44 -08:00
mastra-platform[bot]
4985b71a20
fix(playground-ui): run CodeDiff lines flush under the file header (#30668)
> Opened by @damien-schneider

## What

When the Factory changes panel stacks file diffs, a blank band shows
below each file's last line and above the next file's first line.
`@pierre/diffs` adds 8px of padding above the code, and by default it
always keeps room for a horizontal scrollbar under it. The design
system's `CodeDiff` places that code on the card fill, so both show up
as empty strips.

When a `CodeDiff` has a file header, it now sets a `data-header`
attribute. A matching rule in `code-diff.css`, next to the other
`--diffs-*` overrides, sets two of pierre's variables. pierre doesn't
set these itself, so the values reach the diff's shadow DOM:

- `--diffs-gap-block: 0px`: no padding above the first line or below the
last, and the "N unmodified lines" separators between hunks sit flush
too.
- `--diffs-overflow-override: auto`: the horizontal scrollbar only takes
room when lines overflow. Platforms with overlay scrollbars, like macOS,
reserve no room for it.

A `CodeDiff` without a header keeps its padding. That case is the
standalone diff in the observation detail view.

## Test plan

- [x] `vitest run src/ds/components/CodeDiff`: 6/6 pass
- [x] `oxlint` and `prettier --check` pass on the changed files
- [x] Storybook `Elements/CodeDiff` in Chromium with real scrollbars.
File list: 0px top and bottom padding and no scrollbar strip, where
before there was 8px of padding plus a 15px strip under every file. A
multi-hunk diff with overflowing lines: flush lines and separators, with
a scrollbar only on the diff that overflows. A diff without a header
keeps its 8px padding.
- [ ] Full `tsc` for `playground-ui` didn't finish in the sandbox. The
TSX change only adds a `data-header` attribute.


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

<!-- coderabbit-ai-generated:v1 -->

ELI5: When a code diff has a file name bar on top, the diff used to have
empty gaps. This change removes the gap under the bar. It also makes the
horizontal scrollbar appear only when the code is too wide.

## Summary

This change adjusts `CodeDiff` layout when a file header is present. The
outer container gets a `data-header` attribute. A CSS rule for that
attribute sets the block gap to `0px` and sets overflow to `auto`. Diffs
without a header are unchanged. A patch changeset for
`@mastra/playground-ui` documents the change.

## Changes

- `packages/playground-ui/src/ds/components/CodeDiff/code-diff.tsx`
(+5/-1): The root `div` sets `data-header` to an empty string when
`header` is provided. It sets the attribute to `undefined` otherwise.
The `ref` and class names are unchanged.
- `packages/playground-ui/src/ds/components/CodeDiff/code-diff.css`
(+7): Adds a comment and a `.code-diff[data-header]` rule. The rule sets
`--diffs-gap-block: 0px` and `--diffs-overflow-override: auto`.
- `.changeset/flush-diff-lines.md` (+5): Adds a patch entry for
`@mastra/playground-ui`. It states that headered diffs have no blank
band above the first line or below the last. It also states that the
horizontal scrollbar takes space only when lines overflow.

## Notes

- The diff does not set `padding-block: 0`, `scrollbar-width: thin`, or
any shadow-root selector. The PR objectives describe these, but the diff
does not contain them. This summary follows the diff.
- No exported or public declarations changed.
- Totals: 3 files changed, 17 lines added, 1 line removed.
- The PR objectives report that `vitest run src/ds/components/CodeDiff`
passed (6/6) and that `oxlint` and `prettier --check` passed. They also
report that full `tsc` did not finish. These results come from the PR
description. They were not re-run here.

<!-- 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>
2026-11-16 23:51:12 -08:00
Eric Pinzur
135aa65c3c
fix(otel-bridge): deliver logs in apps on OpenTelemetry JS SDK 3 (#30546)
## Description

In an app on OpenTelemetry JS SDK 3, `OtelBridge` dropped every Mastra
log without an error. Spans were fine.

The bridge only looked for the app's global `LoggerProvider` in
`@opentelemetry/api-logs`. SDK 3 apps register theirs through `logs`
from `@opentelemetry/api` (1.10 and later), and the two registries don't
see each other, so the bridge got a no-op proxy.

The bridge now checks both registries on each log and each flush and
uses whichever holds a registered provider. SDK 2 apps keep working,
including when `@opentelemetry/api` 1.10 is installed next to SDK 2. A
provider registered after `new OtelBridge()` is picked up too. When
nothing is registered anywhere, the bridge says so once at debug level,
so a missing registration can be told apart from a bug.

```ts
// SDK 3 app
import { logs } from '@opentelemetry/api';
logs.setGlobalLoggerProvider(loggerProvider);

new OtelBridge(); // before: logs dropped. after: logs reach loggerProvider
```

Passing `new OtelBridge({ loggerProvider })` behaves as before.

The four new tests fail with the fix reverted. I also ran the built
bridge against the published `@opentelemetry/sdk-logs` 3.1.0 and
`@opentelemetry/api` 1.10.0 in a scratch project, and the log arrived
whether the provider was registered before or after the bridge was
constructed.

This does not move the package to SDK 3. That is tracked in #29696.

## Related issue(s)

Fixes #29695

## 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
- [ ] I have addressed all Coderabbit comments on this PR

---
_Generated by [Claude
Code](https://claude.ai/code/session_018e9kMajbtR6UM1nrfYpvGa)_

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

<!-- coderabbit-ai-generated:v1 -->

**ELI5:** Mastra sends its logs through the app's OpenTelemetry setup.
On newer OpenTelemetry versions, the app registers its log sender in a
different place. Mastra looked only in the old place, so it lost every
log. This PR makes Mastra look in both places.

## Summary

This PR fixes `@mastra/otel-bridge` so it drops no logs in apps that use
OpenTelemetry JS SDK 3. The bridge now finds the global `LoggerProvider`
in either registry:

- `logs` from `@opentelemetry/api`, used by SDK 3 apps.
- `logs` from `@opentelemetry/api-logs`, used by SDK 2 apps.

### Changes

- **`observability/otel-bridge/src/bridge.ts`**
- Adds `globalLogsApis()`. It reads `logs` from the `@opentelemetry/api`
namespace object, not as a named import. This keeps the module linkable
on `@opentelemetry/api` versions below 1.10, which do not export `logs`.
The `api-logs` registry is always checked too.
- Adds `getGlobalLoggerProvider()`. It returns the first provider that
is not an unregistered proxy. It also returns whether a provider was
registered. The proxy check tests for a `_setDelegate` function.
- Adds `resolveLogger()`. When no `loggerProvider` is passed in config,
it re-reads the global provider on each log emit. This picks up
providers registered after the bridge is constructed. If the provider
changes, it rebuilds the logger.
- When no provider is registered, `resolveLogger()` writes one debug
message. The message is written once per bridge instance. It explains
how to register a provider or pass one to `new OtelBridge({
loggerProvider })`.
- `flush()` uses the same global lookup for the logger provider when no
`loggerProvider` is passed in config.
  - The constructor uses the same lookup for its initial logger.
- An explicit `loggerProvider` in config is unchanged. It is never
re-resolved.
- **`.changeset/quiet-logs-arrive.md`**: adds a patch changeset for
`@mastra/otel-bridge`.
- **`observability/otel-bridge/src/bridge.test.ts`**: adds tests. They
cover a provider registered through `@opentelemetry/api`, with
registration before and after bridge construction. They also cover
flushing that provider and the single debug message when no provider is
registered. The author reports that four new tests fail with the fix
reverted.

### Scope

- Only log delivery changes. Span handling is not changed.
- The package stays on the SDK 2 line. The move to SDK 3 is tracked
separately in `#29696`.
- The author reports a scratch-project check with
`@opentelemetry/sdk-logs` 3.1.0 and `@opentelemetry/api` 1.10.0. In that
check, the log arrived whether registration happened before or after
bridge construction. This check was not run in CI as part of this
review.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-17 12:52:26 +05:30
mastra-platform[bot]
c2fc2fca28
fix(factory): open the card's session from posted card links (#30666)
> Opened by @damien-schneider

## Summary

Factory card links that agents post (Slack replies, GitHub comments,
tool results like `factory_create_work_item` /
`factory_transition_work_item` / `factory_list_work_items`) opened the
board with `?item=<id>`. The UI treats that as a highlight on the board
list, so people landed on the list and had to find and click the card
again to reach its session.

`factoryWorkItemUrl()` now builds `/factories/<id>/cards/<workItemId>`.
That's the route a board click already uses: it redirects to the session
the card shows (the current phase's context, otherwise the most recently
visited one), or to a draft that starts one if the card has no session
yet. The `board` argument is gone because the card route resolves the
board on its own.

In-app board highlights (`?item=` from the attention list) stay as they
are.

## Test plan

- `mastracode/factory`: `links.test.ts`, `read-tools.test.ts`,
`work-item-tools.test.ts` updated to expect `/cards/<id>`. All 67 pass,
and `tsc --noEmit` is clean.
- `mastracode/factory-ui`: added a `CardDraftPage` MSW test showing that
`/cards/<id>` on a card with triage and work sessions, sitting in
Building, redirects to the work session's thread. The file's 12 tests
pass.


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

<!-- coderabbit-ai-generated:v1 -->

ELI5: When an agent posts a link to a work card, the link now opens that
card's work session. Before, it opened the board list. Readers now go
straight to the work they need.

## Summary

Posted card links now use the card route. `factoryWorkItemUrl()` returns
`/factories/<id>/cards/<workItemId>`. It no longer returns a board URL
with an `?item=<id>` query parameter.

The card route resolves the board, so the `board` input is removed from
`factoryWorkItemUrl()`. Its signature changes from `{ factoryProjectId,
board, workItemId }` to `{ factoryProjectId, workItemId }`.

The card route behaves as follows:
- It redirects to the session for the card's current phase when one
exists.
- If not, it redirects to the most recently visited session.
- If the card has no sessions, it opens a draft that starts a session.

### Changes by area

- **Link generation (`mastracode/factory/src/links.ts`):** Builds card
links from the project and work item IDs. The work item ID is
URL-encoded. The documentation describes the new routing.
- **Callers (`read-tools.ts`, `work-item-tools.ts`):** Stop passing the
board key to `factoryWorkItemUrl()`. Board-based stage validation and
transitions still use the work item's board.
- **Tests (`links.test.ts`, `read-tools.test.ts`,
`work-item-tools.test.ts`):** Expect `/cards/<id>` URLs. The
no-public-URL case expects `undefined`.
- **UI test
(`mastracode/factory-ui/src/ui/pages/__tests__/CardDraftPage.msw.test.tsx`):**
Adds a test. A card with `triage` and `work` sessions in the `execute`
stage redirects to the thread for the `work` session.
- **Changeset (`.changeset/card-links-open-session.md`):** Declares a
patch release for `@mastra/factory`.

Board highlights in the in-app attention list are unchanged.

### Scope

8 files changed, 47 lines added, 21 lines removed.

### Test status

The PR author reports these results. This summary does not verify them
against completed CI checks on the current head:
- `mastracode/factory`: 67 tests pass in the updated files. `tsc
--noEmit` is clean.
- `mastracode/factory-ui`: 12 tests in `CardDraftPage.msw.test.tsx`
pass.

### API impact

`factoryWorkItemUrl()` has a breaking signature change for direct
callers. The `board` input is removed. The changeset is a patch release.

<!-- 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>
2026-11-16 23:08:59 -08:00
Damien Schneider
ec3fd034e5
feat(factory): let org admins create skills for one Factory (#30647)
## Description

Factory could edit the skills an app already ships (#29042), but it
couldn't create new ones. Settings › Skills now has a **New skill**
button. An org admin enters a name, description and instructions, and
the skill belongs to that one Factory. No redeploy is needed. Agents
load it from their next session, and a board phase can run it as
`runner.skill`. Created skills show a **Custom** badge and can be edited
or deleted from the same dialog.

What changed:

- **Storage:**
- `factory_skill_overrides` gets an additive `kind` column (`edit` |
`created`). It defaults to `edit`, so existing rows keep working. I
checked that an existing Postgres table upgrades in place.
- `create()` and `updateCreated()` run under the existing revision-row
lock. A second create of a name returns null, and so does a save that
lands after a delete, so a late save doesn't bring the skill back.
- **Sessions:**
- Created skills come from the snapshot each workspace already loads for
edits, so there is no new query on the session path.
- `FactorySkillSource` serves a created skill when no code, folder or
built-in skill has a `SKILL.md` under that name. It also reserves the
name, so a repository skill with the same name stays hidden.
- A folder or file the app left behind under the name doesn't hide a
created skill.
  - Edits whose original skill was removed stay hidden, as before.
- **API:**
- `POST /web/factory/projects/:id/skills` with `{ name, content }`
creates a skill. It returns 409 `skill_exists` when an app skill or
another created skill already uses the name.
- `PUT /web/factory/projects/:id/skills/:name` updates a created skill,
and `DELETE` on the same path deletes one, returning `{ skill: null }`.
- Responses are built from the row that was written, not from a reread.
- Admins only. New audit actions: `factory.skill.created` and
`factory.skill.deleted`.
- **Boards:**
- Board validation and board problems count the project's created
skills, so a phase can run one.
- The board cache rechecks when the project's skill revision moves. If
the names can't be read, the boards still load, flag the skill as
missing, and aren't cached.
- A board *write* that can't read the names fails with the storage error
instead of `unknown_skill`.
- `upsertBoard()` checks each project listed in `projects`. A board for
`'all'` projects may only run app skills.
- **CLI:** new `mastra api factory skill create`. Route metadata is
regenerated.
- **UI:**
- New skill dialog, which reuses `SkillSimpleForm` with an editable name
and checks the name format client-side. The name is quoted in the
SKILL.md it writes, so names like `123` work.
  - **Custom** badge on the Skills page and the phase page.
  - **Delete** with an inline confirmation.

If an app later ships a skill with the same name, the app's skill takes
over the name and the Factory's text becomes an edit of it. It keeps
applying, the editor shows "original changed", and **Revert to
original** switches to the app's skill. Nothing is lost.

One review suggestion is deliberately not applied. CodeRabbit suggested
wiring the board cache's skill reader even when the `skill-overrides`
domain isn't ready at boot. Sessions get skill edits under the same
boot-time readiness check (`factory.ts`, where the workspace factory is
built). Changing only boards would let a board accept a skill that
sessions can't load, so both keep that check.

⚠️ **Before release:** `factory.skill.created` and
`factory.skill.deleted` must be registered in the WorkOS dashboard
(Audit Logs → Events), like the edit actions were.

## Related issue(s)

None. Follow-up to #29042 (skill edits) and #28823 (custom board
skills).

## 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)
- [x] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update

## Test plan

All new tests use real storage and real routes, with no mocked storage.
I checked that each fix's test fails without that fix.

- **Storage (LibSQL and Postgres):**
  - create once per name, including under concurrency
  - `updateCreated` refuses after a delete, and never touches edits
  - an orphaned edit gives way to a created skill
  - an existing table upgrades in place
- **Routes:**
  - create, update and delete, each with its audit event
  - 409 for app-skill and duplicate names
  - 400 for an invalid SKILL.md or name
  - 403 for non-admins, and 404 for another org's project
  - an all-digit name works
- responses stay correct when another admin deletes the skill
mid-request
  - a created skill becomes an edit once the app ships the same name
- **Sessions:**
- the creating project's sessions load the skill, and another project's
don't
  - a delete reaches new and reused workspaces
  - a repository skill with the same name is hidden
  - a leftover folder or stray file doesn't hide the created skill
- **Boards and `upsertBoard()`:**
- a phase running a created skill is accepted, and flagged missing after
a delete
  - a names read that fails once recovers on the next load
  - a write fails with the storage error
  - named projects are each checked, and `'all'` stays app-only
- **UI (MSW):**
- create sends the expected SKILL.md (quoted name) and shows **Custom**
- an invalid name keeps Create disabled, and a 409 message shows in the
dialog
  - non-admins get no button
  - delete asks for confirmation
- **Results:**
- `@mastra/factory`: `check` and `lint` pass, and 32 focused test files
(920 tests) pass.
- `factory-ui`: `typecheck`, `test:unit` and the skills and board-config
MSW tests pass.
  - CLI descriptor test passes.
  - Not tried in a running Factory in a browser yet.

## Checklist

- [ ] 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VhgyDSnuLvveDjDQduz1fT

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

<!-- coderabbit-ai-generated:v1 -->

ELI5: Organization admins can now create a new skill for one Factory
project without a new app release. Sessions and board phases can then
use that skill. Admins can also edit or delete it.

## Overview

This change adds Factory-scoped skills. Admins create them in the UI or
the CLI. A created skill belongs to one Factory project. Admins can edit
and delete it. The skill works in sessions, board phases, and board
validation.

## Storage

- `SkillOverridesStorage` adds a `kind` field to each record. Valid
values are `edit` and `created`. The database default is `edit`.
- `upsert` accepts an optional `kind`. The default is `edit`.
- The new `create` method stores a created skill with an empty
`baseHash`. If a created skill with the same name exists, `create`
returns `null` and does not change the revision. Otherwise, it replaces
any existing row and increments the project revision in one transaction.
- `updateCreated` saves changes only to an existing created skill.
Otherwise, it returns `null`.
- The audit `skill` action list adds `created` and `deleted`.

## Catalog and sessions

- `FactorySkillInfo.origin` adds the value `project`. It adds optional
`created` metadata with `updatedBy` and `updatedAt`.
- `listFactorySkills` includes created overrides whose names do not
match an original skill. It sorts the combined list by name.
- A name that matches an original skill appears as an edit to that
original skill.
- The new `projectSkillNamesOf` adapter returns the storage revision and
the created-skill names for a board scope.
- `workspace.ts` adds an optional `created` flag to
`FactorySkillOverride`. Created skills appear as directories that
contain `SKILL.md`. Created skill names are excluded from repository
skills.

## Boards

- `ProjectBoardCache` accepts a `projectSkills` provider. It stores the
skill revision with each board check. It rechecks board skill problems
when the revision changes.
- If reading project skill names fails, the cache logs one warning per
project. It compiles with an empty set. It records an unreadable
revision so the next load retries.
- `findBoardSkillProblems` accepts a `projectSkills` set. A runner skill
that matches a project skill name counts as found.
- `BoardWrites.validate` accepts an optional `projectSkills` set. Board
create, replace, and validate paths pass it.
- `MastraFactory.upsertBoard` checks each named project against that
project's skill names. A board for `'all'` projects can use only app
skills.
- `factory.ts` supplies the resolver only when the `skill-overrides`
storage domain is ready.

## API

- The new `skillCreate` route is `POST
/web/factory/projects/:id/skills`. Its body schema checks the name and
content.
- The create handler returns `409` when the name matches an original
skill or when storage reports a conflict. Otherwise, it returns `201`
with the catalog entry.
- Edit works for a skill that has an original or an existing override of
kind `created`.
- Revert of a created skill deletes it, audits `factory.skill.deleted`,
and returns `skill: null`.

## CLI

- `mastra api factory skill create` uses the `skillCreate` route and
requires JSON input.
- The `update` and `revert` descriptions now cover project-created
skills.

## Factory UI

- `FactorySkillsSection` shows a **New skill** button when `factoryId`
is set and `canEdit` is true. It shows a **Custom** badge for
`project`-origin skills. `PhaseConfig` shows the same badge.
- `FactorySkillEditorDialog` supports create and edit. Its `skill` prop
is optional. Names allow lowercase letters and digits separated by
single hyphens, up to 64 characters. The description must be nonempty
after trimming.
- For project-origin skills, the dialog offers delete with confirmation.
Confirming calls the edit mutation with `content: null`.
- `useFactorySkillCreateMutation` is added. The edit and create
mutations invalidate the skills and board catalog queries.

## Notes

- If an app later ships a skill with the same name, the app skill takes
over the name. The Factory text remains as an edit. Reverting it removes
the Factory text.
- `factory.skill.created` and `factory.skill.deleted` must be registered
in WorkOS before release. The PR objectives state this requirement. The
diff does not verify it.

## Test coverage

- Storage tests cover create, the duplicate case, kind preservation on
upsert, replacement of an edit, and six concurrent creates that yield
one result.
- Route tests cover creation and audit records, edit and delete of
created skills, conflicts, invalid content, permission checks, and
app-skill takeover.
- Workspace tests cover session visibility, reuse, other projects, and
deletion.
- Board tests cover unknown-skill refusal and recovery after creation or
deletion.
- UI MSW tests cover creation, invalid names, duplicate-name errors,
admin-only access, and confirmed deletion.
- The PR author reports these results. This review did not verify them
against the current head:
  - `@mastra/factory` `check` and `lint` pass.
  - Focused suites pass across 32 files and 911 tests.
  - `factory-ui` `typecheck` and `test:unit` pass (776 tests).
  - The CLI descriptor test passes.

## Review metrics

- Files changed: 28. Lines added: 1447. Lines removed: 163.
- Review findings: not available.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 23:08:01 -08:00
dane-ai-mastra[bot]
f346f6c4af
chore: version packages (alpha) (#30660)
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/core@1.84.0-alpha.6

### Minor Changes

- Knowledge storage can supply scope declarations, access rules
included. ([#29428](https://github.com/mastra-ai/mastra/pull/29428))

A store returns declarations from `getScopeDeclarations()` (none by
default). Knowledge merges them under its config's: the config wins on a
key both declare, and a declaration that doesn't compile is skipped with
a warning. When stored scopes come from a skipped declaration, the
declaration check's error names that declaration and why it was skipped,
so it can be fixed in the store. The store's answer is reused for 30
seconds and read again after `renameScopeDeclaration`, so a declaration
the store adds, removes or changes (access rules included) applies
within that window without a store read on every call. Revoking access
through the store can therefore take up to 30 seconds to take effect.

  ```ts
  class ImportingKnowledgeStorage extends InMemoryKnowledgeStorage {
    override async getScopeDeclarations() {
      return {
        'imports:$name': {},
'linear:$account:$connection': { access: [{ principal: 'imports:all',
role: 'viewer' }] },
      };
    }
  }
  ```

Runs that hold `imports:all` then read every Linear connection's pages.
## @mastra/platform@0.1.0-alpha.1

### Minor Changes

- Added `PlatformBrowser`, a Stagehand browser backed by a Mastra
Platform browser session. By default it provisions a session with `POST
/v1/browsers/sessions` on the Platform and connects to the returned CDP
URL; pass `cdpUrl` to connect to a session you already provisioned, with
no token or API call. The access token falls back to
`MASTRA_PLATFORM_ACCESS_TOKEN` / `MASTRA_PLATFORM_SECRET_KEY`, the
project to `MASTRA_PROJECT_ID`, and the API URL to
`MASTRA_BROWSER_API_URL`. `@mastra/platform` now depends on
`@mastra/stagehand` at runtime.
([#29428](https://github.com/mastra-ai/mastra/pull/29428))

  ```ts
  import { PlatformBrowser } from '@mastra/platform';

const agent = new Agent({ name: 'browser-agent', model, browser: new
PlatformBrowser() });
  ```

- Added `@mastra/platform`: hosted Mastra Platform Memory and Knowledge
clients, with Platform Sandbox and Filesystem re-exported from
`@mastra/platform-workspace`. `PlatformMemory` is a drop-in `memory` for
`Agent` that loads observations and recent messages from a Platform
Memory instance and saves each turn back; observation and reflection run
on the Platform. `PlatformMemoryClient` exposes the same API directly.
Credentials fall back to `MASTRA_PLATFORM_ACCESS_TOKEN` /
`MASTRA_PLATFORM_SECRET_KEY`. `PlatformMemory` uses
`MASTRA_MEMORY_INSTANCE_ID`; `PlatformKnowledge` uses
`MASTRA_KNOWLEDGE_INSTANCE_ID`. `PlatformKnowledge` takes every scope
declaration and access rule from its instance, Memory's and Platform
importers' included, and has no `scopes` option. Agents read imported
pages when their runs hold the scope an importer's rule grants (for now
`imports:all`).
([#29428](https://github.com/mastra-ai/mastra/pull/29428))

  ```ts
import { PlatformMemory, PlatformKnowledge, PlatformSandbox,
PlatformFilesystem } from '@mastra/platform';

const agent = new Agent({ name: 'assistant', model, memory: new
PlatformMemory() });
  ```

### Patch Changes

- `PlatformKnowledge` now supports listing pins: `knowledge_pin` with
`kind: 'list'` pins a page's listing on hosted Knowledge instead of
refusing it as an old storage adapter.
([#29428](https://github.com/mastra-ai/mastra/pull/29428))

- `PlatformMemory` fixes for read-only runs and working memory:
([#29428](https://github.com/mastra-ai/mastra/pull/29428))

- A read-only run (`memory: { options: { readOnly: true } }`) now sees
the thread's observations and unobserved messages, read through the
Memory instance's read-only context route. Before, it got no stored
context at all. It still saves nothing and starts no observation.
- The `workingMemory` option now delivers what it says: `readonly` and
`tool` add the resource's stored working memory to each run's prompt,
read fresh each run; `tool` also tells the agent to update it with
`updateWorkingMemory`; `off` leaves it out. Before, stored working
memory never reached the prompt in any mode.

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6

See [release notes](https://github.com/mastra-ai/mastra/releases) for
published changes.
## @mastra/client-js@1.60.1-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
## @mastra/react@1.15.1-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/client-js@1.60.1-alpha.6
## @mastra/deployer-cloud@1.84.0-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/deployer@1.84.0-alpha.6
## @mastra/longmemeval@1.1.43-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
## @mastra/opencode@0.1.43-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
## @mastra/factory@0.29.0-alpha.7

### Patch Changes

- The **Activity** sort in the Factory sidebar now orders sessions that
share a status by their last update instead of their creation date, the
same as **Last updated** does. An older session that was updated since
no longer sinks below a newer one that was left alone.
([#30656](https://github.com/mastra-ai/mastra/pull/30656))

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/code-sdk@1.19.1-alpha.7
## create-factory@0.5.0-alpha.6

### Patch Changes

- Updated dependencies
[[`bfcb0f7`](bfcb0f738d),
[`383a19d`](383a19d047)]:
  - mastra@1.40.0-alpha.6
## @mastra/code-sdk@1.19.1-alpha.7

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/client-js@1.60.1-alpha.6
## mastracode@0.50.1-alpha.7

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/code-sdk@1.19.1-alpha.7
## mastra@1.40.0-alpha.6

### Patch Changes

- The Factory sidebar now groups sessions by board and shows a second
line under each session by default, with when it last changed and its
pull request. Turn on **Compact view** or set **Group** to **None** in
the sidebar's properties menu to get one line per session or a single
list back. Settings you already changed keep their values; the rest
follow the new defaults.
([#30656](https://github.com/mastra-ai/mastra/pull/30656))

- Factory **Settings** now shows theme and completion sound on **My
account**, next to your profile and log out, instead of on a separate
**Preferences** page. Settings opens on **My account**, and old
Preferences links go there.
([#30658](https://github.com/mastra-ai/mastra/pull/30658))

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/deployer@1.84.0-alpha.6
## @mastra/deployer@1.84.0-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/mcp-docs-server@1.3.14-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
## @mastra/playground-ui@69.1.0-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/client-js@1.60.1-alpha.6
  - @mastra/react@1.15.1-alpha.6
## @mastra/server@1.84.0-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
## @mastra/elysia@0.1.24-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/express@1.5.28-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/fastify@1.5.28-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/hono@1.7.26-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/koa@1.7.28-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/nestjs@0.3.1-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/next@0.2.42-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/hono@1.7.26-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/tanstack-start@0.2.42-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/hono@1.7.26-alpha.6
  - @mastra/server@1.84.0-alpha.6
## @mastra/temporal@0.6.1-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/deployer@1.84.0-alpha.6
## create-mastra@1.40.0-alpha.6


## @internal/playground@1.40.0-alpha.6

### Patch Changes

- Updated dependencies
[[`0eb407e`](0eb407ebcc)]:
  - @mastra/core@1.84.0-alpha.6
  - @mastra/client-js@1.60.1-alpha.6
  - @mastra/react@1.15.1-alpha.6
  - @mastra/playground-ui@69.1.0-alpha.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-17 00:01:31 -07:00
Damien Schneider
de5af00226
fix(factory-ui): collapse empty board columns to vertical strips on phones (#30659)
## Description

In the Kanban board view on phones, empty columns stayed full width
(320px). Each one showed a count with its name written flat below it. A
board with mostly empty phases took several screens of sideways
scrolling to cross, and from the first screen you couldn't tell those
phases were there.

Desktop already showed empty columns as narrow strips with the phase
name written vertically. That only applied at the `lg` breakpoint. Now
it applies at every width. The change is limited to `BoardColumn.tsx`:
the `lg:` variants on the collapsed width, the count and action
placement, and the vertical label are now unconditional.

Desktop is unchanged: the before and after desktop screenshots are
byte-identical.

**Phone (390 × 844, touch), dark mode**

| | Before | After |
|---|---|---|
| Board as it opens | <img
src="https://raw.githubusercontent.com/mastra-ai/mastra/7bb4183dfa1faa22a063649244b0046c4a90f7d9/pr-assets/phone-before.png"
width="260" /> | <img
src="https://raw.githubusercontent.com/mastra-ai/mastra/7bb4183dfa1faa22a063649244b0046c4a90f7d9/pr-assets/phone-after.png"
width="260" /> |
| Scrolled to the far right | <img
src="https://raw.githubusercontent.com/mastra-ai/mastra/7bb4183dfa1faa22a063649244b0046c4a90f7d9/pr-assets/phone-far-edge-before.png"
width="260" /> | <img
src="https://raw.githubusercontent.com/mastra-ai/mastra/7bb4183dfa1faa22a063649244b0046c4a90f7d9/pr-assets/phone-far-edge-after.png"
width="260" /> |

Before, the board was about 2,320px wide on a phone and you had to
scroll past six full-width empty columns. Now it's about 736px, and all
the empty phases fit on one screen. On touch screens a strip shows its
`+` (create) button where desktop shows the count, the same as on a
touch laptop today.

**Desktop (unchanged)**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/7bb4183dfa1faa22a063649244b0046c4a90f7d9/pr-assets/desktop-after.png"
width="600" />

The existing board MSW suites (`BoardPagePendingStates`,
`BoardPageEmptyStates`, `CustomBoardPage`) and the typecheck pass.

The screenshots are served from a commit on this branch (`7bb4183`) that
the next commit removes, so they aren't part of the diff.

No changeset: the change is only in `@internal/factory-ui`, which
changesets ignore, and other factory-ui-only fixes have shipped without
one.

## Related issue(s)

None filed. This was reported from a phone screenshot of the board view.

## 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

- [ ] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VhgyDTBtDa6hrKYsrk39gW

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 22:00:01 -08:00
Damien Schneider
383a19d047
feat(factory-ui): show Preferences on My account (#30658)
## Description

Settings › Preferences had two rows, Theme and Completion sound. Both
are personal, like everything else on My account, so they now sit on My
account between Profile and Session. That leaves My account and
Connections in the sidebar's Account group.

**Before**: two pages.

![Before: My
account](https://raw.githubusercontent.com/mastra-ai/mastra/7b67e059d0c9d65c60bcbd00d164fa771bbd82f8/.pr-assets/preferences-in-my-account/before-account.png)

[Before: Preferences](``
https://raw.githubusercontent.com/mastra-ai/mastra/7b67e059d0c9d65c60bcbd00d164fa771bbd82f8/.pr-assets/preferences-in-my-account/before-preferences.png
``)

**After**: one page.

![After: My account with
Preferences](https://raw.githubusercontent.com/mastra-ai/mastra/7b67e059d0c9d65c60bcbd00d164fa771bbd82f8/.pr-assets/preferences-in-my-account/after-account.png)

Settings now opens on My account instead of Preferences. That covers the
avatar link at the bottom of the sidebar, the `/settings` index and
unknown sections. `/settings/preferences` is a retired section and
redirects to `/settings/account`, keeping search and return state, so
old links and bookmarks still work. Settings search and global search
find My account when you type "preferences", "theme" or "completion
sound".

Preferences render outside the account loading checks. Before, a failed
or pending `/auth/me` replaced the whole page with a notice. Now that
notice only replaces Profile, and the theme and sound controls stay
usable. `GeneralSettings` is renamed `PreferencesSettings`, and its test
is folded into the `AccountSettingsSection` tests.

Tests: MSW tests cover changing the theme from My account, theme and
sound still working when account details fail to load (this test fails
if Preferences goes back behind the account checks), the
`/settings/preferences` redirect, and settings search. Existing tests
that opened `/settings/preferences` now open `/settings/account`. The
affected files pass 85/85 on two runs. Typecheck, oxlint and prettier
are clean. `AppStartup.msw.test.tsx` has 8 failures, including the
Settings case, but they fail the same way on `main` (`GET /web/status`
waits for the sign-in check), so they're unrelated to this change.

The screenshots come from the real Vite dev server, with API responses
filled in by Playwright using placeholder account data. They're linked
by commit, and the second commit removes them from the tree. There's a
patch changeset for `mastra`.

## Related issue(s)

None. This came from a review of the settings layout.

## 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

- [ ] I have linked the related issue(s) in the description above
- [x] I have made corresponding changes to the documentation (if
applicable). No docs mention the Preferences page.
- [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

---
_Generated by [Claude
Code](https://claude.ai/code/session_01VhgyDSq83V7jJPCXfD2Grj)_

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

<!-- coderabbit-ai-generated:v1 -->

## ELI5

Settings now puts the theme and completion sound on the My account page.
Old links to the Preferences page send people to My account instead.

## Overview

This change removes the separate Preferences settings page in the
Factory UI. Its controls move to the My account page, between Profile
and Session. The Account sidebar group now lists only My account and
Connections.

## Behavior changes

- Settings opens on My account. This applies to the avatar link,
`/settings`, and unknown settings sections.
- `/settings/preferences` redirects to `/settings/account`. The redirect
keeps the search query and location state.
- Global search and settings search find My account for "preferences",
"theme", and "completion sound".
- The Preferences controls render outside the account-loading checks.
They stay usable when account details are pending or fail to load.
- The logout section appears only when authentication is enabled and the
user is signed in. Logout still clears MastraCode storage and redirects
to the logout URL.

## Code changes

- `GeneralSettings` is renamed to `PreferencesSettings`. Its subsection
title changes from "General" to "Preferences".
- `SettingsSection` no longer includes `preferences`.
`RETIRED_SETTINGS_SECTIONS` maps `preferences` to `account`.
- `useSettingsSection`, `SettingsPage`, the `/settings` router default,
and `SidebarSettingsLink` now use `account` instead of `preferences`.
- `SettingsPanel` no longer imports or renders `GeneralSettings`.
- `SettingsNavigation` removes the Preferences item and its
`IconColorPalette` import. Its search text moves to the My account item.
- `GlobalSearchNavigationResults` replaces the Preferences destination
with My account and updates its search keywords.
- `AccountSettingsSection` renders profile details through
`ProfileSubsection` and always includes `PreferencesSettings`.
- A changeset records a patch release for `mastra`.

## Tests

- `GeneralSettings.msw.test.tsx` is deleted. Its coverage moves to the
`AccountSettingsSection` tests.
- Tests added or updated:
- Switching the theme from System to Dark saves the choice to
`localStorage`.
- With account details failing to load, the theme can still change, and
the completion sound control stays visible without the logout button.
  - A retired `/preferences` route redirects to My account.
- Navigation tests start at the account route and expect the Account
group to show only My account and Connections.
- Search for "preferences", "theme", and "completion sound" finds My
account.
- The author reports 85/85 passing tests across two runs for the
affected files. The author also reports clean typecheck, oxlint, and
prettier results. These results were not verified against the current
head.
- The author reports 8 failures in `AppStartup.msw.test.tsx`, including
the Settings case. The author states that the same failures occur on
`main`, because `GET /web/status` waits for the sign-in check. This was
not verified.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 21:49:44 -08:00
Damien Schneider
bfcb0f738d
fix(factory-ui): group sessions sidebar by board (#30656)
**─────── TLDR ───────**
> The Sessions sidebar now opens grouped by board with two-line rows, so
a fresh view shows where each session belongs and when it last moved.

The old defaults gave a new reader one flat list of titles: no board, no
date. The Activity sort also broke ties by creation date, so inside Idle
it read exactly like Last created.

### Behavior changed

someone opening the sidebar with no saved view
&nbsp;&nbsp;├─ **was** — one "All sessions" list, one line per session
&nbsp;&nbsp;└─ **now** — Work, custom boards, then User; last update
under each row

two sessions with the same status under Activity
&nbsp;&nbsp;├─ **was** — the newest created first, whatever changed
since
&nbsp;&nbsp;└─ **now** — the most recently updated first, as Last
updated does

someone who already picked None or Compact view
&nbsp;&nbsp;└─ **unchanged** — the view stores only what differs, so it
stays

### Decisions

- **Board grouping returns, Owner stays All** — Mine hides the Factory's
card sessions; one constant each to undo.
- **ties read `updatedAt` as stored** — it moves on rename, sandbox or
first message, not each chat turn; a per-run touch is separate.
- **server default stays `groupBy: 'none'`** — the sidebar always sends
`groupBy`; only raw API callers read it.

### Not verified

- [ ] the new defaults in a running sidebar — checked through the MSW
suites, not in a browser

---

> ██████████████████ **tests** `+47 −53` — net −6, the fixture that
undid the old default is gone
> ██ **changeset** `+10`
> █ **source** `+3 −3` — three one-line changes
2026-11-16 21:45:12 -08:00
mastra-platform[bot]
0eb407ebcc
Publish unified Platform clients for Memory, Knowledge, Browser, Sandbox, and Filesystem (#29428)
## Summary

Adds `@mastra/platform`: one package with clients for hosted Mastra
Platform services. It also changes `@mastra/core` Knowledge so that a
store can supply its own scope declarations.

### `@mastra/platform`
- `PlatformMemory` / `PlatformMemoryClient`: hosted Memory. It loads
observations and recent messages from a Platform Memory instance and
saves each turn back. Observation and reflection run on the Platform.
- Read-only runs (`readOnly: true`) read the thread's context through
the instance's read-only context route. They save nothing.
- `workingMemory: 'readonly' | 'tool' | 'off'` controls whether the
resource's stored working memory goes into each run's prompt. `tool`
also tells the agent to update it.
- `PlatformKnowledge`: hosted Knowledge. It forwards Knowledge
page-store operations to the Knowledge service and rebuilds Knowledge
error types from the error names the service returns.
- It takes no `scopes` option. The instance serves every scope
declaration and access rule (Memory's and importers' included) through
`getScopeDeclarations`, so access is changed in one place.
  - It supports listing pins.
- If the service doesn't have `getScopeDeclarations` yet, the client
treats that as no declarations. Only the service's own unknown-operation
404 (`Knowledge operation not found`) counts; a missing instance or any
other 404 still fails, so a misrouted client can't silently read no
declarations.
- `PlatformBrowser`: a Stagehand browser on a Platform browser session.
- By default it provisions a session through `POST
/v1/browsers/sessions` and connects to the returned CDP URL.
- Pass `cdpUrl` to connect to an existing session. That needs no token
and makes no API call.
  - Env vars: `MASTRA_PROJECT_ID` and `MASTRA_BROWSER_API_URL`.
  - New runtime dependency: `@mastra/stagehand`.
- `PlatformSandbox` / `PlatformFilesystem`: re-exported from
`@mastra/platform-workspace`.
- Credentials fall back to `MASTRA_PLATFORM_ACCESS_TOKEN`, then
`MASTRA_PLATFORM_SECRET_KEY`. Instance IDs come from
`MASTRA_MEMORY_INSTANCE_ID` and `MASTRA_KNOWLEDGE_INSTANCE_ID`; service
URLs can be overridden with `MASTRA_MEMORY_API_URL` and
`MASTRA_KNOWLEDGE_API_URL`.

### `@mastra/core` Knowledge (for core reviewers)
- `KnowledgeStorage.getScopeDeclarations()` is new and returns `{}` by
default. Knowledge merges the store's declarations under the config's:
  - On a key both declare, the config's declaration wins.
  - A store declaration that doesn't compile is skipped with a warning.
- Every Knowledge entry point now calls
`KnowledgeScopeRuntime.resolve()` before it runs: agent runs, host
writes, `readScopeFor`, `explainAccess` and `renameScopeDeclaration`.
- The store's answer is reused for 30 seconds and shared by concurrent
calls.
- A failed read isn't cached. The cache is also cleared after
`renameScopeDeclaration`, and a read that started before the rename
can't publish its answer after it.
- The cache also holds access rules, so revoking access through the
store can take up to 30 seconds. The changeset says so.
- The declarations are recompiled only when the store's answer changes.
- Without the cache, hosted Knowledge would make one extra HTTP call per
operation.
- The `'*'` access principal is gone. Access rules must name a declared
principal (for example `imports:all`).
- Public signatures are unchanged. `readScopeFor` and
`renameScopeDeclaration` already returned promises.

## Test plan (head `93ca37f845`)
- `pnpm exec vitest run packages/platform/src --config
packages/platform/vitest.config.ts`: 42 passed. 28 live tests were
skipped because they need hosted credentials.
- `pnpm --filter @mastra/platform exec tsc --noEmit`: clean. oxlint and
oxfmt: clean.
- `pnpm --filter @mastra/core exec vitest run src/knowledge`: 30 files,
318 tests passed. `pnpm --filter ./packages/core check`: clean.
- New tests:
- `store-scopes.test.ts`: call counts for `getScopeDeclarations` within
the 30-second window and after a rename, a retry after a failed read,
expiry of the 30-second window, a read started before `invalidate()` or
replaced by a newer read that must not publish its answer, and the
declaration-check error naming a skipped store declaration and why.
- `errors.test.ts`: the unknown-operation 404 reads as no declarations,
while a missing instance, any other 404 or a 500 still fails.
- `platform-browser.test.ts`: trailing slashes on the API URL are
dropped before the sessions path is added.
  - Each new test fails against a mutated implementation.
- Built ESM and CommonJS imports of `PlatformMemory`,
`PlatformKnowledge`, `PlatformBrowser`, `PlatformSandbox` and
`PlatformFilesystem`: 21 exports in each format.
- Hosted staging, snapshot `0.0.0-feat-platform-unified-20261117035452`
built from this head and installed from npm:
- `PlatformKnowledge`: a real `Agent` (only the model scripted) creates,
reads, notes, searches, lists, updates, pins and unpins a page in an org
scope through the Knowledge tools. Deleting the page as the agent is
refused because the run holds `editor`, not `owner`.
- `PlatformMemory` (`MASTRA_MEMORY_API_URL` set to the staging host):
two `Agent` turns on one thread; the second turn's prompt carries the
first, and all four messages are stored. The client's create, save,
list, context and working-memory calls work, and deleting the thread
works.
- `PlatformSandbox` and `PlatformFilesystem`: bucket write, read, list
and delete; a sandbox starts, runs `echo ok`, writes and reads a file,
and is destroyed; reattaching the destroyed sandbox fails with 410.
- Not yet run: `PlatformBrowser` hosted provisioning. Its endpoint,
`POST /v1/browsers/sessions`, is not deployed yet and returns 404.
Connecting through `cdpUrl` needs no Platform endpoint.

## Merged with main
Main was merged in (no rebase). The only code conflict was
`packages/core/src/knowledge/scope-runtime.ts`: it keeps main's
stale-row filtering from #30019 and this PR's narrowed return type.
`pnpm-lock.yaml` takes main's and was regenerated; only the
`packages/platform` importer differs. Main was merged in again at
`4c364b00ba` with no conflicts. Factory's requested changes are in: the
30-second reuse of store declarations, the PlatformBrowser changeset and
the removed `platform/*` workspace glob.

---------

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: Jamie Lee Nichols <10267569+CodingButter@users.noreply.github.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-5-5) <noreply@mastra.ai>
Co-authored-by: Abhi Aiyer <abhiaiyer91@gmail.com>
Co-authored-by: arctic-char <146986046+arctic-char@users.noreply.github.com>
Co-authored-by: remy-builder[bot] <324360501+remy-builder[bot]@users.noreply.github.com>
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
2026-11-16 21:36:00 -08:00
dane-ai-mastra[bot]
3b426304ac
chore: version packages (alpha) (#30602)
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/factory@0.29.0-alpha.6

### Minor Changes

- Added personal custom providers. A custom OpenAI-compatible endpoint
is now saved either for yourself or for your organization, the same way
provider API keys are.
([#29879](https://github.com/mastra-ai/mastra/pull/29879))

- **Personal endpoints** are visible only to you and are used by your
personal sessions.
- **Organization endpoints** are used by work that runs on the
organization's credentials. Adding, editing or removing one now requires
an organization admin.
- Custom endpoints are added from the **Add provider** dialog and listed
with the other providers. The separate "Custom providers" section is
gone.
- Editing an endpoint without retyping its API key keeps the saved key,
as long as the URL stays on the same host. Moving it to another host
asks for the key again.
- Adding an endpoint under a name that is already in use is refused
instead of replacing the existing one. So are names reserved for a
built-in provider, its sign-in, or the Mastra Gateway (for example
"OpenAI", "OpenAI Codex" or "Mastra Gateway").
- A Factory hosted on the Mastra platform only calls custom endpoints at
a public HTTPS address. Saving one on plain HTTP, `localhost`, a private
network or the cloud metadata address is refused with a message
explaining why. Local and self-hosted Factories can still use endpoints
on their own machine or network, such as Ollama or vLLM.

  **Before you upgrade**

- Organization endpoints no longer apply to personal sessions. Add the
endpoint again as a personal one to keep using it there.
- On a hosted Factory, endpoints saved earlier on a local or plain-HTTP
address are marked "URL not allowed" and their models are no longer
offered. Edit them to a public HTTPS address.
- Review your organization's endpoints. One named like a built-in
provider (for example "OpenAI") still takes over that provider's models;
remove it or rename it.

The custom provider routes take a `scope` (`user` by default, or `org`).
Saving with `previousId` edits that provider; saving without it adds
one:

  ```http
  POST /web/config/custom-providers
{ "name": "My gateway", "url": "https://llm.example.com/v1", "models":
["my-model"], "scope": "org" }

  DELETE /web/config/custom-providers/my-gateway?scope=org
  ```

- Work Intake: what you select is what comes in.
([#30625](https://github.com/mastra-ai/mastra/pull/30625))

- **One list per service, no sync switches.** Settings → Work Intake
lists each connected service with its selected sources and an Add
account button. A service with nothing selected brings in nothing.
Dependabot alerts keep their own switch.
- **GitHub issues follow the list.** New GitHub issues become cards only
for repositories in the GitHub list. Pull requests still come from every
linked repository. On upgrade, every repository already linked to a
Factory is added to the list once, so nothing stops arriving. Linking a
repository adds it to the list unless the request sends `selectIntake:
false`, and adding a repository to the list brings in its open issues.
    To link a repository without bringing in its issues:

    ```http
POST
/web/factory/projects/:projectId/source-control-connections/:connectionId/repositories
{ "repository": { "externalId": "99", "slug": "acme/app" },
"selectIntake": false }
    ```

- **Vanta follows its selection.** Vulnerabilities sync only while the
Vanta source is selected. Organizations whose Vanta sync was on with
nothing selected get the source selected once on upgrade.
- **Routing has its own page.** The intake order and the Not routed list
moved from Settings to Routing in board settings.

- Fixed Factory server memory growing with every session it ever opened.
Factory now unloads a session from server memory when it stops the
session's sandbox (a card leaving a phase's context or finishing), and
after 30 minutes without activity. Sessions that are running, waiting on
an approval or answer, open in a browser tab, or running a background
process in their sandbox stay loaded. Unloading keeps the thread, its
messages, the session row and the sandbox, and the session's next
message, run, wake or opened tab loads it again. Without `auth`, a
deferred wake for an unloaded session waits until something else loads
it, as it does after a restart.
([#30612](https://github.com/mastra-ai/mastra/pull/30612))

Change the timeout with `idleSessionUnload`, or pass `false` to keep
every session loaded:

  ```ts
  const factory = new MastraFactory({
    storage,
idleSessionUnload: { idleMs: 60 * 60_000, sweepIntervalMs: 5 * 60_000 },
  });
  ```

- Asking a Factory session to work on a card now goes through the board,
the way the board's own buttons do. Before, asking a Slack or web
session to "review" a pull request that already had a card often ended
in a side session posting its review in the chat, while the card's own
review waited for approval.
([#30628](https://github.com/mastra-ai/mastra/pull/30628))

- `factory_transition_work_item` takes `rerun: true` to run the stage a
card is already in again, as the board's **Start** button does. The run
counts as approved by the person asking, and a busy card is refused as
on the board. A rerun needs a person in the turn. Without `rerun`, a
request for the card's own stage changes nothing and says whether its
run is waiting for approval. The result now includes the card's `url`.
- Asking for a side session still starts one. The tools now steer a
plain "review this pull request" to the pull request's card, and keep
side sessions for what people ask to run in one and for work no stage
does, such as pushing fixes to a pull request.
- Every tool that takes a work item also accepts the issue or pull
request it tracks: its link, `owner/repo#12`, `group/project!7`, or a
tracker key such as `ENG-42`. With several repositories linked, the link
finds the right card where a bare `#12` might not.
`factory_list_work_items` takes the same references as its query.
- `factory_inspect_work_item` lists the card's stage, whether it can run
again, and the stages its board lets it move to next.
- `factory_start_session` only starts side sessions. Its `workItem` and
`role` inputs are removed: they started a card's role without the
board's rules, such as which stage the card is in and whether it is
busy.

### Patch Changes

- Added `GET
/web/factory/projects/:id/work-items/:workItemId/session-repository`. It
returns the repository a session on the card starts in, resolved with
the same rules as the card's runs, or the reason the card has none.
([#30609](https://github.com/mastra-ai/mastra/pull/30609))

- Fixed reopened pull request review sessions loading the pull request's
AGENTS.md and CLAUDE.md as trusted instructions. After a review card
finished and the server restarted or unloaded the session, a new message
in that session read instruction files from the pull request branch.
Sessions that ever ran pull request or review work now keep reading
instructions from the base branch, or read none when the trusted branch
can't be determined.
([#30612](https://github.com/mastra-ai/mastra/pull/30612))

- **Settings › Tools** can now list each Mastra Connect connection's
tools. The new `GET /web/integrations/platform/connect-tools/tools`
route resolves the tools a session started by the signed-in user would
get: Factory's default Connect tools, or what the `tools` option
returns. It marks tools that ask for approval and lists the default
tools Factory leaves out because they delete or archive. When the tools
can't be resolved, it answers 502 `tools_unavailable` with the reason.
([#30610](https://github.com/mastra-ai/mastra/pull/30610))

- Fixed **Settings › Tools** saying Mastra Connect tools are off when a
Factory sets the `tools` option, even when that option uses Connect
tools (#30579). The page now lists the Platform project's connections
whenever the Factory has Platform credentials and `MASTRA_PROJECT_ID`,
and says that session tools come from code. When either one is missing,
the page names it instead of listing every possible cause.
([#30607](https://github.com/mastra-ai/mastra/pull/30607))

- Reduced the work the Factory server does to keep the session sidebar
and board up to date, and fixed session latency timestamps on LibSQL.
([#30648](https://github.com/mastra-ai/mastra/pull/30648))

- Projects without a linked repository no longer rebuild their session
list on every sidebar poll.
- Session activity now sorts only the cards that are running, waiting or
held by a session, instead of every card on the board.
- A session's first materialize, first message and first command times
are now recorded once when several Factory processes share one LibSQL
database, so a later write no longer replaces the first recorded time.

- Fixed slow reading of the pull request number from GitHub card keys
that contain very long runs of digits. The number returned is unchanged.
([#30577](https://github.com/mastra-ai/mastra/pull/30577))

- New, renamed and hidden sessions now show up in teammates' sidebars
right away, instead of after up to a minute, and the sidebar no longer
polls while a session starts. The `session-rows` and `session-activity`
answers no longer include `settling`: every change to either answer now
sends a frame on the project's feed.
([#30617](https://github.com/mastra-ai/mastra/pull/30617))

- Fixed deleting an intake rule being slow on remote databases and
breaking other open rule edits. A delete now removes only the deleted
rule instead of rewriting every rule after it, so the remaining rules
keep their order and revision and edits opened before the delete still
save. ([#30613](https://github.com/mastra-ai/mastra/pull/30613))

- Approving a held Factory run with `factory_resolve_proposal`, or
retrying a failed one with `factory_retry_decision`, now makes the
session follow the run's card, as moving the card already did. Before, a
Slack session that approved a card's review could promise to post the
result and then never hear how the review ended. Both results now
include the card's `url`.
([#30637](https://github.com/mastra-ai/mastra/pull/30637))

- Fixed board cards showing a different session status than the sidebar.
A card with a suggested run and a running session now shows it waits on
you on the board too, and a card with one working and one starting
session shows it working.
([#30624](https://github.com/mastra-ai/mastra/pull/30624))

- Fixed Factory starting a card's session in a repository the card
doesn't come from. When a card's repository wasn't linked to the
Factory, the draft started the session in the first linked repository
and wrote that repository onto the card. The draft now asks the server
which repository the card's session uses, and when there is none it
shows why, for example "Repository acme/docs is not linked to this
Factory.", starts nothing, and links to repository settings. When the
lookup itself fails, the draft offers Retry.
([#30609](https://github.com/mastra-ai/mastra/pull/30609))

A card from GitHub in a Factory whose repositories are all on GitLab, or
the reverse, is now refused the same way instead of starting in that
Factory's repository, even when a repository there has the same name.

- Improved sidebar performance in projects with many sessions. The
Factory now builds the session list once and reuses it for everyone
until a session, card or follow changes, so each sidebar request uses
about a third of the server CPU it did.
([#30616](https://github.com/mastra-ai/mastra/pull/30616))

- Fixed the session status in Factory's sidebar and board. A person's
own session now shows "Waiting on you" while its agent waits for their
answer, instead of "Working". A session now shows "Working" while it
runs on a thread opened after its first one, such as a new thread or a
Slack conversation. A session shows "Initializing" only while a run
waits on its first setup, so a session whose setup never finished, or
that never ran, no longer stays stuck on "Initializing".
([#30627](https://github.com/mastra-ai/mastra/pull/30627))

- Updated dependencies
[[`944bb3a`](944bb3ab0f),
[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`b1ba914`](b1ba914ea1),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/code-sdk@1.19.1-alpha.6
  - @mastra/core@1.84.0-alpha.5
  - @mastra/connect@1.4.1-alpha.2
## create-factory@0.5.0-alpha.5

### Minor Changes

- Added a `--tag <dist-tag>` option to `create-factory`. It pins the
scaffolded template's `mastra` and `@mastra/*` dependencies to the exact
versions published under that npm dist-tag, so you can try a new Factory
on prerelease packages:
([#30598](https://github.com/mastra-ai/mastra/pull/30598))

  ```sh
  npx create-factory@latest my-factory --tag alpha
  ```

When the pinned versions include prereleases and the project uses npm,
`create-factory` also writes `legacy-peer-deps=true` to the project's
`.npmrc`, because npm otherwise rejects the prerelease peer ranges.

### Patch Changes

- `create-factory --tag` now stops before installing when the npm
registry lookup for a Mastra package fails, instead of keeping that
package's template version and producing a project that mixes release
channels. A package that simply has no release under the tag still keeps
its template version with a warning.
([#30614](https://github.com/mastra-ai/mastra/pull/30614))

- Updated dependencies
[[`c638825`](c638825c83),
[`a6dbd29`](a6dbd29a4e),
[`3c7c003`](3c7c00383d),
[`b90d0ec`](b90d0ecd41),
[`e22c5a7`](e22c5a7035)]:
  - mastra@1.40.0-alpha.5
## @mastra/core@1.84.0-alpha.5

### Minor Changes

- Added `knowledge.movePage()` to move a page, with its child pages, to
a new parent or scope from your app. The page keeps its ID, notes, pins
and embeddings, and links by path follow it, so a sync that sees a page
move at its source no longer has to remove and re-create it.
([#30631](https://github.com/mastra-ai/mastra/pull/30631))

  ```ts
await knowledge.movePage({ scope: 'docs:acme', path: 'inbox/plan',
parent: 'projects/q4' });
  ```

Links by name now stay correct when a page moves or a new page takes a
name. A page moved to another scope, and every page under it,
re-resolves its `[[Name]]` links in the new scope. A link that pointed
at one page by name stops resolving once a second page answers to that
name. When more than 99 pages share that name, the write logs a warning
and `knowledge.reindexLinks()` repairs the rest.

- Added `knowledge.reembed()` to embed Knowledge pages and notes that
already exist, such as content written before `vector` and `embedder`
were configured or after switching embedders. It runs in batches with a
resumable cursor, doesn't change the pages, lists failures and pages
over the chunk cap, and stops early with a cursor when the embedder
keeps rate limiting.
([#30603](https://github.com/mastra-ai/mastra/pull/30603))

  ```ts
  let cursor: string | undefined;
  do {
const result = await knowledge.reembed({ scope: 'org:acme', cursor });
if (result.rateLimited) await new Promise(resolve => setTimeout(resolve,
60_000));
    cursor = result.nextCursor;
  } while (cursor);
  ```

### Patch Changes

- Fixed slow handling of Gateway base URLs and Supabase URLs that
contain very long runs of `/`. The resulting URLs are unchanged.
([#30577](https://github.com/mastra-ai/mastra/pull/30577))

- Fixed `run.restart()` running a step again when the workflow run
finished or suspended after `restart()` read it but before `restart()`
took it over from the process running it. Restarting a run that finished
now returns its stored result, and restarting a run that suspended fails
with the usual "This workflow run was not active" error.
([#30399](https://github.com/mastra-ai/mastra/pull/30399))

- Fixed workflow `.sleep()` and `.sleepUntil()` waits longer than about
24.8 days ending almost immediately. The next step now runs only after
the full wait, on the default and evented engines.
([#30395](https://github.com/mastra-ai/mastra/pull/30395))
## @mastra/auth-supabase@1.2.1-alpha.0

### Patch Changes

- Fixed slow handling of Gateway base URLs and Supabase URLs that
contain very long runs of `/`. The resulting URLs are unchanged.
([#30577](https://github.com/mastra-ai/mastra/pull/30577))
## @mastra/client-js@1.60.1-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/react@1.15.1-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/client-js@1.60.1-alpha.5
## @mastra/deployer-cloud@1.84.0-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/deployer@1.84.0-alpha.5
## @mastra/longmemeval@1.1.43-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/libsql@1.31.0-alpha.2
## @mastra/opencode@0.1.43-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/libsql@1.31.0-alpha.2
## @mastra/code-sdk@1.19.1-alpha.6

### Patch Changes

- Fixed custom OpenAI-compatible providers so they only ever
authenticate with the API key saved on the provider itself.
([#29879](https://github.com/mastra-ai/mastra/pull/29879))

- A custom provider is no longer given the saved credential of another
provider when their names match (for example a custom provider called
"OpenAI").
- A Mastra Gateway model (`mastra/...`) never runs on a custom provider
that shares its id, with or without a gateway key.
- Requests to a custom provider no longer follow redirects, so its API
key is never sent on to another address.
- A custom provider without an API key now works when sign-in is
enabled, instead of failing with a missing credential error.

If a custom provider in `settings.json` has no `apiKey` and relied on a
key you saved for the provider it is named after (for example with
`/api-keys`), set `apiKey` on the custom provider itself.

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34),
[`464810d`](464810dcf8)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/pg@1.37.0-alpha.3
  - @mastra/client-js@1.60.1-alpha.5
  - @mastra/libsql@1.31.0-alpha.2
## mastracode@0.50.1-alpha.6

### Patch Changes

- Added an ESM-only `mastracode/run-tui` export so a launcher can start
the Mastra Code TUI with extra session options, such as Knowledge and
its scopes: ([#30371](https://github.com/mastra-ai/mastra/pull/30371))

  ```ts
  import { runTui } from 'mastracode/run-tui';

await runTui({ createMastraCode: { knowledge: { key: 'team', instance:
knowledge }, scopes: ['org:acme'] } });
  ```

Options given here replace the values Mastra Code would pass for the
same keys, and apply to the interactive local TUI only. The `mastracode`
command behaves as before.

- Updated dependencies
[[`944bb3a`](944bb3ab0f),
[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34),
[`464810d`](464810dcf8)]:
  - @mastra/code-sdk@1.19.1-alpha.6
  - @mastra/core@1.84.0-alpha.5
  - @mastra/pg@1.37.0-alpha.3
  - @mastra/libsql@1.31.0-alpha.2
## @mastra/arize@1.3.31-alpha.1

### Patch Changes

- Raised the minimum versions of the OpenTelemetry SDK and OTLP exporter
dependencies (`@opentelemetry/sdk-trace-base` and `@opentelemetry/core`
`^2.12.1`, OTLP exporters `^0.223.1`) so they no longer resolve to
releases that pin `@opentelemetry/resources` 2.12.0, which is affected
by security advisory GHSA-qrww-3xmv-qhgm. If your project also depends
on OpenTelemetry packages directly, check that they resolve
`@opentelemetry/resources` 2.12.1 or later on the 2.x line, or 3.1.1 or
later on the 3.x line.
([#30580](https://github.com/mastra-ai/mastra/pull/30580))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`93b823a`](93b823a847),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/otel-exporter@1.5.3-alpha.1
## @mastra/arthur@0.4.31-alpha.1

### Patch Changes

- Raised the minimum versions of the OpenTelemetry SDK and OTLP exporter
dependencies (`@opentelemetry/sdk-trace-base` and `@opentelemetry/core`
`^2.12.1`, OTLP exporters `^0.223.1`) so they no longer resolve to
releases that pin `@opentelemetry/resources` 2.12.0, which is affected
by security advisory GHSA-qrww-3xmv-qhgm. If your project also depends
on OpenTelemetry packages directly, check that they resolve
`@opentelemetry/resources` 2.12.1 or later on the 2.x line, or 3.1.1 or
later on the 3.x line.
([#30580](https://github.com/mastra-ai/mastra/pull/30580))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`93b823a`](93b823a847),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/otel-exporter@1.5.3-alpha.1
## @mastra/laminar@1.3.33-alpha.1

### Patch Changes

- Raised the minimum versions of the OpenTelemetry SDK and OTLP exporter
dependencies (`@opentelemetry/sdk-trace-base` and `@opentelemetry/core`
`^2.12.1`, OTLP exporters `^0.223.1`) so they no longer resolve to
releases that pin `@opentelemetry/resources` 2.12.0, which is affected
by security advisory GHSA-qrww-3xmv-qhgm. If your project also depends
on OpenTelemetry packages directly, check that they resolve
`@opentelemetry/resources` 2.12.1 or later on the 2.x line, or 3.1.1 or
later on the 3.x line.
([#30580](https://github.com/mastra-ai/mastra/pull/30580))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/langfuse@1.6.7-alpha.1

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`93b823a`](93b823a847),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/otel-exporter@1.5.3-alpha.1
## @mastra/otel-bridge@1.5.23-alpha.1

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`93b823a`](93b823a847),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/otel-exporter@1.5.3-alpha.1
## @mastra/otel-exporter@1.5.3-alpha.1

### Patch Changes

- Raised the minimum versions of the OpenTelemetry SDK and OTLP exporter
dependencies (`@opentelemetry/sdk-trace-base` and `@opentelemetry/core`
`^2.12.1`, OTLP exporters `^0.223.1`) so they no longer resolve to
releases that pin `@opentelemetry/resources` 2.12.0, which is affected
by security advisory GHSA-qrww-3xmv-qhgm. If your project also depends
on OpenTelemetry packages directly, check that they resolve
`@opentelemetry/resources` 2.12.1 or later on the 2.x line, or 3.1.1 or
later on the 3.x line.
([#30580](https://github.com/mastra-ai/mastra/pull/30580))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/sentry@1.2.33-alpha.1

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`93b823a`](93b823a847),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/otel-exporter@1.5.3-alpha.1
## mastra@1.40.0-alpha.5

### Patch Changes

- The Factory **Settings › Tools** page shows how many tools sessions
get from each Mastra Connect connection. Expand one to see its tools
with their descriptions, which ones ask for approval, and which ones
Factory leaves out. With a `tools` option, a connection the code doesn't
use shows no tools, and the code's other tools are listed under **Other
tools from code**.
([#30610](https://github.com/mastra-ai/mastra/pull/30610))

- The Factory **Settings › Tools** page lists a project's Mastra Connect
connections when the Factory sets its session tools in code, with a note
that the `tools` option decides which of their tools sessions get. When
Connect isn't set up, it names the missing Platform credentials or
`MASTRA_PROJECT_ID` (#30579).
([#30607](https://github.com/mastra-ai/mastra/pull/30607))

- Added `mastra api factory work-item session-repository <project-id>
<work-item-id>`. It shows the repository a session on a Factory card
starts in, or why the card has none.
([#30609](https://github.com/mastra-ai/mastra/pull/30609))

- Fixed board cards showing a different session status than the sidebar.
A card with a suggested run and a running session now shows it waits on
you on the board too, and a card with one working and one starting
session shows it working.
([#30624](https://github.com/mastra-ai/mastra/pull/30624))

- Fixed the session status in Factory's sidebar and board. A person's
own session now shows "Waiting on you" while its agent waits for their
answer, instead of "Working". A session now shows "Working" while it
runs on a thread opened after its first one, such as a new thread or a
Slack conversation. A session shows "Initializing" only while a run
waits on its first setup, so a session whose setup never finished, or
that never ran, no longer stays stuck on "Initializing".
([#30627](https://github.com/mastra-ai/mastra/pull/30627))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/deployer@1.84.0-alpha.5
## @mastra/connect@1.4.1-alpha.2

### Patch Changes

- Fixed `posthog_run_query` failing provider-response validation
whenever PostHog returned column types, which it does for every query
with columns, even `select 1`. PostHog returns column types as
`[columnName, clickhouseType]` pairs, such as `[["count()", "UInt64"]]`,
and the tool now accepts them and returns them in that shape. The
inferred type of `types` in the tool's output changes from `string[]` to
`[string, string][]`, and a plain string entry, which PostHog never
sends, is now rejected. Fixes
[#30528](https://github.com/mastra-ai/mastra/issues/30528).
([#30541](https://github.com/mastra-ai/mastra/pull/30541))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/deployer@1.84.0-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/mcp-docs-server@1.3.14-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/playground-ui@69.1.0-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/client-js@1.60.1-alpha.5
  - @mastra/react@1.15.1-alpha.5
## @mastra/server@1.84.0-alpha.5

### Patch Changes

- Reduced memory and CPU use when clients stream agent controller
sessions. Each display-state update is now copied and serialized once
and shared by every client of the session, instead of once per client,
and the copy no longer duplicates message text or tool results. Display
state is now serialized the same way as other stream events, so the
bytes change for three kinds of value: an object with a `toJSON` method
is sent as that method's result, an error keeps its own enumerable
fields such as `statusCode`, and a value that cannot be cloned, such as
a function, is left out and no longer closes the stream.
([#30615](https://github.com/mastra-ai/mastra/pull/30615))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/elysia@0.1.24-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/express@1.5.28-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/fastify@1.5.28-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/hono@1.7.26-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/koa@1.7.28-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/nestjs@0.3.1-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
## @mastra/next@0.2.42-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
  - @mastra/hono@1.7.26-alpha.5
## @mastra/tanstack-start@0.2.42-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`0ed63d7`](0ed63d7308),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/server@1.84.0-alpha.5
  - @mastra/hono@1.7.26-alpha.5
## @mastra/pg@1.37.0-alpha.3

### Patch Changes

- Fixed `PgVector` calls failing with "Vector table ... does not exist"
after an index was deleted with `deleteIndex()` and created again while
that `PgVector` instance was still starting up. Also fixed
`createIndex()` on that instance keeping the previous metric when the
index was deleted and recreated, or rebuilt, during that time.
([#30578](https://github.com/mastra-ai/mastra/pull/30578))

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
## @mastra/temporal@0.6.1-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/deployer@1.84.0-alpha.5
## create-mastra@1.40.0-alpha.5


## @internal/playground@1.40.0-alpha.5

### Patch Changes

- Updated dependencies
[[`7518c05`](7518c05d6f),
[`b07dd23`](b07dd23713),
[`33fba78`](33fba78931),
[`e110fa6`](e110fa681a),
[`d0a2fa4`](d0a2fa4e34)]:
  - @mastra/core@1.84.0-alpha.5
  - @mastra/client-js@1.60.1-alpha.5
  - @mastra/react@1.15.1-alpha.5
  - @mastra/playground-ui@69.1.0-alpha.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-16 21:12:17 -08:00
Damien Schneider
31f1b765c3
fix(factory): stamp a session's first events once and stop redoing session work (#30648)
**─────── TLDR ───────**
> A session's first-event times now survive concurrent LibSQL writers,
and the server stops redoing session work it already had.

Two LibSQL processes stamping the same session could both write, so a
later write replaced the first and inflated latency metrics such as
`materialize_s`. Projects without a GitHub connection evicted each
other's session index on every poll, and session activity sorted every
card status to report the few in flight. The one-request rows and
activity read and the shared owner lookup from the first push are
reverted: each carried a trade-off, so they wait until after the
release. The platform GitHub backlog test, red on `main` since #30625
made issue intake follow the selected repositories, now selects its
repository first.

### Behavior changed

two LibSQL processes stamp the same session's first message
&nbsp;&nbsp;├─ **was** — both could write, and the later time replaced
the first
&nbsp;&nbsp;└─ **now** — the `IS NULL` check runs inside the update; the
first write stays

two projects with no GitHub connection, polled in turn
&nbsp;&nbsp;├─ **was** — each read evicted the other's session index
&nbsp;&nbsp;└─ **now** — each project keeps its own until its sessions
change

### Gain

> ██████████████████ **session activity, before** `3.1 ms`
> █ **session activity, after** `0.11 ms`

Per call on 2,850 card statuses with 30 in flight, from a throwaway
bench that is not committed; the output is identical. Postgres already
serialized the stamps with `SELECT … FOR UPDATE`, so there the change
only trades a dedicated connection running five statements for two
statements.

---

> ██████████████████ **tests** `+98 −1` — 75% of the additions
> ████ **source** `+24 −40` — net −16
> ██ **changeset** `+9`


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

**ELI5:** When two copies of the app share one database, each can record
when a session started. This change makes sure only the first recorded
time is kept. The app also avoids some repeated work when it loads
session lists for projects that have no GitHub connection.

## Summary

This change covers six files: 131 lines added and 41 removed.

### Changes by file

- **`mastracode/factory/src/storage/domains/source-control/base.ts`**
(+17/-36):
  - Removes the `NO_SESSIONS` constant.
- When `linkedProjectSessions` finds no connections, it continues to the
repository-link lookup and the cached session read and filter path. It
no longer returns the shared empty constant. This stops projects without
a GitHub connection from evicting each other's session indexes.
- The three session timestamp methods call a new `#stampOnce` helper.
The helper updates only rows whose selected timestamp is null. If no row
changes, it returns without announcing. Otherwise, it reloads the row
and announces it when the row exists.
- **`mastracode/factory/src/session/session-row-view.ts`** (+7/-4):
`sessionActivity` filters card-status entries to in-flight statuses
before it builds the sorted `cardStatuses` list and the working and
waiting counts. Held-card IDs still come from all card-status entries
and are sorted.
-
**`mastracode/factory/src/storage/domains/source-control/base.test.ts`**
(+69/-1): Adds a test. It opens two `LibSQLFactoryStorage` instances on
one temporary file database. It creates a session and calls
`markMaterialized` from both instances concurrently. Over 10 attempts,
it asserts that the project is announced exactly once.
- **`mastracode/factory/src/routes/project-sessions.test.ts`** (+28/-0):
Adds a test for `createProjectSessionsReader`. It creates two projects
without a repository. It checks that repeated reads for each project
return the same object instance.
-
**`mastracode/factory/src/integrations/platform/github/integration.test.ts`**
(+1/-0): The linked-repository backlog import test saves an enabled
GitHub intake configuration for `acme/app` before it builds the
integration context and runs the import. This fixes a test that failed
on `main` after issue intake began to follow selected repositories.
- **`.changeset/funky-bears-know.md`** (+9/-0): Adds a patch changeset
for `@mastra/factory`. It describes reduced work during session sidebar
and board updates. It also describes one-time recording of session
timestamps when Factory processes share a LibSQL database.

### Scope notes

- The PR objectives state that the one-request rows and activity read,
and the shared owner lookup, were reverted from the first push. The six
changed files do not include them.
- The objectives report that session activity reads take 0.11 ms, down
from 3.1 ms, on 2,850 card statuses with 30 in flight. This figure comes
from an uncommitted throwaway benchmark. The output was identical.
- On Postgres, the objectives state that the stamp path already used
`SELECT … FOR UPDATE`. The change reduces that path from five statements
on a dedicated connection to two statements. This diff does not show a
Postgres test.

### Verification

No CI, build, or test results were available for this review.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-16 20:51:46 -08:00
Tyler Barnes
7518c05d6f
feat(core): add knowledge.movePage() to move a page without losing its notes or pins (#30631) 2026-11-16 21:48:39 -07:00
Ward Peeters
8cc2b95344
fix(factory): unload idle and released sessions from server memory (#30612)
## Description

A long-running Factory server keeps every agent session it has ever
opened in memory. In production that adds up to roughly 2 GB growing to
7 GB over six hours, with GC climbing from about 13% to 42% of busy CPU
until the next redeploy. The core `AgentController` holds sessions until
the host deletes them, and Factory only deleted them from the explicit
delete routes. Each session kept its display state, tool results,
workspace caches and subscriptions.

Factory now unloads a session from memory in two cases. The first is
when it stops or releases the session's sandbox: a card leaving a
context, a card finishing, or a retired session. The second is after 30
minutes without activity, checked every minute. A session stays loaded
while it has a run in flight, a pending approval or
`ask_user`/`submit_plan` wait, an active thread stream, or a browser tab
following its event stream. Busy sessions released by a sandbox stop get
unloaded on the first sweep after their work ends. Before unloading,
Factory waits for run-end audit writes, then drops its per-session
workspace caches. It does not stop or destroy the sandbox VM. The
thread, messages, session row, sandbox and work-item bindings all stay,
so the next message, dispatched run, deferred wake or reopened tab loads
the session again from storage. No `@mastra/core` changes.

```ts
new MastraFactory({
  // defaults shown; `idleMs: 0` only unloads on sandbox release, `false` never unloads
  idleSessionUnload: { idleMs: 30 * 60_000, sweepIntervalMs: 60_000 },
});
```

Unloading drops in-memory state that isn't persisted: `session.state`
that isn't mirrored to thread metadata, auto-approvals granted for the
session, and past bus events. The UI rebuilds the transcript from stored
messages.

I'd like reviewers to weigh in on some risks. There's a small window
where the sweep can unload a session that the start coordinator just got
back from `createSession` but hasn't touched yet. The re-checks right
before `deleteSession` shrink that window but don't close it, and owner
takeover and route deletes have the same gap today.
`mastra_factory_sandboxes_active` counts memoized sandboxes, so it
undercounts VMs whose session idled out while the VM kept running (a
restart already does the same). Without `auth`, a deferred wake for an
unloaded session waits until something else loads it, same as after a
restart. Unloading is per replica: a replica only unloads sessions it
holds itself, and every replica runs its own sweep. I also haven't
measured heap in a long-running process. The tests prove the controller
drops the session and Factory clears its caches, but not that RSS
flattens in production.

Test plan: new tests run on a real `AgentController` with
`InMemoryStore`, a mock language model and a real Hono server
(`session/session-unloader.test.ts`). They cover idle unload, a running
turn, a parked `ask_user`, an open SSE tab, rehydration with history and
the row owner, release-then-sweep, the timer, and settings validation.
`sandbox/context-sandboxes.test.ts` covers unload when a card leaves a
context or finishes, over libsql and pg. `workspace.test.ts` checks that
invalidation drops caches without stopping or destroying the sandbox.
Mutation checks showed the new tests fail when the unload hook, watcher
check, busy check, timer or run-audit settle is removed. The focused
Factory suites pass (41 files, 1111 tests), along with `tsc --noEmit`
and oxlint. In the full Factory suite, the only failures are the 13 that
also fail on untouched `main` in this environment (config, fs,
session-model-catalog and session-tools route tests that pick up local
provider credentials).

## Related issue(s)

No public issue. This was reported from the production Factory
deployment.

## 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)
- [x] Documentation update
- [ ] Code refactoring
- [x] Performance improvement
- [ ] Test update

## Checklist

- [ ] 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: When a Factory session is no longer needed, the server removes it
from memory. The saved session data stays on disk, so the session loads
again when someone uses it.

## Summary

This PR adds session unloading to `@mastra/factory`. The server removes
a session from memory in these cases:

- Its sandbox is stopped or released.
- It has been idle for 30 minutes. The default sweep runs every minute
per process.

A session stays loaded while any of these hold:

- A run is active.
- An approval or user answer (`ask_user` or `submit_plan`) is pending.
- A browser event stream is open.
- Its running sandbox reports a tracked background process.

For an idle session with a running process, the idle clock resets for
another idle timeout. Only sandboxes with status `running` are queried
for processes. Released sessions are not queried, because their sandbox
has already stopped. A busy session that is released unloads on a later
sweep, after it becomes idle.

Before unloading, the factory waits for run-end audit writes to finish.
It then clears the session's cached workspace entry. It does not stop or
destroy the sandbox VM.

Threads, messages, session rows, sandboxes, and work-item bindings stay
stored. A later request reloads the session. In-memory-only state,
session auto-approvals, and past bus events are dropped.

The PR also changes the following:

- **Default model on unloaded sessions:** When a bound session is not
loaded, the default-model apply job calls `setThreadModel`. It counts
the binding as applied, not skipped.
- **Untrusted-checkout posture on prompt creation:**
`restorePromptCheckoutTrust` consults a session's run-binding history,
including revoked bindings, even when a binding is active. It marks the
checkout untrusted when bindings span multiple projects or when a
trusted binding's item cannot be verified. Reopened review sessions load
`AGENTS.md` and `CLAUDE.md` from the base branch, or no instructions
when the trusted branch cannot be determined.
- **Process listing failures:** A failed sandbox process listing keeps
the session loaded.

### Key changes

- **`session/session-unloader.ts` (new):** Adds `SessionUnloader`,
`sessionHoldsWork`, `createSessionActivityMiddleware`, and the
`IdleSessionUnloadOptions`, `UnloadableSession`, `UnloadableController`,
and `SessionUnloaderOptions` interfaces. Negative or non-finite idle
values and non-finite or non-positive sweep intervals throw errors.
`unloadReleased` returns `not-loaded`, `unloaded`, or `deferred`. A run
that starts during release cancels the pending unload.
- **`factory.ts`:** Adds `idleSessionUnload?: false |
IdleSessionUnloadOptions` to `MastraFactoryConfig`. The factory creates
the unloader unless the option is `false`. It starts the unloader in
`finalize()` and stops it in `shutdown()`. It adds a `setThreadModel`
callback to the controller wiring. `hostInstructions` calls
`restorePromptCheckoutTrust`.
- **`sandbox/session-retirement.ts`:** Adds an optional `unloadSession`
callback. The coordinator calls it after sandbox stop or release. Unload
errors are logged and not propagated.
- **`rules/dispatcher.ts`:** Uses `sessionHoldsWork(session)` to decide
whether to keep a stale run binding.
- **`rules/binding-context.ts`:** Adds `restorePromptCheckoutTrust`. It
classifies review-context and pull-request items as untrusted.
- **`storage/domains/work-items/base.ts`:** Adds an index on `(org_id,
session_id)` and `listRunBindingsForSession`. The method returns all
bindings for a session, including revoked ones, oldest first.
- **`session/run-audit.ts`:** Changes `waitForSessionRunAudit` to accept
`object` instead of `RunEndCaptureSession`.
- **`routes/projects.ts`:** `ModelApplyController` now requires
`setThreadModel`.
- **Docs and changesets:** `mastracode/factory/README.md` adds an
"Unloading idle sessions" section. The changesets mark a minor
`@mastra/factory` release and a patch release for reopened review trust.
- **Tests:** Adds `session/session-unloader.test.ts` (443 added lines).
Updates the context-sandbox, workspace, default-model scenario,
source-control session, and projects tests. Several controller mocks now
include `onSessionDeleted` and return unsubscribe functions.

The PR changes 23 files, with 1,433 lines added and 82 removed.

### Configuration

- `idleSessionUnload` is enabled by default.
- `idleMs: 0` disables idle unloading. Released-session unloading still
runs.
- `false` disables all unloading.

### Known limitations

- A deferred wake without `auth` does not reload an unloaded session.
The session loads when another event loads it, as after a restart.
- Whether a remote sandbox provider's process listing reports processes
after reload is not verified.
- Production heap or RSS improvement was not measured.
- The risks the author lists include a race between session creation and
sweeping, possible undercounting by `mastra_factory_sandboxes_active`,
and per-replica unloading.

### Verification

The author reports these results. They were not re-run for this summary.

- 41 focused Factory test files with 1,111 tests pass.
- After the later trust fix, `source-control-sessions.test.ts`,
`src/rules`, and `src/session` pass (1,344 tests).
- `tsc --noEmit` and oxlint pass.
- 13 full-suite Factory failures occur. The same failures occur on
untouched `main` in the author's environment.

### Review status

- Review finding counts: not available.
<!-- 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: Damien Schneider <74979845+damien-schneider@users.noreply.github.com>
2026-11-16 20:45:19 -08:00
Damien Schneider
76069d5b99
fix(factory): follow a card when a chat approves or retries its run (#30637)
## Description

Stacked on mastra-ai/mastra#30628.

When a session moves a card, it follows it, so the run's report (done,
failed, blocked, waiting for approval) reaches that session and it can
pass the outcome on in its chat. Approving a held run with
`factory_resolve_proposal` (as the person), or retrying a failed one
with `factory_retry_decision` (which keeps the run's original approver),
also starts a run from the session, but didn't follow the card.

That matches what happened in Slack on Nov 16: asked to "start the
automated review on the board" for #30578, Shipyard approved the held
review run, said "I'm following the card and will post here when the
review finishes", and never posted, although the review finished and was
approved on GitHub. The card's run-end report goes only to the card's
followers (`workItemReportRecipients`). I couldn't read that session's
traces from here, so this is the gap the code shows, not a confirmed
cause for that thread.

Now both tools follow the run's card with reason `started`, as
`factory_start_session` did for a card's role before #30628 removed that
mode. Dismissing a proposal doesn't follow. Both results also carry the
card's `url`, like `factory_transition_work_item` in #30628. The
approval or retry has committed before the card is read and followed, so
a failed read or follow returns the result with a warning rather than an
error.

```ts
factory_resolve_proposal({ decisionId, action: 'approve' })
// before: { decisionId, status: 'pending', workItemId }, and the session hears nothing more
// after:  { decisionId, status: 'pending', workItemId, url }, and the run's report reaches this session
```

Not in this PR: whether the woken session then reliably posts the
outcome in its thread. That's the agent's call today, guided by the
channel instructions ("post the outcome when the people in the thread
asked for this work"). A system-posted line, like the existing pull
request opened and merged announcements, would make it deterministic but
adds Slack noise, so it needs a decision first.

## Related issue(s)

Reported in Slack (Factory review requests answered in the chat instead
of on the card). Related to FACT-517.

## 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
- [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
- [x] I have addressed all Coderabbit comments on this PR

Tests in `src/tools/work-item-tools.test.ts`, on the real transition
service and LibSQL storage: a pull request card in Review with its
review held as a proposal. Approving it from the chat, or retrying it
after it failed, makes the chat session a recipient of the card's
run-end report (`workItemReportRecipients`). Both fail without the fix
(no recipients). Dismissing doesn't follow. A card read that fails after
the approval returns the approved run with a warning (it rejected before
the fix). Ran `tsc`, oxlint, and the `src/tools` and `src/mcp` suites
(16 files, 342 tests).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VhgyDWFgVkhDt1X1NPmPas

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

<!-- coderabbit-ai-generated:v1 -->

**ELI5:** When a chat session approves a held Factory run or retries a
failed one, the chat now follows that run's card. The tool result also
includes the card's link. Dismissing a held run does not make the chat
follow the card.

## Summary

This change makes the chat session follow a Factory run's card when the
session approves or retries that run. Both tool results include the card
URL. Dismissing a held proposal does not follow the card.

### Changes by file

- **`mastracode/factory/src/tools/work-item-tools.ts`** (+42/-11)
  - Adds `started` as a subscription reason for `follow`.
  - Adds `followStartedRun`. It looks up the decision's work item.
- If the work item ID is missing or the lookup finds no item, the helper
returns the original result.
- If the lookup or subscription throws, the helper returns the result
with a warning. The result includes the URL if it was already obtained.
- Retry results and approved proposal results use this helper. Dismissed
proposal results do not.
  - Tool descriptions document the follow behavior and the URL.
- **`mastracode/factory/src/tools/work-item-tools.test.ts`** (+94/-0)
  - Imports `workItemReportRecipients`.
  - Adds `url: null` to the expected retry result.
- Adds tests. Approving a held run and retrying a failed run each add
the chat session to `workItemReportRecipients`. Dismissing a held run
does not.
- Adds a test. When the card read fails after approval, the approval
still reports success. The result has a null URL and a warning.
- **`mastracode/factory/README.md`** (+1/-1)
- Documents that `factory_resolve_proposal` approves the run as the
acting person.
- Documents that `factory_retry_decision` keeps the run's original
approver and needs no person in the turn.
- Documents that both actions make the session follow the card and
include the card URL in the result.
- **`.changeset/silly-moose-read.md`** (+5/-0)
  - Adds a patch changeset for `@mastra/factory`.

### Scope and limits

- The change adds the session to the card's report recipients. It does
not show that the woken session posts its outcome in its thread. The PR
description places that behavior outside this change.
- The author reports that `tsc`, oxlint, and the `src/tools`, `src/mcp`,
and `src/integrations/slack` suites passed (29 files, 669 tests). This
summary does not verify those results. CI results for the current head:
not available.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 20:24:45 -08:00
Damien Schneider
c547a8303c
fix(factory): let chat sessions run a card's work the way the board's buttons do (#30628)
## Description

When someone asks a Factory chat session (Slack or the web) to review a
pull request that already has a card, the session usually reviews it
itself or in a side session and posts the review in the chat. The card's
own review stays held for approval, nothing is recorded on the card, and
the review never lands on GitHub through the review stage. Romain hit it
on Oct 30 ("review this PR pls"), then Yujohn, Arthur and Charlie on Nov
16.

The cause is that session tools didn't do what the board's buttons do:

- The board's **Start**/**Review** button on a card already in its stage
sends a transition to that same stage with `reenter: true`.
`factory_transition_work_item` calls the same transition service, but
couldn't send `reenter`, so "move #30578 to pr-review" on a card already
there did nothing, and a re-review from Slack wasn't possible at all.
- So agents fell back to `factory_start_session(workItem, role)`, which
started a card's role straight from the start coordinator. That path
skipped the board's rules: it didn't check which stage the card was in
or whether it was busy, and it refused a role that had ever had a
session.
- The tools only took a card id or `#number`, so a pasted pull request
link didn't resolve. With several repositories linked, `#5001` picked an
issue in one repository over a pull request in another.

This PR makes session tools use the same operations as the board, and
adds a test that keeps it that way:

- `factory_transition_work_item` takes `rerun: true` to run the stage a
card is already in again, sending `reenter` like the button. On a
person's turn the run counts as approved by them, so a held run no
longer waits, and a busy card is refused as on the board. A turn nobody
signed in started can't rerun a stage. Without `rerun`, a request for
the card's own stage changes nothing and says whether its run is waiting
for approval, so "move it to review" on a card that was already reviewed
doesn't start another pass.
- `factory_start_session` only starts side sessions. Its `workItem` and
`role` inputs are removed, along with the code behind them.
- The tool descriptions steer a plain "review this pull request" to the
pull request's card, and keep side sessions for what people ask to run
in one and for work no stage does (investigations, pushing fixes to a
pull request, taking one over).
- Tools that take a work item also accept the issue or pull request it
tracks: its link (including `/files` or comment links), `owner/repo#12`,
`group/project!7`, or a key like `ENG-42`. They're matched against the
source keys the provider adapters already store. The pull request's own
card wins, then the card it's attached to, and a reference that matches
more than one card is refused with the candidates.
`factory_list_work_items` takes the same references as its query.
- `factory_inspect_work_item` returns `moves`: the card's stage, whether
it can run again, and the stages its board lets it move to next, so the
agent doesn't have to guess `review` vs `pr-review`.
- `board-parity.test.ts` scans `src/tools` and fails if a tool starts a
card's run, commits a transition, or settles a run without going through
the transition service and the shared decision actions that the board's
routes use. It flags 5 lines in the previous `session-tools.ts`.

Before, from Slack, on a card in Review whose review is held for
approval:

```ts
factory_transition_work_item({ workItem: '#30578', stage: 'pr-review' })
// accepted, nothing queued: the agent then starts a side session instead
```

After:

```ts
factory_transition_work_item({ workItem: 'https://github.com/mastra-ai/mastra/pull/30578', stage: 'pr-review' })
// { unchanged: true, message: '#30578 is already in pr-review, and its run there is waiting for approval. Pass rerun: true …' }
factory_transition_work_item({ workItem: 'https://github.com/mastra-ai/mastra/pull/30578', stage: 'pr-review', rerun: true })
// { stage: 'pr-review', reran: true }: a review run approved by the person is queued, as the board's button does
```

**Checked against how people use Shipyard from Slack.** I went through
#shipyard-graveyard and #eng-proj-factories for side session and card
requests:

- Explicit side sessions are the most common request: Abhi ("fix this
issue in a side session", 15+ times), Ryan ("take on PLTFRM-3694 in a
side session"), Romain, Nik, Justin, Charlie ("start separate sessions
to address the requested changes"). They still start side sessions; the
descriptions say so.
- "Review and take over this PR" (Abhi, several PRs a day): a side
session that reviews, pushes fixes and approves. A card's review stage
can't push commits, so this stays side-session work.
- Side sessions running the review skills without being bound to a card
(Abhi, mastra-ai/mastra#27918): unchanged, the workspace exception is
untouched.
- `factory_start_session(workItem, role)`: Shipyard offered it a few
times but didn't use it; it approved the held run or moved the card
instead. When a review got stuck after "changes requested", the
documented way out was moving the card to Building. It also couldn't
re-review ("I can't trigger the re-review from here"), which `rerun` now
can.
- "Move it to review" on a card that was already reviewed (Dustin, Nov
16, mastra-ai/mastra#30345): this is why `rerun` is explicit instead of
implied by the stage.

Not in this PR, as follow-ups:

- The UI's draft start (`/runs/start` from
`useStartCardSessionFromDraft`) also calls the start coordinator without
a destination stage; it needs the same check.
- A note from the person ("focus on security", or "point it at the nits
I found") can't ride along with a rerun yet; the agent can send it to
the card's session with `factory_signal_session` once it starts.
- A request for a review from GitHub by a maintainer is still held for
approval on human-authored pull requests (`transition-service.ts`, event
routes disarm). Whether that should count as approval is a separate
decision.
- "Review these in side sessions" on pull requests that have cards stays
a side session, as asked. Whether that wording should go to the cards
instead is a product call.
- A state signal that tells a session which cards the PR or issue links
in a message belong to, so it doesn't depend on the model looking first.

## Related issue(s)

Reported in Slack (Factory review requests answered in the chat instead
of on the card). Related to FACT-517.

## Type of change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [x] 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
- [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

Tests: `src/tools/work-item-tools.test.ts` drives the real transition
service and LibSQL storage: a pull request card in Review with its
review held as a proposal, asked for by link. It fails without the
`reenter` change (`expected [] to deeply equal [ObjectContaining{…}]`).
Also covered: the same request without `rerun` leaves the held run alone
and says it's waiting, the busy refusal, the turn without a person,
`moves`, and resolving a link when an issue in another repository has
the same number, or when a pull request is attached to its issue's card.
`card-reference.test.ts` covers GitLab, Linear and Jira references. Ran
`tsc`, oxlint, and the `src/tools`, `src/mcp`, `src/integrations/slack`,
`factory.test.ts`, start coordinator and transition service suites
locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VhgyDWFgVkhDt1X1NPmPas

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

**ELI5:** This change lets the Factory chat tools act on the board's
cards the same way the board does. Users can rerun a card's current
stage, find cards by link or key, and start side sessions for work that
has no card.

## Overview

- Base: `main`, merge base `3c7c00383d`.
- Files changed: 12. Lines: +627 / -860.
- Changes span the Factory tools, the MCP test fixture, the README, a
changeset, and new tests.

## Changes

### Card transitions (`work-item-tools.ts`)

- `factory_transition_work_item` accepts `rerun: true`. This reruns the
card's current stage through the transition service.
- Without `rerun`, a request for the current stage returns an unchanged
result. The result reports whether an `invokeSkill` decision awaits
approval.
- Reruns require an interactive person.
- Transition results include the card URL. The URL is `null` when no
public Factory URL is configured.
- The tool follows the card after a transition. A follow failure
produces a warning and does not fail the call.
- The tool description separates stage work from side-session work.
- The update-tool description directs stage reruns to the transition
tool.
- A `workItemLabel` helper shows numbered cards as `#number`. Unnumbered
cards show their title.

### Work-item references (`read-tools.ts`, `card-reference.ts`)

- `workItemRefSchema` accepts a UUID, a numeric card number, or a source
reference. The maximum length rises from 64 to 512 characters.
- A UUID resolves directly.
- A source reference (issue or pull-request link, repository shorthand,
or tracker key) resolves in this order:
  1. A card that is the source's own card.
  2. A card that carries the source.
- Ambiguity errors show the board and stage. Nonnumeric references are
labeled as supplied.
- Listing supports source-reference queries. Filter descriptions state
stage and board keys.
- Inspection adds the board's available moves. The moves show whether
the current working stage can be rerun.
- Inspection loads the board source before it checks overtaken
decisions.
- New `card-reference.ts` exports:
- `sourceKeyFromReference(reference: string): string | null` parses
GitHub, GitLab, Linear, and Jira references, shorthand, and tracker
identifiers.
- `isSourceReference(reference: string): boolean` also accepts any
HTTP(S) URL.
- `sourceMatchesReference(source, reference): boolean` compares keys
case-insensitively. It compares other URLs after normalization.
- `isCardFor(card, reference): boolean` checks only the card's first
source.
- `cardCarries(card, reference): boolean` checks all of the card's
sources.
- `read-tools.ts` adds a module-scoped helper `findBySource(items, ref):
Card | null`.

### Side sessions (`session-tools.ts`)

- `factory_start_session` accepts only `prompt`, optional `title`, and
optional `model`. It always starts a side session.
- The work-item role-start path is removed. This path validated roles
and existing role sessions. It subscribed the caller to the item,
started the run, and returned work-item and binding details.
- The related board, coordinator, repository-resolution, audit, and
run-heartbeat dependencies are removed.
- The tool instructions no longer direct card-stage work through this
tool.

### Wiring (`factory.ts`, `routes.test.ts`)

- `factory.ts` removes the `FactoryStartCoordinator` import, the
`#startCoordinator` field, and its wiring through `factoryToolDeps` and
`onFactoryRuntime`.
- `factory.ts` removes the `intake` dependency from `factoryToolDeps`.
- `routes.test.ts` stops providing `intake` and `startCoordinator` in
its fixture.

### Tests

- `board-parity.test.ts` (new): a Vitest guard. It scans non-test
TypeScript files under `tools/`. It fails when a line matches patterns
for starting runs, committing transitions, settling deferred decisions,
or recording run starts outside the board's shared routes.
- `work-item-tools.test.ts`:
  - Uses the runtime transition service and read tools.
  - Expects `url: null` when no public Factory URL is configured.
- Adds a chat-request suite. It covers reruns of a held pull-request
review by link, unchanged-stage requests, duplicate queued runs,
noninteractive reruns, stage inspection, and pull-request resolution by
URL or repository-qualified number.
- `card-reference.test.ts` (new): covers the key-extraction and matching
helpers.
- `session-tools.test.ts`:
  - Removes the coordinator setup and the work-item-mode suite.
  - Removes one noninteractive-turn test.
- Asserts that a role with a work item, and a work item without a role,
are both invalid. A prompt alone stays valid.

### Documentation and release

- `mastracode/factory/README.md` documents the `rerun` flag, reference
lookup, and side-session behavior.
- `.changeset/smooth-sails-learn.md` declares a minor release of
`@mastra/factory`.

## Public API changes

- `workItemRefSchema` validation changes as described above.
- New exports in `card-reference.ts`, listed above.
- `factory_start_session` no longer accepts `workItem` or `role`.
- Transition results add a `url` field.

## Verification

- Review findings: not available. No review findings were supplied.
- CI and build results: not available. No completed checks were supplied
for the current head.
- The author reports running `tsc`, oxlint, and the `src/tools`,
`src/mcp`, `src/integrations/slack`, `factory.test.ts`, start
coordinator, and transition service suites locally. These results are
not independently confirmed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 20:24:45 -08:00
mastra-platform[bot]
33fba78931
fix: make URL slash trimming and PR number parsing linear-time (#30577)
## Summary

Resolves four open CodeQL code-scanning findings.

| Ticket | Alert | Rule | Location | Change |
| --- | --- | --- | --- | --- |
| SEC-326 |
[#988](https://github.com/mastra-ai/mastra/security/code-scanning/988) |
js/polynomial-redos | `packages/core/src/llm/model/gateways/mastra.ts` |
`/\/+$/` trailing-slash trim replaced with an end-of-string scan |
| SEC-325 |
[#987](https://github.com/mastra-ai/mastra/security/code-scanning/987) |
js/polynomial-redos | `mastracode/factory/src/boards/semantics.ts` |
`/(\d+)$/` replaced with a `trailingDigits` scan from the end |
| SEC-316 |
[#985](https://github.com/mastra-ai/mastra/security/code-scanning/985) |
js/polynomial-redos | `auth/supabase/src/index.ts` | `/\/+$/`
trailing-slash trim replaced with an end-of-string scan |
| SEC-316 |
[#986](https://github.com/mastra-ai/mastra/security/code-scanning/986) |
js/type-confusion-through-parameter-tampering |
`server-adapters/nestjs/src/__tests__/builtin-mcp-oauth.test.ts` | Test
auth provider now checks `typeof token === 'string'` before using it |
| SEC-259 |
[#752](https://github.com/mastra-ai/mastra/security/code-scanning/752) |
js/insufficient-password-hash | `packages/core/src/utils.ts` | No code
change. This is a false positive (see below) |

### ReDoS fixes

These regexes are unanchored at the start. On a string with a long run
of `/` (or digits) followed by another character, the engine retries the
match from every position, which takes quadratic time. On 100k
characters the old code took about 7s for the slash trim and about 10s
for the digit match. The replacements walk back from the end of the
string once and return the same results. That covers the edge cases too:
an empty run, an all-slash or all-digit string, and leading zeros like
`007`.

### #752 is a false positive

`createDeterministicId` already uses SHA-256
(`createHash('sha256').update(input).digest('hex').slice(0, 8)`). It
builds a short, non-secret `tool-<hash>` ID from `tool.description` in
`setVercelToolProperties`, and nothing in it stores a password. CodeQL
raises this rule for any fast hash it thinks might receive a credential.
Here its taint path runs from the API keys passed to the Gateway model
providers in `mastracode/sdk`, through provider/model objects, and not
through a tool description. No hash change would satisfy the rule: it
wants a slow KDF (bcrypt/scrypt/PBKDF2), which would change every
existing tool ID that callers rely on. Recommend dismissing #752 as a
false positive.

## Test plan

- [x] Regression tests with 100k-character pathological inputs in
`mastra.test.ts`, `auth/supabase/src/index.test.ts`, and
`boards/semantics.test.ts`. I checked that each one fails (times out at
7–20s) against the old regex and passes with the fix.
- [x] Behavior tests for gateway base-URL normalization (`///`,
`/v1///`, `/api/`) and for falling back to the PR number from the GitHub
key (`34`, `007`, empty, `12x`)
- [x] `vitest` passes for the gateway tests in `@mastra/core`, all of
`@mastra/auth-supabase`, the semantics and GitLab rules tests in
`@mastra/factory`, and the MCP OAuth test in `@mastra/nestjs`
- [x] `tsc --noEmit` is clean for `packages/core`, `auth/supabase`,
`mastracode/factory`, and `server-adapters/nestjs`
- [x] Changeset added for `@mastra/core`, `@mastra/auth-supabase`, and
`@mastra/factory`. The NestJS change only touches a test, so it has no
changeset

Ref SEC-326
Ref SEC-325
Ref SEC-316
Ref SEC-259


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

**ELI5:** Some code used regular expressions that ran very slowly on
very long strings of `/` or digit characters. This change replaces them
with loops that scan each string once. The results stay the same.

## Overview

The change replaces three end-anchored regular expressions with backward
scans. It also adds a type guard in a NestJS test helper. The diff
touches 9 files, with 93 lines added and 4 removed.

The change addresses three polynomial ReDoS findings and one
type-confusion finding from CodeQL. It does not change code for the
insufficient-password-hash finding (`#752`) on `createDeterministicId`.
The author classifies that finding as a false positive. The hash creates
non-secret tool IDs from tool descriptions. A slow KDF would change
existing IDs.

## Changes by area

- **Gateway base URL**
(`packages/core/src/llm/model/gateways/mastra.ts`): `getBaseUrl` removes
trailing `/` characters with a character-by-character loop. It then
removes a final `/v1` suffix.
- **Supabase URL** (`auth/supabase/src/index.ts`): The provider stores a
normalized `this.url`. A backward loop removes trailing `/` characters.
The Supabase client still receives the original `supabaseUrl`.
- **Pull request number**
(`mastracode/factory/src/boards/semantics.ts`): The new helper
`trailingDigits` scans backward over ASCII digits `0`–`9`.
`boundChangeRequestNumber` calls it only for `github-pr` sources. It
returns `undefined` when no trailing digit exists.
- **NestJS test helper**
(`server-adapters/nestjs/src/__tests__/builtin-mcp-oauth.test.ts`):
`AudienceAuth.authenticateToken` accepts `unknown`. It returns `null`
for non-string values before it parses `aud=`.
- **Changesets**:
- `.changeset/linear-slash-trim.md` sets patch releases for
`@mastra/core` and `@mastra/auth-supabase`. It describes linear-time
trailing-slash trimming. It states that the resulting URLs are
unchanged.
- `.changeset/linear-pr-number.md` sets a patch release for
`@mastra/factory`. It describes linear-time PR-number extraction. It
states that the returned number is unchanged.

## Tests

The test file diffs were not inspected. The following test additions
come from the raw summary and are not verified against the diff:

- A Supabase test that uses a URL with two 100,000-slash runs. It
asserts construction takes under 500 ms.
- Factory tests for trailing-digit extraction, leading zeroes,
`undefined` results, and 100,000-character keys.
- Gateway `fetchProviders` tests for base URL normalization and a
pathological slash-run case.

The PR reports passing Vitest runs and clean `tsc --noEmit` runs for
`packages/core`, `auth/supabase`, `mastracode/factory`, and
`server-adapters/nestjs`. These results were not verified from completed
checks on the current head: not available.

## Notes

- The NestJS change is test-only. It has no changeset.
<!-- 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: shreyas-mastra <shreyas@mastra.ai>
2026-11-16 22:50:34 -05:00
Tyler Barnes
b07dd23713
feat(core): add knowledge.reembed() to embed existing Knowledge content (#30603) 2026-11-16 20:50:08 -07:00
mastra-platform[bot]
6fbd425c83
ci(renovate): keep store-test MongoDB on 7.x (#30601)
## Summary

`Combined Store Tests / test (mongodb)` fails on every PR that touches
stores (e.g. #30577, #30580, #30593) because the test container never
starts:

> MongoDB cannot start: Linux kernel versions 6.19.0 through 7.0.13 have
a known incompatibility with this version of MongoDB

`stores/mongodb/docker-compose.yaml` was deliberately pinned to
`mongo:7.0.45` because MongoDB 8.x+ refuses to start on the self-hosted
runners' kernel (TCMalloc rseq issue, SERVER-121912). The Renovate major
Docker update in #19788 bumped it to `mongo:9.0.8`, undoing that pin.

This PR:
- Restores `mongo:7.0.45` for the `mongodb-storage` and
`mongodb-fidelity` services (the `mongodb-vector` Atlas Local image is
unchanged).
- Adds a Renovate rule capping `mongo` below 8 for that compose file so
it is not bumped again.
- Updates the compose comment to cover 9.x.

**This is a CI-only workaround.** It only changes the test container
image; no published package or runtime behavior changes, so there is no
changeset. Revisit the pin once MongoDB ships a release compatible with
kernel 6.19+, or once the runners move off an affected kernel.

## Test plan

- `Combined Store Tests / test (mongodb)` passes on this PR (the
`stores/mongodb` `pretest` runs `docker compose up -d --wait` against
this file).
- 7.0.45 is the version the suite ran green on before #19788.


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

<!-- coderabbit-ai-generated:v1 -->

## ELI5

The test setup uses a database program that will not start on some test
machines. This change sets the database to an older version that does
start. It also stops automatic updates from moving that database to
version 8 or later.

## Summary

This change pins MongoDB to a version that works on the self-hosted CI
runners.

### Changes

- `stores/mongodb/docker-compose.yaml`: The `mongodb-storage` and
`mongodb-fidelity` services use `mongo:7.0.45`. They previously used
`mongo:9.0.8`. The `mongodb-vector` Atlas Local image is not changed.
- `stores/mongodb/docker-compose.yaml`: The comments now state that the
compatibility restriction applies to MongoDB 8.x and 9.x on Linux kernel
6.19+. They also state that the service must not move beyond 7.x until
MongoDB ships patched TCMalloc.
- `renovate.json`: A new package rule applies to Docker updates for
`mongo` in `stores/mongodb/docker-compose.yaml`. It limits allowed
versions to `<8`.

### Context

The regression came from a Renovate major Docker update. That update
changed the image from `mongo:7.0.45` to `mongo:9.0.8`. The MongoDB
container then failed to start on self-hosted runners because of a
kernel incompatibility.

### Impact

- The change affects CI test infrastructure only.
- No published package or runtime behavior changes.
- The PR description reports that `Combined Store Tests / test
(mongodb)` passes with the restored image. This summary does not verify
that result.

### Review notes

- The pin should be revisited when MongoDB supports kernel 6.19+ or when
the runners move off an affected kernel.
- The diff totals 2 files, 11 lines added, and 4 lines removed. The
`renovate.json` change adds 7 lines. The Compose file change modifies 4
lines.

<!-- 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>
2026-11-16 22:49:02 -05:00
Tyler Barnes
b35a72cc7c
ci(test-tiers): fill the GitHub to Slack user map and add a skill to update it (#30629) 2026-11-16 20:44:49 -07:00
Damien Schneider
3c7c00383d
fix(factory): let the server decide which repository a card's session starts in (#30609)
**─────── TLDR ───────**
> A card's draft now asks the server which repository its session starts
in, so a card from an unlinked repository is refused instead of started
somewhere else.

The draft carried its own copy of the repository rule, and a looser one:
when the card's repository wasn't linked, it fell back to the
environment's first repository and wrote that slug onto the card before
calling `runs/start`, which then accepted it. The fallback came from
main's `useStartFactoryRun`, not from #30481. Now the draft reads
`resolveRunRepository`, the same function `runs/start` checks with,
through a new route, and shows its hint as is.

### Behavior changed

GitHub card from `acme/docs`, only `acme/app` linked
&nbsp;&nbsp;├─ **was** — starts in `acme/app`, card rewritten to
`repository: acme/app`
&nbsp;&nbsp;└─ **now** — the draft says "Repository acme/docs is not
linked to this Factory.", nothing starts, "Open repository settings"
leads to the fix

card whose repository resolves (linked, Linear mapping, or a single
repository)
&nbsp;&nbsp;├─ **was** — starts there, after the draft writes
`repository` onto the card
&nbsp;&nbsp;└─ **now** — starts there, the card is left as it was

the draft when the server can't answer
&nbsp;&nbsp;└─ **new** — "Could not find this card's repository: …",
sending stays off, also when an earlier lookup had answered; Retry asks
again

the draft after the repository gets linked, or after the card changes
&nbsp;&nbsp;└─ **new** — asks the server again on reopen, on tab focus,
and when the card changes

GitHub card in a Factory whose repositories are all on GitLab, or the
reverse
&nbsp;&nbsp;├─ **was** — the draft refused it; dispatch and `runs/start`
ran it in the Factory's repository
&nbsp;&nbsp;└─ **now** — refused everywhere, even when a repository
there has the same name: "This card comes from GitHub, and no GitHub
repository is linked to this Factory."

card naming no repository among several
&nbsp;&nbsp;└─ **unchanged** — starts in the environment's first one,
the agent picks

### Shape changed

new route the draft reads before the first prompt
&nbsp;&nbsp;&nbsp;&nbsp;`GET
/web/factory/projects/:id/work-items/:workItemId/session-repository` ·
`{ status: 'resolved', projectRepositoryId, slug }` · `{ status:
'unlinked', hint }`
&nbsp;&nbsp;&nbsp;&nbsp;CLI: `mastra api factory work-item
session-repository <project-id> <work-item-id>`

one place every run reads its repository from: the draft route, rule
dispatch, `runs/start` and `factory_start_session`
&nbsp;&nbsp;&nbsp;&nbsp;`resolveRunRepositoryFromIntake(intake, args)` ·
reads the Linear mapping, then Ward's `resolveRunRepository`

removed: `cardSessionRepository` · `firstEnvironmentRepository` ·
`cardRepositorySlug` · `cardLinearProjectId` · `useCardRepositorySlug`

### Decisions

- **a GET the draft reads, not one call that resolves and starts** — the
refusal has to show before the first prompt; `runs/start` still checks
on its own.

### Not verified

- [ ] a real Factory with an unlinked GitHub repository: covered by the
route tests and the draft's MSW tests only

---

> ██████████████████ **tests** `+257 −320` — net −63
> ███████████ **source** `+217 −150` — net +67
> ███ **generated** `+83`
> █ **changeset** `+17`





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

ELI5: A Factory card used to choose its own code repository in the app,
and that choice could be wrong. Now the server chooses the repository,
and a card starts a session only when the server finds one.

## Summary

This pull request moves repository selection for Factory card sessions
from the client to the server. It changes 26 files, with 534 lines added
and 468 removed.

### Server changes (`mastracode/factory`)

- Adds the `GET
/web/factory/projects/:id/work-items/:workItemId/session-repository`
route. The contract is in `routes/contracts.ts`. The handler is in
`routes/work-items.ts`.
- The response is a discriminated union:
  - A resolved result returns `projectRepositoryId` and `slug`.
  - An unlinked result returns a `hint`.
- The route returns 404 when the card is outside the caller's
organization or project. It returns 503 when no `sessionRepository`
resolver is configured.
- Adds `resolveRunRepositoryFromIntake` in
`session/work-item-repository.ts`. It reads Linear intake configuration
for the organization and passes the `repositoryByLinearProject` map to
`resolveRunRepository`. If intake or the map is absent, it passes no
map.
- Adds a provider check. When the active integration has no matching
provider ID, and card metadata contains an ID for another supported
provider (GitHub or GitLab), the result is unlinked, with a hint naming
that provider. This check runs before the repository slug and Linear
mapping are considered.
- `rules/start-coordinator.ts`, `tools/session-tools.ts`, and
`routes/surface.ts` call `resolveRunRepositoryFromIntake`. They no
longer load intake configuration directly.
- `routes/surface.ts` supplies the `sessionRepository` resolver when
source-control integrations are registered. It returns an unlinked
result when no source-control connection resolves.

### Factory UI changes (`mastracode/factory-ui`)

- Adds the `WorkItemSessionRepository` type, the
`workItemSessionRepository` query key, and
`getWorkItemSessionRepository` in `services/workItems.ts`.
- `useCardSessionRepository` takes `factoryId` and a card with `id` and
`updatedAt`. It fetches the repository from the server. The query uses
`staleTime: 0` and refetches on window focus.
- `useStartCardSessionFromDraft` starts a session only when a resolved
repository is available. It no longer writes the selected repository to
the card.
- `CardDraftPage` shows an error message when the lookup fails. It
offers Retry, which is disabled while the lookup runs. It shows the
server hint and a link to repository settings when the result is
unlinked. Sending stays disabled in both cases.
- Removes client-side repository logic from `boardRepository.ts`:
`cardRepositorySlug`, `cardSessionRepository`,
`firstEnvironmentRepository`, and `cardLinearProjectId`. Removes the
`useCardRepositorySlug` hook.
- Adds the `workItemSessionRepository` CLI command in `packages/cli`. It
shows the repository a card session starts in, or the reason none is
available.

### Tests and changesets

- `work-items.test.ts` adds tests for resolved responses, unlinked
responses, and 404 responses. The 404 test confirms that the resolver is
not called.
- `work-item-repository.test.ts` adds parameterized tests. A GitHub card
is unlinked when only a GitLab repository is linked. A GitHub or GitLab
card whose repository isn't linked is named from its URL in the hint.
- `boardRepository.test.ts` targets `cardProjectRepositoryId` and covers
provider-ID lookup. The old slug, session-repository, and
first-environment tests are removed.
- The UI MSW and unit tests now use the endpoint. Environment-based
repository tests are removed.
- The CLI descriptor test expects the new
`factoryWork-itemSession-repository` entry.
- Two changesets declare patch releases for `@mastra/factory`. A third
declares a patch release for `mastra` and documents the new CLI command.

### Behavior notes

- A card with a resolvable repository starts in that repository. The
card is not rewritten.
- A card with no resolvable repository shows the server hint. Sending
stays disabled.
- If the lookup succeeds and a later lookup fails, sending stays
disabled. The PR description reports this as a tested case.
- The PR description says that cards without a repository among several
keep the first-repository behavior. The diff does not confirm this on
the server. The client-side first-environment selector was removed. The
server-side fallback was not checked.

### Verification

- The PR description reports that the unlinked-GitHub scenario was
covered only by route tests and draft MSW tests. It was not verified in
a real Factory.
- CI and build results are not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-16 19:29:51 -08:00
277 changed files with 11686 additions and 3325 deletions

Some files were not shown because too many files have changed in this diff Show more