@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/views/index.js
CHANGED
|
@@ -1,16 +1,69 @@
|
|
|
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 () => {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
try {
|
|
16
|
+
const result = await agent.listAgents({
|
|
17
|
+
projectId,
|
|
18
|
+
search: options.search,
|
|
19
|
+
status: options.status === "all" ? undefined : options.status,
|
|
20
|
+
limit: options.limit ?? 20,
|
|
21
|
+
offset: (page - 1) * (options.limit ?? 20)
|
|
22
|
+
});
|
|
23
|
+
setData(result);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
26
|
+
} finally {
|
|
27
|
+
setLoading(false);
|
|
28
|
+
}
|
|
29
|
+
}, [agent, projectId, options.search, options.status, options.limit, page]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
fetchData();
|
|
32
|
+
}, [fetchData]);
|
|
33
|
+
const stats = useMemo(() => {
|
|
34
|
+
if (!data)
|
|
35
|
+
return null;
|
|
36
|
+
return {
|
|
37
|
+
total: data.total,
|
|
38
|
+
active: data.items.filter((a) => a.status === "ACTIVE").length,
|
|
39
|
+
paused: data.items.filter((a) => a.status === "PAUSED").length,
|
|
40
|
+
draft: data.items.filter((a) => a.status === "DRAFT").length
|
|
41
|
+
};
|
|
42
|
+
}, [data]);
|
|
43
|
+
return {
|
|
44
|
+
data,
|
|
45
|
+
loading,
|
|
46
|
+
error,
|
|
47
|
+
stats,
|
|
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/useRunList.ts
|
|
56
|
+
import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
|
|
57
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
58
|
+
function useRunList(options = {}) {
|
|
59
|
+
const { handlers, projectId } = useTemplateRuntime2();
|
|
60
|
+
const { agent } = handlers;
|
|
61
|
+
const [data, setData] = useState2(null);
|
|
62
|
+
const [metrics, setMetrics] = useState2(null);
|
|
63
|
+
const [loading, setLoading] = useState2(true);
|
|
64
|
+
const [error, setError] = useState2(null);
|
|
65
|
+
const [page, setPage] = useState2(1);
|
|
66
|
+
const fetchData = useCallback2(async () => {
|
|
14
67
|
setLoading(true);
|
|
15
68
|
setError(null);
|
|
16
69
|
try {
|
|
@@ -37,7 +90,7 @@ function useRunList(options = {}) {
|
|
|
37
90
|
setLoading(false);
|
|
38
91
|
}
|
|
39
92
|
}, [agent, projectId, options.agentId, options.status, options.limit, page]);
|
|
40
|
-
|
|
93
|
+
useEffect2(() => {
|
|
41
94
|
fetchData();
|
|
42
95
|
}, [fetchData]);
|
|
43
96
|
return {
|
|
@@ -54,12 +107,12 @@ function useRunList(options = {}) {
|
|
|
54
107
|
|
|
55
108
|
// src/ui/views/RunListView.tsx
|
|
56
109
|
import {
|
|
57
|
-
StatCard,
|
|
58
|
-
StatCardGroup,
|
|
59
|
-
StatusChip,
|
|
60
110
|
EmptyState,
|
|
111
|
+
ErrorState,
|
|
61
112
|
LoaderBlock,
|
|
62
|
-
|
|
113
|
+
StatCard,
|
|
114
|
+
StatCardGroup,
|
|
115
|
+
StatusChip
|
|
63
116
|
} from "@contractspec/lib.design-system";
|
|
64
117
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
65
118
|
"use client";
|
|
@@ -144,45 +197,45 @@ function RunListView({ agentId, onRunClick }) {
|
|
|
144
197
|
]
|
|
145
198
|
}, undefined, true, undefined, this),
|
|
146
199
|
/* @__PURE__ */ jsxDEV("div", {
|
|
147
|
-
className: "
|
|
200
|
+
className: "rounded-lg border border-border",
|
|
148
201
|
children: /* @__PURE__ */ jsxDEV("table", {
|
|
149
202
|
className: "w-full",
|
|
150
203
|
children: [
|
|
151
204
|
/* @__PURE__ */ jsxDEV("thead", {
|
|
152
|
-
className: "border-border bg-muted/30
|
|
205
|
+
className: "border-border border-b bg-muted/30",
|
|
153
206
|
children: /* @__PURE__ */ jsxDEV("tr", {
|
|
154
207
|
children: [
|
|
155
208
|
/* @__PURE__ */ jsxDEV("th", {
|
|
156
|
-
className: "
|
|
209
|
+
className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
|
|
157
210
|
children: "Run"
|
|
158
211
|
}, undefined, false, undefined, this),
|
|
159
212
|
/* @__PURE__ */ jsxDEV("th", {
|
|
160
|
-
className: "
|
|
213
|
+
className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
|
|
161
214
|
children: "Agent"
|
|
162
215
|
}, undefined, false, undefined, this),
|
|
163
216
|
/* @__PURE__ */ jsxDEV("th", {
|
|
164
|
-
className: "
|
|
217
|
+
className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
|
|
165
218
|
children: "Status"
|
|
166
219
|
}, undefined, false, undefined, this),
|
|
167
220
|
/* @__PURE__ */ jsxDEV("th", {
|
|
168
|
-
className: "
|
|
221
|
+
className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
|
|
169
222
|
children: "Tokens"
|
|
170
223
|
}, undefined, false, undefined, this),
|
|
171
224
|
/* @__PURE__ */ jsxDEV("th", {
|
|
172
|
-
className: "
|
|
225
|
+
className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
|
|
173
226
|
children: "Duration"
|
|
174
227
|
}, undefined, false, undefined, this),
|
|
175
228
|
/* @__PURE__ */ jsxDEV("th", {
|
|
176
|
-
className: "
|
|
229
|
+
className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
|
|
177
230
|
children: "Cost"
|
|
178
231
|
}, undefined, false, undefined, this)
|
|
179
232
|
]
|
|
180
233
|
}, undefined, true, undefined, this)
|
|
181
234
|
}, undefined, false, undefined, this),
|
|
182
235
|
/* @__PURE__ */ jsxDEV("tbody", {
|
|
183
|
-
className: "divide-
|
|
236
|
+
className: "divide-y divide-border",
|
|
184
237
|
children: data.items.map((run) => /* @__PURE__ */ jsxDEV("tr", {
|
|
185
|
-
className: "hover:bg-muted/50
|
|
238
|
+
className: "cursor-pointer transition-colors hover:bg-muted/50",
|
|
186
239
|
onClick: () => onRunClick?.(run.id),
|
|
187
240
|
children: [
|
|
188
241
|
/* @__PURE__ */ jsxDEV("td", {
|
|
@@ -231,7 +284,7 @@ function RunListView({ agentId, onRunClick }) {
|
|
|
231
284
|
}, undefined, true, undefined, this)
|
|
232
285
|
}, undefined, false, undefined, this),
|
|
233
286
|
/* @__PURE__ */ jsxDEV("div", {
|
|
234
|
-
className: "text-muted-foreground text-
|
|
287
|
+
className: "text-center text-muted-foreground text-sm",
|
|
235
288
|
children: [
|
|
236
289
|
"Showing ",
|
|
237
290
|
data.items.length,
|
|
@@ -245,16 +298,16 @@ function RunListView({ agentId, onRunClick }) {
|
|
|
245
298
|
}
|
|
246
299
|
|
|
247
300
|
// src/ui/hooks/useToolList.ts
|
|
248
|
-
import {
|
|
249
|
-
import {
|
|
301
|
+
import { useTemplateRuntime as useTemplateRuntime3 } from "@contractspec/lib.example-shared-ui";
|
|
302
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
|
|
250
303
|
function useToolList(options = {}) {
|
|
251
|
-
const { handlers, projectId } =
|
|
304
|
+
const { handlers, projectId } = useTemplateRuntime3();
|
|
252
305
|
const { agent } = handlers;
|
|
253
|
-
const [data, setData] =
|
|
254
|
-
const [loading, setLoading] =
|
|
255
|
-
const [error, setError] =
|
|
256
|
-
const [page, setPage] =
|
|
257
|
-
const fetchData =
|
|
306
|
+
const [data, setData] = useState3(null);
|
|
307
|
+
const [loading, setLoading] = useState3(true);
|
|
308
|
+
const [error, setError] = useState3(null);
|
|
309
|
+
const [page, setPage] = useState3(1);
|
|
310
|
+
const fetchData = useCallback3(async () => {
|
|
258
311
|
setLoading(true);
|
|
259
312
|
setError(null);
|
|
260
313
|
try {
|
|
@@ -281,10 +334,10 @@ function useToolList(options = {}) {
|
|
|
281
334
|
options.limit,
|
|
282
335
|
page
|
|
283
336
|
]);
|
|
284
|
-
|
|
337
|
+
useEffect3(() => {
|
|
285
338
|
fetchData();
|
|
286
339
|
}, [fetchData]);
|
|
287
|
-
const { stats, groupedByCategory, categoryStats } =
|
|
340
|
+
const { stats, groupedByCategory, categoryStats } = useMemo2(() => {
|
|
288
341
|
if (!data)
|
|
289
342
|
return { stats: null, groupedByCategory: {}, categoryStats: [] };
|
|
290
343
|
const items = data.items;
|
|
@@ -329,14 +382,14 @@ function useToolList(options = {}) {
|
|
|
329
382
|
|
|
330
383
|
// src/ui/views/ToolRegistryView.tsx
|
|
331
384
|
import {
|
|
332
|
-
|
|
333
|
-
StatCardGroup as StatCardGroup2,
|
|
334
|
-
StatusChip as StatusChip2,
|
|
335
|
-
EntityCard,
|
|
385
|
+
Button,
|
|
336
386
|
EmptyState as EmptyState2,
|
|
337
|
-
|
|
387
|
+
EntityCard,
|
|
338
388
|
ErrorState as ErrorState2,
|
|
339
|
-
|
|
389
|
+
LoaderBlock as LoaderBlock2,
|
|
390
|
+
StatCard as StatCard2,
|
|
391
|
+
StatCardGroup as StatCardGroup2,
|
|
392
|
+
StatusChip as StatusChip2
|
|
340
393
|
} from "@contractspec/lib.design-system";
|
|
341
394
|
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
342
395
|
"use client";
|
|
@@ -416,11 +469,11 @@ function ToolRegistryView({
|
|
|
416
469
|
children: categoryIcons[category]
|
|
417
470
|
}, undefined, false, undefined, this),
|
|
418
471
|
/* @__PURE__ */ jsxDEV2("h3", {
|
|
419
|
-
className: "text-lg
|
|
472
|
+
className: "font-semibold text-lg",
|
|
420
473
|
children: category
|
|
421
474
|
}, undefined, false, undefined, this),
|
|
422
475
|
/* @__PURE__ */ jsxDEV2("span", {
|
|
423
|
-
className: "
|
|
476
|
+
className: "rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",
|
|
424
477
|
children: tools.length
|
|
425
478
|
}, undefined, false, undefined, this)
|
|
426
479
|
]
|
|
@@ -451,69 +504,16 @@ function ToolRegistryView({
|
|
|
451
504
|
}, undefined, true, undefined, this);
|
|
452
505
|
}
|
|
453
506
|
|
|
454
|
-
// src/ui/hooks/useAgentList.ts
|
|
455
|
-
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
|
|
456
|
-
import { useTemplateRuntime as useTemplateRuntime3 } from "@contractspec/lib.example-shared-ui";
|
|
457
|
-
function useAgentList(options = {}) {
|
|
458
|
-
const { handlers, projectId } = useTemplateRuntime3();
|
|
459
|
-
const { agent } = handlers;
|
|
460
|
-
const [data, setData] = useState3(null);
|
|
461
|
-
const [loading, setLoading] = useState3(true);
|
|
462
|
-
const [error, setError] = useState3(null);
|
|
463
|
-
const [page, setPage] = useState3(1);
|
|
464
|
-
const fetchData = useCallback3(async () => {
|
|
465
|
-
setLoading(true);
|
|
466
|
-
setError(null);
|
|
467
|
-
try {
|
|
468
|
-
const result = await agent.listAgents({
|
|
469
|
-
projectId,
|
|
470
|
-
search: options.search,
|
|
471
|
-
status: options.status === "all" ? undefined : options.status,
|
|
472
|
-
limit: options.limit ?? 20,
|
|
473
|
-
offset: (page - 1) * (options.limit ?? 20)
|
|
474
|
-
});
|
|
475
|
-
setData(result);
|
|
476
|
-
} catch (err) {
|
|
477
|
-
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
478
|
-
} finally {
|
|
479
|
-
setLoading(false);
|
|
480
|
-
}
|
|
481
|
-
}, [agent, projectId, options.search, options.status, options.limit, page]);
|
|
482
|
-
useEffect3(() => {
|
|
483
|
-
fetchData();
|
|
484
|
-
}, [fetchData]);
|
|
485
|
-
const stats = useMemo2(() => {
|
|
486
|
-
if (!data)
|
|
487
|
-
return null;
|
|
488
|
-
return {
|
|
489
|
-
total: data.total,
|
|
490
|
-
active: data.items.filter((a) => a.status === "ACTIVE").length,
|
|
491
|
-
paused: data.items.filter((a) => a.status === "PAUSED").length,
|
|
492
|
-
draft: data.items.filter((a) => a.status === "DRAFT").length
|
|
493
|
-
};
|
|
494
|
-
}, [data]);
|
|
495
|
-
return {
|
|
496
|
-
data,
|
|
497
|
-
loading,
|
|
498
|
-
error,
|
|
499
|
-
stats,
|
|
500
|
-
page,
|
|
501
|
-
refetch: fetchData,
|
|
502
|
-
nextPage: () => setPage((p) => p + 1),
|
|
503
|
-
prevPage: () => page > 1 && setPage((p) => p - 1)
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
|
|
507
507
|
// src/ui/views/AgentListView.tsx
|
|
508
508
|
import {
|
|
509
509
|
Button as Button2,
|
|
510
|
-
|
|
511
|
-
StatCardGroup as StatCardGroup3,
|
|
510
|
+
EmptyState as EmptyState3,
|
|
512
511
|
EntityCard as EntityCard2,
|
|
513
|
-
StatusChip as StatusChip3,
|
|
514
|
-
LoaderBlock as LoaderBlock3,
|
|
515
512
|
ErrorState as ErrorState3,
|
|
516
|
-
|
|
513
|
+
LoaderBlock as LoaderBlock3,
|
|
514
|
+
StatCard as StatCard3,
|
|
515
|
+
StatCardGroup as StatCardGroup3,
|
|
516
|
+
StatusChip as StatusChip3
|
|
517
517
|
} from "@contractspec/lib.design-system";
|
|
518
518
|
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
519
519
|
"use client";
|
|
@@ -578,7 +578,7 @@ function AgentListView() {
|
|
|
578
578
|
className: "flex items-center justify-between",
|
|
579
579
|
children: [
|
|
580
580
|
/* @__PURE__ */ jsxDEV3("h3", {
|
|
581
|
-
className: "text-lg
|
|
581
|
+
className: "font-semibold text-lg",
|
|
582
582
|
children: "Agents"
|
|
583
583
|
}, undefined, false, undefined, this),
|
|
584
584
|
/* @__PURE__ */ jsxDEV3(Button2, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.agent-console",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.7",
|
|
4
4
|
"description": "Agent Console example - AI agent orchestration with tools, runs, and logs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -477,27 +477,27 @@
|
|
|
477
477
|
"dev": "contractspec-bun-build dev",
|
|
478
478
|
"clean": "rimraf dist .turbo",
|
|
479
479
|
"lint": "bun lint:fix",
|
|
480
|
-
"lint:fix": "
|
|
481
|
-
"lint:check": "
|
|
480
|
+
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
481
|
+
"lint:check": "biome check .",
|
|
482
482
|
"test": "bun test --pass-with-no-tests",
|
|
483
483
|
"prebuild": "contractspec-bun-build prebuild",
|
|
484
484
|
"typecheck": "tsc --noEmit"
|
|
485
485
|
},
|
|
486
486
|
"dependencies": {
|
|
487
|
-
"@contractspec/lib.schema": "3.7.
|
|
488
|
-
"@contractspec/lib.contracts-spec": "
|
|
489
|
-
"@contractspec/lib.example-shared-ui": "6.0.
|
|
490
|
-
"@contractspec/lib.design-system": "3.
|
|
491
|
-
"@contractspec/lib.runtime-sandbox": "2.7.
|
|
487
|
+
"@contractspec/lib.schema": "3.7.6",
|
|
488
|
+
"@contractspec/lib.contracts-spec": "4.0.0",
|
|
489
|
+
"@contractspec/lib.example-shared-ui": "6.0.7",
|
|
490
|
+
"@contractspec/lib.design-system": "3.8.0",
|
|
491
|
+
"@contractspec/lib.runtime-sandbox": "2.7.6",
|
|
492
492
|
"react": "19.2.0",
|
|
493
493
|
"react-dom": "19.2.0"
|
|
494
494
|
},
|
|
495
495
|
"devDependencies": {
|
|
496
|
-
"@contractspec/tool.typescript": "3.7.
|
|
496
|
+
"@contractspec/tool.typescript": "3.7.6",
|
|
497
497
|
"typescript": "^5.9.3",
|
|
498
498
|
"@types/react": "^19.2.14",
|
|
499
499
|
"@types/react-dom": "^19.2.2",
|
|
500
|
-
"@contractspec/tool.bun": "3.7.
|
|
500
|
+
"@contractspec/tool.bun": "3.7.6"
|
|
501
501
|
},
|
|
502
502
|
"publishConfig": {
|
|
503
503
|
"exports": {
|
|
@@ -1,137 +1,137 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
defineEntity,
|
|
3
|
+
defineEntityEnum,
|
|
4
|
+
field,
|
|
5
|
+
index,
|
|
6
6
|
} from '@contractspec/lib.schema';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Agent status for lifecycle management.
|
|
10
10
|
*/
|
|
11
11
|
export const AgentStatusEntityEnum = defineEntityEnum({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
name: 'AgentStatus',
|
|
13
|
+
values: ['DRAFT', 'ACTIVE', 'PAUSED', 'ARCHIVED'],
|
|
14
|
+
description: 'Lifecycle status of the agent',
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Agent model provider.
|
|
19
19
|
*/
|
|
20
20
|
export const ModelProviderEntityEnum = defineEntityEnum({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
name: 'ModelProvider',
|
|
22
|
+
values: ['OPENAI', 'ANTHROPIC', 'GOOGLE', 'MISTRAL', 'CUSTOM'],
|
|
23
|
+
description: 'AI model provider',
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Agent entity - Represents an AI agent configuration.
|
|
28
28
|
*/
|
|
29
29
|
export const AgentEntity = defineEntity({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
30
|
+
name: 'Agent',
|
|
31
|
+
schema: 'agent_console',
|
|
32
|
+
description:
|
|
33
|
+
'Represents an AI agent configuration with assigned tools and parameters.',
|
|
34
|
+
fields: {
|
|
35
|
+
id: field.id(),
|
|
36
|
+
organizationId: field.string({
|
|
37
|
+
description: 'Organization that owns this agent',
|
|
38
|
+
}),
|
|
39
|
+
name: field.string({ description: 'Agent name (1-100 chars)' }),
|
|
40
|
+
slug: field.string({
|
|
41
|
+
description: 'URL-safe identifier (lowercase, numbers, hyphens)',
|
|
42
|
+
}),
|
|
43
|
+
description: field.string({
|
|
44
|
+
isOptional: true,
|
|
45
|
+
description: 'Agent description (max 1000 chars)',
|
|
46
|
+
}),
|
|
47
|
+
status: field.enum('AgentStatus', { default: 'DRAFT' }),
|
|
48
|
+
modelProvider: field.enum('ModelProvider', { default: 'OPENAI' }),
|
|
49
|
+
modelName: field.string({
|
|
50
|
+
description: "Model identifier: 'gpt-4', 'claude-3-opus', etc.",
|
|
51
|
+
}),
|
|
52
|
+
modelConfig: field.json({
|
|
53
|
+
isOptional: true,
|
|
54
|
+
description: 'Model parameters: temperature, max_tokens, etc.',
|
|
55
|
+
}),
|
|
56
|
+
systemPrompt: field.string({ description: 'System prompt for the agent' }),
|
|
57
|
+
userPromptTemplate: field.string({
|
|
58
|
+
isOptional: true,
|
|
59
|
+
description: 'Template for user prompts',
|
|
60
|
+
}),
|
|
61
|
+
toolIds: field.string({
|
|
62
|
+
isArray: true,
|
|
63
|
+
isOptional: true,
|
|
64
|
+
description: 'IDs of assigned tools',
|
|
65
|
+
}),
|
|
66
|
+
toolChoice: field.string({
|
|
67
|
+
default: 'auto',
|
|
68
|
+
description: "Tool selection mode: 'auto', 'required', 'none'",
|
|
69
|
+
}),
|
|
70
|
+
maxIterations: field.int({
|
|
71
|
+
default: 10,
|
|
72
|
+
description: 'Maximum iterations per run',
|
|
73
|
+
}),
|
|
74
|
+
maxTokensPerRun: field.int({
|
|
75
|
+
isOptional: true,
|
|
76
|
+
description: 'Maximum tokens per run',
|
|
77
|
+
}),
|
|
78
|
+
timeoutMs: field.int({
|
|
79
|
+
default: 120000,
|
|
80
|
+
description: 'Execution timeout in milliseconds',
|
|
81
|
+
}),
|
|
82
|
+
version: field.string({ default: '1.0.0', description: 'Agent version' }),
|
|
83
|
+
tags: field.string({
|
|
84
|
+
isArray: true,
|
|
85
|
+
isOptional: true,
|
|
86
|
+
description: 'Tags for categorization',
|
|
87
|
+
}),
|
|
88
|
+
createdAt: field.createdAt(),
|
|
89
|
+
updatedAt: field.updatedAt(),
|
|
90
|
+
createdById: field.string({
|
|
91
|
+
isOptional: true,
|
|
92
|
+
description: 'User who created this agent',
|
|
93
|
+
}),
|
|
94
|
+
tools: field.hasMany('Tool', {
|
|
95
|
+
description: 'Tools assigned to this agent',
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
indexes: [
|
|
99
|
+
index.unique(['organizationId', 'slug']),
|
|
100
|
+
index.on(['organizationId', 'status']),
|
|
101
|
+
index.on(['modelProvider', 'modelName']),
|
|
102
|
+
],
|
|
103
|
+
enums: [AgentStatusEntityEnum, ModelProviderEntityEnum],
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* AgentTool join entity - Links agents to their assigned tools.
|
|
108
108
|
*/
|
|
109
109
|
export const AgentToolEntity = defineEntity({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
110
|
+
name: 'AgentTool',
|
|
111
|
+
schema: 'agent_console',
|
|
112
|
+
description: 'Links an agent to its assigned tools with configuration.',
|
|
113
|
+
fields: {
|
|
114
|
+
id: field.id(),
|
|
115
|
+
agentId: field.foreignKey({ description: 'Agent ID' }),
|
|
116
|
+
toolId: field.foreignKey({ description: 'Tool ID' }),
|
|
117
|
+
config: field.json({
|
|
118
|
+
isOptional: true,
|
|
119
|
+
description: 'Tool-specific configuration for this agent',
|
|
120
|
+
}),
|
|
121
|
+
order: field.int({
|
|
122
|
+
default: 0,
|
|
123
|
+
description: 'Order of tool in agent tool list',
|
|
124
|
+
}),
|
|
125
|
+
isEnabled: field.boolean({
|
|
126
|
+
default: true,
|
|
127
|
+
description: 'Whether tool is enabled for this agent',
|
|
128
|
+
}),
|
|
129
|
+
createdAt: field.createdAt(),
|
|
130
|
+
agent: field.belongsTo('Agent', ['agentId'], ['id']),
|
|
131
|
+
tool: field.belongsTo('Tool', ['toolId'], ['id']),
|
|
132
|
+
},
|
|
133
|
+
indexes: [
|
|
134
|
+
index.unique(['agentId', 'toolId']),
|
|
135
|
+
index.on(['agentId', 'order']),
|
|
136
|
+
],
|
|
137
137
|
});
|
package/src/agent/agent.enum.ts
CHANGED
|
@@ -4,28 +4,28 @@ import { defineEnum } from '@contractspec/lib.schema';
|
|
|
4
4
|
* Agent status enum.
|
|
5
5
|
*/
|
|
6
6
|
export const AgentStatusEnum = defineEnum('AgentStatus', [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
'DRAFT',
|
|
8
|
+
'ACTIVE',
|
|
9
|
+
'PAUSED',
|
|
10
|
+
'ARCHIVED',
|
|
11
11
|
]);
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Model provider enum.
|
|
15
15
|
*/
|
|
16
16
|
export const ModelProviderEnum = defineEnum('ModelProvider', [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
'OPENAI',
|
|
18
|
+
'ANTHROPIC',
|
|
19
|
+
'GOOGLE',
|
|
20
|
+
'MISTRAL',
|
|
21
|
+
'CUSTOM',
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Tool choice mode enum.
|
|
26
26
|
*/
|
|
27
27
|
export const ToolChoiceEnum = defineEnum('ToolChoice', [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
'auto',
|
|
29
|
+
'required',
|
|
30
|
+
'none',
|
|
31
31
|
]);
|