@contractspec/example.agent-console 3.7.5 → 3.7.7

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 (176) hide show
  1. package/.turbo/turbo-build.log +18 -18
  2. package/AGENTS.md +50 -31
  3. package/CHANGELOG.md +12 -0
  4. package/README.md +69 -77
  5. package/dist/agent/agent.event.js +1 -1
  6. package/dist/agent/agent.operation.js +1 -1
  7. package/dist/agent/index.d.ts +5 -5
  8. package/dist/agent/index.js +1 -1
  9. package/dist/browser/agent/agent.event.js +1 -1
  10. package/dist/browser/agent/agent.operation.js +1 -1
  11. package/dist/browser/agent/index.js +1 -1
  12. package/dist/browser/index.js +2145 -2145
  13. package/dist/browser/presentations/index.js +4 -4
  14. package/dist/browser/run/index.js +536 -536
  15. package/dist/browser/run/run.event.js +2 -2
  16. package/dist/browser/run/run.presentation.js +2 -2
  17. package/dist/browser/tool/index.js +260 -260
  18. package/dist/browser/tool/tool.event.js +1 -1
  19. package/dist/browser/tool/tool.presentation.js +2 -2
  20. package/dist/browser/ui/AgentDashboard.js +956 -956
  21. package/dist/browser/ui/AgentRunList.js +16 -16
  22. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  23. package/dist/browser/ui/hooks/index.js +153 -153
  24. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  25. package/dist/browser/ui/hooks/useAgentMutations.js +1 -1
  26. package/dist/browser/ui/hooks/useRunList.js +1 -1
  27. package/dist/browser/ui/hooks/useToolList.js +1 -1
  28. package/dist/browser/ui/index.js +1222 -1222
  29. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  30. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  31. package/dist/browser/ui/modals/index.js +297 -297
  32. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  33. package/dist/browser/ui/renderers/index.js +157 -157
  34. package/dist/browser/ui/views/AgentListView.js +7 -7
  35. package/dist/browser/ui/views/RunListView.js +16 -16
  36. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  37. package/dist/browser/ui/views/index.js +97 -97
  38. package/dist/handlers/index.d.ts +1 -1
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.js +2145 -2145
  41. package/dist/node/agent/agent.event.js +1 -1
  42. package/dist/node/agent/agent.operation.js +1 -1
  43. package/dist/node/agent/index.js +1 -1
  44. package/dist/node/index.js +2145 -2145
  45. package/dist/node/presentations/index.js +4 -4
  46. package/dist/node/run/index.js +536 -536
  47. package/dist/node/run/run.event.js +2 -2
  48. package/dist/node/run/run.presentation.js +2 -2
  49. package/dist/node/tool/index.js +260 -260
  50. package/dist/node/tool/tool.event.js +1 -1
  51. package/dist/node/tool/tool.presentation.js +2 -2
  52. package/dist/node/ui/AgentDashboard.js +956 -956
  53. package/dist/node/ui/AgentRunList.js +16 -16
  54. package/dist/node/ui/AgentToolRegistry.js +9 -9
  55. package/dist/node/ui/hooks/index.js +153 -153
  56. package/dist/node/ui/hooks/useAgentList.js +1 -1
  57. package/dist/node/ui/hooks/useAgentMutations.js +1 -1
  58. package/dist/node/ui/hooks/useRunList.js +1 -1
  59. package/dist/node/ui/hooks/useToolList.js +1 -1
  60. package/dist/node/ui/index.js +1222 -1222
  61. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  62. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  63. package/dist/node/ui/modals/index.js +297 -297
  64. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  65. package/dist/node/ui/renderers/index.js +157 -157
  66. package/dist/node/ui/views/AgentListView.js +7 -7
  67. package/dist/node/ui/views/RunListView.js +16 -16
  68. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  69. package/dist/node/ui/views/index.js +97 -97
  70. package/dist/presentations/index.d.ts +3 -5
  71. package/dist/presentations/index.js +4 -4
  72. package/dist/run/index.d.ts +7 -7
  73. package/dist/run/index.js +536 -536
  74. package/dist/run/run.event.js +2 -2
  75. package/dist/run/run.handler.d.ts +3 -0
  76. package/dist/run/run.presentation.js +2 -2
  77. package/dist/shared/index.d.ts +1 -1
  78. package/dist/tool/index.d.ts +7 -7
  79. package/dist/tool/index.js +260 -260
  80. package/dist/tool/tool.event.js +1 -1
  81. package/dist/tool/tool.handler.d.ts +1 -1
  82. package/dist/tool/tool.presentation.js +2 -2
  83. package/dist/ui/AgentDashboard.js +956 -956
  84. package/dist/ui/AgentRunList.js +16 -16
  85. package/dist/ui/AgentToolRegistry.js +9 -9
  86. package/dist/ui/hooks/index.d.ts +4 -4
  87. package/dist/ui/hooks/index.js +153 -153
  88. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  89. package/dist/ui/hooks/useAgentList.js +1 -1
  90. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  91. package/dist/ui/hooks/useAgentMutations.js +1 -1
  92. package/dist/ui/hooks/useRunList.d.ts +5 -0
  93. package/dist/ui/hooks/useRunList.js +1 -1
  94. package/dist/ui/hooks/useToolList.d.ts +5 -0
  95. package/dist/ui/hooks/useToolList.js +1 -1
  96. package/dist/ui/index.d.ts +3 -3
  97. package/dist/ui/index.js +1222 -1222
  98. package/dist/ui/modals/AgentActionsModal.js +13 -13
  99. package/dist/ui/modals/CreateAgentModal.js +15 -15
  100. package/dist/ui/modals/index.d.ts +1 -1
  101. package/dist/ui/modals/index.js +297 -297
  102. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  103. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  104. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  105. package/dist/ui/renderers/index.d.ts +2 -2
  106. package/dist/ui/renderers/index.js +157 -157
  107. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  108. package/dist/ui/renderers/tool-registry.markdown.d.ts +5 -0
  109. package/dist/ui/views/AgentListView.js +7 -7
  110. package/dist/ui/views/RunListView.js +16 -16
  111. package/dist/ui/views/ToolRegistryView.js +9 -9
  112. package/dist/ui/views/index.js +97 -97
  113. package/package.json +10 -10
  114. package/src/agent/agent.entity.ts +111 -111
  115. package/src/agent/agent.enum.ts +12 -12
  116. package/src/agent/agent.event.ts +91 -91
  117. package/src/agent/agent.handler.ts +123 -123
  118. package/src/agent/agent.operation.ts +400 -400
  119. package/src/agent/agent.presentation.ts +62 -62
  120. package/src/agent/agent.schema.ts +175 -175
  121. package/src/agent/agent.test-spec.ts +48 -48
  122. package/src/agent/index.ts +46 -51
  123. package/src/agent.capability.ts +11 -11
  124. package/src/agent.feature.ts +131 -131
  125. package/src/docs/agent-console.docblock.ts +42 -42
  126. package/src/example.ts +35 -35
  127. package/src/handlers/agent.handlers.ts +522 -521
  128. package/src/handlers/index.ts +12 -12
  129. package/src/index.ts +8 -9
  130. package/src/presentations/index.ts +11 -13
  131. package/src/run/index.ts +49 -54
  132. package/src/run/run.entity.ts +137 -137
  133. package/src/run/run.enum.ts +18 -18
  134. package/src/run/run.event.ts +174 -174
  135. package/src/run/run.handler.ts +92 -91
  136. package/src/run/run.operation.ts +474 -474
  137. package/src/run/run.presentation.ts +42 -42
  138. package/src/run/run.schema.ts +126 -126
  139. package/src/run/run.test-spec.ts +48 -48
  140. package/src/seeders/index.ts +21 -21
  141. package/src/shared/index.ts +1 -1
  142. package/src/shared/mock-agents.ts +76 -76
  143. package/src/shared/mock-runs.ts +102 -102
  144. package/src/shared/mock-tools.ts +140 -140
  145. package/src/shared/overlay-types.ts +23 -23
  146. package/src/tool/index.ts +39 -44
  147. package/src/tool/tool.entity.ts +73 -73
  148. package/src/tool/tool.enum.ts +13 -13
  149. package/src/tool/tool.event.ts +80 -80
  150. package/src/tool/tool.handler.ts +102 -102
  151. package/src/tool/tool.operation.ts +328 -328
  152. package/src/tool/tool.presentation.ts +43 -43
  153. package/src/tool/tool.schema.ts +106 -106
  154. package/src/tool/tool.test-spec.ts +48 -48
  155. package/src/ui/AgentDashboard.tsx +348 -348
  156. package/src/ui/hooks/index.ts +7 -7
  157. package/src/ui/hooks/useAgentList.ts +57 -56
  158. package/src/ui/hooks/useAgentMutations.ts +160 -159
  159. package/src/ui/hooks/useRunList.ts +58 -57
  160. package/src/ui/hooks/useToolList.ts +102 -101
  161. package/src/ui/index.ts +6 -9
  162. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  163. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  164. package/src/ui/modals/index.ts +1 -1
  165. package/src/ui/overlays/demo-overlays.ts +52 -52
  166. package/src/ui/renderers/agent-list.markdown.ts +61 -60
  167. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  168. package/src/ui/renderers/dashboard.markdown.ts +140 -139
  169. package/src/ui/renderers/index.ts +3 -4
  170. package/src/ui/renderers/run-list.markdown.ts +48 -47
  171. package/src/ui/renderers/tool-registry.markdown.ts +66 -65
  172. package/src/ui/views/AgentListView.tsx +90 -90
  173. package/src/ui/views/RunListView.tsx +141 -141
  174. package/src/ui/views/ToolRegistryView.tsx +113 -113
  175. package/tsconfig.json +7 -8
  176. package/tsdown.config.js +7 -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;
@@ -54,12 +54,12 @@ function useRunList(options = {}) {
54
54
 
55
55
  // src/ui/views/RunListView.tsx
56
56
  import {
57
- StatCard,
58
- StatCardGroup,
59
- StatusChip,
60
57
  EmptyState,
58
+ ErrorState,
61
59
  LoaderBlock,
62
- ErrorState
60
+ StatCard,
61
+ StatCardGroup,
62
+ StatusChip
63
63
  } from "@contractspec/lib.design-system";
64
64
  import { jsxDEV } from "react/jsx-dev-runtime";
65
65
  "use client";
@@ -144,45 +144,45 @@ function RunListView({ agentId, onRunClick }) {
144
144
  ]
145
145
  }, undefined, true, undefined, this),
146
146
  /* @__PURE__ */ jsxDEV("div", {
147
- className: "border-border rounded-lg border",
147
+ className: "rounded-lg border border-border",
148
148
  children: /* @__PURE__ */ jsxDEV("table", {
149
149
  className: "w-full",
150
150
  children: [
151
151
  /* @__PURE__ */ jsxDEV("thead", {
152
- className: "border-border bg-muted/30 border-b",
152
+ className: "border-border border-b bg-muted/30",
153
153
  children: /* @__PURE__ */ jsxDEV("tr", {
154
154
  children: [
155
155
  /* @__PURE__ */ jsxDEV("th", {
156
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
156
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
157
157
  children: "Run"
158
158
  }, undefined, false, undefined, this),
159
159
  /* @__PURE__ */ jsxDEV("th", {
160
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
160
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
161
161
  children: "Agent"
162
162
  }, undefined, false, undefined, this),
163
163
  /* @__PURE__ */ jsxDEV("th", {
164
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
164
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
165
165
  children: "Status"
166
166
  }, undefined, false, undefined, this),
167
167
  /* @__PURE__ */ jsxDEV("th", {
168
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
168
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
169
169
  children: "Tokens"
170
170
  }, undefined, false, undefined, this),
171
171
  /* @__PURE__ */ jsxDEV("th", {
172
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
172
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
173
173
  children: "Duration"
174
174
  }, undefined, false, undefined, this),
175
175
  /* @__PURE__ */ jsxDEV("th", {
176
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
176
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
177
177
  children: "Cost"
178
178
  }, undefined, false, undefined, this)
179
179
  ]
180
180
  }, undefined, true, undefined, this)
181
181
  }, undefined, false, undefined, this),
182
182
  /* @__PURE__ */ jsxDEV("tbody", {
183
- className: "divide-border divide-y",
183
+ className: "divide-y divide-border",
184
184
  children: data.items.map((run) => /* @__PURE__ */ jsxDEV("tr", {
185
- className: "hover:bg-muted/50 cursor-pointer transition-colors",
185
+ className: "cursor-pointer transition-colors hover:bg-muted/50",
186
186
  onClick: () => onRunClick?.(run.id),
187
187
  children: [
188
188
  /* @__PURE__ */ jsxDEV("td", {
@@ -231,7 +231,7 @@ function RunListView({ agentId, onRunClick }) {
231
231
  }, undefined, true, undefined, this)
232
232
  }, undefined, false, undefined, this),
233
233
  /* @__PURE__ */ jsxDEV("div", {
234
- className: "text-muted-foreground text-center text-sm",
234
+ className: "text-center text-muted-foreground text-sm",
235
235
  children: [
236
236
  "Showing ",
237
237
  data.items.length,
@@ -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';
@@ -1,151 +1,15 @@
1
1
  // @bun
2
- // src/ui/hooks/useRunList.ts
3
- import { useCallback, useEffect, useState } from "react";
2
+ // src/ui/hooks/useAgentList.ts
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
5
- function useRunList(options = {}) {
4
+ import { useCallback, useEffect, useMemo, useState } from "react";
5
+ function useAgentList(options = {}) {
6
6
  const { handlers, projectId } = useTemplateRuntime();
7
7
  const { agent } = handlers;
8
8
  const [data, setData] = useState(null);
9
- const [metrics, setMetrics] = useState(null);
10
9
  const [loading, setLoading] = useState(true);
11
10
  const [error, setError] = useState(null);
12
11
  const [page, setPage] = useState(1);
13
12
  const fetchData = useCallback(async () => {
14
- setLoading(true);
15
- setError(null);
16
- try {
17
- const [runsResult, metricsResult] = await Promise.all([
18
- agent.listRuns({
19
- projectId,
20
- agentId: options.agentId,
21
- status: options.status === "all" ? undefined : options.status,
22
- limit: options.limit ?? 20,
23
- offset: (page - 1) * (options.limit ?? 20)
24
- }),
25
- agent.getRunMetrics({
26
- projectId,
27
- agentId: options.agentId,
28
- startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
29
- endDate: new Date
30
- })
31
- ]);
32
- setData(runsResult);
33
- setMetrics(metricsResult);
34
- } catch (err) {
35
- setError(err instanceof Error ? err : new Error("Unknown error"));
36
- } finally {
37
- setLoading(false);
38
- }
39
- }, [agent, projectId, options.agentId, options.status, options.limit, page]);
40
- useEffect(() => {
41
- fetchData();
42
- }, [fetchData]);
43
- return {
44
- data,
45
- metrics,
46
- loading,
47
- error,
48
- page,
49
- refetch: fetchData,
50
- nextPage: () => setPage((p) => p + 1),
51
- prevPage: () => page > 1 && setPage((p) => p - 1)
52
- };
53
- }
54
-
55
- // src/ui/hooks/useToolList.ts
56
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useState as useState2 } from "react";
57
- import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
58
- function useToolList(options = {}) {
59
- const { handlers, projectId } = useTemplateRuntime2();
60
- const { agent } = handlers;
61
- const [data, setData] = useState2(null);
62
- const [loading, setLoading] = useState2(true);
63
- const [error, setError] = useState2(null);
64
- const [page, setPage] = useState2(1);
65
- const fetchData = useCallback2(async () => {
66
- setLoading(true);
67
- setError(null);
68
- try {
69
- const result = await agent.listTools({
70
- projectId,
71
- search: options.search,
72
- category: options.category,
73
- status: options.status === "all" ? undefined : options.status,
74
- limit: options.limit ?? 50,
75
- offset: (page - 1) * (options.limit ?? 50)
76
- });
77
- setData(result);
78
- } catch (err) {
79
- setError(err instanceof Error ? err : new Error("Unknown error"));
80
- } finally {
81
- setLoading(false);
82
- }
83
- }, [
84
- agent,
85
- projectId,
86
- options.search,
87
- options.category,
88
- options.status,
89
- options.limit,
90
- page
91
- ]);
92
- useEffect2(() => {
93
- fetchData();
94
- }, [fetchData]);
95
- const { stats, groupedByCategory, categoryStats } = useMemo(() => {
96
- if (!data)
97
- return { stats: null, groupedByCategory: {}, categoryStats: [] };
98
- const items = data.items;
99
- const active = items.filter((t) => t.status === "ACTIVE").length;
100
- const deprecated = items.filter((t) => t.status === "DEPRECATED").length;
101
- const disabled = items.filter((t) => t.status === "DISABLED").length;
102
- const grouped = {};
103
- const byCategory = {};
104
- items.forEach((t) => {
105
- const cat = t.category;
106
- if (!grouped[cat])
107
- grouped[cat] = [];
108
- grouped[cat].push(t);
109
- byCategory[cat] = (byCategory[cat] || 0) + 1;
110
- });
111
- const catStats = Object.entries(byCategory).map(([category, count]) => ({ category, count })).sort((a, b) => b.count - a.count);
112
- return {
113
- stats: {
114
- total: data.total,
115
- active,
116
- deprecated,
117
- disabled,
118
- topCategories: catStats.slice(0, 5)
119
- },
120
- groupedByCategory: grouped,
121
- categoryStats: catStats
122
- };
123
- }, [data]);
124
- return {
125
- data,
126
- loading,
127
- error,
128
- stats,
129
- groupedByCategory,
130
- categoryStats,
131
- page,
132
- refetch: fetchData,
133
- nextPage: () => setPage((p) => p + 1),
134
- prevPage: () => page > 1 && setPage((p) => p - 1)
135
- };
136
- }
137
-
138
- // src/ui/hooks/useAgentList.ts
139
- import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
140
- import { useTemplateRuntime as useTemplateRuntime3 } from "@contractspec/lib.example-shared-ui";
141
- function useAgentList(options = {}) {
142
- const { handlers, projectId } = useTemplateRuntime3();
143
- const { agent } = handlers;
144
- const [data, setData] = useState3(null);
145
- const [loading, setLoading] = useState3(true);
146
- const [error, setError] = useState3(null);
147
- const [page, setPage] = useState3(1);
148
- const fetchData = useCallback3(async () => {
149
13
  setLoading(true);
150
14
  setError(null);
151
15
  try {
@@ -163,10 +27,10 @@ function useAgentList(options = {}) {
163
27
  setLoading(false);
164
28
  }
165
29
  }, [agent, projectId, options.search, options.status, options.limit, page]);
166
- useEffect3(() => {
30
+ useEffect(() => {
167
31
  fetchData();
168
32
  }, [fetchData]);
169
- const stats = useMemo2(() => {
33
+ const stats = useMemo(() => {
170
34
  if (!data)
171
35
  return null;
172
36
  return {
@@ -189,27 +53,27 @@ function useAgentList(options = {}) {
189
53
  }
190
54
 
191
55
  // src/ui/hooks/useAgentMutations.ts
192
- import { useCallback as useCallback4, useState as useState4 } from "react";
193
- import { useTemplateRuntime as useTemplateRuntime4 } from "@contractspec/lib.example-shared-ui";
56
+ import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
57
+ import { useCallback as useCallback2, useState as useState2 } from "react";
194
58
  function useAgentMutations(options = {}) {
195
- const { handlers, projectId } = useTemplateRuntime4();
59
+ const { handlers, projectId } = useTemplateRuntime2();
196
60
  const { agent } = handlers;
197
- const [createState, setCreateState] = useState4({
61
+ const [createState, setCreateState] = useState2({
198
62
  loading: false,
199
63
  error: null,
200
64
  data: null
201
65
  });
202
- const [updateState, setUpdateState] = useState4({
66
+ const [updateState, setUpdateState] = useState2({
203
67
  loading: false,
204
68
  error: null,
205
69
  data: null
206
70
  });
207
- const [executeState, setExecuteState] = useState4({
71
+ const [executeState, setExecuteState] = useState2({
208
72
  loading: false,
209
73
  error: null,
210
74
  data: null
211
75
  });
212
- const createAgent = useCallback4(async (input) => {
76
+ const createAgent = useCallback2(async (input) => {
213
77
  setCreateState({ loading: true, error: null, data: null });
214
78
  try {
215
79
  const result = await agent.createAgent(input, {
@@ -226,7 +90,7 @@ function useAgentMutations(options = {}) {
226
90
  return null;
227
91
  }
228
92
  }, [agent, projectId, options]);
229
- const updateAgent = useCallback4(async (input) => {
93
+ const updateAgent = useCallback2(async (input) => {
230
94
  setUpdateState({ loading: true, error: null, data: null });
231
95
  try {
232
96
  const result = await agent.updateAgent(input);
@@ -240,16 +104,16 @@ function useAgentMutations(options = {}) {
240
104
  return null;
241
105
  }
242
106
  }, [agent, options]);
243
- const activateAgent = useCallback4(async (agentId) => {
107
+ const activateAgent = useCallback2(async (agentId) => {
244
108
  return updateAgent({ id: agentId, status: "ACTIVE" });
245
109
  }, [updateAgent]);
246
- const pauseAgent = useCallback4(async (agentId) => {
110
+ const pauseAgent = useCallback2(async (agentId) => {
247
111
  return updateAgent({ id: agentId, status: "PAUSED" });
248
112
  }, [updateAgent]);
249
- const archiveAgent = useCallback4(async (agentId) => {
113
+ const archiveAgent = useCallback2(async (agentId) => {
250
114
  return updateAgent({ id: agentId, status: "ARCHIVED" });
251
115
  }, [updateAgent]);
252
- const executeAgent = useCallback4(async (input) => {
116
+ const executeAgent = useCallback2(async (input) => {
253
117
  setExecuteState({ loading: true, error: null, data: null });
254
118
  try {
255
119
  const result = await agent.executeAgent({
@@ -281,6 +145,142 @@ function useAgentMutations(options = {}) {
281
145
  };
282
146
  }
283
147
 
148
+ // src/ui/hooks/useRunList.ts
149
+ import { useTemplateRuntime as useTemplateRuntime3 } from "@contractspec/lib.example-shared-ui";
150
+ import { useCallback as useCallback3, useEffect as useEffect2, useState as useState3 } from "react";
151
+ function useRunList(options = {}) {
152
+ const { handlers, projectId } = useTemplateRuntime3();
153
+ const { agent } = handlers;
154
+ const [data, setData] = useState3(null);
155
+ const [metrics, setMetrics] = useState3(null);
156
+ const [loading, setLoading] = useState3(true);
157
+ const [error, setError] = useState3(null);
158
+ const [page, setPage] = useState3(1);
159
+ const fetchData = useCallback3(async () => {
160
+ setLoading(true);
161
+ setError(null);
162
+ try {
163
+ const [runsResult, metricsResult] = await Promise.all([
164
+ agent.listRuns({
165
+ projectId,
166
+ agentId: options.agentId,
167
+ status: options.status === "all" ? undefined : options.status,
168
+ limit: options.limit ?? 20,
169
+ offset: (page - 1) * (options.limit ?? 20)
170
+ }),
171
+ agent.getRunMetrics({
172
+ projectId,
173
+ agentId: options.agentId,
174
+ startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
175
+ endDate: new Date
176
+ })
177
+ ]);
178
+ setData(runsResult);
179
+ setMetrics(metricsResult);
180
+ } catch (err) {
181
+ setError(err instanceof Error ? err : new Error("Unknown error"));
182
+ } finally {
183
+ setLoading(false);
184
+ }
185
+ }, [agent, projectId, options.agentId, options.status, options.limit, page]);
186
+ useEffect2(() => {
187
+ fetchData();
188
+ }, [fetchData]);
189
+ return {
190
+ data,
191
+ metrics,
192
+ loading,
193
+ error,
194
+ page,
195
+ refetch: fetchData,
196
+ nextPage: () => setPage((p) => p + 1),
197
+ prevPage: () => page > 1 && setPage((p) => p - 1)
198
+ };
199
+ }
200
+
201
+ // src/ui/hooks/useToolList.ts
202
+ import { useTemplateRuntime as useTemplateRuntime4 } from "@contractspec/lib.example-shared-ui";
203
+ import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo2, useState as useState4 } from "react";
204
+ function useToolList(options = {}) {
205
+ const { handlers, projectId } = useTemplateRuntime4();
206
+ const { agent } = handlers;
207
+ const [data, setData] = useState4(null);
208
+ const [loading, setLoading] = useState4(true);
209
+ const [error, setError] = useState4(null);
210
+ const [page, setPage] = useState4(1);
211
+ const fetchData = useCallback4(async () => {
212
+ setLoading(true);
213
+ setError(null);
214
+ try {
215
+ const result = await agent.listTools({
216
+ projectId,
217
+ search: options.search,
218
+ category: options.category,
219
+ status: options.status === "all" ? undefined : options.status,
220
+ limit: options.limit ?? 50,
221
+ offset: (page - 1) * (options.limit ?? 50)
222
+ });
223
+ setData(result);
224
+ } catch (err) {
225
+ setError(err instanceof Error ? err : new Error("Unknown error"));
226
+ } finally {
227
+ setLoading(false);
228
+ }
229
+ }, [
230
+ agent,
231
+ projectId,
232
+ options.search,
233
+ options.category,
234
+ options.status,
235
+ options.limit,
236
+ page
237
+ ]);
238
+ useEffect3(() => {
239
+ fetchData();
240
+ }, [fetchData]);
241
+ const { stats, groupedByCategory, categoryStats } = useMemo2(() => {
242
+ if (!data)
243
+ return { stats: null, groupedByCategory: {}, categoryStats: [] };
244
+ const items = data.items;
245
+ const active = items.filter((t) => t.status === "ACTIVE").length;
246
+ const deprecated = items.filter((t) => t.status === "DEPRECATED").length;
247
+ const disabled = items.filter((t) => t.status === "DISABLED").length;
248
+ const grouped = {};
249
+ const byCategory = {};
250
+ items.forEach((t) => {
251
+ const cat = t.category;
252
+ if (!grouped[cat])
253
+ grouped[cat] = [];
254
+ grouped[cat].push(t);
255
+ byCategory[cat] = (byCategory[cat] || 0) + 1;
256
+ });
257
+ const catStats = Object.entries(byCategory).map(([category, count]) => ({ category, count })).sort((a, b) => b.count - a.count);
258
+ return {
259
+ stats: {
260
+ total: data.total,
261
+ active,
262
+ deprecated,
263
+ disabled,
264
+ topCategories: catStats.slice(0, 5)
265
+ },
266
+ groupedByCategory: grouped,
267
+ categoryStats: catStats
268
+ };
269
+ }, [data]);
270
+ return {
271
+ data,
272
+ loading,
273
+ error,
274
+ stats,
275
+ groupedByCategory,
276
+ categoryStats,
277
+ page,
278
+ refetch: fetchData,
279
+ nextPage: () => setPage((p) => p + 1),
280
+ prevPage: () => page > 1 && setPage((p) => p - 1)
281
+ };
282
+ }
283
+
284
284
  // src/ui/hooks/index.ts
285
285
  "use client";
286
286
  export {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Hook for fetching and managing agent list data
3
+ *
4
+ * Uses runtime-local database-backed handlers.
5
+ */
1
6
  import type { Agent as RuntimeAgent, ListAgentsOutput as RuntimeListAgentsOutput } from '../../handlers/agent.handlers';
2
7
  export type Agent = RuntimeAgent;
3
8
  export type ListAgentsOutput = RuntimeListAgentsOutput;
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useAgentList.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 useAgentList(options = {}) {
6
6
  const { handlers, projectId } = useTemplateRuntime();
7
7
  const { agent } = handlers;
@@ -1,4 +1,11 @@
1
- import type { Agent, Run, CreateAgentInput, UpdateAgentInput } from '../../handlers/agent.handlers';
1
+ /**
2
+ * Hook for Agent Console mutations (commands)
3
+ *
4
+ * Uses runtime-local database-backed handlers for:
5
+ * - CreateAgentCommand
6
+ * - UpdateAgentCommand
7
+ */
8
+ import type { Agent, CreateAgentInput, Run, UpdateAgentInput } from '../../handlers/agent.handlers';
2
9
  export interface MutationState<T> {
3
10
  loading: boolean;
4
11
  error: Error | null;
@@ -23,4 +30,4 @@ export declare function useAgentMutations(options?: UseAgentMutationsOptions): {
23
30
  executeState: MutationState<Run>;
24
31
  isLoading: boolean;
25
32
  };
26
- export type { CreateAgentInput, UpdateAgentInput, Agent, Run };
33
+ export type { Agent, CreateAgentInput, Run, UpdateAgentInput };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // src/ui/hooks/useAgentMutations.ts
3
- import { useCallback, useState } from "react";
4
3
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ import { useCallback, useState } from "react";
5
5
  function useAgentMutations(options = {}) {
6
6
  const { handlers, projectId } = useTemplateRuntime();
7
7
  const { agent } = handlers;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Hook for fetching and managing run list data
3
+ *
4
+ * Uses runtime-local database-backed handlers.
5
+ */
1
6
  import type { ListRunsOutput as RuntimeListRunsOutput, Run as RuntimeRun, RunMetrics as RuntimeRunMetrics } from '../../handlers/agent.handlers';
2
7
  export type Run = RuntimeRun;
3
8
  export type ListRunsOutput = RuntimeListRunsOutput;
@@ -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;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Hook for fetching and managing tool list data
3
+ *
4
+ * Uses runtime-local database-backed handlers.
5
+ */
1
6
  import type { ListToolsOutput as RuntimeListToolsOutput, Tool as RuntimeTool } from '../../handlers/agent.handlers';
2
7
  export type Tool = RuntimeTool;
3
8
  export type ListToolsOutput = RuntimeListToolsOutput;
@@ -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;
@@ -1,8 +1,8 @@
1
1
  export * from './AgentDashboard';
2
2
  export * from './AgentRunList';
3
3
  export * from './AgentToolRegistry';
4
- export * from './views';
5
- export * from './modals';
6
4
  export * from './hooks';
7
- export * from './renderers';
5
+ export * from './modals';
8
6
  export * from './overlays';
7
+ export * from './renderers';
8
+ export * from './views';