@mastra/deployer 1.50.0-alpha.1 → 1.50.0-alpha.2

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,24 @@
1
1
  # @mastra/deployer
2
2
 
3
+ ## 1.50.0-alpha.2
4
+
5
+ ### Minor Changes
6
+
7
+ - Added file-system-routed workflows support. Workflows placed in `workflows/*.ts` under the mastra directory are now auto-discovered and registered during `mastra dev` / `mastra build`, matching the existing file-based agents convention. Code-registered workflows win on name collisions. ([#18883](https://github.com/mastra-ai/mastra/pull/18883))
8
+
9
+ ```ts
10
+ // src/mastra/workflows/onboarding.ts
11
+ import { createWorkflow } from '@mastra/core/workflows';
12
+
13
+ export default createWorkflow({ id: 'onboarding' /* ...steps */ });
14
+ ```
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`a51c63d`](https://github.com/mastra-ai/mastra/commit/a51c63d8ee639e4daeba2a0be093efa6a1b5e52f), [`02705fd`](https://github.com/mastra-ai/mastra/commit/02705fd2f5a9062210d64ea061adeeb10dc9452e)]:
19
+ - @mastra/core@1.50.0-alpha.2
20
+ - @mastra/server@1.50.0-alpha.2
21
+
3
22
  ## 1.50.0-alpha.1
4
23
 
5
24
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { DiscoveredFsAgent } from './discover.js';
1
+ import type { DiscoveredFsAgent, DiscoveredFsWorkflow } from './discover.js';
2
2
  /**
3
3
  * Generate the source of a wrapper module that:
4
4
  * 1. imports the user's real Mastra entry,
@@ -18,5 +18,19 @@ import type { DiscoveredFsAgent } from './discover.js';
18
18
  * @param userEntry slash-normalized absolute path to the user's mastra entry.
19
19
  * @param agents discovered fs-routed agents (absolute, slash-normalized paths).
20
20
  */
21
- export declare function generateFsAgentsModule(userEntry: string, agents: DiscoveredFsAgent[]): Promise<string>;
21
+ export declare function generateFsAgentsModule(userEntry: string, agents: DiscoveredFsAgent[], options?: {
22
+ workflows?: DiscoveredFsWorkflow[];
23
+ }): Promise<string>;
24
+ /**
25
+ * Generate the workflow-registration lines to splice into the generated wrapper
26
+ * module. Emits import statements for each discovered workflow module and a
27
+ * registration block that calls `__registerFsWorkflows` on the user's mastra.
28
+ *
29
+ * Returns `{ importLines, registrationLines }` so the caller can place them at
30
+ * the correct positions in the wrapper source.
31
+ */
32
+ export declare function generateFsWorkflowsCodegen(workflows: DiscoveredFsWorkflow[]): {
33
+ importLines: string[];
34
+ registrationLines: string[];
35
+ };
22
36
  //# sourceMappingURL=codegen.d.ts.map
@@ -1 +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;AA0HpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAoD5G"}
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/codegen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0H1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,iBAAiB,EAAE,EAC3B,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAAE,GAC/C,OAAO,CAAC,MAAM,CAAC,CAwEjB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,oBAAoB,EAAE,GAAG;IAC7E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAsBA"}
@@ -68,4 +68,24 @@ export type DiscoveredFsSkill = {
68
68
  * evaluation — only filesystem inspection.
69
69
  */
70
70
  export declare function discoverFsAgents(mastraDir: string, onWarn?: (message: string) => void): Promise<DiscoveredFsAgent[]>;
71
+ /**
72
+ * A file-system routed workflow file discovered under `<mastraDir>/workflows/`.
73
+ * All paths are absolute and slash-normalized so they can be embedded into
74
+ * generated module source on any platform.
75
+ */
76
+ export interface DiscoveredFsWorkflow {
77
+ /** Workflow key derived from the filename (without extension). */
78
+ key: string;
79
+ /** Absolute, slash-normalized path to the workflow module. */
80
+ path: string;
81
+ }
82
+ /**
83
+ * Scan `<mastraDir>/workflows/` for file-system routed workflow modules. Only
84
+ * files whose source contains an `export default` are treated as fs-routed
85
+ * workflows — this convention distinguishes them from workflow files that are
86
+ * manually imported and registered programmatically. Returns descriptors with
87
+ * absolute, slash-normalized paths ready for codegen. Performs no module
88
+ * evaluation — only filesystem and source-text inspection.
89
+ */
90
+ export declare function discoverFsWorkflows(mastraDir: string): Promise<DiscoveredFsWorkflow[]>;
71
91
  //# sourceMappingURL=discover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/discover.ts"],"names":[],"mappings":"AAMA;;;;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,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAA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,CAAC;IACvC,mEAAmE;IACnE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B;;;;;OAKG;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;AA4RN;;;;;;;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;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAoC5F"}
@@ -1,8 +1,9 @@
1
1
  export interface PrepareFsAgentsEntryResult {
2
2
  /**
3
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.
4
+ * primitives (agents, workflows) are found this is a generated wrapper module
5
+ * that registers them onto the user's mastra instance; otherwise it is the
6
+ * original entry unchanged.
6
7
  */
7
8
  entryFile: string;
8
9
  /**
@@ -12,26 +13,28 @@ export interface PrepareFsAgentsEntryResult {
12
13
  toolPaths: string[];
13
14
  /** Number of fs-routed agents discovered. */
14
15
  agentCount: number;
16
+ /** Number of fs-routed workflows discovered. */
17
+ workflowCount: number;
15
18
  /**
16
19
  * 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
20
+ * there are no fs-routed primitives. The write is deferred so callers can run
21
+ * it *after* `bundler.prepare()` empties the output directory — otherwise the
19
22
  * wrapper is wiped before the bundler reads it.
20
23
  */
21
24
  moduleSource?: string;
22
25
  }
23
26
  /**
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.
27
+ * Discover fs-routed agents under `<mastraDir>/agents/*` and workflows under
28
+ * `<mastraDir>/workflows/`. When any are found, generate a wrapper entry module
29
+ * that registers them onto the user's mastra instance. Returns the entry the
30
+ * bundler should use plus extra tool glob paths so `agents/*\/tools` are bundled.
28
31
  *
29
32
  * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with
30
33
  * the result after `bundler.prepare()` so the generated file is not wiped when
31
34
  * the output directory is emptied.
32
35
  *
33
- * When no fs-routed agents are present the original entry is returned unchanged,
34
- * so existing code-only projects are completely unaffected.
36
+ * When no fs-routed primitives are present the original entry is returned
37
+ * unchanged, so existing code-only projects are completely unaffected.
35
38
  */
36
39
  export declare function prepareFsAgentsEntry(mastraDir: string, entryFile: string, outputDirectory: string): Promise<PrepareFsAgentsEntryResult>;
37
40
  /**
@@ -1 +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
+ {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/prepare.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;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,CA2BrC;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 chunkYMYRP2K7_cjs = require('../chunk-YMYRP2K7.cjs');
3
+ var chunkXSAPBEYT_cjs = require('../chunk-XSAPBEYT.cjs');
4
4
  var chunkILNCPWNL_cjs = require('../chunk-ILNCPWNL.cjs');
5
5
  var chunkYWKYOGOS_cjs = require('../chunk-YWKYOGOS.cjs');
6
6
  var chunk2GJY6H6M_cjs = require('../chunk-2GJY6H6M.cjs');
@@ -11,35 +11,43 @@ var chunkJZRFRUGM_cjs = require('../chunk-JZRFRUGM.cjs');
11
11
 
12
12
  Object.defineProperty(exports, "createWatcher", {
13
13
  enumerable: true,
14
- get: function () { return chunkYMYRP2K7_cjs.createWatcher; }
14
+ get: function () { return chunkXSAPBEYT_cjs.createWatcher; }
15
15
  });
16
16
  Object.defineProperty(exports, "discoverFsAgents", {
17
17
  enumerable: true,
18
- get: function () { return chunkYMYRP2K7_cjs.discoverFsAgents; }
18
+ get: function () { return chunkXSAPBEYT_cjs.discoverFsAgents; }
19
+ });
20
+ Object.defineProperty(exports, "discoverFsWorkflows", {
21
+ enumerable: true,
22
+ get: function () { return chunkXSAPBEYT_cjs.discoverFsWorkflows; }
19
23
  });
20
24
  Object.defineProperty(exports, "generateFsAgentsModule", {
21
25
  enumerable: true,
22
- get: function () { return chunkYMYRP2K7_cjs.generateFsAgentsModule; }
26
+ get: function () { return chunkXSAPBEYT_cjs.generateFsAgentsModule; }
27
+ });
28
+ Object.defineProperty(exports, "generateFsWorkflowsCodegen", {
29
+ enumerable: true,
30
+ get: function () { return chunkXSAPBEYT_cjs.generateFsWorkflowsCodegen; }
23
31
  });
24
32
  Object.defineProperty(exports, "getServerOptions", {
25
33
  enumerable: true,
26
- get: function () { return chunkYMYRP2K7_cjs.getServerOptions; }
34
+ get: function () { return chunkXSAPBEYT_cjs.getServerOptions; }
27
35
  });
28
36
  Object.defineProperty(exports, "getWatcherInputOptions", {
29
37
  enumerable: true,
30
- get: function () { return chunkYMYRP2K7_cjs.getInputOptions; }
38
+ get: function () { return chunkXSAPBEYT_cjs.getInputOptions; }
31
39
  });
32
40
  Object.defineProperty(exports, "mirrorFsAgentWorkspaces", {
33
41
  enumerable: true,
34
- get: function () { return chunkYMYRP2K7_cjs.mirrorFsAgentWorkspaces; }
42
+ get: function () { return chunkXSAPBEYT_cjs.mirrorFsAgentWorkspaces; }
35
43
  });
36
44
  Object.defineProperty(exports, "prepareFsAgentsEntry", {
37
45
  enumerable: true,
38
- get: function () { return chunkYMYRP2K7_cjs.prepareFsAgentsEntry; }
46
+ get: function () { return chunkXSAPBEYT_cjs.prepareFsAgentsEntry; }
39
47
  });
40
48
  Object.defineProperty(exports, "writeFsAgentsEntry", {
41
49
  enumerable: true,
42
- get: function () { return chunkYMYRP2K7_cjs.writeFsAgentsEntry; }
50
+ get: function () { return chunkXSAPBEYT_cjs.writeFsAgentsEntry; }
43
51
  });
44
52
  Object.defineProperty(exports, "getBundlerOptions", {
45
53
  enumerable: true,
@@ -7,9 +7,9 @@ export { getServerOptions } from './serverOptions.js';
7
7
  export { getBundlerOptions } from './bundlerOptions.js';
8
8
  export { normalizeStudioBase, detectRuntime, injectStudioHtmlConfig, escapeStudioHtmlValue } 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';
10
+ export { discoverFsAgents, discoverFsWorkflows } from './fs-routing/discover.js';
11
+ export type { DiscoveredFsAgent, DiscoveredFsWorkflow } from './fs-routing/discover.js';
12
+ export { generateFsAgentsModule, generateFsWorkflowsCodegen } from './fs-routing/codegen.js';
13
13
  export { prepareFsAgentsEntry, writeFsAgentsEntry } from './fs-routing/prepare.js';
14
14
  export type { PrepareFsAgentsEntryResult } from './fs-routing/prepare.js';
15
15
  export { mirrorFsAgentWorkspaces } from './fs-routing/mirror.js';
@@ -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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a,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5G,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC1F,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, discoverFsAgents, generateFsAgentsModule, getServerOptions, getInputOptions as getWatcherInputOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry } from '../chunk-THSS3CYX.js';
1
+ export { createWatcher, discoverFsAgents, discoverFsWorkflows, generateFsAgentsModule, generateFsWorkflowsCodegen, getServerOptions, getInputOptions as getWatcherInputOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry } from '../chunk-UBCDMTQL.js';
2
2
  export { getBundlerOptions } from '../chunk-UA2DJWFT.js';
3
3
  export { analyzeBundle } from '../chunk-LJBNHINW.js';
4
4
  export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-6ARGMWNC.js';
@@ -6,7 +6,7 @@ import { dirname, posix, join } from 'path';
6
6
  import { noopLogger } from '@mastra/core/logger';
7
7
  import * as pkg from 'empathic/package';
8
8
  import { watch } from 'rollup';
9
- import { readdir, mkdir, writeFile, lstat, readFile, cp } from 'fs/promises';
9
+ import { readdir, lstat, readFile, mkdir, writeFile, cp } from 'fs/promises';
10
10
  import { MAX_FS_SUBAGENT_DEPTH } from '@mastra/core/agent';
11
11
  import matter from 'gray-matter';
12
12
 
@@ -316,6 +316,38 @@ async function discoverFsAgents(mastraDir, onWarn) {
316
316
  }
317
317
  return discovered;
318
318
  }
319
+ async function discoverFsWorkflows(mastraDir) {
320
+ const workflowsDir = join(mastraDir, "workflows");
321
+ if (!await exists(workflowsDir)) {
322
+ return [];
323
+ }
324
+ let entries;
325
+ try {
326
+ entries = await readdir(workflowsDir);
327
+ } catch {
328
+ return [];
329
+ }
330
+ const discovered = [];
331
+ for (const basename of entries.sort()) {
332
+ if (isTestFile(basename)) {
333
+ continue;
334
+ }
335
+ if (!TOOL_EXTENSIONS.some((ext) => basename.endsWith(ext))) {
336
+ continue;
337
+ }
338
+ const path = join(workflowsDir, basename);
339
+ const stats = await lstat(path);
340
+ if (stats.isSymbolicLink() || stats.isDirectory()) {
341
+ continue;
342
+ }
343
+ const source = await readFile(path, "utf-8");
344
+ if (!/\bexport\s+default\b/.test(source)) {
345
+ continue;
346
+ }
347
+ discovered.push({ key: toolKey(basename), path: slash(path) });
348
+ }
349
+ return discovered;
350
+ }
319
351
  function sanitizeIdentifier(name, prefix, index) {
320
352
  const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, "_");
321
353
  return `${prefix}_${index}_${cleaned}`;
@@ -401,7 +433,8 @@ async function emitAgentEntry(agent, idPath, workspaceName, lines) {
401
433
  entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);
402
434
  return `{ ${entryFields.join(", ")} }`;
403
435
  }
404
- async function generateFsAgentsModule(userEntry, agents) {
436
+ async function generateFsAgentsModule(userEntry, agents, options) {
437
+ const workflows = options?.workflows ?? [];
405
438
  const lines = [];
406
439
  const hasInlineSkills = (function check(list) {
407
440
  return list.some((a) => (a.skills ?? []).some((s) => s.kind === "packaged") || check(a.subagents ?? []));
@@ -418,6 +451,13 @@ async function generateFsAgentsModule(userEntry, agents) {
418
451
  lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);
419
452
  lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);
420
453
  lines.push(``);
454
+ const wfCodegen = workflows.length > 0 ? generateFsWorkflowsCodegen(workflows) : void 0;
455
+ if (wfCodegen) {
456
+ for (const line of wfCodegen.importLines) {
457
+ lines.push(line);
458
+ }
459
+ lines.push(``);
460
+ }
421
461
  const entryExprs = [];
422
462
  for (let i = 0; i < agents.length; i++) {
423
463
  const agent = agents[i];
@@ -441,24 +481,56 @@ async function generateFsAgentsModule(userEntry, agents) {
441
481
  lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);
442
482
  lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);
443
483
  lines.push(`}`);
484
+ if (wfCodegen) {
485
+ lines.push(``);
486
+ for (const line of wfCodegen.registrationLines) {
487
+ lines.push(line);
488
+ }
489
+ }
444
490
  lines.push(``);
445
491
  lines.push(`export const mastra = __userEntry.mastra;`);
446
492
  return lines.join("\n");
447
493
  }
494
+ function generateFsWorkflowsCodegen(workflows) {
495
+ const importLines = [];
496
+ const registrationLines = [];
497
+ for (let i = 0; i < workflows.length; i++) {
498
+ const wf = workflows[i];
499
+ const ident = sanitizeIdentifier(wf.key, "workflow", `${i}`);
500
+ importLines.push(`import ${ident} from ${JSON.stringify(wf.path)};`);
501
+ }
502
+ registrationLines.push(`const __fsWorkflows = Object.create(null);`);
503
+ for (let i = 0; i < workflows.length; i++) {
504
+ const wf = workflows[i];
505
+ const ident = sanitizeIdentifier(wf.key, "workflow", `${i}`);
506
+ registrationLines.push(`__fsWorkflows[${JSON.stringify(wf.key)}] = ${ident};`);
507
+ }
508
+ registrationLines.push(``);
509
+ registrationLines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsWorkflows === 'function') {`);
510
+ registrationLines.push(` __userEntry.mastra.__registerFsWorkflows(__fsWorkflows);`);
511
+ registrationLines.push(`}`);
512
+ return { importLines, registrationLines };
513
+ }
448
514
  async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
449
- const agents = await discoverFsAgents(mastraDir);
450
- if (agents.length === 0) {
451
- return { entryFile, toolPaths: [], agentCount: 0 };
515
+ const [agents, workflows] = await Promise.all([discoverFsAgents(mastraDir), discoverFsWorkflows(mastraDir)]);
516
+ if (agents.length === 0 && workflows.length === 0) {
517
+ return { entryFile, toolPaths: [], agentCount: 0, workflowCount: 0 };
452
518
  }
453
- const moduleSource = await generateFsAgentsModule(slash(entryFile), agents);
519
+ const moduleSource = await generateFsAgentsModule(slash(entryFile), agents, { workflows });
454
520
  const generatedEntry = join(outputDirectory, ".mastra-fs-agents-entry.mjs");
455
521
  const normalizedMastraDir = slash(mastraDir);
456
- const toolPaths = [
522
+ const toolPaths = agents.length > 0 ? [
457
523
  posix.join(normalizedMastraDir, "agents/*/tools/**/*.{js,ts}"),
458
524
  `!${posix.join(normalizedMastraDir, "agents/*/tools/**/*.{test,spec}.{js,ts}")}`,
459
525
  `!${posix.join(normalizedMastraDir, "agents/*/tools/**/__tests__/**")}`
460
- ];
461
- return { entryFile: generatedEntry, toolPaths, agentCount: agents.length, moduleSource };
526
+ ] : [];
527
+ return {
528
+ entryFile: generatedEntry,
529
+ toolPaths,
530
+ agentCount: agents.length,
531
+ workflowCount: workflows.length,
532
+ moduleSource
533
+ };
462
534
  }
463
535
  async function writeFsAgentsEntry(result) {
464
536
  if (!result.moduleSource) {
@@ -491,6 +563,6 @@ async function mirrorFsAgentWorkspaces(mastraDir, bundleDir) {
491
563
  return mirrored;
492
564
  }
493
565
 
494
- export { createWatcher, discoverFsAgents, generateFsAgentsModule, getInputOptions2 as getInputOptions, getServerOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry };
495
- //# sourceMappingURL=chunk-THSS3CYX.js.map
496
- //# sourceMappingURL=chunk-THSS3CYX.js.map
566
+ export { createWatcher, discoverFsAgents, discoverFsWorkflows, generateFsAgentsModule, generateFsWorkflowsCodegen, getInputOptions2 as getInputOptions, getServerOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry };
567
+ //# sourceMappingURL=chunk-UBCDMTQL.js.map
568
+ //# sourceMappingURL=chunk-UBCDMTQL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/watcher.ts","../src/build/serverOptions.ts","../src/build/fs-routing/discover.ts","../src/build/fs-routing/codegen.ts","../src/build/fs-routing/prepare.ts","../src/build/fs-routing/mirror.ts"],"names":["getInputOptions","readFile","join","posix","dirname","lstat","mkdir"],"mappings":";;;;;;;;;;;;AAeA,eAAsBA,gBAAAA,CACpB,SAAA,EACA,QAAA,EACA,GAAA,EACA;AAAA,EACE,SAAA,GAAY,KAAA;AAAA,EACZ,cAAA,GAAiB;AAAA,IACf,eAAA,EAAiB,KAAA;AAAA,IACjB,aAAA,EAAe,IAAA;AAAA,IACf,SAAA,EAAW;AAAA,GACb;AAAA,EACA,eAAA,GAAkB,CAAC,SAAS;AAC9B,CAAA,GAA0F,EAAC,EAC3F;AACA,EAAA,MAAM,iBAAqB,GAAA,CAAA,EAAA,CAAG,EAAE,KAAK,OAAA,CAAQ,SAAS,GAAG,CAAA;AACzD,EAAA,MAAM,WAAA,GAAc,cAAA,GAAiB,OAAA,CAAQ,KAAA,CAAM,cAAc,CAAC,CAAA,GAAI,KAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,CAAA;AACzF,EAAA,MAAM,EAAE,cAAc,aAAA,EAAc,GAAI,MAAM,uBAAA,CAAwB,EAAE,eAAA,EAAiB,SAAA,EAAW,CAAA;AAEpG,EAAA,MAAM,qBAAqB,MAAM,aAAA;AAAA,IAC/B,eAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,MACE,WAAW,KAAA,CAAM,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,WAAW,QAAQ,CAAA;AAAA,MACxD,WAAA,EAAa,aAAA,IAAiB,OAAA,CAAQ,GAAA,EAAI;AAAA,MAC1C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AAA,IAAS,KAAA,CAAM,SAAA,IAAa,EAAC,EAAG;AACzC,IAAA,MAAM,gBAAA,CAAiB,OAAO,CAAA,EAAG,aAAa,IAAI,KAAA,CAAM,IAAI,CAAA,CAAA,EAAI,SAAA,EAAW,QAAQ,CAAA;AAAA,EACrF;AACF;AAgBA,eAAsB,uBAAA,CAAwB,WAAmB,SAAA,EAAsC;AACrG,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,CAAiB,SAAS,CAAA;AAC/C,EAAA,MAAM,WAAqB,EAAC;AAE5B,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,MAAM,gBAAA,CAAiB,KAAA,EAAO,KAAA,CAAM,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,EAC/D;AAEA,EAAA,OAAO,QAAA;AACT","file":"chunk-UBCDMTQL.js","sourcesContent":["import { dirname, posix } from 'node:path';\nimport { noopLogger } from '@mastra/core/logger';\nimport * as pkg from 'empathic/package';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport { watch } from 'rollup';\nimport { getWorkspaceInformation } from '../bundler/workspaceDependencies';\nimport { analyzeBundle } from './analyze';\nimport { getInputOptions as getBundlerInputOptions } from './bundler';\nimport { aliasHono } from './plugins/hono-alias';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport type { BundlerOptions } from './types';\nimport { getPackageName, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n platform: BundlerPlatform,\n env?: Record<string, string>,\n {\n sourcemap = false,\n bundlerOptions = {\n enableSourcemap: false,\n enableEsmShim: true,\n externals: true,\n },\n analysisEntries = [entryFile],\n }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions; analysisEntries?: string[] } = {},\n) {\n const closestPkgJson = pkg.up({ cwd: dirname(entryFile) });\n const projectRoot = closestPkgJson ? dirname(slash(closestPkgJson)) : slash(process.cwd());\n const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: entryFile });\n\n const analyzeEntryResult = await analyzeBundle(\n analysisEntries,\n entryFile,\n {\n outputDir: posix.join(process.cwd(), '.mastra', '.build'),\n projectRoot: workspaceRoot || process.cwd(),\n platform,\n isDev: true,\n bundlerOptions,\n },\n noopLogger,\n );\n\n const deps = /* @__PURE__ */ new Map();\n for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {\n const pkgName = getPackageName(dep);\n if (pkgName && workspaceMap.has(pkgName)) {\n deps.set(dep, metadata);\n }\n }\n\n const inputOptions = await getBundlerInputOptions(\n entryFile,\n {\n dependencies: deps,\n externalDependencies: new Map(),\n workspaceMap,\n },\n platform,\n env,\n { sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true },\n );\n\n if (Array.isArray(inputOptions.plugins)) {\n // filter out node-resolve plugin so all node_modules are external\n // and tsconfig-paths plugin as we are injection a custom one\n const plugins = [] as Plugin[];\n inputOptions.plugins.forEach(plugin => {\n if ((plugin as Plugin | undefined)?.name === 'node-resolve') {\n return;\n }\n\n if ((plugin as Plugin | undefined)?.name === 'tsconfig-paths') {\n plugins.push(\n tsConfigPaths({\n localResolve: true,\n }),\n );\n return;\n }\n\n plugins.push(plugin as Plugin);\n });\n\n inputOptions.plugins = plugins;\n inputOptions.plugins.push(aliasHono());\n // fixes imports like lodash/fp/get\n inputOptions.plugins.push(nodeModulesExtensionResolver());\n }\n\n return inputOptions;\n}\n\nexport async function createWatcher(inputOptions: InputOptions, outputOptions: OutputOptions) {\n const watcher = await watch({\n ...inputOptions,\n output: {\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n },\n });\n\n return watcher;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getServerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('server', entryFile, result);\n}\n\nexport async function getServerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['server'] | null> {\n const result = await extractMastraOption('server', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n","import { lstat, readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { MAX_FS_SUBAGENT_DEPTH } from '@mastra/core/agent';\nimport matter from 'gray-matter';\nimport { slash } from '../utils';\n\n/**\n * A file-system routed agent directory discovered under `<mastraDir>/agents/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsAgent {\n /** Agent directory name. Used as the default `id`/`name`. */\n name: string;\n /** Absolute, slash-normalized path to the agent directory. */\n dir: string;\n /** Absolute path to `config.ts`/`config.js`, if present. */\n configPath?: string;\n /** Absolute path to `instructions.md`, if present. */\n instructionsPath?: string;\n /** Absolute path to `workspace.ts`/`workspace.js`, if present. */\n workspacePath?: string;\n /** Absolute path to `memory.ts`/`memory.js`, if present. */\n memoryPath?: string;\n /**\n * Absolute, slash-normalized path to an authored `workspace/` directory of\n * seed files, if present. These are mirrored into the deployed workspace at\n * build time (Eve parity) so the agent starts with them on disk.\n */\n workspaceSeedDir?: string;\n /** Tools discovered under `tools/`, in stable (sorted) order. */\n tools: { key: string; path: string }[];\n /** Skills discovered under `skills/`, in stable (sorted) order. */\n skills: DiscoveredFsSkill[];\n /**\n * Declared subagents discovered under `subagents/`, in stable (sorted) order.\n * Subagents may declare their own `subagents/`, up to `MAX_FS_SUBAGENT_DEPTH`\n * levels below the top-level agent; deeper `subagents/` directories are\n * ignored with a warning.\n */\n subagents: DiscoveredFsAgent[];\n}\n\n/**\n * A skill discovered under `agents/<name>/skills/`.\n *\n * - `kind: 'module'` — a `.ts`/`.js` file whose default export is a `createSkill(...)`\n * result. Codegen imports it directly; `name`/`description`/`instructions` are\n * unknown at discovery time and resolved at runtime from the module.\n * - `kind: 'packaged'` — a `SKILL.md` (optionally with a `references/` subdir) or a\n * flat `<skill>.md`. Codegen inlines it via `createSkill(...)` using the parsed\n * fields below so the deployed bundle carries no filesystem dependency.\n */\nexport type DiscoveredFsSkill =\n | {\n kind: 'module';\n /** Absolute, slash-normalized path to the `.ts`/`.js` skill module. */\n path: string;\n }\n | {\n kind: 'packaged';\n name: string;\n description: string;\n instructions: string;\n /** Reference file contents keyed by relative path (from `references/`). */\n references: Record<string, string>;\n };\n\nconst CONFIG_BASENAMES = ['config.ts', 'config.js'];\nconst WORKSPACE_BASENAMES = ['workspace.ts', 'workspace.js'];\nconst MEMORY_BASENAMES = ['memory.ts', 'memory.js'];\nconst INSTRUCTIONS_BASENAME = 'instructions.md';\nconst TOOL_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MODULE_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MD_BASENAME = 'SKILL.md';\n\n/**\n * Presence check that does NOT follow symlinks. Returns `false` for symlinks\n * (and broken links) so a symlinked `config.ts`/`instructions.md`/`workspace.ts`/\n * `memory.ts` is never inlined or imported into the generated bundle.\n */\nasync function exists(path: string): Promise<boolean> {\n try {\n return !(await lstat(path)).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Returns the slash-normalized path when `path` is a real directory (not a\n * symlink). Symlinked directories are rejected to prevent the build from\n * following links out of the project tree during discovery.\n */\nasync function realDirectory(path: string): Promise<string | undefined> {\n try {\n const info = await lstat(path);\n if (info.isDirectory() && !info.isSymbolicLink()) {\n return slash(path);\n }\n } catch {\n // not present\n }\n return undefined;\n}\n\nasync function directoryExists(path: string): Promise<string | undefined> {\n return realDirectory(path);\n}\n\nasync function firstExisting(dir: string, basenames: string[]): Promise<string | undefined> {\n for (const basename of basenames) {\n const candidate = join(dir, basename);\n if (await exists(candidate)) {\n return slash(candidate);\n }\n }\n return undefined;\n}\n\nfunction isTestFile(basename: string): boolean {\n return /\\.(test|spec)\\.(ts|js)$/.test(basename);\n}\n\nfunction toolKey(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverTools(toolsDir: string): Promise<DiscoveredFsAgent['tools']> {\n if (!(await exists(toolsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(toolsDir);\n } catch {\n return [];\n }\n\n const tools: DiscoveredFsAgent['tools'] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(toolsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks and\n // directories: a symlinked tool file could point anywhere on the build\n // machine and be embedded into generated import code.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n tools.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return tools;\n}\n\nasync function readReferences(referencesDir: string): Promise<Record<string, string>> {\n if (!(await exists(referencesDir))) {\n return {};\n }\n const references: Record<string, string> = {};\n let entries: string[];\n try {\n entries = await readdir(referencesDir);\n } catch {\n return {};\n }\n for (const basename of entries.sort()) {\n const path = join(referencesDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlink under `references/` could point anywhere on the build machine and\n // silently embed arbitrary file contents into the generated bundle.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n references[basename] = await readFile(path, 'utf-8');\n }\n return references;\n}\n\nasync function parsePackagedSkill(\n skillMdPath: string,\n fallbackName: string,\n references: Record<string, string> = {},\n): Promise<Extract<DiscoveredFsSkill, { kind: 'packaged' }>> {\n const raw = await readFile(skillMdPath, 'utf-8');\n const parsed = matter(raw);\n const frontmatter = parsed.data as { name?: string; description?: string };\n const name = frontmatter.name ?? fallbackName;\n const description = frontmatter.description ?? '';\n const instructions = parsed.content.trim();\n return { kind: 'packaged', name, description, instructions, references };\n}\n\nfunction skillModuleName(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverSkills(skillsDir: string): Promise<DiscoveredFsSkill[]> {\n if (!(await exists(skillsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(skillsDir);\n } catch {\n return [];\n }\n\n const skills: DiscoveredFsSkill[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n const path = join(skillsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlinked skill module/markdown could point anywhere on the build machine\n // and be bundled or inlined into the generated output.\n const stats = await lstat(path);\n if (stats.isSymbolicLink()) {\n continue;\n }\n const isDir = stats.isDirectory();\n\n // Packaged skill directory: <skill>/SKILL.md (+ references/)\n if (isDir) {\n const skillMd = join(path, SKILL_MD_BASENAME);\n if (await exists(skillMd)) {\n const references = await readReferences(join(path, 'references'));\n skills.push(await parsePackagedSkill(skillMd, skillModuleName(basename), references));\n }\n continue;\n }\n\n // createSkill module: <skill>.ts | <skill>.js\n if (SKILL_MODULE_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n skills.push({ kind: 'module', path: slash(path) });\n continue;\n }\n\n // Flat markdown skill: <skill>.md\n if (basename.endsWith('.md')) {\n const skill = await parsePackagedSkill(path, basename.replace(/\\.md$/, ''));\n skills.push(skill);\n }\n }\n\n return skills;\n}\n\n/**\n * Discover a single agent directory: its `config`/`instructions`/`workspace`\n * files plus `tools/`, `skills/`, and declared `subagents/`. Returns\n * `undefined` when `dir` is not an agent directory (no `config.(ts|js)` and no\n * `instructions.md`).\n *\n * `depth` is the subagent nesting level (`0` for top-level agents). Discovery\n * recurses into `subagents/` until `MAX_FS_SUBAGENT_DEPTH`; deeper directories\n * are ignored with a warning.\n */\nasync function discoverAgentDir(\n dir: string,\n name: string,\n depth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent | undefined> {\n const configPath = await firstExisting(dir, CONFIG_BASENAMES);\n const instructionsPath = (await exists(join(dir, INSTRUCTIONS_BASENAME)))\n ? slash(join(dir, INSTRUCTIONS_BASENAME))\n : undefined;\n\n // Not an agent directory unless it has a config or instructions file.\n if (!configPath && !instructionsPath) {\n return undefined;\n }\n\n const workspacePath = await firstExisting(dir, WORKSPACE_BASENAMES);\n const memoryPath = await firstExisting(dir, MEMORY_BASENAMES);\n const workspaceSeedDir = await directoryExists(join(dir, 'workspace'));\n const tools = await discoverTools(join(dir, 'tools'));\n const skills = await discoverSkills(join(dir, 'skills'));\n const subagents = await discoverSubagents(dir, depth, onWarn);\n\n return {\n name,\n dir: slash(dir),\n configPath,\n instructionsPath,\n workspacePath,\n memoryPath,\n workspaceSeedDir,\n tools,\n skills,\n subagents,\n };\n}\n\n/**\n * Discover declared subagents under `<dir>/subagents/*`. `parentDepth` is the\n * parent agent's nesting level (`0` for top-level agents). Discovery recurses\n * until `MAX_FS_SUBAGENT_DEPTH` levels of subagents; a `subagents/` directory\n * that would exceed the cap is skipped with a warning.\n */\nasync function discoverSubagents(\n parentDir: string,\n parentDepth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const subagentsDir = join(parentDir, 'subagents');\n if (!(await exists(subagentsDir))) {\n return [];\n }\n\n if (parentDepth >= MAX_FS_SUBAGENT_DEPTH) {\n onWarn?.(\n `Ignoring subagents in \"${slash(subagentsDir)}\": subagents may only nest ${MAX_FS_SUBAGENT_DEPTH} levels below a top-level agent.`,\n );\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(subagentsDir);\n } catch {\n return [];\n }\n\n const subagents: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(subagentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const child = await discoverAgentDir(dir, name, parentDepth + 1, onWarn);\n if (child) {\n subagents.push(child);\n }\n }\n\n return subagents;\n}\n\n/**\n * Scan `<mastraDir>/agents/*` for file-system routed agents. A directory is\n * treated as an agent only when it contains a `config.(ts|js)` or an\n * `instructions.md`; other directories are ignored. Each agent may declare\n * `subagents/` up to `MAX_FS_SUBAGENT_DEPTH` levels deep. Returns descriptors\n * with absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem inspection.\n */\nexport async function discoverFsAgents(\n mastraDir: string,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const agentsDir = join(mastraDir, 'agents');\n if (!(await exists(agentsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(agentsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(agentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const agent = await discoverAgentDir(dir, name, 0, onWarn);\n if (agent) {\n discovered.push(agent);\n }\n }\n\n return discovered;\n}\n\n/**\n * A file-system routed workflow file discovered under `<mastraDir>/workflows/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsWorkflow {\n /** Workflow key derived from the filename (without extension). */\n key: string;\n /** Absolute, slash-normalized path to the workflow module. */\n path: string;\n}\n\n/**\n * Scan `<mastraDir>/workflows/` for file-system routed workflow modules. Only\n * files whose source contains an `export default` are treated as fs-routed\n * workflows — this convention distinguishes them from workflow files that are\n * manually imported and registered programmatically. Returns descriptors with\n * absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem and source-text inspection.\n */\nexport async function discoverFsWorkflows(mastraDir: string): Promise<DiscoveredFsWorkflow[]> {\n const workflowsDir = join(mastraDir, 'workflows');\n if (!(await exists(workflowsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(workflowsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsWorkflow[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(workflowsDir, basename);\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n // Convention: only files with `export default` are fs-routed workflows.\n // Files using named exports are assumed to be manually imported.\n const source = await readFile(path, 'utf-8');\n if (!/\\bexport\\s+default\\b/.test(source)) {\n continue;\n }\n discovered.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return discovered;\n}\n","import { readFile } from 'node:fs/promises';\nimport type { DiscoveredFsAgent, DiscoveredFsWorkflow } from './discover';\n\nfunction sanitizeIdentifier(name: string, prefix: string, index: string): string {\n const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, '_');\n return `${prefix}_${index}_${cleaned}`;\n}\n\n/**\n * Emit the imports for a single discovered agent into `lines` and return the\n * source of its `assembleAgentFromFsEntry` entry object (the `{ name, config,\n * ... }` argument). `idPath` is a dot-free, unique path index (e.g. `0` for the\n * first top-level agent, `0_1` for its second subagent) used to keep generated\n * identifiers unique across the parent/child tree. `workspaceName` is the\n * slash-joined workspace key (`<parent>/<child>` for subagents) so seed files\n * don't collide. Discovered subagents are emitted recursively as a nested\n * `subagents: [...]` field (discovery already enforces the depth cap).\n */\nasync function emitAgentEntry(\n agent: DiscoveredFsAgent,\n idPath: string,\n workspaceName: string,\n lines: string[],\n): Promise<string> {\n const configIdent = sanitizeIdentifier(agent.name, 'config', idPath);\n const toolIdents: { key: string; ident: string }[] = [];\n\n if (agent.configPath) {\n lines.push(`import ${configIdent} from ${JSON.stringify(agent.configPath)};`);\n }\n\n let workspaceIdent: string | undefined;\n if (agent.workspacePath) {\n workspaceIdent = sanitizeIdentifier(`${agent.name}_workspace`, 'workspace', idPath);\n lines.push(`import ${workspaceIdent} from ${JSON.stringify(agent.workspacePath)};`);\n }\n\n let memoryIdent: string | undefined;\n if (agent.memoryPath) {\n memoryIdent = sanitizeIdentifier(`${agent.name}_memory`, 'memory', idPath);\n lines.push(`import ${memoryIdent} from ${JSON.stringify(agent.memoryPath)};`);\n }\n\n for (let t = 0; t < agent.tools.length; t++) {\n const tool = agent.tools[t]!;\n const ident = sanitizeIdentifier(`${agent.name}_${tool.key}`, 'tool', `${idPath}_${t}`);\n lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);\n toolIdents.push({ key: tool.key, ident });\n }\n\n // Skills: `createSkill(...)` modules are imported and used directly;\n // packaged `SKILL.md` skills are inlined via `createSkill({...})`.\n const skillExprs: string[] = [];\n const agentSkills = agent.skills ?? [];\n for (let s = 0; s < agentSkills.length; s++) {\n const skill = agentSkills[s]!;\n if (skill.kind === 'module') {\n const ident = sanitizeIdentifier(`${agent.name}_skill`, 'skill', `${idPath}_${s}`);\n lines.push(`import ${ident} from ${JSON.stringify(skill.path)};`);\n skillExprs.push(ident);\n } else {\n const referenceFields = Object.entries(skill.references).map(\n ([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n );\n const skillFields = [\n `name: ${JSON.stringify(skill.name)}`,\n `description: ${JSON.stringify(skill.description)}`,\n `instructions: ${JSON.stringify(skill.instructions)}`,\n ];\n if (referenceFields.length > 0) {\n skillFields.push(`references: { ${referenceFields.join(', ')} }`);\n }\n skillExprs.push(`__createSkill({ ${skillFields.join(', ')} })`);\n }\n }\n\n let instructionsMd: string | undefined;\n if (agent.instructionsPath) {\n instructionsMd = await readFile(agent.instructionsPath, 'utf-8');\n }\n\n // Declared subagents. Each is itself an `assembleAgentFromFsEntry` entry\n // object, recursively carrying its own `subagents`.\n const subagentExprs: string[] = [];\n for (let c = 0; c < agent.subagents.length; c++) {\n const child = agent.subagents[c]!;\n const childExpr = await emitAgentEntry(child, `${idPath}_${c}`, `${workspaceName}/${child.name}`, lines);\n subagentExprs.push(childExpr);\n }\n\n const entryFields: string[] = [`name: ${JSON.stringify(agent.name)}`];\n if (agent.configPath) {\n entryFields.push(`config: ${configIdent}`);\n }\n if (instructionsMd !== undefined) {\n entryFields.push(`instructionsMd: ${JSON.stringify(instructionsMd)}`);\n }\n if (toolIdents.length > 0) {\n const toolEntries = toolIdents.map(({ key, ident }) => `{ key: ${JSON.stringify(key)}, tool: ${ident} }`);\n entryFields.push(`tools: [${toolEntries.join(', ')}]`);\n }\n if (skillExprs.length > 0) {\n entryFields.push(`skills: [${skillExprs.join(', ')}]`);\n }\n if (subagentExprs.length > 0) {\n entryFields.push(`subagents: [${subagentExprs.join(', ')}]`);\n }\n if (workspaceIdent) {\n entryFields.push(`workspace: ${workspaceIdent}`);\n }\n if (memoryIdent) {\n entryFields.push(`memory: ${memoryIdent}`);\n }\n // Default-on parity: every FS agent gets a default workspace (file + shell\n // tools) rooted at a per-agent `workspace/` dir next to the bundle, unless\n // config.ts or workspace.ts supplies one. Assembly applies the explicit >\n // convention > default precedence. Subagents nest under `<parent>/<child>` so\n // their seed directories never collide with the parent's.\n entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);\n\n return `{ ${entryFields.join(', ')} }`;\n}\n\n/**\n * Generate the source of a wrapper module that:\n * 1. imports the user's real Mastra entry,\n * 2. imports each discovered `config.ts`, `tools/*.ts`, `skills/*.ts`\n * (`createSkill(...)` modules), `workspace.ts`, and `memory.ts`, inlining\n * packaged `SKILL.md` skills,\n * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any\n * declared `subagents/` into the parent (nested up to `MAX_FS_SUBAGENT_DEPTH`),\n * 4. registers them onto the user's `mastra` instance (code-registered agents\n * win on name collisions), and\n * 5. re-exports everything from the user's entry so this module is a drop-in\n * replacement for the original `#mastra` target.\n *\n * `instructions.md` contents are inlined at codegen time so no markdown loader\n * plugin is required in the bundler graph.\n *\n * @param userEntry slash-normalized absolute path to the user's mastra entry.\n * @param agents discovered fs-routed agents (absolute, slash-normalized paths).\n */\nexport async function generateFsAgentsModule(\n userEntry: string,\n agents: DiscoveredFsAgent[],\n options?: { workflows?: DiscoveredFsWorkflow[] },\n): Promise<string> {\n const workflows = options?.workflows ?? [];\n const lines: string[] = [];\n\n const hasInlineSkills = (function check(list: DiscoveredFsAgent[]): boolean {\n return list.some(a => (a.skills ?? []).some(s => s.kind === 'packaged') || check(a.subagents ?? []));\n })(agents);\n\n lines.push(`import { assembleAgentFromFsEntry } from '@mastra/core/agent';`);\n if (hasInlineSkills) {\n lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);\n }\n lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);\n lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);\n lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);\n lines.push(`export * from ${JSON.stringify(userEntry)};`);\n lines.push(``);\n // Resolve workspace base paths relative to this bundled module so they point\n // at `<bundle>/workspace/<name>` wherever the bundle is deployed. Seed files\n // authored under `agents/<name>/workspace/**` are mirrored there at build time.\n // `name` may be a slash-joined path (`<parent>/<child>`) for subagents.\n lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);\n lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);\n lines.push(``);\n\n const wfCodegen = workflows.length > 0 ? generateFsWorkflowsCodegen(workflows) : undefined;\n\n // Workflow imports (placed alongside other imports, before agent entries).\n if (wfCodegen) {\n for (const line of wfCodegen.importLines) {\n lines.push(line);\n }\n lines.push(``);\n }\n\n const entryExprs: string[] = [];\n for (let i = 0; i < agents.length; i++) {\n const agent = agents[i]!;\n const expr = await emitAgentEntry(agent, `${i}`, agent.name, lines);\n entryExprs.push(expr);\n }\n\n lines.push(``);\n lines.push(`const __fsAgentEntries = [`);\n for (const expr of entryExprs) {\n lines.push(` ${expr},`);\n }\n lines.push(`];`);\n lines.push(``);\n lines.push(`const __fsAgents = Object.create(null);`);\n lines.push(`for (const __entry of __fsAgentEntries) {`);\n lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);\n lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);\n lines.push(` });`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);\n lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);\n lines.push(`}`);\n\n // Workflow registration (after agents, before final export).\n if (wfCodegen) {\n lines.push(``);\n for (const line of wfCodegen.registrationLines) {\n lines.push(line);\n }\n }\n\n lines.push(``);\n lines.push(`export const mastra = __userEntry.mastra;`);\n\n return lines.join('\\n');\n}\n\n/**\n * Generate the workflow-registration lines to splice into the generated wrapper\n * module. Emits import statements for each discovered workflow module and a\n * registration block that calls `__registerFsWorkflows` on the user's mastra.\n *\n * Returns `{ importLines, registrationLines }` so the caller can place them at\n * the correct positions in the wrapper source.\n */\nexport function generateFsWorkflowsCodegen(workflows: DiscoveredFsWorkflow[]): {\n importLines: string[];\n registrationLines: string[];\n} {\n const importLines: string[] = [];\n const registrationLines: string[] = [];\n\n for (let i = 0; i < workflows.length; i++) {\n const wf = workflows[i]!;\n const ident = sanitizeIdentifier(wf.key, 'workflow', `${i}`);\n importLines.push(`import ${ident} from ${JSON.stringify(wf.path)};`);\n }\n\n registrationLines.push(`const __fsWorkflows = Object.create(null);`);\n for (let i = 0; i < workflows.length; i++) {\n const wf = workflows[i]!;\n const ident = sanitizeIdentifier(wf.key, 'workflow', `${i}`);\n registrationLines.push(`__fsWorkflows[${JSON.stringify(wf.key)}] = ${ident};`);\n }\n registrationLines.push(``);\n registrationLines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsWorkflows === 'function') {`);\n registrationLines.push(` __userEntry.mastra.__registerFsWorkflows(__fsWorkflows);`);\n registrationLines.push(`}`);\n\n return { importLines, registrationLines };\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { slash } from '../utils';\nimport { generateFsAgentsModule } from './codegen';\nimport { discoverFsAgents, discoverFsWorkflows } from './discover';\n\nexport interface PrepareFsAgentsEntryResult {\n /**\n * The entry file that should be fed to the bundler/analyzer. When fs-routed\n * primitives (agents, workflows) are found this is a generated wrapper module\n * that registers them onto the user's mastra instance; otherwise it is the\n * original entry unchanged.\n */\n entryFile: string;\n /**\n * Glob tool paths for tools defined under `agents/*\\/tools` so they are\n * bundled alongside the top-level `tools/` directory.\n */\n toolPaths: string[];\n /** Number of fs-routed agents discovered. */\n agentCount: number;\n /** Number of fs-routed workflows discovered. */\n workflowCount: number;\n /**\n * Generated wrapper source to write to {@link entryFile}, or `undefined` when\n * there are no fs-routed primitives. The write is deferred so callers can run\n * it *after* `bundler.prepare()` empties the output directory — otherwise the\n * wrapper is wiped before the bundler reads it.\n */\n moduleSource?: string;\n}\n\n/**\n * Discover fs-routed agents under `<mastraDir>/agents/*` and workflows under\n * `<mastraDir>/workflows/`. When any are found, generate a wrapper entry module\n * that registers them onto the user's mastra instance. Returns the entry the\n * bundler should use plus extra tool glob paths so `agents/*\\/tools` are bundled.\n *\n * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with\n * the result after `bundler.prepare()` so the generated file is not wiped when\n * the output directory is emptied.\n *\n * When no fs-routed primitives are present the original entry is returned\n * unchanged, so existing code-only projects are completely unaffected.\n */\nexport async function prepareFsAgentsEntry(\n mastraDir: string,\n entryFile: string,\n outputDirectory: string,\n): Promise<PrepareFsAgentsEntryResult> {\n const [agents, workflows] = await Promise.all([discoverFsAgents(mastraDir), discoverFsWorkflows(mastraDir)]);\n\n if (agents.length === 0 && workflows.length === 0) {\n return { entryFile, toolPaths: [], agentCount: 0, workflowCount: 0 };\n }\n\n const moduleSource = await generateFsAgentsModule(slash(entryFile), agents, { workflows });\n const generatedEntry = join(outputDirectory, '.mastra-fs-agents-entry.mjs');\n\n const normalizedMastraDir = slash(mastraDir);\n const toolPaths =\n agents.length > 0\n ? [\n posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{js,ts}'),\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/__tests__/**')}`,\n ]\n : [];\n\n return {\n entryFile: generatedEntry,\n toolPaths,\n agentCount: agents.length,\n workflowCount: workflows.length,\n moduleSource,\n };\n}\n\n/**\n * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}\n * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER\n * `bundler.prepare()` (which empties the output directory) so the wrapper\n * survives for the bundler/watcher to read.\n */\nexport async function writeFsAgentsEntry(result: PrepareFsAgentsEntryResult): Promise<void> {\n if (!result.moduleSource) {\n return;\n }\n\n await mkdir(dirname(result.entryFile), { recursive: true });\n await writeFile(result.entryFile, result.moduleSource, 'utf-8');\n}\n","import { cp, lstat, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { discoverFsAgents } from './discover';\nimport type { DiscoveredFsAgent } from './discover';\n\n/**\n * Skip symlinks when copying workspace seeds. A symlink under\n * `agents/<name>/workspace/` could point outside the workspace and be preserved\n * in the bundle, letting the agent read arbitrary files at runtime. We copy only\n * regular files and directories.\n */\nasync function rejectSymlinks(source: string): Promise<boolean> {\n const stats = await lstat(source);\n return !stats.isSymbolicLink();\n}\n\nasync function mirrorAgentSeeds(\n agent: DiscoveredFsAgent,\n workspaceName: string,\n bundleDir: string,\n mirrored: string[],\n): Promise<void> {\n if (agent.workspaceSeedDir) {\n const destination = join(bundleDir, 'workspace', ...workspaceName.split('/'));\n await mkdir(destination, { recursive: true });\n await cp(agent.workspaceSeedDir, destination, { recursive: true, filter: rejectSymlinks });\n mirrored.push(workspaceName);\n }\n\n // Subagents nest under `<parent>/<child>`, matching the codegen workspace key.\n for (const child of agent.subagents ?? []) {\n await mirrorAgentSeeds(child, `${workspaceName}/${child.name}`, bundleDir, mirrored);\n }\n}\n\n/**\n * Mirror authored `agents/<name>/workspace/**` seed files into the bundled\n * output so each fs-routed agent starts with them on disk (Eve parity). Files\n * are copied to `<bundleDir>/workspace/<name>`, which is exactly where the\n * generated entry roots each agent's default workspace at runtime (resolved\n * relative to the bundled module via `import.meta.url`). Declared subagents\n * mirror to the nested `<bundleDir>/workspace/<parent>/<child>` path.\n *\n * Must run AFTER the bundle step, since bundling recreates the output dir.\n *\n * @param mastraDir The user's `src/mastra` directory (source of seeds).\n * @param bundleDir The final bundle directory (e.g. `<outputDirectory>/output`).\n * @returns the workspace names whose seeds were mirrored (`<parent>/<child>` for subagents).\n */\nexport async function mirrorFsAgentWorkspaces(mastraDir: string, bundleDir: string): Promise<string[]> {\n const agents = await discoverFsAgents(mastraDir);\n const mirrored: string[] = [];\n\n for (const agent of agents) {\n await mirrorAgentSeeds(agent, agent.name, bundleDir, mirrored);\n }\n\n return mirrored;\n}\n"]}
@@ -341,6 +341,38 @@ async function discoverFsAgents(mastraDir, onWarn) {
341
341
  }
342
342
  return discovered;
343
343
  }
344
+ async function discoverFsWorkflows(mastraDir) {
345
+ const workflowsDir = path.join(mastraDir, "workflows");
346
+ if (!await exists(workflowsDir)) {
347
+ return [];
348
+ }
349
+ let entries;
350
+ try {
351
+ entries = await promises.readdir(workflowsDir);
352
+ } catch {
353
+ return [];
354
+ }
355
+ const discovered = [];
356
+ for (const basename of entries.sort()) {
357
+ if (isTestFile(basename)) {
358
+ continue;
359
+ }
360
+ if (!TOOL_EXTENSIONS.some((ext) => basename.endsWith(ext))) {
361
+ continue;
362
+ }
363
+ const path$1 = path.join(workflowsDir, basename);
364
+ const stats = await promises.lstat(path$1);
365
+ if (stats.isSymbolicLink() || stats.isDirectory()) {
366
+ continue;
367
+ }
368
+ const source = await promises.readFile(path$1, "utf-8");
369
+ if (!/\bexport\s+default\b/.test(source)) {
370
+ continue;
371
+ }
372
+ discovered.push({ key: toolKey(basename), path: chunkJZRFRUGM_cjs.slash(path$1) });
373
+ }
374
+ return discovered;
375
+ }
344
376
  function sanitizeIdentifier(name, prefix, index) {
345
377
  const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, "_");
346
378
  return `${prefix}_${index}_${cleaned}`;
@@ -426,7 +458,8 @@ async function emitAgentEntry(agent, idPath, workspaceName, lines) {
426
458
  entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);
427
459
  return `{ ${entryFields.join(", ")} }`;
428
460
  }
429
- async function generateFsAgentsModule(userEntry, agents) {
461
+ async function generateFsAgentsModule(userEntry, agents, options) {
462
+ const workflows = options?.workflows ?? [];
430
463
  const lines = [];
431
464
  const hasInlineSkills = (function check(list) {
432
465
  return list.some((a) => (a.skills ?? []).some((s) => s.kind === "packaged") || check(a.subagents ?? []));
@@ -443,6 +476,13 @@ async function generateFsAgentsModule(userEntry, agents) {
443
476
  lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);
444
477
  lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);
445
478
  lines.push(``);
479
+ const wfCodegen = workflows.length > 0 ? generateFsWorkflowsCodegen(workflows) : void 0;
480
+ if (wfCodegen) {
481
+ for (const line of wfCodegen.importLines) {
482
+ lines.push(line);
483
+ }
484
+ lines.push(``);
485
+ }
446
486
  const entryExprs = [];
447
487
  for (let i = 0; i < agents.length; i++) {
448
488
  const agent = agents[i];
@@ -466,24 +506,56 @@ async function generateFsAgentsModule(userEntry, agents) {
466
506
  lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);
467
507
  lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);
468
508
  lines.push(`}`);
509
+ if (wfCodegen) {
510
+ lines.push(``);
511
+ for (const line of wfCodegen.registrationLines) {
512
+ lines.push(line);
513
+ }
514
+ }
469
515
  lines.push(``);
470
516
  lines.push(`export const mastra = __userEntry.mastra;`);
471
517
  return lines.join("\n");
472
518
  }
519
+ function generateFsWorkflowsCodegen(workflows) {
520
+ const importLines = [];
521
+ const registrationLines = [];
522
+ for (let i = 0; i < workflows.length; i++) {
523
+ const wf = workflows[i];
524
+ const ident = sanitizeIdentifier(wf.key, "workflow", `${i}`);
525
+ importLines.push(`import ${ident} from ${JSON.stringify(wf.path)};`);
526
+ }
527
+ registrationLines.push(`const __fsWorkflows = Object.create(null);`);
528
+ for (let i = 0; i < workflows.length; i++) {
529
+ const wf = workflows[i];
530
+ const ident = sanitizeIdentifier(wf.key, "workflow", `${i}`);
531
+ registrationLines.push(`__fsWorkflows[${JSON.stringify(wf.key)}] = ${ident};`);
532
+ }
533
+ registrationLines.push(``);
534
+ registrationLines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsWorkflows === 'function') {`);
535
+ registrationLines.push(` __userEntry.mastra.__registerFsWorkflows(__fsWorkflows);`);
536
+ registrationLines.push(`}`);
537
+ return { importLines, registrationLines };
538
+ }
473
539
  async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
474
- const agents = await discoverFsAgents(mastraDir);
475
- if (agents.length === 0) {
476
- return { entryFile, toolPaths: [], agentCount: 0 };
540
+ const [agents, workflows] = await Promise.all([discoverFsAgents(mastraDir), discoverFsWorkflows(mastraDir)]);
541
+ if (agents.length === 0 && workflows.length === 0) {
542
+ return { entryFile, toolPaths: [], agentCount: 0, workflowCount: 0 };
477
543
  }
478
- const moduleSource = await generateFsAgentsModule(chunkJZRFRUGM_cjs.slash(entryFile), agents);
544
+ const moduleSource = await generateFsAgentsModule(chunkJZRFRUGM_cjs.slash(entryFile), agents, { workflows });
479
545
  const generatedEntry = path.join(outputDirectory, ".mastra-fs-agents-entry.mjs");
480
546
  const normalizedMastraDir = chunkJZRFRUGM_cjs.slash(mastraDir);
481
- const toolPaths = [
547
+ const toolPaths = agents.length > 0 ? [
482
548
  path.posix.join(normalizedMastraDir, "agents/*/tools/**/*.{js,ts}"),
483
549
  `!${path.posix.join(normalizedMastraDir, "agents/*/tools/**/*.{test,spec}.{js,ts}")}`,
484
550
  `!${path.posix.join(normalizedMastraDir, "agents/*/tools/**/__tests__/**")}`
485
- ];
486
- return { entryFile: generatedEntry, toolPaths, agentCount: agents.length, moduleSource };
551
+ ] : [];
552
+ return {
553
+ entryFile: generatedEntry,
554
+ toolPaths,
555
+ agentCount: agents.length,
556
+ workflowCount: workflows.length,
557
+ moduleSource
558
+ };
487
559
  }
488
560
  async function writeFsAgentsEntry(result) {
489
561
  if (!result.moduleSource) {
@@ -518,11 +590,13 @@ async function mirrorFsAgentWorkspaces(mastraDir, bundleDir) {
518
590
 
519
591
  exports.createWatcher = createWatcher;
520
592
  exports.discoverFsAgents = discoverFsAgents;
593
+ exports.discoverFsWorkflows = discoverFsWorkflows;
521
594
  exports.generateFsAgentsModule = generateFsAgentsModule;
595
+ exports.generateFsWorkflowsCodegen = generateFsWorkflowsCodegen;
522
596
  exports.getInputOptions = getInputOptions2;
523
597
  exports.getServerOptions = getServerOptions;
524
598
  exports.mirrorFsAgentWorkspaces = mirrorFsAgentWorkspaces;
525
599
  exports.prepareFsAgentsEntry = prepareFsAgentsEntry;
526
600
  exports.writeFsAgentsEntry = writeFsAgentsEntry;
527
- //# sourceMappingURL=chunk-YMYRP2K7.cjs.map
528
- //# sourceMappingURL=chunk-YMYRP2K7.cjs.map
601
+ //# sourceMappingURL=chunk-XSAPBEYT.cjs.map
602
+ //# sourceMappingURL=chunk-XSAPBEYT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/watcher.ts","../src/build/serverOptions.ts","../src/build/fs-routing/discover.ts","../src/build/fs-routing/codegen.ts","../src/build/fs-routing/prepare.ts","../src/build/fs-routing/mirror.ts"],"names":["getInputOptions","pkg","dirname","slash","getWorkspaceInformation","analyzeBundle","posix","noopLogger","getPackageName","tsConfigPaths","aliasHono","nodeModulesExtensionResolver","watch","extractMastraOption","lstat","join","readdir","path","readFile","matter","MAX_FS_SUBAGENT_DEPTH","mkdir","writeFile","cp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAsBA,gBAAAA,CACpB,SAAA,EACA,QAAA,EACA,GAAA,EACA;AAAA,EACE,SAAA,GAAY,KAAA;AAAA,EACZ,cAAA,GAAiB;AAAA,IACf,eAAA,EAAiB,KAAA;AAAA,IACjB,aAAA,EAAe,IAAA;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AAA,EAAO,KAAA,CAAM,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,EAC/D;AAEA,EAAA,OAAO,QAAA;AACT","file":"chunk-XSAPBEYT.cjs","sourcesContent":["import { dirname, posix } from 'node:path';\nimport { noopLogger } from '@mastra/core/logger';\nimport * as pkg from 'empathic/package';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport { watch } from 'rollup';\nimport { getWorkspaceInformation } from '../bundler/workspaceDependencies';\nimport { analyzeBundle } from './analyze';\nimport { getInputOptions as getBundlerInputOptions } from './bundler';\nimport { aliasHono } from './plugins/hono-alias';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport type { BundlerOptions } from './types';\nimport { getPackageName, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n platform: BundlerPlatform,\n env?: Record<string, string>,\n {\n sourcemap = false,\n bundlerOptions = {\n enableSourcemap: false,\n enableEsmShim: true,\n externals: true,\n },\n analysisEntries = [entryFile],\n }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions; analysisEntries?: string[] } = {},\n) {\n const closestPkgJson = pkg.up({ cwd: dirname(entryFile) });\n const projectRoot = closestPkgJson ? dirname(slash(closestPkgJson)) : slash(process.cwd());\n const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: entryFile });\n\n const analyzeEntryResult = await analyzeBundle(\n analysisEntries,\n entryFile,\n {\n outputDir: posix.join(process.cwd(), '.mastra', '.build'),\n projectRoot: workspaceRoot || process.cwd(),\n platform,\n isDev: true,\n bundlerOptions,\n },\n noopLogger,\n );\n\n const deps = /* @__PURE__ */ new Map();\n for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {\n const pkgName = getPackageName(dep);\n if (pkgName && workspaceMap.has(pkgName)) {\n deps.set(dep, metadata);\n }\n }\n\n const inputOptions = await getBundlerInputOptions(\n entryFile,\n {\n dependencies: deps,\n externalDependencies: new Map(),\n workspaceMap,\n },\n platform,\n env,\n { sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true },\n );\n\n if (Array.isArray(inputOptions.plugins)) {\n // filter out node-resolve plugin so all node_modules are external\n // and tsconfig-paths plugin as we are injection a custom one\n const plugins = [] as Plugin[];\n inputOptions.plugins.forEach(plugin => {\n if ((plugin as Plugin | undefined)?.name === 'node-resolve') {\n return;\n }\n\n if ((plugin as Plugin | undefined)?.name === 'tsconfig-paths') {\n plugins.push(\n tsConfigPaths({\n localResolve: true,\n }),\n );\n return;\n }\n\n plugins.push(plugin as Plugin);\n });\n\n inputOptions.plugins = plugins;\n inputOptions.plugins.push(aliasHono());\n // fixes imports like lodash/fp/get\n inputOptions.plugins.push(nodeModulesExtensionResolver());\n }\n\n return inputOptions;\n}\n\nexport async function createWatcher(inputOptions: InputOptions, outputOptions: OutputOptions) {\n const watcher = await watch({\n ...inputOptions,\n output: {\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n },\n });\n\n return watcher;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getServerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('server', entryFile, result);\n}\n\nexport async function getServerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['server'] | null> {\n const result = await extractMastraOption('server', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n","import { lstat, readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { MAX_FS_SUBAGENT_DEPTH } from '@mastra/core/agent';\nimport matter from 'gray-matter';\nimport { slash } from '../utils';\n\n/**\n * A file-system routed agent directory discovered under `<mastraDir>/agents/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsAgent {\n /** Agent directory name. Used as the default `id`/`name`. */\n name: string;\n /** Absolute, slash-normalized path to the agent directory. */\n dir: string;\n /** Absolute path to `config.ts`/`config.js`, if present. */\n configPath?: string;\n /** Absolute path to `instructions.md`, if present. */\n instructionsPath?: string;\n /** Absolute path to `workspace.ts`/`workspace.js`, if present. */\n workspacePath?: string;\n /** Absolute path to `memory.ts`/`memory.js`, if present. */\n memoryPath?: string;\n /**\n * Absolute, slash-normalized path to an authored `workspace/` directory of\n * seed files, if present. These are mirrored into the deployed workspace at\n * build time (Eve parity) so the agent starts with them on disk.\n */\n workspaceSeedDir?: string;\n /** Tools discovered under `tools/`, in stable (sorted) order. */\n tools: { key: string; path: string }[];\n /** Skills discovered under `skills/`, in stable (sorted) order. */\n skills: DiscoveredFsSkill[];\n /**\n * Declared subagents discovered under `subagents/`, in stable (sorted) order.\n * Subagents may declare their own `subagents/`, up to `MAX_FS_SUBAGENT_DEPTH`\n * levels below the top-level agent; deeper `subagents/` directories are\n * ignored with a warning.\n */\n subagents: DiscoveredFsAgent[];\n}\n\n/**\n * A skill discovered under `agents/<name>/skills/`.\n *\n * - `kind: 'module'` — a `.ts`/`.js` file whose default export is a `createSkill(...)`\n * result. Codegen imports it directly; `name`/`description`/`instructions` are\n * unknown at discovery time and resolved at runtime from the module.\n * - `kind: 'packaged'` — a `SKILL.md` (optionally with a `references/` subdir) or a\n * flat `<skill>.md`. Codegen inlines it via `createSkill(...)` using the parsed\n * fields below so the deployed bundle carries no filesystem dependency.\n */\nexport type DiscoveredFsSkill =\n | {\n kind: 'module';\n /** Absolute, slash-normalized path to the `.ts`/`.js` skill module. */\n path: string;\n }\n | {\n kind: 'packaged';\n name: string;\n description: string;\n instructions: string;\n /** Reference file contents keyed by relative path (from `references/`). */\n references: Record<string, string>;\n };\n\nconst CONFIG_BASENAMES = ['config.ts', 'config.js'];\nconst WORKSPACE_BASENAMES = ['workspace.ts', 'workspace.js'];\nconst MEMORY_BASENAMES = ['memory.ts', 'memory.js'];\nconst INSTRUCTIONS_BASENAME = 'instructions.md';\nconst TOOL_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MODULE_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MD_BASENAME = 'SKILL.md';\n\n/**\n * Presence check that does NOT follow symlinks. Returns `false` for symlinks\n * (and broken links) so a symlinked `config.ts`/`instructions.md`/`workspace.ts`/\n * `memory.ts` is never inlined or imported into the generated bundle.\n */\nasync function exists(path: string): Promise<boolean> {\n try {\n return !(await lstat(path)).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Returns the slash-normalized path when `path` is a real directory (not a\n * symlink). Symlinked directories are rejected to prevent the build from\n * following links out of the project tree during discovery.\n */\nasync function realDirectory(path: string): Promise<string | undefined> {\n try {\n const info = await lstat(path);\n if (info.isDirectory() && !info.isSymbolicLink()) {\n return slash(path);\n }\n } catch {\n // not present\n }\n return undefined;\n}\n\nasync function directoryExists(path: string): Promise<string | undefined> {\n return realDirectory(path);\n}\n\nasync function firstExisting(dir: string, basenames: string[]): Promise<string | undefined> {\n for (const basename of basenames) {\n const candidate = join(dir, basename);\n if (await exists(candidate)) {\n return slash(candidate);\n }\n }\n return undefined;\n}\n\nfunction isTestFile(basename: string): boolean {\n return /\\.(test|spec)\\.(ts|js)$/.test(basename);\n}\n\nfunction toolKey(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverTools(toolsDir: string): Promise<DiscoveredFsAgent['tools']> {\n if (!(await exists(toolsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(toolsDir);\n } catch {\n return [];\n }\n\n const tools: DiscoveredFsAgent['tools'] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(toolsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks and\n // directories: a symlinked tool file could point anywhere on the build\n // machine and be embedded into generated import code.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n tools.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return tools;\n}\n\nasync function readReferences(referencesDir: string): Promise<Record<string, string>> {\n if (!(await exists(referencesDir))) {\n return {};\n }\n const references: Record<string, string> = {};\n let entries: string[];\n try {\n entries = await readdir(referencesDir);\n } catch {\n return {};\n }\n for (const basename of entries.sort()) {\n const path = join(referencesDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlink under `references/` could point anywhere on the build machine and\n // silently embed arbitrary file contents into the generated bundle.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n references[basename] = await readFile(path, 'utf-8');\n }\n return references;\n}\n\nasync function parsePackagedSkill(\n skillMdPath: string,\n fallbackName: string,\n references: Record<string, string> = {},\n): Promise<Extract<DiscoveredFsSkill, { kind: 'packaged' }>> {\n const raw = await readFile(skillMdPath, 'utf-8');\n const parsed = matter(raw);\n const frontmatter = parsed.data as { name?: string; description?: string };\n const name = frontmatter.name ?? fallbackName;\n const description = frontmatter.description ?? '';\n const instructions = parsed.content.trim();\n return { kind: 'packaged', name, description, instructions, references };\n}\n\nfunction skillModuleName(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverSkills(skillsDir: string): Promise<DiscoveredFsSkill[]> {\n if (!(await exists(skillsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(skillsDir);\n } catch {\n return [];\n }\n\n const skills: DiscoveredFsSkill[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n const path = join(skillsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlinked skill module/markdown could point anywhere on the build machine\n // and be bundled or inlined into the generated output.\n const stats = await lstat(path);\n if (stats.isSymbolicLink()) {\n continue;\n }\n const isDir = stats.isDirectory();\n\n // Packaged skill directory: <skill>/SKILL.md (+ references/)\n if (isDir) {\n const skillMd = join(path, SKILL_MD_BASENAME);\n if (await exists(skillMd)) {\n const references = await readReferences(join(path, 'references'));\n skills.push(await parsePackagedSkill(skillMd, skillModuleName(basename), references));\n }\n continue;\n }\n\n // createSkill module: <skill>.ts | <skill>.js\n if (SKILL_MODULE_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n skills.push({ kind: 'module', path: slash(path) });\n continue;\n }\n\n // Flat markdown skill: <skill>.md\n if (basename.endsWith('.md')) {\n const skill = await parsePackagedSkill(path, basename.replace(/\\.md$/, ''));\n skills.push(skill);\n }\n }\n\n return skills;\n}\n\n/**\n * Discover a single agent directory: its `config`/`instructions`/`workspace`\n * files plus `tools/`, `skills/`, and declared `subagents/`. Returns\n * `undefined` when `dir` is not an agent directory (no `config.(ts|js)` and no\n * `instructions.md`).\n *\n * `depth` is the subagent nesting level (`0` for top-level agents). Discovery\n * recurses into `subagents/` until `MAX_FS_SUBAGENT_DEPTH`; deeper directories\n * are ignored with a warning.\n */\nasync function discoverAgentDir(\n dir: string,\n name: string,\n depth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent | undefined> {\n const configPath = await firstExisting(dir, CONFIG_BASENAMES);\n const instructionsPath = (await exists(join(dir, INSTRUCTIONS_BASENAME)))\n ? slash(join(dir, INSTRUCTIONS_BASENAME))\n : undefined;\n\n // Not an agent directory unless it has a config or instructions file.\n if (!configPath && !instructionsPath) {\n return undefined;\n }\n\n const workspacePath = await firstExisting(dir, WORKSPACE_BASENAMES);\n const memoryPath = await firstExisting(dir, MEMORY_BASENAMES);\n const workspaceSeedDir = await directoryExists(join(dir, 'workspace'));\n const tools = await discoverTools(join(dir, 'tools'));\n const skills = await discoverSkills(join(dir, 'skills'));\n const subagents = await discoverSubagents(dir, depth, onWarn);\n\n return {\n name,\n dir: slash(dir),\n configPath,\n instructionsPath,\n workspacePath,\n memoryPath,\n workspaceSeedDir,\n tools,\n skills,\n subagents,\n };\n}\n\n/**\n * Discover declared subagents under `<dir>/subagents/*`. `parentDepth` is the\n * parent agent's nesting level (`0` for top-level agents). Discovery recurses\n * until `MAX_FS_SUBAGENT_DEPTH` levels of subagents; a `subagents/` directory\n * that would exceed the cap is skipped with a warning.\n */\nasync function discoverSubagents(\n parentDir: string,\n parentDepth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const subagentsDir = join(parentDir, 'subagents');\n if (!(await exists(subagentsDir))) {\n return [];\n }\n\n if (parentDepth >= MAX_FS_SUBAGENT_DEPTH) {\n onWarn?.(\n `Ignoring subagents in \"${slash(subagentsDir)}\": subagents may only nest ${MAX_FS_SUBAGENT_DEPTH} levels below a top-level agent.`,\n );\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(subagentsDir);\n } catch {\n return [];\n }\n\n const subagents: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(subagentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const child = await discoverAgentDir(dir, name, parentDepth + 1, onWarn);\n if (child) {\n subagents.push(child);\n }\n }\n\n return subagents;\n}\n\n/**\n * Scan `<mastraDir>/agents/*` for file-system routed agents. A directory is\n * treated as an agent only when it contains a `config.(ts|js)` or an\n * `instructions.md`; other directories are ignored. Each agent may declare\n * `subagents/` up to `MAX_FS_SUBAGENT_DEPTH` levels deep. Returns descriptors\n * with absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem inspection.\n */\nexport async function discoverFsAgents(\n mastraDir: string,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const agentsDir = join(mastraDir, 'agents');\n if (!(await exists(agentsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(agentsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(agentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const agent = await discoverAgentDir(dir, name, 0, onWarn);\n if (agent) {\n discovered.push(agent);\n }\n }\n\n return discovered;\n}\n\n/**\n * A file-system routed workflow file discovered under `<mastraDir>/workflows/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsWorkflow {\n /** Workflow key derived from the filename (without extension). */\n key: string;\n /** Absolute, slash-normalized path to the workflow module. */\n path: string;\n}\n\n/**\n * Scan `<mastraDir>/workflows/` for file-system routed workflow modules. Only\n * files whose source contains an `export default` are treated as fs-routed\n * workflows — this convention distinguishes them from workflow files that are\n * manually imported and registered programmatically. Returns descriptors with\n * absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem and source-text inspection.\n */\nexport async function discoverFsWorkflows(mastraDir: string): Promise<DiscoveredFsWorkflow[]> {\n const workflowsDir = join(mastraDir, 'workflows');\n if (!(await exists(workflowsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(workflowsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsWorkflow[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(workflowsDir, basename);\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n // Convention: only files with `export default` are fs-routed workflows.\n // Files using named exports are assumed to be manually imported.\n const source = await readFile(path, 'utf-8');\n if (!/\\bexport\\s+default\\b/.test(source)) {\n continue;\n }\n discovered.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return discovered;\n}\n","import { readFile } from 'node:fs/promises';\nimport type { DiscoveredFsAgent, DiscoveredFsWorkflow } from './discover';\n\nfunction sanitizeIdentifier(name: string, prefix: string, index: string): string {\n const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, '_');\n return `${prefix}_${index}_${cleaned}`;\n}\n\n/**\n * Emit the imports for a single discovered agent into `lines` and return the\n * source of its `assembleAgentFromFsEntry` entry object (the `{ name, config,\n * ... }` argument). `idPath` is a dot-free, unique path index (e.g. `0` for the\n * first top-level agent, `0_1` for its second subagent) used to keep generated\n * identifiers unique across the parent/child tree. `workspaceName` is the\n * slash-joined workspace key (`<parent>/<child>` for subagents) so seed files\n * don't collide. Discovered subagents are emitted recursively as a nested\n * `subagents: [...]` field (discovery already enforces the depth cap).\n */\nasync function emitAgentEntry(\n agent: DiscoveredFsAgent,\n idPath: string,\n workspaceName: string,\n lines: string[],\n): Promise<string> {\n const configIdent = sanitizeIdentifier(agent.name, 'config', idPath);\n const toolIdents: { key: string; ident: string }[] = [];\n\n if (agent.configPath) {\n lines.push(`import ${configIdent} from ${JSON.stringify(agent.configPath)};`);\n }\n\n let workspaceIdent: string | undefined;\n if (agent.workspacePath) {\n workspaceIdent = sanitizeIdentifier(`${agent.name}_workspace`, 'workspace', idPath);\n lines.push(`import ${workspaceIdent} from ${JSON.stringify(agent.workspacePath)};`);\n }\n\n let memoryIdent: string | undefined;\n if (agent.memoryPath) {\n memoryIdent = sanitizeIdentifier(`${agent.name}_memory`, 'memory', idPath);\n lines.push(`import ${memoryIdent} from ${JSON.stringify(agent.memoryPath)};`);\n }\n\n for (let t = 0; t < agent.tools.length; t++) {\n const tool = agent.tools[t]!;\n const ident = sanitizeIdentifier(`${agent.name}_${tool.key}`, 'tool', `${idPath}_${t}`);\n lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);\n toolIdents.push({ key: tool.key, ident });\n }\n\n // Skills: `createSkill(...)` modules are imported and used directly;\n // packaged `SKILL.md` skills are inlined via `createSkill({...})`.\n const skillExprs: string[] = [];\n const agentSkills = agent.skills ?? [];\n for (let s = 0; s < agentSkills.length; s++) {\n const skill = agentSkills[s]!;\n if (skill.kind === 'module') {\n const ident = sanitizeIdentifier(`${agent.name}_skill`, 'skill', `${idPath}_${s}`);\n lines.push(`import ${ident} from ${JSON.stringify(skill.path)};`);\n skillExprs.push(ident);\n } else {\n const referenceFields = Object.entries(skill.references).map(\n ([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n );\n const skillFields = [\n `name: ${JSON.stringify(skill.name)}`,\n `description: ${JSON.stringify(skill.description)}`,\n `instructions: ${JSON.stringify(skill.instructions)}`,\n ];\n if (referenceFields.length > 0) {\n skillFields.push(`references: { ${referenceFields.join(', ')} }`);\n }\n skillExprs.push(`__createSkill({ ${skillFields.join(', ')} })`);\n }\n }\n\n let instructionsMd: string | undefined;\n if (agent.instructionsPath) {\n instructionsMd = await readFile(agent.instructionsPath, 'utf-8');\n }\n\n // Declared subagents. Each is itself an `assembleAgentFromFsEntry` entry\n // object, recursively carrying its own `subagents`.\n const subagentExprs: string[] = [];\n for (let c = 0; c < agent.subagents.length; c++) {\n const child = agent.subagents[c]!;\n const childExpr = await emitAgentEntry(child, `${idPath}_${c}`, `${workspaceName}/${child.name}`, lines);\n subagentExprs.push(childExpr);\n }\n\n const entryFields: string[] = [`name: ${JSON.stringify(agent.name)}`];\n if (agent.configPath) {\n entryFields.push(`config: ${configIdent}`);\n }\n if (instructionsMd !== undefined) {\n entryFields.push(`instructionsMd: ${JSON.stringify(instructionsMd)}`);\n }\n if (toolIdents.length > 0) {\n const toolEntries = toolIdents.map(({ key, ident }) => `{ key: ${JSON.stringify(key)}, tool: ${ident} }`);\n entryFields.push(`tools: [${toolEntries.join(', ')}]`);\n }\n if (skillExprs.length > 0) {\n entryFields.push(`skills: [${skillExprs.join(', ')}]`);\n }\n if (subagentExprs.length > 0) {\n entryFields.push(`subagents: [${subagentExprs.join(', ')}]`);\n }\n if (workspaceIdent) {\n entryFields.push(`workspace: ${workspaceIdent}`);\n }\n if (memoryIdent) {\n entryFields.push(`memory: ${memoryIdent}`);\n }\n // Default-on parity: every FS agent gets a default workspace (file + shell\n // tools) rooted at a per-agent `workspace/` dir next to the bundle, unless\n // config.ts or workspace.ts supplies one. Assembly applies the explicit >\n // convention > default precedence. Subagents nest under `<parent>/<child>` so\n // their seed directories never collide with the parent's.\n entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);\n\n return `{ ${entryFields.join(', ')} }`;\n}\n\n/**\n * Generate the source of a wrapper module that:\n * 1. imports the user's real Mastra entry,\n * 2. imports each discovered `config.ts`, `tools/*.ts`, `skills/*.ts`\n * (`createSkill(...)` modules), `workspace.ts`, and `memory.ts`, inlining\n * packaged `SKILL.md` skills,\n * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any\n * declared `subagents/` into the parent (nested up to `MAX_FS_SUBAGENT_DEPTH`),\n * 4. registers them onto the user's `mastra` instance (code-registered agents\n * win on name collisions), and\n * 5. re-exports everything from the user's entry so this module is a drop-in\n * replacement for the original `#mastra` target.\n *\n * `instructions.md` contents are inlined at codegen time so no markdown loader\n * plugin is required in the bundler graph.\n *\n * @param userEntry slash-normalized absolute path to the user's mastra entry.\n * @param agents discovered fs-routed agents (absolute, slash-normalized paths).\n */\nexport async function generateFsAgentsModule(\n userEntry: string,\n agents: DiscoveredFsAgent[],\n options?: { workflows?: DiscoveredFsWorkflow[] },\n): Promise<string> {\n const workflows = options?.workflows ?? [];\n const lines: string[] = [];\n\n const hasInlineSkills = (function check(list: DiscoveredFsAgent[]): boolean {\n return list.some(a => (a.skills ?? []).some(s => s.kind === 'packaged') || check(a.subagents ?? []));\n })(agents);\n\n lines.push(`import { assembleAgentFromFsEntry } from '@mastra/core/agent';`);\n if (hasInlineSkills) {\n lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);\n }\n lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);\n lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);\n lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);\n lines.push(`export * from ${JSON.stringify(userEntry)};`);\n lines.push(``);\n // Resolve workspace base paths relative to this bundled module so they point\n // at `<bundle>/workspace/<name>` wherever the bundle is deployed. Seed files\n // authored under `agents/<name>/workspace/**` are mirrored there at build time.\n // `name` may be a slash-joined path (`<parent>/<child>`) for subagents.\n lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);\n lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);\n lines.push(``);\n\n const wfCodegen = workflows.length > 0 ? generateFsWorkflowsCodegen(workflows) : undefined;\n\n // Workflow imports (placed alongside other imports, before agent entries).\n if (wfCodegen) {\n for (const line of wfCodegen.importLines) {\n lines.push(line);\n }\n lines.push(``);\n }\n\n const entryExprs: string[] = [];\n for (let i = 0; i < agents.length; i++) {\n const agent = agents[i]!;\n const expr = await emitAgentEntry(agent, `${i}`, agent.name, lines);\n entryExprs.push(expr);\n }\n\n lines.push(``);\n lines.push(`const __fsAgentEntries = [`);\n for (const expr of entryExprs) {\n lines.push(` ${expr},`);\n }\n lines.push(`];`);\n lines.push(``);\n lines.push(`const __fsAgents = Object.create(null);`);\n lines.push(`for (const __entry of __fsAgentEntries) {`);\n lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);\n lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);\n lines.push(` });`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);\n lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);\n lines.push(`}`);\n\n // Workflow registration (after agents, before final export).\n if (wfCodegen) {\n lines.push(``);\n for (const line of wfCodegen.registrationLines) {\n lines.push(line);\n }\n }\n\n lines.push(``);\n lines.push(`export const mastra = __userEntry.mastra;`);\n\n return lines.join('\\n');\n}\n\n/**\n * Generate the workflow-registration lines to splice into the generated wrapper\n * module. Emits import statements for each discovered workflow module and a\n * registration block that calls `__registerFsWorkflows` on the user's mastra.\n *\n * Returns `{ importLines, registrationLines }` so the caller can place them at\n * the correct positions in the wrapper source.\n */\nexport function generateFsWorkflowsCodegen(workflows: DiscoveredFsWorkflow[]): {\n importLines: string[];\n registrationLines: string[];\n} {\n const importLines: string[] = [];\n const registrationLines: string[] = [];\n\n for (let i = 0; i < workflows.length; i++) {\n const wf = workflows[i]!;\n const ident = sanitizeIdentifier(wf.key, 'workflow', `${i}`);\n importLines.push(`import ${ident} from ${JSON.stringify(wf.path)};`);\n }\n\n registrationLines.push(`const __fsWorkflows = Object.create(null);`);\n for (let i = 0; i < workflows.length; i++) {\n const wf = workflows[i]!;\n const ident = sanitizeIdentifier(wf.key, 'workflow', `${i}`);\n registrationLines.push(`__fsWorkflows[${JSON.stringify(wf.key)}] = ${ident};`);\n }\n registrationLines.push(``);\n registrationLines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsWorkflows === 'function') {`);\n registrationLines.push(` __userEntry.mastra.__registerFsWorkflows(__fsWorkflows);`);\n registrationLines.push(`}`);\n\n return { importLines, registrationLines };\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { slash } from '../utils';\nimport { generateFsAgentsModule } from './codegen';\nimport { discoverFsAgents, discoverFsWorkflows } from './discover';\n\nexport interface PrepareFsAgentsEntryResult {\n /**\n * The entry file that should be fed to the bundler/analyzer. When fs-routed\n * primitives (agents, workflows) are found this is a generated wrapper module\n * that registers them onto the user's mastra instance; otherwise it is the\n * original entry unchanged.\n */\n entryFile: string;\n /**\n * Glob tool paths for tools defined under `agents/*\\/tools` so they are\n * bundled alongside the top-level `tools/` directory.\n */\n toolPaths: string[];\n /** Number of fs-routed agents discovered. */\n agentCount: number;\n /** Number of fs-routed workflows discovered. */\n workflowCount: number;\n /**\n * Generated wrapper source to write to {@link entryFile}, or `undefined` when\n * there are no fs-routed primitives. The write is deferred so callers can run\n * it *after* `bundler.prepare()` empties the output directory — otherwise the\n * wrapper is wiped before the bundler reads it.\n */\n moduleSource?: string;\n}\n\n/**\n * Discover fs-routed agents under `<mastraDir>/agents/*` and workflows under\n * `<mastraDir>/workflows/`. When any are found, generate a wrapper entry module\n * that registers them onto the user's mastra instance. Returns the entry the\n * bundler should use plus extra tool glob paths so `agents/*\\/tools` are bundled.\n *\n * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with\n * the result after `bundler.prepare()` so the generated file is not wiped when\n * the output directory is emptied.\n *\n * When no fs-routed primitives are present the original entry is returned\n * unchanged, so existing code-only projects are completely unaffected.\n */\nexport async function prepareFsAgentsEntry(\n mastraDir: string,\n entryFile: string,\n outputDirectory: string,\n): Promise<PrepareFsAgentsEntryResult> {\n const [agents, workflows] = await Promise.all([discoverFsAgents(mastraDir), discoverFsWorkflows(mastraDir)]);\n\n if (agents.length === 0 && workflows.length === 0) {\n return { entryFile, toolPaths: [], agentCount: 0, workflowCount: 0 };\n }\n\n const moduleSource = await generateFsAgentsModule(slash(entryFile), agents, { workflows });\n const generatedEntry = join(outputDirectory, '.mastra-fs-agents-entry.mjs');\n\n const normalizedMastraDir = slash(mastraDir);\n const toolPaths =\n agents.length > 0\n ? [\n posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{js,ts}'),\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/__tests__/**')}`,\n ]\n : [];\n\n return {\n entryFile: generatedEntry,\n toolPaths,\n agentCount: agents.length,\n workflowCount: workflows.length,\n moduleSource,\n };\n}\n\n/**\n * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}\n * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER\n * `bundler.prepare()` (which empties the output directory) so the wrapper\n * survives for the bundler/watcher to read.\n */\nexport async function writeFsAgentsEntry(result: PrepareFsAgentsEntryResult): Promise<void> {\n if (!result.moduleSource) {\n return;\n }\n\n await mkdir(dirname(result.entryFile), { recursive: true });\n await writeFile(result.entryFile, result.moduleSource, 'utf-8');\n}\n","import { cp, lstat, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { discoverFsAgents } from './discover';\nimport type { DiscoveredFsAgent } from './discover';\n\n/**\n * Skip symlinks when copying workspace seeds. A symlink under\n * `agents/<name>/workspace/` could point outside the workspace and be preserved\n * in the bundle, letting the agent read arbitrary files at runtime. We copy only\n * regular files and directories.\n */\nasync function rejectSymlinks(source: string): Promise<boolean> {\n const stats = await lstat(source);\n return !stats.isSymbolicLink();\n}\n\nasync function mirrorAgentSeeds(\n agent: DiscoveredFsAgent,\n workspaceName: string,\n bundleDir: string,\n mirrored: string[],\n): Promise<void> {\n if (agent.workspaceSeedDir) {\n const destination = join(bundleDir, 'workspace', ...workspaceName.split('/'));\n await mkdir(destination, { recursive: true });\n await cp(agent.workspaceSeedDir, destination, { recursive: true, filter: rejectSymlinks });\n mirrored.push(workspaceName);\n }\n\n // Subagents nest under `<parent>/<child>`, matching the codegen workspace key.\n for (const child of agent.subagents ?? []) {\n await mirrorAgentSeeds(child, `${workspaceName}/${child.name}`, bundleDir, mirrored);\n }\n}\n\n/**\n * Mirror authored `agents/<name>/workspace/**` seed files into the bundled\n * output so each fs-routed agent starts with them on disk (Eve parity). Files\n * are copied to `<bundleDir>/workspace/<name>`, which is exactly where the\n * generated entry roots each agent's default workspace at runtime (resolved\n * relative to the bundled module via `import.meta.url`). Declared subagents\n * mirror to the nested `<bundleDir>/workspace/<parent>/<child>` path.\n *\n * Must run AFTER the bundle step, since bundling recreates the output dir.\n *\n * @param mastraDir The user's `src/mastra` directory (source of seeds).\n * @param bundleDir The final bundle directory (e.g. `<outputDirectory>/output`).\n * @returns the workspace names whose seeds were mirrored (`<parent>/<child>` for subagents).\n */\nexport async function mirrorFsAgentWorkspaces(mastraDir: string, bundleDir: string): Promise<string[]> {\n const agents = await discoverFsAgents(mastraDir);\n const mirrored: string[] = [];\n\n for (const agent of agents) {\n await mirrorAgentSeeds(agent, agent.name, bundleDir, mirrored);\n }\n\n return mirrored;\n}\n"]}
@@ -3,7 +3,7 @@ name: mastra-deployer
3
3
  description: Documentation for @mastra/deployer. Use when working with @mastra/deployer APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/deployer"
6
- version: "1.50.0-alpha.1"
6
+ version: "1.50.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.50.0-alpha.1",
2
+ "version": "1.50.0-alpha.2",
3
3
  "package": "@mastra/deployer",
4
4
  "exports": {
5
5
  "Deps": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer",
3
- "version": "1.50.0-alpha.1",
3
+ "version": "1.50.0-alpha.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -113,7 +113,7 @@
113
113
  "tinyglobby": "^0.2.17",
114
114
  "typescript-paths": "^1.5.2",
115
115
  "ws": "^8.21.0",
116
- "@mastra/server": "1.50.0-alpha.1"
116
+ "@mastra/server": "1.50.0-alpha.2"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@hono/node-server": "^1.19.11",
@@ -134,13 +134,13 @@
134
134
  "typescript": "^6.0.3",
135
135
  "vitest": "4.1.8",
136
136
  "zod": "^4.4.3",
137
- "@internal/lint": "0.0.111",
138
137
  "@internal/types-builder": "0.0.86",
138
+ "@internal/lint": "0.0.111",
139
139
  "@mastra/agent-browser": "0.4.1-alpha.0",
140
- "@mastra/core": "1.50.0-alpha.1",
141
- "@mastra/hono": "1.5.5-alpha.1",
140
+ "@mastra/core": "1.50.0-alpha.2",
142
141
  "@mastra/mcp": "^1.13.1-alpha.0",
143
- "@mastra/server": "1.50.0-alpha.1"
142
+ "@mastra/hono": "1.5.5-alpha.2",
143
+ "@mastra/server": "1.50.0-alpha.2"
144
144
  },
145
145
  "peerDependencies": {
146
146
  "@mastra/core": ">=1.47.0-0 <2.0.0-0"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/build/watcher.ts","../src/build/serverOptions.ts","../src/build/fs-routing/discover.ts","../src/build/fs-routing/codegen.ts","../src/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EAAW,IAAA,EAAM,MAAA,EAAQ,cAAA,EAAgB,CAAA;AACzF,IAAA,QAAA,CAAS,KAAK,aAAa,CAAA;AAAA,EAC7B;AAGA,EAAA,KAAA,MAAW,KAAA,IAAS,KAAA,CAAM,SAAA,IAAa,EAAC,EAAG;AACzC,IAAA,MAAM,gBAAA,CAAiB,OAAO,CAAA,EAAG,aAAa,IAAI,KAAA,CAAM,IAAI,CAAA,CAAA,EAAI,SAAA,EAAW,QAAQ,CAAA;AAAA,EACrF;AACF;AAgBA,eAAsB,uBAAA,CAAwB,WAAmB,SAAA,EAAsC;AACrG,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,CAAiB,SAAS,CAAA;AAC/C,EAAA,MAAM,WAAqB,EAAC;AAE5B,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,MAAM,gBAAA,CAAiB,KAAA,EAAO,KAAA,CAAM,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,EAC/D;AAEA,EAAA,OAAO,QAAA;AACT","file":"chunk-THSS3CYX.js","sourcesContent":["import { dirname, posix } from 'node:path';\nimport { noopLogger } from '@mastra/core/logger';\nimport * as pkg from 'empathic/package';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport { watch } from 'rollup';\nimport { getWorkspaceInformation } from '../bundler/workspaceDependencies';\nimport { analyzeBundle } from './analyze';\nimport { getInputOptions as getBundlerInputOptions } from './bundler';\nimport { aliasHono } from './plugins/hono-alias';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport type { BundlerOptions } from './types';\nimport { getPackageName, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n platform: BundlerPlatform,\n env?: Record<string, string>,\n {\n sourcemap = false,\n bundlerOptions = {\n enableSourcemap: false,\n enableEsmShim: true,\n externals: true,\n },\n analysisEntries = [entryFile],\n }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions; analysisEntries?: string[] } = {},\n) {\n const closestPkgJson = pkg.up({ cwd: dirname(entryFile) });\n const projectRoot = closestPkgJson ? dirname(slash(closestPkgJson)) : slash(process.cwd());\n const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: entryFile });\n\n const analyzeEntryResult = await analyzeBundle(\n analysisEntries,\n entryFile,\n {\n outputDir: posix.join(process.cwd(), '.mastra', '.build'),\n projectRoot: workspaceRoot || process.cwd(),\n platform,\n isDev: true,\n bundlerOptions,\n },\n noopLogger,\n );\n\n const deps = /* @__PURE__ */ new Map();\n for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {\n const pkgName = getPackageName(dep);\n if (pkgName && workspaceMap.has(pkgName)) {\n deps.set(dep, metadata);\n }\n }\n\n const inputOptions = await getBundlerInputOptions(\n entryFile,\n {\n dependencies: deps,\n externalDependencies: new Map(),\n workspaceMap,\n },\n platform,\n env,\n { sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true },\n );\n\n if (Array.isArray(inputOptions.plugins)) {\n // filter out node-resolve plugin so all node_modules are external\n // and tsconfig-paths plugin as we are injection a custom one\n const plugins = [] as Plugin[];\n inputOptions.plugins.forEach(plugin => {\n if ((plugin as Plugin | undefined)?.name === 'node-resolve') {\n return;\n }\n\n if ((plugin as Plugin | undefined)?.name === 'tsconfig-paths') {\n plugins.push(\n tsConfigPaths({\n localResolve: true,\n }),\n );\n return;\n }\n\n plugins.push(plugin as Plugin);\n });\n\n inputOptions.plugins = plugins;\n inputOptions.plugins.push(aliasHono());\n // fixes imports like lodash/fp/get\n inputOptions.plugins.push(nodeModulesExtensionResolver());\n }\n\n return inputOptions;\n}\n\nexport async function createWatcher(inputOptions: InputOptions, outputOptions: OutputOptions) {\n const watcher = await watch({\n ...inputOptions,\n output: {\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n },\n });\n\n return watcher;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getServerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('server', entryFile, result);\n}\n\nexport async function getServerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['server'] | null> {\n const result = await extractMastraOption('server', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n","import { lstat, readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { MAX_FS_SUBAGENT_DEPTH } from '@mastra/core/agent';\nimport matter from 'gray-matter';\nimport { slash } from '../utils';\n\n/**\n * A file-system routed agent directory discovered under `<mastraDir>/agents/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsAgent {\n /** Agent directory name. Used as the default `id`/`name`. */\n name: string;\n /** Absolute, slash-normalized path to the agent directory. */\n dir: string;\n /** Absolute path to `config.ts`/`config.js`, if present. */\n configPath?: string;\n /** Absolute path to `instructions.md`, if present. */\n instructionsPath?: string;\n /** Absolute path to `workspace.ts`/`workspace.js`, if present. */\n workspacePath?: string;\n /** Absolute path to `memory.ts`/`memory.js`, if present. */\n memoryPath?: string;\n /**\n * Absolute, slash-normalized path to an authored `workspace/` directory of\n * seed files, if present. These are mirrored into the deployed workspace at\n * build time (Eve parity) so the agent starts with them on disk.\n */\n workspaceSeedDir?: string;\n /** Tools discovered under `tools/`, in stable (sorted) order. */\n tools: { key: string; path: string }[];\n /** Skills discovered under `skills/`, in stable (sorted) order. */\n skills: DiscoveredFsSkill[];\n /**\n * Declared subagents discovered under `subagents/`, in stable (sorted) order.\n * Subagents may declare their own `subagents/`, up to `MAX_FS_SUBAGENT_DEPTH`\n * levels below the top-level agent; deeper `subagents/` directories are\n * ignored with a warning.\n */\n subagents: DiscoveredFsAgent[];\n}\n\n/**\n * A skill discovered under `agents/<name>/skills/`.\n *\n * - `kind: 'module'` — a `.ts`/`.js` file whose default export is a `createSkill(...)`\n * result. Codegen imports it directly; `name`/`description`/`instructions` are\n * unknown at discovery time and resolved at runtime from the module.\n * - `kind: 'packaged'` — a `SKILL.md` (optionally with a `references/` subdir) or a\n * flat `<skill>.md`. Codegen inlines it via `createSkill(...)` using the parsed\n * fields below so the deployed bundle carries no filesystem dependency.\n */\nexport type DiscoveredFsSkill =\n | {\n kind: 'module';\n /** Absolute, slash-normalized path to the `.ts`/`.js` skill module. */\n path: string;\n }\n | {\n kind: 'packaged';\n name: string;\n description: string;\n instructions: string;\n /** Reference file contents keyed by relative path (from `references/`). */\n references: Record<string, string>;\n };\n\nconst CONFIG_BASENAMES = ['config.ts', 'config.js'];\nconst WORKSPACE_BASENAMES = ['workspace.ts', 'workspace.js'];\nconst MEMORY_BASENAMES = ['memory.ts', 'memory.js'];\nconst INSTRUCTIONS_BASENAME = 'instructions.md';\nconst TOOL_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MODULE_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MD_BASENAME = 'SKILL.md';\n\n/**\n * Presence check that does NOT follow symlinks. Returns `false` for symlinks\n * (and broken links) so a symlinked `config.ts`/`instructions.md`/`workspace.ts`/\n * `memory.ts` is never inlined or imported into the generated bundle.\n */\nasync function exists(path: string): Promise<boolean> {\n try {\n return !(await lstat(path)).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Returns the slash-normalized path when `path` is a real directory (not a\n * symlink). Symlinked directories are rejected to prevent the build from\n * following links out of the project tree during discovery.\n */\nasync function realDirectory(path: string): Promise<string | undefined> {\n try {\n const info = await lstat(path);\n if (info.isDirectory() && !info.isSymbolicLink()) {\n return slash(path);\n }\n } catch {\n // not present\n }\n return undefined;\n}\n\nasync function directoryExists(path: string): Promise<string | undefined> {\n return realDirectory(path);\n}\n\nasync function firstExisting(dir: string, basenames: string[]): Promise<string | undefined> {\n for (const basename of basenames) {\n const candidate = join(dir, basename);\n if (await exists(candidate)) {\n return slash(candidate);\n }\n }\n return undefined;\n}\n\nfunction isTestFile(basename: string): boolean {\n return /\\.(test|spec)\\.(ts|js)$/.test(basename);\n}\n\nfunction toolKey(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverTools(toolsDir: string): Promise<DiscoveredFsAgent['tools']> {\n if (!(await exists(toolsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(toolsDir);\n } catch {\n return [];\n }\n\n const tools: DiscoveredFsAgent['tools'] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(toolsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks and\n // directories: a symlinked tool file could point anywhere on the build\n // machine and be embedded into generated import code.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n tools.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return tools;\n}\n\nasync function readReferences(referencesDir: string): Promise<Record<string, string>> {\n if (!(await exists(referencesDir))) {\n return {};\n }\n const references: Record<string, string> = {};\n let entries: string[];\n try {\n entries = await readdir(referencesDir);\n } catch {\n return {};\n }\n for (const basename of entries.sort()) {\n const path = join(referencesDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlink under `references/` could point anywhere on the build machine and\n // silently embed arbitrary file contents into the generated bundle.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n references[basename] = await readFile(path, 'utf-8');\n }\n return references;\n}\n\nasync function parsePackagedSkill(\n skillMdPath: string,\n fallbackName: string,\n references: Record<string, string> = {},\n): Promise<Extract<DiscoveredFsSkill, { kind: 'packaged' }>> {\n const raw = await readFile(skillMdPath, 'utf-8');\n const parsed = matter(raw);\n const frontmatter = parsed.data as { name?: string; description?: string };\n const name = frontmatter.name ?? fallbackName;\n const description = frontmatter.description ?? '';\n const instructions = parsed.content.trim();\n return { kind: 'packaged', name, description, instructions, references };\n}\n\nfunction skillModuleName(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverSkills(skillsDir: string): Promise<DiscoveredFsSkill[]> {\n if (!(await exists(skillsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(skillsDir);\n } catch {\n return [];\n }\n\n const skills: DiscoveredFsSkill[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n const path = join(skillsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlinked skill module/markdown could point anywhere on the build machine\n // and be bundled or inlined into the generated output.\n const stats = await lstat(path);\n if (stats.isSymbolicLink()) {\n continue;\n }\n const isDir = stats.isDirectory();\n\n // Packaged skill directory: <skill>/SKILL.md (+ references/)\n if (isDir) {\n const skillMd = join(path, SKILL_MD_BASENAME);\n if (await exists(skillMd)) {\n const references = await readReferences(join(path, 'references'));\n skills.push(await parsePackagedSkill(skillMd, skillModuleName(basename), references));\n }\n continue;\n }\n\n // createSkill module: <skill>.ts | <skill>.js\n if (SKILL_MODULE_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n skills.push({ kind: 'module', path: slash(path) });\n continue;\n }\n\n // Flat markdown skill: <skill>.md\n if (basename.endsWith('.md')) {\n const skill = await parsePackagedSkill(path, basename.replace(/\\.md$/, ''));\n skills.push(skill);\n }\n }\n\n return skills;\n}\n\n/**\n * Discover a single agent directory: its `config`/`instructions`/`workspace`\n * files plus `tools/`, `skills/`, and declared `subagents/`. Returns\n * `undefined` when `dir` is not an agent directory (no `config.(ts|js)` and no\n * `instructions.md`).\n *\n * `depth` is the subagent nesting level (`0` for top-level agents). Discovery\n * recurses into `subagents/` until `MAX_FS_SUBAGENT_DEPTH`; deeper directories\n * are ignored with a warning.\n */\nasync function discoverAgentDir(\n dir: string,\n name: string,\n depth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent | undefined> {\n const configPath = await firstExisting(dir, CONFIG_BASENAMES);\n const instructionsPath = (await exists(join(dir, INSTRUCTIONS_BASENAME)))\n ? slash(join(dir, INSTRUCTIONS_BASENAME))\n : undefined;\n\n // Not an agent directory unless it has a config or instructions file.\n if (!configPath && !instructionsPath) {\n return undefined;\n }\n\n const workspacePath = await firstExisting(dir, WORKSPACE_BASENAMES);\n const memoryPath = await firstExisting(dir, MEMORY_BASENAMES);\n const workspaceSeedDir = await directoryExists(join(dir, 'workspace'));\n const tools = await discoverTools(join(dir, 'tools'));\n const skills = await discoverSkills(join(dir, 'skills'));\n const subagents = await discoverSubagents(dir, depth, onWarn);\n\n return {\n name,\n dir: slash(dir),\n configPath,\n instructionsPath,\n workspacePath,\n memoryPath,\n workspaceSeedDir,\n tools,\n skills,\n subagents,\n };\n}\n\n/**\n * Discover declared subagents under `<dir>/subagents/*`. `parentDepth` is the\n * parent agent's nesting level (`0` for top-level agents). Discovery recurses\n * until `MAX_FS_SUBAGENT_DEPTH` levels of subagents; a `subagents/` directory\n * that would exceed the cap is skipped with a warning.\n */\nasync function discoverSubagents(\n parentDir: string,\n parentDepth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const subagentsDir = join(parentDir, 'subagents');\n if (!(await exists(subagentsDir))) {\n return [];\n }\n\n if (parentDepth >= MAX_FS_SUBAGENT_DEPTH) {\n onWarn?.(\n `Ignoring subagents in \"${slash(subagentsDir)}\": subagents may only nest ${MAX_FS_SUBAGENT_DEPTH} levels below a top-level agent.`,\n );\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(subagentsDir);\n } catch {\n return [];\n }\n\n const subagents: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(subagentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const child = await discoverAgentDir(dir, name, parentDepth + 1, onWarn);\n if (child) {\n subagents.push(child);\n }\n }\n\n return subagents;\n}\n\n/**\n * Scan `<mastraDir>/agents/*` for file-system routed agents. A directory is\n * treated as an agent only when it contains a `config.(ts|js)` or an\n * `instructions.md`; other directories are ignored. Each agent may declare\n * `subagents/` up to `MAX_FS_SUBAGENT_DEPTH` levels deep. Returns descriptors\n * with absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem inspection.\n */\nexport async function discoverFsAgents(\n mastraDir: string,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const agentsDir = join(mastraDir, 'agents');\n if (!(await exists(agentsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(agentsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(agentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const agent = await discoverAgentDir(dir, name, 0, onWarn);\n if (agent) {\n discovered.push(agent);\n }\n }\n\n return discovered;\n}\n","import { readFile } from 'node:fs/promises';\nimport type { DiscoveredFsAgent } from './discover';\n\nfunction sanitizeIdentifier(name: string, prefix: string, index: string): string {\n const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, '_');\n return `${prefix}_${index}_${cleaned}`;\n}\n\n/**\n * Emit the imports for a single discovered agent into `lines` and return the\n * source of its `assembleAgentFromFsEntry` entry object (the `{ name, config,\n * ... }` argument). `idPath` is a dot-free, unique path index (e.g. `0` for the\n * first top-level agent, `0_1` for its second subagent) used to keep generated\n * identifiers unique across the parent/child tree. `workspaceName` is the\n * slash-joined workspace key (`<parent>/<child>` for subagents) so seed files\n * don't collide. Discovered subagents are emitted recursively as a nested\n * `subagents: [...]` field (discovery already enforces the depth cap).\n */\nasync function emitAgentEntry(\n agent: DiscoveredFsAgent,\n idPath: string,\n workspaceName: string,\n lines: string[],\n): Promise<string> {\n const configIdent = sanitizeIdentifier(agent.name, 'config', idPath);\n const toolIdents: { key: string; ident: string }[] = [];\n\n if (agent.configPath) {\n lines.push(`import ${configIdent} from ${JSON.stringify(agent.configPath)};`);\n }\n\n let workspaceIdent: string | undefined;\n if (agent.workspacePath) {\n workspaceIdent = sanitizeIdentifier(`${agent.name}_workspace`, 'workspace', idPath);\n lines.push(`import ${workspaceIdent} from ${JSON.stringify(agent.workspacePath)};`);\n }\n\n let memoryIdent: string | undefined;\n if (agent.memoryPath) {\n memoryIdent = sanitizeIdentifier(`${agent.name}_memory`, 'memory', idPath);\n lines.push(`import ${memoryIdent} from ${JSON.stringify(agent.memoryPath)};`);\n }\n\n for (let t = 0; t < agent.tools.length; t++) {\n const tool = agent.tools[t]!;\n const ident = sanitizeIdentifier(`${agent.name}_${tool.key}`, 'tool', `${idPath}_${t}`);\n lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);\n toolIdents.push({ key: tool.key, ident });\n }\n\n // Skills: `createSkill(...)` modules are imported and used directly;\n // packaged `SKILL.md` skills are inlined via `createSkill({...})`.\n const skillExprs: string[] = [];\n const agentSkills = agent.skills ?? [];\n for (let s = 0; s < agentSkills.length; s++) {\n const skill = agentSkills[s]!;\n if (skill.kind === 'module') {\n const ident = sanitizeIdentifier(`${agent.name}_skill`, 'skill', `${idPath}_${s}`);\n lines.push(`import ${ident} from ${JSON.stringify(skill.path)};`);\n skillExprs.push(ident);\n } else {\n const referenceFields = Object.entries(skill.references).map(\n ([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n );\n const skillFields = [\n `name: ${JSON.stringify(skill.name)}`,\n `description: ${JSON.stringify(skill.description)}`,\n `instructions: ${JSON.stringify(skill.instructions)}`,\n ];\n if (referenceFields.length > 0) {\n skillFields.push(`references: { ${referenceFields.join(', ')} }`);\n }\n skillExprs.push(`__createSkill({ ${skillFields.join(', ')} })`);\n }\n }\n\n let instructionsMd: string | undefined;\n if (agent.instructionsPath) {\n instructionsMd = await readFile(agent.instructionsPath, 'utf-8');\n }\n\n // Declared subagents. Each is itself an `assembleAgentFromFsEntry` entry\n // object, recursively carrying its own `subagents`.\n const subagentExprs: string[] = [];\n for (let c = 0; c < agent.subagents.length; c++) {\n const child = agent.subagents[c]!;\n const childExpr = await emitAgentEntry(child, `${idPath}_${c}`, `${workspaceName}/${child.name}`, lines);\n subagentExprs.push(childExpr);\n }\n\n const entryFields: string[] = [`name: ${JSON.stringify(agent.name)}`];\n if (agent.configPath) {\n entryFields.push(`config: ${configIdent}`);\n }\n if (instructionsMd !== undefined) {\n entryFields.push(`instructionsMd: ${JSON.stringify(instructionsMd)}`);\n }\n if (toolIdents.length > 0) {\n const toolEntries = toolIdents.map(({ key, ident }) => `{ key: ${JSON.stringify(key)}, tool: ${ident} }`);\n entryFields.push(`tools: [${toolEntries.join(', ')}]`);\n }\n if (skillExprs.length > 0) {\n entryFields.push(`skills: [${skillExprs.join(', ')}]`);\n }\n if (subagentExprs.length > 0) {\n entryFields.push(`subagents: [${subagentExprs.join(', ')}]`);\n }\n if (workspaceIdent) {\n entryFields.push(`workspace: ${workspaceIdent}`);\n }\n if (memoryIdent) {\n entryFields.push(`memory: ${memoryIdent}`);\n }\n // Default-on parity: every FS agent gets a default workspace (file + shell\n // tools) rooted at a per-agent `workspace/` dir next to the bundle, unless\n // config.ts or workspace.ts supplies one. Assembly applies the explicit >\n // convention > default precedence. Subagents nest under `<parent>/<child>` so\n // their seed directories never collide with the parent's.\n entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);\n\n return `{ ${entryFields.join(', ')} }`;\n}\n\n/**\n * Generate the source of a wrapper module that:\n * 1. imports the user's real Mastra entry,\n * 2. imports each discovered `config.ts`, `tools/*.ts`, `skills/*.ts`\n * (`createSkill(...)` modules), `workspace.ts`, and `memory.ts`, inlining\n * packaged `SKILL.md` skills,\n * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any\n * declared `subagents/` into the parent (nested up to `MAX_FS_SUBAGENT_DEPTH`),\n * 4. registers them onto the user's `mastra` instance (code-registered agents\n * win on name collisions), and\n * 5. re-exports everything from the user's entry so this module is a drop-in\n * replacement for the original `#mastra` target.\n *\n * `instructions.md` contents are inlined at codegen time so no markdown loader\n * plugin is required in the bundler graph.\n *\n * @param userEntry slash-normalized absolute path to the user's mastra entry.\n * @param agents discovered fs-routed agents (absolute, slash-normalized paths).\n */\nexport async function generateFsAgentsModule(userEntry: string, agents: DiscoveredFsAgent[]): Promise<string> {\n const lines: string[] = [];\n\n const hasInlineSkills = (function check(list: DiscoveredFsAgent[]): boolean {\n return list.some(a => (a.skills ?? []).some(s => s.kind === 'packaged') || check(a.subagents ?? []));\n })(agents);\n\n lines.push(`import { assembleAgentFromFsEntry } from '@mastra/core/agent';`);\n if (hasInlineSkills) {\n lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);\n }\n lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);\n lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);\n lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);\n lines.push(`export * from ${JSON.stringify(userEntry)};`);\n lines.push(``);\n // Resolve workspace base paths relative to this bundled module so they point\n // at `<bundle>/workspace/<name>` wherever the bundle is deployed. Seed files\n // authored under `agents/<name>/workspace/**` are mirrored there at build time.\n // `name` may be a slash-joined path (`<parent>/<child>`) for subagents.\n lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);\n lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);\n lines.push(``);\n\n const entryExprs: string[] = [];\n for (let i = 0; i < agents.length; i++) {\n const agent = agents[i]!;\n const expr = await emitAgentEntry(agent, `${i}`, agent.name, lines);\n entryExprs.push(expr);\n }\n\n lines.push(``);\n lines.push(`const __fsAgentEntries = [`);\n for (const expr of entryExprs) {\n lines.push(` ${expr},`);\n }\n lines.push(`];`);\n lines.push(``);\n lines.push(`const __fsAgents = Object.create(null);`);\n lines.push(`for (const __entry of __fsAgentEntries) {`);\n lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);\n lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);\n lines.push(` });`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);\n lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`export const mastra = __userEntry.mastra;`);\n\n return lines.join('\\n');\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { slash } from '../utils';\nimport { generateFsAgentsModule } from './codegen';\nimport { discoverFsAgents } from './discover';\n\nexport interface PrepareFsAgentsEntryResult {\n /**\n * The entry file that should be fed to the bundler/analyzer. When fs-routed\n * agents are found this is a generated wrapper module that registers them onto\n * the user's mastra instance; otherwise it is the original entry unchanged.\n */\n entryFile: string;\n /**\n * Glob tool paths for tools defined under `agents/*\\/tools` so they are\n * bundled alongside the top-level `tools/` directory.\n */\n toolPaths: string[];\n /** Number of fs-routed agents discovered. */\n agentCount: number;\n /**\n * Generated wrapper source to write to {@link entryFile}, or `undefined` when\n * there are no fs-routed agents. The write is deferred so callers can run it\n * *after* `bundler.prepare()` empties the output directory — otherwise the\n * wrapper is wiped before the bundler reads it.\n */\n moduleSource?: string;\n}\n\n/**\n * Discover fs-routed agents under `<mastraDir>/agents/*` and, if any exist,\n * generate a wrapper entry module that registers them onto the user's mastra\n * instance. Returns the entry the bundler should use plus extra tool glob paths\n * so `agents/*\\/tools` are bundled.\n *\n * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with\n * the result after `bundler.prepare()` so the generated file is not wiped when\n * the output directory is emptied.\n *\n * When no fs-routed agents are present the original entry is returned unchanged,\n * so existing code-only projects are completely unaffected.\n */\nexport async function prepareFsAgentsEntry(\n mastraDir: string,\n entryFile: string,\n outputDirectory: string,\n): Promise<PrepareFsAgentsEntryResult> {\n const agents = await discoverFsAgents(mastraDir);\n\n if (agents.length === 0) {\n return { entryFile, toolPaths: [], agentCount: 0 };\n }\n\n const moduleSource = await generateFsAgentsModule(slash(entryFile), agents);\n const generatedEntry = join(outputDirectory, '.mastra-fs-agents-entry.mjs');\n\n const normalizedMastraDir = slash(mastraDir);\n const toolPaths = [\n posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{js,ts}'),\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/__tests__/**')}`,\n ];\n\n return { entryFile: generatedEntry, toolPaths, agentCount: agents.length, moduleSource };\n}\n\n/**\n * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}\n * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER\n * `bundler.prepare()` (which empties the output directory) so the wrapper\n * survives for the bundler/watcher to read.\n */\nexport async function writeFsAgentsEntry(result: PrepareFsAgentsEntryResult): Promise<void> {\n if (!result.moduleSource) {\n return;\n }\n\n await mkdir(dirname(result.entryFile), { recursive: true });\n await writeFile(result.entryFile, result.moduleSource, 'utf-8');\n}\n","import { cp, lstat, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { discoverFsAgents } from './discover';\nimport type { DiscoveredFsAgent } from './discover';\n\n/**\n * Skip symlinks when copying workspace seeds. A symlink under\n * `agents/<name>/workspace/` could point outside the workspace and be preserved\n * in the bundle, letting the agent read arbitrary files at runtime. We copy only\n * regular files and directories.\n */\nasync function rejectSymlinks(source: string): Promise<boolean> {\n const stats = await lstat(source);\n return !stats.isSymbolicLink();\n}\n\nasync function mirrorAgentSeeds(\n agent: DiscoveredFsAgent,\n workspaceName: string,\n bundleDir: string,\n mirrored: string[],\n): Promise<void> {\n if (agent.workspaceSeedDir) {\n const destination = join(bundleDir, 'workspace', ...workspaceName.split('/'));\n await mkdir(destination, { recursive: true });\n await cp(agent.workspaceSeedDir, destination, { recursive: true, filter: rejectSymlinks });\n mirrored.push(workspaceName);\n }\n\n // Subagents nest under `<parent>/<child>`, matching the codegen workspace key.\n for (const child of agent.subagents ?? []) {\n await mirrorAgentSeeds(child, `${workspaceName}/${child.name}`, bundleDir, mirrored);\n }\n}\n\n/**\n * Mirror authored `agents/<name>/workspace/**` seed files into the bundled\n * output so each fs-routed agent starts with them on disk (Eve parity). Files\n * are copied to `<bundleDir>/workspace/<name>`, which is exactly where the\n * generated entry roots each agent's default workspace at runtime (resolved\n * relative to the bundled module via `import.meta.url`). Declared subagents\n * mirror to the nested `<bundleDir>/workspace/<parent>/<child>` path.\n *\n * Must run AFTER the bundle step, since bundling recreates the output dir.\n *\n * @param mastraDir The user's `src/mastra` directory (source of seeds).\n * @param bundleDir The final bundle directory (e.g. `<outputDirectory>/output`).\n * @returns the workspace names whose seeds were mirrored (`<parent>/<child>` for subagents).\n */\nexport async function mirrorFsAgentWorkspaces(mastraDir: string, bundleDir: string): Promise<string[]> {\n const agents = await discoverFsAgents(mastraDir);\n const mirrored: string[] = [];\n\n for (const agent of agents) {\n await mirrorAgentSeeds(agent, agent.name, bundleDir, mirrored);\n }\n\n return mirrored;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/build/watcher.ts","../src/build/serverOptions.ts","../src/build/fs-routing/discover.ts","../src/build/fs-routing/codegen.ts","../src/build/fs-routing/prepare.ts","../src/build/fs-routing/mirror.ts"],"names":["getInputOptions","pkg","dirname","slash","getWorkspaceInformation","analyzeBundle","posix","noopLogger","getPackageName","tsConfigPaths","aliasHono","nodeModulesExtensionResolver","watch","extractMastraOption","lstat","join","readdir","path","readFile","matter","MAX_FS_SUBAGENT_DEPTH","mkdir","writeFile","cp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAsBA,gBAAAA,CACpB,SAAA,EACA,QAAA,EACA,GAAA,EACA;AAAA,EACE,SAAA,GAAY,KAAA;AAAA,EACZ,cAAA,GAAiB;AAAA,IAC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;AAGA,EAAA,KAAA,MAAW,KAAA,IAAS,KAAA,CAAM,SAAA,IAAa,EAAC,EAAG;AACzC,IAAA,MAAM,gBAAA,CAAiB,OAAO,CAAA,EAAG,aAAa,IAAI,KAAA,CAAM,IAAI,CAAA,CAAA,EAAI,SAAA,EAAW,QAAQ,CAAA;AAAA,EACrF;AACF;AAgBA,eAAsB,uBAAA,CAAwB,WAAmB,SAAA,EAAsC;AACrG,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,CAAiB,SAAS,CAAA;AAC/C,EAAA,MAAM,WAAqB,EAAC;AAE5B,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,MAAM,gBAAA,CAAiB,KAAA,EAAO,KAAA,CAAM,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,EAC/D;AAEA,EAAA,OAAO,QAAA;AACT","file":"chunk-YMYRP2K7.cjs","sourcesContent":["import { dirname, posix } from 'node:path';\nimport { noopLogger } from '@mastra/core/logger';\nimport * as pkg from 'empathic/package';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport { watch } from 'rollup';\nimport { getWorkspaceInformation } from '../bundler/workspaceDependencies';\nimport { analyzeBundle } from './analyze';\nimport { getInputOptions as getBundlerInputOptions } from './bundler';\nimport { aliasHono } from './plugins/hono-alias';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport type { BundlerOptions } from './types';\nimport { getPackageName, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n platform: BundlerPlatform,\n env?: Record<string, string>,\n {\n sourcemap = false,\n bundlerOptions = {\n enableSourcemap: false,\n enableEsmShim: true,\n externals: true,\n },\n analysisEntries = [entryFile],\n }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions; analysisEntries?: string[] } = {},\n) {\n const closestPkgJson = pkg.up({ cwd: dirname(entryFile) });\n const projectRoot = closestPkgJson ? dirname(slash(closestPkgJson)) : slash(process.cwd());\n const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: entryFile });\n\n const analyzeEntryResult = await analyzeBundle(\n analysisEntries,\n entryFile,\n {\n outputDir: posix.join(process.cwd(), '.mastra', '.build'),\n projectRoot: workspaceRoot || process.cwd(),\n platform,\n isDev: true,\n bundlerOptions,\n },\n noopLogger,\n );\n\n const deps = /* @__PURE__ */ new Map();\n for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {\n const pkgName = getPackageName(dep);\n if (pkgName && workspaceMap.has(pkgName)) {\n deps.set(dep, metadata);\n }\n }\n\n const inputOptions = await getBundlerInputOptions(\n entryFile,\n {\n dependencies: deps,\n externalDependencies: new Map(),\n workspaceMap,\n },\n platform,\n env,\n { sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true },\n );\n\n if (Array.isArray(inputOptions.plugins)) {\n // filter out node-resolve plugin so all node_modules are external\n // and tsconfig-paths plugin as we are injection a custom one\n const plugins = [] as Plugin[];\n inputOptions.plugins.forEach(plugin => {\n if ((plugin as Plugin | undefined)?.name === 'node-resolve') {\n return;\n }\n\n if ((plugin as Plugin | undefined)?.name === 'tsconfig-paths') {\n plugins.push(\n tsConfigPaths({\n localResolve: true,\n }),\n );\n return;\n }\n\n plugins.push(plugin as Plugin);\n });\n\n inputOptions.plugins = plugins;\n inputOptions.plugins.push(aliasHono());\n // fixes imports like lodash/fp/get\n inputOptions.plugins.push(nodeModulesExtensionResolver());\n }\n\n return inputOptions;\n}\n\nexport async function createWatcher(inputOptions: InputOptions, outputOptions: OutputOptions) {\n const watcher = await watch({\n ...inputOptions,\n output: {\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n },\n });\n\n return watcher;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getServerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('server', entryFile, result);\n}\n\nexport async function getServerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['server'] | null> {\n const result = await extractMastraOption('server', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n","import { lstat, readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { MAX_FS_SUBAGENT_DEPTH } from '@mastra/core/agent';\nimport matter from 'gray-matter';\nimport { slash } from '../utils';\n\n/**\n * A file-system routed agent directory discovered under `<mastraDir>/agents/`.\n * All paths are absolute and slash-normalized so they can be embedded into\n * generated module source on any platform.\n */\nexport interface DiscoveredFsAgent {\n /** Agent directory name. Used as the default `id`/`name`. */\n name: string;\n /** Absolute, slash-normalized path to the agent directory. */\n dir: string;\n /** Absolute path to `config.ts`/`config.js`, if present. */\n configPath?: string;\n /** Absolute path to `instructions.md`, if present. */\n instructionsPath?: string;\n /** Absolute path to `workspace.ts`/`workspace.js`, if present. */\n workspacePath?: string;\n /** Absolute path to `memory.ts`/`memory.js`, if present. */\n memoryPath?: string;\n /**\n * Absolute, slash-normalized path to an authored `workspace/` directory of\n * seed files, if present. These are mirrored into the deployed workspace at\n * build time (Eve parity) so the agent starts with them on disk.\n */\n workspaceSeedDir?: string;\n /** Tools discovered under `tools/`, in stable (sorted) order. */\n tools: { key: string; path: string }[];\n /** Skills discovered under `skills/`, in stable (sorted) order. */\n skills: DiscoveredFsSkill[];\n /**\n * Declared subagents discovered under `subagents/`, in stable (sorted) order.\n * Subagents may declare their own `subagents/`, up to `MAX_FS_SUBAGENT_DEPTH`\n * levels below the top-level agent; deeper `subagents/` directories are\n * ignored with a warning.\n */\n subagents: DiscoveredFsAgent[];\n}\n\n/**\n * A skill discovered under `agents/<name>/skills/`.\n *\n * - `kind: 'module'` — a `.ts`/`.js` file whose default export is a `createSkill(...)`\n * result. Codegen imports it directly; `name`/`description`/`instructions` are\n * unknown at discovery time and resolved at runtime from the module.\n * - `kind: 'packaged'` — a `SKILL.md` (optionally with a `references/` subdir) or a\n * flat `<skill>.md`. Codegen inlines it via `createSkill(...)` using the parsed\n * fields below so the deployed bundle carries no filesystem dependency.\n */\nexport type DiscoveredFsSkill =\n | {\n kind: 'module';\n /** Absolute, slash-normalized path to the `.ts`/`.js` skill module. */\n path: string;\n }\n | {\n kind: 'packaged';\n name: string;\n description: string;\n instructions: string;\n /** Reference file contents keyed by relative path (from `references/`). */\n references: Record<string, string>;\n };\n\nconst CONFIG_BASENAMES = ['config.ts', 'config.js'];\nconst WORKSPACE_BASENAMES = ['workspace.ts', 'workspace.js'];\nconst MEMORY_BASENAMES = ['memory.ts', 'memory.js'];\nconst INSTRUCTIONS_BASENAME = 'instructions.md';\nconst TOOL_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MODULE_EXTENSIONS = ['.ts', '.js'];\nconst SKILL_MD_BASENAME = 'SKILL.md';\n\n/**\n * Presence check that does NOT follow symlinks. Returns `false` for symlinks\n * (and broken links) so a symlinked `config.ts`/`instructions.md`/`workspace.ts`/\n * `memory.ts` is never inlined or imported into the generated bundle.\n */\nasync function exists(path: string): Promise<boolean> {\n try {\n return !(await lstat(path)).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Returns the slash-normalized path when `path` is a real directory (not a\n * symlink). Symlinked directories are rejected to prevent the build from\n * following links out of the project tree during discovery.\n */\nasync function realDirectory(path: string): Promise<string | undefined> {\n try {\n const info = await lstat(path);\n if (info.isDirectory() && !info.isSymbolicLink()) {\n return slash(path);\n }\n } catch {\n // not present\n }\n return undefined;\n}\n\nasync function directoryExists(path: string): Promise<string | undefined> {\n return realDirectory(path);\n}\n\nasync function firstExisting(dir: string, basenames: string[]): Promise<string | undefined> {\n for (const basename of basenames) {\n const candidate = join(dir, basename);\n if (await exists(candidate)) {\n return slash(candidate);\n }\n }\n return undefined;\n}\n\nfunction isTestFile(basename: string): boolean {\n return /\\.(test|spec)\\.(ts|js)$/.test(basename);\n}\n\nfunction toolKey(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverTools(toolsDir: string): Promise<DiscoveredFsAgent['tools']> {\n if (!(await exists(toolsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(toolsDir);\n } catch {\n return [];\n }\n\n const tools: DiscoveredFsAgent['tools'] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n if (!TOOL_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n continue;\n }\n const path = join(toolsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks and\n // directories: a symlinked tool file could point anywhere on the build\n // machine and be embedded into generated import code.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n tools.push({ key: toolKey(basename), path: slash(path) });\n }\n\n return tools;\n}\n\nasync function readReferences(referencesDir: string): Promise<Record<string, string>> {\n if (!(await exists(referencesDir))) {\n return {};\n }\n const references: Record<string, string> = {};\n let entries: string[];\n try {\n entries = await readdir(referencesDir);\n } catch {\n return {};\n }\n for (const basename of entries.sort()) {\n const path = join(referencesDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlink under `references/` could point anywhere on the build machine and\n // silently embed arbitrary file contents into the generated bundle.\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || stats.isDirectory()) {\n continue;\n }\n references[basename] = await readFile(path, 'utf-8');\n }\n return references;\n}\n\nasync function parsePackagedSkill(\n skillMdPath: string,\n fallbackName: string,\n references: Record<string, string> = {},\n): Promise<Extract<DiscoveredFsSkill, { kind: 'packaged' }>> {\n const raw = await readFile(skillMdPath, 'utf-8');\n const parsed = matter(raw);\n const frontmatter = parsed.data as { name?: string; description?: string };\n const name = frontmatter.name ?? fallbackName;\n const description = frontmatter.description ?? '';\n const instructions = parsed.content.trim();\n return { kind: 'packaged', name, description, instructions, references };\n}\n\nfunction skillModuleName(basename: string): string {\n return basename.replace(/\\.(ts|js)$/, '');\n}\n\nasync function discoverSkills(skillsDir: string): Promise<DiscoveredFsSkill[]> {\n if (!(await exists(skillsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(skillsDir);\n } catch {\n return [];\n }\n\n const skills: DiscoveredFsSkill[] = [];\n for (const basename of entries.sort()) {\n if (isTestFile(basename)) {\n continue;\n }\n const path = join(skillsDir, basename);\n // Use lstat so symlinks are detected (not followed). Skip symlinks: a\n // symlinked skill module/markdown could point anywhere on the build machine\n // and be bundled or inlined into the generated output.\n const stats = await lstat(path);\n if (stats.isSymbolicLink()) {\n continue;\n }\n const isDir = stats.isDirectory();\n\n // Packaged skill directory: <skill>/SKILL.md (+ references/)\n if (isDir) {\n const skillMd = join(path, SKILL_MD_BASENAME);\n if (await exists(skillMd)) {\n const references = await readReferences(join(path, 'references'));\n skills.push(await parsePackagedSkill(skillMd, skillModuleName(basename), references));\n }\n continue;\n }\n\n // createSkill module: <skill>.ts | <skill>.js\n if (SKILL_MODULE_EXTENSIONS.some(ext => basename.endsWith(ext))) {\n skills.push({ kind: 'module', path: slash(path) });\n continue;\n }\n\n // Flat markdown skill: <skill>.md\n if (basename.endsWith('.md')) {\n const skill = await parsePackagedSkill(path, basename.replace(/\\.md$/, ''));\n skills.push(skill);\n }\n }\n\n return skills;\n}\n\n/**\n * Discover a single agent directory: its `config`/`instructions`/`workspace`\n * files plus `tools/`, `skills/`, and declared `subagents/`. Returns\n * `undefined` when `dir` is not an agent directory (no `config.(ts|js)` and no\n * `instructions.md`).\n *\n * `depth` is the subagent nesting level (`0` for top-level agents). Discovery\n * recurses into `subagents/` until `MAX_FS_SUBAGENT_DEPTH`; deeper directories\n * are ignored with a warning.\n */\nasync function discoverAgentDir(\n dir: string,\n name: string,\n depth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent | undefined> {\n const configPath = await firstExisting(dir, CONFIG_BASENAMES);\n const instructionsPath = (await exists(join(dir, INSTRUCTIONS_BASENAME)))\n ? slash(join(dir, INSTRUCTIONS_BASENAME))\n : undefined;\n\n // Not an agent directory unless it has a config or instructions file.\n if (!configPath && !instructionsPath) {\n return undefined;\n }\n\n const workspacePath = await firstExisting(dir, WORKSPACE_BASENAMES);\n const memoryPath = await firstExisting(dir, MEMORY_BASENAMES);\n const workspaceSeedDir = await directoryExists(join(dir, 'workspace'));\n const tools = await discoverTools(join(dir, 'tools'));\n const skills = await discoverSkills(join(dir, 'skills'));\n const subagents = await discoverSubagents(dir, depth, onWarn);\n\n return {\n name,\n dir: slash(dir),\n configPath,\n instructionsPath,\n workspacePath,\n memoryPath,\n workspaceSeedDir,\n tools,\n skills,\n subagents,\n };\n}\n\n/**\n * Discover declared subagents under `<dir>/subagents/*`. `parentDepth` is the\n * parent agent's nesting level (`0` for top-level agents). Discovery recurses\n * until `MAX_FS_SUBAGENT_DEPTH` levels of subagents; a `subagents/` directory\n * that would exceed the cap is skipped with a warning.\n */\nasync function discoverSubagents(\n parentDir: string,\n parentDepth: number,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const subagentsDir = join(parentDir, 'subagents');\n if (!(await exists(subagentsDir))) {\n return [];\n }\n\n if (parentDepth >= MAX_FS_SUBAGENT_DEPTH) {\n onWarn?.(\n `Ignoring subagents in \"${slash(subagentsDir)}\": subagents may only nest ${MAX_FS_SUBAGENT_DEPTH} levels below a top-level agent.`,\n );\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(subagentsDir);\n } catch {\n return [];\n }\n\n const subagents: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(subagentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const child = await discoverAgentDir(dir, name, parentDepth + 1, onWarn);\n if (child) {\n subagents.push(child);\n }\n }\n\n return subagents;\n}\n\n/**\n * Scan `<mastraDir>/agents/*` for file-system routed agents. A directory is\n * treated as an agent only when it contains a `config.(ts|js)` or an\n * `instructions.md`; other directories are ignored. Each agent may declare\n * `subagents/` up to `MAX_FS_SUBAGENT_DEPTH` levels deep. Returns descriptors\n * with absolute, slash-normalized paths ready for codegen. Performs no module\n * evaluation — only filesystem inspection.\n */\nexport async function discoverFsAgents(\n mastraDir: string,\n onWarn?: (message: string) => void,\n): Promise<DiscoveredFsAgent[]> {\n const agentsDir = join(mastraDir, 'agents');\n if (!(await exists(agentsDir))) {\n return [];\n }\n\n let entries: string[];\n try {\n entries = await readdir(agentsDir);\n } catch {\n return [];\n }\n\n const discovered: DiscoveredFsAgent[] = [];\n for (const name of entries.sort()) {\n const dir = join(agentsDir, name);\n if (!(await realDirectory(dir))) {\n continue;\n }\n const agent = await discoverAgentDir(dir, name, 0, onWarn);\n if (agent) {\n discovered.push(agent);\n }\n }\n\n return discovered;\n}\n","import { readFile } from 'node:fs/promises';\nimport type { DiscoveredFsAgent } from './discover';\n\nfunction sanitizeIdentifier(name: string, prefix: string, index: string): string {\n const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, '_');\n return `${prefix}_${index}_${cleaned}`;\n}\n\n/**\n * Emit the imports for a single discovered agent into `lines` and return the\n * source of its `assembleAgentFromFsEntry` entry object (the `{ name, config,\n * ... }` argument). `idPath` is a dot-free, unique path index (e.g. `0` for the\n * first top-level agent, `0_1` for its second subagent) used to keep generated\n * identifiers unique across the parent/child tree. `workspaceName` is the\n * slash-joined workspace key (`<parent>/<child>` for subagents) so seed files\n * don't collide. Discovered subagents are emitted recursively as a nested\n * `subagents: [...]` field (discovery already enforces the depth cap).\n */\nasync function emitAgentEntry(\n agent: DiscoveredFsAgent,\n idPath: string,\n workspaceName: string,\n lines: string[],\n): Promise<string> {\n const configIdent = sanitizeIdentifier(agent.name, 'config', idPath);\n const toolIdents: { key: string; ident: string }[] = [];\n\n if (agent.configPath) {\n lines.push(`import ${configIdent} from ${JSON.stringify(agent.configPath)};`);\n }\n\n let workspaceIdent: string | undefined;\n if (agent.workspacePath) {\n workspaceIdent = sanitizeIdentifier(`${agent.name}_workspace`, 'workspace', idPath);\n lines.push(`import ${workspaceIdent} from ${JSON.stringify(agent.workspacePath)};`);\n }\n\n let memoryIdent: string | undefined;\n if (agent.memoryPath) {\n memoryIdent = sanitizeIdentifier(`${agent.name}_memory`, 'memory', idPath);\n lines.push(`import ${memoryIdent} from ${JSON.stringify(agent.memoryPath)};`);\n }\n\n for (let t = 0; t < agent.tools.length; t++) {\n const tool = agent.tools[t]!;\n const ident = sanitizeIdentifier(`${agent.name}_${tool.key}`, 'tool', `${idPath}_${t}`);\n lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);\n toolIdents.push({ key: tool.key, ident });\n }\n\n // Skills: `createSkill(...)` modules are imported and used directly;\n // packaged `SKILL.md` skills are inlined via `createSkill({...})`.\n const skillExprs: string[] = [];\n const agentSkills = agent.skills ?? [];\n for (let s = 0; s < agentSkills.length; s++) {\n const skill = agentSkills[s]!;\n if (skill.kind === 'module') {\n const ident = sanitizeIdentifier(`${agent.name}_skill`, 'skill', `${idPath}_${s}`);\n lines.push(`import ${ident} from ${JSON.stringify(skill.path)};`);\n skillExprs.push(ident);\n } else {\n const referenceFields = Object.entries(skill.references).map(\n ([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n );\n const skillFields = [\n `name: ${JSON.stringify(skill.name)}`,\n `description: ${JSON.stringify(skill.description)}`,\n `instructions: ${JSON.stringify(skill.instructions)}`,\n ];\n if (referenceFields.length > 0) {\n skillFields.push(`references: { ${referenceFields.join(', ')} }`);\n }\n skillExprs.push(`__createSkill({ ${skillFields.join(', ')} })`);\n }\n }\n\n let instructionsMd: string | undefined;\n if (agent.instructionsPath) {\n instructionsMd = await readFile(agent.instructionsPath, 'utf-8');\n }\n\n // Declared subagents. Each is itself an `assembleAgentFromFsEntry` entry\n // object, recursively carrying its own `subagents`.\n const subagentExprs: string[] = [];\n for (let c = 0; c < agent.subagents.length; c++) {\n const child = agent.subagents[c]!;\n const childExpr = await emitAgentEntry(child, `${idPath}_${c}`, `${workspaceName}/${child.name}`, lines);\n subagentExprs.push(childExpr);\n }\n\n const entryFields: string[] = [`name: ${JSON.stringify(agent.name)}`];\n if (agent.configPath) {\n entryFields.push(`config: ${configIdent}`);\n }\n if (instructionsMd !== undefined) {\n entryFields.push(`instructionsMd: ${JSON.stringify(instructionsMd)}`);\n }\n if (toolIdents.length > 0) {\n const toolEntries = toolIdents.map(({ key, ident }) => `{ key: ${JSON.stringify(key)}, tool: ${ident} }`);\n entryFields.push(`tools: [${toolEntries.join(', ')}]`);\n }\n if (skillExprs.length > 0) {\n entryFields.push(`skills: [${skillExprs.join(', ')}]`);\n }\n if (subagentExprs.length > 0) {\n entryFields.push(`subagents: [${subagentExprs.join(', ')}]`);\n }\n if (workspaceIdent) {\n entryFields.push(`workspace: ${workspaceIdent}`);\n }\n if (memoryIdent) {\n entryFields.push(`memory: ${memoryIdent}`);\n }\n // Default-on parity: every FS agent gets a default workspace (file + shell\n // tools) rooted at a per-agent `workspace/` dir next to the bundle, unless\n // config.ts or workspace.ts supplies one. Assembly applies the explicit >\n // convention > default precedence. Subagents nest under `<parent>/<child>` so\n // their seed directories never collide with the parent's.\n entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);\n\n return `{ ${entryFields.join(', ')} }`;\n}\n\n/**\n * Generate the source of a wrapper module that:\n * 1. imports the user's real Mastra entry,\n * 2. imports each discovered `config.ts`, `tools/*.ts`, `skills/*.ts`\n * (`createSkill(...)` modules), `workspace.ts`, and `memory.ts`, inlining\n * packaged `SKILL.md` skills,\n * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any\n * declared `subagents/` into the parent (nested up to `MAX_FS_SUBAGENT_DEPTH`),\n * 4. registers them onto the user's `mastra` instance (code-registered agents\n * win on name collisions), and\n * 5. re-exports everything from the user's entry so this module is a drop-in\n * replacement for the original `#mastra` target.\n *\n * `instructions.md` contents are inlined at codegen time so no markdown loader\n * plugin is required in the bundler graph.\n *\n * @param userEntry slash-normalized absolute path to the user's mastra entry.\n * @param agents discovered fs-routed agents (absolute, slash-normalized paths).\n */\nexport async function generateFsAgentsModule(userEntry: string, agents: DiscoveredFsAgent[]): Promise<string> {\n const lines: string[] = [];\n\n const hasInlineSkills = (function check(list: DiscoveredFsAgent[]): boolean {\n return list.some(a => (a.skills ?? []).some(s => s.kind === 'packaged') || check(a.subagents ?? []));\n })(agents);\n\n lines.push(`import { assembleAgentFromFsEntry } from '@mastra/core/agent';`);\n if (hasInlineSkills) {\n lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);\n }\n lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);\n lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);\n lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);\n lines.push(`export * from ${JSON.stringify(userEntry)};`);\n lines.push(``);\n // Resolve workspace base paths relative to this bundled module so they point\n // at `<bundle>/workspace/<name>` wherever the bundle is deployed. Seed files\n // authored under `agents/<name>/workspace/**` are mirrored there at build time.\n // `name` may be a slash-joined path (`<parent>/<child>`) for subagents.\n lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);\n lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);\n lines.push(``);\n\n const entryExprs: string[] = [];\n for (let i = 0; i < agents.length; i++) {\n const agent = agents[i]!;\n const expr = await emitAgentEntry(agent, `${i}`, agent.name, lines);\n entryExprs.push(expr);\n }\n\n lines.push(``);\n lines.push(`const __fsAgentEntries = [`);\n for (const expr of entryExprs) {\n lines.push(` ${expr},`);\n }\n lines.push(`];`);\n lines.push(``);\n lines.push(`const __fsAgents = Object.create(null);`);\n lines.push(`for (const __entry of __fsAgentEntries) {`);\n lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);\n lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);\n lines.push(` });`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);\n lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);\n lines.push(`}`);\n lines.push(``);\n lines.push(`export const mastra = __userEntry.mastra;`);\n\n return lines.join('\\n');\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { slash } from '../utils';\nimport { generateFsAgentsModule } from './codegen';\nimport { discoverFsAgents } from './discover';\n\nexport interface PrepareFsAgentsEntryResult {\n /**\n * The entry file that should be fed to the bundler/analyzer. When fs-routed\n * agents are found this is a generated wrapper module that registers them onto\n * the user's mastra instance; otherwise it is the original entry unchanged.\n */\n entryFile: string;\n /**\n * Glob tool paths for tools defined under `agents/*\\/tools` so they are\n * bundled alongside the top-level `tools/` directory.\n */\n toolPaths: string[];\n /** Number of fs-routed agents discovered. */\n agentCount: number;\n /**\n * Generated wrapper source to write to {@link entryFile}, or `undefined` when\n * there are no fs-routed agents. The write is deferred so callers can run it\n * *after* `bundler.prepare()` empties the output directory — otherwise the\n * wrapper is wiped before the bundler reads it.\n */\n moduleSource?: string;\n}\n\n/**\n * Discover fs-routed agents under `<mastraDir>/agents/*` and, if any exist,\n * generate a wrapper entry module that registers them onto the user's mastra\n * instance. Returns the entry the bundler should use plus extra tool glob paths\n * so `agents/*\\/tools` are bundled.\n *\n * This does NOT write the wrapper to disk; call {@link writeFsAgentsEntry} with\n * the result after `bundler.prepare()` so the generated file is not wiped when\n * the output directory is emptied.\n *\n * When no fs-routed agents are present the original entry is returned unchanged,\n * so existing code-only projects are completely unaffected.\n */\nexport async function prepareFsAgentsEntry(\n mastraDir: string,\n entryFile: string,\n outputDirectory: string,\n): Promise<PrepareFsAgentsEntryResult> {\n const agents = await discoverFsAgents(mastraDir);\n\n if (agents.length === 0) {\n return { entryFile, toolPaths: [], agentCount: 0 };\n }\n\n const moduleSource = await generateFsAgentsModule(slash(entryFile), agents);\n const generatedEntry = join(outputDirectory, '.mastra-fs-agents-entry.mjs');\n\n const normalizedMastraDir = slash(mastraDir);\n const toolPaths = [\n posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{js,ts}'),\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'agents/*/tools/**/__tests__/**')}`,\n ];\n\n return { entryFile: generatedEntry, toolPaths, agentCount: agents.length, moduleSource };\n}\n\n/**\n * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}\n * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER\n * `bundler.prepare()` (which empties the output directory) so the wrapper\n * survives for the bundler/watcher to read.\n */\nexport async function writeFsAgentsEntry(result: PrepareFsAgentsEntryResult): Promise<void> {\n if (!result.moduleSource) {\n return;\n }\n\n await mkdir(dirname(result.entryFile), { recursive: true });\n await writeFile(result.entryFile, result.moduleSource, 'utf-8');\n}\n","import { cp, lstat, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { discoverFsAgents } from './discover';\nimport type { DiscoveredFsAgent } from './discover';\n\n/**\n * Skip symlinks when copying workspace seeds. A symlink under\n * `agents/<name>/workspace/` could point outside the workspace and be preserved\n * in the bundle, letting the agent read arbitrary files at runtime. We copy only\n * regular files and directories.\n */\nasync function rejectSymlinks(source: string): Promise<boolean> {\n const stats = await lstat(source);\n return !stats.isSymbolicLink();\n}\n\nasync function mirrorAgentSeeds(\n agent: DiscoveredFsAgent,\n workspaceName: string,\n bundleDir: string,\n mirrored: string[],\n): Promise<void> {\n if (agent.workspaceSeedDir) {\n const destination = join(bundleDir, 'workspace', ...workspaceName.split('/'));\n await mkdir(destination, { recursive: true });\n await cp(agent.workspaceSeedDir, destination, { recursive: true, filter: rejectSymlinks });\n mirrored.push(workspaceName);\n }\n\n // Subagents nest under `<parent>/<child>`, matching the codegen workspace key.\n for (const child of agent.subagents ?? []) {\n await mirrorAgentSeeds(child, `${workspaceName}/${child.name}`, bundleDir, mirrored);\n }\n}\n\n/**\n * Mirror authored `agents/<name>/workspace/**` seed files into the bundled\n * output so each fs-routed agent starts with them on disk (Eve parity). Files\n * are copied to `<bundleDir>/workspace/<name>`, which is exactly where the\n * generated entry roots each agent's default workspace at runtime (resolved\n * relative to the bundled module via `import.meta.url`). Declared subagents\n * mirror to the nested `<bundleDir>/workspace/<parent>/<child>` path.\n *\n * Must run AFTER the bundle step, since bundling recreates the output dir.\n *\n * @param mastraDir The user's `src/mastra` directory (source of seeds).\n * @param bundleDir The final bundle directory (e.g. `<outputDirectory>/output`).\n * @returns the workspace names whose seeds were mirrored (`<parent>/<child>` for subagents).\n */\nexport async function mirrorFsAgentWorkspaces(mastraDir: string, bundleDir: string): Promise<string[]> {\n const agents = await discoverFsAgents(mastraDir);\n const mirrored: string[] = [];\n\n for (const agent of agents) {\n await mirrorAgentSeeds(agent, agent.name, bundleDir, mirrored);\n }\n\n return mirrored;\n}\n"]}