@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.
Files changed (288) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +52 -31
  3. package/CHANGELOG.md +29 -0
  4. package/README.md +112 -83
  5. package/dist/agent/agent.event.js +1 -1
  6. package/dist/agent/agent.handler.d.ts +3 -0
  7. package/dist/agent/agent.handler.js +730 -1
  8. package/dist/agent/agent.operation.js +1 -1
  9. package/dist/agent/index.d.ts +5 -5
  10. package/dist/agent/index.js +74 -73
  11. package/dist/agent.feature.js +179 -0
  12. package/dist/browser/agent/agent.event.js +1 -1
  13. package/dist/browser/agent/agent.handler.js +730 -1
  14. package/dist/browser/agent/agent.operation.js +1 -1
  15. package/dist/browser/agent/index.js +74 -73
  16. package/dist/browser/agent.feature.js +179 -0
  17. package/dist/browser/docs/agent-console.docblock.js +11 -8
  18. package/dist/browser/docs/index.js +11 -8
  19. package/dist/browser/example.js +2 -3
  20. package/dist/browser/handlers/agent.handlers.js +1883 -2
  21. package/dist/browser/handlers/index.js +2142 -8
  22. package/dist/browser/index.js +4075 -3161
  23. package/dist/browser/presentations/index.js +51 -51
  24. package/dist/browser/run/index.js +380 -374
  25. package/dist/browser/run/run.event.js +2 -2
  26. package/dist/browser/run/run.handler.js +666 -1
  27. package/dist/browser/run/run.presentation.js +2 -2
  28. package/dist/browser/shared/index.js +293 -1
  29. package/dist/browser/shared/mock-runs.js +5 -0
  30. package/dist/browser/tool/index.js +161 -161
  31. package/dist/browser/tool/tool.event.js +1 -1
  32. package/dist/browser/tool/tool.handler.js +479 -3
  33. package/dist/browser/tool/tool.presentation.js +2 -2
  34. package/dist/browser/ui/AgentDashboard.js +1816 -931
  35. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  36. package/dist/browser/ui/AgentRunList.js +360 -128
  37. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  38. package/dist/browser/ui/hooks/index.js +611 -161
  39. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  40. package/dist/browser/ui/hooks/useAgentMutations.js +444 -9
  41. package/dist/browser/ui/hooks/useRunList.js +26 -11
  42. package/dist/browser/ui/hooks/useToolList.js +1 -1
  43. package/dist/browser/ui/index.js +2161 -1258
  44. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  45. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  46. package/dist/browser/ui/modals/index.js +297 -297
  47. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  48. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  49. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  50. package/dist/browser/ui/renderers/index.js +359 -163
  51. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  52. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  53. package/dist/browser/ui/views/AgentListView.js +7 -7
  54. package/dist/browser/ui/views/RunDataTable.js +326 -0
  55. package/dist/browser/ui/views/RunListView.js +360 -128
  56. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  57. package/dist/browser/ui/views/index.js +478 -246
  58. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  59. package/dist/browser/ui/views/run-list.shared.js +177 -0
  60. package/dist/browser/visualizations/catalog.js +134 -0
  61. package/dist/browser/visualizations/index.js +187 -0
  62. package/dist/browser/visualizations/selectors.js +181 -0
  63. package/dist/docs/agent-console.docblock.js +11 -8
  64. package/dist/docs/index.js +11 -8
  65. package/dist/example.js +2 -3
  66. package/dist/example.test.d.ts +1 -0
  67. package/dist/handlers/agent.handlers.d.ts +2 -0
  68. package/dist/handlers/agent.handlers.js +1883 -2
  69. package/dist/handlers/index.d.ts +2 -4
  70. package/dist/handlers/index.js +2142 -8
  71. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  72. package/dist/index.d.ts +6 -4
  73. package/dist/index.js +4075 -3161
  74. package/dist/node/agent/agent.event.js +1 -1
  75. package/dist/node/agent/agent.handler.js +730 -1
  76. package/dist/node/agent/agent.operation.js +1 -1
  77. package/dist/node/agent/index.js +74 -73
  78. package/dist/node/agent.feature.js +179 -0
  79. package/dist/node/docs/agent-console.docblock.js +11 -8
  80. package/dist/node/docs/index.js +11 -8
  81. package/dist/node/example.js +2 -3
  82. package/dist/node/handlers/agent.handlers.js +1883 -2
  83. package/dist/node/handlers/index.js +2142 -8
  84. package/dist/node/index.js +4075 -3161
  85. package/dist/node/presentations/index.js +51 -51
  86. package/dist/node/run/index.js +380 -374
  87. package/dist/node/run/run.event.js +2 -2
  88. package/dist/node/run/run.handler.js +666 -1
  89. package/dist/node/run/run.presentation.js +2 -2
  90. package/dist/node/shared/index.js +293 -1
  91. package/dist/node/shared/mock-runs.js +5 -0
  92. package/dist/node/tool/index.js +161 -161
  93. package/dist/node/tool/tool.event.js +1 -1
  94. package/dist/node/tool/tool.handler.js +479 -3
  95. package/dist/node/tool/tool.presentation.js +2 -2
  96. package/dist/node/ui/AgentDashboard.js +1816 -931
  97. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  98. package/dist/node/ui/AgentRunList.js +360 -128
  99. package/dist/node/ui/AgentToolRegistry.js +9 -9
  100. package/dist/node/ui/hooks/index.js +611 -161
  101. package/dist/node/ui/hooks/useAgentList.js +1 -1
  102. package/dist/node/ui/hooks/useAgentMutations.js +444 -9
  103. package/dist/node/ui/hooks/useRunList.js +26 -11
  104. package/dist/node/ui/hooks/useToolList.js +1 -1
  105. package/dist/node/ui/index.js +2161 -1258
  106. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  107. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  108. package/dist/node/ui/modals/index.js +297 -297
  109. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  110. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  111. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  112. package/dist/node/ui/renderers/index.js +359 -163
  113. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  114. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  115. package/dist/node/ui/views/AgentListView.js +7 -7
  116. package/dist/node/ui/views/RunDataTable.js +326 -0
  117. package/dist/node/ui/views/RunListView.js +360 -128
  118. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  119. package/dist/node/ui/views/index.js +478 -246
  120. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  121. package/dist/node/ui/views/run-list.shared.js +177 -0
  122. package/dist/node/visualizations/catalog.js +134 -0
  123. package/dist/node/visualizations/index.js +187 -0
  124. package/dist/node/visualizations/selectors.js +181 -0
  125. package/dist/presentations/index.d.ts +3 -5
  126. package/dist/presentations/index.js +51 -51
  127. package/dist/proof/index.d.ts +2 -0
  128. package/dist/proof/meetup-proof.d.ts +10 -0
  129. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  130. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  131. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  132. package/dist/proof/meetup-proof.test.d.ts +1 -0
  133. package/dist/run/index.d.ts +7 -7
  134. package/dist/run/index.js +380 -374
  135. package/dist/run/run.event.js +2 -2
  136. package/dist/run/run.handler.d.ts +7 -0
  137. package/dist/run/run.handler.js +666 -1
  138. package/dist/run/run.presentation.js +2 -2
  139. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  140. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  141. package/dist/shared/demo-runtime.d.ts +8 -0
  142. package/dist/shared/demo-runtime.test.d.ts +1 -0
  143. package/dist/shared/index.d.ts +4 -1
  144. package/dist/shared/index.js +293 -1
  145. package/dist/shared/mock-runs.d.ts +4 -0
  146. package/dist/shared/mock-runs.js +5 -0
  147. package/dist/tool/index.d.ts +7 -7
  148. package/dist/tool/index.js +161 -161
  149. package/dist/tool/tool.event.js +1 -1
  150. package/dist/tool/tool.handler.d.ts +3 -0
  151. package/dist/tool/tool.handler.js +479 -3
  152. package/dist/tool/tool.presentation.js +2 -2
  153. package/dist/ui/AgentDashboard.js +1816 -931
  154. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  155. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  156. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  157. package/dist/ui/AgentRunList.js +360 -128
  158. package/dist/ui/AgentToolRegistry.js +9 -9
  159. package/dist/ui/hooks/index.d.ts +4 -4
  160. package/dist/ui/hooks/index.js +611 -161
  161. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  162. package/dist/ui/hooks/useAgentList.js +1 -1
  163. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  164. package/dist/ui/hooks/useAgentMutations.js +444 -9
  165. package/dist/ui/hooks/useRunList.d.ts +13 -2
  166. package/dist/ui/hooks/useRunList.js +26 -11
  167. package/dist/ui/hooks/useToolList.d.ts +5 -0
  168. package/dist/ui/hooks/useToolList.js +1 -1
  169. package/dist/ui/index.d.ts +3 -3
  170. package/dist/ui/index.js +2161 -1258
  171. package/dist/ui/modals/AgentActionsModal.js +13 -13
  172. package/dist/ui/modals/CreateAgentModal.js +15 -15
  173. package/dist/ui/modals/index.d.ts +1 -1
  174. package/dist/ui/modals/index.js +297 -297
  175. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  176. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  177. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  178. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  179. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  180. package/dist/ui/renderers/index.d.ts +2 -2
  181. package/dist/ui/renderers/index.js +359 -163
  182. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  183. package/dist/ui/renderers/run-list.markdown.js +9 -4
  184. package/dist/ui/renderers/tool-registry.markdown.d.ts +6 -1
  185. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  186. package/dist/ui/views/AgentListView.js +7 -7
  187. package/dist/ui/views/RunDataTable.d.ts +18 -0
  188. package/dist/ui/views/RunDataTable.js +327 -0
  189. package/dist/ui/views/RunListView.js +360 -128
  190. package/dist/ui/views/ToolRegistryView.js +9 -9
  191. package/dist/ui/views/index.js +478 -246
  192. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  193. package/dist/ui/views/run-data-table.columns.js +272 -0
  194. package/dist/ui/views/run-list.shared.d.ts +14 -0
  195. package/dist/ui/views/run-list.shared.js +178 -0
  196. package/dist/visualizations/catalog.d.ts +10 -0
  197. package/dist/visualizations/catalog.js +135 -0
  198. package/dist/visualizations/index.d.ts +2 -0
  199. package/dist/visualizations/index.js +188 -0
  200. package/dist/visualizations/selectors.d.ts +3 -0
  201. package/dist/visualizations/selectors.js +182 -0
  202. package/dist/visualizations/selectors.test.d.ts +1 -0
  203. package/package.json +114 -12
  204. package/proofs/agent-console-meetup.replay.json +220 -0
  205. package/src/agent/agent.entity.ts +111 -111
  206. package/src/agent/agent.enum.ts +12 -12
  207. package/src/agent/agent.event.ts +91 -91
  208. package/src/agent/agent.handler.ts +144 -127
  209. package/src/agent/agent.operation.ts +400 -400
  210. package/src/agent/agent.presentation.ts +62 -62
  211. package/src/agent/agent.schema.ts +175 -175
  212. package/src/agent/agent.test-spec.ts +48 -48
  213. package/src/agent/index.ts +46 -51
  214. package/src/agent.capability.ts +11 -11
  215. package/src/agent.feature.ts +134 -131
  216. package/src/docs/agent-console.docblock.ts +52 -49
  217. package/src/example.test.ts +75 -0
  218. package/src/example.ts +34 -35
  219. package/src/handlers/agent.handlers.ts +576 -522
  220. package/src/handlers/index.ts +30 -14
  221. package/src/handlers/mock-handlers.test.ts +77 -0
  222. package/src/index.ts +10 -9
  223. package/src/presentations/index.ts +11 -13
  224. package/src/proof/index.ts +2 -0
  225. package/src/proof/meetup-proof.runtime.ts +196 -0
  226. package/src/proof/meetup-proof.scenario.ts +99 -0
  227. package/src/proof/meetup-proof.suite.ts +29 -0
  228. package/src/proof/meetup-proof.test.ts +28 -0
  229. package/src/proof/meetup-proof.ts +130 -0
  230. package/src/run/index.ts +49 -54
  231. package/src/run/run.entity.ts +137 -137
  232. package/src/run/run.enum.ts +18 -18
  233. package/src/run/run.event.ts +174 -174
  234. package/src/run/run.handler.ts +113 -96
  235. package/src/run/run.operation.ts +474 -474
  236. package/src/run/run.presentation.ts +42 -42
  237. package/src/run/run.schema.ts +126 -126
  238. package/src/run/run.test-spec.ts +48 -48
  239. package/src/seeders/index.ts +21 -21
  240. package/src/shared/demo-dashboard-data.ts +58 -0
  241. package/src/shared/demo-runtime-seed.ts +139 -0
  242. package/src/shared/demo-runtime.test.ts +169 -0
  243. package/src/shared/demo-runtime.ts +260 -0
  244. package/src/shared/index.ts +12 -1
  245. package/src/shared/mock-agents.ts +76 -76
  246. package/src/shared/mock-runs.ts +107 -102
  247. package/src/shared/mock-tools.ts +140 -140
  248. package/src/shared/overlay-types.ts +23 -23
  249. package/src/tool/index.ts +39 -44
  250. package/src/tool/tool.entity.ts +73 -73
  251. package/src/tool/tool.enum.ts +13 -13
  252. package/src/tool/tool.event.ts +80 -80
  253. package/src/tool/tool.handler.ts +124 -107
  254. package/src/tool/tool.operation.ts +328 -328
  255. package/src/tool/tool.presentation.ts +43 -43
  256. package/src/tool/tool.schema.ts +106 -106
  257. package/src/tool/tool.test-spec.ts +48 -48
  258. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  259. package/src/ui/AgentDashboard.tsx +351 -348
  260. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  261. package/src/ui/hooks/index.ts +7 -7
  262. package/src/ui/hooks/useAgentList.ts +57 -56
  263. package/src/ui/hooks/useAgentMutations.ts +168 -159
  264. package/src/ui/hooks/useRunList.ts +90 -57
  265. package/src/ui/hooks/useToolList.ts +102 -101
  266. package/src/ui/index.ts +6 -9
  267. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  268. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  269. package/src/ui/modals/index.ts +1 -1
  270. package/src/ui/overlays/demo-overlays.ts +52 -52
  271. package/src/ui/renderers/agent-list.markdown.ts +81 -61
  272. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  273. package/src/ui/renderers/dashboard.markdown.ts +135 -139
  274. package/src/ui/renderers/index.ts +3 -4
  275. package/src/ui/renderers/run-list.markdown.ts +56 -47
  276. package/src/ui/renderers/tool-registry.markdown.ts +79 -66
  277. package/src/ui/views/AgentListView.tsx +90 -90
  278. package/src/ui/views/RunDataTable.tsx +74 -0
  279. package/src/ui/views/RunListView.tsx +84 -158
  280. package/src/ui/views/ToolRegistryView.tsx +113 -113
  281. package/src/ui/views/run-data-table.columns.tsx +102 -0
  282. package/src/ui/views/run-list.shared.tsx +139 -0
  283. package/src/visualizations/catalog.ts +132 -0
  284. package/src/visualizations/index.ts +2 -0
  285. package/src/visualizations/selectors.test.ts +12 -0
  286. package/src/visualizations/selectors.ts +70 -0
  287. package/tsconfig.json +7 -8
  288. 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
- type Agent = AgentSummary;
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
- mimeType: string;
21
- body: string;
28
+ mimeType: string;
29
+ body: string;
22
30
  }> = {
23
- target: 'markdown',
24
- render: async (desc: PresentationSpec) => {
25
- // Only handle AgentListView
26
- if (
27
- desc.source.type !== 'component' ||
28
- desc.source.componentKey !== 'AgentListView'
29
- ) {
30
- throw new Error('agentListMarkdownRenderer: not AgentListView');
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
- // Fetch data using mock handler
34
- const data = await mockListAgentsHandler({
35
- organizationId: 'demo-org',
36
- limit: 50,
37
- offset: 0,
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
- // Generate markdown
41
- const lines: string[] = [
42
- `# ${desc.meta.description ?? 'Agent List'}`,
43
- '',
44
- `> ${desc.meta.key} v${desc.meta.version}`,
45
- '',
46
- `**Total Agents:** ${data.total}`,
47
- '',
48
- '## Agents',
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
- // Group by status
53
- const byStatus: Record<string, Agent[]> = {};
54
- for (const agent of data.items) {
55
- const status = agent.status;
56
- if (byStatus[status]) {
57
- byStatus[status].push(agent);
58
- } else {
59
- byStatus[status] = [agent];
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
- for (const [status, agents] of Object.entries(byStatus)) {
64
- lines.push(`### ${status} (${agents.length})`);
65
- lines.push('');
66
- for (const agent of agents) {
67
- lines.push(
68
- `- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`
69
- );
70
- if (agent.description) {
71
- lines.push(` > ${agent.description}`);
72
- }
73
- }
74
- lines.push('');
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
- return {
78
- mimeType: 'text/markdown',
79
- body: lines.join('\n'),
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
- 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
- };
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
- if (ms < 1000) return `${ms}ms`;
16
- if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
17
- return `${(ms / 60000).toFixed(1)}m`;
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
- mimeType: string;
26
- body: string;
26
+ mimeType: string;
27
+ body: string;
27
28
  }> = {
28
- target: 'markdown',
29
- render: async (desc: PresentationSpec) => {
30
- // Only handle AgentConsoleDashboard
31
- if (
32
- desc.source.type !== 'component' ||
33
- desc.source.componentKey !== 'AgentConsoleDashboard'
34
- ) {
35
- throw new Error(
36
- 'agentDashboardMarkdownRenderer: not AgentConsoleDashboard'
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
- // Fetch all data in parallel
41
- const [agentsData, runsData, toolsData] = await Promise.all([
42
- mockListAgentsHandler({
43
- organizationId: 'demo-org',
44
- limit: 100,
45
- }),
46
- mockListRunsHandler({
47
- limit: 100,
48
- }),
49
- mockListToolsHandler({
50
- organizationId: 'demo-org',
51
- limit: 100,
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
- // Calculate stats
56
- const activeAgents = agentsData.items.filter(
57
- (a) => a.status === 'ACTIVE'
58
- ).length;
59
- const completedRuns = runsData.items.filter(
60
- (r) => r.status === 'COMPLETED'
61
- ).length;
62
- const failedRuns = runsData.items.filter(
63
- (r) => r.status === 'FAILED'
64
- ).length;
65
- const totalTokens = runsData.items.reduce(
66
- (sum, r) => sum + (r.totalTokens ?? 0),
67
- 0
68
- );
69
- const totalCost = runsData.items.reduce(
70
- (sum, r) => sum + (r.estimatedCostUsd ?? 0),
71
- 0
72
- );
73
- const activeTools = toolsData.items.filter(
74
- (t) => t.status === 'ACTIVE'
75
- ).length;
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
- // Build dashboard markdown
78
- const lines: string[] = [
79
- '# Agent Console Dashboard',
80
- '',
81
- '> AI agent operations overview',
82
- '',
83
- '## Summary',
84
- '',
85
- '| Metric | Value |',
86
- '|--------|-------|',
87
- `| Total Agents | ${agentsData.total} |`,
88
- `| Active Agents | ${activeAgents} |`,
89
- `| Total Runs | ${runsData.total} |`,
90
- `| Completed Runs | ${completedRuns} |`,
91
- `| Failed Runs | ${failedRuns} |`,
92
- `| Total Tokens | ${totalTokens.toLocaleString()} |`,
93
- `| Total Cost | $${totalCost.toFixed(4)} |`,
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
- // Agent list
102
- if (agentsData.items.length === 0) {
103
- lines.push('_No agents configured._');
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
- lines.push('');
118
- lines.push('## Recent Runs');
119
- lines.push('');
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
- // Recent runs
122
- if (runsData.items.length === 0) {
123
- lines.push('_No runs yet._');
124
- } else {
125
- lines.push('| Run ID | Agent | Status | Duration | Tokens | Cost |');
126
- lines.push('|--------|-------|--------|----------|--------|------|');
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
- lines.push('');
140
- lines.push('## Tools');
141
- lines.push('');
135
+ lines.push('');
136
+ lines.push('## Tools');
137
+ lines.push('');
142
138
 
143
- // Tool categories
144
- const toolsByCategory: Record<string, typeof toolsData.items> = {};
145
- for (const tool of toolsData.items) {
146
- const cat = tool.category;
147
- if (!toolsByCategory[cat]) toolsByCategory[cat] = [];
148
- toolsByCategory[cat].push(tool);
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
- if (Object.keys(toolsByCategory).length === 0) {
152
- lines.push('_No tools registered._');
153
- } else {
154
- lines.push('| Category | Tools | Active |');
155
- lines.push('|----------|-------|--------|');
156
- for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
157
- const active = tools.filter((t) => t.status === 'ACTIVE').length;
158
- lines.push(`| ${category} | ${tools.length} | ${active} |`);
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
- return {
163
- mimeType: 'text/markdown',
164
- body: lines.join('\n'),
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
- items: Run[];
13
- total: number;
14
- hasMore: boolean;
16
+ items: Run[];
17
+ total: number;
18
+ hasMore: boolean;
15
19
  }
16
20
 
17
21
  function formatDuration(ms: number): string {
18
- if (ms < 1000) return `${ms}ms`;
19
- if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
20
- return `${(ms / 60000).toFixed(1)}m`;
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
- mimeType: string;
29
- body: string;
32
+ mimeType: string;
33
+ body: string;
30
34
  }> = {
31
- target: 'markdown',
32
- render: async (desc: PresentationSpec) => {
33
- // Only handle RunListView
34
- if (
35
- desc.source.type !== 'component' ||
36
- desc.source.componentKey !== 'RunListView'
37
- ) {
38
- throw new Error('runListMarkdownRenderer: not RunListView');
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
- // Fetch data using mock handler
42
- const data = (await mockListRunsHandler({
43
- organizationId: 'demo-org',
44
- limit: 20,
45
- offset: 0,
46
- })) as RunListOutput;
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
- // Generate markdown
49
- const lines: string[] = [
50
- `# ${desc.meta.description ?? 'Agent Runs'}`,
51
- '',
52
- `> ${desc.meta.key} v${desc.meta.version}`,
53
- '',
54
- `**Total Runs:** ${data.total}`,
55
- '',
56
- '## Recent Runs',
57
- '',
58
- '| ID | Agent | Status | Duration | Tokens | Cost |',
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
- for (const run of data.items.slice(0, 10)) {
63
- lines.push(
64
- `| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : '-'} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? '-'} |`
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
- return {
69
- mimeType: 'text/markdown',
70
- body: lines.join('\n'),
71
- };
72
- },
77
+ return {
78
+ mimeType: 'text/markdown',
79
+ body: lines.join('\n'),
80
+ };
81
+ },
73
82
  };