@mastra/dane 0.0.2-alpha.2 → 0.0.2-alpha.3

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.
Files changed (51) hide show
  1. package/dist/commands/issue-labeler.d.ts +1 -0
  2. package/dist/commands/issue-labeler.js +18 -0
  3. package/dist/commands/message.d.ts +1 -0
  4. package/dist/commands/message.js +12 -0
  5. package/dist/index.d.ts +2 -0
  6. package/{src/index.ts → dist/index.js} +0 -5
  7. package/dist/mastra/agents/index.d.ts +167 -0
  8. package/{src/mastra/agents/index.ts → dist/mastra/agents/index.js} +25 -28
  9. package/dist/mastra/index.d.ts +195 -0
  10. package/dist/mastra/index.js +29 -0
  11. package/dist/mastra/integrations/index.d.ts +4 -0
  12. package/{src/mastra/integrations/index.ts → dist/mastra/integrations/index.js} +3 -5
  13. package/dist/mastra/tools/browser.d.ts +39 -0
  14. package/dist/mastra/tools/browser.js +118 -0
  15. package/dist/mastra/tools/calendar.d.ts +20 -0
  16. package/dist/mastra/tools/calendar.js +134 -0
  17. package/dist/mastra/tools/crawl.d.ts +32 -0
  18. package/dist/mastra/tools/crawl.js +24 -0
  19. package/dist/mastra/tools/execa.d.ts +26 -0
  20. package/dist/mastra/tools/execa.js +39 -0
  21. package/dist/mastra/tools/fs.d.ts +32 -0
  22. package/dist/mastra/tools/fs.js +36 -0
  23. package/dist/mastra/tools/pdf.d.ts +20 -0
  24. package/dist/mastra/tools/pdf.js +41 -0
  25. package/dist/mastra/workflows/chat.d.ts +12 -0
  26. package/dist/mastra/workflows/chat.js +93 -0
  27. package/dist/mastra/workflows/index.js +2 -0
  28. package/dist/mastra/workflows/issue-labeler.d.ts +15 -0
  29. package/dist/mastra/workflows/issue-labeler.js +85 -0
  30. package/package.json +8 -5
  31. package/CHANGELOG.md +0 -37
  32. package/docker-compose.yaml +0 -22
  33. package/src/commands/issue-labeler.ts +0 -26
  34. package/src/commands/message.ts +0 -16
  35. package/src/mastra/index.ts +0 -32
  36. package/src/mastra/tools/browser.ts +0 -132
  37. package/src/mastra/tools/calendar.ts +0 -154
  38. package/src/mastra/tools/crawl.ts +0 -26
  39. package/src/mastra/tools/execa.ts +0 -41
  40. package/src/mastra/tools/fs.ts +0 -36
  41. package/src/mastra/tools/pdf.ts +0 -46
  42. package/src/mastra/workflows/chat.ts +0 -111
  43. package/src/mastra/workflows/issue-labeler.ts +0 -104
  44. package/test/data/05-versions-space.pdf +0 -0
  45. package/test/data/05-versions-space.pdf.txt +0 -42
  46. package/test-files/roman.md +0 -79
  47. package/test-files/sample-1.pdf +0 -0
  48. package/test-files/taxes/2022.txt +0 -45
  49. package/test-files/taxes/2023.txt +0 -44
  50. package/tsconfig.json +0 -11
  51. /package/{src/mastra/workflows/index.ts → dist/mastra/workflows/index.d.ts} +0 -0
@@ -0,0 +1,118 @@
1
+ import { createTool } from '@mastra/core';
2
+ import { MDocument } from '@mastra/rag';
3
+ import chalk from 'chalk';
4
+ import { chromium } from 'playwright-core';
5
+ import { z } from 'zod';
6
+ export const browserTool = createTool({
7
+ id: 'browserTool',
8
+ name: 'Browser Tool',
9
+ description: 'Browser Tool, opens a browser and navigates to a url capturing the content',
10
+ inputSchema: z.object({
11
+ url: z.string(),
12
+ }),
13
+ outputSchema: z.object({
14
+ message: z.string(),
15
+ }),
16
+ execute: async ({ context: { url } }) => {
17
+ try {
18
+ const browser = await chromium.launch({
19
+ headless: true,
20
+ });
21
+ const page = await browser.newPage();
22
+ await page.goto(url);
23
+ const docs = MDocument.fromHTML(await page.content());
24
+ await docs.chunk({
25
+ strategy: 'html',
26
+ options: {
27
+ chunkSize: 300,
28
+ sections: [
29
+ ['h1', 'Header 1'],
30
+ ['h2', 'Header 2'],
31
+ ['h3', 'Header 3'],
32
+ ['h4', 'Header 4'],
33
+ ['h5', 'Header 5'],
34
+ ['h6', 'Header 6'],
35
+ ['p', 'Paragraph'],
36
+ ],
37
+ },
38
+ });
39
+ await page.close();
40
+ await browser.close();
41
+ if (!docs.getText().length) {
42
+ return { message: 'No content' };
43
+ }
44
+ return { message: docs.getText().join('\n') };
45
+ }
46
+ catch (e) {
47
+ if (e instanceof Error) {
48
+ console.log(`\n${chalk.red(e.message)}`);
49
+ return { message: `Error: ${e.message}` };
50
+ }
51
+ return { message: 'Error' };
52
+ }
53
+ },
54
+ });
55
+ export const googleSearch = createTool({
56
+ id: 'googleSearch',
57
+ name: 'Google Search',
58
+ description: 'Google Search. Passes the query to Google and returns the search results.',
59
+ inputSchema: z.object({
60
+ query: z.string(),
61
+ }),
62
+ outputSchema: z.object({
63
+ message: z.string(),
64
+ }),
65
+ execute: async ({ context: { query } }) => {
66
+ let browser;
67
+ try {
68
+ browser = await chromium.launch({
69
+ headless: true,
70
+ });
71
+ }
72
+ catch (e) {
73
+ if (e instanceof Error) {
74
+ console.log(`\n${chalk.red(e.message)}`);
75
+ return { message: `Error: ${e.message}` };
76
+ }
77
+ return { message: 'Error' };
78
+ }
79
+ try {
80
+ const page = await browser.newPage();
81
+ await page.goto(`https://www.google.com/search?q=${encodeURIComponent(query)}`);
82
+ console.log(`\n`);
83
+ console.log(chalk.blue('Waiting for search results...'));
84
+ try {
85
+ await page.click('button:has-text("Accept all")', { timeout: 5000 });
86
+ }
87
+ catch (e) {
88
+ // Cookie dialog didn't appear, continue
89
+ }
90
+ // Wait for results and click first organic result
91
+ await page.waitForSelector('#search');
92
+ const text = await page.evaluate(() => {
93
+ const links = [];
94
+ const searchResults = document.querySelectorAll('div.g a');
95
+ searchResults.forEach(link => {
96
+ const href = link.getAttribute('href');
97
+ if (href && href.startsWith('http')) {
98
+ links.push(href);
99
+ }
100
+ });
101
+ return links;
102
+ });
103
+ await page.close();
104
+ await browser.close();
105
+ if (!text.length) {
106
+ return { message: 'No results' };
107
+ }
108
+ return { message: text.join('\n') };
109
+ }
110
+ catch (e) {
111
+ if (e instanceof Error) {
112
+ console.log(`\n${chalk.red(e.message)}`);
113
+ return { message: `Error: ${e.message}` };
114
+ }
115
+ return { message: `Error` };
116
+ }
117
+ },
118
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const listEvents: import("@mastra/core").Tool<"listEvents", z.ZodObject<{
3
+ startDate: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ startDate: string;
6
+ }, {
7
+ startDate: string;
8
+ }>, z.ZodObject<{
9
+ content: z.ZodString;
10
+ }, "strip", z.ZodTypeAny, {
11
+ content: string;
12
+ }, {
13
+ content: string;
14
+ }>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
15
+ startDate: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ startDate: string;
18
+ }, {
19
+ startDate: string;
20
+ }>, import("@mastra/core").WorkflowContext<any>>>;
@@ -0,0 +1,134 @@
1
+ import { createTool } from '@mastra/core';
2
+ import chalk from 'chalk';
3
+ import { execSync } from 'child_process';
4
+ import Table from 'cli-table3';
5
+ import { z } from 'zod';
6
+ class LocalCalendarReader {
7
+ async getEvents() {
8
+ const script = `
9
+ tell application "Calendar"
10
+ set eventList to {}
11
+ set startDate to (current date) - 7 * days
12
+ set endDate to (current date) + 365 * days
13
+
14
+ repeat with calendarAccount in calendars
15
+ set eventList to eventList & (every event of calendarAccount whose start date is greater than or equal to startDate and start date is less than or equal to endDate)
16
+ end repeat
17
+
18
+ set output to ""
19
+ repeat with anEvent in eventList
20
+ set theTitle to summary of anEvent
21
+ set theStart to start date of anEvent as string
22
+ set theEnd to end date of anEvent as string
23
+ set theLoc to location of anEvent
24
+ set theDesc to description of anEvent
25
+
26
+ if theLoc is missing value then
27
+ set theLoc to ""
28
+ end if
29
+ if theDesc is missing value then
30
+ set theDesc to ""
31
+ end if
32
+
33
+ set output to output & theTitle & "|" & theStart & "|" & theEnd & "|" & theLoc & "|" & theDesc & "
34
+ "
35
+ end repeat
36
+
37
+ return output
38
+ end tell
39
+ `;
40
+ try {
41
+ const result = execSync(`osascript -e '${script}'`).toString();
42
+ return this.parseAppleScriptOutput(result);
43
+ }
44
+ catch (error) {
45
+ if (error instanceof Error) {
46
+ console.error('Raw AppleScript error:', error.message);
47
+ throw new Error(`Failed to read Mac calendar: ${error.message}`);
48
+ }
49
+ else {
50
+ console.error('An unknown error occurred:', error);
51
+ throw new Error('Failed to read Mac calendar');
52
+ }
53
+ }
54
+ }
55
+ parseAppleScriptOutput(output) {
56
+ const events = [];
57
+ const lines = output.split('\n').filter(line => line.trim());
58
+ for (const line of lines) {
59
+ try {
60
+ const [title, startDateStr, endDateStr, location, description] = line.split('|');
61
+ const startStandardized = startDateStr
62
+ ?.split(',')?.[1] // Remove day name
63
+ ?.replace(' at ', ' ') // Remove 'at'
64
+ ?.trim(); // 'January 3, 2025 9:00:00 AM'
65
+ const startDate = new Date(startStandardized || '');
66
+ const endStandardized = endDateStr
67
+ ?.split(',')?.[1] // Remove day name
68
+ ?.replace(' at ', ' ') // Remove 'at'
69
+ ?.trim(); // 'January 3, 2025 9:00:00 AM'
70
+ const endDate = new Date(endStandardized || '');
71
+ const event = {
72
+ title: title?.trim(),
73
+ startDate,
74
+ endDate,
75
+ location: location?.trim() || '',
76
+ description: description?.trim() || '',
77
+ };
78
+ events.push(event);
79
+ }
80
+ catch (error) {
81
+ console.error('Failed to parse event line:', line, error);
82
+ }
83
+ }
84
+ return events.sort((a, b) => a.startDate.getTime() - b.startDate.getTime());
85
+ }
86
+ }
87
+ const reader = new LocalCalendarReader();
88
+ export const listEvents = createTool({
89
+ id: 'listEvents',
90
+ name: 'List Events',
91
+ description: 'List calendar events',
92
+ inputSchema: z.object({
93
+ startDate: z.string(),
94
+ }),
95
+ outputSchema: z.object({
96
+ content: z.string(),
97
+ }),
98
+ execute: async () => {
99
+ try {
100
+ const events = await reader.getEvents();
101
+ const table = new Table({
102
+ head: [
103
+ chalk.blue('Start'),
104
+ chalk.blue('End'),
105
+ chalk.blue('Title'),
106
+ chalk.blue('Location'),
107
+ chalk.blue('Description'),
108
+ ],
109
+ colWidths: [12, 15, 30, 20, 40],
110
+ });
111
+ events.forEach(event => {
112
+ if (event.title) {
113
+ table.push([
114
+ event.startDate.toISOString(),
115
+ event.endDate.toISOString(),
116
+ event.title || '',
117
+ event.location || '',
118
+ (event.description || '').substring(0, 37) + '...',
119
+ ]);
120
+ }
121
+ });
122
+ // console.log(chalk.blue(table.toString()));
123
+ return {
124
+ content: JSON.stringify(events, null, 2),
125
+ };
126
+ }
127
+ catch (e) {
128
+ if (e instanceof Error) {
129
+ console.log(`\n${chalk.red(e.message)}`);
130
+ }
131
+ return { content: 'Error' };
132
+ }
133
+ },
134
+ });
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare const crawl: import("@mastra/core").Tool<"crawler", z.ZodObject<{
3
+ url: z.ZodString;
4
+ limit: z.ZodDefault<z.ZodNumber>;
5
+ pathRegex: z.ZodNullable<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ url: string;
8
+ limit: number;
9
+ pathRegex: string | null;
10
+ }, {
11
+ url: string;
12
+ pathRegex: string | null;
13
+ limit?: number | undefined;
14
+ }>, z.ZodObject<{
15
+ message: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ message: string;
18
+ }, {
19
+ message: string;
20
+ }>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
21
+ url: z.ZodString;
22
+ limit: z.ZodDefault<z.ZodNumber>;
23
+ pathRegex: z.ZodNullable<z.ZodString>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ url: string;
26
+ limit: number;
27
+ pathRegex: string | null;
28
+ }, {
29
+ url: string;
30
+ pathRegex: string | null;
31
+ limit?: number | undefined;
32
+ }>, import("@mastra/core").WorkflowContext<any>>>;
@@ -0,0 +1,24 @@
1
+ import { createTool } from '@mastra/core';
2
+ import { z } from 'zod';
3
+ export const crawl = createTool({
4
+ id: 'crawler',
5
+ name: 'Crawler Tool',
6
+ description: 'Crawler Tool to crawl a website and return the content',
7
+ inputSchema: z.object({
8
+ url: z.string(),
9
+ limit: z.number().default(3),
10
+ pathRegex: z.string().nullable(),
11
+ }),
12
+ outputSchema: z.object({
13
+ message: z.string(),
14
+ }),
15
+ execute: async ({ context, mastra }) => {
16
+ await mastra?.syncs?.['FIRECRAWL:CRAWL_AND_SYNC']?.execute({
17
+ context,
18
+ mastra,
19
+ });
20
+ return {
21
+ message: 'The website has been successfully crawled and chunks have been synced to the database. Finish.',
22
+ };
23
+ },
24
+ });
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ export declare const execaTool: import("@mastra/core").Tool<"execaTool", z.ZodObject<{
3
+ command: z.ZodString;
4
+ args: z.ZodArray<z.ZodString, "many">;
5
+ }, "strip", z.ZodTypeAny, {
6
+ command: string;
7
+ args: string[];
8
+ }, {
9
+ command: string;
10
+ args: 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
+ command: z.ZodString;
19
+ args: z.ZodArray<z.ZodString, "many">;
20
+ }, "strip", z.ZodTypeAny, {
21
+ command: string;
22
+ args: string[];
23
+ }, {
24
+ command: string;
25
+ args: string[];
26
+ }>, import("@mastra/core").WorkflowContext<any>>>;
@@ -0,0 +1,39 @@
1
+ import { createTool } from '@mastra/core';
2
+ import chalk from 'chalk';
3
+ import { execa } from 'execa';
4
+ import { Transform } from 'stream';
5
+ import { z } from 'zod';
6
+ // Create transform stream that applies chalk
7
+ const colorTransform = new Transform({
8
+ transform(chunk, _encoding, callback) {
9
+ // Convert chunk to string and apply chalk
10
+ const colored = chalk.blue(chunk.toString());
11
+ this.push(colored);
12
+ callback();
13
+ },
14
+ });
15
+ export const execaTool = createTool({
16
+ id: 'execaTool',
17
+ name: 'Execa System Tool',
18
+ description: 'Execa System Tool',
19
+ inputSchema: z.object({
20
+ command: z.string(),
21
+ args: z.array(z.string()),
22
+ }),
23
+ outputSchema: z.object({
24
+ message: z.string(),
25
+ }),
26
+ execute: async ({ context: { command, args } }) => {
27
+ try {
28
+ const p = execa(command, args);
29
+ console.log(`\n`);
30
+ p.stdout.pipe(colorTransform).pipe(process.stdout);
31
+ p.stderr.pipe(colorTransform).pipe(process.stderr);
32
+ const r = await p;
33
+ return { message: r.stdout };
34
+ }
35
+ catch (e) {
36
+ return { message: 'Error' };
37
+ }
38
+ },
39
+ });
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare const fsTool: import("@mastra/core").Tool<"fsTool", z.ZodObject<{
3
+ action: z.ZodString;
4
+ file: z.ZodString;
5
+ data: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ data: string;
8
+ action: string;
9
+ file: string;
10
+ }, {
11
+ data: string;
12
+ action: string;
13
+ file: string;
14
+ }>, z.ZodObject<{
15
+ message: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ message: string;
18
+ }, {
19
+ message: string;
20
+ }>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
21
+ action: z.ZodString;
22
+ file: z.ZodString;
23
+ data: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ data: string;
26
+ action: string;
27
+ file: string;
28
+ }, {
29
+ data: string;
30
+ action: string;
31
+ file: string;
32
+ }>, import("@mastra/core").WorkflowContext<any>>>;
@@ -0,0 +1,36 @@
1
+ import { createTool } from '@mastra/core';
2
+ import { readFileSync, writeFileSync } from 'fs';
3
+ import { z } from 'zod';
4
+ export const fsTool = createTool({
5
+ id: 'fsTool',
6
+ name: 'File System Tool',
7
+ description: 'File System Tool',
8
+ inputSchema: z.object({
9
+ action: z.string(),
10
+ file: z.string(),
11
+ data: z.string(),
12
+ }),
13
+ outputSchema: z.object({
14
+ message: z.string(),
15
+ }),
16
+ execute: async ({ context: { action, file, data } }) => {
17
+ try {
18
+ switch (action) {
19
+ case 'write':
20
+ writeFileSync(file, data);
21
+ break;
22
+ case 'read':
23
+ return { message: readFileSync(file, 'utf8') };
24
+ case 'append':
25
+ writeFileSync(file, data, { flag: 'a' });
26
+ break;
27
+ default:
28
+ return { message: 'Invalid action' };
29
+ }
30
+ return { message: 'Success' };
31
+ }
32
+ catch (e) {
33
+ return { message: 'Error' };
34
+ }
35
+ },
36
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const readPDF: import("@mastra/core").Tool<"readPDF", z.ZodObject<{
3
+ pdfPath: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ pdfPath: string;
6
+ }, {
7
+ pdfPath: string;
8
+ }>, z.ZodObject<{
9
+ content: z.ZodString;
10
+ }, "strip", z.ZodTypeAny, {
11
+ content: string;
12
+ }, {
13
+ content: string;
14
+ }>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
15
+ pdfPath: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ pdfPath: string;
18
+ }, {
19
+ pdfPath: string;
20
+ }>, import("@mastra/core").WorkflowContext<any>>>;
@@ -0,0 +1,41 @@
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
+ export const readPDF = createTool({
8
+ id: 'readPDF',
9
+ name: 'Read PDF',
10
+ description: 'Read PDF file and extract information',
11
+ inputSchema: z.object({
12
+ pdfPath: z.string(),
13
+ }),
14
+ outputSchema: z.object({
15
+ content: z.string(),
16
+ }),
17
+ execute: async ({ context: { pdfPath } }) => {
18
+ try {
19
+ // Check if file exists
20
+ if (!existsSync(pdfPath)) {
21
+ throw new Error('PDF file not found');
22
+ }
23
+ // Check if file is a PDF
24
+ if (path.extname(pdfPath).toLowerCase() !== '.pdf') {
25
+ throw new Error('File is not a PDF');
26
+ }
27
+ // Read the PDF file
28
+ const dataBuffer = readFileSync(pdfPath);
29
+ // Parse PDF content
30
+ const data = await pdf(dataBuffer);
31
+ console.log(chalk.blue('\n'));
32
+ console.log(chalk.blue('PDF Information:'));
33
+ console.log(chalk.blue('-----------------'));
34
+ console.log(chalk.blue(`Number of pages: ${data.numpages}`));
35
+ return { content: data.text };
36
+ }
37
+ catch (e) {
38
+ return { content: 'Error scanning PDF' };
39
+ }
40
+ },
41
+ });
@@ -0,0 +1,12 @@
1
+ import { Workflow } from '@mastra/core';
2
+ import { z } from 'zod';
3
+ export declare const messageWorkflow: Workflow<any, z.ZodObject<{
4
+ resourceid: z.ZodString;
5
+ threadId: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ resourceid: string;
8
+ threadId: string;
9
+ }, {
10
+ resourceid: string;
11
+ threadId: string;
12
+ }>>;
@@ -0,0 +1,93 @@
1
+ import { Step, Workflow } from '@mastra/core';
2
+ import chalk from 'chalk';
3
+ import inquirer from 'inquirer';
4
+ import { z } from 'zod';
5
+ import { dane } from '../agents/index.js';
6
+ export const messageWorkflow = new Workflow({
7
+ name: 'entry',
8
+ triggerSchema: z.object({
9
+ resourceid: z.string(),
10
+ threadId: z.string(),
11
+ }),
12
+ });
13
+ const messageStep = new Step({
14
+ id: 'message-input',
15
+ outputSchema: z.object({
16
+ message: z.string(),
17
+ }),
18
+ execute: async () => {
19
+ const { content } = await inquirer.prompt([
20
+ {
21
+ type: 'input',
22
+ name: 'content',
23
+ message: '\n You:',
24
+ validate: input => input.trim().length > 0 || 'Message cannot be empty',
25
+ },
26
+ ]);
27
+ return { message: content };
28
+ },
29
+ });
30
+ const messageOutputStep = new Step({
31
+ id: 'message-output',
32
+ outputSchema: z.object({
33
+ message: z.string(),
34
+ }),
35
+ // SHOULD BE ABLE TO ACCESS ALL MASTRA PRIMS FROM EXECTUE
36
+ execute: async ({ context, mastra }) => {
37
+ // WISH THIS WAS TYPED
38
+ const threadId = context?.machineContext?.triggerData?.threadId;
39
+ const resourceid = context?.machineContext?.triggerData?.resourceid;
40
+ const messageInputStatus = context?.machineContext?.stepResults?.['message-input']?.status;
41
+ if (messageInputStatus !== 'success') {
42
+ return { message: 'Failure in workflow' };
43
+ }
44
+ // is there someway to know what steps are flowing into this one and type their props
45
+ const message = context?.machineContext?.stepResults?.['message-input']?.payload?.message;
46
+ try {
47
+ let messages = await mastra?.memory?.getContextWindow({
48
+ threadId,
49
+ format: 'core_message',
50
+ });
51
+ if (!messages || messages.length === 0) {
52
+ messages = [];
53
+ }
54
+ const res = await mastra?.agents?.['dane']?.generate(message, {
55
+ stream: true,
56
+ maxSteps: 5,
57
+ resourceid,
58
+ threadId,
59
+ context: [],
60
+ });
61
+ if (res) {
62
+ console.log(chalk.green(`\nDane: \n`));
63
+ for await (const chunk of res.textStream) {
64
+ process.stdout.write(chalk.green(chunk));
65
+ }
66
+ console.log(chalk.green(`\n`));
67
+ return { message: 'success' };
68
+ }
69
+ }
70
+ catch (e) {
71
+ console.log(chalk.red(`\n`));
72
+ console.log(chalk.red(`\n`));
73
+ console.log(chalk.red(`Error streaming results. Let's try again.`));
74
+ if (e instanceof Error) {
75
+ console.log(chalk.red(e.message));
76
+ }
77
+ }
78
+ const res = await dane.generate(message, {
79
+ maxSteps: 5,
80
+ threadId,
81
+ resourceid,
82
+ });
83
+ console.log(chalk.green(res?.text));
84
+ return { message: res?.text };
85
+ },
86
+ });
87
+ messageWorkflow
88
+ .step(messageStep)
89
+ .after(messageStep)
90
+ .step(messageOutputStep)
91
+ .after(messageOutputStep)
92
+ .step(messageStep)
93
+ .commit();
@@ -0,0 +1,2 @@
1
+ export * from './chat.js';
2
+ export * from './issue-labeler.js';
@@ -0,0 +1,15 @@
1
+ import { Workflow } from '@mastra/core';
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
+ }>>;