@contractspec/example.agent-console 3.8.8 → 3.8.10

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 (228) hide show
  1. package/.turbo/turbo-build.log +225 -222
  2. package/CHANGELOG.md +34 -0
  3. package/dist/agent/agent.entity.js +1 -127
  4. package/dist/agent/agent.enum.js +1 -25
  5. package/dist/agent/agent.event.js +1 -116
  6. package/dist/agent/agent.handler.js +1 -1030
  7. package/dist/agent/agent.operation.js +1 -735
  8. package/dist/agent/agent.presentation.js +1 -282
  9. package/dist/agent/agent.schema.js +1 -215
  10. package/dist/agent/agent.test-spec.js +1 -58
  11. package/dist/agent/index.js +1 -1248
  12. package/dist/agent.capability.js +1 -19
  13. package/dist/agent.feature.js +1 -305
  14. package/dist/browser/agent/agent.entity.js +1 -127
  15. package/dist/browser/agent/agent.enum.js +1 -25
  16. package/dist/browser/agent/agent.event.js +1 -116
  17. package/dist/browser/agent/agent.handler.js +1 -1030
  18. package/dist/browser/agent/agent.operation.js +1 -735
  19. package/dist/browser/agent/agent.presentation.js +1 -282
  20. package/dist/browser/agent/agent.schema.js +1 -215
  21. package/dist/browser/agent/agent.test-spec.js +1 -58
  22. package/dist/browser/agent/index.js +1 -1248
  23. package/dist/browser/agent.capability.js +1 -19
  24. package/dist/browser/agent.feature.js +1 -305
  25. package/dist/browser/docs/agent-console.docblock.js +5 -49
  26. package/dist/browser/docs/index.js +5 -49
  27. package/dist/browser/example.js +1 -41
  28. package/dist/browser/handlers/agent.handlers.js +6 -2143
  29. package/dist/browser/handlers/index.js +6 -2943
  30. package/dist/browser/index.js +14 -6828
  31. package/dist/browser/presentations/index.js +1 -693
  32. package/dist/browser/run/index.js +1 -1363
  33. package/dist/browser/run/run.entity.js +1 -160
  34. package/dist/browser/run/run.enum.js +1 -34
  35. package/dist/browser/run/run.event.js +1 -217
  36. package/dist/browser/run/run.handler.js +1 -919
  37. package/dist/browser/run/run.operation.js +1 -667
  38. package/dist/browser/run/run.presentation.js +1 -223
  39. package/dist/browser/run/run.schema.js +1 -179
  40. package/dist/browser/run/run.test-spec.js +1 -58
  41. package/dist/browser/seeders/index.js +2 -21
  42. package/dist/browser/shared/index.js +1 -626
  43. package/dist/browser/shared/mock-agents.js +1 -82
  44. package/dist/browser/shared/mock-runs.js +1 -113
  45. package/dist/browser/shared/mock-tools.js +1 -146
  46. package/dist/browser/tool/index.js +1 -949
  47. package/dist/browser/tool/tool.entity.js +1 -90
  48. package/dist/browser/tool/tool.enum.js +1 -26
  49. package/dist/browser/tool/tool.event.js +1 -99
  50. package/dist/browser/tool/tool.handler.js +1 -699
  51. package/dist/browser/tool/tool.operation.js +1 -482
  52. package/dist/browser/tool/tool.presentation.js +1 -188
  53. package/dist/browser/tool/tool.schema.js +1 -141
  54. package/dist/browser/tool/tool.test-spec.js +1 -58
  55. package/dist/browser/ui/AgentDashboard.js +1 -2527
  56. package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
  57. package/dist/browser/ui/AgentRunList.js +1 -482
  58. package/dist/browser/ui/AgentToolRegistry.js +1 -212
  59. package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
  60. package/dist/browser/ui/hooks/index.js +1 -740
  61. package/dist/browser/ui/hooks/useAgentList.js +1 -55
  62. package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
  63. package/dist/browser/ui/hooks/useRunList.js +1 -70
  64. package/dist/browser/ui/hooks/useToolList.js +1 -85
  65. package/dist/browser/ui/index.js +5 -3018
  66. package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
  67. package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
  68. package/dist/browser/ui/modals/index.js +1 -546
  69. package/dist/browser/ui/overlays/demo-overlays.js +1 -64
  70. package/dist/browser/ui/overlays/index.js +1 -64
  71. package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
  72. package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
  73. package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
  74. package/dist/browser/ui/renderers/index.js +5 -642
  75. package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
  76. package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
  77. package/dist/browser/ui/views/AgentListView.js +1 -165
  78. package/dist/browser/ui/views/RunDataTable.js +1 -326
  79. package/dist/browser/ui/views/RunListView.js +1 -479
  80. package/dist/browser/ui/views/ToolRegistryView.js +1 -209
  81. package/dist/browser/ui/views/index.js +1 -851
  82. package/dist/browser/ui/views/run-data-table.columns.js +1 -271
  83. package/dist/browser/ui/views/run-list.shared.js +1 -177
  84. package/dist/browser/visualizations/catalog.js +1 -134
  85. package/dist/browser/visualizations/index.js +1 -187
  86. package/dist/browser/visualizations/selectors.js +1 -181
  87. package/dist/docs/agent-console.docblock.js +5 -49
  88. package/dist/docs/index.js +5 -49
  89. package/dist/example.js +1 -41
  90. package/dist/handlers/agent.handlers.js +6 -2143
  91. package/dist/handlers/index.js +6 -2943
  92. package/dist/index.js +14 -6828
  93. package/dist/node/agent/agent.entity.js +1 -127
  94. package/dist/node/agent/agent.enum.js +1 -25
  95. package/dist/node/agent/agent.event.js +1 -116
  96. package/dist/node/agent/agent.handler.js +1 -1030
  97. package/dist/node/agent/agent.operation.js +1 -735
  98. package/dist/node/agent/agent.presentation.js +1 -282
  99. package/dist/node/agent/agent.schema.js +1 -215
  100. package/dist/node/agent/agent.test-spec.js +1 -58
  101. package/dist/node/agent/index.js +1 -1248
  102. package/dist/node/agent.capability.js +1 -19
  103. package/dist/node/agent.feature.js +1 -305
  104. package/dist/node/docs/agent-console.docblock.js +5 -49
  105. package/dist/node/docs/index.js +5 -49
  106. package/dist/node/example.js +1 -41
  107. package/dist/node/handlers/agent.handlers.js +6 -2143
  108. package/dist/node/handlers/index.js +6 -2943
  109. package/dist/node/index.js +14 -6828
  110. package/dist/node/presentations/index.js +1 -693
  111. package/dist/node/run/index.js +1 -1363
  112. package/dist/node/run/run.entity.js +1 -160
  113. package/dist/node/run/run.enum.js +1 -34
  114. package/dist/node/run/run.event.js +1 -217
  115. package/dist/node/run/run.handler.js +1 -919
  116. package/dist/node/run/run.operation.js +1 -667
  117. package/dist/node/run/run.presentation.js +1 -223
  118. package/dist/node/run/run.schema.js +1 -179
  119. package/dist/node/run/run.test-spec.js +1 -58
  120. package/dist/node/seeders/index.js +2 -21
  121. package/dist/node/shared/index.js +1 -626
  122. package/dist/node/shared/mock-agents.js +1 -82
  123. package/dist/node/shared/mock-runs.js +1 -113
  124. package/dist/node/shared/mock-tools.js +1 -146
  125. package/dist/node/tool/index.js +1 -949
  126. package/dist/node/tool/tool.entity.js +1 -90
  127. package/dist/node/tool/tool.enum.js +1 -26
  128. package/dist/node/tool/tool.event.js +1 -99
  129. package/dist/node/tool/tool.handler.js +1 -699
  130. package/dist/node/tool/tool.operation.js +1 -482
  131. package/dist/node/tool/tool.presentation.js +1 -188
  132. package/dist/node/tool/tool.schema.js +1 -141
  133. package/dist/node/tool/tool.test-spec.js +1 -58
  134. package/dist/node/ui/AgentDashboard.js +1 -2527
  135. package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
  136. package/dist/node/ui/AgentRunList.js +1 -482
  137. package/dist/node/ui/AgentToolRegistry.js +1 -212
  138. package/dist/node/ui/ExecutionConsoleHost.js +1 -0
  139. package/dist/node/ui/hooks/index.js +1 -740
  140. package/dist/node/ui/hooks/useAgentList.js +1 -55
  141. package/dist/node/ui/hooks/useAgentMutations.js +1 -530
  142. package/dist/node/ui/hooks/useRunList.js +1 -70
  143. package/dist/node/ui/hooks/useToolList.js +1 -85
  144. package/dist/node/ui/index.js +5 -3018
  145. package/dist/node/ui/modals/AgentActionsModal.js +1 -304
  146. package/dist/node/ui/modals/CreateAgentModal.js +1 -243
  147. package/dist/node/ui/modals/index.js +1 -546
  148. package/dist/node/ui/overlays/demo-overlays.js +1 -64
  149. package/dist/node/ui/overlays/index.js +1 -64
  150. package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
  151. package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
  152. package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
  153. package/dist/node/ui/renderers/index.js +5 -642
  154. package/dist/node/ui/renderers/run-list.markdown.js +2 -50
  155. package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
  156. package/dist/node/ui/views/AgentListView.js +1 -165
  157. package/dist/node/ui/views/RunDataTable.js +1 -326
  158. package/dist/node/ui/views/RunListView.js +1 -479
  159. package/dist/node/ui/views/ToolRegistryView.js +1 -209
  160. package/dist/node/ui/views/index.js +1 -851
  161. package/dist/node/ui/views/run-data-table.columns.js +1 -271
  162. package/dist/node/ui/views/run-list.shared.js +1 -177
  163. package/dist/node/visualizations/catalog.js +1 -134
  164. package/dist/node/visualizations/index.js +1 -187
  165. package/dist/node/visualizations/selectors.js +1 -181
  166. package/dist/presentations/index.js +1 -693
  167. package/dist/run/index.js +1 -1363
  168. package/dist/run/run.entity.js +1 -160
  169. package/dist/run/run.enum.js +1 -34
  170. package/dist/run/run.event.js +1 -217
  171. package/dist/run/run.handler.js +1 -919
  172. package/dist/run/run.operation.js +1 -667
  173. package/dist/run/run.presentation.js +1 -223
  174. package/dist/run/run.schema.js +1 -179
  175. package/dist/run/run.test-spec.js +1 -58
  176. package/dist/seeders/index.js +2 -21
  177. package/dist/shared/index.js +1 -626
  178. package/dist/shared/mock-agents.js +1 -82
  179. package/dist/shared/mock-runs.js +1 -113
  180. package/dist/shared/mock-tools.js +1 -146
  181. package/dist/tool/index.js +1 -949
  182. package/dist/tool/tool.entity.js +1 -90
  183. package/dist/tool/tool.enum.js +1 -26
  184. package/dist/tool/tool.event.js +1 -99
  185. package/dist/tool/tool.handler.js +1 -699
  186. package/dist/tool/tool.operation.js +1 -482
  187. package/dist/tool/tool.presentation.js +1 -188
  188. package/dist/tool/tool.schema.js +1 -141
  189. package/dist/tool/tool.test-spec.js +1 -58
  190. package/dist/ui/AgentDashboard.js +1 -2527
  191. package/dist/ui/AgentDashboard.visualizations.js +1 -217
  192. package/dist/ui/AgentRunList.js +1 -482
  193. package/dist/ui/AgentToolRegistry.js +1 -212
  194. package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
  195. package/dist/ui/ExecutionConsoleHost.js +2 -0
  196. package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
  197. package/dist/ui/hooks/index.js +1 -740
  198. package/dist/ui/hooks/useAgentList.js +1 -55
  199. package/dist/ui/hooks/useAgentMutations.js +1 -530
  200. package/dist/ui/hooks/useRunList.js +1 -70
  201. package/dist/ui/hooks/useToolList.js +1 -85
  202. package/dist/ui/index.d.ts +1 -0
  203. package/dist/ui/index.js +5 -3018
  204. package/dist/ui/modals/AgentActionsModal.js +1 -304
  205. package/dist/ui/modals/CreateAgentModal.js +1 -243
  206. package/dist/ui/modals/index.js +1 -546
  207. package/dist/ui/overlays/demo-overlays.js +1 -64
  208. package/dist/ui/overlays/index.js +1 -64
  209. package/dist/ui/renderers/agent-list.markdown.js +2 -64
  210. package/dist/ui/renderers/agent-list.renderer.js +1 -180
  211. package/dist/ui/renderers/dashboard.markdown.js +2 -288
  212. package/dist/ui/renderers/index.js +5 -642
  213. package/dist/ui/renderers/run-list.markdown.js +2 -50
  214. package/dist/ui/renderers/tool-registry.markdown.js +2 -64
  215. package/dist/ui/views/AgentListView.js +1 -165
  216. package/dist/ui/views/RunDataTable.js +1 -326
  217. package/dist/ui/views/RunListView.js +1 -479
  218. package/dist/ui/views/ToolRegistryView.js +1 -209
  219. package/dist/ui/views/index.js +1 -851
  220. package/dist/ui/views/run-data-table.columns.js +1 -271
  221. package/dist/ui/views/run-list.shared.js +1 -177
  222. package/dist/visualizations/catalog.js +1 -134
  223. package/dist/visualizations/index.js +1 -187
  224. package/dist/visualizations/selectors.js +1 -181
  225. package/package.json +29 -13
  226. package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
  227. package/src/ui/ExecutionConsoleHost.tsx +14 -0
  228. package/src/ui/index.ts +1 -1
@@ -1,642 +1,5 @@
1
- // src/visualizations/catalog.ts
2
- import {
3
- defineVisualization,
4
- VisualizationRegistry
5
- } from "@contractspec/lib.contracts-spec/visualizations";
6
- var RUN_LIST_REF = { key: "agent.run.list", version: "1.0.0" };
7
- var META = {
8
- version: "1.0.0",
9
- domain: "ai-ops",
10
- stability: "experimental",
11
- owners: ["@example.agent-console"],
12
- tags: ["agent-console", "visualization", "operations"]
13
- };
14
- var AgentRunStatusVisualization = defineVisualization({
15
- meta: {
16
- ...META,
17
- key: "agent-console.visualization.run-status",
18
- title: "Run Status Breakdown",
19
- description: "Distribution of run outcomes across the current sample.",
20
- goal: "Make operational success and failure mix visible at a glance.",
21
- context: "Agent operations overview."
22
- },
23
- source: { primary: RUN_LIST_REF, resultPath: "data" },
24
- visualization: {
25
- kind: "pie",
26
- nameDimension: "status",
27
- valueMeasure: "runs",
28
- dimensions: [
29
- { key: "status", label: "Status", dataPath: "status", type: "category" }
30
- ],
31
- measures: [
32
- { key: "runs", label: "Runs", dataPath: "runs", format: "number" }
33
- ],
34
- table: { caption: "Run counts by status." }
35
- }
36
- });
37
- var AgentRunActivityVisualization = defineVisualization({
38
- meta: {
39
- ...META,
40
- key: "agent-console.visualization.run-activity",
41
- title: "Recent Run Activity",
42
- description: "Daily run volume across the current sample.",
43
- goal: "Show whether agent activity is rising or slowing down.",
44
- context: "Operations trend monitoring."
45
- },
46
- source: { primary: RUN_LIST_REF, resultPath: "data" },
47
- visualization: {
48
- kind: "cartesian",
49
- variant: "line",
50
- xDimension: "day",
51
- yMeasures: ["runs"],
52
- dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
53
- measures: [
54
- {
55
- key: "runs",
56
- label: "Runs",
57
- dataPath: "runs",
58
- format: "number",
59
- color: "#0f766e"
60
- }
61
- ],
62
- table: { caption: "Daily run counts." }
63
- }
64
- });
65
- var AgentRunEfficiencyVisualization = defineVisualization({
66
- meta: {
67
- ...META,
68
- key: "agent-console.visualization.run-efficiency",
69
- title: "Duration vs Tokens",
70
- description: "Scatter chart comparing token consumption and runtime.",
71
- goal: "Reveal outlier runs that are slow relative to their token usage.",
72
- context: "Operational performance diagnostics."
73
- },
74
- source: { primary: RUN_LIST_REF, resultPath: "data" },
75
- visualization: {
76
- kind: "cartesian",
77
- variant: "scatter",
78
- xDimension: "totalTokens",
79
- yMeasures: ["durationMs"],
80
- dimensions: [
81
- {
82
- key: "totalTokens",
83
- label: "Total Tokens",
84
- dataPath: "totalTokens",
85
- type: "number"
86
- }
87
- ],
88
- measures: [
89
- {
90
- key: "durationMs",
91
- label: "Duration",
92
- dataPath: "durationMs",
93
- format: "duration",
94
- color: "#7c3aed"
95
- },
96
- {
97
- key: "estimatedCostUsd",
98
- label: "Cost",
99
- dataPath: "estimatedCostUsd",
100
- format: "currency"
101
- }
102
- ],
103
- series: [
104
- {
105
- key: "runs",
106
- label: "Runs",
107
- measure: "durationMs",
108
- type: "scatter",
109
- color: "#7c3aed"
110
- }
111
- ],
112
- table: { caption: "Run duration versus token usage." }
113
- }
114
- });
115
- var AgentVisualizationSpecs = [
116
- AgentRunStatusVisualization,
117
- AgentRunActivityVisualization,
118
- AgentRunEfficiencyVisualization
119
- ];
120
- var AgentVisualizationRegistry = new VisualizationRegistry([
121
- ...AgentVisualizationSpecs
122
- ]);
123
- var AgentVisualizationRefs = AgentVisualizationSpecs.map((spec) => ({
124
- key: spec.meta.key,
125
- version: spec.meta.version
126
- }));
127
-
128
- // src/visualizations/selectors.ts
129
- function dayKey(value) {
130
- if (!value)
131
- return "unknown";
132
- return value.toISOString().slice(0, 10);
133
- }
134
- function createAgentVisualizationItems(runs) {
135
- const statusCounts = new Map;
136
- const activityCounts = new Map;
137
- for (const run of runs) {
138
- statusCounts.set(run.status, (statusCounts.get(run.status) ?? 0) + 1);
139
- activityCounts.set(dayKey(run.startedAt ?? run.queuedAt), (activityCounts.get(dayKey(run.startedAt ?? run.queuedAt)) ?? 0) + 1);
140
- }
141
- return [
142
- {
143
- key: "run-status",
144
- spec: AgentRunStatusVisualization,
145
- data: {
146
- data: Array.from(statusCounts.entries()).map(([status, count]) => ({
147
- status,
148
- runs: count
149
- }))
150
- },
151
- title: "Run Status Breakdown",
152
- description: "Completed, failed, running, and cancelled runs in the sample.",
153
- height: 260
154
- },
155
- {
156
- key: "run-activity",
157
- spec: AgentRunActivityVisualization,
158
- data: {
159
- data: Array.from(activityCounts.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, runs: count }))
160
- },
161
- title: "Recent Run Activity",
162
- description: "Daily run volume derived from run start times."
163
- },
164
- {
165
- key: "run-efficiency",
166
- spec: AgentRunEfficiencyVisualization,
167
- data: {
168
- data: runs.filter((run) => typeof run.durationMs === "number").map((run) => ({
169
- totalTokens: run.totalTokens,
170
- durationMs: run.durationMs ?? 0,
171
- estimatedCostUsd: run.estimatedCostUsd
172
- }))
173
- },
174
- title: "Duration vs Tokens",
175
- description: "Operational scatter plot for spotting inefficient runs."
176
- }
177
- ];
178
- }
179
- // src/ui/hooks/useAgentList.ts
180
- import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
181
- import { useCallback, useEffect, useMemo, useState } from "react";
182
- function useAgentList(options = {}) {
183
- const { handlers, projectId } = useTemplateRuntime();
184
- const { agent } = handlers;
185
- const [data, setData] = useState(null);
186
- const [loading, setLoading] = useState(true);
187
- const [error, setError] = useState(null);
188
- const [page, setPage] = useState(1);
189
- const fetchData = useCallback(async () => {
190
- setLoading(true);
191
- setError(null);
192
- try {
193
- const result = await agent.listAgents({
194
- projectId,
195
- search: options.search,
196
- status: options.status === "all" ? undefined : options.status,
197
- limit: options.limit ?? 20,
198
- offset: (page - 1) * (options.limit ?? 20)
199
- });
200
- setData(result);
201
- } catch (err) {
202
- setError(err instanceof Error ? err : new Error("Unknown error"));
203
- } finally {
204
- setLoading(false);
205
- }
206
- }, [agent, projectId, options.search, options.status, options.limit, page]);
207
- useEffect(() => {
208
- fetchData();
209
- }, [fetchData]);
210
- const stats = useMemo(() => {
211
- if (!data)
212
- return null;
213
- return {
214
- total: data.total,
215
- active: data.items.filter((a) => a.status === "ACTIVE").length,
216
- paused: data.items.filter((a) => a.status === "PAUSED").length,
217
- draft: data.items.filter((a) => a.status === "DRAFT").length
218
- };
219
- }, [data]);
220
- return {
221
- data,
222
- loading,
223
- error,
224
- stats,
225
- page,
226
- refetch: fetchData,
227
- nextPage: () => setPage((p) => p + 1),
228
- prevPage: () => page > 1 && setPage((p) => p - 1)
229
- };
230
- }
231
-
232
- // src/ui/renderers/agent-list.markdown.ts
233
- import {
234
- AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
235
- AGENT_CONSOLE_DEMO_PROJECT_ID,
236
- createAgentConsoleDemoHandlers
237
- } from "@contractspec/example.agent-console/shared";
238
- var agentListMarkdownRenderer = {
239
- target: "markdown",
240
- render: async (desc, ctx) => {
241
- if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
242
- throw new Error("agentListMarkdownRenderer: not AgentListView");
243
- }
244
- const data = Array.isArray(ctx?.data) ? {
245
- items: ctx.data,
246
- total: ctx.data.length,
247
- hasMore: false
248
- } : await createAgentConsoleDemoHandlers({
249
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID
250
- }).listAgents({
251
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
252
- organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
253
- limit: 50,
254
- offset: 0
255
- });
256
- const lines = [
257
- `# ${desc.meta.description ?? "Agent List"}`,
258
- "",
259
- `> ${desc.meta.key} v${desc.meta.version}`,
260
- "",
261
- `**Total Agents:** ${data.total}`,
262
- "",
263
- "## Agents",
264
- ""
265
- ];
266
- const byStatus = {};
267
- for (const agent of data.items) {
268
- const status = agent.status;
269
- if (byStatus[status]) {
270
- byStatus[status].push(agent);
271
- } else {
272
- byStatus[status] = [agent];
273
- }
274
- }
275
- for (const [status, agents] of Object.entries(byStatus)) {
276
- lines.push(`### ${status} (${agents.length})`);
277
- lines.push("");
278
- for (const agent of agents) {
279
- lines.push(`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`);
280
- if (agent.description) {
281
- lines.push(` > ${agent.description}`);
282
- }
283
- }
284
- lines.push("");
285
- }
286
- return {
287
- mimeType: "text/markdown",
288
- body: lines.join(`
289
- `)
290
- };
291
- }
292
- };
293
-
294
- // src/ui/views/AgentListView.tsx
295
- import {
296
- Button,
297
- EmptyState,
298
- EntityCard,
299
- ErrorState,
300
- LoaderBlock,
301
- StatCard,
302
- StatCardGroup,
303
- StatusChip
304
- } from "@contractspec/lib.design-system";
305
- import { jsxDEV } from "react/jsx-dev-runtime";
306
- "use client";
307
- function getStatusTone(status) {
308
- switch (status) {
309
- case "ACTIVE":
310
- return "success";
311
- case "PAUSED":
312
- case "DRAFT":
313
- return "warning";
314
- case "ARCHIVED":
315
- return "neutral";
316
- default:
317
- return "neutral";
318
- }
319
- }
320
- function AgentListView() {
321
- const { data, loading, error, stats, refetch } = useAgentList();
322
- if (loading && !data) {
323
- return /* @__PURE__ */ jsxDEV(LoaderBlock, {
324
- label: "Loading agents..."
325
- }, undefined, false, undefined, this);
326
- }
327
- if (error) {
328
- return /* @__PURE__ */ jsxDEV(ErrorState, {
329
- title: "Failed to load agents",
330
- description: error.message,
331
- onRetry: refetch,
332
- retryLabel: "Retry"
333
- }, undefined, false, undefined, this);
334
- }
335
- if (!data?.items.length) {
336
- return /* @__PURE__ */ jsxDEV(EmptyState, {
337
- title: "No agents yet",
338
- description: "Create your first AI agent to get started."
339
- }, undefined, false, undefined, this);
340
- }
341
- return /* @__PURE__ */ jsxDEV("div", {
342
- className: "space-y-6",
343
- children: [
344
- stats && /* @__PURE__ */ jsxDEV(StatCardGroup, {
345
- children: [
346
- /* @__PURE__ */ jsxDEV(StatCard, {
347
- label: "Total Agents",
348
- value: stats.total
349
- }, undefined, false, undefined, this),
350
- /* @__PURE__ */ jsxDEV(StatCard, {
351
- label: "Active",
352
- value: stats.active
353
- }, undefined, false, undefined, this),
354
- /* @__PURE__ */ jsxDEV(StatCard, {
355
- label: "Paused",
356
- value: stats.paused
357
- }, undefined, false, undefined, this),
358
- /* @__PURE__ */ jsxDEV(StatCard, {
359
- label: "Draft",
360
- value: stats.draft
361
- }, undefined, false, undefined, this)
362
- ]
363
- }, undefined, true, undefined, this),
364
- /* @__PURE__ */ jsxDEV("div", {
365
- className: "flex items-center justify-between",
366
- children: [
367
- /* @__PURE__ */ jsxDEV("h3", {
368
- className: "font-semibold text-lg",
369
- children: "Agents"
370
- }, undefined, false, undefined, this),
371
- /* @__PURE__ */ jsxDEV(Button, {
372
- onPress: () => alert("Create Agent clicked!"),
373
- children: "Create Agent"
374
- }, undefined, false, undefined, this)
375
- ]
376
- }, undefined, true, undefined, this),
377
- /* @__PURE__ */ jsxDEV("div", {
378
- className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
379
- children: data.items.map((agent) => /* @__PURE__ */ jsxDEV(EntityCard, {
380
- cardTitle: agent.name,
381
- cardSubtitle: agent.modelName,
382
- meta: /* @__PURE__ */ jsxDEV("p", {
383
- className: "text-muted-foreground text-sm",
384
- children: agent.description
385
- }, undefined, false, undefined, this),
386
- chips: /* @__PURE__ */ jsxDEV(StatusChip, {
387
- tone: getStatusTone(agent.status),
388
- label: agent.status
389
- }, undefined, false, undefined, this),
390
- footer: /* @__PURE__ */ jsxDEV("span", {
391
- className: "text-muted-foreground text-xs",
392
- children: [
393
- "Created ",
394
- agent.createdAt.toLocaleDateString()
395
- ]
396
- }, undefined, true, undefined, this),
397
- onClick: () => alert(`View agent: ${agent.name}`)
398
- }, agent.id, false, undefined, this))
399
- }, undefined, false, undefined, this)
400
- ]
401
- }, undefined, true, undefined, this);
402
- }
403
-
404
- // src/ui/renderers/agent-list.renderer.tsx
405
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
406
- var agentListReactRenderer = {
407
- target: "react",
408
- render: async (desc) => {
409
- if (desc.source.type !== "component") {
410
- throw new Error("AgentListRenderer: expected component source");
411
- }
412
- if (desc.source.componentKey !== "AgentListView") {
413
- throw new Error(`AgentListRenderer: unknown component ${desc.source.componentKey}`);
414
- }
415
- return /* @__PURE__ */ jsxDEV2(AgentListView, {}, undefined, false, undefined, this);
416
- }
417
- };
418
-
419
- // src/ui/renderers/dashboard.markdown.ts
420
- import {
421
- getFallbackAgentConsoleDashboardData
422
- } from "@contractspec/example.agent-console/shared";
423
- function formatDuration(ms) {
424
- if (ms < 1000)
425
- return `${ms}ms`;
426
- if (ms < 60000)
427
- return `${(ms / 1000).toFixed(1)}s`;
428
- return `${(ms / 60000).toFixed(1)}m`;
429
- }
430
- var agentDashboardMarkdownRenderer = {
431
- target: "markdown",
432
- render: async (desc, ctx) => {
433
- if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
434
- throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
435
- }
436
- const data = ctx?.data ?? await getFallbackAgentConsoleDashboardData();
437
- const activeAgents = data.agents.filter((a) => a.status === "ACTIVE").length;
438
- const completedRuns = data.runs.filter((r) => r.status === "COMPLETED").length;
439
- const failedRuns = data.runs.filter((r) => r.status === "FAILED").length;
440
- const totalTokens = data.runs.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
441
- const totalCost = data.runs.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
442
- const activeTools = data.tools.filter((t) => t.status === "ACTIVE").length;
443
- const visualizationItems = createAgentVisualizationItems(data.runs);
444
- const lines = [
445
- "# Agent Console Dashboard",
446
- "",
447
- "> AI agent operations overview",
448
- "",
449
- "## Summary",
450
- "",
451
- "| Metric | Value |",
452
- "|--------|-------|",
453
- `| Total Agents | ${data.summary.totalAgents} |`,
454
- `| Active Agents | ${activeAgents} |`,
455
- `| Total Runs | ${data.summary.totalRuns} |`,
456
- `| Completed Runs | ${completedRuns} |`,
457
- `| Failed Runs | ${failedRuns} |`,
458
- `| Total Tokens | ${totalTokens.toLocaleString()} |`,
459
- `| Total Cost | $${totalCost.toFixed(4)} |`,
460
- `| Total Tools | ${data.summary.totalTools} |`,
461
- `| Active Tools | ${activeTools} |`,
462
- "",
463
- "## Agents",
464
- ""
465
- ];
466
- if (data.agents.length === 0) {
467
- lines.push("_No agents configured._");
468
- } else {
469
- lines.push("| Agent | Model | Status | Description |");
470
- lines.push("|-------|-------|--------|-------------|");
471
- for (const agent of data.agents.slice(0, 5)) {
472
- lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
473
- }
474
- if (data.agents.length > 5) {
475
- lines.push(`| ... | ... | ... | _${data.summary.totalAgents - 5} more_ |`);
476
- }
477
- }
478
- lines.push("");
479
- lines.push("## Recent Runs");
480
- lines.push("");
481
- if (data.runs.length === 0) {
482
- lines.push("_No runs yet._");
483
- } else {
484
- lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
485
- lines.push("|--------|-------|--------|----------|--------|------|");
486
- for (const run of data.runs.slice(0, 5)) {
487
- lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
488
- }
489
- if (data.runs.length > 5) {
490
- lines.push(`| ... | ... | ... | ... | ... | _${data.summary.totalRuns - 5} more_ |`);
491
- }
492
- }
493
- lines.push("");
494
- lines.push("## Visualization Overview");
495
- lines.push("");
496
- for (const item of visualizationItems) {
497
- lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
498
- }
499
- lines.push("");
500
- lines.push("## Tools");
501
- lines.push("");
502
- const toolsByCategory = {};
503
- for (const tool of data.tools) {
504
- const cat = tool.category;
505
- if (!toolsByCategory[cat])
506
- toolsByCategory[cat] = [];
507
- toolsByCategory[cat].push(tool);
508
- }
509
- if (Object.keys(toolsByCategory).length === 0) {
510
- lines.push("_No tools registered._");
511
- } else {
512
- lines.push("| Category | Tools | Active |");
513
- lines.push("|----------|-------|--------|");
514
- for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
515
- const active = tools.filter((t) => t.status === "ACTIVE").length;
516
- lines.push(`| ${category} | ${tools.length} | ${active} |`);
517
- }
518
- }
519
- return {
520
- mimeType: "text/markdown",
521
- body: lines.join(`
522
- `)
523
- };
524
- }
525
- };
526
-
527
- // src/ui/renderers/run-list.markdown.ts
528
- import {
529
- AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID2,
530
- createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers2
531
- } from "@contractspec/example.agent-console/shared";
532
- function formatDuration2(ms) {
533
- if (ms < 1000)
534
- return `${ms}ms`;
535
- if (ms < 60000)
536
- return `${(ms / 1000).toFixed(1)}s`;
537
- return `${(ms / 60000).toFixed(1)}m`;
538
- }
539
- var runListMarkdownRenderer = {
540
- target: "markdown",
541
- render: async (desc, ctx) => {
542
- if (desc.source.type !== "component" || desc.source.componentKey !== "RunListView") {
543
- throw new Error("runListMarkdownRenderer: not RunListView");
544
- }
545
- const data = Array.isArray(ctx?.data) ? { items: ctx.data, total: ctx.data.length, hasMore: false } : await createAgentConsoleDemoHandlers2({
546
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2
547
- }).listRuns({
548
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2,
549
- limit: 20,
550
- offset: 0
551
- });
552
- const lines = [
553
- `# ${desc.meta.description ?? "Agent Runs"}`,
554
- "",
555
- `> ${desc.meta.key} v${desc.meta.version}`,
556
- "",
557
- `**Total Runs:** ${data.total}`,
558
- "",
559
- "## Recent Runs",
560
- "",
561
- "| ID | Agent | Status | Duration | Tokens | Cost |",
562
- "| --- | --- | --- | --- | --- | --- |"
563
- ];
564
- for (const run of data.items.slice(0, 10)) {
565
- lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration2(run.durationMs) : "-"} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? "-"} |`);
566
- }
567
- return {
568
- mimeType: "text/markdown",
569
- body: lines.join(`
570
- `)
571
- };
572
- }
573
- };
574
-
575
- // src/ui/renderers/tool-registry.markdown.ts
576
- import {
577
- AGENT_CONSOLE_DEMO_ORGANIZATION_ID as AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
578
- AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID3,
579
- createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers3
580
- } from "@contractspec/example.agent-console/shared";
581
- var toolRegistryMarkdownRenderer = {
582
- target: "markdown",
583
- render: async (desc, ctx) => {
584
- if (desc.source.type !== "component" || desc.source.componentKey !== "ToolRegistryView") {
585
- throw new Error("toolRegistryMarkdownRenderer: not ToolRegistryView");
586
- }
587
- const data = Array.isArray(ctx?.data) ? {
588
- items: ctx.data,
589
- total: ctx.data.length,
590
- hasMore: false
591
- } : await createAgentConsoleDemoHandlers3({
592
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3
593
- }).listTools({
594
- projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3,
595
- organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
596
- limit: 50,
597
- offset: 0
598
- });
599
- const lines = [
600
- `# ${desc.meta.description ?? "Tool Registry"}`,
601
- "",
602
- `> ${desc.meta.key} v${desc.meta.version}`,
603
- "",
604
- `**Total Tools:** ${data.total}`,
605
- ""
606
- ];
607
- const byCategory = {};
608
- for (const tool of data.items) {
609
- const cat = tool.category;
610
- if (!byCategory[cat])
611
- byCategory[cat] = [];
612
- byCategory[cat].push(tool);
613
- }
614
- for (const [category, tools] of Object.entries(byCategory).sort()) {
615
- lines.push(`## ${category} (${tools.length})`);
616
- lines.push("");
617
- for (const tool of tools) {
618
- const statusIcon = tool.status === "ACTIVE" ? "✅" : tool.status === "DEPRECATED" ? "⚠️" : "❌";
619
- lines.push(`### ${statusIcon} ${tool.name} v${tool.version}`);
620
- lines.push("");
621
- lines.push(`> \`${tool.id}\``);
622
- lines.push("");
623
- if (tool.description) {
624
- lines.push(tool.description);
625
- lines.push("");
626
- }
627
- }
628
- }
629
- return {
630
- mimeType: "text/markdown",
631
- body: lines.join(`
632
- `)
633
- };
634
- }
635
- };
636
- export {
637
- toolRegistryMarkdownRenderer,
638
- runListMarkdownRenderer,
639
- agentListReactRenderer,
640
- agentListMarkdownRenderer,
641
- agentDashboardMarkdownRenderer
642
- };
1
+ import{defineVisualization as P,VisualizationRegistry as u}from"@contractspec/lib.contracts-spec/visualizations";var z={key:"agent.run.list",version:"1.0.0"},B={version:"1.0.0",domain:"ai-ops",stability:"experimental",owners:["@example.agent-console"],tags:["agent-console","visualization","operations"]},G=P({meta:{...B,key:"agent-console.visualization.run-status",title:"Run Status Breakdown",description:"Distribution of run outcomes across the current sample.",goal:"Make operational success and failure mix visible at a glance.",context:"Agent operations overview."},source:{primary:z,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"runs",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number"}],table:{caption:"Run counts by status."}}}),V=P({meta:{...B,key:"agent-console.visualization.run-activity",title:"Recent Run Activity",description:"Daily run volume across the current sample.",goal:"Show whether agent activity is rising or slowing down.",context:"Operations trend monitoring."},source:{primary:z,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["runs"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number",color:"#0f766e"}],table:{caption:"Daily run counts."}}}),h=P({meta:{...B,key:"agent-console.visualization.run-efficiency",title:"Duration vs Tokens",description:"Scatter chart comparing token consumption and runtime.",goal:"Reveal outlier runs that are slow relative to their token usage.",context:"Operational performance diagnostics."},source:{primary:z,resultPath:"data"},visualization:{kind:"cartesian",variant:"scatter",xDimension:"totalTokens",yMeasures:["durationMs"],dimensions:[{key:"totalTokens",label:"Total Tokens",dataPath:"totalTokens",type:"number"}],measures:[{key:"durationMs",label:"Duration",dataPath:"durationMs",format:"duration",color:"#7c3aed"},{key:"estimatedCostUsd",label:"Cost",dataPath:"estimatedCostUsd",format:"currency"}],series:[{key:"runs",label:"Runs",measure:"durationMs",type:"scatter",color:"#7c3aed"}],table:{caption:"Run duration versus token usage."}}}),b=[G,V,h],Wf=new u([...b]),Xf=b.map((f)=>({key:f.meta.key,version:f.meta.version}));function m(f){if(!f)return"unknown";return f.toISOString().slice(0,10)}function L(f){let Q=new Map,w=new Map;for(let k of f)Q.set(k.status,(Q.get(k.status)??0)+1),w.set(m(k.startedAt??k.queuedAt),(w.get(m(k.startedAt??k.queuedAt))??0)+1);return[{key:"run-status",spec:G,data:{data:Array.from(Q.entries()).map(([k,M])=>({status:k,runs:M}))},title:"Run Status Breakdown",description:"Completed, failed, running, and cancelled runs in the sample.",height:260},{key:"run-activity",spec:V,data:{data:Array.from(w.entries()).sort(([k],[M])=>k.localeCompare(M)).map(([k,M])=>({day:k,runs:M}))},title:"Recent Run Activity",description:"Daily run volume derived from run start times."},{key:"run-efficiency",spec:h,data:{data:f.filter((k)=>typeof k.durationMs==="number").map((k)=>({totalTokens:k.totalTokens,durationMs:k.durationMs??0,estimatedCostUsd:k.estimatedCostUsd}))},title:"Duration vs Tokens",description:"Operational scatter plot for spotting inefficient runs."}]}import{useTemplateRuntime as O}from"@contractspec/lib.example-shared-ui";import{useCallback as A,useEffect as C,useMemo as j,useState as U}from"react";function y(f={}){let{handlers:Q,projectId:w}=O(),{agent:k}=Q,[M,K]=U(null),[X,W]=U(!0),[R,J]=U(null),[r,H]=U(1),q=A(async()=>{W(!0),J(null);try{let Y=await k.listAgents({projectId:w,search:f.search,status:f.status==="all"?void 0:f.status,limit:f.limit??20,offset:(r-1)*(f.limit??20)});K(Y)}catch(Y){J(Y instanceof Error?Y:Error("Unknown error"))}finally{W(!1)}},[k,w,f.search,f.status,f.limit,r]);C(()=>{q()},[q]);let v=j(()=>{if(!M)return null;return{total:M.total,active:M.items.filter((Y)=>Y.status==="ACTIVE").length,paused:M.items.filter((Y)=>Y.status==="PAUSED").length,draft:M.items.filter((Y)=>Y.status==="DRAFT").length}},[M]);return{data:M,loading:X,error:R,stats:v,page:r,refetch:q,nextPage:()=>H((Y)=>Y+1),prevPage:()=>r>1&&H((Y)=>Y-1)}}import{AGENT_CONSOLE_DEMO_ORGANIZATION_ID as S,AGENT_CONSOLE_DEMO_PROJECT_ID as I,createAgentConsoleDemoHandlers as _}from"@contractspec/example.agent-console/shared";var E={target:"markdown",render:async(f,Q)=>{if(f.source.type!=="component"||f.source.componentKey!=="AgentListView")throw Error("agentListMarkdownRenderer: not AgentListView");let w=Array.isArray(Q?.data)?{items:Q.data,total:Q.data.length,hasMore:!1}:await _({projectId:I}).listAgents({projectId:I,organizationId:S,limit:50,offset:0}),k=[`# ${f.meta.description??"Agent List"}`,"",`> ${f.meta.key} v${f.meta.version}`,"",`**Total Agents:** ${w.total}`,"","## Agents",""],M={};for(let K of w.items){let X=K.status;if(M[X])M[X].push(K);else M[X]=[K]}for(let[K,X]of Object.entries(M)){k.push(`### ${K} (${X.length})`),k.push("");for(let W of X)if(k.push(`- **${W.name}** (${W.modelProvider}/${W.modelName})`),W.description)k.push(` > ${W.description}`);k.push("")}return{mimeType:"text/markdown",body:k.join(`
2
+ `)}}};import{Button as x,EmptyState as d,EntityCard as g,ErrorState as i,LoaderBlock as o,StatCard as Z,StatCardGroup as l,StatusChip as n}from"@contractspec/lib.design-system";import{jsx as $,jsxs as F}from"react/jsx-runtime";function c(f){switch(f){case"ACTIVE":return"success";case"PAUSED":case"DRAFT":return"warning";case"ARCHIVED":return"neutral";default:return"neutral"}}function D(){let{data:f,loading:Q,error:w,stats:k,refetch:M}=y();if(Q&&!f)return $(o,{label:"Loading agents..."});if(w)return $(i,{title:"Failed to load agents",description:w.message,onRetry:M,retryLabel:"Retry"});if(!f?.items.length)return $(d,{title:"No agents yet",description:"Create your first AI agent to get started."});return F("div",{className:"space-y-6",children:[k&&F(l,{children:[$(Z,{label:"Total Agents",value:k.total}),$(Z,{label:"Active",value:k.active}),$(Z,{label:"Paused",value:k.paused}),$(Z,{label:"Draft",value:k.draft})]}),F("div",{className:"flex items-center justify-between",children:[$("h3",{className:"font-semibold text-lg",children:"Agents"}),$(x,{onPress:()=>alert("Create Agent clicked!"),children:"Create Agent"})]}),$("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:f.items.map((K)=>$(g,{cardTitle:K.name,cardSubtitle:K.modelName,meta:$("p",{className:"text-muted-foreground text-sm",children:K.description}),chips:$(n,{tone:c(K.status),label:K.status}),footer:F("span",{className:"text-muted-foreground text-xs",children:["Created ",K.createdAt.toLocaleDateString()]}),onClick:()=>alert(`View agent: ${K.name}`)},K.id))})]})}import{jsx as a}from"react/jsx-runtime";var e={target:"react",render:async(f)=>{if(f.source.type!=="component")throw Error("AgentListRenderer: expected component source");if(f.source.componentKey!=="AgentListView")throw Error(`AgentListRenderer: unknown component ${f.source.componentKey}`);return a(D,{})}};import{getFallbackAgentConsoleDashboardData as t}from"@contractspec/example.agent-console/shared";function s(f){if(f<1000)return`${f}ms`;if(f<60000)return`${(f/1000).toFixed(1)}s`;return`${(f/60000).toFixed(1)}m`}var ff={target:"markdown",render:async(f,Q)=>{if(f.source.type!=="component"||f.source.componentKey!=="AgentConsoleDashboard")throw Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");let w=Q?.data??await t(),k=w.agents.filter((q)=>q.status==="ACTIVE").length,M=w.runs.filter((q)=>q.status==="COMPLETED").length,K=w.runs.filter((q)=>q.status==="FAILED").length,X=w.runs.reduce((q,v)=>q+(v.totalTokens??0),0),W=w.runs.reduce((q,v)=>q+(v.estimatedCostUsd??0),0),R=w.tools.filter((q)=>q.status==="ACTIVE").length,J=L(w.runs),r=["# Agent Console Dashboard","","> AI agent operations overview","","## Summary","","| Metric | Value |","|--------|-------|",`| Total Agents | ${w.summary.totalAgents} |`,`| Active Agents | ${k} |`,`| Total Runs | ${w.summary.totalRuns} |`,`| Completed Runs | ${M} |`,`| Failed Runs | ${K} |`,`| Total Tokens | ${X.toLocaleString()} |`,`| Total Cost | $${W.toFixed(4)} |`,`| Total Tools | ${w.summary.totalTools} |`,`| Active Tools | ${R} |`,"","## Agents",""];if(w.agents.length===0)r.push("_No agents configured._");else{r.push("| Agent | Model | Status | Description |"),r.push("|-------|-------|--------|-------------|");for(let q of w.agents.slice(0,5))r.push(`| ${q.name} | ${q.modelProvider}/${q.modelName} | ${q.status} | ${q.description??"-"} |`);if(w.agents.length>5)r.push(`| ... | ... | ... | _${w.summary.totalAgents-5} more_ |`)}if(r.push(""),r.push("## Recent Runs"),r.push(""),w.runs.length===0)r.push("_No runs yet._");else{r.push("| Run ID | Agent | Status | Duration | Tokens | Cost |"),r.push("|--------|-------|--------|----------|--------|------|");for(let q of w.runs.slice(0,5))r.push(`| ${q.id.slice(-8)} | ${q.agentName} | ${q.status} | ${q.durationMs?s(q.durationMs):"-"} | ${q.totalTokens??0} | $${(q.estimatedCostUsd??0).toFixed(4)} |`);if(w.runs.length>5)r.push(`| ... | ... | ... | ... | ... | _${w.summary.totalRuns-5} more_ |`)}r.push(""),r.push("## Visualization Overview"),r.push("");for(let q of J)r.push(`- **${q.title}** via \`${q.spec.meta.key}\``);r.push(""),r.push("## Tools"),r.push("");let H={};for(let q of w.tools){let v=q.category;if(!H[v])H[v]=[];H[v].push(q)}if(Object.keys(H).length===0)r.push("_No tools registered._");else{r.push("| Category | Tools | Active |"),r.push("|----------|-------|--------|");for(let[q,v]of Object.entries(H).sort()){let Y=v.filter((p)=>p.status==="ACTIVE").length;r.push(`| ${q} | ${v.length} | ${Y} |`)}}return{mimeType:"text/markdown",body:r.join(`
3
+ `)}}};import{AGENT_CONSOLE_DEMO_PROJECT_ID as N,createAgentConsoleDemoHandlers as kf}from"@contractspec/example.agent-console/shared";function wf(f){if(f<1000)return`${f}ms`;if(f<60000)return`${(f/1000).toFixed(1)}s`;return`${(f/60000).toFixed(1)}m`}var qf={target:"markdown",render:async(f,Q)=>{if(f.source.type!=="component"||f.source.componentKey!=="RunListView")throw Error("runListMarkdownRenderer: not RunListView");let w=Array.isArray(Q?.data)?{items:Q.data,total:Q.data.length,hasMore:!1}:await kf({projectId:N}).listRuns({projectId:N,limit:20,offset:0}),k=[`# ${f.meta.description??"Agent Runs"}`,"",`> ${f.meta.key} v${f.meta.version}`,"",`**Total Runs:** ${w.total}`,"","## Recent Runs","","| ID | Agent | Status | Duration | Tokens | Cost |","| --- | --- | --- | --- | --- | --- |"];for(let M of w.items.slice(0,10))k.push(`| ${M.id.slice(-8)} | ${M.agentName} | ${M.status} | ${M.durationMs?wf(M.durationMs):"-"} | ${M.totalTokens} | $${M.estimatedCostUsd?.toFixed(4)??"-"} |`);return{mimeType:"text/markdown",body:k.join(`
4
+ `)}}};import{AGENT_CONSOLE_DEMO_ORGANIZATION_ID as Mf,AGENT_CONSOLE_DEMO_PROJECT_ID as T,createAgentConsoleDemoHandlers as rf}from"@contractspec/example.agent-console/shared";var Kf={target:"markdown",render:async(f,Q)=>{if(f.source.type!=="component"||f.source.componentKey!=="ToolRegistryView")throw Error("toolRegistryMarkdownRenderer: not ToolRegistryView");let w=Array.isArray(Q?.data)?{items:Q.data,total:Q.data.length,hasMore:!1}:await rf({projectId:T}).listTools({projectId:T,organizationId:Mf,limit:50,offset:0}),k=[`# ${f.meta.description??"Tool Registry"}`,"",`> ${f.meta.key} v${f.meta.version}`,"",`**Total Tools:** ${w.total}`,""],M={};for(let K of w.items){let X=K.category;if(!M[X])M[X]=[];M[X].push(K)}for(let[K,X]of Object.entries(M).sort()){k.push(`## ${K} (${X.length})`),k.push("");for(let W of X){let R=W.status==="ACTIVE"?"✅":W.status==="DEPRECATED"?"⚠️":"❌";if(k.push(`### ${R} ${W.name} v${W.version}`),k.push(""),k.push(`> \`${W.id}\``),k.push(""),W.description)k.push(W.description),k.push("")}}return{mimeType:"text/markdown",body:k.join(`
5
+ `)}}};export{Kf as toolRegistryMarkdownRenderer,qf as runListMarkdownRenderer,e as agentListReactRenderer,E as agentListMarkdownRenderer,ff as agentDashboardMarkdownRenderer};