@@ -139,42 +139,39 @@ graph TB
139139``` mermaid
140140%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
141141sequenceDiagram
142- participant W as Workflow Step
143- participant Writer as Writer (custom)
144- participant UI as UI/Frontend
142+ participant User
143+ participant Workflow
144+ participant Writer
145+ participant Agent/Tool
146+ participant Logger
147+
148+ User->>Workflow: Execute workflow step
149+ Workflow->>Logger: logStepStart()
145150
146- Note over W,UI: Standardized Workflow Logging Pattern
151+ Workflow->>Writer: custom({ type: "data-tool-progress" })
152+ Note over Writer: status: "in-progress"<br/>message: "Starting..."<br/>stage: "step-id"
153+ Writer-->>User: Stream progress update
147154
148- W->>Writer: step-start event
149- Writer->>UI: data-workflow-step-start
150- Note right of UI: {type: "workflow", data: "step-id", id: "step-id"}
155+ Workflow->>Agent/Tool: Execute operation
156+ Agent/Tool->>Writer: custom({ type: "data-tool-progress" })
157+ Note over Writer: Tool emits progress<br/>with same format
158+ Writer-->>User: Stream tool progress
151159
152- W->>Writer: progress update (20%)
153- Writer->>UI: data-workflow-progress
154- Note right of UI: {status: "20%", message: "...", stage: "workflow"}
160+ Agent/Tool-->>Workflow: Return result
155161
156- W->>W: Execute step logic
162+ Workflow->>Writer: custom({ type: "data-tool-progress" })
163+ Note over Writer: status: "done"<br/>message: "Completed..."<br/>stage: "step-id"
164+ Writer-->>User: Stream completion
157165
158- W->>Writer: progress update (50%)
159- Writer->>UI: data-workflow-progress
160- Note right of UI: {status: "50%", message: "...", stage: "workflow"}
166+ Workflow->>Logger: logStepEnd()
167+ Workflow-->>User: Return final output
161168
162- W->>W: Continue execution
163-
164- W->>Writer: progress update (100%)
165- Writer->>UI: data-workflow-progress
166- Note right of UI: {status: "100%", message: "...", stage: "workflow"}
167-
168- W->>Writer: step-complete event
169- Writer->>UI: data-workflow-step-complete
170- Note right of UI: {stepId: "step-id", success: true, duration: ms}
171-
172- Note over W,UI: Error Handling Pattern
173-
174- W->>W: Error occurs
175- W->>Writer: step-error event
176- Writer->>UI: data-workflow-step-error
177- Note right of UI: {stepId: "step-id", error: "error message"}
169+ alt Error occurs
170+ Agent/Tool->>Writer: custom({ type: "data-tool-progress" })
171+ Note over Writer: status: "error"<br/>message: error details
172+ Writer-->>User: Stream error
173+ Workflow->>Logger: logError()
174+ end
178175```
179176
180177## 📊 ** System Flowchart**
@@ -330,9 +327,6 @@ cp .env.example .env
330327``` bash
331328# Terminal 1: Start Mastra backend (agents/tools/workflows at :4111)
332329npm run dev
333-
334- # Terminal 2: Start Next.js frontend (at :3000)
335-
336330```
337331
338332### Next.js + Mastra Client SDK
@@ -404,13 +398,15 @@ export type Agent = z.infer<typeof AgentSchema>;
404398```
405399
406400** Key Features:**
401+
407402- ** Type Safety** : All API responses validated with Zod schemas
408403- ** Caching** : Centralized query keys for efficient cache management
409404- ** Mutations** : useExecuteToolMutation, useCreateThreadMutation, useVectorQueryMutation
410405- ** Real-time** : Automatic cache invalidation and refetch on mutations
411406- ** Error Handling** : Built-in loading/error states
412407
413408** Usage in client components:**
409+
414410``` typescript
415411" use client" ;
416412import { useAgentsQuery } from " @/lib/hooks/use-dashboard-queries" ;
@@ -1145,4 +1141,4 @@ classDiagram
11451141 Writer --> WriterCustomPayload : sends
11461142
11471143 UpstashConfig o--> UpstashVector
1148- ` ` `
1144+ ` ` `
0 commit comments