@mastra/dane 0.0.1 → 0.0.2-alpha.10
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/issue-labeler.d.ts +2 -0
- package/dist/commands/issue-labeler.d.ts.map +1 -0
- package/dist/commands/issue-labeler.js +34 -0
- package/dist/commands/message.d.ts +2 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +12 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/mastra/agents/index.d.ts +168 -0
- package/dist/mastra/agents/index.d.ts.map +1 -0
- package/{src/mastra/agents/index.ts → dist/mastra/agents/index.js} +31 -34
- package/dist/mastra/index.d.ts +196 -0
- package/dist/mastra/index.d.ts.map +1 -0
- package/dist/mastra/index.js +32 -0
- package/dist/mastra/integrations/index.d.ts +5 -0
- package/dist/mastra/integrations/index.d.ts.map +1 -0
- package/{src/mastra/integrations/index.ts → dist/mastra/integrations/index.js} +3 -5
- 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 +33 -0
- package/dist/mastra/tools/crawl.d.ts.map +1 -0
- package/dist/mastra/tools/crawl.js +24 -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 +39 -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/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/workflows/chat.d.ts +13 -0
- package/dist/mastra/workflows/chat.d.ts.map +1 -0
- package/dist/mastra/workflows/chat.js +93 -0
- package/dist/mastra/workflows/index.d.ts +3 -0
- package/dist/mastra/workflows/index.d.ts.map +1 -0
- package/dist/mastra/workflows/index.js +2 -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/package.json +23 -10
- package/docker-compose.yaml +0 -22
- package/src/index.ts +0 -19
- package/src/issue-labeler.ts +0 -32
- package/src/mastra/index.ts +0 -32
- package/src/mastra/tools/browser.ts +0 -123
- package/src/mastra/tools/calendar.ts +0 -153
- package/src/mastra/tools/crawl.ts +0 -26
- package/src/mastra/tools/execa.ts +0 -41
- package/src/mastra/tools/fs.ts +0 -36
- package/src/mastra/tools/pdf.ts +0 -46
- package/src/mastra/workflows/chat.ts +0 -109
- package/src/mastra/workflows/index.ts +0 -2
- package/src/mastra/workflows/issue-labeler.ts +0 -103
package/src/mastra/tools/pdf.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createTool } from '@mastra/core';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { existsSync, readFileSync } from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import pdf from 'pdf-parse';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
|
|
8
|
-
export const readPDF = createTool({
|
|
9
|
-
id: 'readPDF',
|
|
10
|
-
name: 'Read PDF',
|
|
11
|
-
description: 'Read PDF file and extract information',
|
|
12
|
-
inputSchema: z.object({
|
|
13
|
-
pdfPath: z.string(),
|
|
14
|
-
}),
|
|
15
|
-
outputSchema: z.object({
|
|
16
|
-
content: z.string(),
|
|
17
|
-
}),
|
|
18
|
-
execute: async ({ context: { pdfPath } }) => {
|
|
19
|
-
try {
|
|
20
|
-
// Check if file exists
|
|
21
|
-
if (!existsSync(pdfPath)) {
|
|
22
|
-
throw new Error('PDF file not found');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Check if file is a PDF
|
|
26
|
-
if (path.extname(pdfPath).toLowerCase() !== '.pdf') {
|
|
27
|
-
throw new Error('File is not a PDF');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Read the PDF file
|
|
31
|
-
const dataBuffer = readFileSync(pdfPath);
|
|
32
|
-
|
|
33
|
-
// Parse PDF content
|
|
34
|
-
const data = await pdf(dataBuffer);
|
|
35
|
-
|
|
36
|
-
console.log(chalk.blue('\n'));
|
|
37
|
-
console.log(chalk.blue('PDF Information:'));
|
|
38
|
-
console.log(chalk.blue('-----------------'));
|
|
39
|
-
console.log(chalk.blue(`Number of pages: ${data.numpages}`));
|
|
40
|
-
|
|
41
|
-
return { content: data.text };
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return { content: 'Error scanning PDF' };
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Step, Workflow } from '@mastra/core';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
import { dane } from '../agents';
|
|
7
|
-
|
|
8
|
-
export const messageWorkflow = new Workflow({
|
|
9
|
-
name: 'entry',
|
|
10
|
-
triggerSchema: z.object({
|
|
11
|
-
resourceid: z.string(),
|
|
12
|
-
threadId: z.string(),
|
|
13
|
-
}),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const messageStep = new Step({
|
|
17
|
-
id: 'message-input',
|
|
18
|
-
outputSchema: z.object({
|
|
19
|
-
message: z.string(),
|
|
20
|
-
}),
|
|
21
|
-
execute: async () => {
|
|
22
|
-
const { content } = await inquirer.prompt([
|
|
23
|
-
{
|
|
24
|
-
type: 'input',
|
|
25
|
-
name: 'content',
|
|
26
|
-
message: '\n You:',
|
|
27
|
-
validate: input => input.trim().length > 0 || 'Message cannot be empty',
|
|
28
|
-
},
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
return { message: content };
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const messageOutputStep = new Step({
|
|
36
|
-
id: 'message-output',
|
|
37
|
-
outputSchema: z.object({
|
|
38
|
-
message: z.string(),
|
|
39
|
-
}),
|
|
40
|
-
// SHOULD BE ABLE TO ACCESS ALL MASTRA PRIMS FROM EXECTUE
|
|
41
|
-
execute: async ({ context, mastra }) => {
|
|
42
|
-
// WISH THIS WAS TYPED
|
|
43
|
-
const threadId = context?.machineContext?.triggerData?.threadId;
|
|
44
|
-
const resourceid = context?.machineContext?.triggerData?.resourceid;
|
|
45
|
-
|
|
46
|
-
const messageInputStatus = context?.machineContext?.stepResults?.['message-input']?.status;
|
|
47
|
-
|
|
48
|
-
if (messageInputStatus !== 'success') {
|
|
49
|
-
return { message: 'Failure in workflow' };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// is there someway to know what steps are flowing into this one and type their props
|
|
53
|
-
const message = context?.machineContext?.stepResults?.['message-input']?.payload?.message;
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
let messages = await mastra?.memory?.getContextWindow({
|
|
57
|
-
threadId,
|
|
58
|
-
format: 'core_message',
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
if (!messages || messages.length === 0) {
|
|
62
|
-
messages = [];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const res = await mastra?.agents?.['dane'].generate(message, {
|
|
66
|
-
stream: true,
|
|
67
|
-
maxSteps: 5,
|
|
68
|
-
resourceid,
|
|
69
|
-
threadId,
|
|
70
|
-
context: [],
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (res) {
|
|
74
|
-
console.log(chalk.green(`\nDane: \n`));
|
|
75
|
-
|
|
76
|
-
for await (const chunk of res.textStream) {
|
|
77
|
-
process.stdout.write(chalk.green(chunk));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
console.log(chalk.green(`\n`));
|
|
81
|
-
|
|
82
|
-
return { message: 'success' };
|
|
83
|
-
}
|
|
84
|
-
} catch (e) {
|
|
85
|
-
console.log(chalk.red(`\n`));
|
|
86
|
-
console.log(chalk.red(`\n`));
|
|
87
|
-
console.log(chalk.red(`Error streaming results. Let's try again.`));
|
|
88
|
-
console.log(chalk.red(e.message));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const res = await dane.generate(message, {
|
|
92
|
-
maxSteps: 5,
|
|
93
|
-
threadId,
|
|
94
|
-
resourceid,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
console.log(chalk.green(res.text));
|
|
98
|
-
|
|
99
|
-
return { message: res.text };
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
messageWorkflow
|
|
104
|
-
.step(messageStep)
|
|
105
|
-
.after(messageStep)
|
|
106
|
-
.step(messageOutputStep)
|
|
107
|
-
.after(messageOutputStep)
|
|
108
|
-
.step(messageStep)
|
|
109
|
-
.commit();
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Step, Workflow } from '@mastra/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
import { github } from '../integrations';
|
|
5
|
-
|
|
6
|
-
export const githubIssueLabeler = new Workflow({
|
|
7
|
-
name: 'github-issue-labeler',
|
|
8
|
-
triggerSchema: z.object({
|
|
9
|
-
repo: z.string(),
|
|
10
|
-
owner: z.string(),
|
|
11
|
-
issue_number: z.number(),
|
|
12
|
-
}),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const getIssue = new Step({
|
|
16
|
-
id: 'getIssue',
|
|
17
|
-
outputSchema: z.object({
|
|
18
|
-
title: z.string(),
|
|
19
|
-
body: z.string(),
|
|
20
|
-
labelNames: z.array(z.string()),
|
|
21
|
-
}),
|
|
22
|
-
execute: async ({ context }) => {
|
|
23
|
-
const client = await github.getApiClient();
|
|
24
|
-
|
|
25
|
-
const issue = await client.issuesGet({
|
|
26
|
-
path: {
|
|
27
|
-
owner: context?.machineContext?.triggerData?.owner,
|
|
28
|
-
repo: context?.machineContext?.triggerData?.repo,
|
|
29
|
-
issue_number: context?.machineContext?.triggerData?.issue_number,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const labels = await client.issuesListLabelsForRepo({
|
|
34
|
-
path: {
|
|
35
|
-
owner: context?.machineContext?.triggerData?.owner,
|
|
36
|
-
repo: context?.machineContext?.triggerData?.repo,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const labelNames = labels?.data?.map(label => label.name);
|
|
41
|
-
|
|
42
|
-
return { title: issue?.data?.title!, body: issue?.data?.body!, labelNames: labelNames! };
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const labelIssue = new Step({
|
|
47
|
-
id: 'labelIssue',
|
|
48
|
-
outputSchema: z.object({
|
|
49
|
-
labels: z.array(z.string()),
|
|
50
|
-
}),
|
|
51
|
-
execute: async ({ context, mastra }) => {
|
|
52
|
-
const parentStep = context?.machineContext?.stepResults?.getIssue;
|
|
53
|
-
if (!parentStep || parentStep.status !== 'success') {
|
|
54
|
-
return { labels: [] };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const daneIssueLabeler = mastra?.agents?.daneIssueLabeler;
|
|
58
|
-
|
|
59
|
-
const res = await daneIssueLabeler?.generate(
|
|
60
|
-
`
|
|
61
|
-
Hey Dane, given:
|
|
62
|
-
* this issue title: ${parentStep?.payload?.title}
|
|
63
|
-
* this issue body: ${parentStep?.payload?.body}
|
|
64
|
-
* these labels: ${parentStep?.payload?.labelNames}
|
|
65
|
-
|
|
66
|
-
What label or labels would you assign?
|
|
67
|
-
`,
|
|
68
|
-
{
|
|
69
|
-
schema: z.object({
|
|
70
|
-
labels: z.array(z.string()),
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return { labels: res?.object?.labels as string[] };
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const applyLabels = new Step({
|
|
80
|
-
id: 'applyLabels',
|
|
81
|
-
execute: async ({ context }) => {
|
|
82
|
-
const parentStep = context?.machineContext?.stepResults?.labelIssue;
|
|
83
|
-
|
|
84
|
-
if (!parentStep || parentStep.status !== 'success') {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const client = await github.getApiClient();
|
|
89
|
-
|
|
90
|
-
await client.issuesAddLabels({
|
|
91
|
-
path: {
|
|
92
|
-
owner: context?.machineContext?.triggerData?.owner,
|
|
93
|
-
repo: context?.machineContext?.triggerData?.repo,
|
|
94
|
-
issue_number: context?.machineContext?.triggerData?.issue_number,
|
|
95
|
-
},
|
|
96
|
-
body: {
|
|
97
|
-
labels: parentStep.payload.labels,
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
githubIssueLabeler.step(getIssue).then(labelIssue).then(applyLabels).commit();
|