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