@contractspec/example.agent-console 3.7.7 → 3.8.4

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 (191) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +3 -1
  3. package/CHANGELOG.md +57 -0
  4. package/README.md +46 -9
  5. package/dist/agent/agent.handler.d.ts +3 -0
  6. package/dist/agent/agent.handler.js +730 -1
  7. package/dist/agent/index.js +73 -72
  8. package/dist/agent.feature.js +179 -0
  9. package/dist/browser/agent/agent.handler.js +730 -1
  10. package/dist/browser/agent/index.js +73 -72
  11. package/dist/browser/agent.feature.js +179 -0
  12. package/dist/browser/docs/agent-console.docblock.js +11 -8
  13. package/dist/browser/docs/index.js +11 -8
  14. package/dist/browser/example.js +2 -3
  15. package/dist/browser/handlers/agent.handlers.js +1883 -2
  16. package/dist/browser/handlers/index.js +2142 -8
  17. package/dist/browser/index.js +3347 -2433
  18. package/dist/browser/presentations/index.js +49 -49
  19. package/dist/browser/run/index.js +818 -812
  20. package/dist/browser/run/run.handler.js +666 -1
  21. package/dist/browser/shared/index.js +293 -1
  22. package/dist/browser/shared/mock-runs.js +5 -0
  23. package/dist/browser/tool/index.js +331 -331
  24. package/dist/browser/tool/tool.handler.js +479 -3
  25. package/dist/browser/ui/AgentDashboard.js +1204 -319
  26. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  27. package/dist/browser/ui/AgentRunList.js +359 -127
  28. package/dist/browser/ui/hooks/index.js +468 -18
  29. package/dist/browser/ui/hooks/useAgentMutations.js +443 -8
  30. package/dist/browser/ui/hooks/useRunList.js +25 -10
  31. package/dist/browser/ui/index.js +1293 -390
  32. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  33. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  34. package/dist/browser/ui/renderers/index.js +245 -49
  35. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  36. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  37. package/dist/browser/ui/views/RunDataTable.js +326 -0
  38. package/dist/browser/ui/views/RunListView.js +359 -127
  39. package/dist/browser/ui/views/index.js +406 -174
  40. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  41. package/dist/browser/ui/views/run-list.shared.js +177 -0
  42. package/dist/browser/visualizations/catalog.js +134 -0
  43. package/dist/browser/visualizations/index.js +187 -0
  44. package/dist/browser/visualizations/selectors.js +181 -0
  45. package/dist/docs/agent-console.docblock.js +11 -8
  46. package/dist/docs/index.js +11 -8
  47. package/dist/example.js +2 -3
  48. package/dist/example.test.d.ts +1 -0
  49. package/dist/handlers/agent.handlers.d.ts +2 -0
  50. package/dist/handlers/agent.handlers.js +1883 -2
  51. package/dist/handlers/index.d.ts +1 -3
  52. package/dist/handlers/index.js +2142 -8
  53. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +3347 -2433
  56. package/dist/node/agent/agent.handler.js +730 -1
  57. package/dist/node/agent/index.js +73 -72
  58. package/dist/node/agent.feature.js +179 -0
  59. package/dist/node/docs/agent-console.docblock.js +11 -8
  60. package/dist/node/docs/index.js +11 -8
  61. package/dist/node/example.js +2 -3
  62. package/dist/node/handlers/agent.handlers.js +1883 -2
  63. package/dist/node/handlers/index.js +2142 -8
  64. package/dist/node/index.js +3347 -2433
  65. package/dist/node/presentations/index.js +49 -49
  66. package/dist/node/run/index.js +818 -812
  67. package/dist/node/run/run.handler.js +666 -1
  68. package/dist/node/shared/index.js +293 -1
  69. package/dist/node/shared/mock-runs.js +5 -0
  70. package/dist/node/tool/index.js +331 -331
  71. package/dist/node/tool/tool.handler.js +479 -3
  72. package/dist/node/ui/AgentDashboard.js +1204 -319
  73. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  74. package/dist/node/ui/AgentRunList.js +359 -127
  75. package/dist/node/ui/hooks/index.js +468 -18
  76. package/dist/node/ui/hooks/useAgentMutations.js +443 -8
  77. package/dist/node/ui/hooks/useRunList.js +25 -10
  78. package/dist/node/ui/index.js +1293 -390
  79. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  80. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  81. package/dist/node/ui/renderers/index.js +245 -49
  82. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  83. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  84. package/dist/node/ui/views/RunDataTable.js +326 -0
  85. package/dist/node/ui/views/RunListView.js +359 -127
  86. package/dist/node/ui/views/index.js +406 -174
  87. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  88. package/dist/node/ui/views/run-list.shared.js +177 -0
  89. package/dist/node/visualizations/catalog.js +134 -0
  90. package/dist/node/visualizations/index.js +187 -0
  91. package/dist/node/visualizations/selectors.js +181 -0
  92. package/dist/presentations/index.js +49 -49
  93. package/dist/proof/index.d.ts +2 -0
  94. package/dist/proof/meetup-proof.d.ts +10 -0
  95. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  96. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  97. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  98. package/dist/proof/meetup-proof.test.d.ts +1 -0
  99. package/dist/run/index.js +818 -812
  100. package/dist/run/run.handler.d.ts +4 -0
  101. package/dist/run/run.handler.js +666 -1
  102. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  103. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  104. package/dist/shared/demo-runtime.d.ts +8 -0
  105. package/dist/shared/demo-runtime.test.d.ts +1 -0
  106. package/dist/shared/index.d.ts +3 -0
  107. package/dist/shared/index.js +293 -1
  108. package/dist/shared/mock-runs.d.ts +4 -0
  109. package/dist/shared/mock-runs.js +5 -0
  110. package/dist/tool/index.js +331 -331
  111. package/dist/tool/tool.handler.d.ts +4 -1
  112. package/dist/tool/tool.handler.js +479 -3
  113. package/dist/ui/AgentDashboard.js +1204 -319
  114. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  115. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  116. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  117. package/dist/ui/AgentRunList.js +359 -127
  118. package/dist/ui/hooks/index.js +468 -18
  119. package/dist/ui/hooks/useAgentMutations.js +443 -8
  120. package/dist/ui/hooks/useRunList.d.ts +8 -2
  121. package/dist/ui/hooks/useRunList.js +25 -10
  122. package/dist/ui/index.js +1293 -390
  123. package/dist/ui/renderers/agent-list.markdown.d.ts +1 -1
  124. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  125. package/dist/ui/renderers/agent-list.renderer.d.ts +1 -1
  126. package/dist/ui/renderers/dashboard.markdown.d.ts +1 -1
  127. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  128. package/dist/ui/renderers/index.js +245 -49
  129. package/dist/ui/renderers/run-list.markdown.d.ts +1 -1
  130. package/dist/ui/renderers/run-list.markdown.js +9 -4
  131. package/dist/ui/renderers/tool-registry.markdown.d.ts +2 -2
  132. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  133. package/dist/ui/views/RunDataTable.d.ts +18 -0
  134. package/dist/ui/views/RunDataTable.js +327 -0
  135. package/dist/ui/views/RunListView.js +359 -127
  136. package/dist/ui/views/index.js +406 -174
  137. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  138. package/dist/ui/views/run-data-table.columns.js +272 -0
  139. package/dist/ui/views/run-list.shared.d.ts +14 -0
  140. package/dist/ui/views/run-list.shared.js +178 -0
  141. package/dist/visualizations/catalog.d.ts +10 -0
  142. package/dist/visualizations/catalog.js +135 -0
  143. package/dist/visualizations/index.d.ts +2 -0
  144. package/dist/visualizations/index.js +188 -0
  145. package/dist/visualizations/selectors.d.ts +3 -0
  146. package/dist/visualizations/selectors.js +182 -0
  147. package/dist/visualizations/selectors.test.d.ts +1 -0
  148. package/package.json +114 -11
  149. package/proofs/agent-console-meetup.replay.json +220 -0
  150. package/src/agent/agent.handler.ts +18 -1
  151. package/src/agent.feature.ts +3 -0
  152. package/src/docs/agent-console.docblock.ts +11 -8
  153. package/src/example.test.ts +75 -0
  154. package/src/example.ts +2 -3
  155. package/src/handlers/agent.handlers.ts +55 -2
  156. package/src/handlers/index.ts +18 -2
  157. package/src/handlers/mock-handlers.test.ts +77 -0
  158. package/src/index.ts +2 -0
  159. package/src/proof/index.ts +2 -0
  160. package/src/proof/meetup-proof.runtime.ts +196 -0
  161. package/src/proof/meetup-proof.scenario.ts +99 -0
  162. package/src/proof/meetup-proof.suite.ts +29 -0
  163. package/src/proof/meetup-proof.test.ts +28 -0
  164. package/src/proof/meetup-proof.ts +130 -0
  165. package/src/run/run.handler.ts +17 -1
  166. package/src/shared/demo-dashboard-data.ts +58 -0
  167. package/src/shared/demo-runtime-seed.ts +139 -0
  168. package/src/shared/demo-runtime.test.ts +169 -0
  169. package/src/shared/demo-runtime.ts +260 -0
  170. package/src/shared/index.ts +11 -0
  171. package/src/shared/mock-runs.ts +5 -0
  172. package/src/tool/tool.handler.ts +21 -4
  173. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  174. package/src/ui/AgentDashboard.tsx +4 -1
  175. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  176. package/src/ui/hooks/useAgentMutations.ts +19 -11
  177. package/src/ui/hooks/useRunList.ts +41 -9
  178. package/src/ui/renderers/agent-list.markdown.ts +32 -13
  179. package/src/ui/renderers/agent-list.renderer.tsx +1 -1
  180. package/src/ui/renderers/dashboard.markdown.ts +38 -43
  181. package/src/ui/renderers/run-list.markdown.ts +17 -9
  182. package/src/ui/renderers/tool-registry.markdown.ts +22 -10
  183. package/src/ui/views/RunDataTable.tsx +74 -0
  184. package/src/ui/views/RunListView.tsx +37 -111
  185. package/src/ui/views/run-data-table.columns.tsx +102 -0
  186. package/src/ui/views/run-list.shared.tsx +139 -0
  187. package/src/visualizations/catalog.ts +132 -0
  188. package/src/visualizations/index.ts +2 -0
  189. package/src/visualizations/selectors.test.ts +12 -0
  190. package/src/visualizations/selectors.ts +70 -0
  191. package/tsdown.config.js +17 -0
@@ -1,3 +1,553 @@
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/shared/mock-agents.ts
180
+ var MOCK_AGENTS = [
181
+ {
182
+ id: "agent-1",
183
+ organizationId: "demo-org",
184
+ name: "Customer Support Bot",
185
+ slug: "customer-support-bot",
186
+ description: "Handles tier-1 customer inquiries and routes complex issues.",
187
+ status: "ACTIVE",
188
+ modelProvider: "OPENAI",
189
+ modelName: "gpt-4o-mini",
190
+ modelConfig: { temperature: 0.7 },
191
+ systemPrompt: "You are a helpful customer support assistant.",
192
+ toolChoice: "auto",
193
+ maxIterations: 10,
194
+ timeoutMs: 120000,
195
+ version: "1.0.0",
196
+ tags: ["support", "tier-1"],
197
+ createdAt: new Date("2024-01-15T10:00:00Z"),
198
+ updatedAt: new Date("2024-03-20T14:30:00Z")
199
+ },
200
+ {
201
+ id: "agent-2",
202
+ organizationId: "demo-org",
203
+ name: "Code Review Assistant",
204
+ slug: "code-review-assistant",
205
+ description: "Reviews pull requests and provides actionable feedback.",
206
+ status: "ACTIVE",
207
+ modelProvider: "ANTHROPIC",
208
+ modelName: "claude-sonnet-4-20250514",
209
+ modelConfig: { temperature: 0.3 },
210
+ systemPrompt: "You are a code review expert.",
211
+ toolChoice: "auto",
212
+ maxIterations: 15,
213
+ timeoutMs: 180000,
214
+ version: "2.1.0",
215
+ tags: ["code", "review", "dev"],
216
+ createdAt: new Date("2024-02-10T09:00:00Z"),
217
+ updatedAt: new Date("2024-04-05T11:15:00Z")
218
+ },
219
+ {
220
+ id: "agent-3",
221
+ organizationId: "demo-org",
222
+ name: "Data Analyst",
223
+ slug: "data-analyst",
224
+ description: "Queries databases and generates insights from data.",
225
+ status: "PAUSED",
226
+ modelProvider: "OPENAI",
227
+ modelName: "gpt-4o",
228
+ modelConfig: { temperature: 0.5 },
229
+ systemPrompt: "You are a data analyst expert in SQL and analytics.",
230
+ toolChoice: "required",
231
+ maxIterations: 20,
232
+ timeoutMs: 300000,
233
+ version: "1.2.0",
234
+ tags: ["data", "analytics", "sql"],
235
+ createdAt: new Date("2024-03-01T08:00:00Z"),
236
+ updatedAt: new Date("2024-04-10T16:45:00Z")
237
+ },
238
+ {
239
+ id: "agent-4",
240
+ organizationId: "demo-org",
241
+ name: "Meeting Scheduler",
242
+ slug: "meeting-scheduler",
243
+ description: "Schedules meetings and manages calendar conflicts.",
244
+ status: "DRAFT",
245
+ modelProvider: "GOOGLE",
246
+ modelName: "gemini-2.0-flash",
247
+ modelConfig: { temperature: 0.2 },
248
+ systemPrompt: "You help schedule and organize meetings efficiently.",
249
+ toolChoice: "auto",
250
+ maxIterations: 5,
251
+ timeoutMs: 60000,
252
+ version: "0.1.0",
253
+ tags: ["calendar", "scheduling"],
254
+ createdAt: new Date("2024-04-01T12:00:00Z"),
255
+ updatedAt: new Date("2024-04-01T12:00:00Z")
256
+ }
257
+ ];
258
+
259
+ // src/shared/mock-tools.ts
260
+ var MOCK_TOOLS = [
261
+ {
262
+ id: "tool-1",
263
+ organizationId: "demo-org",
264
+ name: "Web Search",
265
+ slug: "web-search",
266
+ description: "Search the web for real-time information using Brave API.",
267
+ category: "RETRIEVAL",
268
+ status: "ACTIVE",
269
+ parametersSchema: {
270
+ type: "object",
271
+ properties: {
272
+ query: { type: "string", description: "Search query" },
273
+ numResults: { type: "number", default: 10 }
274
+ },
275
+ required: ["query"]
276
+ },
277
+ outputSchema: { type: "array", items: { type: "object" } },
278
+ implementationType: "http",
279
+ implementationConfig: {
280
+ url: "https://api.brave.com/search",
281
+ method: "GET"
282
+ },
283
+ maxInvocationsPerMinute: 60,
284
+ timeoutMs: 30000,
285
+ version: "1.0.0",
286
+ tags: ["search", "web"],
287
+ createdAt: new Date("2024-01-01T00:00:00Z"),
288
+ updatedAt: new Date("2024-02-15T10:00:00Z")
289
+ },
290
+ {
291
+ id: "tool-2",
292
+ organizationId: "demo-org",
293
+ name: "SQL Query",
294
+ slug: "sql-query",
295
+ description: "Execute read-only SQL queries against the data warehouse.",
296
+ category: "RETRIEVAL",
297
+ status: "ACTIVE",
298
+ parametersSchema: {
299
+ type: "object",
300
+ properties: {
301
+ query: { type: "string", description: "SQL query" },
302
+ maxRows: { type: "number", default: 100 }
303
+ },
304
+ required: ["query"]
305
+ },
306
+ outputSchema: { type: "object" },
307
+ implementationType: "function",
308
+ implementationConfig: { handler: "executeSqlQuery" },
309
+ maxInvocationsPerMinute: 30,
310
+ timeoutMs: 60000,
311
+ version: "1.1.0",
312
+ tags: ["sql", "database"],
313
+ createdAt: new Date("2024-01-05T00:00:00Z"),
314
+ updatedAt: new Date("2024-03-10T14:00:00Z")
315
+ },
316
+ {
317
+ id: "tool-3",
318
+ organizationId: "demo-org",
319
+ name: "Email Sender",
320
+ slug: "email-sender",
321
+ description: "Send emails via SMTP or API.",
322
+ category: "COMMUNICATION",
323
+ status: "ACTIVE",
324
+ parametersSchema: {
325
+ type: "object",
326
+ properties: {
327
+ to: { type: "string" },
328
+ subject: { type: "string" },
329
+ body: { type: "string" }
330
+ },
331
+ required: ["to", "subject", "body"]
332
+ },
333
+ implementationType: "http",
334
+ implementationConfig: { url: "/api/send-email", method: "POST" },
335
+ maxInvocationsPerMinute: 10,
336
+ timeoutMs: 30000,
337
+ version: "1.0.0",
338
+ tags: ["email", "communication"],
339
+ createdAt: new Date("2024-02-01T00:00:00Z"),
340
+ updatedAt: new Date("2024-02-01T00:00:00Z")
341
+ },
342
+ {
343
+ id: "tool-4",
344
+ organizationId: "demo-org",
345
+ name: "GitHub Integration",
346
+ slug: "github-integration",
347
+ description: "Interact with GitHub repositories, PRs, and issues.",
348
+ category: "INTEGRATION",
349
+ status: "ACTIVE",
350
+ parametersSchema: {
351
+ type: "object",
352
+ properties: {
353
+ action: {
354
+ type: "string",
355
+ enum: ["list_prs", "get_pr", "create_comment"]
356
+ },
357
+ repo: { type: "string" },
358
+ params: { type: "object" }
359
+ },
360
+ required: ["action", "repo"]
361
+ },
362
+ implementationType: "http",
363
+ implementationConfig: { url: "https://api.github.com", auth: "token" },
364
+ maxInvocationsPerMinute: 100,
365
+ timeoutMs: 15000,
366
+ version: "2.0.0",
367
+ tags: ["github", "integration", "code"],
368
+ createdAt: new Date("2024-02-20T00:00:00Z"),
369
+ updatedAt: new Date("2024-04-01T09:00:00Z")
370
+ },
371
+ {
372
+ id: "tool-5",
373
+ organizationId: "demo-org",
374
+ name: "Calculator",
375
+ slug: "calculator",
376
+ description: "Perform mathematical calculations.",
377
+ category: "COMPUTATION",
378
+ status: "ACTIVE",
379
+ parametersSchema: {
380
+ type: "object",
381
+ properties: {
382
+ expression: {
383
+ type: "string",
384
+ description: "Math expression to evaluate"
385
+ }
386
+ },
387
+ required: ["expression"]
388
+ },
389
+ outputSchema: {
390
+ type: "object",
391
+ properties: { result: { type: "number" } }
392
+ },
393
+ implementationType: "function",
394
+ implementationConfig: { handler: "evaluateMath" },
395
+ timeoutMs: 5000,
396
+ version: "1.0.0",
397
+ tags: ["math", "utility"],
398
+ createdAt: new Date("2024-01-10T00:00:00Z"),
399
+ updatedAt: new Date("2024-01-10T00:00:00Z")
400
+ }
401
+ ];
402
+
403
+ // src/shared/mock-runs.ts
404
+ var MOCK_RUNS = [
405
+ {
406
+ id: "run-1",
407
+ organizationId: "demo-org",
408
+ projectId: "demo-project",
409
+ agentId: "agent-1",
410
+ agentName: "Customer Support Bot",
411
+ userId: "user-1",
412
+ sessionId: "session-1",
413
+ input: { message: "How do I reset my password?", context: {} },
414
+ output: { response: "You can reset your password by clicking..." },
415
+ status: "COMPLETED",
416
+ totalTokens: 1250,
417
+ promptTokens: 800,
418
+ completionTokens: 450,
419
+ totalIterations: 3,
420
+ durationMs: 4500,
421
+ estimatedCostUsd: 0.0025,
422
+ queuedAt: new Date("2024-04-15T10:00:00Z"),
423
+ startedAt: new Date("2024-04-15T10:00:01Z"),
424
+ completedAt: new Date("2024-04-15T10:00:05Z"),
425
+ steps: [],
426
+ logs: []
427
+ },
428
+ {
429
+ id: "run-2",
430
+ organizationId: "demo-org",
431
+ projectId: "demo-project",
432
+ agentId: "agent-2",
433
+ agentName: "Code Review Assistant",
434
+ userId: "user-2",
435
+ input: { message: "Review PR #123", context: { prNumber: 123 } },
436
+ status: "IN_PROGRESS",
437
+ totalTokens: 3500,
438
+ promptTokens: 3000,
439
+ completionTokens: 500,
440
+ totalIterations: 5,
441
+ queuedAt: new Date("2024-04-15T10:30:00Z"),
442
+ startedAt: new Date("2024-04-15T10:30:02Z"),
443
+ steps: [],
444
+ logs: []
445
+ },
446
+ {
447
+ id: "run-3",
448
+ organizationId: "demo-org",
449
+ projectId: "demo-project",
450
+ agentId: "agent-1",
451
+ agentName: "Customer Support Bot",
452
+ userId: "user-1",
453
+ input: { message: "What are your business hours?" },
454
+ output: { response: "Our business hours are 9 AM to 5 PM EST..." },
455
+ status: "COMPLETED",
456
+ totalTokens: 800,
457
+ promptTokens: 500,
458
+ completionTokens: 300,
459
+ totalIterations: 2,
460
+ durationMs: 2100,
461
+ estimatedCostUsd: 0.0012,
462
+ queuedAt: new Date("2024-04-15T09:00:00Z"),
463
+ startedAt: new Date("2024-04-15T09:00:01Z"),
464
+ completedAt: new Date("2024-04-15T09:00:03Z"),
465
+ steps: [],
466
+ logs: []
467
+ },
468
+ {
469
+ id: "run-4",
470
+ organizationId: "demo-org",
471
+ projectId: "demo-project",
472
+ agentId: "agent-3",
473
+ agentName: "Data Analyst",
474
+ userId: "user-3",
475
+ input: { message: "Generate sales report for Q1" },
476
+ status: "FAILED",
477
+ errorMessage: "Database connection timeout",
478
+ errorCode: "DB_TIMEOUT",
479
+ totalTokens: 2000,
480
+ promptTokens: 1500,
481
+ completionTokens: 500,
482
+ totalIterations: 8,
483
+ durationMs: 45000,
484
+ queuedAt: new Date("2024-04-14T15:00:00Z"),
485
+ startedAt: new Date("2024-04-14T15:00:05Z"),
486
+ completedAt: new Date("2024-04-14T15:00:50Z"),
487
+ steps: [],
488
+ logs: []
489
+ },
490
+ {
491
+ id: "run-5",
492
+ organizationId: "demo-org",
493
+ projectId: "demo-project",
494
+ agentId: "agent-2",
495
+ agentName: "Code Review Assistant",
496
+ userId: "user-2",
497
+ input: { message: "Review PR #120" },
498
+ output: { response: "Code review complete. 3 suggestions..." },
499
+ status: "COMPLETED",
500
+ totalTokens: 5200,
501
+ promptTokens: 4000,
502
+ completionTokens: 1200,
503
+ totalIterations: 7,
504
+ durationMs: 15000,
505
+ estimatedCostUsd: 0.0156,
506
+ queuedAt: new Date("2024-04-14T11:00:00Z"),
507
+ startedAt: new Date("2024-04-14T11:00:03Z"),
508
+ completedAt: new Date("2024-04-14T11:00:18Z"),
509
+ steps: [],
510
+ logs: []
511
+ }
512
+ ];
513
+
514
+ // src/ui/AgentDashboard.visualizations.tsx
515
+ import {
516
+ VisualizationCard,
517
+ VisualizationGrid
518
+ } from "@contractspec/lib.design-system";
519
+ import { jsxDEV } from "react/jsx-dev-runtime";
520
+ "use client";
521
+ function AgentVisualizationOverview({ runs }) {
522
+ const items = createAgentVisualizationItems(runs);
523
+ return /* @__PURE__ */ jsxDEV("section", {
524
+ className: "space-y-3",
525
+ children: [
526
+ /* @__PURE__ */ jsxDEV("div", {
527
+ children: [
528
+ /* @__PURE__ */ jsxDEV("h3", {
529
+ className: "font-semibold text-lg",
530
+ children: "Operational Visualizations"
531
+ }, undefined, false, undefined, this),
532
+ /* @__PURE__ */ jsxDEV("p", {
533
+ className: "text-muted-foreground text-sm",
534
+ children: "Contract-backed charts derived from recent run activity."
535
+ }, undefined, false, undefined, this)
536
+ ]
537
+ }, undefined, true, undefined, this),
538
+ /* @__PURE__ */ jsxDEV(VisualizationGrid, {
539
+ children: items.map((item) => /* @__PURE__ */ jsxDEV(VisualizationCard, {
540
+ data: item.data,
541
+ description: item.description,
542
+ height: item.height,
543
+ spec: item.spec,
544
+ title: item.title
545
+ }, item.key, false, undefined, this))
546
+ }, undefined, false, undefined, this)
547
+ ]
548
+ }, undefined, true, undefined, this);
549
+ }
550
+
1
551
  // src/ui/hooks/useAgentList.ts
2
552
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
553
  import { useCallback, useEffect, useMemo, useState } from "react";
@@ -54,6 +604,103 @@ function useAgentList(options = {}) {
54
604
  // src/ui/hooks/useAgentMutations.ts
55
605
  import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
56
606
  import { useCallback as useCallback2, useState as useState2 } from "react";
607
+
608
+ // src/shared/demo-runtime-seed.ts
609
+ var AGENT_CONSOLE_DEMO_ORGANIZATION_ID = "demo-org";
610
+ var AGENT_CONSOLE_DEMO_PROJECT_ID = "agent-console-demo";
611
+ function slugify(name) {
612
+ return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
613
+ }
614
+ function cloneAgent(agent) {
615
+ return { ...agent };
616
+ }
617
+ function cloneTool(tool) {
618
+ return { ...tool };
619
+ }
620
+ function cloneRun(run) {
621
+ return { ...run };
622
+ }
623
+ function createDefaultNow() {
624
+ let tick = 0;
625
+ const base = Date.parse("2026-03-20T09:00:00.000Z");
626
+ return () => new Date(base + tick++ * 60000);
627
+ }
628
+ function normalizeProvider(provider) {
629
+ return provider.toLowerCase();
630
+ }
631
+ function normalizeRunStatus(status) {
632
+ return status === "IN_PROGRESS" ? "RUNNING" : status;
633
+ }
634
+ function createSeedState(projectId, organizationId) {
635
+ const agents = MOCK_AGENTS.map((agent) => ({
636
+ id: agent.id,
637
+ projectId,
638
+ organizationId,
639
+ name: agent.name,
640
+ slug: agent.slug,
641
+ description: agent.description,
642
+ modelProvider: normalizeProvider(agent.modelProvider),
643
+ modelName: agent.modelName,
644
+ systemPrompt: agent.systemPrompt,
645
+ temperature: typeof agent.modelConfig?.temperature === "number" ? agent.modelConfig.temperature : 0.4,
646
+ maxTokens: 8192,
647
+ status: agent.status,
648
+ createdAt: agent.createdAt,
649
+ updatedAt: agent.updatedAt
650
+ }));
651
+ const tools = MOCK_TOOLS.map((tool) => ({
652
+ id: tool.id,
653
+ projectId,
654
+ organizationId,
655
+ name: tool.name,
656
+ description: tool.description,
657
+ version: tool.version,
658
+ category: tool.category,
659
+ status: tool.status,
660
+ inputSchema: JSON.stringify(tool.parametersSchema),
661
+ outputSchema: tool.outputSchema ? JSON.stringify(tool.outputSchema) : undefined,
662
+ endpoint: typeof tool.implementationConfig?.url === "string" ? tool.implementationConfig.url : undefined,
663
+ createdAt: tool.createdAt,
664
+ updatedAt: tool.updatedAt
665
+ }));
666
+ const agentNames = new Map(agents.map((agent) => [agent.id, agent.name]));
667
+ const runs = MOCK_RUNS.map((run) => ({
668
+ id: run.id,
669
+ projectId,
670
+ agentId: run.agentId,
671
+ agentName: agentNames.get(run.agentId) ?? run.agentName ?? "Unknown agent",
672
+ status: normalizeRunStatus(run.status),
673
+ input: JSON.stringify(run.input),
674
+ output: run.output ? JSON.stringify(run.output) : undefined,
675
+ totalTokens: run.totalTokens,
676
+ promptTokens: run.promptTokens,
677
+ completionTokens: run.completionTokens,
678
+ estimatedCostUsd: run.estimatedCostUsd ?? 0,
679
+ durationMs: run.durationMs,
680
+ errorMessage: run.errorMessage,
681
+ queuedAt: run.queuedAt,
682
+ startedAt: run.startedAt,
683
+ completedAt: run.completedAt
684
+ }));
685
+ return { agents, tools, runs };
686
+ }
687
+ function summarizeRunMetrics(runs) {
688
+ const totalRuns = runs.length;
689
+ const completedRuns = runs.filter((run) => run.status === "COMPLETED").length;
690
+ const completedDurations = runs.map((run) => run.durationMs).filter((duration) => typeof duration === "number");
691
+ return {
692
+ totalRuns,
693
+ successRate: totalRuns === 0 ? 0 : completedRuns / totalRuns,
694
+ averageDurationMs: completedDurations.length === 0 ? 0 : Math.round(completedDurations.reduce((sum, duration) => sum + duration, 0) / completedDurations.length),
695
+ totalTokens: runs.reduce((sum, run) => sum + run.totalTokens, 0),
696
+ totalCostUsd: runs.reduce((sum, run) => sum + run.estimatedCostUsd, 0)
697
+ };
698
+ }
699
+
700
+ // src/ui/hooks/useAgentMutations.ts
701
+ function normalizeMutationError(error, fallbackMessage) {
702
+ return error instanceof Error ? error : new Error(fallbackMessage);
703
+ }
57
704
  function useAgentMutations(options = {}) {
58
705
  const { handlers, projectId } = useTemplateRuntime2();
59
706
  const { agent } = handlers;
@@ -77,16 +724,16 @@ function useAgentMutations(options = {}) {
77
724
  try {
78
725
  const result = await agent.createAgent(input, {
79
726
  projectId,
80
- organizationId: "demo-org"
727
+ organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
81
728
  });
82
729
  setCreateState({ loading: false, error: null, data: result });
83
730
  options.onSuccess?.();
84
731
  return result;
85
732
  } catch (err) {
86
- const error = err instanceof Error ? err : new Error("Failed to create agent");
733
+ const error = normalizeMutationError(err, "Failed to create agent");
87
734
  setCreateState({ loading: false, error, data: null });
88
735
  options.onError?.(error);
89
- return null;
736
+ throw error;
90
737
  }
91
738
  }, [agent, projectId, options]);
92
739
  const updateAgent = useCallback2(async (input) => {
@@ -97,10 +744,10 @@ function useAgentMutations(options = {}) {
97
744
  options.onSuccess?.();
98
745
  return result;
99
746
  } catch (err) {
100
- const error = err instanceof Error ? err : new Error("Failed to update agent");
747
+ const error = normalizeMutationError(err, "Failed to update agent");
101
748
  setUpdateState({ loading: false, error, data: null });
102
749
  options.onError?.(error);
103
- return null;
750
+ throw error;
104
751
  }
105
752
  }, [agent, options]);
106
753
  const activateAgent = useCallback2(async (agentId) => {
@@ -118,16 +765,19 @@ function useAgentMutations(options = {}) {
118
765
  const result = await agent.executeAgent({
119
766
  agentId: input.agentId,
120
767
  message: input.message,
121
- context: { projectId, organizationId: "demo-org" }
768
+ context: {
769
+ projectId,
770
+ organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
771
+ }
122
772
  });
123
773
  setExecuteState({ loading: false, error: null, data: result });
124
774
  options.onSuccess?.();
125
775
  return result;
126
776
  } catch (err) {
127
- const error = err instanceof Error ? err : new Error("Failed to execute agent");
777
+ const error = normalizeMutationError(err, "Failed to execute agent");
128
778
  setExecuteState({ loading: false, error, data: null });
129
779
  options.onError?.(error);
130
- return null;
780
+ throw error;
131
781
  }
132
782
  }, [agent, projectId, options]);
133
783
  return {
@@ -154,7 +804,10 @@ function useRunList(options = {}) {
154
804
  const [metrics, setMetrics] = useState3(null);
155
805
  const [loading, setLoading] = useState3(true);
156
806
  const [error, setError] = useState3(null);
157
- const [page, setPage] = useState3(1);
807
+ const [internalPageIndex, setInternalPageIndex] = useState3(0);
808
+ const pageSize = options.pageSize ?? options.limit ?? 20;
809
+ const pageIndex = options.pageIndex ?? internalPageIndex;
810
+ const [sort] = options.sorting ?? [];
158
811
  const fetchData = useCallback3(async () => {
159
812
  setLoading(true);
160
813
  setError(null);
@@ -164,14 +817,14 @@ function useRunList(options = {}) {
164
817
  projectId,
165
818
  agentId: options.agentId,
166
819
  status: options.status === "all" ? undefined : options.status,
167
- limit: options.limit ?? 20,
168
- offset: (page - 1) * (options.limit ?? 20)
820
+ sortBy: sort?.id,
821
+ sortDirection: sort ? sort.desc ? "desc" : "asc" : undefined,
822
+ limit: pageSize,
823
+ offset: pageIndex * pageSize
169
824
  }),
170
825
  agent.getRunMetrics({
171
826
  projectId,
172
- agentId: options.agentId,
173
- startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
174
- endDate: new Date
827
+ agentId: options.agentId
175
828
  })
176
829
  ]);
177
830
  setData(runsResult);
@@ -181,26 +834,38 @@ function useRunList(options = {}) {
181
834
  } finally {
182
835
  setLoading(false);
183
836
  }
184
- }, [agent, projectId, options.agentId, options.status, options.limit, page]);
837
+ }, [
838
+ agent,
839
+ pageIndex,
840
+ pageSize,
841
+ projectId,
842
+ options.agentId,
843
+ options.status,
844
+ sort?.desc,
845
+ sort?.id
846
+ ]);
185
847
  useEffect2(() => {
186
848
  fetchData();
187
849
  }, [fetchData]);
850
+ const hasControlledPagination = options.pageIndex !== undefined;
188
851
  return {
189
852
  data,
190
853
  metrics,
191
854
  loading,
192
855
  error,
193
- page,
856
+ page: pageIndex + 1,
857
+ pageIndex,
858
+ pageSize,
194
859
  refetch: fetchData,
195
- nextPage: () => setPage((p) => p + 1),
196
- prevPage: () => page > 1 && setPage((p) => p - 1)
860
+ nextPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => current + 1),
861
+ prevPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => Math.max(0, current - 1))
197
862
  };
198
863
  }
199
864
 
200
865
  // src/ui/modals/AgentActionsModal.tsx
201
866
  import { Button } from "@contractspec/lib.design-system";
202
867
  import { useState as useState4 } from "react";
203
- import { jsxDEV } from "react/jsx-dev-runtime";
868
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
204
869
  "use client";
205
870
  function getStatusColor(status) {
206
871
  switch (status) {
@@ -278,10 +943,10 @@ function AgentActionsModal({
278
943
  };
279
944
  if (!isOpen || !agent)
280
945
  return null;
281
- return /* @__PURE__ */ jsxDEV("div", {
946
+ return /* @__PURE__ */ jsxDEV2("div", {
282
947
  className: "fixed inset-0 z-50 flex items-center justify-center",
283
948
  children: [
284
- /* @__PURE__ */ jsxDEV("div", {
949
+ /* @__PURE__ */ jsxDEV2("div", {
285
950
  className: "absolute inset-0 bg-background/80 backdrop-blur-sm",
286
951
  onClick: handleClose,
287
952
  role: "button",
@@ -292,20 +957,20 @@ function AgentActionsModal({
292
957
  },
293
958
  "aria-label": "Close modal"
294
959
  }, undefined, false, undefined, this),
295
- /* @__PURE__ */ jsxDEV("div", {
960
+ /* @__PURE__ */ jsxDEV2("div", {
296
961
  className: "relative z-10 w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-xl",
297
962
  children: [
298
- /* @__PURE__ */ jsxDEV("div", {
963
+ /* @__PURE__ */ jsxDEV2("div", {
299
964
  className: "mb-4 border-border border-b pb-4",
300
965
  children: [
301
- /* @__PURE__ */ jsxDEV("h2", {
966
+ /* @__PURE__ */ jsxDEV2("h2", {
302
967
  className: "font-semibold text-xl",
303
968
  children: agent.name
304
969
  }, undefined, false, undefined, this),
305
- /* @__PURE__ */ jsxDEV("div", {
970
+ /* @__PURE__ */ jsxDEV2("div", {
306
971
  className: "mt-1 flex items-center gap-2",
307
972
  children: [
308
- /* @__PURE__ */ jsxDEV("span", {
973
+ /* @__PURE__ */ jsxDEV2("span", {
309
974
  className: "text-muted-foreground text-sm",
310
975
  children: [
311
976
  agent.modelProvider,
@@ -313,60 +978,60 @@ function AgentActionsModal({
313
978
  agent.modelName
314
979
  ]
315
980
  }, undefined, true, undefined, this),
316
- /* @__PURE__ */ jsxDEV("span", {
981
+ /* @__PURE__ */ jsxDEV2("span", {
317
982
  className: `rounded-full px-2 py-0.5 font-medium text-xs ${getStatusColor(agent.status)}`,
318
983
  children: agent.status
319
984
  }, undefined, false, undefined, this)
320
985
  ]
321
986
  }, undefined, true, undefined, this),
322
- agent.description && /* @__PURE__ */ jsxDEV("p", {
987
+ agent.description && /* @__PURE__ */ jsxDEV2("p", {
323
988
  className: "mt-2 text-muted-foreground text-sm",
324
989
  children: agent.description
325
990
  }, undefined, false, undefined, this)
326
991
  ]
327
992
  }, undefined, true, undefined, this),
328
- mode === "menu" && /* @__PURE__ */ jsxDEV("div", {
993
+ mode === "menu" && /* @__PURE__ */ jsxDEV2("div", {
329
994
  className: "space-y-3",
330
995
  children: [
331
- agent.status === "ACTIVE" && /* @__PURE__ */ jsxDEV(Button, {
996
+ agent.status === "ACTIVE" && /* @__PURE__ */ jsxDEV2(Button, {
332
997
  className: "w-full justify-start",
333
998
  variant: "ghost",
334
999
  onPress: () => setMode("execute"),
335
1000
  children: [
336
- /* @__PURE__ */ jsxDEV("span", {
1001
+ /* @__PURE__ */ jsxDEV2("span", {
337
1002
  className: "mr-2",
338
1003
  children: "▶️"
339
1004
  }, undefined, false, undefined, this),
340
1005
  " Execute Agent"
341
1006
  ]
342
1007
  }, undefined, true, undefined, this),
343
- (agent.status === "DRAFT" || agent.status === "PAUSED") && /* @__PURE__ */ jsxDEV(Button, {
1008
+ (agent.status === "DRAFT" || agent.status === "PAUSED") && /* @__PURE__ */ jsxDEV2(Button, {
344
1009
  className: "w-full justify-start",
345
1010
  variant: "ghost",
346
1011
  onPress: () => handleStatusChange("activate"),
347
1012
  disabled: isLoading,
348
1013
  children: [
349
- /* @__PURE__ */ jsxDEV("span", {
1014
+ /* @__PURE__ */ jsxDEV2("span", {
350
1015
  className: "mr-2",
351
1016
  children: "\uD83D\uDFE2"
352
1017
  }, undefined, false, undefined, this),
353
1018
  " Activate Agent"
354
1019
  ]
355
1020
  }, undefined, true, undefined, this),
356
- agent.status === "ACTIVE" && /* @__PURE__ */ jsxDEV(Button, {
1021
+ agent.status === "ACTIVE" && /* @__PURE__ */ jsxDEV2(Button, {
357
1022
  className: "w-full justify-start",
358
1023
  variant: "ghost",
359
1024
  onPress: () => handleStatusChange("pause"),
360
1025
  disabled: isLoading,
361
1026
  children: [
362
- /* @__PURE__ */ jsxDEV("span", {
1027
+ /* @__PURE__ */ jsxDEV2("span", {
363
1028
  className: "mr-2",
364
1029
  children: "⏸️"
365
1030
  }, undefined, false, undefined, this),
366
1031
  " Pause Agent"
367
1032
  ]
368
1033
  }, undefined, true, undefined, this),
369
- agent.status !== "ARCHIVED" && /* @__PURE__ */ jsxDEV(Button, {
1034
+ agent.status !== "ARCHIVED" && /* @__PURE__ */ jsxDEV2(Button, {
370
1035
  className: "w-full justify-start text-yellow-600 hover:text-yellow-700",
371
1036
  variant: "ghost",
372
1037
  onPress: () => {
@@ -374,33 +1039,33 @@ function AgentActionsModal({
374
1039
  setMode("confirm");
375
1040
  },
376
1041
  children: [
377
- /* @__PURE__ */ jsxDEV("span", {
1042
+ /* @__PURE__ */ jsxDEV2("span", {
378
1043
  className: "mr-2",
379
1044
  children: "\uD83D\uDCE6"
380
1045
  }, undefined, false, undefined, this),
381
1046
  " Archive Agent"
382
1047
  ]
383
1048
  }, undefined, true, undefined, this),
384
- agent.status === "ARCHIVED" && /* @__PURE__ */ jsxDEV(Button, {
1049
+ agent.status === "ARCHIVED" && /* @__PURE__ */ jsxDEV2(Button, {
385
1050
  className: "w-full justify-start",
386
1051
  variant: "ghost",
387
1052
  onPress: () => handleStatusChange("activate"),
388
1053
  disabled: isLoading,
389
1054
  children: [
390
- /* @__PURE__ */ jsxDEV("span", {
1055
+ /* @__PURE__ */ jsxDEV2("span", {
391
1056
  className: "mr-2",
392
1057
  children: "\uD83D\uDD04"
393
1058
  }, undefined, false, undefined, this),
394
1059
  " Restore Agent"
395
1060
  ]
396
1061
  }, undefined, true, undefined, this),
397
- error && /* @__PURE__ */ jsxDEV("div", {
1062
+ error && /* @__PURE__ */ jsxDEV2("div", {
398
1063
  className: "rounded-md bg-destructive/10 p-3 text-destructive text-sm",
399
1064
  children: error
400
1065
  }, undefined, false, undefined, this),
401
- /* @__PURE__ */ jsxDEV("div", {
1066
+ /* @__PURE__ */ jsxDEV2("div", {
402
1067
  className: "border-border border-t pt-3",
403
- children: /* @__PURE__ */ jsxDEV(Button, {
1068
+ children: /* @__PURE__ */ jsxDEV2(Button, {
404
1069
  className: "w-full",
405
1070
  variant: "outline",
406
1071
  onPress: handleClose,
@@ -409,17 +1074,17 @@ function AgentActionsModal({
409
1074
  }, undefined, false, undefined, this)
410
1075
  ]
411
1076
  }, undefined, true, undefined, this),
412
- mode === "execute" && /* @__PURE__ */ jsxDEV("div", {
1077
+ mode === "execute" && /* @__PURE__ */ jsxDEV2("div", {
413
1078
  className: "space-y-4",
414
1079
  children: [
415
- /* @__PURE__ */ jsxDEV("div", {
1080
+ /* @__PURE__ */ jsxDEV2("div", {
416
1081
  children: [
417
- /* @__PURE__ */ jsxDEV("label", {
1082
+ /* @__PURE__ */ jsxDEV2("label", {
418
1083
  htmlFor: "execute-message",
419
1084
  className: "mb-1 block font-medium text-muted-foreground text-sm",
420
1085
  children: "Message *"
421
1086
  }, undefined, false, undefined, this),
422
- /* @__PURE__ */ jsxDEV("textarea", {
1087
+ /* @__PURE__ */ jsxDEV2("textarea", {
423
1088
  id: "execute-message",
424
1089
  value: message,
425
1090
  onChange: (e) => setMessage(e.target.value),
@@ -430,20 +1095,20 @@ function AgentActionsModal({
430
1095
  }, undefined, false, undefined, this)
431
1096
  ]
432
1097
  }, undefined, true, undefined, this),
433
- error && /* @__PURE__ */ jsxDEV("div", {
1098
+ error && /* @__PURE__ */ jsxDEV2("div", {
434
1099
  className: "rounded-md bg-destructive/10 p-3 text-destructive text-sm",
435
1100
  children: error
436
1101
  }, undefined, false, undefined, this),
437
- /* @__PURE__ */ jsxDEV("div", {
1102
+ /* @__PURE__ */ jsxDEV2("div", {
438
1103
  className: "flex justify-end gap-3 pt-2",
439
1104
  children: [
440
- /* @__PURE__ */ jsxDEV(Button, {
1105
+ /* @__PURE__ */ jsxDEV2(Button, {
441
1106
  variant: "ghost",
442
1107
  onPress: () => setMode("menu"),
443
1108
  disabled: isLoading,
444
1109
  children: "Back"
445
1110
  }, undefined, false, undefined, this),
446
- /* @__PURE__ */ jsxDEV(Button, {
1111
+ /* @__PURE__ */ jsxDEV2(Button, {
447
1112
  onPress: handleExecute,
448
1113
  disabled: isLoading,
449
1114
  children: isLoading ? "Executing..." : "▶️ Execute"
@@ -452,39 +1117,39 @@ function AgentActionsModal({
452
1117
  }, undefined, true, undefined, this)
453
1118
  ]
454
1119
  }, undefined, true, undefined, this),
455
- mode === "confirm" && confirmAction === "archive" && /* @__PURE__ */ jsxDEV("div", {
1120
+ mode === "confirm" && confirmAction === "archive" && /* @__PURE__ */ jsxDEV2("div", {
456
1121
  className: "space-y-4",
457
1122
  children: [
458
- /* @__PURE__ */ jsxDEV("p", {
1123
+ /* @__PURE__ */ jsxDEV2("p", {
459
1124
  className: "text-muted-foreground",
460
1125
  children: [
461
1126
  "Are you sure you want to archive",
462
1127
  " ",
463
- /* @__PURE__ */ jsxDEV("span", {
1128
+ /* @__PURE__ */ jsxDEV2("span", {
464
1129
  className: "font-medium text-foreground",
465
1130
  children: agent.name
466
1131
  }, undefined, false, undefined, this),
467
1132
  "?"
468
1133
  ]
469
1134
  }, undefined, true, undefined, this),
470
- /* @__PURE__ */ jsxDEV("p", {
1135
+ /* @__PURE__ */ jsxDEV2("p", {
471
1136
  className: "text-muted-foreground text-sm",
472
1137
  children: "Archived agents cannot be executed but can be restored later."
473
1138
  }, undefined, false, undefined, this),
474
- error && /* @__PURE__ */ jsxDEV("div", {
1139
+ error && /* @__PURE__ */ jsxDEV2("div", {
475
1140
  className: "rounded-md bg-destructive/10 p-3 text-destructive text-sm",
476
1141
  children: error
477
1142
  }, undefined, false, undefined, this),
478
- /* @__PURE__ */ jsxDEV("div", {
1143
+ /* @__PURE__ */ jsxDEV2("div", {
479
1144
  className: "flex justify-end gap-3 pt-2",
480
1145
  children: [
481
- /* @__PURE__ */ jsxDEV(Button, {
1146
+ /* @__PURE__ */ jsxDEV2(Button, {
482
1147
  variant: "ghost",
483
1148
  onPress: () => setMode("menu"),
484
1149
  disabled: isLoading,
485
1150
  children: "Cancel"
486
1151
  }, undefined, false, undefined, this),
487
- /* @__PURE__ */ jsxDEV(Button, {
1152
+ /* @__PURE__ */ jsxDEV2(Button, {
488
1153
  onPress: () => handleStatusChange("archive"),
489
1154
  disabled: isLoading,
490
1155
  children: isLoading ? "Archiving..." : "\uD83D\uDCE6 Archive"
@@ -502,7 +1167,7 @@ function AgentActionsModal({
502
1167
  // src/ui/modals/CreateAgentModal.tsx
503
1168
  import { Button as Button2, Input } from "@contractspec/lib.design-system";
504
1169
  import { useState as useState5 } from "react";
505
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
1170
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
506
1171
  "use client";
507
1172
  var MODEL_PROVIDERS = [
508
1173
  {
@@ -583,10 +1248,10 @@ function CreateAgentModal({
583
1248
  };
584
1249
  if (!isOpen)
585
1250
  return null;
586
- return /* @__PURE__ */ jsxDEV2("div", {
1251
+ return /* @__PURE__ */ jsxDEV3("div", {
587
1252
  className: "fixed inset-0 z-50 flex items-center justify-center",
588
1253
  children: [
589
- /* @__PURE__ */ jsxDEV2("div", {
1254
+ /* @__PURE__ */ jsxDEV3("div", {
590
1255
  className: "absolute inset-0 bg-background/80 backdrop-blur-sm",
591
1256
  onClick: onClose,
592
1257
  role: "button",
@@ -597,25 +1262,25 @@ function CreateAgentModal({
597
1262
  },
598
1263
  "aria-label": "Close modal"
599
1264
  }, undefined, false, undefined, this),
600
- /* @__PURE__ */ jsxDEV2("div", {
1265
+ /* @__PURE__ */ jsxDEV3("div", {
601
1266
  className: "relative z-10 max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-xl border border-border bg-card p-6 shadow-xl",
602
1267
  children: [
603
- /* @__PURE__ */ jsxDEV2("h2", {
1268
+ /* @__PURE__ */ jsxDEV3("h2", {
604
1269
  className: "mb-4 font-semibold text-xl",
605
1270
  children: "Create New Agent"
606
1271
  }, undefined, false, undefined, this),
607
- /* @__PURE__ */ jsxDEV2("form", {
1272
+ /* @__PURE__ */ jsxDEV3("form", {
608
1273
  onSubmit: handleSubmit,
609
1274
  className: "space-y-4",
610
1275
  children: [
611
- /* @__PURE__ */ jsxDEV2("div", {
1276
+ /* @__PURE__ */ jsxDEV3("div", {
612
1277
  children: [
613
- /* @__PURE__ */ jsxDEV2("label", {
1278
+ /* @__PURE__ */ jsxDEV3("label", {
614
1279
  htmlFor: "agent-name",
615
1280
  className: "mb-1 block font-medium text-muted-foreground text-sm",
616
1281
  children: "Agent Name *"
617
1282
  }, undefined, false, undefined, this),
618
- /* @__PURE__ */ jsxDEV2(Input, {
1283
+ /* @__PURE__ */ jsxDEV3(Input, {
619
1284
  id: "agent-name",
620
1285
  value: name,
621
1286
  onChange: (e) => setName(e.target.value),
@@ -624,14 +1289,14 @@ function CreateAgentModal({
624
1289
  }, undefined, false, undefined, this)
625
1290
  ]
626
1291
  }, undefined, true, undefined, this),
627
- /* @__PURE__ */ jsxDEV2("div", {
1292
+ /* @__PURE__ */ jsxDEV3("div", {
628
1293
  children: [
629
- /* @__PURE__ */ jsxDEV2("label", {
1294
+ /* @__PURE__ */ jsxDEV3("label", {
630
1295
  htmlFor: "agent-description",
631
1296
  className: "mb-1 block font-medium text-muted-foreground text-sm",
632
1297
  children: "Description"
633
1298
  }, undefined, false, undefined, this),
634
- /* @__PURE__ */ jsxDEV2("textarea", {
1299
+ /* @__PURE__ */ jsxDEV3("textarea", {
635
1300
  id: "agent-description",
636
1301
  value: description,
637
1302
  onChange: (e) => setDescription(e.target.value),
@@ -642,45 +1307,45 @@ function CreateAgentModal({
642
1307
  }, undefined, false, undefined, this)
643
1308
  ]
644
1309
  }, undefined, true, undefined, this),
645
- /* @__PURE__ */ jsxDEV2("div", {
1310
+ /* @__PURE__ */ jsxDEV3("div", {
646
1311
  className: "flex gap-3",
647
1312
  children: [
648
- /* @__PURE__ */ jsxDEV2("div", {
1313
+ /* @__PURE__ */ jsxDEV3("div", {
649
1314
  className: "flex-1",
650
1315
  children: [
651
- /* @__PURE__ */ jsxDEV2("label", {
1316
+ /* @__PURE__ */ jsxDEV3("label", {
652
1317
  htmlFor: "model-provider",
653
1318
  className: "mb-1 block font-medium text-muted-foreground text-sm",
654
1319
  children: "Provider *"
655
1320
  }, undefined, false, undefined, this),
656
- /* @__PURE__ */ jsxDEV2("select", {
1321
+ /* @__PURE__ */ jsxDEV3("select", {
657
1322
  id: "model-provider",
658
1323
  value: modelProvider,
659
1324
  onChange: (e) => handleProviderChange(e.target.value),
660
1325
  disabled: isLoading,
661
1326
  className: "h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",
662
- children: MODEL_PROVIDERS.map((p) => /* @__PURE__ */ jsxDEV2("option", {
1327
+ children: MODEL_PROVIDERS.map((p) => /* @__PURE__ */ jsxDEV3("option", {
663
1328
  value: p.value,
664
1329
  children: p.label
665
1330
  }, p.value, false, undefined, this))
666
1331
  }, undefined, false, undefined, this)
667
1332
  ]
668
1333
  }, undefined, true, undefined, this),
669
- /* @__PURE__ */ jsxDEV2("div", {
1334
+ /* @__PURE__ */ jsxDEV3("div", {
670
1335
  className: "flex-1",
671
1336
  children: [
672
- /* @__PURE__ */ jsxDEV2("label", {
1337
+ /* @__PURE__ */ jsxDEV3("label", {
673
1338
  htmlFor: "model-name",
674
1339
  className: "mb-1 block font-medium text-muted-foreground text-sm",
675
1340
  children: "Model *"
676
1341
  }, undefined, false, undefined, this),
677
- /* @__PURE__ */ jsxDEV2("select", {
1342
+ /* @__PURE__ */ jsxDEV3("select", {
678
1343
  id: "model-name",
679
1344
  value: modelName,
680
1345
  onChange: (e) => setModelName(e.target.value),
681
1346
  disabled: isLoading,
682
1347
  className: "h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",
683
- children: selectedProvider?.models.map((m) => /* @__PURE__ */ jsxDEV2("option", {
1348
+ children: selectedProvider?.models.map((m) => /* @__PURE__ */ jsxDEV3("option", {
684
1349
  value: m,
685
1350
  children: m
686
1351
  }, m, false, undefined, this))
@@ -689,14 +1354,14 @@ function CreateAgentModal({
689
1354
  }, undefined, true, undefined, this)
690
1355
  ]
691
1356
  }, undefined, true, undefined, this),
692
- /* @__PURE__ */ jsxDEV2("div", {
1357
+ /* @__PURE__ */ jsxDEV3("div", {
693
1358
  children: [
694
- /* @__PURE__ */ jsxDEV2("label", {
1359
+ /* @__PURE__ */ jsxDEV3("label", {
695
1360
  htmlFor: "system-prompt",
696
1361
  className: "mb-1 block font-medium text-muted-foreground text-sm",
697
1362
  children: "System Prompt"
698
1363
  }, undefined, false, undefined, this),
699
- /* @__PURE__ */ jsxDEV2("textarea", {
1364
+ /* @__PURE__ */ jsxDEV3("textarea", {
700
1365
  id: "system-prompt",
701
1366
  value: systemPrompt,
702
1367
  onChange: (e) => setSystemPrompt(e.target.value),
@@ -705,27 +1370,27 @@ function CreateAgentModal({
705
1370
  disabled: isLoading,
706
1371
  className: "w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"
707
1372
  }, undefined, false, undefined, this),
708
- /* @__PURE__ */ jsxDEV2("p", {
1373
+ /* @__PURE__ */ jsxDEV3("p", {
709
1374
  className: "mt-1 text-muted-foreground text-xs",
710
1375
  children: "Instructions that define the agent's behavior"
711
1376
  }, undefined, false, undefined, this)
712
1377
  ]
713
1378
  }, undefined, true, undefined, this),
714
- error && /* @__PURE__ */ jsxDEV2("div", {
1379
+ error && /* @__PURE__ */ jsxDEV3("div", {
715
1380
  className: "rounded-md bg-destructive/10 p-3 text-destructive text-sm",
716
1381
  children: error
717
1382
  }, undefined, false, undefined, this),
718
- /* @__PURE__ */ jsxDEV2("div", {
1383
+ /* @__PURE__ */ jsxDEV3("div", {
719
1384
  className: "flex justify-end gap-3 pt-2",
720
1385
  children: [
721
- /* @__PURE__ */ jsxDEV2(Button2, {
1386
+ /* @__PURE__ */ jsxDEV3(Button2, {
722
1387
  type: "button",
723
1388
  variant: "ghost",
724
1389
  onPress: onClose,
725
1390
  disabled: isLoading,
726
1391
  children: "Cancel"
727
1392
  }, undefined, false, undefined, this),
728
- /* @__PURE__ */ jsxDEV2(Button2, {
1393
+ /* @__PURE__ */ jsxDEV3(Button2, {
729
1394
  type: "submit",
730
1395
  disabled: isLoading,
731
1396
  children: isLoading ? "Creating..." : "Create Agent"
@@ -740,16 +1405,11 @@ function CreateAgentModal({
740
1405
  }, undefined, true, undefined, this);
741
1406
  }
742
1407
 
743
- // src/ui/views/RunListView.tsx
744
- import {
745
- EmptyState,
746
- ErrorState,
747
- LoaderBlock,
748
- StatCard,
749
- StatCardGroup,
750
- StatusChip
751
- } from "@contractspec/lib.design-system";
752
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
1408
+ // src/ui/views/run-list.shared.tsx
1409
+ import { Button as Button3, StatusChip } from "@contractspec/lib.design-system";
1410
+ import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
1411
+ import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
1412
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
753
1413
  "use client";
754
1414
  function getStatusTone(status) {
755
1415
  switch (status) {
@@ -787,15 +1447,320 @@ function formatCost(cost) {
787
1447
  return "-";
788
1448
  return `$${cost.toFixed(4)}`;
789
1449
  }
1450
+ function formatJson(value) {
1451
+ return JSON.stringify(value ?? null, null, 2);
1452
+ }
1453
+ function RunExpandedContent({ run }) {
1454
+ return /* @__PURE__ */ jsxDEV4(VStack, {
1455
+ gap: "sm",
1456
+ className: "py-2",
1457
+ children: [
1458
+ /* @__PURE__ */ jsxDEV4(HStack, {
1459
+ justify: "between",
1460
+ className: "flex-wrap",
1461
+ children: [
1462
+ /* @__PURE__ */ jsxDEV4(StatusChip, {
1463
+ tone: getStatusTone(run.status),
1464
+ label: run.status
1465
+ }, undefined, false, undefined, this),
1466
+ /* @__PURE__ */ jsxDEV4(Text, {
1467
+ className: "text-muted-foreground text-sm",
1468
+ children: [
1469
+ "Queued ",
1470
+ run.queuedAt.toLocaleString()
1471
+ ]
1472
+ }, undefined, true, undefined, this)
1473
+ ]
1474
+ }, undefined, true, undefined, this),
1475
+ /* @__PURE__ */ jsxDEV4(HStack, {
1476
+ gap: "lg",
1477
+ className: "flex-wrap",
1478
+ children: [
1479
+ /* @__PURE__ */ jsxDEV4(Text, {
1480
+ className: "text-muted-foreground text-sm",
1481
+ children: [
1482
+ "Prompt ",
1483
+ formatTokens(run.promptTokens)
1484
+ ]
1485
+ }, undefined, true, undefined, this),
1486
+ /* @__PURE__ */ jsxDEV4(Text, {
1487
+ className: "text-muted-foreground text-sm",
1488
+ children: [
1489
+ "Completion ",
1490
+ formatTokens(run.completionTokens)
1491
+ ]
1492
+ }, undefined, true, undefined, this),
1493
+ /* @__PURE__ */ jsxDEV4(Text, {
1494
+ className: "text-muted-foreground text-sm",
1495
+ children: [
1496
+ "Duration ",
1497
+ formatDuration(run.durationMs)
1498
+ ]
1499
+ }, undefined, true, undefined, this)
1500
+ ]
1501
+ }, undefined, true, undefined, this),
1502
+ /* @__PURE__ */ jsxDEV4(VStack, {
1503
+ gap: "xs",
1504
+ children: [
1505
+ /* @__PURE__ */ jsxDEV4(Text, {
1506
+ className: "font-medium text-sm",
1507
+ children: "Input"
1508
+ }, undefined, false, undefined, this),
1509
+ /* @__PURE__ */ jsxDEV4("pre", {
1510
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
1511
+ children: formatJson(run.input)
1512
+ }, undefined, false, undefined, this)
1513
+ ]
1514
+ }, undefined, true, undefined, this),
1515
+ /* @__PURE__ */ jsxDEV4(VStack, {
1516
+ gap: "xs",
1517
+ children: [
1518
+ /* @__PURE__ */ jsxDEV4(Text, {
1519
+ className: "font-medium text-sm",
1520
+ children: "Output"
1521
+ }, undefined, false, undefined, this),
1522
+ /* @__PURE__ */ jsxDEV4("pre", {
1523
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
1524
+ children: formatJson(run.output ?? run.errorMessage ?? "Pending")
1525
+ }, undefined, false, undefined, this)
1526
+ ]
1527
+ }, undefined, true, undefined, this)
1528
+ ]
1529
+ }, undefined, true, undefined, this);
1530
+ }
1531
+ function RunTableToolbar({
1532
+ controller,
1533
+ totalRuns
1534
+ }) {
1535
+ const firstRow = controller.rows[0];
1536
+ const queuedColumn = controller.columns.find((column) => column.id === "queuedAt");
1537
+ const durationColumn = controller.columns.find((column) => column.id === "durationMs");
1538
+ const costColumn = controller.columns.find((column) => column.id === "estimatedCostUsd");
1539
+ return /* @__PURE__ */ jsxDEV4(HStack, {
1540
+ gap: "sm",
1541
+ className: "flex-wrap",
1542
+ children: [
1543
+ /* @__PURE__ */ jsxDEV4(Text, {
1544
+ className: "text-muted-foreground text-sm",
1545
+ children: [
1546
+ totalRuns,
1547
+ " runs"
1548
+ ]
1549
+ }, undefined, true, undefined, this),
1550
+ /* @__PURE__ */ jsxDEV4(Button3, {
1551
+ variant: "outline",
1552
+ size: "sm",
1553
+ onPress: () => firstRow?.toggleExpanded?.(!firstRow?.isExpanded),
1554
+ children: "Expand Latest Run"
1555
+ }, undefined, false, undefined, this),
1556
+ /* @__PURE__ */ jsxDEV4(Button3, {
1557
+ variant: "outline",
1558
+ size: "sm",
1559
+ onPress: () => queuedColumn?.toggleVisibility?.(!queuedColumn?.visible),
1560
+ children: queuedColumn?.visible ? "Hide Time" : "Show Time"
1561
+ }, undefined, false, undefined, this),
1562
+ /* @__PURE__ */ jsxDEV4(Button3, {
1563
+ variant: "outline",
1564
+ size: "sm",
1565
+ onPress: () => durationColumn?.toggleVisibility?.(!durationColumn?.visible),
1566
+ children: durationColumn?.visible ? "Hide Duration" : "Show Duration"
1567
+ }, undefined, false, undefined, this),
1568
+ /* @__PURE__ */ jsxDEV4(Button3, {
1569
+ variant: "outline",
1570
+ size: "sm",
1571
+ onPress: () => costColumn?.toggleVisibility?.(!costColumn?.visible),
1572
+ children: costColumn?.visible ? "Hide Cost" : "Show Cost"
1573
+ }, undefined, false, undefined, this)
1574
+ ]
1575
+ }, undefined, true, undefined, this);
1576
+ }
1577
+
1578
+ // src/ui/views/run-data-table.columns.tsx
1579
+ import { StatusChip as StatusChip2 } from "@contractspec/lib.design-system";
1580
+ import { VStack as VStack2 } from "@contractspec/lib.ui-kit-web/ui/stack";
1581
+ import { Text as Text2 } from "@contractspec/lib.ui-kit-web/ui/text";
1582
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
1583
+ "use client";
1584
+ function createRunTableColumns() {
1585
+ return [
1586
+ {
1587
+ id: "queuedAt",
1588
+ header: "Run",
1589
+ label: "Run",
1590
+ accessor: (run) => run.queuedAt.getTime(),
1591
+ cell: ({ item }) => /* @__PURE__ */ jsxDEV5(VStack2, {
1592
+ gap: "xs",
1593
+ children: [
1594
+ /* @__PURE__ */ jsxDEV5(Text2, {
1595
+ className: "font-mono text-sm",
1596
+ children: item.id.slice(-8)
1597
+ }, undefined, false, undefined, this),
1598
+ /* @__PURE__ */ jsxDEV5(Text2, {
1599
+ className: "text-muted-foreground text-xs",
1600
+ children: item.queuedAt.toLocaleString()
1601
+ }, undefined, false, undefined, this)
1602
+ ]
1603
+ }, undefined, true, undefined, this),
1604
+ size: 220,
1605
+ minSize: 180,
1606
+ canSort: true,
1607
+ canHide: true,
1608
+ canResize: true
1609
+ },
1610
+ {
1611
+ id: "agentName",
1612
+ header: "Agent",
1613
+ label: "Agent",
1614
+ accessor: (run) => run.agentName ?? "Unknown Agent",
1615
+ cell: ({ value }) => /* @__PURE__ */ jsxDEV5(Text2, {
1616
+ className: "font-medium",
1617
+ children: typeof value === "string" ? value : "Unknown Agent"
1618
+ }, undefined, false, undefined, this),
1619
+ size: 220,
1620
+ canSort: true,
1621
+ canResize: true
1622
+ },
1623
+ {
1624
+ id: "status",
1625
+ header: "Status",
1626
+ label: "Status",
1627
+ accessorKey: "status",
1628
+ cell: ({ value }) => {
1629
+ const status = typeof value === "string" ? value : "QUEUED";
1630
+ return /* @__PURE__ */ jsxDEV5(StatusChip2, {
1631
+ tone: getStatusTone(status),
1632
+ label: status
1633
+ }, undefined, false, undefined, this);
1634
+ },
1635
+ size: 150,
1636
+ canSort: true,
1637
+ canResize: true
1638
+ },
1639
+ {
1640
+ id: "totalTokens",
1641
+ header: "Tokens",
1642
+ label: "Tokens",
1643
+ accessorKey: "totalTokens",
1644
+ cell: ({ value }) => formatTokens(Number(value ?? 0)),
1645
+ align: "right",
1646
+ size: 140,
1647
+ canSort: true,
1648
+ canResize: true
1649
+ },
1650
+ {
1651
+ id: "durationMs",
1652
+ header: "Duration",
1653
+ label: "Duration",
1654
+ accessorKey: "durationMs",
1655
+ cell: ({ value }) => formatDuration(typeof value === "number" ? value : undefined),
1656
+ align: "right",
1657
+ size: 140,
1658
+ canSort: true,
1659
+ canHide: true,
1660
+ canResize: true
1661
+ },
1662
+ {
1663
+ id: "estimatedCostUsd",
1664
+ header: "Cost",
1665
+ label: "Cost",
1666
+ accessorKey: "estimatedCostUsd",
1667
+ cell: ({ value }) => formatCost(typeof value === "number" ? value : undefined),
1668
+ align: "right",
1669
+ size: 140,
1670
+ canSort: true,
1671
+ canHide: true,
1672
+ canResize: true
1673
+ }
1674
+ ];
1675
+ }
1676
+
1677
+ // src/ui/views/RunDataTable.tsx
1678
+ import { DataTable } from "@contractspec/lib.design-system";
1679
+ import { useContractTable } from "@contractspec/lib.presentation-runtime-react";
1680
+ import * as React from "react";
1681
+ import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
1682
+ "use client";
1683
+ function RunDataTable({
1684
+ runs,
1685
+ totalItems,
1686
+ pageIndex,
1687
+ pageSize,
1688
+ sorting,
1689
+ loading,
1690
+ onSortingChange,
1691
+ onPaginationChange,
1692
+ onRunClick
1693
+ }) {
1694
+ const columns = React.useMemo(() => createRunTableColumns(), []);
1695
+ const controller = useContractTable({
1696
+ data: runs,
1697
+ columns,
1698
+ executionMode: "server",
1699
+ totalItems,
1700
+ state: {
1701
+ sorting,
1702
+ pagination: { pageIndex, pageSize }
1703
+ },
1704
+ onSortingChange,
1705
+ onPaginationChange,
1706
+ initialState: {
1707
+ columnVisibility: { estimatedCostUsd: false }
1708
+ },
1709
+ getRowId: (run) => run.id,
1710
+ renderExpandedContent: (run) => /* @__PURE__ */ jsxDEV6(RunExpandedContent, {
1711
+ run
1712
+ }, undefined, false, undefined, this),
1713
+ getCanExpand: () => true
1714
+ });
1715
+ return /* @__PURE__ */ jsxDEV6(DataTable, {
1716
+ controller,
1717
+ title: "Run History",
1718
+ description: "Server-mode ContractSpec table with shared pagination, sorting, visibility, and expansion.",
1719
+ loading,
1720
+ onRowPress: (row) => onRunClick?.(row.id),
1721
+ toolbar: /* @__PURE__ */ jsxDEV6(RunTableToolbar, {
1722
+ controller,
1723
+ totalRuns: totalItems
1724
+ }, undefined, false, undefined, this),
1725
+ emptyState: /* @__PURE__ */ jsxDEV6("div", {
1726
+ className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
1727
+ children: "No runs yet"
1728
+ }, undefined, false, undefined, this)
1729
+ }, undefined, false, undefined, this);
1730
+ }
1731
+
1732
+ // src/ui/views/RunListView.tsx
1733
+ import {
1734
+ EmptyState,
1735
+ ErrorState,
1736
+ LoaderBlock,
1737
+ StatCard,
1738
+ StatCardGroup
1739
+ } from "@contractspec/lib.design-system";
1740
+ import { useState as useState6 } from "react";
1741
+ import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
1742
+ "use client";
790
1743
  function RunListView({ agentId, onRunClick }) {
791
- const { data, metrics, loading, error, refetch } = useRunList({ agentId });
1744
+ const [sorting, setSorting] = useState6([
1745
+ { id: "queuedAt", desc: true }
1746
+ ]);
1747
+ const [pagination, setPagination] = useState6({
1748
+ pageIndex: 0,
1749
+ pageSize: 3
1750
+ });
1751
+ const { data, metrics, loading, error, refetch } = useRunList({
1752
+ agentId,
1753
+ pageIndex: pagination.pageIndex,
1754
+ pageSize: pagination.pageSize,
1755
+ sorting
1756
+ });
792
1757
  if (loading && !data) {
793
- return /* @__PURE__ */ jsxDEV3(LoaderBlock, {
1758
+ return /* @__PURE__ */ jsxDEV7(LoaderBlock, {
794
1759
  label: "Loading runs..."
795
1760
  }, undefined, false, undefined, this);
796
1761
  }
797
1762
  if (error) {
798
- return /* @__PURE__ */ jsxDEV3(ErrorState, {
1763
+ return /* @__PURE__ */ jsxDEV7(ErrorState, {
799
1764
  title: "Failed to load runs",
800
1765
  description: error.message,
801
1766
  onRetry: refetch,
@@ -803,145 +1768,62 @@ function RunListView({ agentId, onRunClick }) {
803
1768
  }, undefined, false, undefined, this);
804
1769
  }
805
1770
  if (!data?.items.length) {
806
- return /* @__PURE__ */ jsxDEV3(EmptyState, {
1771
+ return /* @__PURE__ */ jsxDEV7(EmptyState, {
807
1772
  title: "No runs yet",
808
1773
  description: "Execute an agent to see run history here."
809
1774
  }, undefined, false, undefined, this);
810
1775
  }
811
- return /* @__PURE__ */ jsxDEV3("div", {
1776
+ return /* @__PURE__ */ jsxDEV7("div", {
812
1777
  className: "space-y-6",
813
1778
  children: [
814
- metrics && /* @__PURE__ */ jsxDEV3(StatCardGroup, {
1779
+ metrics ? /* @__PURE__ */ jsxDEV7(StatCardGroup, {
815
1780
  children: [
816
- /* @__PURE__ */ jsxDEV3(StatCard, {
1781
+ /* @__PURE__ */ jsxDEV7(StatCard, {
817
1782
  label: "Total Runs",
818
1783
  value: metrics.totalRuns
819
1784
  }, undefined, false, undefined, this),
820
- /* @__PURE__ */ jsxDEV3(StatCard, {
1785
+ /* @__PURE__ */ jsxDEV7(StatCard, {
821
1786
  label: "Success Rate",
822
1787
  value: `${(metrics.successRate * 100).toFixed(1)}%`
823
1788
  }, undefined, false, undefined, this),
824
- /* @__PURE__ */ jsxDEV3(StatCard, {
1789
+ /* @__PURE__ */ jsxDEV7(StatCard, {
825
1790
  label: "Total Tokens",
826
1791
  value: formatTokens(metrics.totalTokens)
827
1792
  }, undefined, false, undefined, this),
828
- /* @__PURE__ */ jsxDEV3(StatCard, {
1793
+ /* @__PURE__ */ jsxDEV7(StatCard, {
829
1794
  label: "Total Cost",
830
1795
  value: `$${metrics.totalCostUsd.toFixed(2)}`
831
1796
  }, undefined, false, undefined, this)
832
1797
  ]
833
- }, undefined, true, undefined, this),
834
- /* @__PURE__ */ jsxDEV3("div", {
835
- className: "rounded-lg border border-border",
836
- children: /* @__PURE__ */ jsxDEV3("table", {
837
- className: "w-full",
838
- children: [
839
- /* @__PURE__ */ jsxDEV3("thead", {
840
- className: "border-border border-b bg-muted/30",
841
- children: /* @__PURE__ */ jsxDEV3("tr", {
842
- children: [
843
- /* @__PURE__ */ jsxDEV3("th", {
844
- className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
845
- children: "Run"
846
- }, undefined, false, undefined, this),
847
- /* @__PURE__ */ jsxDEV3("th", {
848
- className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
849
- children: "Agent"
850
- }, undefined, false, undefined, this),
851
- /* @__PURE__ */ jsxDEV3("th", {
852
- className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
853
- children: "Status"
854
- }, undefined, false, undefined, this),
855
- /* @__PURE__ */ jsxDEV3("th", {
856
- className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
857
- children: "Tokens"
858
- }, undefined, false, undefined, this),
859
- /* @__PURE__ */ jsxDEV3("th", {
860
- className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
861
- children: "Duration"
862
- }, undefined, false, undefined, this),
863
- /* @__PURE__ */ jsxDEV3("th", {
864
- className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
865
- children: "Cost"
866
- }, undefined, false, undefined, this)
867
- ]
868
- }, undefined, true, undefined, this)
869
- }, undefined, false, undefined, this),
870
- /* @__PURE__ */ jsxDEV3("tbody", {
871
- className: "divide-y divide-border",
872
- children: data.items.map((run) => /* @__PURE__ */ jsxDEV3("tr", {
873
- className: "cursor-pointer transition-colors hover:bg-muted/50",
874
- onClick: () => onRunClick?.(run.id),
875
- children: [
876
- /* @__PURE__ */ jsxDEV3("td", {
877
- className: "px-4 py-3",
878
- children: [
879
- /* @__PURE__ */ jsxDEV3("div", {
880
- className: "font-mono text-sm",
881
- children: run.id.slice(-8)
882
- }, undefined, false, undefined, this),
883
- /* @__PURE__ */ jsxDEV3("div", {
884
- className: "text-muted-foreground text-xs",
885
- children: run.queuedAt.toLocaleString()
886
- }, undefined, false, undefined, this)
887
- ]
888
- }, undefined, true, undefined, this),
889
- /* @__PURE__ */ jsxDEV3("td", {
890
- className: "px-4 py-3",
891
- children: /* @__PURE__ */ jsxDEV3("span", {
892
- className: "font-medium",
893
- children: run.agentName
894
- }, undefined, false, undefined, this)
895
- }, undefined, false, undefined, this),
896
- /* @__PURE__ */ jsxDEV3("td", {
897
- className: "px-4 py-3",
898
- children: /* @__PURE__ */ jsxDEV3(StatusChip, {
899
- tone: getStatusTone(run.status),
900
- label: run.status
901
- }, undefined, false, undefined, this)
902
- }, undefined, false, undefined, this),
903
- /* @__PURE__ */ jsxDEV3("td", {
904
- className: "px-4 py-3 text-right font-mono text-sm",
905
- children: formatTokens(run.totalTokens)
906
- }, undefined, false, undefined, this),
907
- /* @__PURE__ */ jsxDEV3("td", {
908
- className: "px-4 py-3 text-right font-mono text-sm",
909
- children: formatDuration(run.durationMs)
910
- }, undefined, false, undefined, this),
911
- /* @__PURE__ */ jsxDEV3("td", {
912
- className: "px-4 py-3 text-right font-mono text-sm",
913
- children: formatCost(run.estimatedCostUsd)
914
- }, undefined, false, undefined, this)
915
- ]
916
- }, run.id, true, undefined, this))
917
- }, undefined, false, undefined, this)
918
- ]
919
- }, undefined, true, undefined, this)
920
- }, undefined, false, undefined, this),
921
- /* @__PURE__ */ jsxDEV3("div", {
922
- className: "text-center text-muted-foreground text-sm",
923
- children: [
924
- "Showing ",
925
- data.items.length,
926
- " of ",
927
- data.total,
928
- " runs"
929
- ]
930
- }, undefined, true, undefined, this)
1798
+ }, undefined, true, undefined, this) : null,
1799
+ /* @__PURE__ */ jsxDEV7(RunDataTable, {
1800
+ runs: data.items,
1801
+ totalItems: data.total,
1802
+ pageIndex: pagination.pageIndex,
1803
+ pageSize: pagination.pageSize,
1804
+ sorting,
1805
+ loading,
1806
+ onSortingChange: (nextSorting) => {
1807
+ setSorting(nextSorting);
1808
+ setPagination((current) => ({ ...current, pageIndex: 0 }));
1809
+ },
1810
+ onPaginationChange: setPagination,
1811
+ onRunClick
1812
+ }, undefined, false, undefined, this)
931
1813
  ]
932
1814
  }, undefined, true, undefined, this);
933
1815
  }
934
1816
 
935
1817
  // src/ui/hooks/useToolList.ts
936
1818
  import { useTemplateRuntime as useTemplateRuntime4 } from "@contractspec/lib.example-shared-ui";
937
- import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo2, useState as useState6 } from "react";
1819
+ import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo3, useState as useState7 } from "react";
938
1820
  function useToolList(options = {}) {
939
1821
  const { handlers, projectId } = useTemplateRuntime4();
940
1822
  const { agent } = handlers;
941
- const [data, setData] = useState6(null);
942
- const [loading, setLoading] = useState6(true);
943
- const [error, setError] = useState6(null);
944
- const [page, setPage] = useState6(1);
1823
+ const [data, setData] = useState7(null);
1824
+ const [loading, setLoading] = useState7(true);
1825
+ const [error, setError] = useState7(null);
1826
+ const [page, setPage] = useState7(1);
945
1827
  const fetchData = useCallback4(async () => {
946
1828
  setLoading(true);
947
1829
  setError(null);
@@ -972,7 +1854,7 @@ function useToolList(options = {}) {
972
1854
  useEffect3(() => {
973
1855
  fetchData();
974
1856
  }, [fetchData]);
975
- const { stats, groupedByCategory, categoryStats } = useMemo2(() => {
1857
+ const { stats, groupedByCategory, categoryStats } = useMemo3(() => {
976
1858
  if (!data)
977
1859
  return { stats: null, groupedByCategory: {}, categoryStats: [] };
978
1860
  const items = data.items;
@@ -1017,16 +1899,16 @@ function useToolList(options = {}) {
1017
1899
 
1018
1900
  // src/ui/views/ToolRegistryView.tsx
1019
1901
  import {
1020
- Button as Button3,
1902
+ Button as Button4,
1021
1903
  EmptyState as EmptyState2,
1022
1904
  EntityCard,
1023
1905
  ErrorState as ErrorState2,
1024
1906
  LoaderBlock as LoaderBlock2,
1025
1907
  StatCard as StatCard2,
1026
1908
  StatCardGroup as StatCardGroup2,
1027
- StatusChip as StatusChip2
1909
+ StatusChip as StatusChip3
1028
1910
  } from "@contractspec/lib.design-system";
1029
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
1911
+ import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
1030
1912
  "use client";
1031
1913
  var categoryIcons = {
1032
1914
  RETRIEVAL: "\uD83D\uDD0D",
@@ -1056,12 +1938,12 @@ function ToolRegistryView({
1056
1938
  }) {
1057
1939
  const { data, loading, error, groupedByCategory, categoryStats, refetch } = useToolList();
1058
1940
  if (loading && !data) {
1059
- return /* @__PURE__ */ jsxDEV4(LoaderBlock2, {
1941
+ return /* @__PURE__ */ jsxDEV8(LoaderBlock2, {
1060
1942
  label: "Loading tools..."
1061
1943
  }, undefined, false, undefined, this);
1062
1944
  }
1063
1945
  if (error) {
1064
- return /* @__PURE__ */ jsxDEV4(ErrorState2, {
1946
+ return /* @__PURE__ */ jsxDEV8(ErrorState2, {
1065
1947
  title: "Failed to load tools",
1066
1948
  description: error.message,
1067
1949
  onRetry: refetch,
@@ -1069,64 +1951,64 @@ function ToolRegistryView({
1069
1951
  }, undefined, false, undefined, this);
1070
1952
  }
1071
1953
  if (!data?.items.length) {
1072
- return /* @__PURE__ */ jsxDEV4(EmptyState2, {
1954
+ return /* @__PURE__ */ jsxDEV8(EmptyState2, {
1073
1955
  title: "No tools registered",
1074
1956
  description: "Create your first tool to extend agent capabilities.",
1075
- primaryAction: onCreateTool ? /* @__PURE__ */ jsxDEV4(Button3, {
1957
+ primaryAction: onCreateTool ? /* @__PURE__ */ jsxDEV8(Button4, {
1076
1958
  onPress: onCreateTool,
1077
1959
  children: "Create Tool"
1078
1960
  }, undefined, false, undefined, this) : undefined
1079
1961
  }, undefined, false, undefined, this);
1080
1962
  }
1081
- return /* @__PURE__ */ jsxDEV4("div", {
1963
+ return /* @__PURE__ */ jsxDEV8("div", {
1082
1964
  className: "space-y-8",
1083
1965
  children: [
1084
- /* @__PURE__ */ jsxDEV4(StatCardGroup2, {
1966
+ /* @__PURE__ */ jsxDEV8(StatCardGroup2, {
1085
1967
  children: [
1086
- /* @__PURE__ */ jsxDEV4(StatCard2, {
1968
+ /* @__PURE__ */ jsxDEV8(StatCard2, {
1087
1969
  label: "Total Tools",
1088
1970
  value: data.total
1089
1971
  }, undefined, false, undefined, this),
1090
- categoryStats.slice(0, 3).map(({ category, count }) => /* @__PURE__ */ jsxDEV4(StatCard2, {
1972
+ categoryStats.slice(0, 3).map(({ category, count }) => /* @__PURE__ */ jsxDEV8(StatCard2, {
1091
1973
  label: `${categoryIcons[category] ?? ""} ${category}`,
1092
1974
  value: count
1093
1975
  }, category, false, undefined, this))
1094
1976
  ]
1095
1977
  }, undefined, true, undefined, this),
1096
- Object.entries(groupedByCategory).map(([category, tools]) => /* @__PURE__ */ jsxDEV4("section", {
1978
+ Object.entries(groupedByCategory).map(([category, tools]) => /* @__PURE__ */ jsxDEV8("section", {
1097
1979
  className: "space-y-4",
1098
1980
  children: [
1099
- /* @__PURE__ */ jsxDEV4("div", {
1981
+ /* @__PURE__ */ jsxDEV8("div", {
1100
1982
  className: "flex items-center gap-2",
1101
1983
  children: [
1102
- /* @__PURE__ */ jsxDEV4("span", {
1984
+ /* @__PURE__ */ jsxDEV8("span", {
1103
1985
  className: "text-2xl",
1104
1986
  children: categoryIcons[category]
1105
1987
  }, undefined, false, undefined, this),
1106
- /* @__PURE__ */ jsxDEV4("h3", {
1988
+ /* @__PURE__ */ jsxDEV8("h3", {
1107
1989
  className: "font-semibold text-lg",
1108
1990
  children: category
1109
1991
  }, undefined, false, undefined, this),
1110
- /* @__PURE__ */ jsxDEV4("span", {
1992
+ /* @__PURE__ */ jsxDEV8("span", {
1111
1993
  className: "rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",
1112
1994
  children: tools.length
1113
1995
  }, undefined, false, undefined, this)
1114
1996
  ]
1115
1997
  }, undefined, true, undefined, this),
1116
- /* @__PURE__ */ jsxDEV4("div", {
1998
+ /* @__PURE__ */ jsxDEV8("div", {
1117
1999
  className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3",
1118
- children: tools.map((tool) => /* @__PURE__ */ jsxDEV4(EntityCard, {
2000
+ children: tools.map((tool) => /* @__PURE__ */ jsxDEV8(EntityCard, {
1119
2001
  cardTitle: tool.name,
1120
2002
  cardSubtitle: `v${tool.version}`,
1121
- meta: /* @__PURE__ */ jsxDEV4("p", {
2003
+ meta: /* @__PURE__ */ jsxDEV8("p", {
1122
2004
  className: "text-muted-foreground text-sm",
1123
2005
  children: tool.description
1124
2006
  }, undefined, false, undefined, this),
1125
- chips: /* @__PURE__ */ jsxDEV4(StatusChip2, {
2007
+ chips: /* @__PURE__ */ jsxDEV8(StatusChip3, {
1126
2008
  tone: getStatusTone2(tool.status),
1127
2009
  label: tool.status
1128
2010
  }, undefined, false, undefined, this),
1129
- footer: /* @__PURE__ */ jsxDEV4("code", {
2011
+ footer: /* @__PURE__ */ jsxDEV8("code", {
1130
2012
  className: "text-muted-foreground text-xs",
1131
2013
  children: tool.name
1132
2014
  }, undefined, false, undefined, this),
@@ -1141,19 +2023,19 @@ function ToolRegistryView({
1141
2023
 
1142
2024
  // src/ui/AgentDashboard.tsx
1143
2025
  import {
1144
- Button as Button4,
2026
+ Button as Button5,
1145
2027
  StatCard as StatCard3,
1146
2028
  StatCardGroup as StatCardGroup3
1147
2029
  } from "@contractspec/lib.design-system";
1148
- import { useCallback as useCallback5, useMemo as useMemo3, useState as useState7 } from "react";
1149
- import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
2030
+ import { useCallback as useCallback5, useMemo as useMemo4, useState as useState8 } from "react";
2031
+ import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
1150
2032
  "use client";
1151
2033
  function AgentDashboard() {
1152
- const [activeTab, setActiveTab] = useState7("runs");
1153
- const [isCreateModalOpen, setIsCreateModalOpen] = useState7(false);
1154
- const [selectedAgent, setSelectedAgent] = useState7(null);
1155
- const [isAgentActionsOpen, setIsAgentActionsOpen] = useState7(false);
1156
- const { metrics, refetch: refetchRuns } = useRunList();
2034
+ const [activeTab, setActiveTab] = useState8("runs");
2035
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState8(false);
2036
+ const [selectedAgent, setSelectedAgent] = useState8(null);
2037
+ const [isAgentActionsOpen, setIsAgentActionsOpen] = useState8(false);
2038
+ const { data: runData, metrics, refetch: refetchRuns } = useRunList();
1157
2039
  const { refetch: refetchAgents } = useAgentList();
1158
2040
  const mutations = useAgentMutations({
1159
2041
  onSuccess: () => {
@@ -1171,7 +2053,7 @@ function AgentDashboard() {
1171
2053
  { id: "tools", label: "Tools", icon: "\uD83D\uDD27" },
1172
2054
  { id: "metrics", label: "Metrics", icon: "\uD83D\uDCCA" }
1173
2055
  ];
1174
- const summaryStats = useMemo3(() => {
2056
+ const summaryStats = useMemo4(() => {
1175
2057
  if (!metrics) {
1176
2058
  return [
1177
2059
  { label: "Total Runs", value: "-", hint: "Loading..." },
@@ -1203,20 +2085,20 @@ function AgentDashboard() {
1203
2085
  }
1204
2086
  ];
1205
2087
  }, [metrics]);
1206
- return /* @__PURE__ */ jsxDEV5("div", {
2088
+ return /* @__PURE__ */ jsxDEV9("div", {
1207
2089
  className: "space-y-6",
1208
2090
  children: [
1209
- /* @__PURE__ */ jsxDEV5("div", {
2091
+ /* @__PURE__ */ jsxDEV9("div", {
1210
2092
  className: "flex items-center justify-between",
1211
2093
  children: [
1212
- /* @__PURE__ */ jsxDEV5("h2", {
2094
+ /* @__PURE__ */ jsxDEV9("h2", {
1213
2095
  className: "font-bold text-2xl",
1214
2096
  children: "AI Agent Console"
1215
2097
  }, undefined, false, undefined, this),
1216
- /* @__PURE__ */ jsxDEV5(Button4, {
2098
+ /* @__PURE__ */ jsxDEV9(Button5, {
1217
2099
  onPress: () => setIsCreateModalOpen(true),
1218
2100
  children: [
1219
- /* @__PURE__ */ jsxDEV5("span", {
2101
+ /* @__PURE__ */ jsxDEV9("span", {
1220
2102
  className: "mr-2",
1221
2103
  children: "+"
1222
2104
  }, undefined, false, undefined, this),
@@ -1225,45 +2107,48 @@ function AgentDashboard() {
1225
2107
  }, undefined, true, undefined, this)
1226
2108
  ]
1227
2109
  }, undefined, true, undefined, this),
1228
- /* @__PURE__ */ jsxDEV5(StatCardGroup3, {
1229
- children: summaryStats.map((stat, i) => /* @__PURE__ */ jsxDEV5(StatCard3, {
2110
+ /* @__PURE__ */ jsxDEV9(StatCardGroup3, {
2111
+ children: summaryStats.map((stat, i) => /* @__PURE__ */ jsxDEV9(StatCard3, {
1230
2112
  label: stat.label,
1231
2113
  value: stat.value,
1232
2114
  hint: stat.hint
1233
2115
  }, i, false, undefined, this))
1234
2116
  }, undefined, false, undefined, this),
1235
- /* @__PURE__ */ jsxDEV5("nav", {
2117
+ /* @__PURE__ */ jsxDEV9(AgentVisualizationOverview, {
2118
+ runs: runData?.items ?? []
2119
+ }, undefined, false, undefined, this),
2120
+ /* @__PURE__ */ jsxDEV9("nav", {
1236
2121
  className: "flex gap-1 rounded-lg bg-muted p-1",
1237
2122
  role: "tablist",
1238
- children: tabs.map((tab) => /* @__PURE__ */ jsxDEV5("button", {
2123
+ children: tabs.map((tab) => /* @__PURE__ */ jsxDEV9("button", {
1239
2124
  type: "button",
1240
2125
  role: "tab",
1241
2126
  "aria-selected": activeTab === tab.id,
1242
2127
  onClick: () => setActiveTab(tab.id),
1243
2128
  className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
1244
2129
  children: [
1245
- /* @__PURE__ */ jsxDEV5("span", {
2130
+ /* @__PURE__ */ jsxDEV9("span", {
1246
2131
  children: tab.icon
1247
2132
  }, undefined, false, undefined, this),
1248
2133
  tab.label
1249
2134
  ]
1250
2135
  }, tab.id, true, undefined, this))
1251
2136
  }, undefined, false, undefined, this),
1252
- /* @__PURE__ */ jsxDEV5("div", {
2137
+ /* @__PURE__ */ jsxDEV9("div", {
1253
2138
  className: "min-h-[400px]",
1254
2139
  role: "tabpanel",
1255
2140
  children: [
1256
- activeTab === "runs" && /* @__PURE__ */ jsxDEV5(RunListView, {}, undefined, false, undefined, this),
1257
- activeTab === "agents" && /* @__PURE__ */ jsxDEV5(AgentListViewWithActions, {
2141
+ activeTab === "runs" && /* @__PURE__ */ jsxDEV9(RunListView, {}, undefined, false, undefined, this),
2142
+ activeTab === "agents" && /* @__PURE__ */ jsxDEV9(AgentListViewWithActions, {
1258
2143
  onAgentClick: handleAgentClick
1259
2144
  }, undefined, false, undefined, this),
1260
- activeTab === "tools" && /* @__PURE__ */ jsxDEV5(ToolRegistryView, {}, undefined, false, undefined, this),
1261
- activeTab === "metrics" && /* @__PURE__ */ jsxDEV5(MetricsView, {
2145
+ activeTab === "tools" && /* @__PURE__ */ jsxDEV9(ToolRegistryView, {}, undefined, false, undefined, this),
2146
+ activeTab === "metrics" && /* @__PURE__ */ jsxDEV9(MetricsView, {
1262
2147
  metrics
1263
2148
  }, undefined, false, undefined, this)
1264
2149
  ]
1265
2150
  }, undefined, true, undefined, this),
1266
- /* @__PURE__ */ jsxDEV5(CreateAgentModal, {
2151
+ /* @__PURE__ */ jsxDEV9(CreateAgentModal, {
1267
2152
  isOpen: isCreateModalOpen,
1268
2153
  onClose: () => setIsCreateModalOpen(false),
1269
2154
  onSubmit: async (input) => {
@@ -1271,7 +2156,7 @@ function AgentDashboard() {
1271
2156
  },
1272
2157
  isLoading: mutations.createState.loading
1273
2158
  }, undefined, false, undefined, this),
1274
- /* @__PURE__ */ jsxDEV5(AgentActionsModal, {
2159
+ /* @__PURE__ */ jsxDEV9(AgentActionsModal, {
1275
2160
  isOpen: isAgentActionsOpen,
1276
2161
  agent: selectedAgent,
1277
2162
  onClose: () => {
@@ -1300,22 +2185,22 @@ function AgentListViewWithActions({
1300
2185
  }) {
1301
2186
  const { data, loading, error, stats, refetch } = useAgentList();
1302
2187
  if (loading && !data) {
1303
- return /* @__PURE__ */ jsxDEV5("div", {
2188
+ return /* @__PURE__ */ jsxDEV9("div", {
1304
2189
  className: "flex h-64 items-center justify-center text-muted-foreground",
1305
2190
  children: "Loading agents..."
1306
2191
  }, undefined, false, undefined, this);
1307
2192
  }
1308
2193
  if (error) {
1309
- return /* @__PURE__ */ jsxDEV5("div", {
2194
+ return /* @__PURE__ */ jsxDEV9("div", {
1310
2195
  className: "flex h-64 flex-col items-center justify-center text-destructive",
1311
2196
  children: [
1312
- /* @__PURE__ */ jsxDEV5("p", {
2197
+ /* @__PURE__ */ jsxDEV9("p", {
1313
2198
  children: [
1314
2199
  "Failed to load agents: ",
1315
2200
  error.message
1316
2201
  ]
1317
2202
  }, undefined, true, undefined, this),
1318
- /* @__PURE__ */ jsxDEV5(Button4, {
2203
+ /* @__PURE__ */ jsxDEV9(Button5, {
1319
2204
  variant: "outline",
1320
2205
  onPress: refetch,
1321
2206
  className: "mt-2",
@@ -1325,47 +2210,47 @@ function AgentListViewWithActions({
1325
2210
  }, undefined, true, undefined, this);
1326
2211
  }
1327
2212
  if (!data?.items.length) {
1328
- return /* @__PURE__ */ jsxDEV5("div", {
2213
+ return /* @__PURE__ */ jsxDEV9("div", {
1329
2214
  className: "flex h-64 flex-col items-center justify-center text-muted-foreground",
1330
2215
  children: [
1331
- /* @__PURE__ */ jsxDEV5("p", {
2216
+ /* @__PURE__ */ jsxDEV9("p", {
1332
2217
  className: "font-medium text-lg",
1333
2218
  children: "No agents yet"
1334
2219
  }, undefined, false, undefined, this),
1335
- /* @__PURE__ */ jsxDEV5("p", {
2220
+ /* @__PURE__ */ jsxDEV9("p", {
1336
2221
  className: "text-sm",
1337
2222
  children: "Create your first AI agent to get started."
1338
2223
  }, undefined, false, undefined, this)
1339
2224
  ]
1340
2225
  }, undefined, true, undefined, this);
1341
2226
  }
1342
- return /* @__PURE__ */ jsxDEV5("div", {
2227
+ return /* @__PURE__ */ jsxDEV9("div", {
1343
2228
  className: "space-y-4",
1344
2229
  children: [
1345
- stats && /* @__PURE__ */ jsxDEV5("div", {
2230
+ stats && /* @__PURE__ */ jsxDEV9("div", {
1346
2231
  className: "flex gap-4 text-sm",
1347
2232
  children: [
1348
- /* @__PURE__ */ jsxDEV5("span", {
2233
+ /* @__PURE__ */ jsxDEV9("span", {
1349
2234
  children: [
1350
2235
  "Total: ",
1351
2236
  stats.total
1352
2237
  ]
1353
2238
  }, undefined, true, undefined, this),
1354
- /* @__PURE__ */ jsxDEV5("span", {
2239
+ /* @__PURE__ */ jsxDEV9("span", {
1355
2240
  className: "text-green-600",
1356
2241
  children: [
1357
2242
  "Active: ",
1358
2243
  stats.active
1359
2244
  ]
1360
2245
  }, undefined, true, undefined, this),
1361
- /* @__PURE__ */ jsxDEV5("span", {
2246
+ /* @__PURE__ */ jsxDEV9("span", {
1362
2247
  className: "text-yellow-600",
1363
2248
  children: [
1364
2249
  "Paused: ",
1365
2250
  stats.paused
1366
2251
  ]
1367
2252
  }, undefined, true, undefined, this),
1368
- /* @__PURE__ */ jsxDEV5("span", {
2253
+ /* @__PURE__ */ jsxDEV9("span", {
1369
2254
  className: "text-blue-600",
1370
2255
  children: [
1371
2256
  "Draft: ",
@@ -1374,9 +2259,9 @@ function AgentListViewWithActions({
1374
2259
  }, undefined, true, undefined, this)
1375
2260
  ]
1376
2261
  }, undefined, true, undefined, this),
1377
- /* @__PURE__ */ jsxDEV5("div", {
2262
+ /* @__PURE__ */ jsxDEV9("div", {
1378
2263
  className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3",
1379
- children: data.items.map((agent) => /* @__PURE__ */ jsxDEV5(AgentCard, {
2264
+ children: data.items.map((agent) => /* @__PURE__ */ jsxDEV9(AgentCard, {
1380
2265
  agent,
1381
2266
  onClick: () => onAgentClick(agent)
1382
2267
  }, agent.id, false, undefined, this))
@@ -1391,7 +2276,7 @@ function AgentCard({ agent, onClick }) {
1391
2276
  PAUSED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
1392
2277
  ARCHIVED: "bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"
1393
2278
  };
1394
- return /* @__PURE__ */ jsxDEV5("div", {
2279
+ return /* @__PURE__ */ jsxDEV9("div", {
1395
2280
  onClick,
1396
2281
  className: "cursor-pointer rounded-xl border border-border bg-card p-4 transition-all hover:shadow-md",
1397
2282
  role: "button",
@@ -1401,17 +2286,17 @@ function AgentCard({ agent, onClick }) {
1401
2286
  onClick();
1402
2287
  },
1403
2288
  children: [
1404
- /* @__PURE__ */ jsxDEV5("div", {
2289
+ /* @__PURE__ */ jsxDEV9("div", {
1405
2290
  className: "flex items-start justify-between",
1406
2291
  children: [
1407
- /* @__PURE__ */ jsxDEV5("div", {
2292
+ /* @__PURE__ */ jsxDEV9("div", {
1408
2293
  className: "min-w-0 flex-1",
1409
2294
  children: [
1410
- /* @__PURE__ */ jsxDEV5("h3", {
2295
+ /* @__PURE__ */ jsxDEV9("h3", {
1411
2296
  className: "truncate font-semibold",
1412
2297
  children: agent.name
1413
2298
  }, undefined, false, undefined, this),
1414
- /* @__PURE__ */ jsxDEV5("p", {
2299
+ /* @__PURE__ */ jsxDEV9("p", {
1415
2300
  className: "text-muted-foreground text-sm",
1416
2301
  children: [
1417
2302
  agent.modelProvider,
@@ -1421,24 +2306,24 @@ function AgentCard({ agent, onClick }) {
1421
2306
  }, undefined, true, undefined, this)
1422
2307
  ]
1423
2308
  }, undefined, true, undefined, this),
1424
- /* @__PURE__ */ jsxDEV5("span", {
2309
+ /* @__PURE__ */ jsxDEV9("span", {
1425
2310
  className: `rounded-full px-2 py-0.5 font-medium text-xs ${statusColors[agent.status]}`,
1426
2311
  children: agent.status
1427
2312
  }, undefined, false, undefined, this)
1428
2313
  ]
1429
2314
  }, undefined, true, undefined, this),
1430
- agent.description && /* @__PURE__ */ jsxDEV5("p", {
2315
+ agent.description && /* @__PURE__ */ jsxDEV9("p", {
1431
2316
  className: "mt-2 line-clamp-2 text-muted-foreground text-sm",
1432
2317
  children: agent.description
1433
2318
  }, undefined, false, undefined, this),
1434
- /* @__PURE__ */ jsxDEV5("div", {
2319
+ /* @__PURE__ */ jsxDEV9("div", {
1435
2320
  className: "mt-3 flex items-center justify-between",
1436
2321
  children: [
1437
- /* @__PURE__ */ jsxDEV5("span", {
2322
+ /* @__PURE__ */ jsxDEV9("span", {
1438
2323
  className: "text-muted-foreground text-xs",
1439
2324
  children: agent.modelName
1440
2325
  }, undefined, false, undefined, this),
1441
- /* @__PURE__ */ jsxDEV5(Button4, {
2326
+ /* @__PURE__ */ jsxDEV9(Button5, {
1442
2327
  variant: "ghost",
1443
2328
  size: "sm",
1444
2329
  onPress: onClick,
@@ -1451,40 +2336,40 @@ function AgentCard({ agent, onClick }) {
1451
2336
  }
1452
2337
  function MetricsView({ metrics }) {
1453
2338
  if (!metrics) {
1454
- return /* @__PURE__ */ jsxDEV5("div", {
2339
+ return /* @__PURE__ */ jsxDEV9("div", {
1455
2340
  className: "flex h-64 items-center justify-center text-muted-foreground",
1456
2341
  children: "Loading metrics..."
1457
2342
  }, undefined, false, undefined, this);
1458
2343
  }
1459
2344
  const completedRuns = Math.round(metrics.totalRuns * metrics.successRate);
1460
2345
  const failedRuns = metrics.totalRuns - completedRuns;
1461
- return /* @__PURE__ */ jsxDEV5("div", {
2346
+ return /* @__PURE__ */ jsxDEV9("div", {
1462
2347
  className: "space-y-6",
1463
2348
  children: [
1464
- /* @__PURE__ */ jsxDEV5("h3", {
2349
+ /* @__PURE__ */ jsxDEV9("h3", {
1465
2350
  className: "font-semibold text-lg",
1466
2351
  children: "Usage Analytics"
1467
2352
  }, undefined, false, undefined, this),
1468
- /* @__PURE__ */ jsxDEV5("div", {
2353
+ /* @__PURE__ */ jsxDEV9("div", {
1469
2354
  className: "grid gap-6 md:grid-cols-2",
1470
2355
  children: [
1471
- /* @__PURE__ */ jsxDEV5("div", {
2356
+ /* @__PURE__ */ jsxDEV9("div", {
1472
2357
  className: "rounded-xl border border-border bg-card p-4",
1473
2358
  children: [
1474
- /* @__PURE__ */ jsxDEV5("h4", {
2359
+ /* @__PURE__ */ jsxDEV9("h4", {
1475
2360
  className: "font-medium",
1476
2361
  children: "Run Outcomes"
1477
2362
  }, undefined, false, undefined, this),
1478
- /* @__PURE__ */ jsxDEV5("div", {
2363
+ /* @__PURE__ */ jsxDEV9("div", {
1479
2364
  className: "mt-4 space-y-3",
1480
2365
  children: [
1481
- /* @__PURE__ */ jsxDEV5(ProgressBar, {
2366
+ /* @__PURE__ */ jsxDEV9(ProgressBar, {
1482
2367
  label: "Completed",
1483
2368
  value: completedRuns,
1484
2369
  total: metrics.totalRuns,
1485
2370
  color: "bg-green-500"
1486
2371
  }, undefined, false, undefined, this),
1487
- /* @__PURE__ */ jsxDEV5(ProgressBar, {
2372
+ /* @__PURE__ */ jsxDEV9(ProgressBar, {
1488
2373
  label: "Failed",
1489
2374
  value: failedRuns,
1490
2375
  total: metrics.totalRuns,
@@ -1494,23 +2379,23 @@ function MetricsView({ metrics }) {
1494
2379
  }, undefined, true, undefined, this)
1495
2380
  ]
1496
2381
  }, undefined, true, undefined, this),
1497
- /* @__PURE__ */ jsxDEV5("div", {
2382
+ /* @__PURE__ */ jsxDEV9("div", {
1498
2383
  className: "rounded-xl border border-border bg-card p-4",
1499
2384
  children: [
1500
- /* @__PURE__ */ jsxDEV5("h4", {
2385
+ /* @__PURE__ */ jsxDEV9("h4", {
1501
2386
  className: "font-medium",
1502
2387
  children: "Performance"
1503
2388
  }, undefined, false, undefined, this),
1504
- /* @__PURE__ */ jsxDEV5("dl", {
2389
+ /* @__PURE__ */ jsxDEV9("dl", {
1505
2390
  className: "mt-4 grid grid-cols-2 gap-4",
1506
2391
  children: [
1507
- /* @__PURE__ */ jsxDEV5("div", {
2392
+ /* @__PURE__ */ jsxDEV9("div", {
1508
2393
  children: [
1509
- /* @__PURE__ */ jsxDEV5("dt", {
2394
+ /* @__PURE__ */ jsxDEV9("dt", {
1510
2395
  className: "text-muted-foreground text-sm",
1511
2396
  children: "Avg Duration"
1512
2397
  }, undefined, false, undefined, this),
1513
- /* @__PURE__ */ jsxDEV5("dd", {
2398
+ /* @__PURE__ */ jsxDEV9("dd", {
1514
2399
  className: "font-semibold text-xl",
1515
2400
  children: [
1516
2401
  (metrics.averageDurationMs / 1000).toFixed(1),
@@ -1519,13 +2404,13 @@ function MetricsView({ metrics }) {
1519
2404
  }, undefined, true, undefined, this)
1520
2405
  ]
1521
2406
  }, undefined, true, undefined, this),
1522
- /* @__PURE__ */ jsxDEV5("div", {
2407
+ /* @__PURE__ */ jsxDEV9("div", {
1523
2408
  children: [
1524
- /* @__PURE__ */ jsxDEV5("dt", {
2409
+ /* @__PURE__ */ jsxDEV9("dt", {
1525
2410
  className: "text-muted-foreground text-sm",
1526
2411
  children: "Success Rate"
1527
2412
  }, undefined, false, undefined, this),
1528
- /* @__PURE__ */ jsxDEV5("dd", {
2413
+ /* @__PURE__ */ jsxDEV9("dd", {
1529
2414
  className: "font-semibold text-xl",
1530
2415
  children: [
1531
2416
  (metrics.successRate * 100).toFixed(0),
@@ -1540,35 +2425,35 @@ function MetricsView({ metrics }) {
1540
2425
  }, undefined, true, undefined, this)
1541
2426
  ]
1542
2427
  }, undefined, true, undefined, this),
1543
- /* @__PURE__ */ jsxDEV5("div", {
2428
+ /* @__PURE__ */ jsxDEV9("div", {
1544
2429
  className: "rounded-xl border border-border bg-card p-4",
1545
2430
  children: [
1546
- /* @__PURE__ */ jsxDEV5("h4", {
2431
+ /* @__PURE__ */ jsxDEV9("h4", {
1547
2432
  className: "font-medium",
1548
2433
  children: "Key Metrics"
1549
2434
  }, undefined, false, undefined, this),
1550
- /* @__PURE__ */ jsxDEV5("dl", {
2435
+ /* @__PURE__ */ jsxDEV9("dl", {
1551
2436
  className: "mt-4 grid gap-4 sm:grid-cols-3",
1552
2437
  children: [
1553
- /* @__PURE__ */ jsxDEV5("div", {
2438
+ /* @__PURE__ */ jsxDEV9("div", {
1554
2439
  children: [
1555
- /* @__PURE__ */ jsxDEV5("dt", {
2440
+ /* @__PURE__ */ jsxDEV9("dt", {
1556
2441
  className: "text-muted-foreground text-sm",
1557
2442
  children: "Total Runs"
1558
2443
  }, undefined, false, undefined, this),
1559
- /* @__PURE__ */ jsxDEV5("dd", {
2444
+ /* @__PURE__ */ jsxDEV9("dd", {
1560
2445
  className: "font-semibold text-2xl",
1561
2446
  children: metrics.totalRuns.toLocaleString()
1562
2447
  }, undefined, false, undefined, this)
1563
2448
  ]
1564
2449
  }, undefined, true, undefined, this),
1565
- /* @__PURE__ */ jsxDEV5("div", {
2450
+ /* @__PURE__ */ jsxDEV9("div", {
1566
2451
  children: [
1567
- /* @__PURE__ */ jsxDEV5("dt", {
2452
+ /* @__PURE__ */ jsxDEV9("dt", {
1568
2453
  className: "text-muted-foreground text-sm",
1569
2454
  children: "Total Tokens"
1570
2455
  }, undefined, false, undefined, this),
1571
- /* @__PURE__ */ jsxDEV5("dd", {
2456
+ /* @__PURE__ */ jsxDEV9("dd", {
1572
2457
  className: "font-semibold text-2xl",
1573
2458
  children: [
1574
2459
  (metrics.totalTokens / 1000).toFixed(0),
@@ -1577,13 +2462,13 @@ function MetricsView({ metrics }) {
1577
2462
  }, undefined, true, undefined, this)
1578
2463
  ]
1579
2464
  }, undefined, true, undefined, this),
1580
- /* @__PURE__ */ jsxDEV5("div", {
2465
+ /* @__PURE__ */ jsxDEV9("div", {
1581
2466
  children: [
1582
- /* @__PURE__ */ jsxDEV5("dt", {
2467
+ /* @__PURE__ */ jsxDEV9("dt", {
1583
2468
  className: "text-muted-foreground text-sm",
1584
2469
  children: "Cost per Run"
1585
2470
  }, undefined, false, undefined, this),
1586
- /* @__PURE__ */ jsxDEV5("dd", {
2471
+ /* @__PURE__ */ jsxDEV9("dd", {
1587
2472
  className: "font-semibold text-2xl",
1588
2473
  children: [
1589
2474
  "$",
@@ -1606,15 +2491,15 @@ function ProgressBar({
1606
2491
  color
1607
2492
  }) {
1608
2493
  const pct = total > 0 ? value / total * 100 : 0;
1609
- return /* @__PURE__ */ jsxDEV5("div", {
2494
+ return /* @__PURE__ */ jsxDEV9("div", {
1610
2495
  children: [
1611
- /* @__PURE__ */ jsxDEV5("div", {
2496
+ /* @__PURE__ */ jsxDEV9("div", {
1612
2497
  className: "flex justify-between text-sm",
1613
2498
  children: [
1614
- /* @__PURE__ */ jsxDEV5("span", {
2499
+ /* @__PURE__ */ jsxDEV9("span", {
1615
2500
  children: label
1616
2501
  }, undefined, false, undefined, this),
1617
- /* @__PURE__ */ jsxDEV5("span", {
2502
+ /* @__PURE__ */ jsxDEV9("span", {
1618
2503
  className: "text-muted-foreground",
1619
2504
  children: [
1620
2505
  value,
@@ -1625,9 +2510,9 @@ function ProgressBar({
1625
2510
  }, undefined, true, undefined, this)
1626
2511
  ]
1627
2512
  }, undefined, true, undefined, this),
1628
- /* @__PURE__ */ jsxDEV5("div", {
2513
+ /* @__PURE__ */ jsxDEV9("div", {
1629
2514
  className: "mt-1 h-2 overflow-hidden rounded-full bg-muted",
1630
- children: /* @__PURE__ */ jsxDEV5("div", {
2515
+ children: /* @__PURE__ */ jsxDEV9("div", {
1631
2516
  className: `h-full ${color}`,
1632
2517
  style: { width: `${pct}%` }
1633
2518
  }, undefined, false, undefined, this)
@@ -1705,16 +2590,25 @@ var agentConsoleOverlays = [
1705
2590
  ];
1706
2591
  // src/ui/renderers/agent-list.markdown.ts
1707
2592
  import {
1708
- mockListAgentsHandler
1709
- } from "@contractspec/example.agent-console/handlers";
2593
+ AGENT_CONSOLE_DEMO_ORGANIZATION_ID as AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
2594
+ AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID2,
2595
+ createAgentConsoleDemoHandlers
2596
+ } from "@contractspec/example.agent-console/shared";
1710
2597
  var agentListMarkdownRenderer = {
1711
2598
  target: "markdown",
1712
- render: async (desc) => {
2599
+ render: async (desc, ctx) => {
1713
2600
  if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
1714
2601
  throw new Error("agentListMarkdownRenderer: not AgentListView");
1715
2602
  }
1716
- const data = await mockListAgentsHandler({
1717
- organizationId: "demo-org",
2603
+ const data = Array.isArray(ctx?.data) ? {
2604
+ items: ctx.data,
2605
+ total: ctx.data.length,
2606
+ hasMore: false
2607
+ } : await createAgentConsoleDemoHandlers({
2608
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2
2609
+ }).listAgents({
2610
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2,
2611
+ organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
1718
2612
  limit: 50,
1719
2613
  offset: 0
1720
2614
  });
@@ -1758,16 +2652,16 @@ var agentListMarkdownRenderer = {
1758
2652
 
1759
2653
  // src/ui/views/AgentListView.tsx
1760
2654
  import {
1761
- Button as Button5,
2655
+ Button as Button6,
1762
2656
  EmptyState as EmptyState3,
1763
2657
  EntityCard as EntityCard2,
1764
2658
  ErrorState as ErrorState3,
1765
2659
  LoaderBlock as LoaderBlock3,
1766
2660
  StatCard as StatCard4,
1767
2661
  StatCardGroup as StatCardGroup4,
1768
- StatusChip as StatusChip3
2662
+ StatusChip as StatusChip4
1769
2663
  } from "@contractspec/lib.design-system";
1770
- import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
2664
+ import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
1771
2665
  "use client";
1772
2666
  function getStatusTone3(status) {
1773
2667
  switch (status) {
@@ -1785,12 +2679,12 @@ function getStatusTone3(status) {
1785
2679
  function AgentListView() {
1786
2680
  const { data, loading, error, stats, refetch } = useAgentList();
1787
2681
  if (loading && !data) {
1788
- return /* @__PURE__ */ jsxDEV6(LoaderBlock3, {
2682
+ return /* @__PURE__ */ jsxDEV10(LoaderBlock3, {
1789
2683
  label: "Loading agents..."
1790
2684
  }, undefined, false, undefined, this);
1791
2685
  }
1792
2686
  if (error) {
1793
- return /* @__PURE__ */ jsxDEV6(ErrorState3, {
2687
+ return /* @__PURE__ */ jsxDEV10(ErrorState3, {
1794
2688
  title: "Failed to load agents",
1795
2689
  description: error.message,
1796
2690
  onRetry: refetch,
@@ -1798,61 +2692,61 @@ function AgentListView() {
1798
2692
  }, undefined, false, undefined, this);
1799
2693
  }
1800
2694
  if (!data?.items.length) {
1801
- return /* @__PURE__ */ jsxDEV6(EmptyState3, {
2695
+ return /* @__PURE__ */ jsxDEV10(EmptyState3, {
1802
2696
  title: "No agents yet",
1803
2697
  description: "Create your first AI agent to get started."
1804
2698
  }, undefined, false, undefined, this);
1805
2699
  }
1806
- return /* @__PURE__ */ jsxDEV6("div", {
2700
+ return /* @__PURE__ */ jsxDEV10("div", {
1807
2701
  className: "space-y-6",
1808
2702
  children: [
1809
- stats && /* @__PURE__ */ jsxDEV6(StatCardGroup4, {
2703
+ stats && /* @__PURE__ */ jsxDEV10(StatCardGroup4, {
1810
2704
  children: [
1811
- /* @__PURE__ */ jsxDEV6(StatCard4, {
2705
+ /* @__PURE__ */ jsxDEV10(StatCard4, {
1812
2706
  label: "Total Agents",
1813
2707
  value: stats.total
1814
2708
  }, undefined, false, undefined, this),
1815
- /* @__PURE__ */ jsxDEV6(StatCard4, {
2709
+ /* @__PURE__ */ jsxDEV10(StatCard4, {
1816
2710
  label: "Active",
1817
2711
  value: stats.active
1818
2712
  }, undefined, false, undefined, this),
1819
- /* @__PURE__ */ jsxDEV6(StatCard4, {
2713
+ /* @__PURE__ */ jsxDEV10(StatCard4, {
1820
2714
  label: "Paused",
1821
2715
  value: stats.paused
1822
2716
  }, undefined, false, undefined, this),
1823
- /* @__PURE__ */ jsxDEV6(StatCard4, {
2717
+ /* @__PURE__ */ jsxDEV10(StatCard4, {
1824
2718
  label: "Draft",
1825
2719
  value: stats.draft
1826
2720
  }, undefined, false, undefined, this)
1827
2721
  ]
1828
2722
  }, undefined, true, undefined, this),
1829
- /* @__PURE__ */ jsxDEV6("div", {
2723
+ /* @__PURE__ */ jsxDEV10("div", {
1830
2724
  className: "flex items-center justify-between",
1831
2725
  children: [
1832
- /* @__PURE__ */ jsxDEV6("h3", {
2726
+ /* @__PURE__ */ jsxDEV10("h3", {
1833
2727
  className: "font-semibold text-lg",
1834
2728
  children: "Agents"
1835
2729
  }, undefined, false, undefined, this),
1836
- /* @__PURE__ */ jsxDEV6(Button5, {
2730
+ /* @__PURE__ */ jsxDEV10(Button6, {
1837
2731
  onPress: () => alert("Create Agent clicked!"),
1838
2732
  children: "Create Agent"
1839
2733
  }, undefined, false, undefined, this)
1840
2734
  ]
1841
2735
  }, undefined, true, undefined, this),
1842
- /* @__PURE__ */ jsxDEV6("div", {
2736
+ /* @__PURE__ */ jsxDEV10("div", {
1843
2737
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
1844
- children: data.items.map((agent) => /* @__PURE__ */ jsxDEV6(EntityCard2, {
2738
+ children: data.items.map((agent) => /* @__PURE__ */ jsxDEV10(EntityCard2, {
1845
2739
  cardTitle: agent.name,
1846
2740
  cardSubtitle: agent.modelName,
1847
- meta: /* @__PURE__ */ jsxDEV6("p", {
2741
+ meta: /* @__PURE__ */ jsxDEV10("p", {
1848
2742
  className: "text-muted-foreground text-sm",
1849
2743
  children: agent.description
1850
2744
  }, undefined, false, undefined, this),
1851
- chips: /* @__PURE__ */ jsxDEV6(StatusChip3, {
2745
+ chips: /* @__PURE__ */ jsxDEV10(StatusChip4, {
1852
2746
  tone: getStatusTone3(agent.status),
1853
2747
  label: agent.status
1854
2748
  }, undefined, false, undefined, this),
1855
- footer: /* @__PURE__ */ jsxDEV6("span", {
2749
+ footer: /* @__PURE__ */ jsxDEV10("span", {
1856
2750
  className: "text-muted-foreground text-xs",
1857
2751
  children: [
1858
2752
  "Created ",
@@ -1867,7 +2761,7 @@ function AgentListView() {
1867
2761
  }
1868
2762
 
1869
2763
  // src/ui/renderers/agent-list.renderer.tsx
1870
- import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
2764
+ import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
1871
2765
  var agentListReactRenderer = {
1872
2766
  target: "react",
1873
2767
  render: async (desc) => {
@@ -1877,16 +2771,14 @@ var agentListReactRenderer = {
1877
2771
  if (desc.source.componentKey !== "AgentListView") {
1878
2772
  throw new Error(`AgentListRenderer: unknown component ${desc.source.componentKey}`);
1879
2773
  }
1880
- return /* @__PURE__ */ jsxDEV7(AgentListView, {}, undefined, false, undefined, this);
2774
+ return /* @__PURE__ */ jsxDEV11(AgentListView, {}, undefined, false, undefined, this);
1881
2775
  }
1882
2776
  };
1883
2777
 
1884
2778
  // src/ui/renderers/dashboard.markdown.ts
1885
2779
  import {
1886
- mockListAgentsHandler as mockListAgentsHandler2,
1887
- mockListRunsHandler,
1888
- mockListToolsHandler
1889
- } from "@contractspec/example.agent-console/handlers";
2780
+ getFallbackAgentConsoleDashboardData
2781
+ } from "@contractspec/example.agent-console/shared";
1890
2782
  function formatDuration2(ms) {
1891
2783
  if (ms < 1000)
1892
2784
  return `${ms}ms`;
@@ -1896,29 +2788,18 @@ function formatDuration2(ms) {
1896
2788
  }
1897
2789
  var agentDashboardMarkdownRenderer = {
1898
2790
  target: "markdown",
1899
- render: async (desc) => {
2791
+ render: async (desc, ctx) => {
1900
2792
  if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
1901
2793
  throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
1902
2794
  }
1903
- const [agentsData, runsData, toolsData] = await Promise.all([
1904
- mockListAgentsHandler2({
1905
- organizationId: "demo-org",
1906
- limit: 100
1907
- }),
1908
- mockListRunsHandler({
1909
- limit: 100
1910
- }),
1911
- mockListToolsHandler({
1912
- organizationId: "demo-org",
1913
- limit: 100
1914
- })
1915
- ]);
1916
- const activeAgents = agentsData.items.filter((a) => a.status === "ACTIVE").length;
1917
- const completedRuns = runsData.items.filter((r) => r.status === "COMPLETED").length;
1918
- const failedRuns = runsData.items.filter((r) => r.status === "FAILED").length;
1919
- const totalTokens = runsData.items.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
1920
- const totalCost = runsData.items.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
1921
- const activeTools = toolsData.items.filter((t) => t.status === "ACTIVE").length;
2795
+ const data = ctx?.data ?? await getFallbackAgentConsoleDashboardData();
2796
+ const activeAgents = data.agents.filter((a) => a.status === "ACTIVE").length;
2797
+ const completedRuns = data.runs.filter((r) => r.status === "COMPLETED").length;
2798
+ const failedRuns = data.runs.filter((r) => r.status === "FAILED").length;
2799
+ const totalTokens = data.runs.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
2800
+ const totalCost = data.runs.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
2801
+ const activeTools = data.tools.filter((t) => t.status === "ACTIVE").length;
2802
+ const visualizationItems = createAgentVisualizationItems(data.runs);
1922
2803
  const lines = [
1923
2804
  "# Agent Console Dashboard",
1924
2805
  "",
@@ -1928,51 +2809,57 @@ var agentDashboardMarkdownRenderer = {
1928
2809
  "",
1929
2810
  "| Metric | Value |",
1930
2811
  "|--------|-------|",
1931
- `| Total Agents | ${agentsData.total} |`,
2812
+ `| Total Agents | ${data.summary.totalAgents} |`,
1932
2813
  `| Active Agents | ${activeAgents} |`,
1933
- `| Total Runs | ${runsData.total} |`,
2814
+ `| Total Runs | ${data.summary.totalRuns} |`,
1934
2815
  `| Completed Runs | ${completedRuns} |`,
1935
2816
  `| Failed Runs | ${failedRuns} |`,
1936
2817
  `| Total Tokens | ${totalTokens.toLocaleString()} |`,
1937
2818
  `| Total Cost | $${totalCost.toFixed(4)} |`,
1938
- `| Total Tools | ${toolsData.total} |`,
2819
+ `| Total Tools | ${data.summary.totalTools} |`,
1939
2820
  `| Active Tools | ${activeTools} |`,
1940
2821
  "",
1941
2822
  "## Agents",
1942
2823
  ""
1943
2824
  ];
1944
- if (agentsData.items.length === 0) {
2825
+ if (data.agents.length === 0) {
1945
2826
  lines.push("_No agents configured._");
1946
2827
  } else {
1947
2828
  lines.push("| Agent | Model | Status | Description |");
1948
2829
  lines.push("|-------|-------|--------|-------------|");
1949
- for (const agent of agentsData.items.slice(0, 5)) {
2830
+ for (const agent of data.agents.slice(0, 5)) {
1950
2831
  lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
1951
2832
  }
1952
- if (agentsData.items.length > 5) {
1953
- lines.push(`| ... | ... | ... | _${agentsData.total - 5} more_ |`);
2833
+ if (data.agents.length > 5) {
2834
+ lines.push(`| ... | ... | ... | _${data.summary.totalAgents - 5} more_ |`);
1954
2835
  }
1955
2836
  }
1956
2837
  lines.push("");
1957
2838
  lines.push("## Recent Runs");
1958
2839
  lines.push("");
1959
- if (runsData.items.length === 0) {
2840
+ if (data.runs.length === 0) {
1960
2841
  lines.push("_No runs yet._");
1961
2842
  } else {
1962
2843
  lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
1963
2844
  lines.push("|--------|-------|--------|----------|--------|------|");
1964
- for (const run of runsData.items.slice(0, 5)) {
2845
+ for (const run of data.runs.slice(0, 5)) {
1965
2846
  lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration2(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
1966
2847
  }
1967
- if (runsData.items.length > 5) {
1968
- lines.push(`| ... | ... | ... | ... | ... | _${runsData.total - 5} more_ |`);
2848
+ if (data.runs.length > 5) {
2849
+ lines.push(`| ... | ... | ... | ... | ... | _${data.summary.totalRuns - 5} more_ |`);
1969
2850
  }
1970
2851
  }
1971
2852
  lines.push("");
2853
+ lines.push("## Visualization Overview");
2854
+ lines.push("");
2855
+ for (const item of visualizationItems) {
2856
+ lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
2857
+ }
2858
+ lines.push("");
1972
2859
  lines.push("## Tools");
1973
2860
  lines.push("");
1974
2861
  const toolsByCategory = {};
1975
- for (const tool of toolsData.items) {
2862
+ for (const tool of data.tools) {
1976
2863
  const cat = tool.category;
1977
2864
  if (!toolsByCategory[cat])
1978
2865
  toolsByCategory[cat] = [];
@@ -1997,7 +2884,10 @@ var agentDashboardMarkdownRenderer = {
1997
2884
  };
1998
2885
 
1999
2886
  // src/ui/renderers/run-list.markdown.ts
2000
- import { mockListRunsHandler as mockListRunsHandler2 } from "@contractspec/example.agent-console/handlers";
2887
+ import {
2888
+ AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID3,
2889
+ createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers2
2890
+ } from "@contractspec/example.agent-console/shared";
2001
2891
  function formatDuration3(ms) {
2002
2892
  if (ms < 1000)
2003
2893
  return `${ms}ms`;
@@ -2007,12 +2897,14 @@ function formatDuration3(ms) {
2007
2897
  }
2008
2898
  var runListMarkdownRenderer = {
2009
2899
  target: "markdown",
2010
- render: async (desc) => {
2900
+ render: async (desc, ctx) => {
2011
2901
  if (desc.source.type !== "component" || desc.source.componentKey !== "RunListView") {
2012
2902
  throw new Error("runListMarkdownRenderer: not RunListView");
2013
2903
  }
2014
- const data = await mockListRunsHandler2({
2015
- organizationId: "demo-org",
2904
+ const data = Array.isArray(ctx?.data) ? { items: ctx.data, total: ctx.data.length, hasMore: false } : await createAgentConsoleDemoHandlers2({
2905
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3
2906
+ }).listRuns({
2907
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3,
2016
2908
  limit: 20,
2017
2909
  offset: 0
2018
2910
  });
@@ -2040,15 +2932,26 @@ var runListMarkdownRenderer = {
2040
2932
  };
2041
2933
 
2042
2934
  // src/ui/renderers/tool-registry.markdown.ts
2043
- import { mockListToolsHandler as mockListToolsHandler2 } from "@contractspec/example.agent-console/handlers";
2935
+ import {
2936
+ AGENT_CONSOLE_DEMO_ORGANIZATION_ID as AGENT_CONSOLE_DEMO_ORGANIZATION_ID3,
2937
+ AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID4,
2938
+ createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers3
2939
+ } from "@contractspec/example.agent-console/shared";
2044
2940
  var toolRegistryMarkdownRenderer = {
2045
2941
  target: "markdown",
2046
- render: async (desc) => {
2942
+ render: async (desc, ctx) => {
2047
2943
  if (desc.source.type !== "component" || desc.source.componentKey !== "ToolRegistryView") {
2048
2944
  throw new Error("toolRegistryMarkdownRenderer: not ToolRegistryView");
2049
2945
  }
2050
- const data = await mockListToolsHandler2({
2051
- organizationId: "demo-org",
2946
+ const data = Array.isArray(ctx?.data) ? {
2947
+ items: ctx.data,
2948
+ total: ctx.data.length,
2949
+ hasMore: false
2950
+ } : await createAgentConsoleDemoHandlers3({
2951
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID4
2952
+ }).listTools({
2953
+ projectId: AGENT_CONSOLE_DEMO_PROJECT_ID4,
2954
+ organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID3,
2052
2955
  limit: 50,
2053
2956
  offset: 0
2054
2957
  });