@contractspec/example.agent-console 3.7.6 → 3.8.2
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 +126 -105
- package/AGENTS.md +52 -31
- package/CHANGELOG.md +29 -0
- package/README.md +112 -83
- package/dist/agent/agent.event.js +1 -1
- package/dist/agent/agent.handler.d.ts +3 -0
- package/dist/agent/agent.handler.js +730 -1
- package/dist/agent/agent.operation.js +1 -1
- package/dist/agent/index.d.ts +5 -5
- package/dist/agent/index.js +74 -73
- package/dist/agent.feature.js +179 -0
- package/dist/browser/agent/agent.event.js +1 -1
- package/dist/browser/agent/agent.handler.js +730 -1
- package/dist/browser/agent/agent.operation.js +1 -1
- package/dist/browser/agent/index.js +74 -73
- package/dist/browser/agent.feature.js +179 -0
- package/dist/browser/docs/agent-console.docblock.js +11 -8
- package/dist/browser/docs/index.js +11 -8
- package/dist/browser/example.js +2 -3
- package/dist/browser/handlers/agent.handlers.js +1883 -2
- package/dist/browser/handlers/index.js +2142 -8
- package/dist/browser/index.js +4075 -3161
- package/dist/browser/presentations/index.js +51 -51
- package/dist/browser/run/index.js +380 -374
- package/dist/browser/run/run.event.js +2 -2
- package/dist/browser/run/run.handler.js +666 -1
- package/dist/browser/run/run.presentation.js +2 -2
- package/dist/browser/shared/index.js +293 -1
- package/dist/browser/shared/mock-runs.js +5 -0
- package/dist/browser/tool/index.js +161 -161
- package/dist/browser/tool/tool.event.js +1 -1
- package/dist/browser/tool/tool.handler.js +479 -3
- package/dist/browser/tool/tool.presentation.js +2 -2
- package/dist/browser/ui/AgentDashboard.js +1816 -931
- package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/browser/ui/AgentRunList.js +360 -128
- package/dist/browser/ui/AgentToolRegistry.js +9 -9
- package/dist/browser/ui/hooks/index.js +611 -161
- package/dist/browser/ui/hooks/useAgentList.js +1 -1
- package/dist/browser/ui/hooks/useAgentMutations.js +444 -9
- package/dist/browser/ui/hooks/useRunList.js +26 -11
- package/dist/browser/ui/hooks/useToolList.js +1 -1
- package/dist/browser/ui/index.js +2161 -1258
- 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.markdown.js +14 -5
- package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/browser/ui/renderers/index.js +359 -163
- package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
- package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/browser/ui/views/AgentListView.js +7 -7
- package/dist/browser/ui/views/RunDataTable.js +326 -0
- package/dist/browser/ui/views/RunListView.js +360 -128
- package/dist/browser/ui/views/ToolRegistryView.js +9 -9
- package/dist/browser/ui/views/index.js +478 -246
- package/dist/browser/ui/views/run-data-table.columns.js +271 -0
- package/dist/browser/ui/views/run-list.shared.js +177 -0
- package/dist/browser/visualizations/catalog.js +134 -0
- package/dist/browser/visualizations/index.js +187 -0
- package/dist/browser/visualizations/selectors.js +181 -0
- package/dist/docs/agent-console.docblock.js +11 -8
- package/dist/docs/index.js +11 -8
- package/dist/example.js +2 -3
- package/dist/example.test.d.ts +1 -0
- package/dist/handlers/agent.handlers.d.ts +2 -0
- package/dist/handlers/agent.handlers.js +1883 -2
- package/dist/handlers/index.d.ts +2 -4
- package/dist/handlers/index.js +2142 -8
- package/dist/handlers/mock-handlers.test.d.ts +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4075 -3161
- package/dist/node/agent/agent.event.js +1 -1
- package/dist/node/agent/agent.handler.js +730 -1
- package/dist/node/agent/agent.operation.js +1 -1
- package/dist/node/agent/index.js +74 -73
- package/dist/node/agent.feature.js +179 -0
- package/dist/node/docs/agent-console.docblock.js +11 -8
- package/dist/node/docs/index.js +11 -8
- package/dist/node/example.js +2 -3
- package/dist/node/handlers/agent.handlers.js +1883 -2
- package/dist/node/handlers/index.js +2142 -8
- package/dist/node/index.js +4075 -3161
- package/dist/node/presentations/index.js +51 -51
- package/dist/node/run/index.js +380 -374
- package/dist/node/run/run.event.js +2 -2
- package/dist/node/run/run.handler.js +666 -1
- package/dist/node/run/run.presentation.js +2 -2
- package/dist/node/shared/index.js +293 -1
- package/dist/node/shared/mock-runs.js +5 -0
- package/dist/node/tool/index.js +161 -161
- package/dist/node/tool/tool.event.js +1 -1
- package/dist/node/tool/tool.handler.js +479 -3
- package/dist/node/tool/tool.presentation.js +2 -2
- package/dist/node/ui/AgentDashboard.js +1816 -931
- package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/node/ui/AgentRunList.js +360 -128
- package/dist/node/ui/AgentToolRegistry.js +9 -9
- package/dist/node/ui/hooks/index.js +611 -161
- package/dist/node/ui/hooks/useAgentList.js +1 -1
- package/dist/node/ui/hooks/useAgentMutations.js +444 -9
- package/dist/node/ui/hooks/useRunList.js +26 -11
- package/dist/node/ui/hooks/useToolList.js +1 -1
- package/dist/node/ui/index.js +2161 -1258
- 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.markdown.js +14 -5
- package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/node/ui/renderers/index.js +359 -163
- package/dist/node/ui/renderers/run-list.markdown.js +9 -4
- package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/node/ui/views/AgentListView.js +7 -7
- package/dist/node/ui/views/RunDataTable.js +326 -0
- package/dist/node/ui/views/RunListView.js +360 -128
- package/dist/node/ui/views/ToolRegistryView.js +9 -9
- package/dist/node/ui/views/index.js +478 -246
- package/dist/node/ui/views/run-data-table.columns.js +271 -0
- package/dist/node/ui/views/run-list.shared.js +177 -0
- package/dist/node/visualizations/catalog.js +134 -0
- package/dist/node/visualizations/index.js +187 -0
- package/dist/node/visualizations/selectors.js +181 -0
- package/dist/presentations/index.d.ts +3 -5
- package/dist/presentations/index.js +51 -51
- package/dist/proof/index.d.ts +2 -0
- package/dist/proof/meetup-proof.d.ts +10 -0
- package/dist/proof/meetup-proof.runtime.d.ts +22 -0
- package/dist/proof/meetup-proof.scenario.d.ts +2 -0
- package/dist/proof/meetup-proof.suite.d.ts +1 -0
- package/dist/proof/meetup-proof.test.d.ts +1 -0
- package/dist/run/index.d.ts +7 -7
- package/dist/run/index.js +380 -374
- package/dist/run/run.event.js +2 -2
- package/dist/run/run.handler.d.ts +7 -0
- package/dist/run/run.handler.js +666 -1
- package/dist/run/run.presentation.js +2 -2
- package/dist/shared/demo-dashboard-data.d.ts +16 -0
- package/dist/shared/demo-runtime-seed.d.ts +17 -0
- package/dist/shared/demo-runtime.d.ts +8 -0
- package/dist/shared/demo-runtime.test.d.ts +1 -0
- package/dist/shared/index.d.ts +4 -1
- package/dist/shared/index.js +293 -1
- package/dist/shared/mock-runs.d.ts +4 -0
- package/dist/shared/mock-runs.js +5 -0
- package/dist/tool/index.d.ts +7 -7
- package/dist/tool/index.js +161 -161
- package/dist/tool/tool.event.js +1 -1
- package/dist/tool/tool.handler.d.ts +3 -0
- package/dist/tool/tool.handler.js +479 -3
- package/dist/tool/tool.presentation.js +2 -2
- package/dist/ui/AgentDashboard.js +1816 -931
- package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
- package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
- package/dist/ui/AgentDashboard.visualizations.js +218 -0
- package/dist/ui/AgentRunList.js +360 -128
- package/dist/ui/AgentToolRegistry.js +9 -9
- package/dist/ui/hooks/index.d.ts +4 -4
- package/dist/ui/hooks/index.js +611 -161
- 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 +444 -9
- package/dist/ui/hooks/useRunList.d.ts +13 -2
- package/dist/ui/hooks/useRunList.js +26 -11
- 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 +2161 -1258
- 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.markdown.js +14 -5
- package/dist/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
- package/dist/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.js +359 -163
- package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
- package/dist/ui/renderers/run-list.markdown.js +9 -4
- package/dist/ui/renderers/tool-registry.markdown.d.ts +6 -1
- package/dist/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/ui/views/AgentListView.js +7 -7
- package/dist/ui/views/RunDataTable.d.ts +18 -0
- package/dist/ui/views/RunDataTable.js +327 -0
- package/dist/ui/views/RunListView.js +360 -128
- package/dist/ui/views/ToolRegistryView.js +9 -9
- package/dist/ui/views/index.js +478 -246
- package/dist/ui/views/run-data-table.columns.d.ts +3 -0
- package/dist/ui/views/run-data-table.columns.js +272 -0
- package/dist/ui/views/run-list.shared.d.ts +14 -0
- package/dist/ui/views/run-list.shared.js +178 -0
- package/dist/visualizations/catalog.d.ts +10 -0
- package/dist/visualizations/catalog.js +135 -0
- package/dist/visualizations/index.d.ts +2 -0
- package/dist/visualizations/index.js +188 -0
- package/dist/visualizations/selectors.d.ts +3 -0
- package/dist/visualizations/selectors.js +182 -0
- package/dist/visualizations/selectors.test.d.ts +1 -0
- package/package.json +114 -12
- package/proofs/agent-console-meetup.replay.json +220 -0
- 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 +144 -127
- 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 +134 -131
- package/src/docs/agent-console.docblock.ts +52 -49
- package/src/example.test.ts +75 -0
- package/src/example.ts +34 -35
- package/src/handlers/agent.handlers.ts +576 -522
- package/src/handlers/index.ts +30 -14
- package/src/handlers/mock-handlers.test.ts +77 -0
- package/src/index.ts +10 -9
- package/src/presentations/index.ts +11 -13
- package/src/proof/index.ts +2 -0
- package/src/proof/meetup-proof.runtime.ts +196 -0
- package/src/proof/meetup-proof.scenario.ts +99 -0
- package/src/proof/meetup-proof.suite.ts +29 -0
- package/src/proof/meetup-proof.test.ts +28 -0
- package/src/proof/meetup-proof.ts +130 -0
- 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 +113 -96
- 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/demo-dashboard-data.ts +58 -0
- package/src/shared/demo-runtime-seed.ts +139 -0
- package/src/shared/demo-runtime.test.ts +169 -0
- package/src/shared/demo-runtime.ts +260 -0
- package/src/shared/index.ts +12 -1
- package/src/shared/mock-agents.ts +76 -76
- package/src/shared/mock-runs.ts +107 -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 +124 -107
- 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.sandbox.test.tsx +312 -0
- package/src/ui/AgentDashboard.tsx +351 -348
- package/src/ui/AgentDashboard.visualizations.tsx +35 -0
- package/src/ui/hooks/index.ts +7 -7
- package/src/ui/hooks/useAgentList.ts +57 -56
- package/src/ui/hooks/useAgentMutations.ts +168 -159
- package/src/ui/hooks/useRunList.ts +90 -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 +81 -61
- package/src/ui/renderers/agent-list.renderer.tsx +14 -14
- package/src/ui/renderers/dashboard.markdown.ts +135 -139
- package/src/ui/renderers/index.ts +3 -4
- package/src/ui/renderers/run-list.markdown.ts +56 -47
- package/src/ui/renderers/tool-registry.markdown.ts +79 -66
- package/src/ui/views/AgentListView.tsx +90 -90
- package/src/ui/views/RunDataTable.tsx +74 -0
- package/src/ui/views/RunListView.tsx +84 -158
- package/src/ui/views/ToolRegistryView.tsx +113 -113
- package/src/ui/views/run-data-table.columns.tsx +102 -0
- package/src/ui/views/run-list.shared.tsx +139 -0
- package/src/visualizations/catalog.ts +132 -0
- package/src/visualizations/index.ts +2 -0
- package/src/visualizations/selectors.test.ts +12 -0
- package/src/visualizations/selectors.ts +70 -0
- package/tsconfig.json +7 -8
- package/tsdown.config.js +24 -3
|
@@ -3,80 +3,100 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses handlers from the agent-console example package.
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
9
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
10
|
+
createAgentConsoleDemoHandlers,
|
|
11
|
+
} from '@contractspec/example.agent-console/shared';
|
|
6
12
|
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
7
13
|
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
8
|
-
import {
|
|
9
|
-
type AgentSummary,
|
|
10
|
-
mockListAgentsHandler,
|
|
11
|
-
} from '@contractspec/example.agent-console/handlers';
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
interface AgentListItem {
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
status: string;
|
|
19
|
+
modelProvider: string;
|
|
20
|
+
modelName: string;
|
|
21
|
+
}
|
|
14
22
|
|
|
15
23
|
/**
|
|
16
24
|
* Markdown renderer for agent-console.agent.list presentation
|
|
17
25
|
* Only handles AgentListView component
|
|
18
26
|
*/
|
|
19
27
|
export const agentListMarkdownRenderer: PresentationRenderer<{
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
mimeType: string;
|
|
29
|
+
body: string;
|
|
22
30
|
}> = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
target: 'markdown',
|
|
32
|
+
render: async (desc: PresentationSpec, ctx) => {
|
|
33
|
+
// Only handle AgentListView
|
|
34
|
+
if (
|
|
35
|
+
desc.source.type !== 'component' ||
|
|
36
|
+
desc.source.componentKey !== 'AgentListView'
|
|
37
|
+
) {
|
|
38
|
+
throw new Error('agentListMarkdownRenderer: not AgentListView');
|
|
39
|
+
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
const data: {
|
|
42
|
+
items: AgentListItem[];
|
|
43
|
+
total: number;
|
|
44
|
+
hasMore: boolean;
|
|
45
|
+
} = Array.isArray(ctx?.data)
|
|
46
|
+
? {
|
|
47
|
+
items: ctx.data as AgentListItem[],
|
|
48
|
+
total: ctx.data.length,
|
|
49
|
+
hasMore: false,
|
|
50
|
+
}
|
|
51
|
+
: await createAgentConsoleDemoHandlers({
|
|
52
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
53
|
+
}).listAgents({
|
|
54
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
55
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
56
|
+
limit: 50,
|
|
57
|
+
offset: 0,
|
|
58
|
+
});
|
|
39
59
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
// Generate markdown
|
|
61
|
+
const lines: string[] = [
|
|
62
|
+
`# ${desc.meta.description ?? 'Agent List'}`,
|
|
63
|
+
'',
|
|
64
|
+
`> ${desc.meta.key} v${desc.meta.version}`,
|
|
65
|
+
'',
|
|
66
|
+
`**Total Agents:** ${data.total}`,
|
|
67
|
+
'',
|
|
68
|
+
'## Agents',
|
|
69
|
+
'',
|
|
70
|
+
];
|
|
51
71
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
// Group by status
|
|
73
|
+
const byStatus: Record<string, AgentListItem[]> = {};
|
|
74
|
+
for (const agent of data.items) {
|
|
75
|
+
const status = agent.status;
|
|
76
|
+
if (byStatus[status]) {
|
|
77
|
+
byStatus[status].push(agent);
|
|
78
|
+
} else {
|
|
79
|
+
byStatus[status] = [agent];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
62
82
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
for (const [status, agents] of Object.entries(byStatus)) {
|
|
84
|
+
lines.push(`### ${status} (${agents.length})`);
|
|
85
|
+
lines.push('');
|
|
86
|
+
for (const agent of agents) {
|
|
87
|
+
lines.push(
|
|
88
|
+
`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`
|
|
89
|
+
);
|
|
90
|
+
if (agent.description) {
|
|
91
|
+
lines.push(` > ${agent.description}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
lines.push('');
|
|
95
|
+
}
|
|
76
96
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
return {
|
|
98
|
+
mimeType: 'text/markdown',
|
|
99
|
+
body: lines.join('\n'),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
82
102
|
};
|
|
@@ -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 {
|
|
8
|
+
type AgentConsoleDashboardData,
|
|
9
|
+
getFallbackAgentConsoleDashboardData,
|
|
10
|
+
} from '@contractspec/example.agent-console/shared';
|
|
6
11
|
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
7
12
|
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
8
|
-
import {
|
|
9
|
-
mockListAgentsHandler,
|
|
10
|
-
mockListRunsHandler,
|
|
11
|
-
mockListToolsHandler,
|
|
12
|
-
} from '@contractspec/example.agent-console/handlers';
|
|
13
|
+
import { createAgentVisualizationItems } from '../../visualizations';
|
|
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,141 @@ 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, ctx) => {
|
|
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
|
+
}
|
|
40
|
+
|
|
41
|
+
const data =
|
|
42
|
+
(ctx?.data as AgentConsoleDashboardData | undefined) ??
|
|
43
|
+
(await getFallbackAgentConsoleDashboardData());
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
// Calculate stats
|
|
46
|
+
const activeAgents = data.agents.filter(
|
|
47
|
+
(a) => a.status === 'ACTIVE'
|
|
48
|
+
).length;
|
|
49
|
+
const completedRuns = data.runs.filter(
|
|
50
|
+
(r) => r.status === 'COMPLETED'
|
|
51
|
+
).length;
|
|
52
|
+
const failedRuns = data.runs.filter((r) => r.status === 'FAILED').length;
|
|
53
|
+
const totalTokens = data.runs.reduce(
|
|
54
|
+
(sum, r) => sum + (r.totalTokens ?? 0),
|
|
55
|
+
0
|
|
56
|
+
);
|
|
57
|
+
const totalCost = data.runs.reduce(
|
|
58
|
+
(sum, r) => sum + (r.estimatedCostUsd ?? 0),
|
|
59
|
+
0
|
|
60
|
+
);
|
|
61
|
+
const activeTools = data.tools.filter((t) => t.status === 'ACTIVE').length;
|
|
62
|
+
const visualizationItems = createAgentVisualizationItems(data.runs);
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
// Build dashboard markdown
|
|
65
|
+
const lines: string[] = [
|
|
66
|
+
'# Agent Console Dashboard',
|
|
67
|
+
'',
|
|
68
|
+
'> AI agent operations overview',
|
|
69
|
+
'',
|
|
70
|
+
'## Summary',
|
|
71
|
+
'',
|
|
72
|
+
'| Metric | Value |',
|
|
73
|
+
'|--------|-------|',
|
|
74
|
+
`| Total Agents | ${data.summary.totalAgents} |`,
|
|
75
|
+
`| Active Agents | ${activeAgents} |`,
|
|
76
|
+
`| Total Runs | ${data.summary.totalRuns} |`,
|
|
77
|
+
`| Completed Runs | ${completedRuns} |`,
|
|
78
|
+
`| Failed Runs | ${failedRuns} |`,
|
|
79
|
+
`| Total Tokens | ${totalTokens.toLocaleString()} |`,
|
|
80
|
+
`| Total Cost | $${totalCost.toFixed(4)} |`,
|
|
81
|
+
`| Total Tools | ${data.summary.totalTools} |`,
|
|
82
|
+
`| Active Tools | ${activeTools} |`,
|
|
83
|
+
'',
|
|
84
|
+
'## Agents',
|
|
85
|
+
'',
|
|
86
|
+
];
|
|
76
87
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
`| Total Tools | ${toolsData.total} |`,
|
|
95
|
-
`| Active Tools | ${activeTools} |`,
|
|
96
|
-
'',
|
|
97
|
-
'## Agents',
|
|
98
|
-
'',
|
|
99
|
-
];
|
|
88
|
+
// Agent list
|
|
89
|
+
if (data.agents.length === 0) {
|
|
90
|
+
lines.push('_No agents configured._');
|
|
91
|
+
} else {
|
|
92
|
+
lines.push('| Agent | Model | Status | Description |');
|
|
93
|
+
lines.push('|-------|-------|--------|-------------|');
|
|
94
|
+
for (const agent of data.agents.slice(0, 5)) {
|
|
95
|
+
lines.push(
|
|
96
|
+
`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? '-'} |`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (data.agents.length > 5) {
|
|
100
|
+
lines.push(
|
|
101
|
+
`| ... | ... | ... | _${data.summary.totalAgents - 5} more_ |`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} else {
|
|
105
|
-
lines.push('| Agent | Model | Status | Description |');
|
|
106
|
-
lines.push('|-------|-------|--------|-------------|');
|
|
107
|
-
for (const agent of agentsData.items.slice(0, 5)) {
|
|
108
|
-
lines.push(
|
|
109
|
-
`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? '-'} |`
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (agentsData.items.length > 5) {
|
|
113
|
-
lines.push(`| ... | ... | ... | _${agentsData.total - 5} more_ |`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
106
|
+
lines.push('');
|
|
107
|
+
lines.push('## Recent Runs');
|
|
108
|
+
lines.push('');
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
// Recent runs
|
|
111
|
+
if (data.runs.length === 0) {
|
|
112
|
+
lines.push('_No runs yet._');
|
|
113
|
+
} else {
|
|
114
|
+
lines.push('| Run ID | Agent | Status | Duration | Tokens | Cost |');
|
|
115
|
+
lines.push('|--------|-------|--------|----------|--------|------|');
|
|
116
|
+
for (const run of data.runs.slice(0, 5)) {
|
|
117
|
+
lines.push(
|
|
118
|
+
`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (data.runs.length > 5) {
|
|
122
|
+
lines.push(
|
|
123
|
+
`| ... | ... | ... | ... | ... | _${data.summary.totalRuns - 5} more_ |`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
120
127
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (const run of runsData.items.slice(0, 5)) {
|
|
128
|
-
lines.push(
|
|
129
|
-
`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
if (runsData.items.length > 5) {
|
|
133
|
-
lines.push(
|
|
134
|
-
`| ... | ... | ... | ... | ... | _${runsData.total - 5} more_ |`
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push('## Visualization Overview');
|
|
130
|
+
lines.push('');
|
|
131
|
+
for (const item of visualizationItems) {
|
|
132
|
+
lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
|
|
133
|
+
}
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
lines.push('');
|
|
136
|
+
lines.push('## Tools');
|
|
137
|
+
lines.push('');
|
|
142
138
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
// Tool categories
|
|
140
|
+
const toolsByCategory: Record<string, typeof data.tools> = {};
|
|
141
|
+
for (const tool of data.tools) {
|
|
142
|
+
const cat = tool.category;
|
|
143
|
+
if (!toolsByCategory[cat]) toolsByCategory[cat] = [];
|
|
144
|
+
toolsByCategory[cat].push(tool);
|
|
145
|
+
}
|
|
150
146
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
if (Object.keys(toolsByCategory).length === 0) {
|
|
148
|
+
lines.push('_No tools registered._');
|
|
149
|
+
} else {
|
|
150
|
+
lines.push('| Category | Tools | Active |');
|
|
151
|
+
lines.push('|----------|-------|--------|');
|
|
152
|
+
for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
|
|
153
|
+
const active = tools.filter((t) => t.status === 'ACTIVE').length;
|
|
154
|
+
lines.push(`| ${category} | ${tools.length} | ${active} |`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
161
157
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
return {
|
|
159
|
+
mimeType: 'text/markdown',
|
|
160
|
+
body: lines.join('\n'),
|
|
161
|
+
};
|
|
162
|
+
},
|
|
167
163
|
};
|
|
@@ -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,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses dynamic import for handlers to ensure correct build order.
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
9
|
+
createAgentConsoleDemoHandlers,
|
|
10
|
+
} from '@contractspec/example.agent-console/shared';
|
|
6
11
|
import type { PresentationSpec } from '@contractspec/lib.contracts-spec/presentations';
|
|
7
12
|
import type { PresentationRenderer } from '@contractspec/lib.contracts-spec/presentations/transform-engine';
|
|
8
13
|
import type { Run } from '../hooks/useRunList';
|
|
9
|
-
import { mockListRunsHandler } from '@contractspec/example.agent-console/handlers';
|
|
10
14
|
|
|
11
15
|
interface RunListOutput {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
items: Run[];
|
|
17
|
+
total: number;
|
|
18
|
+
hasMore: boolean;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
function formatDuration(ms: number): string {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
if (ms < 1000) return `${ms}ms`;
|
|
23
|
+
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
24
|
+
return `${(ms / 60000).toFixed(1)}m`;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -25,49 +29,54 @@ function formatDuration(ms: number): string {
|
|
|
25
29
|
* Only handles RunListView component
|
|
26
30
|
*/
|
|
27
31
|
export const runListMarkdownRenderer: PresentationRenderer<{
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
mimeType: string;
|
|
33
|
+
body: string;
|
|
30
34
|
}> = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
target: 'markdown',
|
|
36
|
+
render: async (desc: PresentationSpec, ctx) => {
|
|
37
|
+
// Only handle RunListView
|
|
38
|
+
if (
|
|
39
|
+
desc.source.type !== 'component' ||
|
|
40
|
+
desc.source.componentKey !== 'RunListView'
|
|
41
|
+
) {
|
|
42
|
+
throw new Error('runListMarkdownRenderer: not RunListView');
|
|
43
|
+
}
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const data = (
|
|
46
|
+
Array.isArray(ctx?.data)
|
|
47
|
+
? { items: ctx.data as Run[], total: ctx.data.length, hasMore: false }
|
|
48
|
+
: await createAgentConsoleDemoHandlers({
|
|
49
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
50
|
+
}).listRuns({
|
|
51
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
52
|
+
limit: 20,
|
|
53
|
+
offset: 0,
|
|
54
|
+
})
|
|
55
|
+
) as RunListOutput;
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
// Generate markdown
|
|
58
|
+
const lines: string[] = [
|
|
59
|
+
`# ${desc.meta.description ?? 'Agent Runs'}`,
|
|
60
|
+
'',
|
|
61
|
+
`> ${desc.meta.key} v${desc.meta.version}`,
|
|
62
|
+
'',
|
|
63
|
+
`**Total Runs:** ${data.total}`,
|
|
64
|
+
'',
|
|
65
|
+
'## Recent Runs',
|
|
66
|
+
'',
|
|
67
|
+
'| ID | Agent | Status | Duration | Tokens | Cost |',
|
|
68
|
+
'| --- | --- | --- | --- | --- | --- |',
|
|
69
|
+
];
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
for (const run of data.items.slice(0, 10)) {
|
|
72
|
+
lines.push(
|
|
73
|
+
`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? '-'} |`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
return {
|
|
78
|
+
mimeType: 'text/markdown',
|
|
79
|
+
body: lines.join('\n'),
|
|
80
|
+
};
|
|
81
|
+
},
|
|
73
82
|
};
|