@contractspec/example.agent-console 3.7.7 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +3 -1
  3. package/CHANGELOG.md +29 -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.js +14 -5
  124. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  125. package/dist/ui/renderers/index.js +245 -49
  126. package/dist/ui/renderers/run-list.markdown.js +9 -4
  127. package/dist/ui/renderers/tool-registry.markdown.d.ts +1 -1
  128. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  129. package/dist/ui/views/RunDataTable.d.ts +18 -0
  130. package/dist/ui/views/RunDataTable.js +327 -0
  131. package/dist/ui/views/RunListView.js +359 -127
  132. package/dist/ui/views/index.js +406 -174
  133. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  134. package/dist/ui/views/run-data-table.columns.js +272 -0
  135. package/dist/ui/views/run-list.shared.d.ts +14 -0
  136. package/dist/ui/views/run-list.shared.js +178 -0
  137. package/dist/visualizations/catalog.d.ts +10 -0
  138. package/dist/visualizations/catalog.js +135 -0
  139. package/dist/visualizations/index.d.ts +2 -0
  140. package/dist/visualizations/index.js +188 -0
  141. package/dist/visualizations/selectors.d.ts +3 -0
  142. package/dist/visualizations/selectors.js +182 -0
  143. package/dist/visualizations/selectors.test.d.ts +1 -0
  144. package/package.json +112 -10
  145. package/proofs/agent-console-meetup.replay.json +220 -0
  146. package/src/agent/agent.handler.ts +18 -1
  147. package/src/agent.feature.ts +3 -0
  148. package/src/docs/agent-console.docblock.ts +11 -8
  149. package/src/example.test.ts +75 -0
  150. package/src/example.ts +2 -3
  151. package/src/handlers/agent.handlers.ts +55 -2
  152. package/src/handlers/index.ts +18 -2
  153. package/src/handlers/mock-handlers.test.ts +77 -0
  154. package/src/index.ts +2 -0
  155. package/src/proof/index.ts +2 -0
  156. package/src/proof/meetup-proof.runtime.ts +196 -0
  157. package/src/proof/meetup-proof.scenario.ts +99 -0
  158. package/src/proof/meetup-proof.suite.ts +29 -0
  159. package/src/proof/meetup-proof.test.ts +28 -0
  160. package/src/proof/meetup-proof.ts +130 -0
  161. package/src/run/run.handler.ts +17 -1
  162. package/src/shared/demo-dashboard-data.ts +58 -0
  163. package/src/shared/demo-runtime-seed.ts +139 -0
  164. package/src/shared/demo-runtime.test.ts +169 -0
  165. package/src/shared/demo-runtime.ts +260 -0
  166. package/src/shared/index.ts +11 -0
  167. package/src/shared/mock-runs.ts +5 -0
  168. package/src/tool/tool.handler.ts +21 -4
  169. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  170. package/src/ui/AgentDashboard.tsx +4 -1
  171. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  172. package/src/ui/hooks/useAgentMutations.ts +19 -11
  173. package/src/ui/hooks/useRunList.ts +41 -9
  174. package/src/ui/renderers/agent-list.markdown.ts +31 -12
  175. package/src/ui/renderers/dashboard.markdown.ts +37 -42
  176. package/src/ui/renderers/run-list.markdown.ts +16 -8
  177. package/src/ui/renderers/tool-registry.markdown.ts +21 -9
  178. package/src/ui/views/RunDataTable.tsx +74 -0
  179. package/src/ui/views/RunListView.tsx +37 -111
  180. package/src/ui/views/run-data-table.columns.tsx +102 -0
  181. package/src/ui/views/run-list.shared.tsx +139 -0
  182. package/src/visualizations/catalog.ts +132 -0
  183. package/src/visualizations/index.ts +2 -0
  184. package/src/visualizations/selectors.test.ts +12 -0
  185. package/src/visualizations/selectors.ts +70 -0
  186. package/tsdown.config.js +17 -0
@@ -0,0 +1,271 @@
1
+ // src/ui/views/run-list.shared.tsx
2
+ import { Button, StatusChip } from "@contractspec/lib.design-system";
3
+ import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
4
+ import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
5
+ import { jsxDEV } from "react/jsx-dev-runtime";
6
+ "use client";
7
+ function getStatusTone(status) {
8
+ switch (status) {
9
+ case "COMPLETED":
10
+ return "success";
11
+ case "RUNNING":
12
+ return "warning";
13
+ case "QUEUED":
14
+ return "neutral";
15
+ case "FAILED":
16
+ case "CANCELLED":
17
+ return "danger";
18
+ default:
19
+ return "neutral";
20
+ }
21
+ }
22
+ function formatDuration(ms) {
23
+ if (!ms)
24
+ return "-";
25
+ if (ms < 1000)
26
+ return `${ms}ms`;
27
+ if (ms < 60000)
28
+ return `${(ms / 1000).toFixed(1)}s`;
29
+ return `${(ms / 60000).toFixed(1)}m`;
30
+ }
31
+ function formatTokens(tokens) {
32
+ if (tokens < 1000)
33
+ return tokens.toString();
34
+ if (tokens < 1e6)
35
+ return `${(tokens / 1000).toFixed(1)}K`;
36
+ return `${(tokens / 1e6).toFixed(2)}M`;
37
+ }
38
+ function formatCost(cost) {
39
+ if (!cost)
40
+ return "-";
41
+ return `$${cost.toFixed(4)}`;
42
+ }
43
+ function formatJson(value) {
44
+ return JSON.stringify(value ?? null, null, 2);
45
+ }
46
+ function RunExpandedContent({ run }) {
47
+ return /* @__PURE__ */ jsxDEV(VStack, {
48
+ gap: "sm",
49
+ className: "py-2",
50
+ children: [
51
+ /* @__PURE__ */ jsxDEV(HStack, {
52
+ justify: "between",
53
+ className: "flex-wrap",
54
+ children: [
55
+ /* @__PURE__ */ jsxDEV(StatusChip, {
56
+ tone: getStatusTone(run.status),
57
+ label: run.status
58
+ }, undefined, false, undefined, this),
59
+ /* @__PURE__ */ jsxDEV(Text, {
60
+ className: "text-muted-foreground text-sm",
61
+ children: [
62
+ "Queued ",
63
+ run.queuedAt.toLocaleString()
64
+ ]
65
+ }, undefined, true, undefined, this)
66
+ ]
67
+ }, undefined, true, undefined, this),
68
+ /* @__PURE__ */ jsxDEV(HStack, {
69
+ gap: "lg",
70
+ className: "flex-wrap",
71
+ children: [
72
+ /* @__PURE__ */ jsxDEV(Text, {
73
+ className: "text-muted-foreground text-sm",
74
+ children: [
75
+ "Prompt ",
76
+ formatTokens(run.promptTokens)
77
+ ]
78
+ }, undefined, true, undefined, this),
79
+ /* @__PURE__ */ jsxDEV(Text, {
80
+ className: "text-muted-foreground text-sm",
81
+ children: [
82
+ "Completion ",
83
+ formatTokens(run.completionTokens)
84
+ ]
85
+ }, undefined, true, undefined, this),
86
+ /* @__PURE__ */ jsxDEV(Text, {
87
+ className: "text-muted-foreground text-sm",
88
+ children: [
89
+ "Duration ",
90
+ formatDuration(run.durationMs)
91
+ ]
92
+ }, undefined, true, undefined, this)
93
+ ]
94
+ }, undefined, true, undefined, this),
95
+ /* @__PURE__ */ jsxDEV(VStack, {
96
+ gap: "xs",
97
+ children: [
98
+ /* @__PURE__ */ jsxDEV(Text, {
99
+ className: "font-medium text-sm",
100
+ children: "Input"
101
+ }, undefined, false, undefined, this),
102
+ /* @__PURE__ */ jsxDEV("pre", {
103
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
104
+ children: formatJson(run.input)
105
+ }, undefined, false, undefined, this)
106
+ ]
107
+ }, undefined, true, undefined, this),
108
+ /* @__PURE__ */ jsxDEV(VStack, {
109
+ gap: "xs",
110
+ children: [
111
+ /* @__PURE__ */ jsxDEV(Text, {
112
+ className: "font-medium text-sm",
113
+ children: "Output"
114
+ }, undefined, false, undefined, this),
115
+ /* @__PURE__ */ jsxDEV("pre", {
116
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
117
+ children: formatJson(run.output ?? run.errorMessage ?? "Pending")
118
+ }, undefined, false, undefined, this)
119
+ ]
120
+ }, undefined, true, undefined, this)
121
+ ]
122
+ }, undefined, true, undefined, this);
123
+ }
124
+ function RunTableToolbar({
125
+ controller,
126
+ totalRuns
127
+ }) {
128
+ const firstRow = controller.rows[0];
129
+ const queuedColumn = controller.columns.find((column) => column.id === "queuedAt");
130
+ const durationColumn = controller.columns.find((column) => column.id === "durationMs");
131
+ const costColumn = controller.columns.find((column) => column.id === "estimatedCostUsd");
132
+ return /* @__PURE__ */ jsxDEV(HStack, {
133
+ gap: "sm",
134
+ className: "flex-wrap",
135
+ children: [
136
+ /* @__PURE__ */ jsxDEV(Text, {
137
+ className: "text-muted-foreground text-sm",
138
+ children: [
139
+ totalRuns,
140
+ " runs"
141
+ ]
142
+ }, undefined, true, undefined, this),
143
+ /* @__PURE__ */ jsxDEV(Button, {
144
+ variant: "outline",
145
+ size: "sm",
146
+ onPress: () => firstRow?.toggleExpanded?.(!firstRow?.isExpanded),
147
+ children: "Expand Latest Run"
148
+ }, undefined, false, undefined, this),
149
+ /* @__PURE__ */ jsxDEV(Button, {
150
+ variant: "outline",
151
+ size: "sm",
152
+ onPress: () => queuedColumn?.toggleVisibility?.(!queuedColumn?.visible),
153
+ children: queuedColumn?.visible ? "Hide Time" : "Show Time"
154
+ }, undefined, false, undefined, this),
155
+ /* @__PURE__ */ jsxDEV(Button, {
156
+ variant: "outline",
157
+ size: "sm",
158
+ onPress: () => durationColumn?.toggleVisibility?.(!durationColumn?.visible),
159
+ children: durationColumn?.visible ? "Hide Duration" : "Show Duration"
160
+ }, undefined, false, undefined, this),
161
+ /* @__PURE__ */ jsxDEV(Button, {
162
+ variant: "outline",
163
+ size: "sm",
164
+ onPress: () => costColumn?.toggleVisibility?.(!costColumn?.visible),
165
+ children: costColumn?.visible ? "Hide Cost" : "Show Cost"
166
+ }, undefined, false, undefined, this)
167
+ ]
168
+ }, undefined, true, undefined, this);
169
+ }
170
+
171
+ // src/ui/views/run-data-table.columns.tsx
172
+ import { StatusChip as StatusChip2 } from "@contractspec/lib.design-system";
173
+ import { VStack as VStack2 } from "@contractspec/lib.ui-kit-web/ui/stack";
174
+ import { Text as Text2 } from "@contractspec/lib.ui-kit-web/ui/text";
175
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
176
+ "use client";
177
+ function createRunTableColumns() {
178
+ return [
179
+ {
180
+ id: "queuedAt",
181
+ header: "Run",
182
+ label: "Run",
183
+ accessor: (run) => run.queuedAt.getTime(),
184
+ cell: ({ item }) => /* @__PURE__ */ jsxDEV2(VStack2, {
185
+ gap: "xs",
186
+ children: [
187
+ /* @__PURE__ */ jsxDEV2(Text2, {
188
+ className: "font-mono text-sm",
189
+ children: item.id.slice(-8)
190
+ }, undefined, false, undefined, this),
191
+ /* @__PURE__ */ jsxDEV2(Text2, {
192
+ className: "text-muted-foreground text-xs",
193
+ children: item.queuedAt.toLocaleString()
194
+ }, undefined, false, undefined, this)
195
+ ]
196
+ }, undefined, true, undefined, this),
197
+ size: 220,
198
+ minSize: 180,
199
+ canSort: true,
200
+ canHide: true,
201
+ canResize: true
202
+ },
203
+ {
204
+ id: "agentName",
205
+ header: "Agent",
206
+ label: "Agent",
207
+ accessor: (run) => run.agentName ?? "Unknown Agent",
208
+ cell: ({ value }) => /* @__PURE__ */ jsxDEV2(Text2, {
209
+ className: "font-medium",
210
+ children: typeof value === "string" ? value : "Unknown Agent"
211
+ }, undefined, false, undefined, this),
212
+ size: 220,
213
+ canSort: true,
214
+ canResize: true
215
+ },
216
+ {
217
+ id: "status",
218
+ header: "Status",
219
+ label: "Status",
220
+ accessorKey: "status",
221
+ cell: ({ value }) => {
222
+ const status = typeof value === "string" ? value : "QUEUED";
223
+ return /* @__PURE__ */ jsxDEV2(StatusChip2, {
224
+ tone: getStatusTone(status),
225
+ label: status
226
+ }, undefined, false, undefined, this);
227
+ },
228
+ size: 150,
229
+ canSort: true,
230
+ canResize: true
231
+ },
232
+ {
233
+ id: "totalTokens",
234
+ header: "Tokens",
235
+ label: "Tokens",
236
+ accessorKey: "totalTokens",
237
+ cell: ({ value }) => formatTokens(Number(value ?? 0)),
238
+ align: "right",
239
+ size: 140,
240
+ canSort: true,
241
+ canResize: true
242
+ },
243
+ {
244
+ id: "durationMs",
245
+ header: "Duration",
246
+ label: "Duration",
247
+ accessorKey: "durationMs",
248
+ cell: ({ value }) => formatDuration(typeof value === "number" ? value : undefined),
249
+ align: "right",
250
+ size: 140,
251
+ canSort: true,
252
+ canHide: true,
253
+ canResize: true
254
+ },
255
+ {
256
+ id: "estimatedCostUsd",
257
+ header: "Cost",
258
+ label: "Cost",
259
+ accessorKey: "estimatedCostUsd",
260
+ cell: ({ value }) => formatCost(typeof value === "number" ? value : undefined),
261
+ align: "right",
262
+ size: 140,
263
+ canSort: true,
264
+ canHide: true,
265
+ canResize: true
266
+ }
267
+ ];
268
+ }
269
+ export {
270
+ createRunTableColumns
271
+ };
@@ -0,0 +1,177 @@
1
+ // src/ui/views/run-list.shared.tsx
2
+ import { Button, StatusChip } from "@contractspec/lib.design-system";
3
+ import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
4
+ import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
5
+ import { jsxDEV } from "react/jsx-dev-runtime";
6
+ "use client";
7
+ function getStatusTone(status) {
8
+ switch (status) {
9
+ case "COMPLETED":
10
+ return "success";
11
+ case "RUNNING":
12
+ return "warning";
13
+ case "QUEUED":
14
+ return "neutral";
15
+ case "FAILED":
16
+ case "CANCELLED":
17
+ return "danger";
18
+ default:
19
+ return "neutral";
20
+ }
21
+ }
22
+ function formatDuration(ms) {
23
+ if (!ms)
24
+ return "-";
25
+ if (ms < 1000)
26
+ return `${ms}ms`;
27
+ if (ms < 60000)
28
+ return `${(ms / 1000).toFixed(1)}s`;
29
+ return `${(ms / 60000).toFixed(1)}m`;
30
+ }
31
+ function formatTokens(tokens) {
32
+ if (tokens < 1000)
33
+ return tokens.toString();
34
+ if (tokens < 1e6)
35
+ return `${(tokens / 1000).toFixed(1)}K`;
36
+ return `${(tokens / 1e6).toFixed(2)}M`;
37
+ }
38
+ function formatCost(cost) {
39
+ if (!cost)
40
+ return "-";
41
+ return `$${cost.toFixed(4)}`;
42
+ }
43
+ function formatJson(value) {
44
+ return JSON.stringify(value ?? null, null, 2);
45
+ }
46
+ function RunExpandedContent({ run }) {
47
+ return /* @__PURE__ */ jsxDEV(VStack, {
48
+ gap: "sm",
49
+ className: "py-2",
50
+ children: [
51
+ /* @__PURE__ */ jsxDEV(HStack, {
52
+ justify: "between",
53
+ className: "flex-wrap",
54
+ children: [
55
+ /* @__PURE__ */ jsxDEV(StatusChip, {
56
+ tone: getStatusTone(run.status),
57
+ label: run.status
58
+ }, undefined, false, undefined, this),
59
+ /* @__PURE__ */ jsxDEV(Text, {
60
+ className: "text-muted-foreground text-sm",
61
+ children: [
62
+ "Queued ",
63
+ run.queuedAt.toLocaleString()
64
+ ]
65
+ }, undefined, true, undefined, this)
66
+ ]
67
+ }, undefined, true, undefined, this),
68
+ /* @__PURE__ */ jsxDEV(HStack, {
69
+ gap: "lg",
70
+ className: "flex-wrap",
71
+ children: [
72
+ /* @__PURE__ */ jsxDEV(Text, {
73
+ className: "text-muted-foreground text-sm",
74
+ children: [
75
+ "Prompt ",
76
+ formatTokens(run.promptTokens)
77
+ ]
78
+ }, undefined, true, undefined, this),
79
+ /* @__PURE__ */ jsxDEV(Text, {
80
+ className: "text-muted-foreground text-sm",
81
+ children: [
82
+ "Completion ",
83
+ formatTokens(run.completionTokens)
84
+ ]
85
+ }, undefined, true, undefined, this),
86
+ /* @__PURE__ */ jsxDEV(Text, {
87
+ className: "text-muted-foreground text-sm",
88
+ children: [
89
+ "Duration ",
90
+ formatDuration(run.durationMs)
91
+ ]
92
+ }, undefined, true, undefined, this)
93
+ ]
94
+ }, undefined, true, undefined, this),
95
+ /* @__PURE__ */ jsxDEV(VStack, {
96
+ gap: "xs",
97
+ children: [
98
+ /* @__PURE__ */ jsxDEV(Text, {
99
+ className: "font-medium text-sm",
100
+ children: "Input"
101
+ }, undefined, false, undefined, this),
102
+ /* @__PURE__ */ jsxDEV("pre", {
103
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
104
+ children: formatJson(run.input)
105
+ }, undefined, false, undefined, this)
106
+ ]
107
+ }, undefined, true, undefined, this),
108
+ /* @__PURE__ */ jsxDEV(VStack, {
109
+ gap: "xs",
110
+ children: [
111
+ /* @__PURE__ */ jsxDEV(Text, {
112
+ className: "font-medium text-sm",
113
+ children: "Output"
114
+ }, undefined, false, undefined, this),
115
+ /* @__PURE__ */ jsxDEV("pre", {
116
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
117
+ children: formatJson(run.output ?? run.errorMessage ?? "Pending")
118
+ }, undefined, false, undefined, this)
119
+ ]
120
+ }, undefined, true, undefined, this)
121
+ ]
122
+ }, undefined, true, undefined, this);
123
+ }
124
+ function RunTableToolbar({
125
+ controller,
126
+ totalRuns
127
+ }) {
128
+ const firstRow = controller.rows[0];
129
+ const queuedColumn = controller.columns.find((column) => column.id === "queuedAt");
130
+ const durationColumn = controller.columns.find((column) => column.id === "durationMs");
131
+ const costColumn = controller.columns.find((column) => column.id === "estimatedCostUsd");
132
+ return /* @__PURE__ */ jsxDEV(HStack, {
133
+ gap: "sm",
134
+ className: "flex-wrap",
135
+ children: [
136
+ /* @__PURE__ */ jsxDEV(Text, {
137
+ className: "text-muted-foreground text-sm",
138
+ children: [
139
+ totalRuns,
140
+ " runs"
141
+ ]
142
+ }, undefined, true, undefined, this),
143
+ /* @__PURE__ */ jsxDEV(Button, {
144
+ variant: "outline",
145
+ size: "sm",
146
+ onPress: () => firstRow?.toggleExpanded?.(!firstRow?.isExpanded),
147
+ children: "Expand Latest Run"
148
+ }, undefined, false, undefined, this),
149
+ /* @__PURE__ */ jsxDEV(Button, {
150
+ variant: "outline",
151
+ size: "sm",
152
+ onPress: () => queuedColumn?.toggleVisibility?.(!queuedColumn?.visible),
153
+ children: queuedColumn?.visible ? "Hide Time" : "Show Time"
154
+ }, undefined, false, undefined, this),
155
+ /* @__PURE__ */ jsxDEV(Button, {
156
+ variant: "outline",
157
+ size: "sm",
158
+ onPress: () => durationColumn?.toggleVisibility?.(!durationColumn?.visible),
159
+ children: durationColumn?.visible ? "Hide Duration" : "Show Duration"
160
+ }, undefined, false, undefined, this),
161
+ /* @__PURE__ */ jsxDEV(Button, {
162
+ variant: "outline",
163
+ size: "sm",
164
+ onPress: () => costColumn?.toggleVisibility?.(!costColumn?.visible),
165
+ children: costColumn?.visible ? "Hide Cost" : "Show Cost"
166
+ }, undefined, false, undefined, this)
167
+ ]
168
+ }, undefined, true, undefined, this);
169
+ }
170
+ export {
171
+ getStatusTone,
172
+ formatTokens,
173
+ formatDuration,
174
+ formatCost,
175
+ RunTableToolbar,
176
+ RunExpandedContent
177
+ };
@@ -0,0 +1,134 @@
1
+ // src/visualizations/catalog.ts
2
+ import {
3
+ defineVisualization,
4
+ VisualizationRegistry
5
+ } from "@contractspec/lib.contracts-spec/visualizations";
6
+ var RUN_LIST_REF = { key: "agent.run.list", version: "1.0.0" };
7
+ var META = {
8
+ version: "1.0.0",
9
+ domain: "ai-ops",
10
+ stability: "experimental",
11
+ owners: ["@example.agent-console"],
12
+ tags: ["agent-console", "visualization", "operations"]
13
+ };
14
+ var AgentRunStatusVisualization = defineVisualization({
15
+ meta: {
16
+ ...META,
17
+ key: "agent-console.visualization.run-status",
18
+ title: "Run Status Breakdown",
19
+ description: "Distribution of run outcomes across the current sample.",
20
+ goal: "Make operational success and failure mix visible at a glance.",
21
+ context: "Agent operations overview."
22
+ },
23
+ source: { primary: RUN_LIST_REF, resultPath: "data" },
24
+ visualization: {
25
+ kind: "pie",
26
+ nameDimension: "status",
27
+ valueMeasure: "runs",
28
+ dimensions: [
29
+ { key: "status", label: "Status", dataPath: "status", type: "category" }
30
+ ],
31
+ measures: [
32
+ { key: "runs", label: "Runs", dataPath: "runs", format: "number" }
33
+ ],
34
+ table: { caption: "Run counts by status." }
35
+ }
36
+ });
37
+ var AgentRunActivityVisualization = defineVisualization({
38
+ meta: {
39
+ ...META,
40
+ key: "agent-console.visualization.run-activity",
41
+ title: "Recent Run Activity",
42
+ description: "Daily run volume across the current sample.",
43
+ goal: "Show whether agent activity is rising or slowing down.",
44
+ context: "Operations trend monitoring."
45
+ },
46
+ source: { primary: RUN_LIST_REF, resultPath: "data" },
47
+ visualization: {
48
+ kind: "cartesian",
49
+ variant: "line",
50
+ xDimension: "day",
51
+ yMeasures: ["runs"],
52
+ dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
53
+ measures: [
54
+ {
55
+ key: "runs",
56
+ label: "Runs",
57
+ dataPath: "runs",
58
+ format: "number",
59
+ color: "#0f766e"
60
+ }
61
+ ],
62
+ table: { caption: "Daily run counts." }
63
+ }
64
+ });
65
+ var AgentRunEfficiencyVisualization = defineVisualization({
66
+ meta: {
67
+ ...META,
68
+ key: "agent-console.visualization.run-efficiency",
69
+ title: "Duration vs Tokens",
70
+ description: "Scatter chart comparing token consumption and runtime.",
71
+ goal: "Reveal outlier runs that are slow relative to their token usage.",
72
+ context: "Operational performance diagnostics."
73
+ },
74
+ source: { primary: RUN_LIST_REF, resultPath: "data" },
75
+ visualization: {
76
+ kind: "cartesian",
77
+ variant: "scatter",
78
+ xDimension: "totalTokens",
79
+ yMeasures: ["durationMs"],
80
+ dimensions: [
81
+ {
82
+ key: "totalTokens",
83
+ label: "Total Tokens",
84
+ dataPath: "totalTokens",
85
+ type: "number"
86
+ }
87
+ ],
88
+ measures: [
89
+ {
90
+ key: "durationMs",
91
+ label: "Duration",
92
+ dataPath: "durationMs",
93
+ format: "duration",
94
+ color: "#7c3aed"
95
+ },
96
+ {
97
+ key: "estimatedCostUsd",
98
+ label: "Cost",
99
+ dataPath: "estimatedCostUsd",
100
+ format: "currency"
101
+ }
102
+ ],
103
+ series: [
104
+ {
105
+ key: "runs",
106
+ label: "Runs",
107
+ measure: "durationMs",
108
+ type: "scatter",
109
+ color: "#7c3aed"
110
+ }
111
+ ],
112
+ table: { caption: "Run duration versus token usage." }
113
+ }
114
+ });
115
+ var AgentVisualizationSpecs = [
116
+ AgentRunStatusVisualization,
117
+ AgentRunActivityVisualization,
118
+ AgentRunEfficiencyVisualization
119
+ ];
120
+ var AgentVisualizationRegistry = new VisualizationRegistry([
121
+ ...AgentVisualizationSpecs
122
+ ]);
123
+ var AgentVisualizationRefs = AgentVisualizationSpecs.map((spec) => ({
124
+ key: spec.meta.key,
125
+ version: spec.meta.version
126
+ }));
127
+ export {
128
+ AgentVisualizationSpecs,
129
+ AgentVisualizationRegistry,
130
+ AgentVisualizationRefs,
131
+ AgentRunStatusVisualization,
132
+ AgentRunEfficiencyVisualization,
133
+ AgentRunActivityVisualization
134
+ };