@mastra/dane 0.0.3 → 0.0.4
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/changelog.d.ts +2 -0
- package/dist/commands/changelog.d.ts.map +1 -0
- package/dist/commands/changelog.js +15 -0
- package/dist/commands/commit-message.d.ts +2 -0
- package/dist/commands/commit-message.d.ts.map +1 -0
- package/dist/commands/commit-message.js +32 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +40 -0
- package/dist/commands/issue-labeler.d.ts +2 -0
- package/dist/commands/issue-labeler.d.ts.map +1 -0
- package/dist/commands/issue-labeler.js +35 -0
- package/dist/commands/link-checker.d.ts +4 -0
- package/dist/commands/link-checker.d.ts.map +1 -0
- package/dist/commands/link-checker.js +16 -0
- package/dist/commands/message.d.ts +2 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +14 -0
- package/dist/commands/new-contributor-message.d.ts +2 -0
- package/dist/commands/new-contributor-message.d.ts.map +1 -0
- package/dist/commands/new-contributor-message.js +43 -0
- package/dist/commands/publish-packages.d.ts +2 -0
- package/dist/commands/publish-packages.d.ts.map +1 -0
- package/dist/commands/publish-packages.js +11 -0
- package/dist/commands/telephone-game.d.ts +2 -0
- package/dist/commands/telephone-game.d.ts.map +1 -0
- package/dist/commands/telephone-game.js +30 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +75 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/mastra/agents/index.d.ts +165 -0
- package/dist/mastra/agents/index.d.ts.map +1 -0
- package/dist/mastra/agents/index.js +111 -0
- package/dist/mastra/agents/memory.d.ts +3 -0
- package/dist/mastra/agents/memory.d.ts.map +1 -0
- package/dist/mastra/agents/memory.js +10 -0
- package/dist/mastra/agents/model.d.ts +2 -0
- package/dist/mastra/agents/model.d.ts.map +1 -0
- package/dist/mastra/agents/model.js +8 -0
- package/dist/mastra/agents/new-contributor.d.ts +3 -0
- package/dist/mastra/agents/new-contributor.d.ts.map +1 -0
- package/dist/mastra/agents/new-contributor.js +14 -0
- package/dist/mastra/agents/package-publisher.d.ts +65 -0
- package/dist/mastra/agents/package-publisher.d.ts.map +1 -0
- package/dist/mastra/agents/package-publisher.js +170 -0
- package/dist/mastra/index.d.ts +291 -0
- package/dist/mastra/index.d.ts.map +1 -0
- package/dist/mastra/index.js +37 -0
- package/dist/mastra/integrations/index.d.ts +5 -0
- package/dist/mastra/integrations/index.d.ts.map +1 -0
- package/dist/mastra/integrations/index.js +23 -0
- package/dist/mastra/tools/browser.d.ts +40 -0
- package/dist/mastra/tools/browser.d.ts.map +1 -0
- package/dist/mastra/tools/browser.js +116 -0
- package/dist/mastra/tools/calendar.d.ts +21 -0
- package/dist/mastra/tools/calendar.d.ts.map +1 -0
- package/dist/mastra/tools/calendar.js +134 -0
- package/dist/mastra/tools/crawl.d.ts +36 -0
- package/dist/mastra/tools/crawl.d.ts.map +1 -0
- package/dist/mastra/tools/crawl.js +27 -0
- package/dist/mastra/tools/execa.d.ts +27 -0
- package/dist/mastra/tools/execa.d.ts.map +1 -0
- package/dist/mastra/tools/execa.js +43 -0
- package/dist/mastra/tools/fs.d.ts +33 -0
- package/dist/mastra/tools/fs.d.ts.map +1 -0
- package/dist/mastra/tools/fs.js +36 -0
- package/dist/mastra/tools/image.d.ts +27 -0
- package/dist/mastra/tools/image.d.ts.map +1 -0
- package/dist/mastra/tools/image.js +37 -0
- package/dist/mastra/tools/mcp.d.ts +3 -0
- package/dist/mastra/tools/mcp.d.ts.map +1 -0
- package/dist/mastra/tools/mcp.js +12 -0
- package/dist/mastra/tools/pdf.d.ts +21 -0
- package/dist/mastra/tools/pdf.d.ts.map +1 -0
- package/dist/mastra/tools/pdf.js +42 -0
- 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 +127 -0
- package/dist/mastra/workflows/changelog.d.ts +10 -0
- package/dist/mastra/workflows/changelog.d.ts.map +1 -0
- package/dist/mastra/workflows/changelog.js +239 -0
- package/dist/mastra/workflows/chat.d.ts +13 -0
- package/dist/mastra/workflows/chat.d.ts.map +1 -0
- package/dist/mastra/workflows/chat.js +90 -0
- package/dist/mastra/workflows/commit-message.d.ts +10 -0
- package/dist/mastra/workflows/commit-message.d.ts.map +1 -0
- package/dist/mastra/workflows/commit-message.js +141 -0
- package/dist/mastra/workflows/first-contributor.d.ts +16 -0
- package/dist/mastra/workflows/first-contributor.d.ts.map +1 -0
- package/dist/mastra/workflows/first-contributor.js +124 -0
- package/dist/mastra/workflows/index.d.ts +4 -0
- package/dist/mastra/workflows/index.d.ts.map +1 -0
- package/dist/mastra/workflows/index.js +3 -0
- package/dist/mastra/workflows/issue-labeler.d.ts +16 -0
- package/dist/mastra/workflows/issue-labeler.d.ts.map +1 -0
- package/dist/mastra/workflows/issue-labeler.js +85 -0
- package/dist/mastra/workflows/link-checker.d.ts +13 -0
- package/dist/mastra/workflows/link-checker.d.ts.map +1 -0
- package/dist/mastra/workflows/link-checker.js +102 -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 +252 -0
- package/dist/mastra/workflows/telephone-game.d.ts +3 -0
- package/dist/mastra/workflows/telephone-game.d.ts.map +1 -0
- package/dist/mastra/workflows/telephone-game.js +97 -0
- package/package.json +4 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Step, Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { github } from '../integrations/index.js';
|
|
4
|
+
export const githubFirstContributorMessage = new Workflow({
|
|
5
|
+
name: 'github-first-contributor-message',
|
|
6
|
+
triggerSchema: z.object({
|
|
7
|
+
repo: z.string(),
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
pr_number: z.number(),
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
const getPullRequest = new Step({
|
|
13
|
+
id: 'getPullRequest',
|
|
14
|
+
outputSchema: z.object({
|
|
15
|
+
title: z.string(),
|
|
16
|
+
body: z.string(),
|
|
17
|
+
diff: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ context }) => {
|
|
20
|
+
const client = await github.getApiClient();
|
|
21
|
+
const pullRequest = await client.pullsGet({
|
|
22
|
+
path: {
|
|
23
|
+
owner: context?.triggerData?.owner,
|
|
24
|
+
repo: context?.triggerData?.repo,
|
|
25
|
+
pull_number: context?.triggerData?.pr_number,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!pullRequest?.data) {
|
|
29
|
+
throw new Error('Pull request not found');
|
|
30
|
+
}
|
|
31
|
+
const response = await fetch(pullRequest.data.diff_url);
|
|
32
|
+
const diff = await response.text();
|
|
33
|
+
return {
|
|
34
|
+
title: pullRequest.data.title,
|
|
35
|
+
body: pullRequest.data.body || '',
|
|
36
|
+
diff,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const generateMessage = new Step({
|
|
41
|
+
id: 'message-generator',
|
|
42
|
+
outputSchema: z.object({
|
|
43
|
+
intro: z.string(),
|
|
44
|
+
checklist: z.string().array(),
|
|
45
|
+
outro: z.string(),
|
|
46
|
+
}),
|
|
47
|
+
execute: async ({ context, mastra }) => {
|
|
48
|
+
const parentStep = context?.steps?.getPullRequest;
|
|
49
|
+
if (!parentStep || parentStep.status !== 'success') {
|
|
50
|
+
return { intro: '', checklist: [], outro: '' };
|
|
51
|
+
}
|
|
52
|
+
const mastraDocsRes = await fetch('https://mastra.ai/llms.txt');
|
|
53
|
+
const mastraDocs = await mastraDocsRes.text();
|
|
54
|
+
const daneNewContributor = mastra?.agents?.daneNewContributor;
|
|
55
|
+
const res = await daneNewContributor?.generate(`
|
|
56
|
+
Hey Dane, given:
|
|
57
|
+
START TITLE
|
|
58
|
+
${parentStep?.output?.title}
|
|
59
|
+
END TITLE
|
|
60
|
+
|
|
61
|
+
START BODY
|
|
62
|
+
${parentStep?.output?.body}
|
|
63
|
+
END BODY
|
|
64
|
+
START DIFF
|
|
65
|
+
${parentStep?.output?.diff}
|
|
66
|
+
END DIFF
|
|
67
|
+
|
|
68
|
+
I'll give you some more context about Mastra:
|
|
69
|
+
MASTRA DOCS
|
|
70
|
+
${mastraDocs}
|
|
71
|
+
END MASTRA DOCS
|
|
72
|
+
|
|
73
|
+
Write message to the contributor to thank them for their first contribution? And check if the following guidelines are followed, do not mention these checklist if they are actually checked:
|
|
74
|
+
- Check if the body matches the diff and is not empty
|
|
75
|
+
- Check if tests are added or updated
|
|
76
|
+
- check if the code looks similar to what's already written
|
|
77
|
+
- Ask if they have tested the changes on any of the examples
|
|
78
|
+
|
|
79
|
+
VERY IMPORTANT:
|
|
80
|
+
You should not summarize nor you should give advice on the code itself, only follow the guidelines.
|
|
81
|
+
|
|
82
|
+
The message should bes strucutred like:
|
|
83
|
+
an intro message to thank the user for their contribution
|
|
84
|
+
the checklist
|
|
85
|
+
and an outro that just says thank you again and that we will review it shortly. If there is no checklist we should skip thank you.
|
|
86
|
+
`, {
|
|
87
|
+
output: z.object({
|
|
88
|
+
intro: z.string(),
|
|
89
|
+
checklist: z.string().array(),
|
|
90
|
+
outro: z.string(),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
if (!res) {
|
|
94
|
+
throw new Error(`We couldn't generate a message`);
|
|
95
|
+
}
|
|
96
|
+
return res.object;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const createMessage = new Step({
|
|
100
|
+
id: 'create-message',
|
|
101
|
+
execute: async ({ context }) => {
|
|
102
|
+
const parentStep = context?.steps?.['message-generator'];
|
|
103
|
+
if (!parentStep || parentStep.status !== 'success') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const client = await github.getApiClient();
|
|
107
|
+
const res = await client.issuesCreateComment({
|
|
108
|
+
path: {
|
|
109
|
+
owner: context?.triggerData?.owner,
|
|
110
|
+
repo: context?.triggerData?.repo,
|
|
111
|
+
issue_number: context?.triggerData?.pr_number,
|
|
112
|
+
},
|
|
113
|
+
body: {
|
|
114
|
+
body: `${parentStep.output.intro}
|
|
115
|
+
|
|
116
|
+
${parentStep.output.checklist.map((s) => `- [ ] ${s}`).join('\n')}
|
|
117
|
+
|
|
118
|
+
${parentStep.output.outro}`,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
console.log(res);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
githubFirstContributorMessage.step(getPullRequest).then(generateMessage).then(createMessage).commit();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const githubIssueLabeler: Workflow<any, z.ZodObject<{
|
|
4
|
+
repo: z.ZodString;
|
|
5
|
+
owner: z.ZodString;
|
|
6
|
+
issue_number: z.ZodNumber;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
repo: string;
|
|
9
|
+
owner: string;
|
|
10
|
+
issue_number: number;
|
|
11
|
+
}, {
|
|
12
|
+
repo: string;
|
|
13
|
+
owner: string;
|
|
14
|
+
issue_number: number;
|
|
15
|
+
}>>;
|
|
16
|
+
//# sourceMappingURL=issue-labeler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-labeler.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/issue-labeler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;GAO7B,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Step, Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { github } from '../integrations/index.js';
|
|
4
|
+
export const githubIssueLabeler = new Workflow({
|
|
5
|
+
name: 'github-issue-labeler',
|
|
6
|
+
triggerSchema: z.object({
|
|
7
|
+
repo: z.string(),
|
|
8
|
+
owner: z.string(),
|
|
9
|
+
issue_number: z.number(),
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
const getIssue = new Step({
|
|
13
|
+
id: 'getIssue',
|
|
14
|
+
outputSchema: z.object({
|
|
15
|
+
title: z.string(),
|
|
16
|
+
body: z.string(),
|
|
17
|
+
labelNames: z.array(z.string()),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ context }) => {
|
|
20
|
+
const client = await github.getApiClient();
|
|
21
|
+
const issue = await client.issuesGet({
|
|
22
|
+
path: {
|
|
23
|
+
// TODO: Type triggerData in context to the triggerSchema
|
|
24
|
+
owner: context?.triggerData?.owner,
|
|
25
|
+
repo: context?.triggerData?.repo,
|
|
26
|
+
issue_number: context?.triggerData?.issue_number,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const labels = await client.issuesListLabelsForRepo({
|
|
30
|
+
path: {
|
|
31
|
+
owner: context?.triggerData?.owner,
|
|
32
|
+
repo: context?.triggerData?.repo,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const labelNames = labels?.data?.map((label) => label.name);
|
|
36
|
+
return { title: issue?.data?.title, body: issue?.data?.body, labelNames: labelNames };
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const labelIssue = new Step({
|
|
40
|
+
id: 'labelIssue',
|
|
41
|
+
outputSchema: z.object({
|
|
42
|
+
labels: z.array(z.string()),
|
|
43
|
+
}),
|
|
44
|
+
execute: async ({ context, mastra }) => {
|
|
45
|
+
const parentStep = context?.steps?.getIssue;
|
|
46
|
+
if (!parentStep || parentStep.status !== 'success') {
|
|
47
|
+
return { labels: [] };
|
|
48
|
+
}
|
|
49
|
+
const daneIssueLabeler = mastra?.agents?.daneIssueLabeler;
|
|
50
|
+
const res = await daneIssueLabeler?.generate(`
|
|
51
|
+
Hey Dane, given:
|
|
52
|
+
* this issue title: ${parentStep?.output?.title}
|
|
53
|
+
* this issue body: ${parentStep?.output?.body}
|
|
54
|
+
* these labels: ${parentStep?.output?.labelNames}
|
|
55
|
+
|
|
56
|
+
What label or labels would you assign?
|
|
57
|
+
`, {
|
|
58
|
+
output: z.object({
|
|
59
|
+
labels: z.array(z.string()),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
return { labels: res?.object?.labels };
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const applyLabels = new Step({
|
|
66
|
+
id: 'applyLabels',
|
|
67
|
+
execute: async ({ context }) => {
|
|
68
|
+
const parentStep = context?.steps?.labelIssue;
|
|
69
|
+
if (!parentStep || parentStep.status !== 'success') {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const client = await github.getApiClient();
|
|
73
|
+
await client.issuesAddLabels({
|
|
74
|
+
path: {
|
|
75
|
+
owner: context?.triggerData?.owner,
|
|
76
|
+
repo: context?.triggerData?.repo,
|
|
77
|
+
issue_number: context?.triggerData?.issue_number,
|
|
78
|
+
},
|
|
79
|
+
body: {
|
|
80
|
+
labels: parentStep.output.labels,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
githubIssueLabeler.step(getIssue).then(labelIssue).then(applyLabels).commit();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const linkCheckerWorkflow: Workflow<any, z.ZodObject<{
|
|
4
|
+
channelId: z.ZodString;
|
|
5
|
+
targetUrl: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
channelId: string;
|
|
8
|
+
targetUrl: string;
|
|
9
|
+
}, {
|
|
10
|
+
channelId: string;
|
|
11
|
+
targetUrl: string;
|
|
12
|
+
}>>;
|
|
13
|
+
//# sourceMappingURL=link-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-checker.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/link-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,mBAAmB;;;;;;;;;GAM9B,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Step, Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import child_process from 'node:child_process';
|
|
4
|
+
import util from 'node:util';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { slack } from '../tools/mcp.js';
|
|
7
|
+
const exec = util.promisify(child_process.exec);
|
|
8
|
+
export const linkCheckerWorkflow = new Workflow({
|
|
9
|
+
name: 'link-checker',
|
|
10
|
+
triggerSchema: z.object({
|
|
11
|
+
channelId: z.string(),
|
|
12
|
+
targetUrl: z.string(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
const linkSchema = z.object({
|
|
16
|
+
url: z.string(),
|
|
17
|
+
status: z.number(),
|
|
18
|
+
state: z.enum(['OK', 'BROKEN']),
|
|
19
|
+
parent: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
const getBrokenLinks = new Step({
|
|
22
|
+
id: 'get-broken-links',
|
|
23
|
+
description: 'Get broken links',
|
|
24
|
+
inputSchema: z.object({
|
|
25
|
+
targetUrl: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
outputSchema: z.object({
|
|
28
|
+
brokenLinks: z.array(linkSchema),
|
|
29
|
+
}),
|
|
30
|
+
execute: async ({ context }) => {
|
|
31
|
+
const targetUrl = context.targetUrl;
|
|
32
|
+
const res = await exec(`npx linkinator ${targetUrl} --format json`, {
|
|
33
|
+
encoding: 'utf-8',
|
|
34
|
+
});
|
|
35
|
+
if (res.stderr) {
|
|
36
|
+
throw new Error(res.stderr);
|
|
37
|
+
}
|
|
38
|
+
const data = JSON.parse(res.stdout);
|
|
39
|
+
const parsedData = linkSchema.array().parse(data.links);
|
|
40
|
+
return {
|
|
41
|
+
brokenLinks: parsedData.filter(link => link.state === 'BROKEN'),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const reportBrokenLinks = new Step({
|
|
46
|
+
id: 'report-broken-links',
|
|
47
|
+
description: 'Report broken links',
|
|
48
|
+
outputSchema: z.object({
|
|
49
|
+
message: z.string(),
|
|
50
|
+
}),
|
|
51
|
+
execute: async ({ context, mastra }) => {
|
|
52
|
+
const brokenLinks = context?.getStepResult('get-broken-links');
|
|
53
|
+
if (!brokenLinks) {
|
|
54
|
+
return {
|
|
55
|
+
message: 'No broken links found',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (brokenLinks.brokenLinks.length === 0) {
|
|
59
|
+
return {
|
|
60
|
+
message: 'No broken links found',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
await slack.connect();
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error(e);
|
|
68
|
+
}
|
|
69
|
+
const triggerPayload = context?.getStepResult('trigger');
|
|
70
|
+
if (!triggerPayload) {
|
|
71
|
+
return {
|
|
72
|
+
message: 'Trigger payload not found',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const agent = mastra?.agents?.daneLinkChecker;
|
|
76
|
+
if (!agent) {
|
|
77
|
+
return {
|
|
78
|
+
message: 'Agent not found',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const tools = await slack.tools();
|
|
82
|
+
console.log(`🤖Generating...`);
|
|
83
|
+
const res = await agent.generate(`
|
|
84
|
+
Send this ${JSON.stringify(brokenLinks, null, 2)} to this slack channel: "${triggerPayload.channelId}" with the tool slack_post_message.
|
|
85
|
+
Format it in markdown so it displays nicely in slack.
|
|
86
|
+
`, {
|
|
87
|
+
toolsets: { slack: tools },
|
|
88
|
+
});
|
|
89
|
+
console.log(chalk.green(res.text));
|
|
90
|
+
return {
|
|
91
|
+
message: res.text,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
linkCheckerWorkflow
|
|
96
|
+
.step(getBrokenLinks, {
|
|
97
|
+
variables: {
|
|
98
|
+
targetUrl: { step: 'trigger', path: 'targetUrl' },
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
.then(reportBrokenLinks)
|
|
102
|
+
.commit();
|
|
@@ -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,wBAAwB,CAAC;AAYxD,eAAO,MAAM,gBAAgB,oBAE3B,CAAC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { Step, Workflow } from '@mastra/core/workflows';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
// import { z } from 'zod';
|
|
8
|
+
// import { PACKAGES_LIST_PROMPT, /*PUBLISH_PACKAGES_PROMPT*/ } from '../agents/package-publisher.js';
|
|
9
|
+
// import { pnpmBuild } from '../tools/pnpm.js';
|
|
10
|
+
export const packagePublisher = new Workflow({
|
|
11
|
+
name: 'pnpm-changset-publisher',
|
|
12
|
+
});
|
|
13
|
+
// const outputSchema = z.object({
|
|
14
|
+
// packages: z.array(z.string()),
|
|
15
|
+
// integrations: z.array(z.string()),
|
|
16
|
+
// deployers: z.array(z.string()),
|
|
17
|
+
// speech: z.array(z.string()),
|
|
18
|
+
// // combined deprecated stores
|
|
19
|
+
// combined_stores: z.array(z.string()),
|
|
20
|
+
// });
|
|
21
|
+
// const defaultSet = {
|
|
22
|
+
// packages: [],
|
|
23
|
+
// deployers: [],
|
|
24
|
+
// integrations: [],
|
|
25
|
+
// speech: [],
|
|
26
|
+
// combined_stores: [],
|
|
27
|
+
// };
|
|
28
|
+
// const getPacakgesToPublish = new Step({
|
|
29
|
+
// id: 'getPacakgesToPublish',
|
|
30
|
+
// outputSchema,
|
|
31
|
+
// execute: async ({ mastra }) => {
|
|
32
|
+
// const agent = mastra?.agents?.['danePackagePublisher'];
|
|
33
|
+
// if (!agent) {
|
|
34
|
+
// throw new Error('Agent not found');
|
|
35
|
+
// }
|
|
36
|
+
// const result = await agent.generate(PACKAGES_LIST_PROMPT);
|
|
37
|
+
// console.log(chalk.green(`\n${result.text}`));
|
|
38
|
+
// const resultObj = await agent.generate(
|
|
39
|
+
// `
|
|
40
|
+
// Please convert this into a structured object:
|
|
41
|
+
// Input Text: ${result.text}
|
|
42
|
+
// 1. Order Requirements:
|
|
43
|
+
// - @mastra/core MUST be first within packages
|
|
44
|
+
// - @mastra/deployer MUST be second within packages
|
|
45
|
+
// - Group parallel builds by directory type
|
|
46
|
+
// 2. Output Format:
|
|
47
|
+
// - Group into: packages[], integrations[], deployers[], combined_stores[]
|
|
48
|
+
// - Place create-mastra in packages[] array
|
|
49
|
+
// - Maintain correct order within each group
|
|
50
|
+
// 3. Critical Rules:
|
|
51
|
+
// - Never publish without building first
|
|
52
|
+
// - Only include packages that need updates
|
|
53
|
+
// - Follow dependency order strictly
|
|
54
|
+
// `,
|
|
55
|
+
// {
|
|
56
|
+
// output: z.object({
|
|
57
|
+
// packages: z.array(z.string()),
|
|
58
|
+
// integrations: z.array(z.string()),
|
|
59
|
+
// deployers: z.array(z.string()),
|
|
60
|
+
// combined_stores: z.array(z.string()),
|
|
61
|
+
// speech: z.array(z.string()),
|
|
62
|
+
// }),
|
|
63
|
+
// },
|
|
64
|
+
// );
|
|
65
|
+
// return {
|
|
66
|
+
// packages: resultObj?.object?.packages!,
|
|
67
|
+
// integrations: resultObj?.object?.integrations!,
|
|
68
|
+
// deployers: resultObj?.object?.deployers!,
|
|
69
|
+
// combined_stores: resultObj?.object?.stores!,
|
|
70
|
+
// speech: resultObj?.object?.speech!,
|
|
71
|
+
// };
|
|
72
|
+
// },
|
|
73
|
+
// });
|
|
74
|
+
// const assemblePackages = new Step({
|
|
75
|
+
// id: 'assemblePackages',
|
|
76
|
+
// outputSchema,
|
|
77
|
+
// execute: async ({ context }) => {
|
|
78
|
+
// if (context?.steps.getPacakgesToPublish?.status !== 'success') {
|
|
79
|
+
// return {
|
|
80
|
+
// packages: [],
|
|
81
|
+
// integrations: [],
|
|
82
|
+
// deployers: [],
|
|
83
|
+
// combined_stores: [],
|
|
84
|
+
// speech: [],
|
|
85
|
+
// };
|
|
86
|
+
// }
|
|
87
|
+
// const payload = context.steps.getPacakgesToPublish.output;
|
|
88
|
+
// const packagesToBuild: Set<string> = new Set();
|
|
89
|
+
// const deployersToBuild: Set<string> = new Set();
|
|
90
|
+
// const integrationsToBuild: Set<string> = new Set();
|
|
91
|
+
// const combined_storesToBuild: Set<string> = new Set();
|
|
92
|
+
// const speechToBuild: Set<string> = new Set();
|
|
93
|
+
// if (payload?.packages) {
|
|
94
|
+
// payload.packages.forEach((pkg: string) => {
|
|
95
|
+
// let pkgName = pkg.replace('@mastra/', '');
|
|
96
|
+
// if (pkgName === 'mastra') {
|
|
97
|
+
// pkgName = 'cli';
|
|
98
|
+
// }
|
|
99
|
+
// const pkgPath = path.join(process.cwd(), 'packages', pkgName);
|
|
100
|
+
// packagesToBuild.add(pkgPath);
|
|
101
|
+
// });
|
|
102
|
+
// }
|
|
103
|
+
// if (payload?.deployers) {
|
|
104
|
+
// payload.deployers.forEach((pkg: string) => {
|
|
105
|
+
// let pkgName = pkg.replace('@mastra/deployer-', '');
|
|
106
|
+
// if (pkgName === 'mastra') {
|
|
107
|
+
// pkgName = 'cli';
|
|
108
|
+
// }
|
|
109
|
+
// const pkgPath = path.join(process.cwd(), 'deployers', pkgName);
|
|
110
|
+
// deployersToBuild.add(pkgPath);
|
|
111
|
+
// });
|
|
112
|
+
// }
|
|
113
|
+
// if (payload?.combined_stores) {
|
|
114
|
+
// payload.combined_stores.forEach((pkg: string) => {
|
|
115
|
+
// let pkgName = pkg.replace('@mastra/', '');
|
|
116
|
+
// const pkgPath = path.join(process.cwd(), 'stores', pkgName);
|
|
117
|
+
// combined_storesToBuild.add(pkgPath);
|
|
118
|
+
// });
|
|
119
|
+
// }
|
|
120
|
+
// if (payload?.integrations) {
|
|
121
|
+
// const integrations = payload.integrations;
|
|
122
|
+
// integrations.forEach((integration: string) => {
|
|
123
|
+
// let pkgName = integration.replace('@mastra/', '');
|
|
124
|
+
// const integrationPath = path.join(process.cwd(), 'integrations', pkgName);
|
|
125
|
+
// integrationsToBuild.add(integrationPath);
|
|
126
|
+
// });
|
|
127
|
+
// }
|
|
128
|
+
// if (payload?.speech) {
|
|
129
|
+
// const speecs = payload.speech;
|
|
130
|
+
// speecs.forEach((speech: string) => {
|
|
131
|
+
// let pkgName = speech.replace('@mastra/speech-', '');
|
|
132
|
+
// const speechPath = path.join(process.cwd(), 'speech', pkgName);
|
|
133
|
+
// speechToBuild.add(speechPath);
|
|
134
|
+
// });
|
|
135
|
+
// }
|
|
136
|
+
// const pkgSet = Array.from(packagesToBuild.keys());
|
|
137
|
+
// const deploySet = Array.from(deployersToBuild.keys());
|
|
138
|
+
// const integrationSet = Array.from(integrationsToBuild.keys());
|
|
139
|
+
// const combinedStoreSet = Array.from(combined_storesToBuild.keys());
|
|
140
|
+
// const speechSet = Array.from(speechToBuild.keys());
|
|
141
|
+
// if (
|
|
142
|
+
// !packagesToBuild.size &&
|
|
143
|
+
// !deployersToBuild.size &&
|
|
144
|
+
// !integrationsToBuild.size &&
|
|
145
|
+
// !combined_storesToBuild.size
|
|
146
|
+
// ) {
|
|
147
|
+
// console.error(chalk.red('No packages to build.'));
|
|
148
|
+
// return defaultSet;
|
|
149
|
+
// }
|
|
150
|
+
// console.log(chalk.green(`\nBuilding packages:\n`));
|
|
151
|
+
// pkgSet.forEach((pkg: string) => {
|
|
152
|
+
// console.log(chalk.green(pkg));
|
|
153
|
+
// });
|
|
154
|
+
// if (deploySet.length > 0) {
|
|
155
|
+
// console.log(chalk.green(`\nBuilding deployers:\n`));
|
|
156
|
+
// deploySet.forEach((pkg: string) => {
|
|
157
|
+
// console.log(chalk.green(pkg));
|
|
158
|
+
// });
|
|
159
|
+
// }
|
|
160
|
+
// if (integrationSet.length > 0) {
|
|
161
|
+
// console.log(chalk.green(`\nBuilding integrations:\n`));
|
|
162
|
+
// integrationSet.forEach((pkg: string) => {
|
|
163
|
+
// console.log(chalk.green(pkg));
|
|
164
|
+
// });
|
|
165
|
+
// }
|
|
166
|
+
// if (combinedStoreSet.length > 0) {
|
|
167
|
+
// console.log(chalk.green(`\nBuilding store packages:\n`));
|
|
168
|
+
// combinedStoreSet.forEach((pkg: string) => {
|
|
169
|
+
// console.log(chalk.green(pkg));
|
|
170
|
+
// });
|
|
171
|
+
// }
|
|
172
|
+
// if (speechSet.length > 0) {
|
|
173
|
+
// console.log(chalk.green(`\nBuilding speech:\n`));
|
|
174
|
+
// speechSet.forEach((pkg: string) => {
|
|
175
|
+
// console.log(chalk.green(pkg));
|
|
176
|
+
// });
|
|
177
|
+
// }
|
|
178
|
+
// return {
|
|
179
|
+
// packages: pkgSet!,
|
|
180
|
+
// deployers: deploySet!,
|
|
181
|
+
// integrations: integrationSet!,
|
|
182
|
+
// combined_stores: combinedStoreSet!,
|
|
183
|
+
// speech: speechSet!,
|
|
184
|
+
// };
|
|
185
|
+
// },
|
|
186
|
+
// });
|
|
187
|
+
const buildAllPackages = new Step({
|
|
188
|
+
id: 'buildPackages',
|
|
189
|
+
execute: async () => {
|
|
190
|
+
console.log(chalk.green('Building all packages'));
|
|
191
|
+
await execa('pnpm', ['run', 'build'], {
|
|
192
|
+
stdio: 'inherit',
|
|
193
|
+
reject: false,
|
|
194
|
+
cwd: process.cwd(),
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
const publishAllPackages = new Step({
|
|
199
|
+
id: 'publishPackages',
|
|
200
|
+
execute: async () => {
|
|
201
|
+
console.log(chalk.green('Publishing all packages'));
|
|
202
|
+
await execa('pnpm', ['changeset', 'publish'], {
|
|
203
|
+
stdio: 'inherit',
|
|
204
|
+
reject: false,
|
|
205
|
+
cwd: process.cwd(),
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const setAllDistTags = new Step({
|
|
210
|
+
id: 'setAllDistTags',
|
|
211
|
+
execute: async () => {
|
|
212
|
+
console.log(chalk.green('Setting dist tags for all packages'));
|
|
213
|
+
// Get all package.json files from relevant directories
|
|
214
|
+
const packageDirs = ['packages', 'deployers', 'storage', 'vector-stores', 'stores', 'integrations', 'speech'];
|
|
215
|
+
const packages = [];
|
|
216
|
+
for (const dir of packageDirs) {
|
|
217
|
+
const dirPath = path.join(process.cwd(), dir);
|
|
218
|
+
if (!existsSync(dirPath))
|
|
219
|
+
continue;
|
|
220
|
+
const { stdout } = await execa('find', [dirPath, '-name', 'package.json'], {
|
|
221
|
+
reject: false,
|
|
222
|
+
});
|
|
223
|
+
const packagePaths = stdout.split('\n').filter(Boolean);
|
|
224
|
+
for (const packagePath of packagePaths) {
|
|
225
|
+
const pkgJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
226
|
+
if (pkgJson.name && pkgJson.version) {
|
|
227
|
+
packages.push({
|
|
228
|
+
name: pkgJson.name,
|
|
229
|
+
version: pkgJson.version,
|
|
230
|
+
path: path.dirname(packagePath),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
console.log(packages);
|
|
236
|
+
// Set dist tags for each package
|
|
237
|
+
for (const pkg of packages) {
|
|
238
|
+
console.log(chalk.blue(`Setting dist tag for ${pkg.name}@${pkg.version}`));
|
|
239
|
+
try {
|
|
240
|
+
await execa('npm', ['dist-tag', 'add', `${pkg.name}@${pkg.version}`, 'latest'], {
|
|
241
|
+
stdio: 'inherit',
|
|
242
|
+
cwd: pkg.path,
|
|
243
|
+
reject: false,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(chalk.red(`Failed to set dist tag for ${pkg.name}: ${error.message}`));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
packagePublisher.step(buildAllPackages).then(publishAllPackages).then(setAllDistTags).commit();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telephone-game.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/telephone-game.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,QAAQ,EAAiB,MAAM,wBAAwB,CAAC;AAWvE,eAAO,MAAM,qBAAqB,oBAEhC,CAAC"}
|