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