@contractspec/example.agent-console 3.8.16 → 3.8.18

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,5 +1,11 @@
1
1
  'use client';
2
2
 
3
+ import {
4
+ Tabs,
5
+ TabsContent,
6
+ TabsList,
7
+ TabsTrigger,
8
+ } from '@contractspec/lib.design-system';
3
9
  import { createVisualizationModel } from '@contractspec/lib.presentation-runtime-core';
4
10
  import { Button } from '@contractspec/lib.ui-kit-web/ui/button';
5
11
  import {
@@ -12,7 +18,7 @@ import {
12
18
  import { HStack, VStack } from '@contractspec/lib.ui-kit-web/ui/stack';
13
19
  import { Text } from '@contractspec/lib.ui-kit-web/ui/text';
14
20
  import { Visualization } from '@contractspec/lib.ui-kit-web/ui/visualization';
15
- import { useMemo, useState } from 'react';
21
+ import { useMemo } from 'react';
16
22
  import { MOCK_AGENTS } from '../shared/mock-agents';
17
23
  import { MOCK_RUNS } from '../shared/mock-runs';
18
24
  import { MOCK_TOOLS } from '../shared/mock-tools';
@@ -21,7 +27,6 @@ import {
21
27
  AGENT_CONSOLE_PREVIEW_TABS,
22
28
  type AgentConsolePreviewAgent,
23
29
  type AgentConsolePreviewRun,
24
- type AgentConsolePreviewTab,
25
30
  type AgentConsolePreviewTool,
26
31
  createAgentConsolePreviewMetrics,
27
32
  getAgentConsolePressProps,
@@ -47,7 +52,6 @@ export function AgentConsolePreview({
47
52
  showHeaderAction = true,
48
53
  tools = MOCK_TOOLS,
49
54
  }: AgentConsolePreviewProps) {
50
- const [activeTab, setActiveTab] = useState<AgentConsolePreviewTab>('runs');
51
55
  const metrics = useMemo(() => createAgentConsolePreviewMetrics(runs), [runs]);
52
56
  const visualizationItems = useMemo(
53
57
  () => createAgentVisualizationItems(runs),
@@ -93,32 +97,34 @@ export function AgentConsolePreview({
93
97
  </VStack>
94
98
  </VStack>
95
99
 
96
- <HStack className="rounded-lg bg-muted p-1" gap="xs">
97
- {AGENT_CONSOLE_PREVIEW_TABS.map((tab) => (
98
- <Button
99
- key={tab.id}
100
- size="sm"
101
- variant={activeTab === tab.id ? 'secondary' : 'ghost'}
102
- className="flex-1"
103
- {...getAgentConsolePressProps(() => setActiveTab(tab.id))}
104
- >
105
- <Text>
106
- {tab.icon} {tab.label}
107
- </Text>
108
- </Button>
109
- ))}
110
- </HStack>
100
+ <Tabs defaultValue="runs" className="w-full gap-4">
101
+ <TabsList className="h-auto w-full flex-wrap">
102
+ {AGENT_CONSOLE_PREVIEW_TABS.map((tab) => (
103
+ <TabsTrigger
104
+ key={tab.id}
105
+ value={tab.id}
106
+ className="min-h-8 min-w-24 flex-1"
107
+ >
108
+ <Text>
109
+ {tab.icon} {tab.label}
110
+ </Text>
111
+ </TabsTrigger>
112
+ ))}
113
+ </TabsList>
111
114
 
112
- {activeTab === 'runs' ? (
113
- <AgentConsoleRunHistoryTable runs={runs} />
114
- ) : null}
115
- {activeTab === 'agents' ? (
116
- <AgentConsoleAgentCards agents={agents} />
117
- ) : null}
118
- {activeTab === 'tools' ? <AgentConsoleToolCards tools={tools} /> : null}
119
- {activeTab === 'metrics' ? (
120
- <AgentConsoleMetricsPanel metrics={metrics} />
121
- ) : null}
115
+ <TabsContent value="runs">
116
+ <AgentConsoleRunHistoryTable runs={runs} />
117
+ </TabsContent>
118
+ <TabsContent value="agents">
119
+ <AgentConsoleAgentCards agents={agents} />
120
+ </TabsContent>
121
+ <TabsContent value="tools">
122
+ <AgentConsoleToolCards tools={tools} />
123
+ </TabsContent>
124
+ <TabsContent value="metrics">
125
+ <AgentConsoleMetricsPanel metrics={metrics} />
126
+ </TabsContent>
127
+ </Tabs>
122
128
  </VStack>
123
129
  );
124
130
  }
@@ -0,0 +1,75 @@
1
+ 'use client';
2
+
3
+ import { Badge } from '@contractspec/lib.ui-kit-web/ui/badge';
4
+ import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
5
+ import { Box, HStack, VStack } from '@contractspec/lib.ui-kit-web/ui/stack';
6
+ import { Text } from '@contractspec/lib.ui-kit-web/ui/text';
7
+ import type { ReactNode } from 'react';
8
+
9
+ interface AgentConsoleResponsiveCardsProps<TItem> {
10
+ getKey: (item: TItem) => string;
11
+ items: readonly TItem[];
12
+ renderItem: (item: TItem) => ReactNode;
13
+ }
14
+
15
+ export function AgentConsoleResponsiveCards<TItem>({
16
+ getKey,
17
+ items,
18
+ renderItem,
19
+ }: AgentConsoleResponsiveCardsProps<TItem>) {
20
+ return (
21
+ <HStack gap="none" align="stretch" className="flex-wrap">
22
+ {items.map((item) => (
23
+ <Box
24
+ key={getKey(item)}
25
+ gap="none"
26
+ className="flex w-full min-w-0 p-1.5 sm:w-1/2 lg:w-1/4"
27
+ >
28
+ {renderItem(item)}
29
+ </Box>
30
+ ))}
31
+ </HStack>
32
+ );
33
+ }
34
+
35
+ export function AgentConsoleEntityCard({
36
+ description,
37
+ name,
38
+ status,
39
+ subtitle,
40
+ }: {
41
+ description: string;
42
+ name: string;
43
+ status: string;
44
+ subtitle: string;
45
+ }) {
46
+ return (
47
+ <Card className="h-full w-full">
48
+ <CardContent className="flex flex-col gap-2 pt-6">
49
+ <HStack justify="between" align="start">
50
+ <VStack gap="xs" className="flex-1">
51
+ <Text className="font-semibold text-lg">{name}</Text>
52
+ <Text className="text-muted-foreground text-sm">{subtitle}</Text>
53
+ </VStack>
54
+ <AgentConsoleStatusBadge status={status} />
55
+ </HStack>
56
+ <Text className="text-muted-foreground text-sm">{description}</Text>
57
+ </CardContent>
58
+ </Card>
59
+ );
60
+ }
61
+
62
+ export function AgentConsoleStatusBadge({ status }: { status: string }) {
63
+ const variant =
64
+ status === 'FAILED' || status === 'CANCELLED'
65
+ ? 'destructive'
66
+ : status === 'ACTIVE' || status === 'COMPLETED'
67
+ ? 'secondary'
68
+ : 'outline';
69
+
70
+ return (
71
+ <Badge variant={variant}>
72
+ <Text className="font-semibold text-xs">{status}</Text>
73
+ </Badge>
74
+ );
75
+ }
@@ -1,13 +1,12 @@
1
1
  'use client';
2
2
 
3
- import { Badge } from '@contractspec/lib.ui-kit-web/ui/badge';
4
3
  import {
5
4
  Card,
6
5
  CardContent,
7
6
  CardHeader,
8
7
  CardTitle,
9
8
  } from '@contractspec/lib.ui-kit-web/ui/card';
10
- import { HStack, VStack } from '@contractspec/lib.ui-kit-web/ui/stack';
9
+ import { VStack } from '@contractspec/lib.ui-kit-web/ui/stack';
11
10
  import { Text } from '@contractspec/lib.ui-kit-web/ui/text';
12
11
  import type {
13
12
  AgentConsolePreviewAgent,
@@ -15,6 +14,12 @@ import type {
15
14
  createAgentConsolePreviewMetrics,
16
15
  } from './AgentConsolePreview.data';
17
16
  import { formatAgentConsoleTokens } from './AgentConsolePreview.data';
17
+ import {
18
+ AgentConsoleEntityCard,
19
+ AgentConsoleResponsiveCards,
20
+ } from './AgentConsolePreviewCards';
21
+
22
+ export { AgentConsoleStatusBadge } from './AgentConsolePreviewCards';
18
23
 
19
24
  type PreviewMetrics = ReturnType<typeof createAgentConsolePreviewMetrics>;
20
25
 
@@ -47,17 +52,19 @@ export function AgentConsoleMetricCards({
47
52
  ];
48
53
 
49
54
  return (
50
- <HStack gap="md" className="flex-wrap">
51
- {stats.map((stat) => (
52
- <Card key={stat.label} className="min-w-52 flex-1">
55
+ <AgentConsoleResponsiveCards
56
+ items={stats}
57
+ getKey={(stat) => stat.label}
58
+ renderItem={(stat) => (
59
+ <Card className="h-full w-full">
53
60
  <CardContent className="flex flex-col gap-1 pt-6">
54
61
  <Text className="text-muted-foreground text-sm">{stat.label}</Text>
55
62
  <Text className="font-bold text-2xl">{stat.value}</Text>
56
63
  <Text className="text-muted-foreground text-sm">{stat.hint}</Text>
57
64
  </CardContent>
58
65
  </Card>
59
- ))}
60
- </HStack>
66
+ )}
67
+ />
61
68
  );
62
69
  }
63
70
 
@@ -67,26 +74,18 @@ export function AgentConsoleAgentCards({
67
74
  agents: readonly AgentConsolePreviewAgent[];
68
75
  }) {
69
76
  return (
70
- <VStack gap="md">
71
- {agents.map((agent) => (
72
- <Card key={agent.id}>
73
- <CardContent className="flex flex-col gap-2 pt-6">
74
- <HStack justify="between" align="start">
75
- <VStack gap="xs" className="flex-1">
76
- <Text className="font-semibold text-lg">{agent.name}</Text>
77
- <Text className="text-muted-foreground text-sm">
78
- {agent.modelProvider} / {agent.modelName}
79
- </Text>
80
- </VStack>
81
- <AgentConsoleStatusBadge status={agent.status} />
82
- </HStack>
83
- <Text className="text-muted-foreground text-sm">
84
- {agent.description}
85
- </Text>
86
- </CardContent>
87
- </Card>
88
- ))}
89
- </VStack>
77
+ <AgentConsoleResponsiveCards
78
+ items={agents}
79
+ getKey={(agent) => agent.id}
80
+ renderItem={(agent) => (
81
+ <AgentConsoleEntityCard
82
+ description={agent.description}
83
+ name={agent.name}
84
+ status={agent.status}
85
+ subtitle={`${agent.modelProvider} / ${agent.modelName}`}
86
+ />
87
+ )}
88
+ />
90
89
  );
91
90
  }
92
91
 
@@ -96,26 +95,18 @@ export function AgentConsoleToolCards({
96
95
  tools: readonly AgentConsolePreviewTool[];
97
96
  }) {
98
97
  return (
99
- <VStack gap="md">
100
- {tools.map((tool) => (
101
- <Card key={tool.id}>
102
- <CardContent className="flex flex-col gap-2 pt-6">
103
- <HStack justify="between" align="start">
104
- <VStack gap="xs" className="flex-1">
105
- <Text className="font-semibold text-lg">{tool.name}</Text>
106
- <Text className="text-muted-foreground text-sm">
107
- {tool.category} / {tool.implementationType}
108
- </Text>
109
- </VStack>
110
- <AgentConsoleStatusBadge status={tool.status} />
111
- </HStack>
112
- <Text className="text-muted-foreground text-sm">
113
- {tool.description}
114
- </Text>
115
- </CardContent>
116
- </Card>
117
- ))}
118
- </VStack>
98
+ <AgentConsoleResponsiveCards
99
+ items={tools}
100
+ getKey={(tool) => tool.id}
101
+ renderItem={(tool) => (
102
+ <AgentConsoleEntityCard
103
+ description={tool.description}
104
+ name={tool.name}
105
+ status={tool.status}
106
+ subtitle={`${tool.category} / ${tool.implementationType}`}
107
+ />
108
+ )}
109
+ />
119
110
  );
120
111
  }
121
112
 
@@ -129,7 +120,9 @@ export function AgentConsoleMetricsPanel({
129
120
  <Text className="font-semibold text-lg">Usage Analytics</Text>
130
121
  <Card>
131
122
  <CardHeader>
132
- <CardTitle>Run Outcomes</CardTitle>
123
+ <CardTitle>
124
+ <Text>Run Outcomes</Text>
125
+ </CardTitle>
133
126
  </CardHeader>
134
127
  <CardContent className="flex flex-col gap-3">
135
128
  <Text>Completed: {metrics.completedRuns}</Text>
@@ -142,18 +135,3 @@ export function AgentConsoleMetricsPanel({
142
135
  </VStack>
143
136
  );
144
137
  }
145
-
146
- export function AgentConsoleStatusBadge({ status }: { status: string }) {
147
- const variant =
148
- status === 'FAILED' || status === 'CANCELLED'
149
- ? 'destructive'
150
- : status === 'ACTIVE' || status === 'COMPLETED'
151
- ? 'secondary'
152
- : 'outline';
153
-
154
- return (
155
- <Badge variant={variant}>
156
- <Text className="font-semibold text-xs">{status}</Text>
157
- </Badge>
158
- );
159
- }