Skip to content

Commit e603cbe

Browse files
authored
Merge pull request #36 from ssdeanx/develop
feat: enhance agent components and workflows
2 parents bb4a128 + 34729ce commit e603cbe

21 files changed

Lines changed: 49 additions & 142 deletions

app/chat/helpers/tool-part-transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function mapDataToolPartToDynamicToolPart(part: any): DynamicToolUIPart |
128128
(inner?.state ?? inner?.status ?? payload?.state ?? payload?.status ?? "").toString() ?? "";
129129

130130
// Convert a free-form status to tool states defined by the SDK
131-
function mapToToolState(s: string): DynamicToolUIPart["state"] {
131+
const mapToToolState = (s: string): DynamicToolUIPart["state"] => {
132132
const st = String(s ?? "").toLowerCase();
133133

134134
if (!st) {
@@ -164,7 +164,7 @@ export function mapDataToolPartToDynamicToolPart(part: any): DynamicToolUIPart |
164164
// fallback: if an output is present consider finished, otherwise input available
165165
if (output !== undefined && output !== null) {return "output-available";}
166166
return "input-available";
167-
}
167+
};
168168

169169
const state = mapToToolState(rawState);
170170

app/dashboard/agents/_components/agent-details.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export function AgentDetails({ agentId }: AgentDetailsProps) {
4242
)}
4343
<div className="flex gap-2">
4444
<Badge variant="outline">{agent.id}</Badge>
45-
{agent.model && <Badge variant="secondary">{agent.model}</Badge>}
45+
{agent.model && (
46+
<Badge variant="secondary">
47+
{typeof agent.model === "string"
48+
? agent.model
49+
: `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`}
50+
</Badge>
51+
)}
4652
</div>
4753
</div>
4854

@@ -76,7 +82,7 @@ export function AgentDetails({ agentId }: AgentDetailsProps) {
7682
{agent.model && (
7783
<div>
7884
<h4 className="text-sm font-medium mb-2">Model</h4>
79-
<p className="text-sm text-muted-foreground">{agent.model}</p>
85+
{typeof agent.model === "string" ? agent.model : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`}
8086
</div>
8187
)}
8288

app/dashboard/agents/_components/agent-tab.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ export function AgentTab({ agentId }: AgentTabProps) {
6262
</div>
6363
</div>
6464

65-
{agent.tools && agent.tools.length > 0 && (
65+
{Array.isArray(agent.tools) && agent.tools.length > 0 && (
6666
<div>
6767
<h4 className="text-sm font-medium mb-3">Tools</h4>
6868
<div className="flex flex-wrap gap-2">
69-
{agent.tools.map((tool, index) => (
70-
<Badge key={index} variant="secondary">{tool.name}</Badge>
71-
))}
69+
{agent.tools.map((tool, index) => {
70+
const label = typeof tool === "string" ? tool : (tool.name ?? tool.id)
71+
return (
72+
<Badge key={index} variant="secondary">{label}</Badge>
73+
)
74+
})}
7275
</div>
7376
</div>
7477
)}

app/dashboard/agents/_components/agent-tools-tab.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ interface AgentToolsTabProps {
1010
}
1111

1212
export function AgentToolsTab({ agent }: AgentToolsTabProps) {
13-
const tools = agent.tools ?? []
13+
const tools = Array.isArray(agent.tools)
14+
? agent.tools
15+
: agent.tools
16+
? [agent.tools]
17+
: []
1418

1519
if (tools.length === 0) {
1620
return (
@@ -25,16 +29,21 @@ export function AgentToolsTab({ agent }: AgentToolsTabProps) {
2529
return (
2630
<div className="space-y-3">
2731
{tools.map((tool, index) => {
28-
const toolId = typeof tool === "string" ? tool : tool.id
29-
const toolName = typeof tool === "string" ? tool : tool.name || tool.id
32+
const toolId = typeof tool === "string" ? tool : (tool as any).id
33+
const toolName = typeof tool === "string" ? tool : tool.name || (tool as any).id
3034
return (
3135
<div
32-
key={`${toolId}-${index}`}
36+
key={`${toolName}-${toolId}-${index}`}
3337
className="flex items-center justify-between p-3 rounded-md border"
38+
data-testid={`agent-tool-${toolId}-${toolName}`}
3439
>
3540
<div className="flex items-center gap-3">
3641
<Wrench className="h-4 w-4 text-muted-foreground" />
37-
<span className="font-medium">{toolName}</span>
42+
<span className="text-sm font-medium">
43+
{typeof tool === "string"
44+
? tool
45+
: String(tool.name ?? (tool as any).id ?? JSON.stringify(tool))}
46+
</span>
3847
</div>
3948
<Badge variant="secondary">Tool</Badge>
4049
</div>

app/dashboard/agents/_components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export { AgentList } from "./agent-list"
22
export { AgentListItem } from "./agent-list-item"
33
export { AgentDetails } from "./agent-details"
44
export { AgentToolsTab } from "./agent-tools-tab"
5-
export { AgentEvalsTab } from "./agent-tab"
5+
export { AgentTab } from "./agent-tab"

src/mastra/agents/sql.ts

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/mastra/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import { weatherWorkflow } from './workflows/weather-workflow';
8989
import { repoIngestionWorkflow } from './workflows/repo-ingestion-workflow';
9090
import { specGenerationWorkflow } from './workflows/spec-generation-workflow';
9191
import { ResearchRuntimeContext } from './agents/index';
92+
import { governedRagIndex } from "./workflows/governed-rag-index.workflow";
9293

9394
const ml = process.env.MLFLOW_EXPERIMENT_ID
9495

@@ -106,6 +107,8 @@ export const mastra = new Mastra({
106107
telephoneGameWorkflow,
107108
repoIngestionWorkflow,
108109
specGenerationWorkflow,
110+
governedRagIndex,
111+
109112
},
110113
agents: {
111114
// Core Agents

src/mastra/workflows/changelog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ const stepA2 = createStep({
279279
});
280280

281281
const changelogWorkflow = createWorkflow({
282-
id: 'changelog',
282+
id: 'changelogWorkflow',
283283
inputSchema: z.object({
284284
channelId: z.string(),
285285
}),

src/mastra/workflows/content-review-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ const finalizeContentStep = createStep({
700700
});
701701

702702
export const contentReviewWorkflow = createWorkflow({
703-
id: 'content-review-workflow',
703+
id: 'contentReviewWorkflow',
704704
description: 'Content creation workflow with iterative quality review using .dowhile() loop',
705705
inputSchema: contentInputSchema,
706706
outputSchema: finalOutputSchema,

src/mastra/workflows/content-studio-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ Script: ${refinedScript}`;
415415
// --- Workflow ---
416416

417417
export const contentStudioWorkflow = createWorkflow({
418-
id: 'content-studio-workflow',
418+
id: 'contentStudioWorkflow',
419419
inputSchema: z.object({
420420
topic: z.string(),
421421
}),

0 commit comments

Comments
 (0)