@mastra/deployer 1.48.0-alpha.5 → 1.48.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/build/fs-routing/codegen.d.ts +21 -0
- package/dist/build/fs-routing/codegen.d.ts.map +1 -0
- package/dist/build/fs-routing/discover.d.ts +68 -0
- package/dist/build/fs-routing/discover.d.ts.map +1 -0
- package/dist/build/fs-routing/mirror.d.ts +16 -0
- package/dist/build/fs-routing/mirror.d.ts.map +1 -0
- package/dist/build/fs-routing/prepare.d.ts +44 -0
- package/dist/build/fs-routing/prepare.d.ts.map +1 -0
- package/dist/build/index.cjs +27 -7
- package/dist/build/index.d.ts +6 -0
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +2 -2
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-ZIES2RI2.js → chunk-5GX66TF5.js} +3 -3
- package/dist/chunk-5GX66TF5.js.map +1 -0
- package/dist/{chunk-OYMI2TVX.cjs → chunk-CHZ76N6R.cjs} +5 -5
- package/dist/{chunk-OYMI2TVX.cjs.map → chunk-CHZ76N6R.cjs.map} +1 -1
- package/dist/{chunk-IQDJEJM3.js → chunk-T6LS4OKA.js} +3 -3
- package/dist/{chunk-IQDJEJM3.js.map → chunk-T6LS4OKA.js.map} +1 -1
- package/dist/{chunk-UEH6D24P.cjs → chunk-VXLIM7FD.cjs} +5 -5
- package/dist/chunk-VXLIM7FD.cjs.map +1 -0
- package/dist/chunk-YLUHJBYA.js +486 -0
- package/dist/chunk-YLUHJBYA.js.map +1 -0
- package/dist/chunk-ZZHJNINJ.cjs +518 -0
- package/dist/chunk-ZZHJNINJ.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +5 -5
- package/dist/index.cjs +9 -9
- package/dist/index.js +3 -3
- package/dist/services/env.d.ts.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/package.json +7 -6
- package/dist/chunk-EVWJBGLA.js +0 -98
- package/dist/chunk-EVWJBGLA.js.map +0 -1
- package/dist/chunk-UEH6D24P.cjs.map +0 -1
- package/dist/chunk-Y476PH5A.cjs +0 -122
- package/dist/chunk-Y476PH5A.cjs.map +0 -1
- package/dist/chunk-ZIES2RI2.js.map +0 -1
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVZYB4EVX_cjs = require('./chunk-VZYB4EVX.cjs');
|
|
4
|
+
var chunk47KJ3RKB_cjs = require('./chunk-47KJ3RKB.cjs');
|
|
5
|
+
var chunkFBL7GBNM_cjs = require('./chunk-FBL7GBNM.cjs');
|
|
6
|
+
var chunkI7TERDMR_cjs = require('./chunk-I7TERDMR.cjs');
|
|
7
|
+
var chunk7PMC7SBC_cjs = require('./chunk-7PMC7SBC.cjs');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var logger = require('@mastra/core/logger');
|
|
10
|
+
var pkg = require('empathic/package');
|
|
11
|
+
var rollup = require('rollup');
|
|
12
|
+
var promises = require('fs/promises');
|
|
13
|
+
var matter = require('gray-matter');
|
|
14
|
+
|
|
15
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n.default = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var pkg__namespace = /*#__PURE__*/_interopNamespace(pkg);
|
|
36
|
+
var matter__default = /*#__PURE__*/_interopDefault(matter);
|
|
37
|
+
|
|
38
|
+
async function getInputOptions2(entryFile, platform, env, {
|
|
39
|
+
sourcemap = false,
|
|
40
|
+
bundlerOptions = {
|
|
41
|
+
enableSourcemap: false,
|
|
42
|
+
enableEsmShim: true,
|
|
43
|
+
externals: true
|
|
44
|
+
}
|
|
45
|
+
} = {}) {
|
|
46
|
+
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(entryFile) });
|
|
47
|
+
const projectRoot = closestPkgJson ? path.dirname(chunk7PMC7SBC_cjs.slash(closestPkgJson)) : chunk7PMC7SBC_cjs.slash(process.cwd());
|
|
48
|
+
const { workspaceMap, workspaceRoot } = await chunk47KJ3RKB_cjs.getWorkspaceInformation({ mastraEntryFile: entryFile });
|
|
49
|
+
const analyzeEntryResult = await chunk47KJ3RKB_cjs.analyzeBundle(
|
|
50
|
+
[entryFile],
|
|
51
|
+
entryFile,
|
|
52
|
+
{
|
|
53
|
+
outputDir: path.posix.join(process.cwd(), ".mastra", ".build"),
|
|
54
|
+
projectRoot: workspaceRoot || process.cwd(),
|
|
55
|
+
platform,
|
|
56
|
+
isDev: true,
|
|
57
|
+
bundlerOptions
|
|
58
|
+
},
|
|
59
|
+
logger.noopLogger
|
|
60
|
+
);
|
|
61
|
+
const deps = /* @__PURE__ */ new Map();
|
|
62
|
+
for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {
|
|
63
|
+
const pkgName = chunk7PMC7SBC_cjs.getPackageName(dep);
|
|
64
|
+
if (pkgName && workspaceMap.has(pkgName)) {
|
|
65
|
+
deps.set(dep, metadata);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const inputOptions = await chunkFBL7GBNM_cjs.getInputOptions(
|
|
69
|
+
entryFile,
|
|
70
|
+
{
|
|
71
|
+
dependencies: deps,
|
|
72
|
+
externalDependencies: /* @__PURE__ */ new Map(),
|
|
73
|
+
workspaceMap
|
|
74
|
+
},
|
|
75
|
+
platform,
|
|
76
|
+
env,
|
|
77
|
+
{ sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true }
|
|
78
|
+
);
|
|
79
|
+
if (Array.isArray(inputOptions.plugins)) {
|
|
80
|
+
const plugins = [];
|
|
81
|
+
inputOptions.plugins.forEach((plugin) => {
|
|
82
|
+
if (plugin?.name === "node-resolve") {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (plugin?.name === "tsconfig-paths") {
|
|
86
|
+
plugins.push(
|
|
87
|
+
chunkI7TERDMR_cjs.tsConfigPaths({
|
|
88
|
+
localResolve: true
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
plugins.push(plugin);
|
|
94
|
+
});
|
|
95
|
+
inputOptions.plugins = plugins;
|
|
96
|
+
inputOptions.plugins.push(chunk47KJ3RKB_cjs.aliasHono());
|
|
97
|
+
inputOptions.plugins.push(chunkFBL7GBNM_cjs.nodeModulesExtensionResolver());
|
|
98
|
+
}
|
|
99
|
+
return inputOptions;
|
|
100
|
+
}
|
|
101
|
+
async function createWatcher(inputOptions, outputOptions) {
|
|
102
|
+
const watcher = await rollup.watch({
|
|
103
|
+
...inputOptions,
|
|
104
|
+
output: {
|
|
105
|
+
...outputOptions,
|
|
106
|
+
format: "esm",
|
|
107
|
+
entryFileNames: "[name].mjs",
|
|
108
|
+
chunkFileNames: "[name].mjs"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return watcher;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/build/serverOptions.ts
|
|
115
|
+
async function getServerOptions(entryFile, outputDir, logger) {
|
|
116
|
+
const result = await chunkVZYB4EVX_cjs.extractMastraOption("server", entryFile, outputDir, logger);
|
|
117
|
+
if (!result) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return result.getConfig();
|
|
121
|
+
}
|
|
122
|
+
var CONFIG_BASENAMES = ["config.ts", "config.js"];
|
|
123
|
+
var WORKSPACE_BASENAMES = ["workspace.ts", "workspace.js"];
|
|
124
|
+
var INSTRUCTIONS_BASENAME = "instructions.md";
|
|
125
|
+
var TOOL_EXTENSIONS = [".ts", ".js"];
|
|
126
|
+
var SKILL_MODULE_EXTENSIONS = [".ts", ".js"];
|
|
127
|
+
var SKILL_MD_BASENAME = "SKILL.md";
|
|
128
|
+
async function exists(path) {
|
|
129
|
+
try {
|
|
130
|
+
return !(await promises.lstat(path)).isSymbolicLink();
|
|
131
|
+
} catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function realDirectory(path) {
|
|
136
|
+
try {
|
|
137
|
+
const info = await promises.lstat(path);
|
|
138
|
+
if (info.isDirectory() && !info.isSymbolicLink()) {
|
|
139
|
+
return chunk7PMC7SBC_cjs.slash(path);
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
async function directoryExists(path) {
|
|
146
|
+
return realDirectory(path);
|
|
147
|
+
}
|
|
148
|
+
async function firstExisting(dir, basenames) {
|
|
149
|
+
for (const basename of basenames) {
|
|
150
|
+
const candidate = path.join(dir, basename);
|
|
151
|
+
if (await exists(candidate)) {
|
|
152
|
+
return chunk7PMC7SBC_cjs.slash(candidate);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
157
|
+
function isTestFile(basename) {
|
|
158
|
+
return /\.(test|spec)\.(ts|js)$/.test(basename);
|
|
159
|
+
}
|
|
160
|
+
function toolKey(basename) {
|
|
161
|
+
return basename.replace(/\.(ts|js)$/, "");
|
|
162
|
+
}
|
|
163
|
+
async function discoverTools(toolsDir) {
|
|
164
|
+
if (!await exists(toolsDir)) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
let entries;
|
|
168
|
+
try {
|
|
169
|
+
entries = await promises.readdir(toolsDir);
|
|
170
|
+
} catch {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
const tools = [];
|
|
174
|
+
for (const basename of entries.sort()) {
|
|
175
|
+
if (isTestFile(basename)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!TOOL_EXTENSIONS.some((ext) => basename.endsWith(ext))) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const path$1 = path.join(toolsDir, basename);
|
|
182
|
+
const stats = await promises.lstat(path$1);
|
|
183
|
+
if (stats.isSymbolicLink() || stats.isDirectory()) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
tools.push({ key: toolKey(basename), path: chunk7PMC7SBC_cjs.slash(path$1) });
|
|
187
|
+
}
|
|
188
|
+
return tools;
|
|
189
|
+
}
|
|
190
|
+
async function readReferences(referencesDir) {
|
|
191
|
+
if (!await exists(referencesDir)) {
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
const references = {};
|
|
195
|
+
let entries;
|
|
196
|
+
try {
|
|
197
|
+
entries = await promises.readdir(referencesDir);
|
|
198
|
+
} catch {
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
for (const basename of entries.sort()) {
|
|
202
|
+
const path$1 = path.join(referencesDir, basename);
|
|
203
|
+
const stats = await promises.lstat(path$1);
|
|
204
|
+
if (stats.isSymbolicLink() || stats.isDirectory()) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
references[basename] = await promises.readFile(path$1, "utf-8");
|
|
208
|
+
}
|
|
209
|
+
return references;
|
|
210
|
+
}
|
|
211
|
+
async function parsePackagedSkill(skillMdPath, fallbackName, references = {}) {
|
|
212
|
+
const raw = await promises.readFile(skillMdPath, "utf-8");
|
|
213
|
+
const parsed = matter__default.default(raw);
|
|
214
|
+
const frontmatter = parsed.data;
|
|
215
|
+
const name = frontmatter.name ?? fallbackName;
|
|
216
|
+
const description = frontmatter.description ?? "";
|
|
217
|
+
const instructions = parsed.content.trim();
|
|
218
|
+
return { kind: "packaged", name, description, instructions, references };
|
|
219
|
+
}
|
|
220
|
+
function skillModuleName(basename) {
|
|
221
|
+
return basename.replace(/\.(ts|js)$/, "");
|
|
222
|
+
}
|
|
223
|
+
async function discoverSkills(skillsDir) {
|
|
224
|
+
if (!await exists(skillsDir)) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
let entries;
|
|
228
|
+
try {
|
|
229
|
+
entries = await promises.readdir(skillsDir);
|
|
230
|
+
} catch {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const skills = [];
|
|
234
|
+
for (const basename of entries.sort()) {
|
|
235
|
+
if (isTestFile(basename)) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const path$1 = path.join(skillsDir, basename);
|
|
239
|
+
const stats = await promises.lstat(path$1);
|
|
240
|
+
if (stats.isSymbolicLink()) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const isDir = stats.isDirectory();
|
|
244
|
+
if (isDir) {
|
|
245
|
+
const skillMd = path.join(path$1, SKILL_MD_BASENAME);
|
|
246
|
+
if (await exists(skillMd)) {
|
|
247
|
+
const references = await readReferences(path.join(path$1, "references"));
|
|
248
|
+
skills.push(await parsePackagedSkill(skillMd, skillModuleName(basename), references));
|
|
249
|
+
}
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (SKILL_MODULE_EXTENSIONS.some((ext) => basename.endsWith(ext))) {
|
|
253
|
+
skills.push({ kind: "module", path: chunk7PMC7SBC_cjs.slash(path$1) });
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (basename.endsWith(".md")) {
|
|
257
|
+
const skill = await parsePackagedSkill(path$1, basename.replace(/\.md$/, ""));
|
|
258
|
+
skills.push(skill);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return skills;
|
|
262
|
+
}
|
|
263
|
+
async function discoverAgentDir(dir, name, allowSubagents, onWarn) {
|
|
264
|
+
const configPath = await firstExisting(dir, CONFIG_BASENAMES);
|
|
265
|
+
const instructionsPath = await exists(path.join(dir, INSTRUCTIONS_BASENAME)) ? chunk7PMC7SBC_cjs.slash(path.join(dir, INSTRUCTIONS_BASENAME)) : void 0;
|
|
266
|
+
if (!configPath && !instructionsPath) {
|
|
267
|
+
return void 0;
|
|
268
|
+
}
|
|
269
|
+
const workspacePath = await firstExisting(dir, WORKSPACE_BASENAMES);
|
|
270
|
+
const workspaceSeedDir = await directoryExists(path.join(dir, "workspace"));
|
|
271
|
+
const tools = await discoverTools(path.join(dir, "tools"));
|
|
272
|
+
const skills = await discoverSkills(path.join(dir, "skills"));
|
|
273
|
+
const subagents = await discoverSubagents(dir, allowSubagents, onWarn);
|
|
274
|
+
return {
|
|
275
|
+
name,
|
|
276
|
+
dir: chunk7PMC7SBC_cjs.slash(dir),
|
|
277
|
+
configPath,
|
|
278
|
+
instructionsPath,
|
|
279
|
+
workspacePath,
|
|
280
|
+
workspaceSeedDir,
|
|
281
|
+
tools,
|
|
282
|
+
skills,
|
|
283
|
+
subagents
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async function discoverSubagents(parentDir, allowSubagents, onWarn) {
|
|
287
|
+
const subagentsDir = path.join(parentDir, "subagents");
|
|
288
|
+
if (!await exists(subagentsDir)) {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
if (!allowSubagents) {
|
|
292
|
+
onWarn?.(
|
|
293
|
+
`Ignoring nested subagents in "${chunk7PMC7SBC_cjs.slash(subagentsDir)}": subagents are one level deep only, so a subagent cannot declare its own subagents.`
|
|
294
|
+
);
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
let entries;
|
|
298
|
+
try {
|
|
299
|
+
entries = await promises.readdir(subagentsDir);
|
|
300
|
+
} catch {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
const subagents = [];
|
|
304
|
+
for (const name of entries.sort()) {
|
|
305
|
+
const dir = path.join(subagentsDir, name);
|
|
306
|
+
if (!await realDirectory(dir)) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const child = await discoverAgentDir(dir, name, false, onWarn);
|
|
310
|
+
if (child) {
|
|
311
|
+
subagents.push(child);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return subagents;
|
|
315
|
+
}
|
|
316
|
+
async function discoverFsAgents(mastraDir, onWarn) {
|
|
317
|
+
const agentsDir = path.join(mastraDir, "agents");
|
|
318
|
+
if (!await exists(agentsDir)) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
let entries;
|
|
322
|
+
try {
|
|
323
|
+
entries = await promises.readdir(agentsDir);
|
|
324
|
+
} catch {
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
const discovered = [];
|
|
328
|
+
for (const name of entries.sort()) {
|
|
329
|
+
const dir = path.join(agentsDir, name);
|
|
330
|
+
if (!await realDirectory(dir)) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
const agent = await discoverAgentDir(dir, name, true, onWarn);
|
|
334
|
+
if (agent) {
|
|
335
|
+
discovered.push(agent);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return discovered;
|
|
339
|
+
}
|
|
340
|
+
function sanitizeIdentifier(name, prefix, index) {
|
|
341
|
+
const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
342
|
+
return `${prefix}_${index}_${cleaned}`;
|
|
343
|
+
}
|
|
344
|
+
async function emitAgentEntry(agent, idPath, workspaceName, allowSubagents, lines) {
|
|
345
|
+
const configIdent = sanitizeIdentifier(agent.name, "config", idPath);
|
|
346
|
+
const toolIdents = [];
|
|
347
|
+
if (agent.configPath) {
|
|
348
|
+
lines.push(`import ${configIdent} from ${JSON.stringify(agent.configPath)};`);
|
|
349
|
+
}
|
|
350
|
+
let workspaceIdent;
|
|
351
|
+
if (agent.workspacePath) {
|
|
352
|
+
workspaceIdent = sanitizeIdentifier(`${agent.name}_workspace`, "workspace", idPath);
|
|
353
|
+
lines.push(`import ${workspaceIdent} from ${JSON.stringify(agent.workspacePath)};`);
|
|
354
|
+
}
|
|
355
|
+
for (let t = 0; t < agent.tools.length; t++) {
|
|
356
|
+
const tool = agent.tools[t];
|
|
357
|
+
const ident = sanitizeIdentifier(`${agent.name}_${tool.key}`, "tool", `${idPath}_${t}`);
|
|
358
|
+
lines.push(`import ${ident} from ${JSON.stringify(tool.path)};`);
|
|
359
|
+
toolIdents.push({ key: tool.key, ident });
|
|
360
|
+
}
|
|
361
|
+
const skillExprs = [];
|
|
362
|
+
const agentSkills = agent.skills ?? [];
|
|
363
|
+
for (let s = 0; s < agentSkills.length; s++) {
|
|
364
|
+
const skill = agentSkills[s];
|
|
365
|
+
if (skill.kind === "module") {
|
|
366
|
+
const ident = sanitizeIdentifier(`${agent.name}_skill`, "skill", `${idPath}_${s}`);
|
|
367
|
+
lines.push(`import ${ident} from ${JSON.stringify(skill.path)};`);
|
|
368
|
+
skillExprs.push(ident);
|
|
369
|
+
} else {
|
|
370
|
+
const referenceFields = Object.entries(skill.references).map(
|
|
371
|
+
([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`
|
|
372
|
+
);
|
|
373
|
+
const skillFields = [
|
|
374
|
+
`name: ${JSON.stringify(skill.name)}`,
|
|
375
|
+
`description: ${JSON.stringify(skill.description)}`,
|
|
376
|
+
`instructions: ${JSON.stringify(skill.instructions)}`
|
|
377
|
+
];
|
|
378
|
+
if (referenceFields.length > 0) {
|
|
379
|
+
skillFields.push(`references: { ${referenceFields.join(", ")} }`);
|
|
380
|
+
}
|
|
381
|
+
skillExprs.push(`__createSkill({ ${skillFields.join(", ")} })`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
let instructionsMd;
|
|
385
|
+
if (agent.instructionsPath) {
|
|
386
|
+
instructionsMd = await promises.readFile(agent.instructionsPath, "utf-8");
|
|
387
|
+
}
|
|
388
|
+
const subagentExprs = [];
|
|
389
|
+
if (allowSubagents) {
|
|
390
|
+
for (let c = 0; c < agent.subagents.length; c++) {
|
|
391
|
+
const child = agent.subagents[c];
|
|
392
|
+
const childExpr = await emitAgentEntry(child, `${idPath}_${c}`, `${workspaceName}/${child.name}`, false, lines);
|
|
393
|
+
subagentExprs.push(childExpr);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const entryFields = [`name: ${JSON.stringify(agent.name)}`];
|
|
397
|
+
if (agent.configPath) {
|
|
398
|
+
entryFields.push(`config: ${configIdent}`);
|
|
399
|
+
}
|
|
400
|
+
if (instructionsMd !== void 0) {
|
|
401
|
+
entryFields.push(`instructionsMd: ${JSON.stringify(instructionsMd)}`);
|
|
402
|
+
}
|
|
403
|
+
if (toolIdents.length > 0) {
|
|
404
|
+
const toolEntries = toolIdents.map(({ key, ident }) => `{ key: ${JSON.stringify(key)}, tool: ${ident} }`);
|
|
405
|
+
entryFields.push(`tools: [${toolEntries.join(", ")}]`);
|
|
406
|
+
}
|
|
407
|
+
if (skillExprs.length > 0) {
|
|
408
|
+
entryFields.push(`skills: [${skillExprs.join(", ")}]`);
|
|
409
|
+
}
|
|
410
|
+
if (subagentExprs.length > 0) {
|
|
411
|
+
entryFields.push(`subagents: [${subagentExprs.join(", ")}]`);
|
|
412
|
+
}
|
|
413
|
+
if (workspaceIdent) {
|
|
414
|
+
entryFields.push(`workspace: ${workspaceIdent}`);
|
|
415
|
+
}
|
|
416
|
+
entryFields.push(`defaultWorkspaceBasePath: __workspaceBasePath(${JSON.stringify(workspaceName)})`);
|
|
417
|
+
return `{ ${entryFields.join(", ")} }`;
|
|
418
|
+
}
|
|
419
|
+
async function generateFsAgentsModule(userEntry, agents) {
|
|
420
|
+
const lines = [];
|
|
421
|
+
const hasInlineSkills = agents.some(
|
|
422
|
+
(a) => [a, ...a.subagents ?? []].some((x) => (x.skills ?? []).some((s) => s.kind === "packaged"))
|
|
423
|
+
);
|
|
424
|
+
lines.push(`import { assembleAgentFromFsEntry } from '@mastra/core/agent';`);
|
|
425
|
+
if (hasInlineSkills) {
|
|
426
|
+
lines.push(`import { createSkill as __createSkill } from '@mastra/core/skills';`);
|
|
427
|
+
}
|
|
428
|
+
lines.push(`import { fileURLToPath as __fileURLToPath } from 'node:url';`);
|
|
429
|
+
lines.push(`import { dirname as __dirname, join as __join } from 'node:path';`);
|
|
430
|
+
lines.push(`import * as __userEntry from ${JSON.stringify(userEntry)};`);
|
|
431
|
+
lines.push(`export * from ${JSON.stringify(userEntry)};`);
|
|
432
|
+
lines.push(``);
|
|
433
|
+
lines.push(`const __bundleDir = __dirname(__fileURLToPath(import.meta.url));`);
|
|
434
|
+
lines.push(`const __workspaceBasePath = name => __join(__bundleDir, 'workspace', ...name.split('/'));`);
|
|
435
|
+
lines.push(``);
|
|
436
|
+
const entryExprs = [];
|
|
437
|
+
for (let i = 0; i < agents.length; i++) {
|
|
438
|
+
const agent = agents[i];
|
|
439
|
+
const expr = await emitAgentEntry(agent, `${i}`, agent.name, true, lines);
|
|
440
|
+
entryExprs.push(expr);
|
|
441
|
+
}
|
|
442
|
+
lines.push(``);
|
|
443
|
+
lines.push(`const __fsAgentEntries = [`);
|
|
444
|
+
for (const expr of entryExprs) {
|
|
445
|
+
lines.push(` ${expr},`);
|
|
446
|
+
}
|
|
447
|
+
lines.push(`];`);
|
|
448
|
+
lines.push(``);
|
|
449
|
+
lines.push(`const __fsAgents = Object.create(null);`);
|
|
450
|
+
lines.push(`for (const __entry of __fsAgentEntries) {`);
|
|
451
|
+
lines.push(` __fsAgents[__entry.name] = assembleAgentFromFsEntry(__entry, {`);
|
|
452
|
+
lines.push(` onWarn: msg => __userEntry.mastra?.getLogger?.()?.warn?.(msg) ?? console.warn(msg),`);
|
|
453
|
+
lines.push(` });`);
|
|
454
|
+
lines.push(`}`);
|
|
455
|
+
lines.push(``);
|
|
456
|
+
lines.push(`if (__userEntry.mastra && typeof __userEntry.mastra.__registerFsAgents === 'function') {`);
|
|
457
|
+
lines.push(` __userEntry.mastra.__registerFsAgents(__fsAgents);`);
|
|
458
|
+
lines.push(`}`);
|
|
459
|
+
lines.push(``);
|
|
460
|
+
lines.push(`export const mastra = __userEntry.mastra;`);
|
|
461
|
+
return lines.join("\n");
|
|
462
|
+
}
|
|
463
|
+
async function prepareFsAgentsEntry(mastraDir, entryFile, outputDirectory) {
|
|
464
|
+
const agents = await discoverFsAgents(mastraDir);
|
|
465
|
+
if (agents.length === 0) {
|
|
466
|
+
return { entryFile, toolPaths: [], agentCount: 0 };
|
|
467
|
+
}
|
|
468
|
+
const moduleSource = await generateFsAgentsModule(chunk7PMC7SBC_cjs.slash(entryFile), agents);
|
|
469
|
+
const generatedEntry = path.join(outputDirectory, ".mastra-fs-agents-entry.mjs");
|
|
470
|
+
const normalizedMastraDir = chunk7PMC7SBC_cjs.slash(mastraDir);
|
|
471
|
+
const toolPaths = [
|
|
472
|
+
path.posix.join(normalizedMastraDir, "agents/*/tools/**/*.{js,ts}"),
|
|
473
|
+
`!${path.posix.join(normalizedMastraDir, "agents/*/tools/**/*.{test,spec}.{js,ts}")}`,
|
|
474
|
+
`!${path.posix.join(normalizedMastraDir, "agents/*/tools/**/__tests__/**")}`
|
|
475
|
+
];
|
|
476
|
+
return { entryFile: generatedEntry, toolPaths, agentCount: agents.length, moduleSource };
|
|
477
|
+
}
|
|
478
|
+
async function writeFsAgentsEntry(result) {
|
|
479
|
+
if (!result.moduleSource) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
await promises.mkdir(path.dirname(result.entryFile), { recursive: true });
|
|
483
|
+
await promises.writeFile(result.entryFile, result.moduleSource, "utf-8");
|
|
484
|
+
}
|
|
485
|
+
async function rejectSymlinks(source) {
|
|
486
|
+
const stats = await promises.lstat(source);
|
|
487
|
+
return !stats.isSymbolicLink();
|
|
488
|
+
}
|
|
489
|
+
async function mirrorAgentSeeds(agent, workspaceName, bundleDir, mirrored) {
|
|
490
|
+
if (agent.workspaceSeedDir) {
|
|
491
|
+
const destination = path.join(bundleDir, "workspace", ...workspaceName.split("/"));
|
|
492
|
+
await promises.mkdir(destination, { recursive: true });
|
|
493
|
+
await promises.cp(agent.workspaceSeedDir, destination, { recursive: true, filter: rejectSymlinks });
|
|
494
|
+
mirrored.push(workspaceName);
|
|
495
|
+
}
|
|
496
|
+
for (const child of agent.subagents ?? []) {
|
|
497
|
+
await mirrorAgentSeeds(child, `${workspaceName}/${child.name}`, bundleDir, mirrored);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
async function mirrorFsAgentWorkspaces(mastraDir, bundleDir) {
|
|
501
|
+
const agents = await discoverFsAgents(mastraDir);
|
|
502
|
+
const mirrored = [];
|
|
503
|
+
for (const agent of agents) {
|
|
504
|
+
await mirrorAgentSeeds(agent, agent.name, bundleDir, mirrored);
|
|
505
|
+
}
|
|
506
|
+
return mirrored;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
exports.createWatcher = createWatcher;
|
|
510
|
+
exports.discoverFsAgents = discoverFsAgents;
|
|
511
|
+
exports.generateFsAgentsModule = generateFsAgentsModule;
|
|
512
|
+
exports.getInputOptions = getInputOptions2;
|
|
513
|
+
exports.getServerOptions = getServerOptions;
|
|
514
|
+
exports.mirrorFsAgentWorkspaces = mirrorFsAgentWorkspaces;
|
|
515
|
+
exports.prepareFsAgentsEntry = prepareFsAgentsEntry;
|
|
516
|
+
exports.writeFsAgentsEntry = writeFsAgentsEntry;
|
|
517
|
+
//# sourceMappingURL=chunk-ZZHJNINJ.cjs.map
|
|
518
|
+
//# sourceMappingURL=chunk-ZZHJNINJ.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","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;AAAA,IACf,SAAA,EAAW;AAAA;AAEf,CAAA,GAA8D,EAAC,EAC/D;AACA,EAAA,MAAM,iBAAqBC,cAAA,CAAA,EAAA,CAAG,EAAE,KAAKC,YAAA,CAAQ,SAAS,GAAG,CAAA;AACzD,EAAA,MAAM,WAAA,GAAc,cAAA,GAAiBA,YAAA,CAAQC,uBAAA,CAAM,cAAc,CAAC,CAAA,GAAIA,uBAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,CAAA;AACzF,EAAA,MAAM,EAAE,cAAc,aAAA,EAAc,GAAI,MAAMC,yCAAA,CAAwB,EAAE,eAAA,EAAiB,SAAA,EAAW,CAAA;AAEpG,EAAA,MAAM,qBAAqB,MAAMC,+BAAA;AAAA,IAC/B,CAAC,SAAS,CAAA;AAAA,IACV,SAAA;AAAA,IACA;AAAA,MACE,WAAWC,UAAA,CAAM,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,WAAW,QAAQ,CAAA;AAAA,MACxD,WAAA,EAAa,aAAA,IAAiB,OAAA,CAAQ,GAAA,EAAI;AAAA,MAC1C,QAAA;AAAA,MACA,KAAA,EAAO,IAAA;AAAA,MACP;AAAA,KACF;AAAA,IACAC;AAAA,GACF;AAEA,EAAA,MAAM,IAAA,uBAA2B,GAAA,EAAI;AACrC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,QAAQ,KAAK,kBAAA,C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rG,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-ZZHJNINJ.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 }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions } = {},\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 [entryFile],\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 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 /**\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 are one level deep only: a discovered subagent never carries its\n * own `subagents` (nested `subagents/` directories are 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 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 * 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 (when `allowSubagents`) one level of\n * declared `subagents/`. Returns `undefined` when `dir` is not an agent\n * directory (no `config.(ts|js)` and no `instructions.md`).\n *\n * `allowSubagents` is `true` for top-level agents and `false` when discovering a\n * subagent, so nested `subagents/` directories are never recursed into.\n */\nasync function discoverAgentDir(\n dir: string,\n name: string,\n allowSubagents: boolean,\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 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, allowSubagents, onWarn);\n\n return {\n name,\n dir: slash(dir),\n configPath,\n instructionsPath,\n workspacePath,\n workspaceSeedDir,\n tools,\n skills,\n subagents,\n };\n}\n\n/**\n * Discover declared subagents under `<dir>/subagents/*`. Subagents are one level\n * deep only: each discovered subagent is scanned with `allowSubagents: false`,\n * so a nested `subagents/` directory inside a subagent is ignored with a warning.\n * When `allowSubagents` is `false` (we are already inside a subagent) the whole\n * `subagents/` directory is skipped and a warning is emitted if present.\n */\nasync function discoverSubagents(\n parentDir: string,\n allowSubagents: boolean,\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 (!allowSubagents) {\n onWarn?.(\n `Ignoring nested subagents in \"${slash(subagentsDir)}\": subagents are one level deep only, so a subagent cannot declare its own subagents.`,\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, false, 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 top-level agent may\n * declare one level of `subagents/`. Returns descriptors with absolute,\n * slash-normalized paths ready for codegen. Performs no module evaluation —\n * 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, true, 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. When `allowSubagents` is true the agent's discovered subagents\n * are emitted as a nested `subagents: [...]` field.\n */\nasync function emitAgentEntry(\n agent: DiscoveredFsAgent,\n idPath: string,\n workspaceName: string,\n allowSubagents: boolean,\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 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 (one level deep). Each is itself an\n // `assembleAgentFromFsEntry` entry object with no further `subagents`.\n const subagentExprs: string[] = [];\n if (allowSubagents) {\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}`, false, lines);\n subagentExprs.push(childExpr);\n }\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 // 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`, and `skills/*.ts`\n * (`createSkill(...)` modules), inlining packaged `SKILL.md` skills,\n * 3. assembles `Agent` instances via `assembleAgentFromFsEntry`, wiring any\n * declared `subagents/` into the parent (one level deep),\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 = agents.some(a =>\n [a, ...(a.subagents ?? [])].some(x => (x.skills ?? []).some(s => s.kind === 'packaged')),\n );\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, true, 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"]}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.48.0-alpha.
|
|
6
|
+
version: "1.48.0-alpha.7"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.48.0-alpha.
|
|
2
|
+
"version": "1.48.0-alpha.7",
|
|
3
3
|
"package": "@mastra/deployer",
|
|
4
4
|
"exports": {
|
|
5
5
|
"Deps": {
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"implementation": "dist/chunk-
|
|
7
|
+
"implementation": "dist/chunk-5GX66TF5.js",
|
|
8
8
|
"line": 62
|
|
9
9
|
},
|
|
10
10
|
"FileService": {
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
|
-
"implementation": "dist/chunk-
|
|
12
|
+
"implementation": "dist/chunk-5GX66TF5.js",
|
|
13
13
|
"line": 357
|
|
14
14
|
},
|
|
15
15
|
"createChildProcessLogger": {
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"implementation": "dist/chunk-
|
|
17
|
+
"implementation": "dist/chunk-5GX66TF5.js",
|
|
18
18
|
"line": 24
|
|
19
19
|
},
|
|
20
20
|
"createPinoStream": {
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"implementation": "dist/chunk-
|
|
22
|
+
"implementation": "dist/chunk-5GX66TF5.js",
|
|
23
23
|
"line": 12
|
|
24
24
|
}
|
|
25
25
|
},
|