@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.
- package/.turbo/turbo-build.log +18 -18
- package/AGENTS.md +50 -31
- package/CHANGELOG.md +12 -0
- 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 +10 -10
- 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
package/dist/ui/AgentRunList.js
CHANGED
|
@@ -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
|
-
|
|
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: "
|
|
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
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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-
|
|
183
|
+
className: "divide-y divide-border",
|
|
184
184
|
children: data.items.map((run) => /* @__PURE__ */ jsxDEV("tr", {
|
|
185
|
-
className: "hover:bg-muted/50
|
|
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-
|
|
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
|
-
|
|
88
|
-
StatCardGroup,
|
|
89
|
-
StatusChip,
|
|
90
|
-
EntityCard,
|
|
87
|
+
Button,
|
|
91
88
|
EmptyState,
|
|
92
|
-
|
|
89
|
+
EntityCard,
|
|
93
90
|
ErrorState,
|
|
94
|
-
|
|
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
|
|
174
|
+
className: "font-semibold text-lg",
|
|
175
175
|
children: category
|
|
176
176
|
}, undefined, false, undefined, this),
|
|
177
177
|
/* @__PURE__ */ jsxDEV("span", {
|
|
178
|
-
className: "
|
|
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
|
]
|
package/dist/ui/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Data hooks for agent-console template
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
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';
|
package/dist/ui/hooks/index.js
CHANGED
|
@@ -1,151 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/ui/hooks/
|
|
3
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
// src/ui/hooks/useAgentList.ts
|
|
4
3
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
5
|
-
|
|
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
|
-
|
|
30
|
+
useEffect(() => {
|
|
167
31
|
fetchData();
|
|
168
32
|
}, [fetchData]);
|
|
169
|
-
const stats =
|
|
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 {
|
|
193
|
-
import {
|
|
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 } =
|
|
59
|
+
const { handlers, projectId } = useTemplateRuntime2();
|
|
196
60
|
const { agent } = handlers;
|
|
197
|
-
const [createState, setCreateState] =
|
|
61
|
+
const [createState, setCreateState] = useState2({
|
|
198
62
|
loading: false,
|
|
199
63
|
error: null,
|
|
200
64
|
data: null
|
|
201
65
|
});
|
|
202
|
-
const [updateState, setUpdateState] =
|
|
66
|
+
const [updateState, setUpdateState] = useState2({
|
|
203
67
|
loading: false,
|
|
204
68
|
error: null,
|
|
205
69
|
data: null
|
|
206
70
|
});
|
|
207
|
-
const [executeState, setExecuteState] =
|
|
71
|
+
const [executeState, setExecuteState] = useState2({
|
|
208
72
|
loading: false,
|
|
209
73
|
error: null,
|
|
210
74
|
data: null
|
|
211
75
|
});
|
|
212
|
-
const createAgent =
|
|
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 =
|
|
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 =
|
|
107
|
+
const activateAgent = useCallback2(async (agentId) => {
|
|
244
108
|
return updateAgent({ id: agentId, status: "ACTIVE" });
|
|
245
109
|
}, [updateAgent]);
|
|
246
|
-
const pauseAgent =
|
|
110
|
+
const pauseAgent = useCallback2(async (agentId) => {
|
|
247
111
|
return updateAgent({ id: agentId, status: "PAUSED" });
|
|
248
112
|
}, [updateAgent]);
|
|
249
|
-
const archiveAgent =
|
|
113
|
+
const archiveAgent = useCallback2(async (agentId) => {
|
|
250
114
|
return updateAgent({ id: agentId, status: "ARCHIVED" });
|
|
251
115
|
}, [updateAgent]);
|
|
252
|
-
const executeAgent =
|
|
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
|
-
|
|
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 {
|
|
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;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -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 './
|
|
5
|
+
export * from './modals';
|
|
8
6
|
export * from './overlays';
|
|
7
|
+
export * from './renderers';
|
|
8
|
+
export * from './views';
|