@mastra/deployer 1.50.0-alpha.4 → 1.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,154 @@
1
1
  # @mastra/deployer
2
2
 
3
+ ## 1.50.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Auto-construct a Mastra instance when no `index.ts` exists. If your `src/mastra` ([#18893](https://github.com/mastra-ai/mastra/pull/18893))
8
+ directory has file-based primitives but no entry file, `mastra dev` and
9
+ `mastra build` now build and run the project without any boilerplate — no
10
+ `new Mastra({...})` required.
11
+
12
+ ```
13
+ src/mastra/
14
+ storage.ts // export default new LibSQLStore({ url: 'file:./mastra.db' })
15
+ observability.ts // export default new Observability({ ... })
16
+ server.ts // export default { port: 4111 }
17
+ studio.ts // export default { ... }
18
+ agents/weather/ // file-based agent
19
+ workflows/report.ts // export default createWorkflow({ ... })
20
+ ```
21
+
22
+ ```sh
23
+ # No src/mastra/index.ts needed:
24
+ mastra dev
25
+ ```
26
+
27
+ Projects that already export a `mastra` instance from `index.ts` are unaffected.
28
+
29
+ - Added file-system-routed observability singleton. Place an `observability.ts` file in your mastra directory that default-exports an `ObservabilityEntrypoint`, and it will be auto-discovered and registered when running `mastra dev` or `mastra build`. Code-registered observability takes precedence if both are present. ([#18887](https://github.com/mastra-ai/mastra/pull/18887))
30
+
31
+ ```ts
32
+ // src/mastra/observability.ts
33
+ import { Observability, MastraStorageExporter } from '@mastra/observability';
34
+
35
+ export default new Observability({
36
+ configs: { default: { serviceName: 'mastra', exporters: [new MastraStorageExporter()] } },
37
+ });
38
+ ```
39
+
40
+ - Added file-system routed storage support. A `storage.ts` file under the mastra directory is now auto-discovered and registered during `mastra dev` / `mastra build`. The default export replaces the InMemoryStore fallback. Code-registered storage (passed to `new Mastra({storage})`) wins on collision. ([#18885](https://github.com/mastra-ai/mastra/pull/18885))
41
+
42
+ ```ts
43
+ // src/mastra/storage.ts
44
+ import { LibSQLStore } from '@mastra/libsql';
45
+
46
+ export default new LibSQLStore({ url: 'file:local.db' });
47
+ ```
48
+
49
+ - 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))
50
+
51
+ ```ts
52
+ // src/mastra/workflows/onboarding.ts
53
+ import { createWorkflow } from '@mastra/core/workflows';
54
+
55
+ export default createWorkflow({ id: 'onboarding' /* ...steps */ });
56
+ ```
57
+
58
+ - Added file-system routed server config singleton. Place a server.ts file in your mastra directory that default-exports a ServerConfig object, and it will be auto-discovered and registered when running mastra dev or mastra build. Code-registered server config takes precedence if both are present. ([#18888](https://github.com/mastra-ai/mastra/pull/18888))
59
+
60
+ - Added file-system-routed agent processors. Place input and output processor files under `agents/<name>/processors/input/` and `agents/<name>/processors/output/`. Each file default-exports a processor, and they are auto-discovered and merged with config-defined processors when running `mastra dev` or `mastra build`. Config-defined processors run first, and a dynamic (function) `inputProcessors`/`outputProcessors` in `config.ts` takes precedence over discovered files. ([#18890](https://github.com/mastra-ai/mastra/pull/18890))
61
+
62
+ ```
63
+ src/mastra/agents/support/
64
+ ├── config.ts
65
+ ├── instructions.md
66
+ └── processors/
67
+ ├── input/
68
+ │ └── moderation.ts
69
+ └── output/
70
+ └── redact-pii.ts
71
+ ```
72
+
73
+ ```ts
74
+ // src/mastra/agents/support/processors/input/moderation.ts
75
+ import { ModerationProcessor } from '@mastra/core/processors';
76
+
77
+ export default new ModerationProcessor({ model: 'openai/gpt-5-nano' });
78
+ ```
79
+
80
+ - Added file-system routed studio config singleton. Place a studio.ts file in your mastra directory that default-exports a StudioConfig object, and it will be auto-discovered and registered when running mastra dev or mastra build. Code-registered studio config takes precedence if both are present. ([#18889](https://github.com/mastra-ai/mastra/pull/18889))
81
+
82
+ ### Patch Changes
83
+
84
+ - Fixed production builds so transitive workspace packages are bundled instead of being left as runtime imports. ([#18879](https://github.com/mastra-ai/mastra/pull/18879))
85
+
86
+ - Fixed flat markdown skills crashing at runtime when missing a description in frontmatter. Discovery now fails early with a clear error pointing to the file and the Agent Skills spec. ([#18935](https://github.com/mastra-ai/mastra/pull/18935))
87
+
88
+ - Fixed deployer output dependency versions for packages that do not export package.json. ([#18930](https://github.com/mastra-ai/mastra/pull/18930))
89
+
90
+ - Fixed Studio HTML config injection so platform environment values are escaped before they are embedded in served or deployed `index.html` files. This keeps organization IDs, project IDs, observability endpoints and telemetry flags intact when they contain quotes, angle brackets, newlines or `$` sequences, and exposes `escapeStudioHtmlValue` from `@mastra/deployer/build` for the shared injection paths. ([#18812](https://github.com/mastra-ai/mastra/pull/18812))
91
+
92
+ - Update `@mastra/core` peer dependency for the unified schedules API ([#18874](https://github.com/mastra-ai/mastra/pull/18874))
93
+
94
+ - Hardened several string-parsing code paths against regular-expression denial of service (ReDoS). Path normalization, URL trimming, LLM token stripping, and observation parsing now use linear-time string scanning instead of regexes that could back-track polynomially on adversarial input. No behavior changes. ([#18801](https://github.com/mastra-ai/mastra/pull/18801))
95
+
96
+ - Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`6ef59fe`](https://github.com/mastra-ai/mastra/commit/6ef59fef1da52ed8da5fbb2a892c71cf4fb6c739), [`4039488`](https://github.com/mastra-ai/mastra/commit/403948898af7293198d9e8b3e7fb47f623c78b94), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`b2c9d70`](https://github.com/mastra-ai/mastra/commit/b2c9d70757207fb01a9069549e69b6f0d73a6636), [`a51c63d`](https://github.com/mastra-ai/mastra/commit/a51c63d8ee639e4daeba2a0be093efa6a1b5e52f), [`252f63d`](https://github.com/mastra-ai/mastra/commit/252f63d8fec723955adb2202be2f01a75ad0e69c), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`e2b9f33`](https://github.com/mastra-ai/mastra/commit/e2b9f33456fd638eca555f9466c6519d8d049666), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`c547a77`](https://github.com/mastra-ai/mastra/commit/c547a7729bdf64dfc2df29c965046c0712a18f10), [`a0085fa`](https://github.com/mastra-ai/mastra/commit/a0085fa0934e52c37c8c8b3d75a6bb5cd199af36), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`d889c04`](https://github.com/mastra-ai/mastra/commit/d889c046468a97ba9e90007dbca729b4fecf5db0), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`81542c1`](https://github.com/mastra-ai/mastra/commit/81542c1835c35bc32f2ce4fa9136ee11993cd299), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`cb24ce7`](https://github.com/mastra-ai/mastra/commit/cb24ce76bd16ca88eb6a963f6277f8780e703029), [`02705fd`](https://github.com/mastra-ai/mastra/commit/02705fd2f5a9062210d64ea061adeeb10dc9452e), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964), [`5f9858f`](https://github.com/mastra-ai/mastra/commit/5f9858f791f1137ca7d52d23559fb4568f7a9026)]:
97
+ - @mastra/core@1.50.0
98
+ - @mastra/server@1.50.0
99
+
100
+ ## 1.50.0-alpha.5
101
+
102
+ ### Minor Changes
103
+
104
+ - Auto-construct a Mastra instance when no `index.ts` exists. If your `src/mastra` ([#18893](https://github.com/mastra-ai/mastra/pull/18893))
105
+ directory has file-based primitives but no entry file, `mastra dev` and
106
+ `mastra build` now build and run the project without any boilerplate — no
107
+ `new Mastra({...})` required.
108
+
109
+ ```
110
+ src/mastra/
111
+ storage.ts // export default new LibSQLStore({ url: 'file:./mastra.db' })
112
+ observability.ts // export default new Observability({ ... })
113
+ server.ts // export default { port: 4111 }
114
+ studio.ts // export default { ... }
115
+ agents/weather/ // file-based agent
116
+ workflows/report.ts // export default createWorkflow({ ... })
117
+ ```
118
+
119
+ ```sh
120
+ # No src/mastra/index.ts needed:
121
+ mastra dev
122
+ ```
123
+
124
+ Projects that already export a `mastra` instance from `index.ts` are unaffected.
125
+
126
+ - Added file-system-routed agent processors. Place input and output processor files under `agents/<name>/processors/input/` and `agents/<name>/processors/output/`. Each file default-exports a processor, and they are auto-discovered and merged with config-defined processors when running `mastra dev` or `mastra build`. Config-defined processors run first, and a dynamic (function) `inputProcessors`/`outputProcessors` in `config.ts` takes precedence over discovered files. ([#18890](https://github.com/mastra-ai/mastra/pull/18890))
127
+
128
+ ```
129
+ src/mastra/agents/support/
130
+ ├── config.ts
131
+ ├── instructions.md
132
+ └── processors/
133
+ ├── input/
134
+ │ └── moderation.ts
135
+ └── output/
136
+ └── redact-pii.ts
137
+ ```
138
+
139
+ ```ts
140
+ // src/mastra/agents/support/processors/input/moderation.ts
141
+ import { ModerationProcessor } from '@mastra/core/processors';
142
+
143
+ export default new ModerationProcessor({ model: 'openai/gpt-5-nano' });
144
+ ```
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies [[`a0085fa`](https://github.com/mastra-ai/mastra/commit/a0085fa0934e52c37c8c8b3d75a6bb5cd199af36)]:
149
+ - @mastra/core@1.50.0-alpha.5
150
+ - @mastra/server@1.50.0-alpha.5
151
+
3
152
  ## 1.50.0-alpha.4
4
153
 
5
154
  ### Minor Changes
@@ -18,7 +18,7 @@ import type { DiscoveredFsAgent, DiscoveredFsSingleton, DiscoveredFsWorkflow } f
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[], options?: {
21
+ export declare function generateFsAgentsModule(userEntry: string | undefined, agents: DiscoveredFsAgent[], options?: {
22
22
  workflows?: DiscoveredFsWorkflow[];
23
23
  storage?: DiscoveredFsSingleton;
24
24
  observability?: DiscoveredFsSingleton;
@@ -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,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0HjG;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,iBAAiB,EAAE,EAC3B,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC,GACA,OAAO,CAAC,MAAM,CAAC,CAiIjB;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"}
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/build/fs-routing/codegen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAgJjG;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,iBAAiB,EAAE,EAC3B,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC,GACA,OAAO,CAAC,MAAM,CAAC,CAkJjB;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"}
@@ -27,6 +27,16 @@ export interface DiscoveredFsAgent {
27
27
  key: string;
28
28
  path: string;
29
29
  }[];
30
+ /** Input processors discovered under `processors/input/`, in stable (sorted) order. */
31
+ inputProcessors: {
32
+ key: string;
33
+ path: string;
34
+ }[];
35
+ /** Output processors discovered under `processors/output/`, in stable (sorted) order. */
36
+ outputProcessors: {
37
+ key: string;
38
+ path: string;
39
+ }[];
30
40
  /** Skills discovered under `skills/`, in stable (sorted) order. */
31
41
  skills: DiscoveredFsSkill[];
32
42
  /**
@@ -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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,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;AA6UN;;;;;;;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;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;CACd;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAwBrH"}
@@ -4,8 +4,11 @@ export interface PrepareFsAgentsEntryResult {
4
4
  * primitives (agents, workflows, storage, observability, server, studio) are
5
5
  * found this is a generated wrapper module that registers them onto the
6
6
  * user's mastra instance; otherwise it is the original entry unchanged.
7
+ * When auto-constructing (no user entry), this is always the generated module.
7
8
  */
8
9
  entryFile: string;
10
+ /** Whether a standalone Mastra instance was auto-constructed (no index.ts). */
11
+ standalone: boolean;
9
12
  /**
10
13
  * Glob tool paths for tools defined under `agents/*\/tools` so they are
11
14
  * bundled alongside the top-level `tools/` directory.
@@ -43,10 +46,14 @@ export interface PrepareFsAgentsEntryResult {
43
46
  * the result after `bundler.prepare()` so the generated file is not wiped when
44
47
  * the output directory is emptied.
45
48
  *
49
+ * When `entryFile` is `undefined` (no `index.ts`/`index.js`) and fs-routed
50
+ * primitives are found, a standalone Mastra instance is auto-constructed from
51
+ * them — no user code required.
52
+ *
46
53
  * When no fs-routed primitives are present the original entry is returned
47
54
  * unchanged, so existing code-only projects are completely unaffected.
48
55
  */
49
- export declare function prepareFsAgentsEntry(mastraDir: string, entryFile: string, outputDirectory: string): Promise<PrepareFsAgentsEntryResult>;
56
+ export declare function prepareFsAgentsEntry(mastraDir: string, entryFile: string | undefined, outputDirectory: string): Promise<PrepareFsAgentsEntryResult>;
50
57
  /**
51
58
  * Write the generated fs-agents wrapper produced by {@link prepareFsAgentsEntry}
52
59
  * to its `entryFile`. No-op when there are no fs-routed agents. Call this AFTER
@@ -1 +1 @@
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,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,0BAA0B,CAAC,CAqDrC;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;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,UAAU,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,0BAA0B,CAAC,CAkErC;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 chunkQHBSQDGP_cjs = require('../chunk-QHBSQDGP.cjs');
3
+ var chunkBC4D7ZTC_cjs = require('../chunk-BC4D7ZTC.cjs');
4
4
  var chunkJFZNJSRK_cjs = require('../chunk-JFZNJSRK.cjs');
5
5
  var chunkBDPBIAXY_cjs = require('../chunk-BDPBIAXY.cjs');
6
6
  var chunkYZYIXVB4_cjs = require('../chunk-YZYIXVB4.cjs');
@@ -11,47 +11,47 @@ var chunkJZRFRUGM_cjs = require('../chunk-JZRFRUGM.cjs');
11
11
 
12
12
  Object.defineProperty(exports, "createWatcher", {
13
13
  enumerable: true,
14
- get: function () { return chunkQHBSQDGP_cjs.createWatcher; }
14
+ get: function () { return chunkBC4D7ZTC_cjs.createWatcher; }
15
15
  });
16
16
  Object.defineProperty(exports, "discoverFsAgents", {
17
17
  enumerable: true,
18
- get: function () { return chunkQHBSQDGP_cjs.discoverFsAgents; }
18
+ get: function () { return chunkBC4D7ZTC_cjs.discoverFsAgents; }
19
19
  });
20
20
  Object.defineProperty(exports, "discoverFsSingleton", {
21
21
  enumerable: true,
22
- get: function () { return chunkQHBSQDGP_cjs.discoverFsSingleton; }
22
+ get: function () { return chunkBC4D7ZTC_cjs.discoverFsSingleton; }
23
23
  });
24
24
  Object.defineProperty(exports, "discoverFsWorkflows", {
25
25
  enumerable: true,
26
- get: function () { return chunkQHBSQDGP_cjs.discoverFsWorkflows; }
26
+ get: function () { return chunkBC4D7ZTC_cjs.discoverFsWorkflows; }
27
27
  });
28
28
  Object.defineProperty(exports, "generateFsAgentsModule", {
29
29
  enumerable: true,
30
- get: function () { return chunkQHBSQDGP_cjs.generateFsAgentsModule; }
30
+ get: function () { return chunkBC4D7ZTC_cjs.generateFsAgentsModule; }
31
31
  });
32
32
  Object.defineProperty(exports, "generateFsWorkflowsCodegen", {
33
33
  enumerable: true,
34
- get: function () { return chunkQHBSQDGP_cjs.generateFsWorkflowsCodegen; }
34
+ get: function () { return chunkBC4D7ZTC_cjs.generateFsWorkflowsCodegen; }
35
35
  });
36
36
  Object.defineProperty(exports, "getServerOptions", {
37
37
  enumerable: true,
38
- get: function () { return chunkQHBSQDGP_cjs.getServerOptions; }
38
+ get: function () { return chunkBC4D7ZTC_cjs.getServerOptions; }
39
39
  });
40
40
  Object.defineProperty(exports, "getWatcherInputOptions", {
41
41
  enumerable: true,
42
- get: function () { return chunkQHBSQDGP_cjs.getInputOptions; }
42
+ get: function () { return chunkBC4D7ZTC_cjs.getInputOptions; }
43
43
  });
44
44
  Object.defineProperty(exports, "mirrorFsAgentWorkspaces", {
45
45
  enumerable: true,
46
- get: function () { return chunkQHBSQDGP_cjs.mirrorFsAgentWorkspaces; }
46
+ get: function () { return chunkBC4D7ZTC_cjs.mirrorFsAgentWorkspaces; }
47
47
  });
48
48
  Object.defineProperty(exports, "prepareFsAgentsEntry", {
49
49
  enumerable: true,
50
- get: function () { return chunkQHBSQDGP_cjs.prepareFsAgentsEntry; }
50
+ get: function () { return chunkBC4D7ZTC_cjs.prepareFsAgentsEntry; }
51
51
  });
52
52
  Object.defineProperty(exports, "writeFsAgentsEntry", {
53
53
  enumerable: true,
54
- get: function () { return chunkQHBSQDGP_cjs.writeFsAgentsEntry; }
54
+ get: function () { return chunkBC4D7ZTC_cjs.writeFsAgentsEntry; }
55
55
  });
56
56
  Object.defineProperty(exports, "getBundlerOptions", {
57
57
  enumerable: true,
@@ -1,4 +1,4 @@
1
- export { createWatcher, discoverFsAgents, discoverFsSingleton, discoverFsWorkflows, generateFsAgentsModule, generateFsWorkflowsCodegen, getServerOptions, getInputOptions as getWatcherInputOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry } from '../chunk-MYYEG5DS.js';
1
+ export { createWatcher, discoverFsAgents, discoverFsSingleton, discoverFsWorkflows, generateFsAgentsModule, generateFsWorkflowsCodegen, getServerOptions, getInputOptions as getWatcherInputOptions, mirrorFsAgentWorkspaces, prepareFsAgentsEntry, writeFsAgentsEntry } from '../chunk-HEGZBAIW.js';
2
2
  export { getBundlerOptions } from '../chunk-YPDATVNL.js';
3
3
  export { analyzeBundle } from '../chunk-WVXBZMID.js';
4
4
  export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-TA65GR5X.js';
@@ -189,6 +189,36 @@ async function discoverTools(toolsDir) {
189
189
  }
190
190
  return tools;
191
191
  }
192
+ async function discoverProcessors(processorsDir) {
193
+ const result = { input: [], output: [] };
194
+ for (const type of ["input", "output"]) {
195
+ const typeDir = path.join(processorsDir, type);
196
+ if (!await exists(typeDir)) {
197
+ continue;
198
+ }
199
+ let entries;
200
+ try {
201
+ entries = await promises.readdir(typeDir);
202
+ } catch {
203
+ continue;
204
+ }
205
+ for (const basename of entries.sort()) {
206
+ if (isTestFile(basename)) {
207
+ continue;
208
+ }
209
+ if (!TOOL_EXTENSIONS.some((ext) => basename.endsWith(ext))) {
210
+ continue;
211
+ }
212
+ const path$1 = path.join(typeDir, basename);
213
+ const stats = await promises.lstat(path$1);
214
+ if (stats.isSymbolicLink() || stats.isDirectory()) {
215
+ continue;
216
+ }
217
+ result[type].push({ key: toolKey(basename), path: chunkJZRFRUGM_cjs.slash(path$1) });
218
+ }
219
+ }
220
+ return result;
221
+ }
192
222
  async function readReferences(referencesDir) {
193
223
  if (!await exists(referencesDir)) {
194
224
  return {};
@@ -277,6 +307,7 @@ async function discoverAgentDir(dir, name, depth, onWarn) {
277
307
  const memoryPath = await firstExisting(dir, MEMORY_BASENAMES);
278
308
  const workspaceSeedDir = await directoryExists(path.join(dir, "workspace"));
279
309
  const tools = await discoverTools(path.join(dir, "tools"));
310
+ const processors = await discoverProcessors(path.join(dir, "processors"));
280
311
  const skills = await discoverSkills(path.join(dir, "skills"));
281
312
  const subagents = await discoverSubagents(dir, depth, onWarn);
282
313
  return {
@@ -288,6 +319,8 @@ async function discoverAgentDir(dir, name, depth, onWarn) {
288
319
  memoryPath,
289
320
  workspaceSeedDir,
290
321
  tools,
322
+ inputProcessors: processors.input,
323
+ outputProcessors: processors.output,
291
324
  skills,
292
325
  subagents
293
326
  };
@@ -427,6 +460,20 @@ async function emitAgentEntry(agent, idPath, workspaceName, lines) {
427
460
  lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);
428
461
  toolIdents.push({ key: tool.key, ident });
429
462
  }
463
+ const inputProcessorIdents = [];
464
+ for (let p = 0; p < agent.inputProcessors.length; p++) {
465
+ const proc = agent.inputProcessors[p];
466
+ const ident = sanitizeIdentifier(`${agent.name}_inputProc_${proc.key}`, "proc", `${idPath}_ip${p}`);
467
+ lines.push(`import ${ident} from ${JSON.stringify(proc.path)};`);
468
+ inputProcessorIdents.push(ident);
469
+ }
470
+ const outputProcessorIdents = [];
471
+ for (let p = 0; p < agent.outputProcessors.length; p++) {
472
+ const proc = agent.outputProcessors[p];
473
+ const ident = sanitizeIdentifier(`${agent.name}_outputProc_${proc.key}`, "proc", `${idPath}_op${p}`);
474
+ lines.push(`import ${ident} from ${JSON.stringify(proc.path)};`);
475
+ outputProcessorIdents.push(ident);
476
+ }
430
477
  const skillExprs = [];
431
478
  const agentSkills = agent.skills ?? [];
432
479
  for (let s = 0; s < agentSkills.length; s++) {
@@ -474,6 +521,12 @@ async function emitAgentEntry(agent, idPath, workspaceName, lines) {
474
521
  if (skillExprs.length > 0) {
475
522
  entryFields.push(`skills: [${skillExprs.join(", ")}]`);
476
523
  }
524
+ if (inputProcessorIdents.length > 0) {
525
+ entryFields.push(`inputProcessors: [${inputProcessorIdents.join(", ")}]`);
526
+ }
527
+ if (outputProcessorIdents.length > 0) {
528
+ entryFields.push(`outputProcessors: [${outputProcessorIdents.join(", ")}]`);
529
+ }
477
530
  if (subagentExprs.length > 0) {
478
531
  entryFields.push(`subagents: [${subagentExprs.join(", ")}]`);
479
532
  }
@@ -492,6 +545,7 @@ async function generateFsAgentsModule(userEntry, agents, options) {
492
545
  const observability = options?.observability;
493
546
  const server = options?.server;
494
547
  const studio = options?.studio;
548
+ const standalone = userEntry === void 0;
495
549
  const lines = [];
496
550
  const hasInlineSkills = (function check(list) {
497
551
  return list.some((a) => (a.skills ?? []).some((s) => s.kind === "packaged") || check(a.subagents ?? []));
@@ -500,10 +554,15 @@ async function generateFsAgentsModule(userEntry, agents, options) {
500
554
  if (hasInlineSkills) {
501
555
  lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);
502
556
  }
557
+ if (standalone) {
558
+ lines.push(`import { Mastra } from '@mastra/core';`);
559
+ }
503
560
  lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);
504
561
  lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);
505
- lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);
506
- lines.push(`export * from ${JSON.stringify(userEntry)};`);
562
+ if (userEntry) {
563
+ lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);
564
+ lines.push(`export * from ${JSON.stringify(userEntry)};`);
565
+ }
507
566
  lines.push(``);
508
567
  lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);
509
568
  lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);
@@ -538,6 +597,13 @@ async function generateFsAgentsModule(userEntry, agents, options) {
538
597
  const expr = await emitAgentEntry(agent, `${i}`, agent.name, lines);
539
598
  entryExprs.push(expr);
540
599
  }
600
+ if (standalone) {
601
+ lines.push(``);
602
+ lines.push(`const __mastra = new Mastra({});`);
603
+ } else {
604
+ lines.push(``);
605
+ lines.push(`const __mastra = __userEntry.mastra;`);
606
+ }
541
607
  lines.push(``);
542
608
  lines.push(`const __fsAgentEntries = [`);
543
609
  for (const expr of entryExprs) {
@@ -548,36 +614,36 @@ async function generateFsAgentsModule(userEntry, agents, options) {
548
614
  lines.push(`const __fsAgents = Object.create(null);`);
549
615
  lines.push(`for (const __entry of __fsAgentEntries) {`);
550
616
  lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);
551
- lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);
617
+ lines.push(` onWarn: msg => __mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);
552
618
  lines.push(` });`);
553
619
  lines.push(`}`);
554
620
  lines.push(``);
555
621
  if (storage) {
556
- lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsStorage === 'function') {`);
557
- lines.push(` __userEntry.mastra.__registerFsStorage(__fsStorage);`);
622
+ lines.push(`if (__mastra && typeof __mastra.__registerFsStorage === 'function') {`);
623
+ lines.push(` __mastra.__registerFsStorage(__fsStorage);`);
558
624
  lines.push(`}`);
559
625
  lines.push(``);
560
626
  }
561
627
  if (observability) {
562
- lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsObservability === 'function') {`);
563
- lines.push(` __userEntry.mastra.__registerFsObservability(__fsObservability);`);
628
+ lines.push(`if (__mastra && typeof __mastra.__registerFsObservability === 'function') {`);
629
+ lines.push(` __mastra.__registerFsObservability(__fsObservability);`);
564
630
  lines.push(`}`);
565
631
  lines.push(``);
566
632
  }
567
633
  if (server) {
568
- lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsServer === 'function') {`);
569
- lines.push(` __userEntry.mastra.__registerFsServer(__fsServer);`);
634
+ lines.push(`if (__mastra && typeof __mastra.__registerFsServer === 'function') {`);
635
+ lines.push(` __mastra.__registerFsServer(__fsServer);`);
570
636
  lines.push(`}`);
571
637
  lines.push(``);
572
638
  }
573
639
  if (studio) {
574
- lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsStudio === 'function') {`);
575
- lines.push(` __userEntry.mastra.__registerFsStudio(__fsStudio);`);
640
+ lines.push(`if (__mastra && typeof __mastra.__registerFsStudio === 'function') {`);
641
+ lines.push(` __mastra.__registerFsStudio(__fsStudio);`);
576
642
  lines.push(`}`);
577
643
  lines.push(``);
578
644
  }
579
- lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);
580
- lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);
645
+ lines.push(`if (__mastra && typeof __mastra.__registerFsAgents === 'function') {`);
646
+ lines.push(` __mastra.__registerFsAgents(__fsAgents);`);
581
647
  lines.push(`}`);
582
648
  if (wfCodegen) {
583
649
  lines.push(``);
@@ -586,7 +652,7 @@ async function generateFsAgentsModule(userEntry, agents, options) {
586
652
  }
587
653
  }
588
654
  lines.push(``);
589
- lines.push(`export const mastra = __userEntry.mastra;`);
655
+ lines.push(`export const mastra = __mastra;`);
590
656
  return lines.join("\n");
591
657
  }
592
658
  function generateFsWorkflowsCodegen(workflows) {
@@ -604,8 +670,8 @@ function generateFsWorkflowsCodegen(workflows) {
604
670
  registrationLines.push(`__fsWorkflows[${JSON.stringify(wf.key)}] = ${ident};`);
605
671
  }
606
672
  registrationLines.push(``);
607
- registrationLines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsWorkflows === 'function') {`);
608
- registrationLines.push(` __userEntry.mastra.__registerFsWorkflows(__fsWorkflows);`);
673
+ registrationLines.push(`if (__mastra && typeof __mastra.__registerFsWorkflows === 'function') {`);
674
+ registrationLines.push(` __mastra.__registerFsWorkflows(__fsWorkflows);`);
609
675
  registrationLines.push(`}`);
610
676
  return { importLines, registrationLines };
611
677
  }
@@ -618,9 +684,12 @@ async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
618
684
  discoverFsSingleton(mastraDir, "server"),
619
685
  discoverFsSingleton(mastraDir, "studio")
620
686
  ]);
621
- if (agents.length === 0 && workflows.length === 0 && !storage && !observability && !server && !studio) {
687
+ const standalone = entryFile === void 0;
688
+ const hasFsPrimitives = agents.length > 0 || workflows.length > 0 || !!storage || !!observability || !!server || !!studio;
689
+ if (!hasFsPrimitives && entryFile !== void 0) {
622
690
  return {
623
691
  entryFile,
692
+ standalone: false,
624
693
  toolPaths: [],
625
694
  agentCount: 0,
626
695
  workflowCount: 0,
@@ -630,7 +699,12 @@ async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
630
699
  hasStudio: false
631
700
  };
632
701
  }
633
- const moduleSource = await generateFsAgentsModule(chunkJZRFRUGM_cjs.slash(entryFile), agents, {
702
+ if (!hasFsPrimitives && standalone) {
703
+ throw new Error(
704
+ "No index.ts and no file-based primitives found. Create src/mastra/index.ts with a Mastra instance, or add file-based agents/workflows/storage."
705
+ );
706
+ }
707
+ const moduleSource = await generateFsAgentsModule(entryFile ? chunkJZRFRUGM_cjs.slash(entryFile) : void 0, agents, {
634
708
  workflows,
635
709
  storage,
636
710
  observability,
@@ -646,6 +720,7 @@ async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
646
720
  ] : [];
647
721
  return {
648
722
  entryFile: generatedEntry,
723
+ standalone,
649
724
  toolPaths,
650
725
  agentCount: agents.length,
651
726
  workflowCount: workflows.length,
@@ -698,5 +773,5 @@ exports.getServerOptions = getServerOptions;
698
773
  exports.mirrorFsAgentWorkspaces = mirrorFsAgentWorkspaces;
699
774
  exports.prepareFsAgentsEntry = prepareFsAgentsEntry;
700
775
  exports.writeFsAgentsEntry = writeFsAgentsEntry;
701
- //# sourceMappingURL=chunk-QHBSQDGP.cjs.map
702
- //# sourceMappingURL=chunk-QHBSQDGP.cjs.map
776
+ //# sourceMappingURL=chunk-BC4D7ZTC.cjs.map
777
+ //# sourceMappingURL=chunk-BC4D7ZTC.cjs.map