@mastra/dane 0.0.2-alpha.43 → 0.0.2-alpha.47

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.
@@ -1 +1 @@
1
- {"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../src/commands/commit-message.ts"],"names":[],"mappings":"AAKA,wBAAsB,oBAAoB,kBAgCzC"}
1
+ {"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../src/commands/commit-message.ts"],"names":[],"mappings":"AAKA,wBAAsB,oBAAoB,kBAkCzC"}
@@ -12,7 +12,8 @@ export async function commitMessageCommand() {
12
12
  }
13
13
  // Get the current path
14
14
  const currentPath = execSync('pwd', { encoding: 'utf-8' }).trim();
15
- const result = await workflow.execute({
15
+ const { start } = workflow.createRun();
16
+ const result = await start({
16
17
  triggerData: {
17
18
  repoPath: currentPath,
18
19
  },
@@ -1 +1 @@
1
- {"version":3,"file":"issue-labeler.d.ts","sourceRoot":"","sources":["../../src/commands/issue-labeler.ts"],"names":[],"mappings":"AAIA,wBAAsB,mBAAmB,kBA2BxC"}
1
+ {"version":3,"file":"issue-labeler.d.ts","sourceRoot":"","sources":["../../src/commands/issue-labeler.ts"],"names":[],"mappings":"AAIA,wBAAsB,mBAAmB,kBA8BxC"}
@@ -3,7 +3,8 @@ import { mastra } from '../mastra/index.js';
3
3
  export async function issueLabelerCommand() {
4
4
  console.log(chalk.green("Hi! I'm Dane!"));
5
5
  console.log(chalk.green('Let me label this for you..\n'));
6
- const result = await mastra.getWorkflow('githubIssueLabeler').execute({
6
+ const { start } = mastra.getWorkflow('githubIssueLabeler').createRun();
7
+ const result = await start({
7
8
  triggerData: {
8
9
  issue_number: parseInt(process.env.ISSUE_NUMBER, 10),
9
10
  owner: process.env.OWNER,
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/commands/message.ts"],"names":[],"mappings":"AAIA,wBAAsB,OAAO,kBAW5B"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/commands/message.ts"],"names":[],"mappings":"AAIA,wBAAsB,OAAO,kBAgB5B"}
@@ -3,7 +3,9 @@ import { mastra } from '../mastra/index.js';
3
3
  export async function message() {
4
4
  console.log(chalk.green("Hi! I'm Dane!"));
5
5
  console.log(chalk.green('What would you like to do today?\n'));
6
- console.log(await mastra.getWorkflow('message').execute({
6
+ const { runId, start } = mastra.getWorkflow('message').createRun();
7
+ console.log(runId);
8
+ console.log(await start({
7
9
  triggerData: {
8
10
  resourceid: 'f8b5c3a1-d6e7-4f9c-b2a3-1d8e4c7f9b5a',
9
11
  threadId: '2d9e8c7f-6b5a-4d3c-8f1e-9b7d5c3a2e8h',
@@ -1 +1 @@
1
- {"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../src/commands/publish-packages.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,kBASpC"}
1
+ {"version":3,"file":"publish-packages.d.ts","sourceRoot":"","sources":["../../src/commands/publish-packages.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,kBAWpC"}
@@ -4,6 +4,7 @@ export async function publishPackages() {
4
4
  console.log(chalk.green("Hi! I'm Dane!"));
5
5
  console.log(chalk.green('Let me publish your packages..\n'));
6
6
  const workflow = mastra.getWorkflow('packagePublisher');
7
- const result = await workflow.execute();
7
+ const { start } = workflow.createRun();
8
+ const result = await start();
8
9
  console.log(result);
9
10
  }
@@ -0,0 +1,2 @@
1
+ export declare function telephone(): Promise<void>;
2
+ //# sourceMappingURL=telephone-game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telephone-game.d.ts","sourceRoot":"","sources":["../../src/commands/telephone-game.ts"],"names":[],"mappings":"AAKA,wBAAsB,SAAS,kBAgC9B"}
@@ -0,0 +1,32 @@
1
+ import { confirm } from '@inquirer/prompts';
2
+ import chalk from 'chalk';
3
+ import { mastra } from '../mastra/index.js';
4
+ export async function telephone() {
5
+ console.log(chalk.green("Hi! I'm Dane!"));
6
+ console.log(chalk.green('Lets play telephone..\n'));
7
+ const workflow = mastra.getWorkflow('telephoneGame');
8
+ const { runId, start } = workflow.createRun();
9
+ await start();
10
+ await workflow.watch(runId, {
11
+ onTransition: async ({ activePaths, context }) => {
12
+ for (const path of activePaths) {
13
+ const ctx = context.stepResults?.[path.stepId]?.status;
14
+ if (ctx === 'suspended') {
15
+ // Handle suspension
16
+ if (path.stepId === 'stepC2' && ctx === 'suspended') {
17
+ const confirmed = await confirm({ message: 'Do you want to change the message?' });
18
+ if (confirmed) {
19
+ await workflow.resume({
20
+ stepId: path.stepId,
21
+ runId,
22
+ context: {
23
+ confirm: true,
24
+ },
25
+ });
26
+ }
27
+ }
28
+ }
29
+ }
30
+ },
31
+ });
32
+ }
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { configCommand } from './commands/config.js';
6
6
  import { issueLabelerCommand } from './commands/issue-labeler.js';
7
7
  import { message } from './commands/message.js';
8
8
  import { publishPackages } from './commands/publish-packages.js';
9
+ import { telephone } from './commands/telephone-game.js';
9
10
  dotenv.config();
10
11
  process.env.NODE_NO_WARNINGS = '1';
11
12
  const program = new Command();
@@ -20,4 +21,5 @@ program
20
21
  .action(commitMessageCommand);
21
22
  program.addCommand(configCommand);
22
23
  program.command('publish').description('Publish packages to the registry').action(publishPackages);
24
+ program.command('telephone-game').description('Play a classic game of telephone').action(telephone);
23
25
  program.parse(process.argv);
@@ -314,5 +314,6 @@ export declare const mastra: Mastra<{
314
314
  repoPath: string;
315
315
  }>>;
316
316
  packagePublisher: import("@mastra/core").Workflow<any, any>;
317
- }, import("@mastra/core").BaseLogger<import("@mastra/core").BaseLogMessage>>;
317
+ telephoneGame: import("@mastra/core").Workflow<any, any>;
318
+ }, Record<string, import("@mastra/core").MastraVector>, import("@mastra/core").BaseLogger<import("@mastra/core").BaseLogMessage>>;
318
319
  //# 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;AAatC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAuBjB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mastra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AActC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iIAuBjB,CAAC"}
@@ -5,6 +5,7 @@ import { dane, daneCommitMessage, daneIssueLabeler, danePackagePublisher } from
5
5
  import { firecrawl } from './integrations/index.js';
6
6
  import { messageWorkflow, githubIssueLabeler, commitMessageGenerator } from './workflows/index.js';
7
7
  import { packagePublisher } from './workflows/publish-packages.js';
8
+ import { telephoneGameWorkflow } from './workflows/telephone-game.js';
8
9
  const engine = new PostgresEngine({
9
10
  url: 'postgres://postgres:postgres@localhost:5433/mastra',
10
11
  });
@@ -26,8 +27,8 @@ export const mastra = new Mastra({
26
27
  githubIssueLabeler: githubIssueLabeler,
27
28
  commitMessage: commitMessageGenerator,
28
29
  packagePublisher: packagePublisher,
30
+ telephoneGame: telephoneGameWorkflow,
29
31
  },
30
- logger: false,
31
32
  syncs: {
32
33
  ...firecrawl.getSyncs(),
33
34
  },
@@ -16,7 +16,7 @@ const getDiff = new Step({
16
16
  diff: z.string(),
17
17
  }),
18
18
  execute: async ({ context }) => {
19
- const repoPath = context?.machineContext?.triggerData?.repoPath;
19
+ const repoPath = context?.machineContext?.getStepPayload('trigger')?.repoPath;
20
20
  // Get the git diff of staged changes
21
21
  const diff = execSync('git diff --staged', {
22
22
  cwd: repoPath,
@@ -45,21 +45,21 @@ const generateMessage = new Step({
45
45
  guidelines: z.array(z.string()),
46
46
  }),
47
47
  execute: async ({ context, mastra }) => {
48
- const diffStep = context?.machineContext?.stepResults?.getDiff;
49
- const fileDataStep = context?.machineContext?.stepResults?.readConventionalCommitSpec;
50
- if (!diffStep || diffStep.status !== 'success') {
48
+ const diffData = context?.machineContext?.getStepPayload('getDiff');
49
+ const fileData = context?.machineContext?.getStepPayload('readConventionalCommitSpec');
50
+ if (!diffData) {
51
51
  return { commitMessage: '', generated: false, guidelines: [] };
52
52
  }
53
53
  const daneCommitGenerator = mastra?.agents?.daneCommitMessage;
54
54
  const res = await daneCommitGenerator?.generate(`
55
55
  Given this git diff:
56
- ${diffStep.payload.diff}
56
+ ${diffData.diff}
57
57
 
58
58
  IF THE DIFF IS EMPTY, RETURN "No staged changes found", AND SET GENERATED TO FALSE,
59
59
  OTHERWISE, SET GENERATED TO TRUE
60
60
 
61
- ${fileDataStep?.status === 'success' && fileDataStep?.payload?.fileData?.message
62
- ? `USE THE FOLLOWING GUIDELINES: ${fileDataStep?.payload?.fileData?.message}`
61
+ ${fileData && fileData.fileData?.message
62
+ ? `USE THE FOLLOWING GUIDELINES: ${fileData.fileData?.message}`
63
63
  : `USE THE FOLLOWING GUIDELINES:
64
64
  - Start with a verb in the present tense
65
65
  - Be specific but concise
@@ -0,0 +1,3 @@
1
+ import { Workflow } from '@mastra/core';
2
+ export declare const telephoneGameWorkflow: Workflow<any, any>;
3
+ //# sourceMappingURL=telephone-game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telephone-game.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflows/telephone-game.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAiB,MAAM,cAAc,CAAC;AAG7D,eAAO,MAAM,qBAAqB,oBAEhC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { input } from '@inquirer/prompts';
2
+ import { Step, Workflow, getStepResult } from '@mastra/core';
3
+ import { z } from 'zod';
4
+ export const telephoneGameWorkflow = new Workflow({
5
+ name: 'telephoneGame',
6
+ });
7
+ const stepA1 = new Step({
8
+ id: 'stepA1',
9
+ description: 'Starts the message',
10
+ outputSchema: z.object({
11
+ message: z.string(),
12
+ }),
13
+ execute: async () => {
14
+ return {
15
+ message: 'Test',
16
+ };
17
+ },
18
+ });
19
+ const stepA2 = new Step({
20
+ id: 'stepA2',
21
+ description: 'Pass the message through',
22
+ outputSchema: z.object({
23
+ message: z.string(),
24
+ }),
25
+ execute: async () => {
26
+ const content = await input({
27
+ message: 'Give me a message',
28
+ validate: input => input.trim().length > 0 || 'Message cannot be empty',
29
+ });
30
+ return {
31
+ message: content,
32
+ };
33
+ },
34
+ });
35
+ const stepB2 = new Step({
36
+ id: 'stepB2',
37
+ description: 'Checks if the file exists',
38
+ outputSchema: z.object({
39
+ message: z.string(),
40
+ }),
41
+ execute: async ({ context }) => {
42
+ if (context.machineContext?.stepResults.stepA2?.status !== 'success') {
43
+ throw new Error('Message not found');
44
+ }
45
+ const msg = context.machineContext.stepResults.stepA2.payload.message;
46
+ return {
47
+ message: msg,
48
+ };
49
+ },
50
+ });
51
+ const stepC2 = new Step({
52
+ id: 'stepC2',
53
+ description: 'Ask if you should modify the message',
54
+ outputSchema: z.object({
55
+ message: z.string(),
56
+ }),
57
+ execute: async ({ suspend, context, mastra }) => {
58
+ const oMsg = getStepResult(context?.machineContext?.stepResults.stepA2);
59
+ if (context?.machineContext?.stepResults.stepC2?.status === 'success') {
60
+ const msg = getStepResult(context?.machineContext?.stepResults.stepC2);
61
+ if (msg.confirm) {
62
+ if (mastra?.llm) {
63
+ const llm = mastra?.llm({
64
+ provider: 'ANTHROPIC',
65
+ name: 'claude-3-5-haiku-20241022',
66
+ });
67
+ const result = await llm.generate(`
68
+ You are playing a game of telephone.
69
+ Here is the message the previous person sent ${oMsg.message}.
70
+ But you want to change the message.
71
+ Only return the message
72
+ `);
73
+ return {
74
+ message: result.text,
75
+ };
76
+ }
77
+ }
78
+ return oMsg;
79
+ }
80
+ await suspend();
81
+ return { message: 'Suspended' };
82
+ },
83
+ });
84
+ const stepD2 = new Step({
85
+ id: 'stepD2',
86
+ description: 'Pass the message',
87
+ outputSchema: z.object({
88
+ message: z.string(),
89
+ }),
90
+ execute: async ({ context }) => {
91
+ const msg = getStepResult(context?.machineContext?.stepResults.stepC2);
92
+ return msg;
93
+ },
94
+ });
95
+ telephoneGameWorkflow.step(stepA1).step(stepA2).then(stepB2).then(stepC2).then(stepD2).commit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/dane",
3
- "version": "0.0.2-alpha.43",
3
+ "version": "0.0.2-alpha.47",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -38,13 +38,13 @@
38
38
  "sqlite3": "^5.1.7",
39
39
  "typescript": "^5.5.4",
40
40
  "zod": "^3.24.0",
41
- "@mastra/core": "0.1.27-alpha.51",
42
- "@mastra/engine": "0.0.5-alpha.45",
43
- "@mastra/firecrawl": "1.0.4-alpha.37",
44
- "@mastra/github": "1.0.3-alpha.35",
45
- "@mastra/memory": "0.0.2-alpha.31",
46
- "@mastra/rag": "0.0.2-alpha.35",
47
- "@mastra/stabilityai": "1.0.1-alpha.26"
41
+ "@mastra/core": "0.1.27-alpha.55",
42
+ "@mastra/engine": "0.0.5-alpha.49",
43
+ "@mastra/firecrawl": "1.0.4-alpha.41",
44
+ "@mastra/github": "1.0.3-alpha.39",
45
+ "@mastra/memory": "0.0.2-alpha.35",
46
+ "@mastra/rag": "0.0.2-alpha.39",
47
+ "@mastra/stabilityai": "1.0.1-alpha.30"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "npx tsc",