@mastra/dane 0.0.2-alpha.24 → 0.0.2-alpha.26
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/publish-packages.d.ts.map +1 -1
- package/dist/commands/publish-packages.js +3 -67
- package/dist/mastra/agents/index.d.ts +19 -0
- package/dist/mastra/agents/index.d.ts.map +1 -1
- package/dist/mastra/agents/index.js +3 -1
- package/dist/mastra/index.d.ts +20 -0
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +2 -0
- package/dist/mastra/tools/execa.d.ts +0 -39
- package/dist/mastra/tools/execa.d.ts.map +1 -1
- package/dist/mastra/tools/execa.js +0 -90
- package/dist/mastra/tools/pnpm.d.ts +60 -0
- package/dist/mastra/tools/pnpm.d.ts.map +1 -0
- package/dist/mastra/tools/pnpm.js +128 -0
- package/dist/mastra/workflows/publish-packages.d.ts +3 -0
- package/dist/mastra/workflows/publish-packages.d.ts.map +1 -0
- package/dist/mastra/workflows/publish-packages.js +188 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../src/commands/publish-packages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../src/commands/publish-packages.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,kBASpC"}
|
|
@@ -1,73 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { z } from 'zod';
|
|
5
2
|
import { mastra } from '../mastra/index.js';
|
|
6
3
|
export async function publishPackages() {
|
|
7
4
|
console.log(chalk.green("Hi! I'm Dane!"));
|
|
8
5
|
console.log(chalk.green('Let me publish your packages..\n'));
|
|
9
|
-
const
|
|
10
|
-
const result = await
|
|
11
|
-
|
|
12
|
-
`);
|
|
13
|
-
const resultObj = await agent.generate(`
|
|
14
|
-
ONLY RETURN DATA IF WE HAVE PACKAGES TO PUBLISH. If we do not, return empty arrays.
|
|
15
|
-
Can you format this for me ${result.text}?
|
|
16
|
-
@mastra/core must be first. @mastra/dane should be listed after packages and integrations.
|
|
17
|
-
`, {
|
|
18
|
-
schema: z.object({
|
|
19
|
-
packages: z.array(z.string()),
|
|
20
|
-
integrations: z.array(z.string()),
|
|
21
|
-
danePackage: z.string(),
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
24
|
-
console.log(resultObj.object);
|
|
25
|
-
const packagesToBuild = new Set();
|
|
26
|
-
if (resultObj?.object?.packages) {
|
|
27
|
-
const packages = resultObj.object.packages;
|
|
28
|
-
packages.forEach((pkg) => {
|
|
29
|
-
let pkgName = pkg.replace('@mastra/', '');
|
|
30
|
-
if (pkgName === 'mastra') {
|
|
31
|
-
pkgName = 'cli';
|
|
32
|
-
}
|
|
33
|
-
const pkgPath = path.join(process.cwd(), 'packages', pkgName);
|
|
34
|
-
packagesToBuild.add(pkgPath);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (resultObj?.object?.integrations) {
|
|
38
|
-
const integrations = resultObj.object.integrations;
|
|
39
|
-
integrations.forEach((integration) => {
|
|
40
|
-
let pkgName = integration.replace('@mastra/', '');
|
|
41
|
-
const integrationPath = path.join(process.cwd(), 'integrations', pkgName);
|
|
42
|
-
packagesToBuild.add(integrationPath);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (resultObj?.object?.danePackage) {
|
|
46
|
-
const danePackage = resultObj.object.danePackage;
|
|
47
|
-
let pkgName = danePackage.replace('@mastra/', '');
|
|
48
|
-
const danePackageMapped = path.join(process.cwd(), 'examples', pkgName);
|
|
49
|
-
const pkgJsonPath = readFileSync(path.join(danePackageMapped, 'package.json'), 'utf-8');
|
|
50
|
-
const pkgJson = JSON.parse(pkgJsonPath);
|
|
51
|
-
const dependencies = Object.keys(pkgJson.dependencies || {}).filter((dep) => dep.startsWith('@mastra/'));
|
|
52
|
-
dependencies.forEach((dep) => {
|
|
53
|
-
const pkgName = dep.replace('@mastra/', '');
|
|
54
|
-
const pkgPath = path.join(process.cwd(), 'packages', pkgName);
|
|
55
|
-
packagesToBuild.add(pkgPath);
|
|
56
|
-
});
|
|
57
|
-
packagesToBuild.add(danePackage);
|
|
58
|
-
}
|
|
59
|
-
const pkgSet = Array.from(packagesToBuild.keys());
|
|
60
|
-
if (!packagesToBuild.size) {
|
|
61
|
-
console.error(chalk.red('No packages to build.'));
|
|
62
|
-
process.exit(0);
|
|
63
|
-
}
|
|
64
|
-
let res = await agent.generate(`
|
|
65
|
-
Here are the packages that need to be built: ${pkgSet.join(',')}.
|
|
66
|
-
We need to build core first. And dane last. The rest can be done in parallel.
|
|
67
|
-
`);
|
|
68
|
-
console.log(chalk.green(res.text));
|
|
69
|
-
res = await agent.generate(`
|
|
70
|
-
Publish the changeset and then set the dist-tag of latest to the new version.
|
|
71
|
-
`);
|
|
72
|
-
console.log(chalk.green(result.text));
|
|
6
|
+
const workflow = mastra.getWorkflow('packagePublisher');
|
|
7
|
+
const result = await workflow.execute();
|
|
8
|
+
console.log(result);
|
|
73
9
|
}
|
|
@@ -66,6 +66,25 @@ export declare const danePackagePublisher: Agent<{
|
|
|
66
66
|
}, {
|
|
67
67
|
message: string[];
|
|
68
68
|
}>, import("@mastra/core").ToolExecutionContext<import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
69
|
+
activeDistTag: import("@mastra/core").Tool<"activeDistTag", import("zod").ZodObject<{
|
|
70
|
+
packagePath: import("zod").ZodString;
|
|
71
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
72
|
+
packagePath: string;
|
|
73
|
+
}, {
|
|
74
|
+
packagePath: string;
|
|
75
|
+
}>, import("zod").ZodObject<{
|
|
76
|
+
message: import("zod").ZodString;
|
|
77
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
78
|
+
message: string;
|
|
79
|
+
}, {
|
|
80
|
+
message: string;
|
|
81
|
+
}>, import("@mastra/core").ToolExecutionContext<import("zod").ZodObject<{
|
|
82
|
+
packagePath: import("zod").ZodString;
|
|
83
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
84
|
+
packagePath: string;
|
|
85
|
+
}, {
|
|
86
|
+
packagePath: string;
|
|
87
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
69
88
|
}>;
|
|
70
89
|
export declare const dane: Agent<{
|
|
71
90
|
fsTool: import("@mastra/core").Tool<"fsTool", import("zod").ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAmBrC,eAAO,MAAM,iBAAiB,8EAU5B,CAAC;AAEH,eAAO,MAAM,gBAAgB,8EAO3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc/B,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDf,CAAC"}
|
|
@@ -3,10 +3,11 @@ import { config } from '../../config/index.js';
|
|
|
3
3
|
import { browserTool, googleSearch } from '../tools/browser.js';
|
|
4
4
|
import { listEvents } from '../tools/calendar.js';
|
|
5
5
|
import { crawl } from '../tools/crawl.js';
|
|
6
|
-
import { execaTool
|
|
6
|
+
import { execaTool } from '../tools/execa.js';
|
|
7
7
|
import { fsTool } from '../tools/fs.js';
|
|
8
8
|
import { imageTool } from '../tools/image.js';
|
|
9
9
|
import { readPDF } from '../tools/pdf.js';
|
|
10
|
+
import { activeDistTag, pnpmBuild, pnpmChangesetPublish, pnpmChangesetStatus } from '../tools/pnpm.js';
|
|
10
11
|
const getBaseModelConfig = () => ({
|
|
11
12
|
provider: 'ANTHROPIC',
|
|
12
13
|
toolChoice: 'auto',
|
|
@@ -44,6 +45,7 @@ export const danePackagePublisher = new Agent({
|
|
|
44
45
|
pnpmBuild,
|
|
45
46
|
pnpmChangesetPublish,
|
|
46
47
|
pnpmChangesetStatus,
|
|
48
|
+
activeDistTag,
|
|
47
49
|
},
|
|
48
50
|
});
|
|
49
51
|
export const dane = new Agent({
|
package/dist/mastra/index.d.ts
CHANGED
|
@@ -260,6 +260,25 @@ export declare const mastra: Mastra<{
|
|
|
260
260
|
}, {
|
|
261
261
|
message: string[];
|
|
262
262
|
}>, import("@mastra/core").ToolExecutionContext<import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
263
|
+
activeDistTag: import("@mastra/core").Tool<"activeDistTag", import("zod").ZodObject<{
|
|
264
|
+
packagePath: import("zod").ZodString;
|
|
265
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
266
|
+
packagePath: string;
|
|
267
|
+
}, {
|
|
268
|
+
packagePath: string;
|
|
269
|
+
}>, import("zod").ZodObject<{
|
|
270
|
+
message: import("zod").ZodString;
|
|
271
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
272
|
+
message: string;
|
|
273
|
+
}, {
|
|
274
|
+
message: string;
|
|
275
|
+
}>, import("@mastra/core").ToolExecutionContext<import("zod").ZodObject<{
|
|
276
|
+
packagePath: import("zod").ZodString;
|
|
277
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
278
|
+
packagePath: string;
|
|
279
|
+
}, {
|
|
280
|
+
packagePath: string;
|
|
281
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
263
282
|
}>;
|
|
264
283
|
daneIssueLabeler: import("@mastra/core").Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
|
|
265
284
|
daneCommitMessage: import("@mastra/core").Agent<Record<string, import("@mastra/core").ToolAction<any, any, any, any>>>;
|
|
@@ -294,5 +313,6 @@ export declare const mastra: Mastra<{
|
|
|
294
313
|
}, {
|
|
295
314
|
repoPath: string;
|
|
296
315
|
}>>;
|
|
316
|
+
packagePublisher: import("@mastra/core").Workflow<any, any>;
|
|
297
317
|
}, import("@mastra/core").BaseLogger<import("@mastra/core").BaseLogMessage>>;
|
|
298
318
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mastra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mastra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAatC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAuBjB,CAAC"}
|
package/dist/mastra/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { UpstashKVMemory } from '@mastra/memory';
|
|
|
4
4
|
import { dane, daneCommitMessage, daneIssueLabeler, danePackagePublisher } from './agents/index.js';
|
|
5
5
|
import { firecrawl } from './integrations/index.js';
|
|
6
6
|
import { messageWorkflow, githubIssueLabeler, commitMessageGenerator } from './workflows/index.js';
|
|
7
|
+
import { packagePublisher } from './workflows/publish-packages.js';
|
|
7
8
|
const engine = new PostgresEngine({
|
|
8
9
|
url: 'postgres://postgres:postgres@localhost:5433/mastra',
|
|
9
10
|
});
|
|
@@ -24,6 +25,7 @@ export const mastra = new Mastra({
|
|
|
24
25
|
message: messageWorkflow,
|
|
25
26
|
githubIssueLabeler: githubIssueLabeler,
|
|
26
27
|
commitMessage: commitMessageGenerator,
|
|
28
|
+
packagePublisher: packagePublisher,
|
|
27
29
|
},
|
|
28
30
|
logger: false,
|
|
29
31
|
syncs: {
|
|
@@ -24,43 +24,4 @@ export declare const execaTool: import("@mastra/core").Tool<"execaTool", z.ZodOb
|
|
|
24
24
|
command: string;
|
|
25
25
|
args: string[];
|
|
26
26
|
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
27
|
-
export declare const pnpmBuild: import("@mastra/core").Tool<"pnpmBuild", z.ZodObject<{
|
|
28
|
-
name: z.ZodString;
|
|
29
|
-
packagePath: z.ZodString;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
name: string;
|
|
32
|
-
packagePath: string;
|
|
33
|
-
}, {
|
|
34
|
-
name: string;
|
|
35
|
-
packagePath: string;
|
|
36
|
-
}>, z.ZodObject<{
|
|
37
|
-
message: z.ZodString;
|
|
38
|
-
}, "strip", z.ZodTypeAny, {
|
|
39
|
-
message: string;
|
|
40
|
-
}, {
|
|
41
|
-
message: string;
|
|
42
|
-
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
43
|
-
name: z.ZodString;
|
|
44
|
-
packagePath: z.ZodString;
|
|
45
|
-
}, "strip", z.ZodTypeAny, {
|
|
46
|
-
name: string;
|
|
47
|
-
packagePath: string;
|
|
48
|
-
}, {
|
|
49
|
-
name: string;
|
|
50
|
-
packagePath: string;
|
|
51
|
-
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
52
|
-
export declare const pnpmChangesetStatus: import("@mastra/core").Tool<"pnpmChangesetStatus", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
53
|
-
message: z.ZodArray<z.ZodString, "many">;
|
|
54
|
-
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
message: string[];
|
|
56
|
-
}, {
|
|
57
|
-
message: string[];
|
|
58
|
-
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
59
|
-
export declare const pnpmChangesetPublish: import("@mastra/core").Tool<"pnpmChangesetPublish", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
60
|
-
message: z.ZodString;
|
|
61
|
-
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
message: string;
|
|
63
|
-
}, {
|
|
64
|
-
message: string;
|
|
65
|
-
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
66
27
|
//# sourceMappingURL=execa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execa.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/execa.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDA4BpB,CAAC
|
|
1
|
+
{"version":3,"file":"execa.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/execa.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDA4BpB,CAAC"}
|
|
@@ -41,93 +41,3 @@ export const execaTool = createTool({
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
|
-
export const pnpmBuild = createTool({
|
|
45
|
-
id: 'pnpmBuild',
|
|
46
|
-
name: 'PNPM Build Tool',
|
|
47
|
-
description: 'Used to build the pnpm module',
|
|
48
|
-
inputSchema: z.object({
|
|
49
|
-
name: z.string(),
|
|
50
|
-
packagePath: z.string(),
|
|
51
|
-
}),
|
|
52
|
-
outputSchema: z.object({
|
|
53
|
-
message: z.string(),
|
|
54
|
-
}),
|
|
55
|
-
execute: async ({ context: { name, packagePath } }) => {
|
|
56
|
-
try {
|
|
57
|
-
console.log(chalk.green(`Building: ${name} at ${packagePath}`));
|
|
58
|
-
const p = execa(`pnpm`, ['build'], {
|
|
59
|
-
stdio: 'inherit',
|
|
60
|
-
cwd: packagePath,
|
|
61
|
-
reject: false,
|
|
62
|
-
});
|
|
63
|
-
console.log(`\n`);
|
|
64
|
-
await p;
|
|
65
|
-
return { message: 'Done' };
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
console.error(e);
|
|
69
|
-
if (e instanceof ExecaError) {
|
|
70
|
-
return { message: e.message };
|
|
71
|
-
}
|
|
72
|
-
return { message: 'Error' };
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
export const pnpmChangesetStatus = createTool({
|
|
77
|
-
id: 'pnpmChangesetStatus',
|
|
78
|
-
name: 'PNPM Changeset Status Tool',
|
|
79
|
-
description: 'Used to check which pnpm modules need to be published',
|
|
80
|
-
inputSchema: z.object({}),
|
|
81
|
-
outputSchema: z.object({
|
|
82
|
-
message: z.array(z.string()),
|
|
83
|
-
}),
|
|
84
|
-
execute: async () => {
|
|
85
|
-
try {
|
|
86
|
-
console.log('Checking');
|
|
87
|
-
const { stdout } = await execa('pnpm', ['publish', '-r', '--dry-run', '--no-git-checks'], {
|
|
88
|
-
all: true,
|
|
89
|
-
// We want to see stderr too since pnpm sometimes puts important info there
|
|
90
|
-
stderr: 'inherit',
|
|
91
|
-
});
|
|
92
|
-
const lines = stdout.split('\n');
|
|
93
|
-
const filteredLines = lines.filter(line => line.startsWith('+'));
|
|
94
|
-
const packages = filteredLines.map(line => line.trim().substring(2).split('@').slice(0, -1).join('@'));
|
|
95
|
-
return { message: packages };
|
|
96
|
-
}
|
|
97
|
-
catch (e) {
|
|
98
|
-
console.error(e);
|
|
99
|
-
if (e instanceof ExecaError) {
|
|
100
|
-
return { message: [e.message] };
|
|
101
|
-
}
|
|
102
|
-
return { message: ['Error'] };
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
export const pnpmChangesetPublish = createTool({
|
|
107
|
-
id: 'pnpmChangesetPublish',
|
|
108
|
-
name: 'PNPM Changeset Publish Tool',
|
|
109
|
-
description: 'Used to publish the pnpm module',
|
|
110
|
-
inputSchema: z.object({}),
|
|
111
|
-
outputSchema: z.object({
|
|
112
|
-
message: z.string(),
|
|
113
|
-
}),
|
|
114
|
-
execute: async () => {
|
|
115
|
-
try {
|
|
116
|
-
console.log(chalk.green(`Publishing...`));
|
|
117
|
-
const p = execa(`pnpm`, ['changeset', 'publish'], {
|
|
118
|
-
stdio: 'inherit',
|
|
119
|
-
reject: false,
|
|
120
|
-
});
|
|
121
|
-
console.log(`\n`);
|
|
122
|
-
await p;
|
|
123
|
-
return { message: 'Done' };
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
console.error(e);
|
|
127
|
-
if (e instanceof ExecaError) {
|
|
128
|
-
return { message: e.message };
|
|
129
|
-
}
|
|
130
|
-
return { message: 'Error' };
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const pnpmBuild: import("@mastra/core").Tool<"pnpmBuild", z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
packagePath: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
name: string;
|
|
7
|
+
packagePath: string;
|
|
8
|
+
}, {
|
|
9
|
+
name: string;
|
|
10
|
+
packagePath: string;
|
|
11
|
+
}>, z.ZodObject<{
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
message: string;
|
|
15
|
+
}, {
|
|
16
|
+
message: string;
|
|
17
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
packagePath: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
name: string;
|
|
22
|
+
packagePath: string;
|
|
23
|
+
}, {
|
|
24
|
+
name: string;
|
|
25
|
+
packagePath: string;
|
|
26
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
27
|
+
export declare const pnpmChangesetStatus: import("@mastra/core").Tool<"pnpmChangesetStatus", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
28
|
+
message: z.ZodArray<z.ZodString, "many">;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
message: string[];
|
|
31
|
+
}, {
|
|
32
|
+
message: string[];
|
|
33
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
34
|
+
export declare const pnpmChangesetPublish: import("@mastra/core").Tool<"pnpmChangesetPublish", z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, z.ZodObject<{
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
message: string;
|
|
38
|
+
}, {
|
|
39
|
+
message: string;
|
|
40
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
41
|
+
export declare const activeDistTag: import("@mastra/core").Tool<"activeDistTag", z.ZodObject<{
|
|
42
|
+
packagePath: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
packagePath: string;
|
|
45
|
+
}, {
|
|
46
|
+
packagePath: string;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
message: z.ZodString;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
message: string;
|
|
51
|
+
}, {
|
|
52
|
+
message: string;
|
|
53
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
54
|
+
packagePath: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
packagePath: string;
|
|
57
|
+
}, {
|
|
58
|
+
packagePath: string;
|
|
59
|
+
}>, import("@mastra/core").WorkflowContext<any>>>;
|
|
60
|
+
//# sourceMappingURL=pnpm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../../src/mastra/tools/pnpm.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;iDA8BpB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;6IA8B9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;6IA0B/B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;iDA8BxB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createTool } from '@mastra/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa, ExecaError } from 'execa';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const pnpmBuild = createTool({
|
|
8
|
+
id: 'pnpmBuild',
|
|
9
|
+
name: 'PNPM Build Tool',
|
|
10
|
+
description: 'Used to build the pnpm module',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
name: z.string(),
|
|
13
|
+
packagePath: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
message: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ context: { name, packagePath } }) => {
|
|
19
|
+
try {
|
|
20
|
+
console.log(chalk.green(`Building: ${name} at ${packagePath}`));
|
|
21
|
+
const p = execa(`pnpm`, ['build'], {
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
cwd: packagePath,
|
|
24
|
+
reject: false,
|
|
25
|
+
});
|
|
26
|
+
console.log(`\n`);
|
|
27
|
+
await p;
|
|
28
|
+
return { message: 'Done' };
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
if (e instanceof ExecaError) {
|
|
33
|
+
return { message: e.message };
|
|
34
|
+
}
|
|
35
|
+
return { message: 'Error' };
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export const pnpmChangesetStatus = createTool({
|
|
40
|
+
id: 'pnpmChangesetStatus',
|
|
41
|
+
name: 'PNPM Changeset Status Tool',
|
|
42
|
+
description: 'Used to check which pnpm modules need to be published',
|
|
43
|
+
inputSchema: z.object({}),
|
|
44
|
+
outputSchema: z.object({
|
|
45
|
+
message: z.array(z.string()),
|
|
46
|
+
}),
|
|
47
|
+
execute: async () => {
|
|
48
|
+
try {
|
|
49
|
+
console.log('Checking');
|
|
50
|
+
const { stdout } = await execa('pnpm', ['publish', '-r', '--dry-run', '--no-git-checks'], {
|
|
51
|
+
all: true,
|
|
52
|
+
// We want to see stderr too since pnpm sometimes puts important info there
|
|
53
|
+
stderr: 'inherit',
|
|
54
|
+
});
|
|
55
|
+
const lines = stdout.split('\n');
|
|
56
|
+
const filteredLines = lines.filter(line => line.startsWith('+'));
|
|
57
|
+
const packages = filteredLines.map(line => line.trim().substring(2).split('@').slice(0, -1).join('@'));
|
|
58
|
+
return { message: packages };
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error(e);
|
|
62
|
+
if (e instanceof ExecaError) {
|
|
63
|
+
return { message: [e.message] };
|
|
64
|
+
}
|
|
65
|
+
return { message: ['Error'] };
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
export const pnpmChangesetPublish = createTool({
|
|
70
|
+
id: 'pnpmChangesetPublish',
|
|
71
|
+
name: 'PNPM Changeset Publish Tool',
|
|
72
|
+
description: 'Used to publish the pnpm module',
|
|
73
|
+
inputSchema: z.object({}),
|
|
74
|
+
outputSchema: z.object({
|
|
75
|
+
message: z.string(),
|
|
76
|
+
}),
|
|
77
|
+
execute: async () => {
|
|
78
|
+
try {
|
|
79
|
+
console.log(chalk.green(`Publishing...`));
|
|
80
|
+
const p = execa(`pnpm`, ['changeset', 'publish'], {
|
|
81
|
+
stdio: 'inherit',
|
|
82
|
+
reject: false,
|
|
83
|
+
});
|
|
84
|
+
console.log(`\n`);
|
|
85
|
+
await p;
|
|
86
|
+
return { message: 'Done' };
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.error(e);
|
|
90
|
+
if (e instanceof ExecaError) {
|
|
91
|
+
return { message: e.message };
|
|
92
|
+
}
|
|
93
|
+
return { message: 'Error' };
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
export const activeDistTag = createTool({
|
|
98
|
+
id: 'activeDistTag',
|
|
99
|
+
name: 'PNPM Changeset set active tag',
|
|
100
|
+
description: 'Used to set active tag on the pnpm module',
|
|
101
|
+
inputSchema: z.object({
|
|
102
|
+
packagePath: z.string(),
|
|
103
|
+
}),
|
|
104
|
+
outputSchema: z.object({
|
|
105
|
+
message: z.string(),
|
|
106
|
+
}),
|
|
107
|
+
execute: async ({ context }) => {
|
|
108
|
+
try {
|
|
109
|
+
const pkgJson = JSON.parse(readFileSync(path.join(context.packagePath, 'package.json'), 'utf-8'));
|
|
110
|
+
const version = pkgJson.version;
|
|
111
|
+
console.log(chalk.green(`Setting active tag...`));
|
|
112
|
+
const p = execa(`npm`, ['dist-tag', `${pkgJson.name}@${version}`, `latest`], {
|
|
113
|
+
stdio: 'inherit',
|
|
114
|
+
reject: false,
|
|
115
|
+
});
|
|
116
|
+
console.log(`\n`);
|
|
117
|
+
await p;
|
|
118
|
+
return { message: 'Done' };
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
console.error(e);
|
|
122
|
+
if (e instanceof ExecaError) {
|
|
123
|
+
return { message: e.message };
|
|
124
|
+
}
|
|
125
|
+
return { message: 'Error' };
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/publish-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAM9C,eAAO,MAAM,gBAAgB,oBAE3B,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Step, Workflow } from '@mastra/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export const packagePublisher = new Workflow({
|
|
7
|
+
name: 'pnpm-changset-publisher',
|
|
8
|
+
});
|
|
9
|
+
const getPacakgesToPublish = new Step({
|
|
10
|
+
id: 'getPacakgesToPublish',
|
|
11
|
+
outputSchema: z.object({
|
|
12
|
+
packages: z.array(z.string()),
|
|
13
|
+
integrations: z.array(z.string()),
|
|
14
|
+
danePackage: z.string(),
|
|
15
|
+
}),
|
|
16
|
+
execute: async ({ mastra }) => {
|
|
17
|
+
const agent = mastra?.agents?.['danePackagePublisher'];
|
|
18
|
+
if (!agent) {
|
|
19
|
+
throw new Error('Agent not found');
|
|
20
|
+
}
|
|
21
|
+
const result = await agent.generate(`
|
|
22
|
+
Can you tell me which packages within the packages and integrations directory need to be published to npm?
|
|
23
|
+
`);
|
|
24
|
+
const resultObj = await agent.generate(`
|
|
25
|
+
ONLY RETURN DATA IF WE HAVE PACKAGES TO PUBLISH. If we do not, return empty arrays.
|
|
26
|
+
Can you format this for me ${result.text}?
|
|
27
|
+
@mastra/core must be first. @mastra/dane should be listed after packages and integrations.
|
|
28
|
+
`, {
|
|
29
|
+
schema: z.object({
|
|
30
|
+
packages: z.array(z.string()),
|
|
31
|
+
integrations: z.array(z.string()),
|
|
32
|
+
danePackage: z.string(),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
packages: resultObj?.object?.packages,
|
|
37
|
+
integrations: resultObj?.object?.integrations,
|
|
38
|
+
danePackage: resultObj?.object?.danePackage,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const assemblePackages = new Step({
|
|
43
|
+
id: 'assemblePackages',
|
|
44
|
+
outputSchema: z.object({
|
|
45
|
+
packages: z.array(z.string()),
|
|
46
|
+
}),
|
|
47
|
+
execute: async ({ context }) => {
|
|
48
|
+
if (context.machineContext?.stepResults.getPacakgesToPublish?.status !== 'success') {
|
|
49
|
+
return {
|
|
50
|
+
packages: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const payload = context.machineContext.stepResults.getPacakgesToPublish.payload;
|
|
54
|
+
const packagesToBuild = new Set();
|
|
55
|
+
if (payload?.packages) {
|
|
56
|
+
payload.packages.forEach((pkg) => {
|
|
57
|
+
let pkgName = pkg.replace('@mastra/', '');
|
|
58
|
+
if (pkgName === 'mastra') {
|
|
59
|
+
pkgName = 'cli';
|
|
60
|
+
}
|
|
61
|
+
const pkgPath = path.join(process.cwd(), 'packages', pkgName);
|
|
62
|
+
packagesToBuild.add(pkgPath);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (payload?.integrations) {
|
|
66
|
+
const integrations = payload.integrations;
|
|
67
|
+
integrations.forEach((integration) => {
|
|
68
|
+
let pkgName = integration.replace('@mastra/', '');
|
|
69
|
+
const integrationPath = path.join(process.cwd(), 'integrations', pkgName);
|
|
70
|
+
packagesToBuild.add(integrationPath);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (payload?.danePackage) {
|
|
74
|
+
const danePackage = payload.danePackage;
|
|
75
|
+
let pkgName = danePackage.replace('@mastra/', '');
|
|
76
|
+
const danePackageMapped = path.join(process.cwd(), 'examples', pkgName);
|
|
77
|
+
const pkgJsonPath = readFileSync(path.join(danePackageMapped, 'package.json'), 'utf-8');
|
|
78
|
+
const pkgJson = JSON.parse(pkgJsonPath);
|
|
79
|
+
const dependencies = Object.keys(pkgJson.dependencies || {}).filter((dep) => dep.startsWith('@mastra/'));
|
|
80
|
+
dependencies.forEach((dep) => {
|
|
81
|
+
const pkgName = dep.replace('@mastra/', '');
|
|
82
|
+
const pkgPath = path.join(process.cwd(), 'packages', pkgName);
|
|
83
|
+
packagesToBuild.add(pkgPath);
|
|
84
|
+
});
|
|
85
|
+
packagesToBuild.add(danePackage);
|
|
86
|
+
}
|
|
87
|
+
const pkgSet = Array.from(packagesToBuild.keys());
|
|
88
|
+
if (!packagesToBuild.size) {
|
|
89
|
+
console.error(chalk.red('No packages to build.'));
|
|
90
|
+
return {
|
|
91
|
+
packages: [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return { packages: pkgSet };
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const buildPackages = new Step({
|
|
98
|
+
id: 'buildPackages',
|
|
99
|
+
outputSchema: z.object({
|
|
100
|
+
packages: z.array(z.string()),
|
|
101
|
+
}),
|
|
102
|
+
execute: async ({ context, mastra }) => {
|
|
103
|
+
if (context.machineContext?.stepResults.assemblePackages?.status !== 'success') {
|
|
104
|
+
return {
|
|
105
|
+
packages: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const pkgSet = context.machineContext.stepResults.assemblePackages.payload.packages;
|
|
109
|
+
const agent = mastra?.agents?.['danePackagePublisher'];
|
|
110
|
+
if (!agent) {
|
|
111
|
+
throw new Error('Agent not found');
|
|
112
|
+
}
|
|
113
|
+
let res = await agent.generate(`
|
|
114
|
+
Here are the packages that need to be built: ${pkgSet.join(',')}.
|
|
115
|
+
We need to build core first. And dane last. The rest can be done in parallel.
|
|
116
|
+
`);
|
|
117
|
+
console.log(chalk.green(res.text));
|
|
118
|
+
return { packages: pkgSet };
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const publishChangeset = new Step({
|
|
122
|
+
id: 'publishChangeset',
|
|
123
|
+
outputSchema: z.object({
|
|
124
|
+
packages: z.array(z.string()),
|
|
125
|
+
}),
|
|
126
|
+
execute: async ({ context, mastra }) => {
|
|
127
|
+
if (context.machineContext?.stepResults.buildPackages?.status !== 'success') {
|
|
128
|
+
return {
|
|
129
|
+
packages: [],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const pkgSet = context.machineContext.stepResults.buildPackages.payload.packages;
|
|
133
|
+
const agent = mastra?.agents?.['danePackagePublisher'];
|
|
134
|
+
if (!agent) {
|
|
135
|
+
throw new Error('Agent not found');
|
|
136
|
+
}
|
|
137
|
+
let res = await agent.generate(`
|
|
138
|
+
Publish the changeset.
|
|
139
|
+
`);
|
|
140
|
+
console.log(chalk.green(res.text));
|
|
141
|
+
return { packages: pkgSet };
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
const setLatestDistTag = new Step({
|
|
145
|
+
id: 'setLatestDistTag',
|
|
146
|
+
outputSchema: z.object({
|
|
147
|
+
packages: z.array(z.string()),
|
|
148
|
+
}),
|
|
149
|
+
execute: async ({ context, mastra }) => {
|
|
150
|
+
if (context.machineContext?.stepResults.publishChangeset?.status !== 'success') {
|
|
151
|
+
return {
|
|
152
|
+
packages: [],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const pkgSet = context.machineContext.stepResults.publishChangeset.payload.packages;
|
|
156
|
+
const agent = mastra?.agents?.['danePackagePublisher'];
|
|
157
|
+
if (!agent) {
|
|
158
|
+
throw new Error('Agent not found');
|
|
159
|
+
}
|
|
160
|
+
let res = await agent.generate(`
|
|
161
|
+
Set the active tag for these packages ${pkgSet.join(',')}.
|
|
162
|
+
`);
|
|
163
|
+
console.log(chalk.green(res.text));
|
|
164
|
+
return { packages: pkgSet };
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
packagePublisher
|
|
168
|
+
.step(getPacakgesToPublish)
|
|
169
|
+
.then(assemblePackages)
|
|
170
|
+
.then(buildPackages, {
|
|
171
|
+
when: async ({ context }) => {
|
|
172
|
+
return (context.stepResults.assemblePackages?.status === 'success' &&
|
|
173
|
+
context.stepResults.assemblePackages?.payload?.packages.length > 0);
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
.then(publishChangeset, {
|
|
177
|
+
when: async ({ context }) => {
|
|
178
|
+
return (context.stepResults.buildPackages?.status === 'success' &&
|
|
179
|
+
context.stepResults.buildPackages?.payload?.packages.length > 0);
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
.then(setLatestDistTag, {
|
|
183
|
+
when: async ({ context }) => {
|
|
184
|
+
return (context.stepResults.publishChangeset?.status === 'success' &&
|
|
185
|
+
context.stepResults.publishChangeset?.payload?.packages.length > 0);
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
.commit();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dane",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.26",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@mastra/engine": "0.0.5-alpha.40",
|
|
43
43
|
"@mastra/firecrawl": "1.0.4-alpha.32",
|
|
44
44
|
"@mastra/memory": "0.0.2-alpha.26",
|
|
45
|
+
"@mastra/rag": "0.0.2-alpha.30",
|
|
45
46
|
"@mastra/github": "1.0.3-alpha.30",
|
|
46
|
-
"@mastra/stabilityai": "1.0.1-alpha.21"
|
|
47
|
-
"@mastra/rag": "0.0.2-alpha.30"
|
|
47
|
+
"@mastra/stabilityai": "1.0.1-alpha.21"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "npx tsc",
|