Skip to content

Commit 575f068

Browse files
committed
mastra shared state
1 parent e0d9a70 commit 575f068

File tree

6 files changed

+656
-584
lines changed

6 files changed

+656
-584
lines changed

typescript-sdk/apps/dojo/src/app/[integrationId]/feature/agentic_chat/page.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ const AgenticChat: React.FC<AgenticChatProps> = ({ params }) => {
2929
const Chat = () => {
3030
const [background, setBackground] = useState<string>("--copilot-kit-background-color");
3131

32-
const { state: agentState, setState: setAgentState } = useCoAgent({
33-
name: "agentic_chat",
34-
// initialState: {
35-
// firstName: "Markus",
36-
// },
37-
});
38-
39-
console.log(agentState);
40-
4132
useCopilotAction({
4233
name: "lookup_weather",
4334
description: "Lookup the weather for a given city",

typescript-sdk/apps/dojo/src/mastra/index.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,73 @@ export const mastra = new Mastra({
3737
},
3838
}),
3939
}),
40+
shared_state: new Agent({
41+
name: "shared_state",
42+
instructions: `
43+
You are a helpful assistant for creating recipes.
44+
45+
IMPORTANT:
46+
1. Create a recipe using the existing ingredients and instructions. Make sure the recipe is complete.
47+
2. For ingredients, append new ingredients to the existing ones.
48+
3. For instructions, append new steps to the existing ones.
49+
4. 'ingredients' is always an array of objects with 'icon', 'name', and 'amount' fields
50+
5. 'instructions' is always an array of strings
51+
52+
If you have just created or modified the recipe, just answer in one sentence what you did. dont describe the recipe, just say what you did.
53+
`,
54+
model: openai("gpt-4o"),
55+
memory: new Memory({
56+
storage: new LibSQLStore({ url: "file::memory:" }),
57+
options: {
58+
workingMemory: {
59+
enabled: true,
60+
schema: z.object({
61+
recipe: z.object({
62+
skill_level: z
63+
.enum(["Beginner", "Intermediate", "Advanced"])
64+
.describe("The skill level required for the recipe"),
65+
special_preferences: z
66+
.array(
67+
z.enum([
68+
"High Protein",
69+
"Low Carb",
70+
"Spicy",
71+
"Budget-Friendly",
72+
"One-Pot Meal",
73+
"Vegetarian",
74+
"Vegan",
75+
]),
76+
)
77+
.describe("A list of special preferences for the recipe"),
78+
cooking_time: z
79+
.enum(["5 min", "15 min", "30 min", "45 min", "60+ min"])
80+
.describe("The cooking time of the recipe"),
81+
ingredients: z
82+
.array(
83+
z.object({
84+
icon: z
85+
.string()
86+
.describe(
87+
"The icon emoji (not emoji code like '\x1f35e', but the actual emoji like 🥕) of the ingredient",
88+
),
89+
name: z.string().describe("The name of the ingredient"),
90+
amount: z.string().describe("The amount of the ingredient"),
91+
}),
92+
)
93+
.describe(
94+
"Entire list of ingredients for the recipe, including the new ingredients and the ones that are already in the recipe",
95+
),
96+
instructions: z
97+
.array(z.string())
98+
.describe(
99+
"Entire list of instructions for the recipe, including the new instructions and the ones that are already there",
100+
),
101+
changes: z.string().describe("A description of the changes made to the recipe"),
102+
}),
103+
}),
104+
},
105+
},
106+
}),
107+
}),
40108
},
41109
});

typescript-sdk/apps/dojo/src/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
3131
{
3232
id: "mastra-agent-local",
3333
name: "Mastra Agent (Local)",
34-
features: ["agentic_chat"],
34+
features: ["agentic_chat", "shared_state"],
3535
},
3636
{
3737
id: "vercel-ai-sdk",

0 commit comments

Comments
 (0)