mastra 1.23.0 → 1.23.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/dist/commands/dev/DevBundler.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/studio/assets/{core-CbvhbAyq.js → core-R8IQBlLo.js} +1 -1
- package/dist/studio/assets/{index-DUdZoPvJ.js → index-DXHR3Phj.js} +2 -2
- package/dist/studio/assets/{main-tYRi5VOV.js → main-jIvIzWG_.js} +3 -3
- package/dist/studio/index.html +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 1.23.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Added file-based schedules for agents** ([#20711](https://github.com/mastra-ai/mastra/pull/20711))
|
|
8
|
+
|
|
9
|
+
File-based agents can now declare recurring tasks in a `schedules/` directory next to their tools and skills. Mastra registers them into schedule storage at startup, so a scheduled agent no longer needs any runtime registration code.
|
|
10
|
+
|
|
11
|
+
Each file is one schedule: a cron expression plus exactly one execution mode. Prompt mode runs the owning agent with a fixed message.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// src/mastra/agents/support/schedules/heartbeat.ts
|
|
15
|
+
import { defineSchedule } from '@mastra/core/agent';
|
|
16
|
+
|
|
17
|
+
export default defineSchedule({
|
|
18
|
+
cron: '*/5 * * * *',
|
|
19
|
+
prompt: 'Check system health and report any failures.',
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Handler mode computes the fire when it triggers, and returning `null` skips it.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// src/mastra/agents/support/schedules/billing/sweep.ts
|
|
27
|
+
import { defineSchedule } from '@mastra/core/agent';
|
|
28
|
+
|
|
29
|
+
export default defineSchedule({
|
|
30
|
+
cron: '0 3 * * *',
|
|
31
|
+
handler: async () => {
|
|
32
|
+
const overdue = await findOverdueInvoices();
|
|
33
|
+
if (overdue.length === 0) return null;
|
|
34
|
+
return { prompt: `Chase ${overdue.length} overdue invoices.` };
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A schedule's id is its path under `schedules/` with the extension stripped, so `billing/sweep.ts` becomes `billing/sweep` and stays stable across builds. Editing a cron patches the stored schedule and recomputes its next fire time, deleting the file deletes the schedule, and pausing a schedule through the API survives a redeploy. Schedules created with `mastra.schedules.create(...)` are in a separate namespace and are never touched by this sync.
|
|
40
|
+
|
|
41
|
+
A schedule can also be a Markdown file, using cron frontmatter with the document body as the prompt.
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
// src/mastra/agents/support/schedules/cleanup.md
|
|
45
|
+
---
|
|
46
|
+
cron: "0 3 * * *"
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Review tickets untouched for 30 days and close the ones that are resolved.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Declaring a schedule is enough to start the scheduler. Schedules are supported on root agents only; a `schedules/` directory under `subagents/` fails the build, because the scheduler cannot resolve a subagent as a run target.
|
|
53
|
+
|
|
54
|
+
`defineSchedule` is exported from both `@mastra/core/agent` and `@mastra/core/schedules`, so authoring a file-based agent needs a single import path.
|
|
55
|
+
|
|
56
|
+
Build and dev support the same convention: schedules are discovered at build time, Markdown schedules fail the build with a message naming the file when the cron is missing, the body is empty, the frontmatter has an unknown field, or the YAML is unparseable. That last case has its own message because a leading `*` is a YAML alias, so `cron: */5 * * * *` needs quoting. The dev server rebuilds when a Markdown schedule changes.
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [[`45a9147`](https://github.com/mastra-ai/mastra/commit/45a914741f578754d79d8b7de7b4e4f304d8e14a), [`990611b`](https://github.com/mastra-ai/mastra/commit/990611ba76eb876d86c9c594371ae5f02f94b432), [`ed5d606`](https://github.com/mastra-ai/mastra/commit/ed5d606739c5e3fbdfa9f272df7809aa5ab43b1d)]:
|
|
59
|
+
- @mastra/core@1.58.0-alpha.0
|
|
60
|
+
- @mastra/deployer@1.58.0-alpha.0
|
|
61
|
+
|
|
3
62
|
## 1.23.0
|
|
4
63
|
|
|
5
64
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevBundler.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/DevBundler.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EAKd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAqB,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAOnD,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,0BAA0B,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"DevBundler.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/DevBundler.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EAKd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAqB,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAOnD,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,0BAA0B,CAAC;CAC3C;AAeD,qBAAa,UAAW,SAAQ,OAAO;IACrC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,OAAO,CAAU;gBAEb,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,UAAQ;IAQnD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAuB1B,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B/C,KAAK,CACT,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,EACjC,qBAAqB,CAAC,EAAE,qBAAqB,GAC5C,UAAU,CAAC,OAAO,aAAa,CAAC;IAsI7B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import handler from "serve-handler";
|
|
|
41
41
|
//#region package.json
|
|
42
42
|
var package_default = {
|
|
43
43
|
name: "mastra",
|
|
44
|
-
version: "1.23.0",
|
|
44
|
+
version: "1.23.1-alpha.0",
|
|
45
45
|
license: "Apache-2.0",
|
|
46
46
|
description: "cli for mastra",
|
|
47
47
|
type: "module",
|
|
@@ -3296,8 +3296,17 @@ function releaseDevLock(dotMastraPath) {
|
|
|
3296
3296
|
}
|
|
3297
3297
|
//#endregion
|
|
3298
3298
|
//#region src/commands/dev/DevBundler.ts
|
|
3299
|
-
|
|
3300
|
-
|
|
3299
|
+
/**
|
|
3300
|
+
* Files whose contents are inlined into the generated fs-agents module rather
|
|
3301
|
+
* than imported by it. Rollup can't see them through the module graph, so the
|
|
3302
|
+
* dev watcher has to register them explicitly or edits won't trigger a rebuild.
|
|
3303
|
+
*/
|
|
3304
|
+
function collectInlinedPaths(agents) {
|
|
3305
|
+
return agents.flatMap((agent) => [
|
|
3306
|
+
...agent.instructionsPath ? [agent.instructionsPath] : [],
|
|
3307
|
+
...(agent.schedules ?? []).flatMap((schedule) => schedule.kind === "markdown" ? [schedule.path] : []),
|
|
3308
|
+
...collectInlinedPaths(agent.subagents)
|
|
3309
|
+
]);
|
|
3301
3310
|
}
|
|
3302
3311
|
var DevBundler = class extends Bundler {
|
|
3303
3312
|
customEnvFile;
|
|
@@ -3376,7 +3385,7 @@ var DevBundler = class extends Bundler {
|
|
|
3376
3385
|
async buildStart() {
|
|
3377
3386
|
if (!fsRoutingWatchOptions?.preparedEntry.moduleSource) return;
|
|
3378
3387
|
const agents = await discoverFsAgents(fsRoutingWatchOptions.mastraDir);
|
|
3379
|
-
for (const
|
|
3388
|
+
for (const inlinedPath of collectInlinedPaths(agents)) this.addWatchFile(resolve(inlinedPath));
|
|
3380
3389
|
const nextEntry = await prepareFsAgentsEntry(fsRoutingWatchOptions.mastraDir, fsRoutingWatchOptions.userEntryFile, fsRoutingWatchOptions.outputDirectory);
|
|
3381
3390
|
if (nextEntry.moduleSource !== lastFsAgentsModuleSource) {
|
|
3382
3391
|
await writeFsAgentsEntry(nextEntry);
|