@mastra/deployer 1.48.0-alpha.6 → 1.48.0-alpha.7

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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @mastra/deployer
2
2
 
3
+ ## 1.48.0-alpha.7
4
+
5
+ ### Minor Changes
6
+
7
+ - You can now define agents by file convention instead of registering each one in code: drop a directory under `src/mastra/agents/<name>/`, run a Mastra build/dev, and the agent is bundled and registered onto your Mastra instance automatically. A directory becomes an agent when it has a `config.ts` or `instructions.md`; `tools/*.ts` add tools, `skills/` add skills (a `createSkill()` module, a packaged `SKILL.md` with its `references/`, or a flat `<skill>.md`), and `subagents/<childId>/` (one level deep) add delegatable subagents. Each agent gets a default workspace unless `workspace.ts` / `config.workspace` overrides it, and files committed under `agents/<name>/workspace/` are mirrored into the bundle to seed that workspace at runtime. Projects with no file-based agents are unaffected — the original entry is used unchanged. ([#18609](https://github.com/mastra-ai/mastra/pull/18609))
8
+
9
+ ```text
10
+ src/mastra/agents/weather/
11
+ config.ts # export default agentConfig({ model: 'openai/gpt-4o' })
12
+ instructions.md
13
+ tools/get_weather.ts
14
+ workspace/cities.json # mirrored into the agent's workspace
15
+ ```
16
+
17
+ ### Patch Changes
18
+
19
+ - Fix `ENOENT: .mastra-fs-agents-entry.mjs` when running `mastra dev`/`mastra build` in a project that uses file-based agents. The generated fs-agents wrapper entry was written before `bundler.prepare()` emptied the output directory, so it was wiped before the bundler could read it. Wrapper generation is now split: `prepareFsAgentsEntry` returns the generated source without writing, and the new `writeFsAgentsEntry` writes it after `prepare()` runs. ([#18694](https://github.com/mastra-ai/mastra/pull/18694))
20
+
21
+ ```ts
22
+ const fsAgents = await prepareFsAgentsEntry({ entryFile, mastraDir, outputDirectory });
23
+ await bundler.prepare(outputDirectory); // empties output dir
24
+ await writeFsAgentsEntry(fsAgents); // wrapper now survives for the bundler
25
+ ```
26
+
27
+ - Updated dependencies [[`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c)]:
28
+ - @mastra/core@1.48.0-alpha.7
29
+ - @mastra/server@1.48.0-alpha.7
30
+
3
31
  ## 1.48.0-alpha.6
4
32
 
5
33
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ import type { DiscoveredFsAgent } from './discover.js';
2
+ /**
3
+ * Generate the source of a wrapper module that:
4
+ * 1. imports the user's real Mastra entry,
5
+ * 2. imports each discovered `config.ts`, `tools/*.ts`, and `skills/*.ts`
6
+ * (`createSkill(...)` modules), inlining packaged `SKILL.md` skills,
7
+ * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any
8
+ * declared `subagents/` into the parent (one level deep),
9
+ * 4. registers them onto the user's `mastra` instance (code-registered agents
10
+ * win on name collisions), and
11
+ * 5. re-exports everything from the user's entry so this module is a drop-in
12
+ * replacement for the original `#mastra` target.
13
+ *
14
+ * `instructions.md` contents are inlined at codegen time so no markdown loader
15
+ * plugin is required in the bundler graph.
16
+ *
17
+ * @param userEntry slash-normalized absolute path to the user's mastra entry.
18
+ * @param agents discovered fs-routed agents (absolute, slash-normalized paths).
19
+ */
20
+ export declare function generateFsAgentsModule(userEntry: string, agents: DiscoveredFsAgent[]): Promise<string>;
21
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/codegen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoHpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAoD5G"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * A file-system routed agent directory discovered under `<mastraDir>/agents/`.
3
+ * All paths are absolute and slash-normalized so they can be embedded into
4
+ * generated module source on any platform.
5
+ */
6
+ export interface DiscoveredFsAgent {
7
+ /** Agent directory name. Used as the default `id`/`name`. */
8
+ name: string;
9
+ /** Absolute, slash-normalized path to the agent directory. */
10
+ dir: string;
11
+ /** Absolute path to `config.ts`/`config.js`, if present. */
12
+ configPath?: string;
13
+ /** Absolute path to `instructions.md`, if present. */
14
+ instructionsPath?: string;
15
+ /** Absolute path to `workspace.ts`/`workspace.js`, if present. */
16
+ workspacePath?: string;
17
+ /**
18
+ * Absolute, slash-normalized path to an authored `workspace/` directory of
19
+ * seed files, if present. These are mirrored into the deployed workspace at
20
+ * build time (Eve parity) so the agent starts with them on disk.
21
+ */
22
+ workspaceSeedDir?: string;
23
+ /** Tools discovered under `tools/`, in stable (sorted) order. */
24
+ tools: {
25
+ key: string;
26
+ path: string;
27
+ }[];
28
+ /** Skills discovered under `skills/`, in stable (sorted) order. */
29
+ skills: DiscoveredFsSkill[];
30
+ /**
31
+ * Declared subagents discovered under `subagents/`, in stable (sorted) order.
32
+ * Subagents are one level deep only: a discovered subagent never carries its
33
+ * own `subagents` (nested `subagents/` directories are ignored with a warning).
34
+ */
35
+ subagents: DiscoveredFsAgent[];
36
+ }
37
+ /**
38
+ * A skill discovered under `agents/<name>/skills/`.
39
+ *
40
+ * - `kind: 'module'` — a `.ts`/`.js` file whose default export is a `createSkill(...)`
41
+ * result. Codegen imports it directly; `name`/`description`/`instructions` are
42
+ * unknown at discovery time and resolved at runtime from the module.
43
+ * - `kind: 'packaged'` — a `SKILL.md` (optionally with a `references/` subdir) or a
44
+ * flat `<skill>.md`. Codegen inlines it via `createSkill(...)` using the parsed
45
+ * fields below so the deployed bundle carries no filesystem dependency.
46
+ */
47
+ export type DiscoveredFsSkill = {
48
+ kind: 'module';
49
+ /** Absolute, slash-normalized path to the `.ts`/`.js` skill module. */
50
+ path: string;
51
+ } | {
52
+ kind: 'packaged';
53
+ name: string;
54
+ description: string;
55
+ instructions: string;
56
+ /** Reference file contents keyed by relative path (from `references/`). */
57
+ references: Record<string, string>;
58
+ };
59
+ /**
60
+ * Scan `<mastraDir>/agents/*` for file-system routed agents. A directory is
61
+ * treated as an agent only when it contains a `config.(ts|js)` or an
62
+ * `instructions.md`; other directories are ignored. Each top-level agent may
63
+ * declare one level of `subagents/`. Returns descriptors with absolute,
64
+ * slash-normalized paths ready for codegen. Performs no module evaluation —
65
+ * only filesystem inspection.
66
+ */
67
+ export declare function discoverFsAgents(mastraDir: string, onWarn?: (message: string) => void): Promise<DiscoveredFsAgent[]>;
68
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/discover.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,mEAAmE;IACnE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B;;;;OAIG;IACH,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAyRN;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACjC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA0B9B"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Mirror authored `agents/<name>/workspace/**` seed files into the bundled
3
+ * output so each fs-routed agent starts with them on disk (Eve parity). Files
4
+ * are copied to `<bundleDir>/workspace/<name>`, which is exactly where the
5
+ * generated entry roots each agent's default workspace at runtime (resolved
6
+ * relative to the bundled module via `import.meta.url`). Declared subagents
7
+ * mirror to the nested `<bundleDir>/workspace/<parent>/<child>` path.
8
+ *
9
+ * Must run AFTER the bundle step, since bundling recreates the output dir.
10
+ *
11
+ * @param mastraDir The user's `src/mastra` directory (source of seeds).
12
+ * @param bundleDir The final bundle directory (e.g. `<outputDirectory>/output`).
13
+ * @returns the workspace names whose seeds were mirrored (`<parent>/<child>` for subagents).
14
+ */
15
+ export declare function mirrorFsAgentWorkspaces(mastraDir: string, bundleDir: string): Promise<string[]>;
16
+ //# sourceMappingURL=mirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirror.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/mirror.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CASrG"}
@@ -0,0 +1,44 @@
1
+ export interface PrepareFsAgentsEntryResult {
2
+ /**
3
+ * The entry file that should be fed to the bundler/analyzer. When fs-routed
4
+ * agents are found this is a generated wrapper module that registers them onto
5
+ * the user's mastra instance; otherwise it is the original entry unchanged.
6
+ */
7
+ entryFile: string;
8
+ /**
9
+ * Glob tool paths for tools defined under `agents/*\/tools` so they are
10
+ * bundled alongside the top-level `tools/` directory.
11
+ */
12
+ toolPaths: string[];
13
+ /** Number of fs-routed agents discovered. */
14
+ agentCount: number;
15
+ /**
16
+ * Generated wrapper source to write to {@link entryFile}, or `undefined` when
17
+ * there are no fs-routed agents. The write is deferred so callers can run it
18
+ * *after* `bundler.prepare()` empties the output directory — otherwise the
19
+ * wrapper is wiped before the bundler reads it.
20
+ */
21
+ moduleSource?: string;
22
+ }
23
+ /**
24
+ * Discover fs-routed agents under `<mastraDir>/agents/*` and, if any exist,
25
+ * generate a wrapper entry module that registers them onto the user's mastra
26
+ * instance. Returns the entry the bundler should use plus extra tool glob paths
27
+ * so `agents/*\/tools` are bundled.
28
+ *
29
+ * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with
30
+ * the result after `bundler.prepare()` so the generated file is not wiped when
31
+ * the output directory is emptied.
32
+ *
33
+ * When no fs-routed agents are present the original entry is returned unchanged,
34
+ * so existing code-only projects are completely unaffected.
35
+ */
36
+ export declare function prepareFsAgentsEntry(mastraDir: string, entryFile: string, outputDirectory: string): Promise<PrepareFsAgentsEntryResult>;
37
+ /**
38
+ * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}
39
+ * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER
40
+ * `bundler.prepare()` (which empties the output directory) so the wrapper
41
+ * survives for the bundler/watcher to read.
42
+ */
43
+ export declare function writeFsAgentsEntry(result: PrepareFsAgentsEntryResult): Promise<void>;
44
+ //# sourceMappingURL=prepare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/prepare.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,0BAA0B,CAAC,CAkBrC;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1F"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkY476PH5A_cjs = require('../chunk-Y476PH5A.cjs');
3
+ var chunkZZHJNINJ_cjs = require('../chunk-ZZHJNINJ.cjs');
4
4
  var chunkVZYB4EVX_cjs = require('../chunk-VZYB4EVX.cjs');
5
5
  var chunk47KJ3RKB_cjs = require('../chunk-47KJ3RKB.cjs');
6
6
  var chunkFBL7GBNM_cjs = require('../chunk-FBL7GBNM.cjs');
@@ -11,15 +11,35 @@ var chunk7PMC7SBC_cjs = require('../chunk-7PMC7SBC.cjs');
11
11
 
12
12
  Object.defineProperty(exports, "createWatcher", {
13
13
  enumerable: true,
14
- get: function () { return chunkY476PH5A_cjs.createWatcher; }
14
+ get: function () { return chunkZZHJNINJ_cjs.createWatcher; }
15
+ });
16
+ Object.defineProperty(exports, "discoverFsAgents", {
17
+ enumerable: true,
18
+ get: function () { return chunkZZHJNINJ_cjs.discoverFsAgents; }
19
+ });
20
+ Object.defineProperty(exports, "generateFsAgentsModule", {
21
+ enumerable: true,
22
+ get: function () { return chunkZZHJNINJ_cjs.generateFsAgentsModule; }
15
23
  });
16
24
  Object.defineProperty(exports, "getServerOptions", {
17
25
  enumerable: true,
18
- get: function () { return chunkY476PH5A_cjs.getServerOptions; }
26
+ get: function () { return chunkZZHJNINJ_cjs.getServerOptions; }
19
27
  });
20
28
  Object.defineProperty(exports, "getWatcherInputOptions", {
21
29
  enumerable: true,
22
- get: function () { return chunkY476PH5A_cjs.getInputOptions; }
30
+ get: function () { return chunkZZHJNINJ_cjs.getInputOptions; }
31
+ });
32
+ Object.defineProperty(exports, "mirrorFsAgentWorkspaces", {
33
+ enumerable: true,
34
+ get: function () { return chunkZZHJNINJ_cjs.mirrorFsAgentWorkspaces; }
35
+ });
36
+ Object.defineProperty(exports, "prepareFsAgentsEntry", {
37
+ enumerable: true,
38
+ get: function () { return chunkZZHJNINJ_cjs.prepareFsAgentsEntry; }
39
+ });
40
+ Object.defineProperty(exports, "writeFsAgentsEntry", {
41
+ enumerable: true,
42
+ get: function () { return chunkZZHJNINJ_cjs.writeFsAgentsEntry; }
23
43
  });
24
44
  Object.defineProperty(exports, "getBundlerOptions", {
25
45
  enumerable: true,
@@ -7,4 +7,10 @@ export { getServerOptions } from './serverOptions.js';
7
7
  export { getBundlerOptions } from './bundlerOptions.js';
8
8
  export { normalizeStudioBase, detectRuntime, injectStudioHtmlConfig } from './utils.js';
9
9
  export type { RuntimePlatform, BundlerPlatform, StudioInjectionConfig } from './utils.js';
10
+ export { discoverFsAgents } from './fs-routing/discover.js';
11
+ export type { DiscoveredFsAgent } from './fs-routing/discover.js';
12
+ export { generateFsAgentsModule } from './fs-routing/codegen.js';
13
+ export { prepareFsAgentsEntry, writeFsAgentsEntry } from './fs-routing/prepare.js';
14
+ export type { PrepareFsAgentsEntryResult } from './fs-routing/prepare.js';
15
+ export { mirrorFsAgentWorkspaces } from './fs-routing/mirror.js';
10
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACrF,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACrF,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChF,YAAY,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-EVWJBGLA.js';
1
+ export { createWatcher, discoverFsAgents, generateFsAgentsModule, getServerOptions, getInputOptions as getWatcherInputOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry } from '../chunk-YLUHJBYA.js';
2
2
  export { getBundlerOptions } from '../chunk-MPEFRVWJ.js';
3
3
  export { analyzeBundle } from '../chunk-FQC6UUHS.js';
4
4
  export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-2WEUOK6I.js';