Skip to content

Commit 35ac6a4

Browse files
committed
feat: implement UI for listing and searching agent networks, tools, and workflows with associated types.
1 parent 5200010 commit 35ac6a4

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

app/components/networks-list.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { Badge } from '@/ui/badge'
77
import { Input } from '@/ui/input'
88
import { PublicPageHero } from '@/app/components/primitives/public-page-hero'
99
import { AnimatedRadarScan } from '@/app/components/gsap/svg-suite'
10-
import { useAgents } from '@/lib/hooks/use-mastra-query'
11-
import type { Agent } from '@/lib/hooks/use-mastra-query'
10+
import { useMastraQuery } from '@/lib/hooks/use-mastra-query'
11+
import type { Agent } from '@/lib/types/mastra-api'
1212
import {
1313
SearchIcon,
1414
NetworkIcon,
@@ -52,14 +52,15 @@ function selectNetworkIcon(id: string): typeof NetworkIcon {
5252
}
5353

5454
export function NetworksList() {
55-
const { data, loading, error } = useAgents()
55+
const { useAgents } = useMastraQuery()
56+
const { data, isLoading: loading, error } = useAgents()
5657
const [search, setSearch] = useState('')
5758

5859
const networks: NetworkCard[] = (data ?? [])
5960
.filter((agent: Agent) => agent.id.toLowerCase().includes('network'))
6061
.map((network: Agent) => ({
6162
id: network.id,
62-
name: network.name ?? network.id,
63+
name: network.name,
6364
description:
6465
network.description ??
6566
'Network orchestrator available from backend.',

app/components/tools-list.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { Badge } from '@/ui/badge'
88
import { Button } from '@/ui/button'
99
import { PublicPageHero } from '@/app/components/primitives/public-page-hero'
1010
import { AnimatedQuantumLattice } from '@/app/components/gsap/svg-suite'
11-
import { useTools } from '@/lib/hooks/use-mastra'
12-
import type { Tool } from '@/lib/hooks/use-mastra-query'
11+
import { useMastraQuery } from '@/lib/hooks/use-mastra-query'
12+
import type { Tool } from '@/lib/types/mastra-api'
1313
import {
1414
SearchIcon,
1515
WrenchIcon,
@@ -132,17 +132,18 @@ function chooseToolIcon(id: string): typeof WrenchIcon {
132132
}
133133

134134
export function ToolsList() {
135-
const { data, loading, error } = useTools()
135+
const { useTools } = useMastraQuery()
136+
const { data, isLoading: loading, error } = useTools()
136137
const [search, setSearch] = useState('')
137138
const [selectedCategory, setSelectedCategory] = useState('All')
138139
const [showAll, setShowAll] = useState(false)
139140

140141
const tools: ToolCard[] = (data ?? []).map((tool: Tool) => ({
141142
id: tool.id,
142-
name: tool.name ?? tool.id,
143-
description: tool.description ?? 'Tool available from backend catalog.',
144-
inputSchema: tool.id,
145-
outputSchema: tool.id,
143+
name: tool.id,
144+
description: tool.description,
145+
inputSchema: tool.inputSchema,
146+
outputSchema: tool.outputSchema,
146147
category: classifyToolCategory(tool.id),
147148
icon: chooseToolIcon(tool.id),
148149
}))

app/components/workflows-list.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { Badge } from '@/ui/badge'
88
import { Button } from '@/ui/button'
99
import { PublicPageHero } from '@/app/components/primitives/public-page-hero'
1010
import { AnimatedHelixDna } from '@/app/components/gsap/svg-suite'
11-
import { useWorkflows } from '@/lib/hooks/use-mastra'
12-
import type { Workflow as WorkflowType } from '@/lib/hooks/use-mastra-query'
11+
import { useMastraQuery } from '@/lib/hooks/use-mastra-query'
12+
import type { Workflow as WorkflowType } from '@/lib/types/mastra-api'
1313
import {
1414
SearchIcon,
1515
PlayIcon,
@@ -53,24 +53,25 @@ function workflowStepsCount(workflow: WorkflowType): number {
5353
if (Array.isArray(workflow.steps)) {
5454
return workflow.steps.length
5555
}
56-
if (workflow.steps) {
56+
if (typeof workflow.steps === 'object') {
5757
return Object.keys(workflow.steps).length
5858
}
5959
return 0
6060
}
6161

6262
export function WorkflowsList() {
63-
const { data, loading, error } = useWorkflows()
63+
const { useWorkflows } = useMastraQuery()
64+
const { data, isLoading: loading, error } = useWorkflows()
6465
const [search, setSearch] = useState('')
6566
const [selectedCategory, setSelectedCategory] = useState('All')
6667

6768
const workflows: WorkflowCard[] = (data ?? []).map(
6869
(workflow: WorkflowType) => ({
69-
id: workflow.id,
70-
name: workflow.name ?? workflow.id,
70+
id: workflow.name,
71+
name: workflow.name,
7172
description:
7273
workflow.description ?? 'Workflow available from backend.',
73-
category: classifyWorkflowCategory(workflow.id),
74+
category: classifyWorkflowCategory(workflow.name),
7475
steps: workflowStepsCount(workflow),
7576
})
7677
)

lib/types/mastra-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ export type {
115115
}
116116

117117
// Convenience Aliases for the app
118-
export type Agent = GetAgentResponse & { id: string }
119-
export type Tool = GetToolResponse & { id: string }
120-
export type Workflow = GetWorkflowResponse & { id: string }
118+
export type Agent = GetAgentResponse
119+
export type Tool = GetToolResponse
120+
export type Workflow = GetWorkflowResponse
121121
export type StoredAgent = StoredAgentResponse
122122
export type MemoryThread = ListMemoryThreadsResponse['threads'][number]
123123
export type Message = ListMemoryThreadMessagesResponse['messages'][number]

0 commit comments

Comments
 (0)