@contractspec/example.agent-console 3.7.6 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/.turbo/turbo-build.log +126 -105
  2. package/AGENTS.md +52 -31
  3. package/CHANGELOG.md +29 -0
  4. package/README.md +112 -83
  5. package/dist/agent/agent.event.js +1 -1
  6. package/dist/agent/agent.handler.d.ts +3 -0
  7. package/dist/agent/agent.handler.js +730 -1
  8. package/dist/agent/agent.operation.js +1 -1
  9. package/dist/agent/index.d.ts +5 -5
  10. package/dist/agent/index.js +74 -73
  11. package/dist/agent.feature.js +179 -0
  12. package/dist/browser/agent/agent.event.js +1 -1
  13. package/dist/browser/agent/agent.handler.js +730 -1
  14. package/dist/browser/agent/agent.operation.js +1 -1
  15. package/dist/browser/agent/index.js +74 -73
  16. package/dist/browser/agent.feature.js +179 -0
  17. package/dist/browser/docs/agent-console.docblock.js +11 -8
  18. package/dist/browser/docs/index.js +11 -8
  19. package/dist/browser/example.js +2 -3
  20. package/dist/browser/handlers/agent.handlers.js +1883 -2
  21. package/dist/browser/handlers/index.js +2142 -8
  22. package/dist/browser/index.js +4075 -3161
  23. package/dist/browser/presentations/index.js +51 -51
  24. package/dist/browser/run/index.js +380 -374
  25. package/dist/browser/run/run.event.js +2 -2
  26. package/dist/browser/run/run.handler.js +666 -1
  27. package/dist/browser/run/run.presentation.js +2 -2
  28. package/dist/browser/shared/index.js +293 -1
  29. package/dist/browser/shared/mock-runs.js +5 -0
  30. package/dist/browser/tool/index.js +161 -161
  31. package/dist/browser/tool/tool.event.js +1 -1
  32. package/dist/browser/tool/tool.handler.js +479 -3
  33. package/dist/browser/tool/tool.presentation.js +2 -2
  34. package/dist/browser/ui/AgentDashboard.js +1816 -931
  35. package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
  36. package/dist/browser/ui/AgentRunList.js +360 -128
  37. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  38. package/dist/browser/ui/hooks/index.js +611 -161
  39. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  40. package/dist/browser/ui/hooks/useAgentMutations.js +444 -9
  41. package/dist/browser/ui/hooks/useRunList.js +26 -11
  42. package/dist/browser/ui/hooks/useToolList.js +1 -1
  43. package/dist/browser/ui/index.js +2161 -1258
  44. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  45. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  46. package/dist/browser/ui/modals/index.js +297 -297
  47. package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
  48. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  49. package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
  50. package/dist/browser/ui/renderers/index.js +359 -163
  51. package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
  52. package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
  53. package/dist/browser/ui/views/AgentListView.js +7 -7
  54. package/dist/browser/ui/views/RunDataTable.js +326 -0
  55. package/dist/browser/ui/views/RunListView.js +360 -128
  56. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  57. package/dist/browser/ui/views/index.js +478 -246
  58. package/dist/browser/ui/views/run-data-table.columns.js +271 -0
  59. package/dist/browser/ui/views/run-list.shared.js +177 -0
  60. package/dist/browser/visualizations/catalog.js +134 -0
  61. package/dist/browser/visualizations/index.js +187 -0
  62. package/dist/browser/visualizations/selectors.js +181 -0
  63. package/dist/docs/agent-console.docblock.js +11 -8
  64. package/dist/docs/index.js +11 -8
  65. package/dist/example.js +2 -3
  66. package/dist/example.test.d.ts +1 -0
  67. package/dist/handlers/agent.handlers.d.ts +2 -0
  68. package/dist/handlers/agent.handlers.js +1883 -2
  69. package/dist/handlers/index.d.ts +2 -4
  70. package/dist/handlers/index.js +2142 -8
  71. package/dist/handlers/mock-handlers.test.d.ts +1 -0
  72. package/dist/index.d.ts +6 -4
  73. package/dist/index.js +4075 -3161
  74. package/dist/node/agent/agent.event.js +1 -1
  75. package/dist/node/agent/agent.handler.js +730 -1
  76. package/dist/node/agent/agent.operation.js +1 -1
  77. package/dist/node/agent/index.js +74 -73
  78. package/dist/node/agent.feature.js +179 -0
  79. package/dist/node/docs/agent-console.docblock.js +11 -8
  80. package/dist/node/docs/index.js +11 -8
  81. package/dist/node/example.js +2 -3
  82. package/dist/node/handlers/agent.handlers.js +1883 -2
  83. package/dist/node/handlers/index.js +2142 -8
  84. package/dist/node/index.js +4075 -3161
  85. package/dist/node/presentations/index.js +51 -51
  86. package/dist/node/run/index.js +380 -374
  87. package/dist/node/run/run.event.js +2 -2
  88. package/dist/node/run/run.handler.js +666 -1
  89. package/dist/node/run/run.presentation.js +2 -2
  90. package/dist/node/shared/index.js +293 -1
  91. package/dist/node/shared/mock-runs.js +5 -0
  92. package/dist/node/tool/index.js +161 -161
  93. package/dist/node/tool/tool.event.js +1 -1
  94. package/dist/node/tool/tool.handler.js +479 -3
  95. package/dist/node/tool/tool.presentation.js +2 -2
  96. package/dist/node/ui/AgentDashboard.js +1816 -931
  97. package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
  98. package/dist/node/ui/AgentRunList.js +360 -128
  99. package/dist/node/ui/AgentToolRegistry.js +9 -9
  100. package/dist/node/ui/hooks/index.js +611 -161
  101. package/dist/node/ui/hooks/useAgentList.js +1 -1
  102. package/dist/node/ui/hooks/useAgentMutations.js +444 -9
  103. package/dist/node/ui/hooks/useRunList.js +26 -11
  104. package/dist/node/ui/hooks/useToolList.js +1 -1
  105. package/dist/node/ui/index.js +2161 -1258
  106. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  107. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  108. package/dist/node/ui/modals/index.js +297 -297
  109. package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
  110. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  111. package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
  112. package/dist/node/ui/renderers/index.js +359 -163
  113. package/dist/node/ui/renderers/run-list.markdown.js +9 -4
  114. package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
  115. package/dist/node/ui/views/AgentListView.js +7 -7
  116. package/dist/node/ui/views/RunDataTable.js +326 -0
  117. package/dist/node/ui/views/RunListView.js +360 -128
  118. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  119. package/dist/node/ui/views/index.js +478 -246
  120. package/dist/node/ui/views/run-data-table.columns.js +271 -0
  121. package/dist/node/ui/views/run-list.shared.js +177 -0
  122. package/dist/node/visualizations/catalog.js +134 -0
  123. package/dist/node/visualizations/index.js +187 -0
  124. package/dist/node/visualizations/selectors.js +181 -0
  125. package/dist/presentations/index.d.ts +3 -5
  126. package/dist/presentations/index.js +51 -51
  127. package/dist/proof/index.d.ts +2 -0
  128. package/dist/proof/meetup-proof.d.ts +10 -0
  129. package/dist/proof/meetup-proof.runtime.d.ts +22 -0
  130. package/dist/proof/meetup-proof.scenario.d.ts +2 -0
  131. package/dist/proof/meetup-proof.suite.d.ts +1 -0
  132. package/dist/proof/meetup-proof.test.d.ts +1 -0
  133. package/dist/run/index.d.ts +7 -7
  134. package/dist/run/index.js +380 -374
  135. package/dist/run/run.event.js +2 -2
  136. package/dist/run/run.handler.d.ts +7 -0
  137. package/dist/run/run.handler.js +666 -1
  138. package/dist/run/run.presentation.js +2 -2
  139. package/dist/shared/demo-dashboard-data.d.ts +16 -0
  140. package/dist/shared/demo-runtime-seed.d.ts +17 -0
  141. package/dist/shared/demo-runtime.d.ts +8 -0
  142. package/dist/shared/demo-runtime.test.d.ts +1 -0
  143. package/dist/shared/index.d.ts +4 -1
  144. package/dist/shared/index.js +293 -1
  145. package/dist/shared/mock-runs.d.ts +4 -0
  146. package/dist/shared/mock-runs.js +5 -0
  147. package/dist/tool/index.d.ts +7 -7
  148. package/dist/tool/index.js +161 -161
  149. package/dist/tool/tool.event.js +1 -1
  150. package/dist/tool/tool.handler.d.ts +3 -0
  151. package/dist/tool/tool.handler.js +479 -3
  152. package/dist/tool/tool.presentation.js +2 -2
  153. package/dist/ui/AgentDashboard.js +1816 -931
  154. package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
  155. package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
  156. package/dist/ui/AgentDashboard.visualizations.js +218 -0
  157. package/dist/ui/AgentRunList.js +360 -128
  158. package/dist/ui/AgentToolRegistry.js +9 -9
  159. package/dist/ui/hooks/index.d.ts +4 -4
  160. package/dist/ui/hooks/index.js +611 -161
  161. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  162. package/dist/ui/hooks/useAgentList.js +1 -1
  163. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  164. package/dist/ui/hooks/useAgentMutations.js +444 -9
  165. package/dist/ui/hooks/useRunList.d.ts +13 -2
  166. package/dist/ui/hooks/useRunList.js +26 -11
  167. package/dist/ui/hooks/useToolList.d.ts +5 -0
  168. package/dist/ui/hooks/useToolList.js +1 -1
  169. package/dist/ui/index.d.ts +3 -3
  170. package/dist/ui/index.js +2161 -1258
  171. package/dist/ui/modals/AgentActionsModal.js +13 -13
  172. package/dist/ui/modals/CreateAgentModal.js +15 -15
  173. package/dist/ui/modals/index.d.ts +1 -1
  174. package/dist/ui/modals/index.js +297 -297
  175. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  176. package/dist/ui/renderers/agent-list.markdown.js +14 -5
  177. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  178. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  179. package/dist/ui/renderers/dashboard.markdown.js +207 -36
  180. package/dist/ui/renderers/index.d.ts +2 -2
  181. package/dist/ui/renderers/index.js +359 -163
  182. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  183. package/dist/ui/renderers/run-list.markdown.js +9 -4
  184. package/dist/ui/renderers/tool-registry.markdown.d.ts +6 -1
  185. package/dist/ui/renderers/tool-registry.markdown.js +15 -4
  186. package/dist/ui/views/AgentListView.js +7 -7
  187. package/dist/ui/views/RunDataTable.d.ts +18 -0
  188. package/dist/ui/views/RunDataTable.js +327 -0
  189. package/dist/ui/views/RunListView.js +360 -128
  190. package/dist/ui/views/ToolRegistryView.js +9 -9
  191. package/dist/ui/views/index.js +478 -246
  192. package/dist/ui/views/run-data-table.columns.d.ts +3 -0
  193. package/dist/ui/views/run-data-table.columns.js +272 -0
  194. package/dist/ui/views/run-list.shared.d.ts +14 -0
  195. package/dist/ui/views/run-list.shared.js +178 -0
  196. package/dist/visualizations/catalog.d.ts +10 -0
  197. package/dist/visualizations/catalog.js +135 -0
  198. package/dist/visualizations/index.d.ts +2 -0
  199. package/dist/visualizations/index.js +188 -0
  200. package/dist/visualizations/selectors.d.ts +3 -0
  201. package/dist/visualizations/selectors.js +182 -0
  202. package/dist/visualizations/selectors.test.d.ts +1 -0
  203. package/package.json +114 -12
  204. package/proofs/agent-console-meetup.replay.json +220 -0
  205. package/src/agent/agent.entity.ts +111 -111
  206. package/src/agent/agent.enum.ts +12 -12
  207. package/src/agent/agent.event.ts +91 -91
  208. package/src/agent/agent.handler.ts +144 -127
  209. package/src/agent/agent.operation.ts +400 -400
  210. package/src/agent/agent.presentation.ts +62 -62
  211. package/src/agent/agent.schema.ts +175 -175
  212. package/src/agent/agent.test-spec.ts +48 -48
  213. package/src/agent/index.ts +46 -51
  214. package/src/agent.capability.ts +11 -11
  215. package/src/agent.feature.ts +134 -131
  216. package/src/docs/agent-console.docblock.ts +52 -49
  217. package/src/example.test.ts +75 -0
  218. package/src/example.ts +34 -35
  219. package/src/handlers/agent.handlers.ts +576 -522
  220. package/src/handlers/index.ts +30 -14
  221. package/src/handlers/mock-handlers.test.ts +77 -0
  222. package/src/index.ts +10 -9
  223. package/src/presentations/index.ts +11 -13
  224. package/src/proof/index.ts +2 -0
  225. package/src/proof/meetup-proof.runtime.ts +196 -0
  226. package/src/proof/meetup-proof.scenario.ts +99 -0
  227. package/src/proof/meetup-proof.suite.ts +29 -0
  228. package/src/proof/meetup-proof.test.ts +28 -0
  229. package/src/proof/meetup-proof.ts +130 -0
  230. package/src/run/index.ts +49 -54
  231. package/src/run/run.entity.ts +137 -137
  232. package/src/run/run.enum.ts +18 -18
  233. package/src/run/run.event.ts +174 -174
  234. package/src/run/run.handler.ts +113 -96
  235. package/src/run/run.operation.ts +474 -474
  236. package/src/run/run.presentation.ts +42 -42
  237. package/src/run/run.schema.ts +126 -126
  238. package/src/run/run.test-spec.ts +48 -48
  239. package/src/seeders/index.ts +21 -21
  240. package/src/shared/demo-dashboard-data.ts +58 -0
  241. package/src/shared/demo-runtime-seed.ts +139 -0
  242. package/src/shared/demo-runtime.test.ts +169 -0
  243. package/src/shared/demo-runtime.ts +260 -0
  244. package/src/shared/index.ts +12 -1
  245. package/src/shared/mock-agents.ts +76 -76
  246. package/src/shared/mock-runs.ts +107 -102
  247. package/src/shared/mock-tools.ts +140 -140
  248. package/src/shared/overlay-types.ts +23 -23
  249. package/src/tool/index.ts +39 -44
  250. package/src/tool/tool.entity.ts +73 -73
  251. package/src/tool/tool.enum.ts +13 -13
  252. package/src/tool/tool.event.ts +80 -80
  253. package/src/tool/tool.handler.ts +124 -107
  254. package/src/tool/tool.operation.ts +328 -328
  255. package/src/tool/tool.presentation.ts +43 -43
  256. package/src/tool/tool.schema.ts +106 -106
  257. package/src/tool/tool.test-spec.ts +48 -48
  258. package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
  259. package/src/ui/AgentDashboard.tsx +351 -348
  260. package/src/ui/AgentDashboard.visualizations.tsx +35 -0
  261. package/src/ui/hooks/index.ts +7 -7
  262. package/src/ui/hooks/useAgentList.ts +57 -56
  263. package/src/ui/hooks/useAgentMutations.ts +168 -159
  264. package/src/ui/hooks/useRunList.ts +90 -57
  265. package/src/ui/hooks/useToolList.ts +102 -101
  266. package/src/ui/index.ts +6 -9
  267. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  268. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  269. package/src/ui/modals/index.ts +1 -1
  270. package/src/ui/overlays/demo-overlays.ts +52 -52
  271. package/src/ui/renderers/agent-list.markdown.ts +81 -61
  272. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  273. package/src/ui/renderers/dashboard.markdown.ts +135 -139
  274. package/src/ui/renderers/index.ts +3 -4
  275. package/src/ui/renderers/run-list.markdown.ts +56 -47
  276. package/src/ui/renderers/tool-registry.markdown.ts +79 -66
  277. package/src/ui/views/AgentListView.tsx +90 -90
  278. package/src/ui/views/RunDataTable.tsx +74 -0
  279. package/src/ui/views/RunListView.tsx +84 -158
  280. package/src/ui/views/ToolRegistryView.tsx +113 -113
  281. package/src/ui/views/run-data-table.columns.tsx +102 -0
  282. package/src/ui/views/run-list.shared.tsx +139 -0
  283. package/src/visualizations/catalog.ts +132 -0
  284. package/src/visualizations/index.ts +2 -0
  285. package/src/visualizations/selectors.test.ts +12 -0
  286. package/src/visualizations/selectors.ts +70 -0
  287. package/tsconfig.json +7 -8
  288. package/tsdown.config.js +24 -3
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useRunList.ts
3
- import { useCallback, useEffect, useState } from "react";
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ import { useCallback, useEffect, useState } from "react";
5
5
  function useRunList(options = {}) {
6
6
  const { handlers, projectId } = useTemplateRuntime();
7
7
  const { agent } = handlers;
@@ -9,7 +9,10 @@ function useRunList(options = {}) {
9
9
  const [metrics, setMetrics] = useState(null);
10
10
  const [loading, setLoading] = useState(true);
11
11
  const [error, setError] = useState(null);
12
- const [page, setPage] = useState(1);
12
+ const [internalPageIndex, setInternalPageIndex] = useState(0);
13
+ const pageSize = options.pageSize ?? options.limit ?? 20;
14
+ const pageIndex = options.pageIndex ?? internalPageIndex;
15
+ const [sort] = options.sorting ?? [];
13
16
  const fetchData = useCallback(async () => {
14
17
  setLoading(true);
15
18
  setError(null);
@@ -19,14 +22,14 @@ function useRunList(options = {}) {
19
22
  projectId,
20
23
  agentId: options.agentId,
21
24
  status: options.status === "all" ? undefined : options.status,
22
- limit: options.limit ?? 20,
23
- offset: (page - 1) * (options.limit ?? 20)
25
+ sortBy: sort?.id,
26
+ sortDirection: sort ? sort.desc ? "desc" : "asc" : undefined,
27
+ limit: pageSize,
28
+ offset: pageIndex * pageSize
24
29
  }),
25
30
  agent.getRunMetrics({
26
31
  projectId,
27
- agentId: options.agentId,
28
- startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
29
- endDate: new Date
32
+ agentId: options.agentId
30
33
  })
31
34
  ]);
32
35
  setData(runsResult);
@@ -36,31 +39,38 @@ function useRunList(options = {}) {
36
39
  } finally {
37
40
  setLoading(false);
38
41
  }
39
- }, [agent, projectId, options.agentId, options.status, options.limit, page]);
42
+ }, [
43
+ agent,
44
+ pageIndex,
45
+ pageSize,
46
+ projectId,
47
+ options.agentId,
48
+ options.status,
49
+ sort?.desc,
50
+ sort?.id
51
+ ]);
40
52
  useEffect(() => {
41
53
  fetchData();
42
54
  }, [fetchData]);
55
+ const hasControlledPagination = options.pageIndex !== undefined;
43
56
  return {
44
57
  data,
45
58
  metrics,
46
59
  loading,
47
60
  error,
48
- page,
61
+ page: pageIndex + 1,
62
+ pageIndex,
63
+ pageSize,
49
64
  refetch: fetchData,
50
- nextPage: () => setPage((p) => p + 1),
51
- prevPage: () => page > 1 && setPage((p) => p - 1)
65
+ nextPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => current + 1),
66
+ prevPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => Math.max(0, current - 1))
52
67
  };
53
68
  }
54
69
 
55
- // src/ui/views/RunListView.tsx
56
- import {
57
- StatCard,
58
- StatCardGroup,
59
- StatusChip,
60
- EmptyState,
61
- LoaderBlock,
62
- ErrorState
63
- } from "@contractspec/lib.design-system";
70
+ // src/ui/views/run-list.shared.tsx
71
+ import { Button, StatusChip } from "@contractspec/lib.design-system";
72
+ import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
73
+ import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
64
74
  import { jsxDEV } from "react/jsx-dev-runtime";
65
75
  "use client";
66
76
  function getStatusTone(status) {
@@ -99,15 +109,320 @@ function formatCost(cost) {
99
109
  return "-";
100
110
  return `$${cost.toFixed(4)}`;
101
111
  }
112
+ function formatJson(value) {
113
+ return JSON.stringify(value ?? null, null, 2);
114
+ }
115
+ function RunExpandedContent({ run }) {
116
+ return /* @__PURE__ */ jsxDEV(VStack, {
117
+ gap: "sm",
118
+ className: "py-2",
119
+ children: [
120
+ /* @__PURE__ */ jsxDEV(HStack, {
121
+ justify: "between",
122
+ className: "flex-wrap",
123
+ children: [
124
+ /* @__PURE__ */ jsxDEV(StatusChip, {
125
+ tone: getStatusTone(run.status),
126
+ label: run.status
127
+ }, undefined, false, undefined, this),
128
+ /* @__PURE__ */ jsxDEV(Text, {
129
+ className: "text-muted-foreground text-sm",
130
+ children: [
131
+ "Queued ",
132
+ run.queuedAt.toLocaleString()
133
+ ]
134
+ }, undefined, true, undefined, this)
135
+ ]
136
+ }, undefined, true, undefined, this),
137
+ /* @__PURE__ */ jsxDEV(HStack, {
138
+ gap: "lg",
139
+ className: "flex-wrap",
140
+ children: [
141
+ /* @__PURE__ */ jsxDEV(Text, {
142
+ className: "text-muted-foreground text-sm",
143
+ children: [
144
+ "Prompt ",
145
+ formatTokens(run.promptTokens)
146
+ ]
147
+ }, undefined, true, undefined, this),
148
+ /* @__PURE__ */ jsxDEV(Text, {
149
+ className: "text-muted-foreground text-sm",
150
+ children: [
151
+ "Completion ",
152
+ formatTokens(run.completionTokens)
153
+ ]
154
+ }, undefined, true, undefined, this),
155
+ /* @__PURE__ */ jsxDEV(Text, {
156
+ className: "text-muted-foreground text-sm",
157
+ children: [
158
+ "Duration ",
159
+ formatDuration(run.durationMs)
160
+ ]
161
+ }, undefined, true, undefined, this)
162
+ ]
163
+ }, undefined, true, undefined, this),
164
+ /* @__PURE__ */ jsxDEV(VStack, {
165
+ gap: "xs",
166
+ children: [
167
+ /* @__PURE__ */ jsxDEV(Text, {
168
+ className: "font-medium text-sm",
169
+ children: "Input"
170
+ }, undefined, false, undefined, this),
171
+ /* @__PURE__ */ jsxDEV("pre", {
172
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
173
+ children: formatJson(run.input)
174
+ }, undefined, false, undefined, this)
175
+ ]
176
+ }, undefined, true, undefined, this),
177
+ /* @__PURE__ */ jsxDEV(VStack, {
178
+ gap: "xs",
179
+ children: [
180
+ /* @__PURE__ */ jsxDEV(Text, {
181
+ className: "font-medium text-sm",
182
+ children: "Output"
183
+ }, undefined, false, undefined, this),
184
+ /* @__PURE__ */ jsxDEV("pre", {
185
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
186
+ children: formatJson(run.output ?? run.errorMessage ?? "Pending")
187
+ }, undefined, false, undefined, this)
188
+ ]
189
+ }, undefined, true, undefined, this)
190
+ ]
191
+ }, undefined, true, undefined, this);
192
+ }
193
+ function RunTableToolbar({
194
+ controller,
195
+ totalRuns
196
+ }) {
197
+ const firstRow = controller.rows[0];
198
+ const queuedColumn = controller.columns.find((column) => column.id === "queuedAt");
199
+ const durationColumn = controller.columns.find((column) => column.id === "durationMs");
200
+ const costColumn = controller.columns.find((column) => column.id === "estimatedCostUsd");
201
+ return /* @__PURE__ */ jsxDEV(HStack, {
202
+ gap: "sm",
203
+ className: "flex-wrap",
204
+ children: [
205
+ /* @__PURE__ */ jsxDEV(Text, {
206
+ className: "text-muted-foreground text-sm",
207
+ children: [
208
+ totalRuns,
209
+ " runs"
210
+ ]
211
+ }, undefined, true, undefined, this),
212
+ /* @__PURE__ */ jsxDEV(Button, {
213
+ variant: "outline",
214
+ size: "sm",
215
+ onPress: () => firstRow?.toggleExpanded?.(!firstRow?.isExpanded),
216
+ children: "Expand Latest Run"
217
+ }, undefined, false, undefined, this),
218
+ /* @__PURE__ */ jsxDEV(Button, {
219
+ variant: "outline",
220
+ size: "sm",
221
+ onPress: () => queuedColumn?.toggleVisibility?.(!queuedColumn?.visible),
222
+ children: queuedColumn?.visible ? "Hide Time" : "Show Time"
223
+ }, undefined, false, undefined, this),
224
+ /* @__PURE__ */ jsxDEV(Button, {
225
+ variant: "outline",
226
+ size: "sm",
227
+ onPress: () => durationColumn?.toggleVisibility?.(!durationColumn?.visible),
228
+ children: durationColumn?.visible ? "Hide Duration" : "Show Duration"
229
+ }, undefined, false, undefined, this),
230
+ /* @__PURE__ */ jsxDEV(Button, {
231
+ variant: "outline",
232
+ size: "sm",
233
+ onPress: () => costColumn?.toggleVisibility?.(!costColumn?.visible),
234
+ children: costColumn?.visible ? "Hide Cost" : "Show Cost"
235
+ }, undefined, false, undefined, this)
236
+ ]
237
+ }, undefined, true, undefined, this);
238
+ }
239
+
240
+ // src/ui/views/run-data-table.columns.tsx
241
+ import { StatusChip as StatusChip2 } from "@contractspec/lib.design-system";
242
+ import { VStack as VStack2 } from "@contractspec/lib.ui-kit-web/ui/stack";
243
+ import { Text as Text2 } from "@contractspec/lib.ui-kit-web/ui/text";
244
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
245
+ "use client";
246
+ function createRunTableColumns() {
247
+ return [
248
+ {
249
+ id: "queuedAt",
250
+ header: "Run",
251
+ label: "Run",
252
+ accessor: (run) => run.queuedAt.getTime(),
253
+ cell: ({ item }) => /* @__PURE__ */ jsxDEV2(VStack2, {
254
+ gap: "xs",
255
+ children: [
256
+ /* @__PURE__ */ jsxDEV2(Text2, {
257
+ className: "font-mono text-sm",
258
+ children: item.id.slice(-8)
259
+ }, undefined, false, undefined, this),
260
+ /* @__PURE__ */ jsxDEV2(Text2, {
261
+ className: "text-muted-foreground text-xs",
262
+ children: item.queuedAt.toLocaleString()
263
+ }, undefined, false, undefined, this)
264
+ ]
265
+ }, undefined, true, undefined, this),
266
+ size: 220,
267
+ minSize: 180,
268
+ canSort: true,
269
+ canHide: true,
270
+ canResize: true
271
+ },
272
+ {
273
+ id: "agentName",
274
+ header: "Agent",
275
+ label: "Agent",
276
+ accessor: (run) => run.agentName ?? "Unknown Agent",
277
+ cell: ({ value }) => /* @__PURE__ */ jsxDEV2(Text2, {
278
+ className: "font-medium",
279
+ children: typeof value === "string" ? value : "Unknown Agent"
280
+ }, undefined, false, undefined, this),
281
+ size: 220,
282
+ canSort: true,
283
+ canResize: true
284
+ },
285
+ {
286
+ id: "status",
287
+ header: "Status",
288
+ label: "Status",
289
+ accessorKey: "status",
290
+ cell: ({ value }) => {
291
+ const status = typeof value === "string" ? value : "QUEUED";
292
+ return /* @__PURE__ */ jsxDEV2(StatusChip2, {
293
+ tone: getStatusTone(status),
294
+ label: status
295
+ }, undefined, false, undefined, this);
296
+ },
297
+ size: 150,
298
+ canSort: true,
299
+ canResize: true
300
+ },
301
+ {
302
+ id: "totalTokens",
303
+ header: "Tokens",
304
+ label: "Tokens",
305
+ accessorKey: "totalTokens",
306
+ cell: ({ value }) => formatTokens(Number(value ?? 0)),
307
+ align: "right",
308
+ size: 140,
309
+ canSort: true,
310
+ canResize: true
311
+ },
312
+ {
313
+ id: "durationMs",
314
+ header: "Duration",
315
+ label: "Duration",
316
+ accessorKey: "durationMs",
317
+ cell: ({ value }) => formatDuration(typeof value === "number" ? value : undefined),
318
+ align: "right",
319
+ size: 140,
320
+ canSort: true,
321
+ canHide: true,
322
+ canResize: true
323
+ },
324
+ {
325
+ id: "estimatedCostUsd",
326
+ header: "Cost",
327
+ label: "Cost",
328
+ accessorKey: "estimatedCostUsd",
329
+ cell: ({ value }) => formatCost(typeof value === "number" ? value : undefined),
330
+ align: "right",
331
+ size: 140,
332
+ canSort: true,
333
+ canHide: true,
334
+ canResize: true
335
+ }
336
+ ];
337
+ }
338
+
339
+ // src/ui/views/RunDataTable.tsx
340
+ import { DataTable } from "@contractspec/lib.design-system";
341
+ import { useContractTable } from "@contractspec/lib.presentation-runtime-react";
342
+ import * as React from "react";
343
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
344
+ "use client";
345
+ function RunDataTable({
346
+ runs,
347
+ totalItems,
348
+ pageIndex,
349
+ pageSize,
350
+ sorting,
351
+ loading,
352
+ onSortingChange,
353
+ onPaginationChange,
354
+ onRunClick
355
+ }) {
356
+ const columns = React.useMemo(() => createRunTableColumns(), []);
357
+ const controller = useContractTable({
358
+ data: runs,
359
+ columns,
360
+ executionMode: "server",
361
+ totalItems,
362
+ state: {
363
+ sorting,
364
+ pagination: { pageIndex, pageSize }
365
+ },
366
+ onSortingChange,
367
+ onPaginationChange,
368
+ initialState: {
369
+ columnVisibility: { estimatedCostUsd: false }
370
+ },
371
+ getRowId: (run) => run.id,
372
+ renderExpandedContent: (run) => /* @__PURE__ */ jsxDEV3(RunExpandedContent, {
373
+ run
374
+ }, undefined, false, undefined, this),
375
+ getCanExpand: () => true
376
+ });
377
+ return /* @__PURE__ */ jsxDEV3(DataTable, {
378
+ controller,
379
+ title: "Run History",
380
+ description: "Server-mode ContractSpec table with shared pagination, sorting, visibility, and expansion.",
381
+ loading,
382
+ onRowPress: (row) => onRunClick?.(row.id),
383
+ toolbar: /* @__PURE__ */ jsxDEV3(RunTableToolbar, {
384
+ controller,
385
+ totalRuns: totalItems
386
+ }, undefined, false, undefined, this),
387
+ emptyState: /* @__PURE__ */ jsxDEV3("div", {
388
+ className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
389
+ children: "No runs yet"
390
+ }, undefined, false, undefined, this)
391
+ }, undefined, false, undefined, this);
392
+ }
393
+
394
+ // src/ui/views/RunListView.tsx
395
+ import {
396
+ EmptyState,
397
+ ErrorState,
398
+ LoaderBlock,
399
+ StatCard,
400
+ StatCardGroup
401
+ } from "@contractspec/lib.design-system";
402
+ import { useState as useState2 } from "react";
403
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
404
+ "use client";
102
405
  function RunListView({ agentId, onRunClick }) {
103
- const { data, metrics, loading, error, refetch } = useRunList({ agentId });
406
+ const [sorting, setSorting] = useState2([
407
+ { id: "queuedAt", desc: true }
408
+ ]);
409
+ const [pagination, setPagination] = useState2({
410
+ pageIndex: 0,
411
+ pageSize: 3
412
+ });
413
+ const { data, metrics, loading, error, refetch } = useRunList({
414
+ agentId,
415
+ pageIndex: pagination.pageIndex,
416
+ pageSize: pagination.pageSize,
417
+ sorting
418
+ });
104
419
  if (loading && !data) {
105
- return /* @__PURE__ */ jsxDEV(LoaderBlock, {
420
+ return /* @__PURE__ */ jsxDEV4(LoaderBlock, {
106
421
  label: "Loading runs..."
107
422
  }, undefined, false, undefined, this);
108
423
  }
109
424
  if (error) {
110
- return /* @__PURE__ */ jsxDEV(ErrorState, {
425
+ return /* @__PURE__ */ jsxDEV4(ErrorState, {
111
426
  title: "Failed to load runs",
112
427
  description: error.message,
113
428
  onRetry: refetch,
@@ -115,131 +430,48 @@ function RunListView({ agentId, onRunClick }) {
115
430
  }, undefined, false, undefined, this);
116
431
  }
117
432
  if (!data?.items.length) {
118
- return /* @__PURE__ */ jsxDEV(EmptyState, {
433
+ return /* @__PURE__ */ jsxDEV4(EmptyState, {
119
434
  title: "No runs yet",
120
435
  description: "Execute an agent to see run history here."
121
436
  }, undefined, false, undefined, this);
122
437
  }
123
- return /* @__PURE__ */ jsxDEV("div", {
438
+ return /* @__PURE__ */ jsxDEV4("div", {
124
439
  className: "space-y-6",
125
440
  children: [
126
- metrics && /* @__PURE__ */ jsxDEV(StatCardGroup, {
441
+ metrics ? /* @__PURE__ */ jsxDEV4(StatCardGroup, {
127
442
  children: [
128
- /* @__PURE__ */ jsxDEV(StatCard, {
443
+ /* @__PURE__ */ jsxDEV4(StatCard, {
129
444
  label: "Total Runs",
130
445
  value: metrics.totalRuns
131
446
  }, undefined, false, undefined, this),
132
- /* @__PURE__ */ jsxDEV(StatCard, {
447
+ /* @__PURE__ */ jsxDEV4(StatCard, {
133
448
  label: "Success Rate",
134
449
  value: `${(metrics.successRate * 100).toFixed(1)}%`
135
450
  }, undefined, false, undefined, this),
136
- /* @__PURE__ */ jsxDEV(StatCard, {
451
+ /* @__PURE__ */ jsxDEV4(StatCard, {
137
452
  label: "Total Tokens",
138
453
  value: formatTokens(metrics.totalTokens)
139
454
  }, undefined, false, undefined, this),
140
- /* @__PURE__ */ jsxDEV(StatCard, {
455
+ /* @__PURE__ */ jsxDEV4(StatCard, {
141
456
  label: "Total Cost",
142
457
  value: `$${metrics.totalCostUsd.toFixed(2)}`
143
458
  }, undefined, false, undefined, this)
144
459
  ]
145
- }, undefined, true, undefined, this),
146
- /* @__PURE__ */ jsxDEV("div", {
147
- className: "border-border rounded-lg border",
148
- children: /* @__PURE__ */ jsxDEV("table", {
149
- className: "w-full",
150
- children: [
151
- /* @__PURE__ */ jsxDEV("thead", {
152
- className: "border-border bg-muted/30 border-b",
153
- children: /* @__PURE__ */ jsxDEV("tr", {
154
- children: [
155
- /* @__PURE__ */ jsxDEV("th", {
156
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
157
- children: "Run"
158
- }, undefined, false, undefined, this),
159
- /* @__PURE__ */ jsxDEV("th", {
160
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
161
- children: "Agent"
162
- }, undefined, false, undefined, this),
163
- /* @__PURE__ */ jsxDEV("th", {
164
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
165
- children: "Status"
166
- }, undefined, false, undefined, this),
167
- /* @__PURE__ */ jsxDEV("th", {
168
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
169
- children: "Tokens"
170
- }, undefined, false, undefined, this),
171
- /* @__PURE__ */ jsxDEV("th", {
172
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
173
- children: "Duration"
174
- }, undefined, false, undefined, this),
175
- /* @__PURE__ */ jsxDEV("th", {
176
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
177
- children: "Cost"
178
- }, undefined, false, undefined, this)
179
- ]
180
- }, undefined, true, undefined, this)
181
- }, undefined, false, undefined, this),
182
- /* @__PURE__ */ jsxDEV("tbody", {
183
- className: "divide-border divide-y",
184
- children: data.items.map((run) => /* @__PURE__ */ jsxDEV("tr", {
185
- className: "hover:bg-muted/50 cursor-pointer transition-colors",
186
- onClick: () => onRunClick?.(run.id),
187
- children: [
188
- /* @__PURE__ */ jsxDEV("td", {
189
- className: "px-4 py-3",
190
- children: [
191
- /* @__PURE__ */ jsxDEV("div", {
192
- className: "font-mono text-sm",
193
- children: run.id.slice(-8)
194
- }, undefined, false, undefined, this),
195
- /* @__PURE__ */ jsxDEV("div", {
196
- className: "text-muted-foreground text-xs",
197
- children: run.queuedAt.toLocaleString()
198
- }, undefined, false, undefined, this)
199
- ]
200
- }, undefined, true, undefined, this),
201
- /* @__PURE__ */ jsxDEV("td", {
202
- className: "px-4 py-3",
203
- children: /* @__PURE__ */ jsxDEV("span", {
204
- className: "font-medium",
205
- children: run.agentName
206
- }, undefined, false, undefined, this)
207
- }, undefined, false, undefined, this),
208
- /* @__PURE__ */ jsxDEV("td", {
209
- className: "px-4 py-3",
210
- children: /* @__PURE__ */ jsxDEV(StatusChip, {
211
- tone: getStatusTone(run.status),
212
- label: run.status
213
- }, undefined, false, undefined, this)
214
- }, undefined, false, undefined, this),
215
- /* @__PURE__ */ jsxDEV("td", {
216
- className: "px-4 py-3 text-right font-mono text-sm",
217
- children: formatTokens(run.totalTokens)
218
- }, undefined, false, undefined, this),
219
- /* @__PURE__ */ jsxDEV("td", {
220
- className: "px-4 py-3 text-right font-mono text-sm",
221
- children: formatDuration(run.durationMs)
222
- }, undefined, false, undefined, this),
223
- /* @__PURE__ */ jsxDEV("td", {
224
- className: "px-4 py-3 text-right font-mono text-sm",
225
- children: formatCost(run.estimatedCostUsd)
226
- }, undefined, false, undefined, this)
227
- ]
228
- }, run.id, true, undefined, this))
229
- }, undefined, false, undefined, this)
230
- ]
231
- }, undefined, true, undefined, this)
232
- }, undefined, false, undefined, this),
233
- /* @__PURE__ */ jsxDEV("div", {
234
- className: "text-muted-foreground text-center text-sm",
235
- children: [
236
- "Showing ",
237
- data.items.length,
238
- " of ",
239
- data.total,
240
- " runs"
241
- ]
242
- }, undefined, true, undefined, this)
460
+ }, undefined, true, undefined, this) : null,
461
+ /* @__PURE__ */ jsxDEV4(RunDataTable, {
462
+ runs: data.items,
463
+ totalItems: data.total,
464
+ pageIndex: pagination.pageIndex,
465
+ pageSize: pagination.pageSize,
466
+ sorting,
467
+ loading,
468
+ onSortingChange: (nextSorting) => {
469
+ setSorting(nextSorting);
470
+ setPagination((current) => ({ ...current, pageIndex: 0 }));
471
+ },
472
+ onPaginationChange: setPagination,
473
+ onRunClick
474
+ }, undefined, false, undefined, this)
243
475
  ]
244
476
  }, undefined, true, undefined, this);
245
477
  }
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useToolList.ts
3
- import { useCallback, useEffect, useMemo, useState } from "react";
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ import { useCallback, useEffect, useMemo, useState } from "react";
5
5
  function useToolList(options = {}) {
6
6
  const { handlers, projectId } = useTemplateRuntime();
7
7
  const { agent } = handlers;
@@ -84,14 +84,14 @@ function useToolList(options = {}) {
84
84
 
85
85
  // src/ui/views/ToolRegistryView.tsx
86
86
  import {
87
- StatCard,
88
- StatCardGroup,
89
- StatusChip,
90
- EntityCard,
87
+ Button,
91
88
  EmptyState,
92
- LoaderBlock,
89
+ EntityCard,
93
90
  ErrorState,
94
- Button
91
+ LoaderBlock,
92
+ StatCard,
93
+ StatCardGroup,
94
+ StatusChip
95
95
  } from "@contractspec/lib.design-system";
96
96
  import { jsxDEV } from "react/jsx-dev-runtime";
97
97
  "use client";
@@ -171,11 +171,11 @@ function ToolRegistryView({
171
171
  children: categoryIcons[category]
172
172
  }, undefined, false, undefined, this),
173
173
  /* @__PURE__ */ jsxDEV("h3", {
174
- className: "text-lg font-semibold",
174
+ className: "font-semibold text-lg",
175
175
  children: category
176
176
  }, undefined, false, undefined, this),
177
177
  /* @__PURE__ */ jsxDEV("span", {
178
- className: "bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",
178
+ className: "rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",
179
179
  children: tools.length
180
180
  }, undefined, false, undefined, this)
181
181
  ]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Data hooks for agent-console template
3
3
  */
4
- export { useAgentList, type UseAgentListOptions } from './useAgentList';
5
- export { useRunList, type UseRunListOptions } from './useRunList';
6
- export { useToolList, type UseToolListOptions } from './useToolList';
7
- export { useAgentMutations, type UseAgentMutationsOptions, type CreateAgentInput, type UpdateAgentInput, } from './useAgentMutations';
4
+ export { type UseAgentListOptions, useAgentList } from './useAgentList';
5
+ export { type CreateAgentInput, type UpdateAgentInput, type UseAgentMutationsOptions, useAgentMutations, } from './useAgentMutations';
6
+ export { type UseRunListOptions, useRunList } from './useRunList';
7
+ export { type UseToolListOptions, useToolList } from './useToolList';