mastra 0.1.57-unstable.56 → 0.1.57-unstable.88
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/dist/commands/create/create.d.ts +8 -0
- package/dist/commands/create/create.d.ts.map +1 -0
- package/dist/commands/create/create.js +35 -0
- package/dist/commands/create/utils.d.ts +4 -0
- package/dist/commands/create/utils.d.ts.map +1 -0
- package/dist/commands/create/utils.js +58 -0
- package/dist/commands/deploy/cloudflare/index.d.ts.map +1 -1
- package/dist/commands/deploy/cloudflare/index.js +2 -0
- package/dist/commands/deploy/deployer.d.ts +4 -2
- package/dist/commands/deploy/deployer.d.ts.map +1 -1
- package/dist/commands/deploy/deployer.js +4 -4
- package/dist/commands/deploy/index.d.ts +2 -1
- package/dist/commands/deploy/index.d.ts.map +1 -1
- package/dist/commands/deploy/index.js +2 -2
- package/dist/commands/deploy/netlify/index.d.ts.map +1 -1
- package/dist/commands/deploy/netlify/index.js +2 -0
- package/dist/commands/deploy/vercel/index.d.ts +2 -1
- package/dist/commands/deploy/vercel/index.d.ts.map +1 -1
- package/dist/commands/deploy/vercel/index.js +4 -1
- package/dist/commands/dev.d.ts +1 -7
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +117 -12
- package/dist/commands/engine/down.d.ts +1 -1
- package/dist/commands/engine/down.d.ts.map +1 -1
- package/dist/commands/engine/down.js +3 -2
- package/dist/commands/engine/up.d.ts +1 -1
- package/dist/commands/engine/up.d.ts.map +1 -1
- package/dist/commands/engine/up.js +3 -2
- package/dist/commands/init/init.d.ts +2 -2
- package/dist/commands/init/init.d.ts.map +1 -1
- package/dist/commands/init/init.js +33 -9
- package/dist/commands/init/utils.d.ts +21 -9
- package/dist/commands/init/utils.d.ts.map +1 -1
- package/dist/commands/init/utils.js +64 -74
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -57
- package/dist/services/service.deps.d.ts +1 -0
- package/dist/services/service.deps.d.ts.map +1 -1
- package/dist/services/service.deps.js +8 -0
- package/dist/services/service.docker.d.ts +1 -0
- package/dist/services/service.docker.d.ts.map +1 -1
- package/dist/services/service.docker.js +20 -0
- package/dist/src/starter-files/config.ts +28 -0
- package/dist/src/starter-files/mastra-pg.docker-compose.yaml +15 -0
- package/dist/src/starter-files/tools.ts +95 -0
- package/dist/src/starter-files/workflow.ts +173 -0
- package/dist/templates/express-server.d.ts.map +1 -1
- package/dist/templates/express-server.js +70 -43
- package/dist/templates/netlify.d.ts.map +1 -1
- package/dist/templates/netlify.js +199 -34
- package/dist/templates/worker.d.ts.map +1 -1
- package/dist/templates/worker.js +255 -35
- package/dist/utils/bundle.d.ts +4 -1
- package/dist/utils/bundle.d.ts.map +1 -1
- package/dist/utils/bundle.js +28 -13
- package/package.json +7 -3
- package/src/playground/dist/assets/dark-plus-C3mMm8J8.js +1 -0
- package/src/playground/dist/assets/erb-BgreK6rt.js +1 -0
- package/src/playground/dist/assets/{gdresource-D_y5yz_M.js → gdresource-NFcQ0Q3Z.js} +1 -1
- package/src/playground/dist/assets/gdscript-BVlVXSjx.js +1 -0
- package/src/playground/dist/assets/{hcl-Cztwc-HH.js → hcl-_Zu0RE-q.js} +1 -1
- package/src/playground/dist/assets/index-BiEU7Tmg.js +389 -0
- package/src/playground/dist/assets/index-Cke4BidO.js +13 -0
- package/src/playground/dist/assets/light-plus-B7mTdjB0.js +1 -0
- package/src/playground/dist/assets/{monokai-CQWsIgnU.js → monokai-D4h5O-jR.js} +1 -1
- package/src/playground/dist/assets/prisma-CZzQMiei.js +1 -0
- package/src/playground/dist/assets/red-bN70gL4F.js +1 -0
- package/src/playground/dist/assets/rst-BCmapc_q.js +1 -0
- package/src/playground/dist/assets/ruby-DsC6krmi.js +1 -0
- package/src/playground/dist/assets/{solarized-dark-CmY0Y6Yh.js → solarized-dark-DXbdFlpD.js} +1 -1
- package/src/playground/dist/assets/{solarized-light-DZQMDcrx.js → solarized-light-L9t79GZl.js} +1 -1
- package/src/playground/dist/assets/style-7CS44jOg.css +1 -0
- package/src/playground/dist/assets/twig-CvAdjvFj.js +1 -0
- package/src/playground/dist/assets/{vue-html-x3hEOujm.js → vue-html-59TQSa_j.js} +1 -1
- package/src/playground/dist/assets/vue-srE0XGv_.js +1 -0
- package/src/playground/dist/index.html +2 -2
- package/src/starter-files/tools.ts +88 -14
- package/src/starter-files/workflow.ts +160 -21
- package/src/playground/dist/assets/dark-plus-B74Y8nHz.js +0 -1
- package/src/playground/dist/assets/erb-DuefeV9w.js +0 -1
- package/src/playground/dist/assets/gdscript-BIguuW30.js +0 -1
- package/src/playground/dist/assets/index-CzqDlQul.js +0 -13
- package/src/playground/dist/assets/index-qFy09kRJ.js +0 -360
- package/src/playground/dist/assets/light-plus-w1el_4yc.js +0 -1
- package/src/playground/dist/assets/prisma-DFIOpqzz.js +0 -1
- package/src/playground/dist/assets/red-2pWuV6-S.js +0 -1
- package/src/playground/dist/assets/rst-BtGMdPX_.js +0 -1
- package/src/playground/dist/assets/ruby-C8Yez0Ov.js +0 -1
- package/src/playground/dist/assets/style-x_8NJ6Q9.css +0 -1
- package/src/playground/dist/assets/twig-DN6YEzOP.js +0 -1
- package/src/playground/dist/assets/vue-xldAUJov.js +0 -1
- package/src/starter-files/api.ts +0 -11
- package/src/starter-files/framework-utils.ts +0 -33
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create/create.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIlE,eAAO,MAAM,MAAM,SAAgB;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kBAyBA,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import color from 'picocolors';
|
|
3
|
+
import { init } from '../init/init.js';
|
|
4
|
+
import { interactivePrompt } from '../init/utils.js';
|
|
5
|
+
import { createMastraProject } from './utils.js';
|
|
6
|
+
export const create = async (args) => {
|
|
7
|
+
const { projectName } = await createMastraProject();
|
|
8
|
+
const directory = '/src';
|
|
9
|
+
if (!args.components || !args.llmProvider || !args.addExample) {
|
|
10
|
+
const result = await interactivePrompt();
|
|
11
|
+
await init({
|
|
12
|
+
...result,
|
|
13
|
+
llmApiKey: result?.llmApiKey,
|
|
14
|
+
});
|
|
15
|
+
postCreate({ projectName });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { components = [], llmProvider = 'openai', addExample = false, llmApiKey } = args;
|
|
19
|
+
await init({
|
|
20
|
+
directory,
|
|
21
|
+
components,
|
|
22
|
+
llmProvider,
|
|
23
|
+
addExample,
|
|
24
|
+
llmApiKey,
|
|
25
|
+
});
|
|
26
|
+
postCreate({ projectName });
|
|
27
|
+
};
|
|
28
|
+
const postCreate = ({ projectName }) => {
|
|
29
|
+
p.outro(`
|
|
30
|
+
${color.green('To start your project:')}
|
|
31
|
+
|
|
32
|
+
${color.cyan('cd')} ${projectName}
|
|
33
|
+
${color.cyan('npm run dev')}
|
|
34
|
+
`);
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commands/create/utils.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,mBAAmB;;EA6D/B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import child_process from 'node:child_process';
|
|
3
|
+
import util from 'node:util';
|
|
4
|
+
import color from 'picocolors';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import { DepsService } from '../../services/service.deps.js';
|
|
7
|
+
import { logger } from '../../utils/logger.js';
|
|
8
|
+
const exec = util.promisify(child_process.exec);
|
|
9
|
+
export const createMastraProject = async () => {
|
|
10
|
+
p.intro(color.inverse('Mastra Create'));
|
|
11
|
+
const projectName = await p.text({
|
|
12
|
+
message: 'What do you want to name your project?',
|
|
13
|
+
placeholder: 'my-mastra-app',
|
|
14
|
+
defaultValue: 'my-mastra-app',
|
|
15
|
+
});
|
|
16
|
+
if (p.isCancel(projectName)) {
|
|
17
|
+
p.cancel('Operation cancelled');
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
const s = p.spinner();
|
|
21
|
+
s.start('Creating project');
|
|
22
|
+
try {
|
|
23
|
+
await fs.mkdir(projectName);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error instanceof Error && 'code' in error && error.code === 'EEXIST') {
|
|
27
|
+
s.stop(`A directory named "${projectName}" already exists. Please choose a different name or delete the existing directory.`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
process.chdir(projectName);
|
|
33
|
+
s.message('Creating project');
|
|
34
|
+
await exec(`npm init -y`);
|
|
35
|
+
const depsService = new DepsService();
|
|
36
|
+
await depsService.addScriptsToPackageJson({
|
|
37
|
+
dev: 'mastra dev',
|
|
38
|
+
});
|
|
39
|
+
s.stop('Project created');
|
|
40
|
+
s.start('Installing npm dependencies');
|
|
41
|
+
await exec(`npm i zod`);
|
|
42
|
+
await exec(`npm i typescript tsx @types/node --save-dev`);
|
|
43
|
+
s.stop('NPM dependencies installed');
|
|
44
|
+
s.start('Installing mastra');
|
|
45
|
+
await exec(`npm i -D mastra`);
|
|
46
|
+
s.stop('mastra installed');
|
|
47
|
+
s.start('Installing @mastra/core');
|
|
48
|
+
await exec(`npm i @mastra/core@alpha`);
|
|
49
|
+
s.stop('@mastra/core installed');
|
|
50
|
+
s.start('Adding .gitignore');
|
|
51
|
+
await exec(`echo output.txt >> .gitignore`);
|
|
52
|
+
await exec(`echo node_modules >> .gitignore`);
|
|
53
|
+
await exec(`echo dist >> .gitignore`);
|
|
54
|
+
s.stop('.gitignore added');
|
|
55
|
+
p.outro('Project created successfully');
|
|
56
|
+
logger.break();
|
|
57
|
+
return { projectName };
|
|
58
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/cloudflare/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,IAAI,SAAgB;IAEd,UAAU;IAMV,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/cloudflare/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,IAAI,SAAgB;IAEd,UAAU;IAMV,YAAY;IA2BlB,UAAU,IAAI,IAAI;IA+BZ,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAajE"}
|
|
@@ -15,14 +15,16 @@ export declare abstract class Deployer {
|
|
|
15
15
|
}): Promise<void>;
|
|
16
16
|
writePkgJson(): void;
|
|
17
17
|
writeFiles(): void;
|
|
18
|
-
deployCommand({ scope, siteId }: {
|
|
18
|
+
deployCommand({ scope, siteId, projectName }: {
|
|
19
19
|
scope: string;
|
|
20
20
|
siteId?: string;
|
|
21
|
+
projectName?: string;
|
|
21
22
|
}): Promise<void>;
|
|
22
|
-
deploy({ scope, siteId, dir }: {
|
|
23
|
+
deploy({ scope, siteId, dir, projectName, }: {
|
|
23
24
|
dir?: string;
|
|
24
25
|
scope: string;
|
|
25
26
|
siteId?: string;
|
|
27
|
+
projectName?: string;
|
|
26
28
|
}): Promise<void>;
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=deployer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deployer.ts"],"names":[],"mappings":"AAMA,8BAAsB,QAAQ;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAM;gBAEN,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAMlC,UAAU;IAIV,OAAO;IASb,SAAS,CAAC,WAAW,IAAI,MAAM,EAAE;IAOjC,UAAU;IAkBV,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAS5C,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IAQpC,YAAY;IAIZ,UAAU;IAIJ,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deployer.ts"],"names":[],"mappings":"AAMA,8BAAsB,QAAQ;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAM;gBAEN,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAMlC,UAAU;IAIV,OAAO;IASb,SAAS,CAAC,WAAW,IAAI,MAAM,EAAE;IAOjC,UAAU;IAkBV,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAS5C,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IAQpC,YAAY;IAIZ,UAAU;IAIJ,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAItG,MAAM,CAAC,EACX,KAAK,EACL,MAAM,EACN,GAAG,EACH,WAAW,GACZ,EAAE;QACD,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;CAUF"}
|
|
@@ -61,10 +61,10 @@ export class Deployer {
|
|
|
61
61
|
writeFiles() {
|
|
62
62
|
console.log('Writing files...');
|
|
63
63
|
}
|
|
64
|
-
async deployCommand({ scope, siteId }) {
|
|
65
|
-
console.log(`Deploy command ${scope}...${siteId || ''}`);
|
|
64
|
+
async deployCommand({ scope, siteId, projectName }) {
|
|
65
|
+
console.log(`Deploy command ${scope}...${siteId || ''} to ${projectName || 'mastra-starter'}`);
|
|
66
66
|
}
|
|
67
|
-
async deploy({ scope, siteId, dir }) {
|
|
67
|
+
async deploy({ scope, siteId, dir, projectName, }) {
|
|
68
68
|
console.log('Deploying...', scope);
|
|
69
69
|
const dirPath = dir || path.join(process.cwd(), 'src/mastra');
|
|
70
70
|
await this.installCli();
|
|
@@ -72,6 +72,6 @@ export class Deployer {
|
|
|
72
72
|
this.writeFiles();
|
|
73
73
|
await this.install();
|
|
74
74
|
await this.build({ dir: dirPath });
|
|
75
|
-
await this.deployCommand({ scope, siteId });
|
|
75
|
+
await this.deployCommand({ scope, siteId, projectName });
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,YAAY,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,iBAmD9F;AAoBD,wBAAsB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,iBAmD/D;AAgFD,wBAAsB,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,iBAuD5D"}
|
|
@@ -31,7 +31,7 @@ async function fetchVercelTeams(authToken) {
|
|
|
31
31
|
throw error;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
export async function vercelDeploy({ dir }) {
|
|
34
|
+
export async function vercelDeploy({ dir, projectName }) {
|
|
35
35
|
prompts.intro(color.inverse(' Deploying to Vercel '));
|
|
36
36
|
const creds = getCreds('VERCEL');
|
|
37
37
|
let token;
|
|
@@ -68,7 +68,7 @@ export async function vercelDeploy({ dir }) {
|
|
|
68
68
|
scope = creds.scope;
|
|
69
69
|
}
|
|
70
70
|
const deployer = new VercelDeployer({ token });
|
|
71
|
-
await deployer.deploy({ scope, dir });
|
|
71
|
+
await deployer.deploy({ scope, dir, projectName });
|
|
72
72
|
logger.log('Deployment complete!');
|
|
73
73
|
process.exit(0);
|
|
74
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/netlify/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,IAAI,SAAa;IAEjB,mBAAmB;IAMb,UAAU;IAMV,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/netlify/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,IAAI,SAAa;IAEjB,mBAAmB;IAMb,UAAU;IAMV,YAAY;IA8BlB,UAAU,IAAI,IAAI;IAoBZ,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CASzF"}
|
|
@@ -8,8 +8,9 @@ export declare class VercelDeployer extends Deployer {
|
|
|
8
8
|
syncEnv({ scope }: {
|
|
9
9
|
scope: string;
|
|
10
10
|
}): Promise<void>;
|
|
11
|
-
deployCommand({ scope }: {
|
|
11
|
+
deployCommand({ scope, projectName, }: {
|
|
12
12
|
scope: string;
|
|
13
|
+
projectName?: string;
|
|
13
14
|
}): Promise<void>;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/vercel/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAe1C,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,IAAI,SAAY;IACV,UAAU;IAMV,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/vercel/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAe1C,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,IAAI,SAAY;IACV,UAAU;IAMV,YAAY;IA8BlB,UAAU;IA4BV,OAAO,CAAC,YAAY;IAUd,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAqDpC,aAAa,CAAC,EAClB,KAAK,EACL,WAA8B,GAC/B,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,IAAI,CAAC;CA6ClB"}
|
|
@@ -30,6 +30,8 @@ export class VercelDeployer extends Deployer {
|
|
|
30
30
|
'@mastra/core': '0.1.27-alpha.35',
|
|
31
31
|
'express-jsdoc-swagger': '^1.8.0',
|
|
32
32
|
'serverless-http': '^3.2.0',
|
|
33
|
+
superjson: '^2.2.2',
|
|
34
|
+
'zod-to-json-schema': '^3.24.1',
|
|
33
35
|
zod: '3.24.0',
|
|
34
36
|
},
|
|
35
37
|
}, null, 2));
|
|
@@ -110,7 +112,7 @@ export class VercelDeployer extends Deployer {
|
|
|
110
112
|
throw error;
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
|
-
async deployCommand({ scope }) {
|
|
115
|
+
async deployCommand({ scope, projectName = 'mastra-starter', }) {
|
|
114
116
|
// Get env vars for initial deployment
|
|
115
117
|
const envFiles = this.getEnvFiles();
|
|
116
118
|
const envVars = [];
|
|
@@ -128,6 +130,7 @@ export class VercelDeployer extends Deployer {
|
|
|
128
130
|
'--token',
|
|
129
131
|
this.token,
|
|
130
132
|
'--yes',
|
|
133
|
+
...(projectName ? ['--name', projectName] : []),
|
|
131
134
|
];
|
|
132
135
|
// Add env vars to initial deployment
|
|
133
136
|
for (const envVar of envVars) {
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -3,11 +3,5 @@ export declare function dev({ port, env, dir, toolsDirs, }: {
|
|
|
3
3
|
port: number;
|
|
4
4
|
env: Record<string, any>;
|
|
5
5
|
toolsDirs?: string;
|
|
6
|
-
}): Promise<
|
|
7
|
-
cwd: string;
|
|
8
|
-
env: {
|
|
9
|
-
port: string;
|
|
10
|
-
MASTRA_TOOLS_PATH: string;
|
|
11
|
-
};
|
|
12
|
-
}>>;
|
|
6
|
+
}): Promise<void>;
|
|
13
7
|
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAqGA,wBAAsB,GAAG,CAAC,EACxB,IAAI,EACJ,GAAG,EACH,GAAG,EACH,SAAS,GACV,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iBA4HA"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { watch } from 'chokidar';
|
|
1
2
|
import { config } from 'dotenv';
|
|
2
3
|
import { execa } from 'execa';
|
|
3
4
|
import { writeFileSync } from 'fs';
|
|
@@ -11,6 +12,78 @@ import { bundle, bundleServer } from '../utils/bundle.js';
|
|
|
11
12
|
import { EXPRESS_SERVER } from './deploy/server.js';
|
|
12
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
14
|
const __dirname = path.dirname(__filename);
|
|
15
|
+
let currentServerProcess;
|
|
16
|
+
async function rebundleAndRestart(dirPath, dotMastraPath, port, toolsDirs) {
|
|
17
|
+
if (currentServerProcess) {
|
|
18
|
+
console.log('Stopping current server...');
|
|
19
|
+
currentServerProcess.kill();
|
|
20
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
Bundle mastra
|
|
24
|
+
*/
|
|
25
|
+
await bundle(dirPath, { buildName: 'Mastra' });
|
|
26
|
+
/*
|
|
27
|
+
Bundle tools
|
|
28
|
+
*/
|
|
29
|
+
const defaultToolsPath = path.join(dirPath, 'tools');
|
|
30
|
+
const toolsPaths = [...(toolsDirs?.split(',').map(tool => path.join(process.cwd(), tool)) || []), defaultToolsPath];
|
|
31
|
+
const toolPathsWithFileNames = (await Promise.all(toolsPaths.map(async (toolPath) => {
|
|
32
|
+
try {
|
|
33
|
+
const files = await fs.readdir(toolPath);
|
|
34
|
+
return files.map(file => {
|
|
35
|
+
const fullPath = path.join(toolPath, file);
|
|
36
|
+
const fileName = path.parse(file).name;
|
|
37
|
+
const name = fileName === 'index' ? path.basename(path.dirname(fullPath)) : fileName;
|
|
38
|
+
return {
|
|
39
|
+
path: toolPath,
|
|
40
|
+
name,
|
|
41
|
+
fileName,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (toolPath === defaultToolsPath) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
console.warn(`Error reading tools directory ${toolPath}:`, err);
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}))).flat();
|
|
53
|
+
for (const { path, name, fileName } of toolPathsWithFileNames) {
|
|
54
|
+
await bundle(path, {
|
|
55
|
+
outfile: join(dotMastraPath, 'tools', `${name}.mjs`),
|
|
56
|
+
entryFile: fileName,
|
|
57
|
+
buildName: `${name}`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const MASTRA_TOOLS_PATH = toolPathsWithFileNames?.length
|
|
61
|
+
? toolPathsWithFileNames.map(tool => path.join(dotMastraPath, 'tools', `${tool.name}.mjs`)).join(',')
|
|
62
|
+
: undefined;
|
|
63
|
+
try {
|
|
64
|
+
console.log('Restarting server...');
|
|
65
|
+
currentServerProcess = execa('node', ['server.mjs'], {
|
|
66
|
+
cwd: dotMastraPath,
|
|
67
|
+
env: {
|
|
68
|
+
PORT: port.toString() || '4111',
|
|
69
|
+
MASTRA_TOOLS_PATH,
|
|
70
|
+
},
|
|
71
|
+
stdio: 'inherit',
|
|
72
|
+
reject: false,
|
|
73
|
+
});
|
|
74
|
+
if (currentServerProcess.failed) {
|
|
75
|
+
console.error('Server failed to restart with error:', currentServerProcess.stderr);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
const execaError = err;
|
|
81
|
+
if (execaError.stderr)
|
|
82
|
+
console.error('Server error output:', execaError.stderr);
|
|
83
|
+
if (execaError.stdout)
|
|
84
|
+
console.error('Server output:', execaError.stdout);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
14
87
|
export async function dev({ port, env, dir, toolsDirs, }) {
|
|
15
88
|
const dotMastraPath = join(process.cwd(), '.mastra');
|
|
16
89
|
const playgroundServePath = join(dotMastraPath, 'playground');
|
|
@@ -39,7 +112,7 @@ export async function dev({ port, env, dir, toolsDirs, }) {
|
|
|
39
112
|
Bundle mastra
|
|
40
113
|
*/
|
|
41
114
|
const dirPath = dir || path.join(process.cwd(), 'src/mastra');
|
|
42
|
-
await bundle(dirPath);
|
|
115
|
+
await bundle(dirPath, { buildName: 'Mastra' });
|
|
43
116
|
/*
|
|
44
117
|
Bundle tools
|
|
45
118
|
*/
|
|
@@ -55,6 +128,7 @@ export async function dev({ port, env, dir, toolsDirs, }) {
|
|
|
55
128
|
return {
|
|
56
129
|
path: toolPath,
|
|
57
130
|
name,
|
|
131
|
+
fileName,
|
|
58
132
|
};
|
|
59
133
|
});
|
|
60
134
|
}
|
|
@@ -66,9 +140,11 @@ export async function dev({ port, env, dir, toolsDirs, }) {
|
|
|
66
140
|
return [];
|
|
67
141
|
}
|
|
68
142
|
}))).flat();
|
|
69
|
-
for (const { path, name } of toolPathsWithFileNames) {
|
|
143
|
+
for (const { path, name, fileName } of toolPathsWithFileNames) {
|
|
70
144
|
await bundle(path, {
|
|
71
145
|
outfile: join(dotMastraPath, 'tools', `${name}.mjs`),
|
|
146
|
+
entryFile: fileName,
|
|
147
|
+
buildName: `${name}`,
|
|
72
148
|
});
|
|
73
149
|
}
|
|
74
150
|
/*
|
|
@@ -79,14 +155,43 @@ export async function dev({ port, env, dir, toolsDirs, }) {
|
|
|
79
155
|
const MASTRA_TOOLS_PATH = toolPathsWithFileNames?.length
|
|
80
156
|
? toolPathsWithFileNames.map(tool => path.join(dotMastraPath, 'tools', `${tool.name}.mjs`)).join(',')
|
|
81
157
|
: undefined;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
158
|
+
try {
|
|
159
|
+
console.log('Starting server...');
|
|
160
|
+
currentServerProcess = execa('node', ['server.mjs'], {
|
|
161
|
+
cwd: dotMastraPath,
|
|
162
|
+
env: {
|
|
163
|
+
PORT: port.toString() || '4111',
|
|
164
|
+
MASTRA_TOOLS_PATH,
|
|
165
|
+
},
|
|
166
|
+
stdio: 'inherit',
|
|
167
|
+
reject: false,
|
|
168
|
+
});
|
|
169
|
+
if (currentServerProcess.failed) {
|
|
170
|
+
console.error('Server failed to start with error:', currentServerProcess.stderr);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
const watcher = watch(dirPath, {
|
|
174
|
+
persistent: true,
|
|
175
|
+
});
|
|
176
|
+
watcher.on('change', async () => {
|
|
177
|
+
console.log(`Changes detected`);
|
|
178
|
+
await rebundleAndRestart(dirPath, dotMastraPath, port, toolsDirs);
|
|
179
|
+
});
|
|
180
|
+
process.on('SIGINT', () => {
|
|
181
|
+
console.log('Stopping server...');
|
|
182
|
+
if (currentServerProcess) {
|
|
183
|
+
currentServerProcess.kill();
|
|
184
|
+
}
|
|
185
|
+
watcher.close();
|
|
186
|
+
process.exit(0);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
const execaError = err;
|
|
191
|
+
if (execaError.stderr)
|
|
192
|
+
console.error('Server error output:', execaError.stderr);
|
|
193
|
+
if (execaError.stdout)
|
|
194
|
+
console.error('Server output:', execaError.stdout);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
92
197
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function down(): Promise<void>;
|
|
1
|
+
export declare function down(composePath?: string): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=down.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"down.d.ts","sourceRoot":"","sources":["../../../src/commands/engine/down.ts"],"names":[],"mappings":"AAIA,wBAAsB,IAAI,
|
|
1
|
+
{"version":3,"file":"down.d.ts","sourceRoot":"","sources":["../../../src/commands/engine/down.ts"],"names":[],"mappings":"AAIA,wBAAsB,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,iBAY9C"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import yoctoSpinner from 'yocto-spinner';
|
|
2
2
|
import { DockerService } from '../../services/service.docker.js';
|
|
3
|
-
export async function down() {
|
|
3
|
+
export async function down(composePath) {
|
|
4
4
|
const spinner = yoctoSpinner({ text: 'Shutting down docker container\n' });
|
|
5
5
|
spinner.start();
|
|
6
6
|
try {
|
|
7
7
|
const dockerService = new DockerService();
|
|
8
|
-
|
|
8
|
+
const composeFile = dockerService.getComposeFile(composePath);
|
|
9
|
+
await dockerService.stopDockerContainer(composeFile);
|
|
9
10
|
spinner.success('Docker container shut down successfully\n');
|
|
10
11
|
}
|
|
11
12
|
catch (error) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function up(): Promise<void>;
|
|
1
|
+
export declare function up(composePath?: string): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=up.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../../src/commands/engine/up.ts"],"names":[],"mappings":"AAIA,wBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../../src/commands/engine/up.ts"],"names":[],"mappings":"AAIA,wBAAsB,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,iBAY5C"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import yoctoSpinner from 'yocto-spinner';
|
|
2
2
|
import { DockerService } from '../../services/service.docker.js';
|
|
3
|
-
export async function up() {
|
|
3
|
+
export async function up(composePath) {
|
|
4
4
|
const spinner = yoctoSpinner({ text: 'Starting docker container\n' });
|
|
5
5
|
spinner.start();
|
|
6
6
|
try {
|
|
7
7
|
const dockerService = new DockerService();
|
|
8
|
-
|
|
8
|
+
const composeFile = dockerService.getComposeFile(composePath);
|
|
9
|
+
await dockerService.startDockerContainer(composeFile);
|
|
9
10
|
spinner.success('Docker containers started successfully\n');
|
|
10
11
|
}
|
|
11
12
|
catch (error) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LLMProvider } from './utils.js';
|
|
2
|
-
export declare const init: ({ directory, addExample, components, llmProvider,
|
|
2
|
+
export declare const init: ({ directory, addExample, components, llmProvider, llmApiKey, }: {
|
|
3
3
|
directory: string;
|
|
4
4
|
components: string[];
|
|
5
5
|
llmProvider: LLMProvider;
|
|
6
6
|
addExample: boolean;
|
|
7
|
-
|
|
7
|
+
llmApiKey?: string;
|
|
8
8
|
}) => Promise<{
|
|
9
9
|
success: boolean;
|
|
10
10
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,WAAW,EAIZ,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,IAAI,mEAMd;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;EAqDA,CAAC"}
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import color from 'picocolors';
|
|
3
|
+
import { createComponentsDir, createMastraDir, getAPIKey, writeAPIKey, writeCodeSample, writeIndexFile, } from './utils.js';
|
|
4
|
+
const s = p.spinner();
|
|
5
|
+
export const init = async ({ directory, addExample = false, components, llmProvider = 'openai', llmApiKey, }) => {
|
|
6
|
+
s.start('Initializing Mastra');
|
|
4
7
|
try {
|
|
5
8
|
const result = await createMastraDir(directory);
|
|
6
9
|
if (!result.ok) {
|
|
7
|
-
|
|
10
|
+
s.stop(color.inverse(' Mastra already initialized '));
|
|
8
11
|
return { success: false };
|
|
9
12
|
}
|
|
10
13
|
const dirPath = result.dirPath;
|
|
11
14
|
await Promise.all([
|
|
12
|
-
writeIndexFile(
|
|
15
|
+
writeIndexFile({
|
|
16
|
+
dirPath,
|
|
17
|
+
addExample,
|
|
18
|
+
addWorkflow: components.includes('workflows'),
|
|
19
|
+
addAgent: components.includes('agents'),
|
|
20
|
+
}),
|
|
13
21
|
...components.map(component => createComponentsDir(dirPath, component)),
|
|
14
|
-
writeAPIKey(llmProvider),
|
|
22
|
+
writeAPIKey({ provider: llmProvider, apiKey: llmApiKey }),
|
|
15
23
|
]);
|
|
16
24
|
if (addExample) {
|
|
17
|
-
await Promise.all([
|
|
25
|
+
await Promise.all([
|
|
26
|
+
components.map(component => writeCodeSample(dirPath, component, llmProvider, components)),
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
const key = await getAPIKey(llmProvider || 'openai');
|
|
30
|
+
s.stop();
|
|
31
|
+
if (!llmApiKey) {
|
|
32
|
+
p.note(`
|
|
33
|
+
${color.green('Mastra initialized successfully!')}
|
|
34
|
+
|
|
35
|
+
Add your ${color.cyan(key)} as an environment variable
|
|
36
|
+
in your ${color.cyan('.env.development')} file
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
p.note(`
|
|
41
|
+
${color.green('Mastra initialized successfully!')}
|
|
42
|
+
`);
|
|
18
43
|
}
|
|
19
|
-
showSpinner && logger.success('Mastra initialized successfully');
|
|
20
44
|
return { success: true };
|
|
21
45
|
}
|
|
22
46
|
catch (err) {
|
|
23
|
-
|
|
47
|
+
s.stop(color.inverse('An error occurred while initializing Mastra'));
|
|
24
48
|
console.error(err);
|
|
25
49
|
return { success: false };
|
|
26
50
|
}
|
|
@@ -2,26 +2,38 @@ import { ModelConfig } from '@mastra/core';
|
|
|
2
2
|
export type LLMProvider = 'openai' | 'anthropic' | 'groq';
|
|
3
3
|
export type Components = 'agents' | 'workflows' | 'tools';
|
|
4
4
|
export declare const modelToConfigMap: Record<LLMProvider, ModelConfig>;
|
|
5
|
-
export declare function writeAgentSample(llmProvider: LLMProvider, destPath: string): Promise<void>;
|
|
5
|
+
export declare function writeAgentSample(llmProvider: LLMProvider, destPath: string, addExampleTool: boolean): Promise<void>;
|
|
6
6
|
export declare function writeWorkflowSample(destPath: string): Promise<void>;
|
|
7
7
|
export declare function writeToolSample(destPath: string): Promise<void>;
|
|
8
|
-
export declare function writeCodeSampleForComponents(llmprovider: LLMProvider, component: Components, destPath: string): Promise<void | "">;
|
|
8
|
+
export declare function writeCodeSampleForComponents(llmprovider: LLMProvider, component: Components, destPath: string, components: Components[]): Promise<void | "">;
|
|
9
9
|
export declare const createComponentsDir: (dirPath: string, component: string) => Promise<void>;
|
|
10
|
-
export declare const writeIndexFile: (dirPath
|
|
10
|
+
export declare const writeIndexFile: ({ dirPath, addAgent, addExample, addWorkflow, }: {
|
|
11
|
+
dirPath: string;
|
|
12
|
+
addExample: boolean;
|
|
13
|
+
addWorkflow: boolean;
|
|
14
|
+
addAgent: boolean;
|
|
15
|
+
}) => Promise<void>;
|
|
11
16
|
export declare const checkInitialization: (dirPath: string) => Promise<boolean>;
|
|
12
17
|
export declare const checkAndInstallCoreDeps: () => Promise<void>;
|
|
13
18
|
export declare function installCoreDeps(): Promise<void>;
|
|
14
|
-
export declare const
|
|
19
|
+
export declare const getAPIKey: (provider: LLMProvider) => Promise<string>;
|
|
20
|
+
export declare const writeAPIKey: ({ provider, apiKey, }: {
|
|
21
|
+
provider: LLMProvider;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
}) => Promise<void>;
|
|
15
24
|
export declare const createMastraDir: (directory: string) => Promise<{
|
|
16
25
|
ok: true;
|
|
17
26
|
dirPath: string;
|
|
18
27
|
} | {
|
|
19
28
|
ok: false;
|
|
20
29
|
}>;
|
|
21
|
-
export declare const writeCodeSample: (dirPath: string, component: Components, llmProvider: LLMProvider) => Promise<void>;
|
|
22
|
-
export declare const interactivePrompt: () => Promise<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
export declare const writeCodeSample: (dirPath: string, component: Components, llmProvider: LLMProvider, components: Components[]) => Promise<void>;
|
|
31
|
+
export declare const interactivePrompt: () => Promise<{
|
|
32
|
+
components: string[];
|
|
33
|
+
directory: string;
|
|
34
|
+
llmProvider: "openai" | "anthropic" | "groq";
|
|
35
|
+
llmApiKey: unknown;
|
|
36
|
+
addExample: boolean;
|
|
26
37
|
}>;
|
|
38
|
+
export declare const checkPkgJson: () => Promise<void>;
|
|
27
39
|
//# sourceMappingURL=utils.d.ts.map
|