@contractspec/example.agent-console 3.7.5 → 3.7.7
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.
- package/.turbo/turbo-build.log +18 -18
- package/AGENTS.md +50 -31
- package/CHANGELOG.md +12 -0
- package/README.md +69 -77
- package/dist/agent/agent.event.js +1 -1
- package/dist/agent/agent.operation.js +1 -1
- package/dist/agent/index.d.ts +5 -5
- package/dist/agent/index.js +1 -1
- package/dist/browser/agent/agent.event.js +1 -1
- package/dist/browser/agent/agent.operation.js +1 -1
- package/dist/browser/agent/index.js +1 -1
- package/dist/browser/index.js +2145 -2145
- package/dist/browser/presentations/index.js +4 -4
- package/dist/browser/run/index.js +536 -536
- package/dist/browser/run/run.event.js +2 -2
- package/dist/browser/run/run.presentation.js +2 -2
- package/dist/browser/tool/index.js +260 -260
- package/dist/browser/tool/tool.event.js +1 -1
- package/dist/browser/tool/tool.presentation.js +2 -2
- package/dist/browser/ui/AgentDashboard.js +956 -956
- package/dist/browser/ui/AgentRunList.js +16 -16
- package/dist/browser/ui/AgentToolRegistry.js +9 -9
- package/dist/browser/ui/hooks/index.js +153 -153
- package/dist/browser/ui/hooks/useAgentList.js +1 -1
- package/dist/browser/ui/hooks/useAgentMutations.js +1 -1
- package/dist/browser/ui/hooks/useRunList.js +1 -1
- package/dist/browser/ui/hooks/useToolList.js +1 -1
- package/dist/browser/ui/index.js +1222 -1222
- package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
- package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
- package/dist/browser/ui/modals/index.js +297 -297
- package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/browser/ui/renderers/index.js +157 -157
- package/dist/browser/ui/views/AgentListView.js +7 -7
- package/dist/browser/ui/views/RunListView.js +16 -16
- package/dist/browser/ui/views/ToolRegistryView.js +9 -9
- package/dist/browser/ui/views/index.js +97 -97
- package/dist/handlers/index.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2145 -2145
- package/dist/node/agent/agent.event.js +1 -1
- package/dist/node/agent/agent.operation.js +1 -1
- package/dist/node/agent/index.js +1 -1
- package/dist/node/index.js +2145 -2145
- package/dist/node/presentations/index.js +4 -4
- package/dist/node/run/index.js +536 -536
- package/dist/node/run/run.event.js +2 -2
- package/dist/node/run/run.presentation.js +2 -2
- package/dist/node/tool/index.js +260 -260
- package/dist/node/tool/tool.event.js +1 -1
- package/dist/node/tool/tool.presentation.js +2 -2
- package/dist/node/ui/AgentDashboard.js +956 -956
- package/dist/node/ui/AgentRunList.js +16 -16
- package/dist/node/ui/AgentToolRegistry.js +9 -9
- package/dist/node/ui/hooks/index.js +153 -153
- package/dist/node/ui/hooks/useAgentList.js +1 -1
- package/dist/node/ui/hooks/useAgentMutations.js +1 -1
- package/dist/node/ui/hooks/useRunList.js +1 -1
- package/dist/node/ui/hooks/useToolList.js +1 -1
- package/dist/node/ui/index.js +1222 -1222
- package/dist/node/ui/modals/AgentActionsModal.js +13 -13
- package/dist/node/ui/modals/CreateAgentModal.js +15 -15
- package/dist/node/ui/modals/index.js +297 -297
- package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/node/ui/renderers/index.js +157 -157
- package/dist/node/ui/views/AgentListView.js +7 -7
- package/dist/node/ui/views/RunListView.js +16 -16
- package/dist/node/ui/views/ToolRegistryView.js +9 -9
- package/dist/node/ui/views/index.js +97 -97
- package/dist/presentations/index.d.ts +3 -5
- package/dist/presentations/index.js +4 -4
- package/dist/run/index.d.ts +7 -7
- package/dist/run/index.js +536 -536
- package/dist/run/run.event.js +2 -2
- package/dist/run/run.handler.d.ts +3 -0
- package/dist/run/run.presentation.js +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/tool/index.d.ts +7 -7
- package/dist/tool/index.js +260 -260
- package/dist/tool/tool.event.js +1 -1
- package/dist/tool/tool.handler.d.ts +1 -1
- package/dist/tool/tool.presentation.js +2 -2
- package/dist/ui/AgentDashboard.js +956 -956
- package/dist/ui/AgentRunList.js +16 -16
- package/dist/ui/AgentToolRegistry.js +9 -9
- package/dist/ui/hooks/index.d.ts +4 -4
- package/dist/ui/hooks/index.js +153 -153
- package/dist/ui/hooks/useAgentList.d.ts +5 -0
- package/dist/ui/hooks/useAgentList.js +1 -1
- package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
- package/dist/ui/hooks/useAgentMutations.js +1 -1
- package/dist/ui/hooks/useRunList.d.ts +5 -0
- package/dist/ui/hooks/useRunList.js +1 -1
- package/dist/ui/hooks/useToolList.d.ts +5 -0
- package/dist/ui/hooks/useToolList.js +1 -1
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +1222 -1222
- package/dist/ui/modals/AgentActionsModal.js +13 -13
- package/dist/ui/modals/CreateAgentModal.js +15 -15
- package/dist/ui/modals/index.d.ts +1 -1
- package/dist/ui/modals/index.js +297 -297
- package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
- package/dist/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.js +157 -157
- package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
- package/dist/ui/renderers/tool-registry.markdown.d.ts +5 -0
- package/dist/ui/views/AgentListView.js +7 -7
- package/dist/ui/views/RunListView.js +16 -16
- package/dist/ui/views/ToolRegistryView.js +9 -9
- package/dist/ui/views/index.js +97 -97
- package/package.json +10 -10
- package/src/agent/agent.entity.ts +111 -111
- package/src/agent/agent.enum.ts +12 -12
- package/src/agent/agent.event.ts +91 -91
- package/src/agent/agent.handler.ts +123 -123
- package/src/agent/agent.operation.ts +400 -400
- package/src/agent/agent.presentation.ts +62 -62
- package/src/agent/agent.schema.ts +175 -175
- package/src/agent/agent.test-spec.ts +48 -48
- package/src/agent/index.ts +46 -51
- package/src/agent.capability.ts +11 -11
- package/src/agent.feature.ts +131 -131
- package/src/docs/agent-console.docblock.ts +42 -42
- package/src/example.ts +35 -35
- package/src/handlers/agent.handlers.ts +522 -521
- package/src/handlers/index.ts +12 -12
- package/src/index.ts +8 -9
- package/src/presentations/index.ts +11 -13
- package/src/run/index.ts +49 -54
- package/src/run/run.entity.ts +137 -137
- package/src/run/run.enum.ts +18 -18
- package/src/run/run.event.ts +174 -174
- package/src/run/run.handler.ts +92 -91
- package/src/run/run.operation.ts +474 -474
- package/src/run/run.presentation.ts +42 -42
- package/src/run/run.schema.ts +126 -126
- package/src/run/run.test-spec.ts +48 -48
- package/src/seeders/index.ts +21 -21
- package/src/shared/index.ts +1 -1
- package/src/shared/mock-agents.ts +76 -76
- package/src/shared/mock-runs.ts +102 -102
- package/src/shared/mock-tools.ts +140 -140
- package/src/shared/overlay-types.ts +23 -23
- package/src/tool/index.ts +39 -44
- package/src/tool/tool.entity.ts +73 -73
- package/src/tool/tool.enum.ts +13 -13
- package/src/tool/tool.event.ts +80 -80
- package/src/tool/tool.handler.ts +102 -102
- package/src/tool/tool.operation.ts +328 -328
- package/src/tool/tool.presentation.ts +43 -43
- package/src/tool/tool.schema.ts +106 -106
- package/src/tool/tool.test-spec.ts +48 -48
- package/src/ui/AgentDashboard.tsx +348 -348
- package/src/ui/hooks/index.ts +7 -7
- package/src/ui/hooks/useAgentList.ts +57 -56
- package/src/ui/hooks/useAgentMutations.ts +160 -159
- package/src/ui/hooks/useRunList.ts +58 -57
- package/src/ui/hooks/useToolList.ts +102 -101
- package/src/ui/index.ts +6 -9
- package/src/ui/modals/AgentActionsModal.tsx +262 -262
- package/src/ui/modals/CreateAgentModal.tsx +232 -232
- package/src/ui/modals/index.ts +1 -1
- package/src/ui/overlays/demo-overlays.ts +52 -52
- package/src/ui/renderers/agent-list.markdown.ts +61 -60
- package/src/ui/renderers/agent-list.renderer.tsx +14 -14
- package/src/ui/renderers/dashboard.markdown.ts +140 -139
- package/src/ui/renderers/index.ts +3 -4
- package/src/ui/renderers/run-list.markdown.ts +48 -47
- package/src/ui/renderers/tool-registry.markdown.ts +66 -65
- package/src/ui/views/AgentListView.tsx +90 -90
- package/src/ui/views/RunListView.tsx +141 -141
- package/src/ui/views/ToolRegistryView.tsx +113 -113
- package/tsconfig.json +7 -8
- package/tsdown.config.js +7 -3
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses handlers from the agent-console example package.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
6
|
+
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
type AgentSummary,
|
|
9
|
+
mockListAgentsHandler,
|
|
11
10
|
} from '@contractspec/example.agent-console/handlers';
|
|
11
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
12
|
+
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
12
13
|
|
|
13
14
|
type Agent = AgentSummary;
|
|
14
15
|
|
|
@@ -17,66 +18,66 @@ type Agent = AgentSummary;
|
|
|
17
18
|
* Only handles AgentListView component
|
|
18
19
|
*/
|
|
19
20
|
export const agentListMarkdownRenderer: PresentationRenderer<{
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
mimeType: string;
|
|
22
|
+
body: string;
|
|
22
23
|
}> = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
target: 'markdown',
|
|
25
|
+
render: async (desc: PresentationSpec) => {
|
|
26
|
+
// Only handle AgentListView
|
|
27
|
+
if (
|
|
28
|
+
desc.source.type !== 'component' ||
|
|
29
|
+
desc.source.componentKey !== 'AgentListView'
|
|
30
|
+
) {
|
|
31
|
+
throw new Error('agentListMarkdownRenderer: not AgentListView');
|
|
32
|
+
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// Fetch data using mock handler
|
|
35
|
+
const data = await mockListAgentsHandler({
|
|
36
|
+
organizationId: 'demo-org',
|
|
37
|
+
limit: 50,
|
|
38
|
+
offset: 0,
|
|
39
|
+
});
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
// Generate markdown
|
|
42
|
+
const lines: string[] = [
|
|
43
|
+
`# ${desc.meta.description ?? 'Agent List'}`,
|
|
44
|
+
'',
|
|
45
|
+
`> ${desc.meta.key} v${desc.meta.version}`,
|
|
46
|
+
'',
|
|
47
|
+
`**Total Agents:** ${data.total}`,
|
|
48
|
+
'',
|
|
49
|
+
'## Agents',
|
|
50
|
+
'',
|
|
51
|
+
];
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
// Group by status
|
|
54
|
+
const byStatus: Record<string, Agent[]> = {};
|
|
55
|
+
for (const agent of data.items) {
|
|
56
|
+
const status = agent.status;
|
|
57
|
+
if (byStatus[status]) {
|
|
58
|
+
byStatus[status].push(agent);
|
|
59
|
+
} else {
|
|
60
|
+
byStatus[status] = [agent];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
for (const [status, agents] of Object.entries(byStatus)) {
|
|
65
|
+
lines.push(`### ${status} (${agents.length})`);
|
|
66
|
+
lines.push('');
|
|
67
|
+
for (const agent of agents) {
|
|
68
|
+
lines.push(
|
|
69
|
+
`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`
|
|
70
|
+
);
|
|
71
|
+
if (agent.description) {
|
|
72
|
+
lines.push(` > ${agent.description}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
lines.push('');
|
|
76
|
+
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
return {
|
|
79
|
+
mimeType: 'text/markdown',
|
|
80
|
+
body: lines.join('\n'),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
82
83
|
};
|
|
@@ -9,17 +9,17 @@ import { AgentListView } from '../views/AgentListView';
|
|
|
9
9
|
* React renderer for agent-console.agent.list presentation
|
|
10
10
|
*/
|
|
11
11
|
export const agentListReactRenderer: PresentationRenderer<React.ReactElement> =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
{
|
|
13
|
+
target: 'react',
|
|
14
|
+
render: async (desc: PresentationSpec) => {
|
|
15
|
+
if (desc.source.type !== 'component') {
|
|
16
|
+
throw new Error('AgentListRenderer: expected component source');
|
|
17
|
+
}
|
|
18
|
+
if (desc.source.componentKey !== 'AgentListView') {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`AgentListRenderer: unknown component ${desc.source.componentKey}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return <AgentListView />;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides a comprehensive overview of agents, runs, and tools.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
6
|
+
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
mockListAgentsHandler,
|
|
9
|
+
mockListRunsHandler,
|
|
10
|
+
mockListToolsHandler,
|
|
12
11
|
} from '@contractspec/example.agent-console/handlers';
|
|
12
|
+
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
13
|
+
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
13
14
|
|
|
14
15
|
function formatDuration(ms: number): string {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (ms < 1000) return `${ms}ms`;
|
|
17
|
+
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
18
|
+
return `${(ms / 60000).toFixed(1)}m`;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -22,146 +23,146 @@ function formatDuration(ms: number): string {
|
|
|
22
23
|
* Only handles AgentConsoleDashboard component
|
|
23
24
|
*/
|
|
24
25
|
export const agentDashboardMarkdownRenderer: PresentationRenderer<{
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
mimeType: string;
|
|
27
|
+
body: string;
|
|
27
28
|
}> = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
target: 'markdown',
|
|
30
|
+
render: async (desc: PresentationSpec) => {
|
|
31
|
+
// Only handle AgentConsoleDashboard
|
|
32
|
+
if (
|
|
33
|
+
desc.source.type !== 'component' ||
|
|
34
|
+
desc.source.componentKey !== 'AgentConsoleDashboard'
|
|
35
|
+
) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
'agentDashboardMarkdownRenderer: not AgentConsoleDashboard'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
// Fetch all data in parallel
|
|
42
|
+
const [agentsData, runsData, toolsData] = await Promise.all([
|
|
43
|
+
mockListAgentsHandler({
|
|
44
|
+
organizationId: 'demo-org',
|
|
45
|
+
limit: 100,
|
|
46
|
+
}),
|
|
47
|
+
mockListRunsHandler({
|
|
48
|
+
limit: 100,
|
|
49
|
+
}),
|
|
50
|
+
mockListToolsHandler({
|
|
51
|
+
organizationId: 'demo-org',
|
|
52
|
+
limit: 100,
|
|
53
|
+
}),
|
|
54
|
+
]);
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
56
|
+
// Calculate stats
|
|
57
|
+
const activeAgents = agentsData.items.filter(
|
|
58
|
+
(a) => a.status === 'ACTIVE'
|
|
59
|
+
).length;
|
|
60
|
+
const completedRuns = runsData.items.filter(
|
|
61
|
+
(r) => r.status === 'COMPLETED'
|
|
62
|
+
).length;
|
|
63
|
+
const failedRuns = runsData.items.filter(
|
|
64
|
+
(r) => r.status === 'FAILED'
|
|
65
|
+
).length;
|
|
66
|
+
const totalTokens = runsData.items.reduce(
|
|
67
|
+
(sum, r) => sum + (r.totalTokens ?? 0),
|
|
68
|
+
0
|
|
69
|
+
);
|
|
70
|
+
const totalCost = runsData.items.reduce(
|
|
71
|
+
(sum, r) => sum + (r.estimatedCostUsd ?? 0),
|
|
72
|
+
0
|
|
73
|
+
);
|
|
74
|
+
const activeTools = toolsData.items.filter(
|
|
75
|
+
(t) => t.status === 'ACTIVE'
|
|
76
|
+
).length;
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
// Build dashboard markdown
|
|
79
|
+
const lines: string[] = [
|
|
80
|
+
'# Agent Console Dashboard',
|
|
81
|
+
'',
|
|
82
|
+
'> AI agent operations overview',
|
|
83
|
+
'',
|
|
84
|
+
'## Summary',
|
|
85
|
+
'',
|
|
86
|
+
'| Metric | Value |',
|
|
87
|
+
'|--------|-------|',
|
|
88
|
+
`| Total Agents | ${agentsData.total} |`,
|
|
89
|
+
`| Active Agents | ${activeAgents} |`,
|
|
90
|
+
`| Total Runs | ${runsData.total} |`,
|
|
91
|
+
`| Completed Runs | ${completedRuns} |`,
|
|
92
|
+
`| Failed Runs | ${failedRuns} |`,
|
|
93
|
+
`| Total Tokens | ${totalTokens.toLocaleString()} |`,
|
|
94
|
+
`| Total Cost | $${totalCost.toFixed(4)} |`,
|
|
95
|
+
`| Total Tools | ${toolsData.total} |`,
|
|
96
|
+
`| Active Tools | ${activeTools} |`,
|
|
97
|
+
'',
|
|
98
|
+
'## Agents',
|
|
99
|
+
'',
|
|
100
|
+
];
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
// Agent list
|
|
103
|
+
if (agentsData.items.length === 0) {
|
|
104
|
+
lines.push('_No agents configured._');
|
|
105
|
+
} else {
|
|
106
|
+
lines.push('| Agent | Model | Status | Description |');
|
|
107
|
+
lines.push('|-------|-------|--------|-------------|');
|
|
108
|
+
for (const agent of agentsData.items.slice(0, 5)) {
|
|
109
|
+
lines.push(
|
|
110
|
+
`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? '-'} |`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (agentsData.items.length > 5) {
|
|
114
|
+
lines.push(`| ... | ... | ... | _${agentsData.total - 5} more_ |`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
lines.push('');
|
|
119
|
+
lines.push('## Recent Runs');
|
|
120
|
+
lines.push('');
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
122
|
+
// Recent runs
|
|
123
|
+
if (runsData.items.length === 0) {
|
|
124
|
+
lines.push('_No runs yet._');
|
|
125
|
+
} else {
|
|
126
|
+
lines.push('| Run ID | Agent | Status | Duration | Tokens | Cost |');
|
|
127
|
+
lines.push('|--------|-------|--------|----------|--------|------|');
|
|
128
|
+
for (const run of runsData.items.slice(0, 5)) {
|
|
129
|
+
lines.push(
|
|
130
|
+
`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (runsData.items.length > 5) {
|
|
134
|
+
lines.push(
|
|
135
|
+
`| ... | ... | ... | ... | ... | _${runsData.total - 5} more_ |`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
lines.push('');
|
|
141
|
+
lines.push('## Tools');
|
|
142
|
+
lines.push('');
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
// Tool categories
|
|
145
|
+
const toolsByCategory: Record<string, typeof toolsData.items> = {};
|
|
146
|
+
for (const tool of toolsData.items) {
|
|
147
|
+
const cat = tool.category;
|
|
148
|
+
if (!toolsByCategory[cat]) toolsByCategory[cat] = [];
|
|
149
|
+
toolsByCategory[cat].push(tool);
|
|
150
|
+
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
if (Object.keys(toolsByCategory).length === 0) {
|
|
153
|
+
lines.push('_No tools registered._');
|
|
154
|
+
} else {
|
|
155
|
+
lines.push('| Category | Tools | Active |');
|
|
156
|
+
lines.push('|----------|-------|--------|');
|
|
157
|
+
for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
|
|
158
|
+
const active = tools.filter((t) => t.status === 'ACTIVE').length;
|
|
159
|
+
lines.push(`| ${category} | ${tools.length} | ${active} |`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
return {
|
|
164
|
+
mimeType: 'text/markdown',
|
|
165
|
+
body: lines.join('\n'),
|
|
166
|
+
};
|
|
167
|
+
},
|
|
167
168
|
};
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Renderers for agent-console presentations
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
// React renderers
|
|
6
|
-
export { agentListReactRenderer } from './agent-list.renderer';
|
|
7
|
-
|
|
8
5
|
// Markdown renderers
|
|
9
6
|
export { agentListMarkdownRenderer } from './agent-list.markdown';
|
|
7
|
+
// React renderers
|
|
8
|
+
export { agentListReactRenderer } from './agent-list.renderer';
|
|
9
|
+
export { agentDashboardMarkdownRenderer } from './dashboard.markdown';
|
|
10
10
|
export { runListMarkdownRenderer } from './run-list.markdown';
|
|
11
11
|
export { toolRegistryMarkdownRenderer } from './tool-registry.markdown';
|
|
12
|
-
export { agentDashboardMarkdownRenderer } from './dashboard.markdown';
|
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses dynamic import for handlers to ensure correct build order.
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
import { mockListRunsHandler } from '@contractspec/example.agent-console/handlers';
|
|
6
8
|
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
7
9
|
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
8
10
|
import type { Run } from '../hooks/useRunList';
|
|
9
|
-
import { mockListRunsHandler } from '@contractspec/example.agent-console/handlers';
|
|
10
11
|
|
|
11
12
|
interface RunListOutput {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
items: Run[];
|
|
14
|
+
total: number;
|
|
15
|
+
hasMore: boolean;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function formatDuration(ms: number): string {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (ms < 1000) return `${ms}ms`;
|
|
20
|
+
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
21
|
+
return `${(ms / 60000).toFixed(1)}m`;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -25,49 +26,49 @@ function formatDuration(ms: number): string {
|
|
|
25
26
|
* Only handles RunListView component
|
|
26
27
|
*/
|
|
27
28
|
export const runListMarkdownRenderer: PresentationRenderer<{
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
mimeType: string;
|
|
30
|
+
body: string;
|
|
30
31
|
}> = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
target: 'markdown',
|
|
33
|
+
render: async (desc: PresentationSpec) => {
|
|
34
|
+
// Only handle RunListView
|
|
35
|
+
if (
|
|
36
|
+
desc.source.type !== 'component' ||
|
|
37
|
+
desc.source.componentKey !== 'RunListView'
|
|
38
|
+
) {
|
|
39
|
+
throw new Error('runListMarkdownRenderer: not RunListView');
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// Fetch data using mock handler
|
|
43
|
+
const data = (await mockListRunsHandler({
|
|
44
|
+
organizationId: 'demo-org',
|
|
45
|
+
limit: 20,
|
|
46
|
+
offset: 0,
|
|
47
|
+
})) as RunListOutput;
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
// Generate markdown
|
|
50
|
+
const lines: string[] = [
|
|
51
|
+
`# ${desc.meta.description ?? 'Agent Runs'}`,
|
|
52
|
+
'',
|
|
53
|
+
`> ${desc.meta.key} v${desc.meta.version}`,
|
|
54
|
+
'',
|
|
55
|
+
`**Total Runs:** ${data.total}`,
|
|
56
|
+
'',
|
|
57
|
+
'## Recent Runs',
|
|
58
|
+
'',
|
|
59
|
+
'| ID | Agent | Status | Duration | Tokens | Cost |',
|
|
60
|
+
'| --- | --- | --- | --- | --- | --- |',
|
|
61
|
+
];
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
for (const run of data.items.slice(0, 10)) {
|
|
64
|
+
lines.push(
|
|
65
|
+
`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? '-'} |`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
return {
|
|
70
|
+
mimeType: 'text/markdown',
|
|
71
|
+
body: lines.join('\n'),
|
|
72
|
+
};
|
|
73
|
+
},
|
|
73
74
|
};
|