@contractspec/example.agent-console 3.8.8 → 3.8.10
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 +225 -222
- package/CHANGELOG.md +34 -0
- package/dist/agent/agent.entity.js +1 -127
- package/dist/agent/agent.enum.js +1 -25
- package/dist/agent/agent.event.js +1 -116
- package/dist/agent/agent.handler.js +1 -1030
- package/dist/agent/agent.operation.js +1 -735
- package/dist/agent/agent.presentation.js +1 -282
- package/dist/agent/agent.schema.js +1 -215
- package/dist/agent/agent.test-spec.js +1 -58
- package/dist/agent/index.js +1 -1248
- package/dist/agent.capability.js +1 -19
- package/dist/agent.feature.js +1 -305
- package/dist/browser/agent/agent.entity.js +1 -127
- package/dist/browser/agent/agent.enum.js +1 -25
- package/dist/browser/agent/agent.event.js +1 -116
- package/dist/browser/agent/agent.handler.js +1 -1030
- package/dist/browser/agent/agent.operation.js +1 -735
- package/dist/browser/agent/agent.presentation.js +1 -282
- package/dist/browser/agent/agent.schema.js +1 -215
- package/dist/browser/agent/agent.test-spec.js +1 -58
- package/dist/browser/agent/index.js +1 -1248
- package/dist/browser/agent.capability.js +1 -19
- package/dist/browser/agent.feature.js +1 -305
- package/dist/browser/docs/agent-console.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/example.js +1 -41
- package/dist/browser/handlers/agent.handlers.js +6 -2143
- package/dist/browser/handlers/index.js +6 -2943
- package/dist/browser/index.js +14 -6828
- package/dist/browser/presentations/index.js +1 -693
- package/dist/browser/run/index.js +1 -1363
- package/dist/browser/run/run.entity.js +1 -160
- package/dist/browser/run/run.enum.js +1 -34
- package/dist/browser/run/run.event.js +1 -217
- package/dist/browser/run/run.handler.js +1 -919
- package/dist/browser/run/run.operation.js +1 -667
- package/dist/browser/run/run.presentation.js +1 -223
- package/dist/browser/run/run.schema.js +1 -179
- package/dist/browser/run/run.test-spec.js +1 -58
- package/dist/browser/seeders/index.js +2 -21
- package/dist/browser/shared/index.js +1 -626
- package/dist/browser/shared/mock-agents.js +1 -82
- package/dist/browser/shared/mock-runs.js +1 -113
- package/dist/browser/shared/mock-tools.js +1 -146
- package/dist/browser/tool/index.js +1 -949
- package/dist/browser/tool/tool.entity.js +1 -90
- package/dist/browser/tool/tool.enum.js +1 -26
- package/dist/browser/tool/tool.event.js +1 -99
- package/dist/browser/tool/tool.handler.js +1 -699
- package/dist/browser/tool/tool.operation.js +1 -482
- package/dist/browser/tool/tool.presentation.js +1 -188
- package/dist/browser/tool/tool.schema.js +1 -141
- package/dist/browser/tool/tool.test-spec.js +1 -58
- package/dist/browser/ui/AgentDashboard.js +1 -2527
- package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/browser/ui/AgentRunList.js +1 -482
- package/dist/browser/ui/AgentToolRegistry.js +1 -212
- package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
- package/dist/browser/ui/hooks/index.js +1 -740
- package/dist/browser/ui/hooks/useAgentList.js +1 -55
- package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
- package/dist/browser/ui/hooks/useRunList.js +1 -70
- package/dist/browser/ui/hooks/useToolList.js +1 -85
- package/dist/browser/ui/index.js +5 -3018
- package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
- package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
- package/dist/browser/ui/modals/index.js +1 -546
- package/dist/browser/ui/overlays/demo-overlays.js +1 -64
- package/dist/browser/ui/overlays/index.js +1 -64
- package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/browser/ui/renderers/index.js +5 -642
- package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
- package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/browser/ui/views/AgentListView.js +1 -165
- package/dist/browser/ui/views/RunDataTable.js +1 -326
- package/dist/browser/ui/views/RunListView.js +1 -479
- package/dist/browser/ui/views/ToolRegistryView.js +1 -209
- package/dist/browser/ui/views/index.js +1 -851
- package/dist/browser/ui/views/run-data-table.columns.js +1 -271
- package/dist/browser/ui/views/run-list.shared.js +1 -177
- package/dist/browser/visualizations/catalog.js +1 -134
- package/dist/browser/visualizations/index.js +1 -187
- package/dist/browser/visualizations/selectors.js +1 -181
- package/dist/docs/agent-console.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/example.js +1 -41
- package/dist/handlers/agent.handlers.js +6 -2143
- package/dist/handlers/index.js +6 -2943
- package/dist/index.js +14 -6828
- package/dist/node/agent/agent.entity.js +1 -127
- package/dist/node/agent/agent.enum.js +1 -25
- package/dist/node/agent/agent.event.js +1 -116
- package/dist/node/agent/agent.handler.js +1 -1030
- package/dist/node/agent/agent.operation.js +1 -735
- package/dist/node/agent/agent.presentation.js +1 -282
- package/dist/node/agent/agent.schema.js +1 -215
- package/dist/node/agent/agent.test-spec.js +1 -58
- package/dist/node/agent/index.js +1 -1248
- package/dist/node/agent.capability.js +1 -19
- package/dist/node/agent.feature.js +1 -305
- package/dist/node/docs/agent-console.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/example.js +1 -41
- package/dist/node/handlers/agent.handlers.js +6 -2143
- package/dist/node/handlers/index.js +6 -2943
- package/dist/node/index.js +14 -6828
- package/dist/node/presentations/index.js +1 -693
- package/dist/node/run/index.js +1 -1363
- package/dist/node/run/run.entity.js +1 -160
- package/dist/node/run/run.enum.js +1 -34
- package/dist/node/run/run.event.js +1 -217
- package/dist/node/run/run.handler.js +1 -919
- package/dist/node/run/run.operation.js +1 -667
- package/dist/node/run/run.presentation.js +1 -223
- package/dist/node/run/run.schema.js +1 -179
- package/dist/node/run/run.test-spec.js +1 -58
- package/dist/node/seeders/index.js +2 -21
- package/dist/node/shared/index.js +1 -626
- package/dist/node/shared/mock-agents.js +1 -82
- package/dist/node/shared/mock-runs.js +1 -113
- package/dist/node/shared/mock-tools.js +1 -146
- package/dist/node/tool/index.js +1 -949
- package/dist/node/tool/tool.entity.js +1 -90
- package/dist/node/tool/tool.enum.js +1 -26
- package/dist/node/tool/tool.event.js +1 -99
- package/dist/node/tool/tool.handler.js +1 -699
- package/dist/node/tool/tool.operation.js +1 -482
- package/dist/node/tool/tool.presentation.js +1 -188
- package/dist/node/tool/tool.schema.js +1 -141
- package/dist/node/tool/tool.test-spec.js +1 -58
- package/dist/node/ui/AgentDashboard.js +1 -2527
- package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/node/ui/AgentRunList.js +1 -482
- package/dist/node/ui/AgentToolRegistry.js +1 -212
- package/dist/node/ui/ExecutionConsoleHost.js +1 -0
- package/dist/node/ui/hooks/index.js +1 -740
- package/dist/node/ui/hooks/useAgentList.js +1 -55
- package/dist/node/ui/hooks/useAgentMutations.js +1 -530
- package/dist/node/ui/hooks/useRunList.js +1 -70
- package/dist/node/ui/hooks/useToolList.js +1 -85
- package/dist/node/ui/index.js +5 -3018
- package/dist/node/ui/modals/AgentActionsModal.js +1 -304
- package/dist/node/ui/modals/CreateAgentModal.js +1 -243
- package/dist/node/ui/modals/index.js +1 -546
- package/dist/node/ui/overlays/demo-overlays.js +1 -64
- package/dist/node/ui/overlays/index.js +1 -64
- package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/node/ui/renderers/index.js +5 -642
- package/dist/node/ui/renderers/run-list.markdown.js +2 -50
- package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/node/ui/views/AgentListView.js +1 -165
- package/dist/node/ui/views/RunDataTable.js +1 -326
- package/dist/node/ui/views/RunListView.js +1 -479
- package/dist/node/ui/views/ToolRegistryView.js +1 -209
- package/dist/node/ui/views/index.js +1 -851
- package/dist/node/ui/views/run-data-table.columns.js +1 -271
- package/dist/node/ui/views/run-list.shared.js +1 -177
- package/dist/node/visualizations/catalog.js +1 -134
- package/dist/node/visualizations/index.js +1 -187
- package/dist/node/visualizations/selectors.js +1 -181
- package/dist/presentations/index.js +1 -693
- package/dist/run/index.js +1 -1363
- package/dist/run/run.entity.js +1 -160
- package/dist/run/run.enum.js +1 -34
- package/dist/run/run.event.js +1 -217
- package/dist/run/run.handler.js +1 -919
- package/dist/run/run.operation.js +1 -667
- package/dist/run/run.presentation.js +1 -223
- package/dist/run/run.schema.js +1 -179
- package/dist/run/run.test-spec.js +1 -58
- package/dist/seeders/index.js +2 -21
- package/dist/shared/index.js +1 -626
- package/dist/shared/mock-agents.js +1 -82
- package/dist/shared/mock-runs.js +1 -113
- package/dist/shared/mock-tools.js +1 -146
- package/dist/tool/index.js +1 -949
- package/dist/tool/tool.entity.js +1 -90
- package/dist/tool/tool.enum.js +1 -26
- package/dist/tool/tool.event.js +1 -99
- package/dist/tool/tool.handler.js +1 -699
- package/dist/tool/tool.operation.js +1 -482
- package/dist/tool/tool.presentation.js +1 -188
- package/dist/tool/tool.schema.js +1 -141
- package/dist/tool/tool.test-spec.js +1 -58
- package/dist/ui/AgentDashboard.js +1 -2527
- package/dist/ui/AgentDashboard.visualizations.js +1 -217
- package/dist/ui/AgentRunList.js +1 -482
- package/dist/ui/AgentToolRegistry.js +1 -212
- package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
- package/dist/ui/ExecutionConsoleHost.js +2 -0
- package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
- package/dist/ui/hooks/index.js +1 -740
- package/dist/ui/hooks/useAgentList.js +1 -55
- package/dist/ui/hooks/useAgentMutations.js +1 -530
- package/dist/ui/hooks/useRunList.js +1 -70
- package/dist/ui/hooks/useToolList.js +1 -85
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +5 -3018
- package/dist/ui/modals/AgentActionsModal.js +1 -304
- package/dist/ui/modals/CreateAgentModal.js +1 -243
- package/dist/ui/modals/index.js +1 -546
- package/dist/ui/overlays/demo-overlays.js +1 -64
- package/dist/ui/overlays/index.js +1 -64
- package/dist/ui/renderers/agent-list.markdown.js +2 -64
- package/dist/ui/renderers/agent-list.renderer.js +1 -180
- package/dist/ui/renderers/dashboard.markdown.js +2 -288
- package/dist/ui/renderers/index.js +5 -642
- package/dist/ui/renderers/run-list.markdown.js +2 -50
- package/dist/ui/renderers/tool-registry.markdown.js +2 -64
- package/dist/ui/views/AgentListView.js +1 -165
- package/dist/ui/views/RunDataTable.js +1 -326
- package/dist/ui/views/RunListView.js +1 -479
- package/dist/ui/views/ToolRegistryView.js +1 -209
- package/dist/ui/views/index.js +1 -851
- package/dist/ui/views/run-data-table.columns.js +1 -271
- package/dist/ui/views/run-list.shared.js +1 -177
- package/dist/visualizations/catalog.js +1 -134
- package/dist/visualizations/index.js +1 -187
- package/dist/visualizations/selectors.js +1 -181
- package/package.json +29 -13
- package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
- package/src/ui/ExecutionConsoleHost.tsx +14 -0
- package/src/ui/index.ts +1 -1
|
@@ -1,55 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
-
function useAgentList(options = {}) {
|
|
5
|
-
const { handlers, projectId } = useTemplateRuntime();
|
|
6
|
-
const { agent } = handlers;
|
|
7
|
-
const [data, setData] = useState(null);
|
|
8
|
-
const [loading, setLoading] = useState(true);
|
|
9
|
-
const [error, setError] = useState(null);
|
|
10
|
-
const [page, setPage] = useState(1);
|
|
11
|
-
const fetchData = useCallback(async () => {
|
|
12
|
-
setLoading(true);
|
|
13
|
-
setError(null);
|
|
14
|
-
try {
|
|
15
|
-
const result = await agent.listAgents({
|
|
16
|
-
projectId,
|
|
17
|
-
search: options.search,
|
|
18
|
-
status: options.status === "all" ? undefined : options.status,
|
|
19
|
-
limit: options.limit ?? 20,
|
|
20
|
-
offset: (page - 1) * (options.limit ?? 20)
|
|
21
|
-
});
|
|
22
|
-
setData(result);
|
|
23
|
-
} catch (err) {
|
|
24
|
-
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
25
|
-
} finally {
|
|
26
|
-
setLoading(false);
|
|
27
|
-
}
|
|
28
|
-
}, [agent, projectId, options.search, options.status, options.limit, page]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
fetchData();
|
|
31
|
-
}, [fetchData]);
|
|
32
|
-
const stats = useMemo(() => {
|
|
33
|
-
if (!data)
|
|
34
|
-
return null;
|
|
35
|
-
return {
|
|
36
|
-
total: data.total,
|
|
37
|
-
active: data.items.filter((a) => a.status === "ACTIVE").length,
|
|
38
|
-
paused: data.items.filter((a) => a.status === "PAUSED").length,
|
|
39
|
-
draft: data.items.filter((a) => a.status === "DRAFT").length
|
|
40
|
-
};
|
|
41
|
-
}, [data]);
|
|
42
|
-
return {
|
|
43
|
-
data,
|
|
44
|
-
loading,
|
|
45
|
-
error,
|
|
46
|
-
stats,
|
|
47
|
-
page,
|
|
48
|
-
refetch: fetchData,
|
|
49
|
-
nextPage: () => setPage((p) => p + 1),
|
|
50
|
-
prevPage: () => page > 1 && setPage((p) => p - 1)
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
useAgentList
|
|
55
|
-
};
|
|
1
|
+
import{useTemplateRuntime as V}from"@contractspec/lib.example-shared-ui";import{useCallback as W,useEffect as X,useMemo as Y,useState as z}from"react";function $(v={}){let{handlers:K,projectId:B}=V(),{agent:F}=K,[w,N]=z(null),[O,G]=z(!0),[Q,H]=z(null),[y,J]=z(1),A=W(async()=>{G(!0),H(null);try{let q=await F.listAgents({projectId:B,search:v.search,status:v.status==="all"?void 0:v.status,limit:v.limit??20,offset:(y-1)*(v.limit??20)});N(q)}catch(q){H(q instanceof Error?q:Error("Unknown error"))}finally{G(!1)}},[F,B,v.search,v.status,v.limit,y]);X(()=>{A()},[A]);let U=Y(()=>{if(!w)return null;return{total:w.total,active:w.items.filter((q)=>q.status==="ACTIVE").length,paused:w.items.filter((q)=>q.status==="PAUSED").length,draft:w.items.filter((q)=>q.status==="DRAFT").length}},[w]);return{data:w,loading:O,error:Q,stats:U,page:y,refetch:A,nextPage:()=>J((q)=>q+1),prevPage:()=>y>1&&J((q)=>q-1)}}export{$ as useAgentList};
|
|
@@ -1,530 +1 @@
|
|
|
1
|
-
// src/shared/mock-agents.ts
|
|
2
|
-
var MOCK_AGENTS = [
|
|
3
|
-
{
|
|
4
|
-
id: "agent-1",
|
|
5
|
-
organizationId: "demo-org",
|
|
6
|
-
name: "Customer Support Bot",
|
|
7
|
-
slug: "customer-support-bot",
|
|
8
|
-
description: "Handles tier-1 customer inquiries and routes complex issues.",
|
|
9
|
-
status: "ACTIVE",
|
|
10
|
-
modelProvider: "OPENAI",
|
|
11
|
-
modelName: "gpt-4o-mini",
|
|
12
|
-
modelConfig: { temperature: 0.7 },
|
|
13
|
-
systemPrompt: "You are a helpful customer support assistant.",
|
|
14
|
-
toolChoice: "auto",
|
|
15
|
-
maxIterations: 10,
|
|
16
|
-
timeoutMs: 120000,
|
|
17
|
-
version: "1.0.0",
|
|
18
|
-
tags: ["support", "tier-1"],
|
|
19
|
-
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
20
|
-
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: "agent-2",
|
|
24
|
-
organizationId: "demo-org",
|
|
25
|
-
name: "Code Review Assistant",
|
|
26
|
-
slug: "code-review-assistant",
|
|
27
|
-
description: "Reviews pull requests and provides actionable feedback.",
|
|
28
|
-
status: "ACTIVE",
|
|
29
|
-
modelProvider: "ANTHROPIC",
|
|
30
|
-
modelName: "claude-sonnet-4-20250514",
|
|
31
|
-
modelConfig: { temperature: 0.3 },
|
|
32
|
-
systemPrompt: "You are a code review expert.",
|
|
33
|
-
toolChoice: "auto",
|
|
34
|
-
maxIterations: 15,
|
|
35
|
-
timeoutMs: 180000,
|
|
36
|
-
version: "2.1.0",
|
|
37
|
-
tags: ["code", "review", "dev"],
|
|
38
|
-
createdAt: new Date("2024-02-10T09:00:00Z"),
|
|
39
|
-
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: "agent-3",
|
|
43
|
-
organizationId: "demo-org",
|
|
44
|
-
name: "Data Analyst",
|
|
45
|
-
slug: "data-analyst",
|
|
46
|
-
description: "Queries databases and generates insights from data.",
|
|
47
|
-
status: "PAUSED",
|
|
48
|
-
modelProvider: "OPENAI",
|
|
49
|
-
modelName: "gpt-4o",
|
|
50
|
-
modelConfig: { temperature: 0.5 },
|
|
51
|
-
systemPrompt: "You are a data analyst expert in SQL and analytics.",
|
|
52
|
-
toolChoice: "required",
|
|
53
|
-
maxIterations: 20,
|
|
54
|
-
timeoutMs: 300000,
|
|
55
|
-
version: "1.2.0",
|
|
56
|
-
tags: ["data", "analytics", "sql"],
|
|
57
|
-
createdAt: new Date("2024-03-01T08:00:00Z"),
|
|
58
|
-
updatedAt: new Date("2024-04-10T16:45:00Z")
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: "agent-4",
|
|
62
|
-
organizationId: "demo-org",
|
|
63
|
-
name: "Meeting Scheduler",
|
|
64
|
-
slug: "meeting-scheduler",
|
|
65
|
-
description: "Schedules meetings and manages calendar conflicts.",
|
|
66
|
-
status: "DRAFT",
|
|
67
|
-
modelProvider: "GOOGLE",
|
|
68
|
-
modelName: "gemini-2.0-flash",
|
|
69
|
-
modelConfig: { temperature: 0.2 },
|
|
70
|
-
systemPrompt: "You help schedule and organize meetings efficiently.",
|
|
71
|
-
toolChoice: "auto",
|
|
72
|
-
maxIterations: 5,
|
|
73
|
-
timeoutMs: 60000,
|
|
74
|
-
version: "0.1.0",
|
|
75
|
-
tags: ["calendar", "scheduling"],
|
|
76
|
-
createdAt: new Date("2024-04-01T12:00:00Z"),
|
|
77
|
-
updatedAt: new Date("2024-04-01T12:00:00Z")
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
// src/shared/mock-tools.ts
|
|
82
|
-
var MOCK_TOOLS = [
|
|
83
|
-
{
|
|
84
|
-
id: "tool-1",
|
|
85
|
-
organizationId: "demo-org",
|
|
86
|
-
name: "Web Search",
|
|
87
|
-
slug: "web-search",
|
|
88
|
-
description: "Search the web for real-time information using Brave API.",
|
|
89
|
-
category: "RETRIEVAL",
|
|
90
|
-
status: "ACTIVE",
|
|
91
|
-
parametersSchema: {
|
|
92
|
-
type: "object",
|
|
93
|
-
properties: {
|
|
94
|
-
query: { type: "string", description: "Search query" },
|
|
95
|
-
numResults: { type: "number", default: 10 }
|
|
96
|
-
},
|
|
97
|
-
required: ["query"]
|
|
98
|
-
},
|
|
99
|
-
outputSchema: { type: "array", items: { type: "object" } },
|
|
100
|
-
implementationType: "http",
|
|
101
|
-
implementationConfig: {
|
|
102
|
-
url: "https://api.brave.com/search",
|
|
103
|
-
method: "GET"
|
|
104
|
-
},
|
|
105
|
-
maxInvocationsPerMinute: 60,
|
|
106
|
-
timeoutMs: 30000,
|
|
107
|
-
version: "1.0.0",
|
|
108
|
-
tags: ["search", "web"],
|
|
109
|
-
createdAt: new Date("2024-01-01T00:00:00Z"),
|
|
110
|
-
updatedAt: new Date("2024-02-15T10:00:00Z")
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: "tool-2",
|
|
114
|
-
organizationId: "demo-org",
|
|
115
|
-
name: "SQL Query",
|
|
116
|
-
slug: "sql-query",
|
|
117
|
-
description: "Execute read-only SQL queries against the data warehouse.",
|
|
118
|
-
category: "RETRIEVAL",
|
|
119
|
-
status: "ACTIVE",
|
|
120
|
-
parametersSchema: {
|
|
121
|
-
type: "object",
|
|
122
|
-
properties: {
|
|
123
|
-
query: { type: "string", description: "SQL query" },
|
|
124
|
-
maxRows: { type: "number", default: 100 }
|
|
125
|
-
},
|
|
126
|
-
required: ["query"]
|
|
127
|
-
},
|
|
128
|
-
outputSchema: { type: "object" },
|
|
129
|
-
implementationType: "function",
|
|
130
|
-
implementationConfig: { handler: "executeSqlQuery" },
|
|
131
|
-
maxInvocationsPerMinute: 30,
|
|
132
|
-
timeoutMs: 60000,
|
|
133
|
-
version: "1.1.0",
|
|
134
|
-
tags: ["sql", "database"],
|
|
135
|
-
createdAt: new Date("2024-01-05T00:00:00Z"),
|
|
136
|
-
updatedAt: new Date("2024-03-10T14:00:00Z")
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: "tool-3",
|
|
140
|
-
organizationId: "demo-org",
|
|
141
|
-
name: "Email Sender",
|
|
142
|
-
slug: "email-sender",
|
|
143
|
-
description: "Send emails via SMTP or API.",
|
|
144
|
-
category: "COMMUNICATION",
|
|
145
|
-
status: "ACTIVE",
|
|
146
|
-
parametersSchema: {
|
|
147
|
-
type: "object",
|
|
148
|
-
properties: {
|
|
149
|
-
to: { type: "string" },
|
|
150
|
-
subject: { type: "string" },
|
|
151
|
-
body: { type: "string" }
|
|
152
|
-
},
|
|
153
|
-
required: ["to", "subject", "body"]
|
|
154
|
-
},
|
|
155
|
-
implementationType: "http",
|
|
156
|
-
implementationConfig: { url: "/api/send-email", method: "POST" },
|
|
157
|
-
maxInvocationsPerMinute: 10,
|
|
158
|
-
timeoutMs: 30000,
|
|
159
|
-
version: "1.0.0",
|
|
160
|
-
tags: ["email", "communication"],
|
|
161
|
-
createdAt: new Date("2024-02-01T00:00:00Z"),
|
|
162
|
-
updatedAt: new Date("2024-02-01T00:00:00Z")
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: "tool-4",
|
|
166
|
-
organizationId: "demo-org",
|
|
167
|
-
name: "GitHub Integration",
|
|
168
|
-
slug: "github-integration",
|
|
169
|
-
description: "Interact with GitHub repositories, PRs, and issues.",
|
|
170
|
-
category: "INTEGRATION",
|
|
171
|
-
status: "ACTIVE",
|
|
172
|
-
parametersSchema: {
|
|
173
|
-
type: "object",
|
|
174
|
-
properties: {
|
|
175
|
-
action: {
|
|
176
|
-
type: "string",
|
|
177
|
-
enum: ["list_prs", "get_pr", "create_comment"]
|
|
178
|
-
},
|
|
179
|
-
repo: { type: "string" },
|
|
180
|
-
params: { type: "object" }
|
|
181
|
-
},
|
|
182
|
-
required: ["action", "repo"]
|
|
183
|
-
},
|
|
184
|
-
implementationType: "http",
|
|
185
|
-
implementationConfig: { url: "https://api.github.com", auth: "token" },
|
|
186
|
-
maxInvocationsPerMinute: 100,
|
|
187
|
-
timeoutMs: 15000,
|
|
188
|
-
version: "2.0.0",
|
|
189
|
-
tags: ["github", "integration", "code"],
|
|
190
|
-
createdAt: new Date("2024-02-20T00:00:00Z"),
|
|
191
|
-
updatedAt: new Date("2024-04-01T09:00:00Z")
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: "tool-5",
|
|
195
|
-
organizationId: "demo-org",
|
|
196
|
-
name: "Calculator",
|
|
197
|
-
slug: "calculator",
|
|
198
|
-
description: "Perform mathematical calculations.",
|
|
199
|
-
category: "COMPUTATION",
|
|
200
|
-
status: "ACTIVE",
|
|
201
|
-
parametersSchema: {
|
|
202
|
-
type: "object",
|
|
203
|
-
properties: {
|
|
204
|
-
expression: {
|
|
205
|
-
type: "string",
|
|
206
|
-
description: "Math expression to evaluate"
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
required: ["expression"]
|
|
210
|
-
},
|
|
211
|
-
outputSchema: {
|
|
212
|
-
type: "object",
|
|
213
|
-
properties: { result: { type: "number" } }
|
|
214
|
-
},
|
|
215
|
-
implementationType: "function",
|
|
216
|
-
implementationConfig: { handler: "evaluateMath" },
|
|
217
|
-
timeoutMs: 5000,
|
|
218
|
-
version: "1.0.0",
|
|
219
|
-
tags: ["math", "utility"],
|
|
220
|
-
createdAt: new Date("2024-01-10T00:00:00Z"),
|
|
221
|
-
updatedAt: new Date("2024-01-10T00:00:00Z")
|
|
222
|
-
}
|
|
223
|
-
];
|
|
224
|
-
|
|
225
|
-
// src/shared/mock-runs.ts
|
|
226
|
-
var MOCK_RUNS = [
|
|
227
|
-
{
|
|
228
|
-
id: "run-1",
|
|
229
|
-
organizationId: "demo-org",
|
|
230
|
-
projectId: "demo-project",
|
|
231
|
-
agentId: "agent-1",
|
|
232
|
-
agentName: "Customer Support Bot",
|
|
233
|
-
userId: "user-1",
|
|
234
|
-
sessionId: "session-1",
|
|
235
|
-
input: { message: "How do I reset my password?", context: {} },
|
|
236
|
-
output: { response: "You can reset your password by clicking..." },
|
|
237
|
-
status: "COMPLETED",
|
|
238
|
-
totalTokens: 1250,
|
|
239
|
-
promptTokens: 800,
|
|
240
|
-
completionTokens: 450,
|
|
241
|
-
totalIterations: 3,
|
|
242
|
-
durationMs: 4500,
|
|
243
|
-
estimatedCostUsd: 0.0025,
|
|
244
|
-
queuedAt: new Date("2024-04-15T10:00:00Z"),
|
|
245
|
-
startedAt: new Date("2024-04-15T10:00:01Z"),
|
|
246
|
-
completedAt: new Date("2024-04-15T10:00:05Z"),
|
|
247
|
-
steps: [],
|
|
248
|
-
logs: []
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
id: "run-2",
|
|
252
|
-
organizationId: "demo-org",
|
|
253
|
-
projectId: "demo-project",
|
|
254
|
-
agentId: "agent-2",
|
|
255
|
-
agentName: "Code Review Assistant",
|
|
256
|
-
userId: "user-2",
|
|
257
|
-
input: { message: "Review PR #123", context: { prNumber: 123 } },
|
|
258
|
-
status: "IN_PROGRESS",
|
|
259
|
-
totalTokens: 3500,
|
|
260
|
-
promptTokens: 3000,
|
|
261
|
-
completionTokens: 500,
|
|
262
|
-
totalIterations: 5,
|
|
263
|
-
queuedAt: new Date("2024-04-15T10:30:00Z"),
|
|
264
|
-
startedAt: new Date("2024-04-15T10:30:02Z"),
|
|
265
|
-
steps: [],
|
|
266
|
-
logs: []
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
id: "run-3",
|
|
270
|
-
organizationId: "demo-org",
|
|
271
|
-
projectId: "demo-project",
|
|
272
|
-
agentId: "agent-1",
|
|
273
|
-
agentName: "Customer Support Bot",
|
|
274
|
-
userId: "user-1",
|
|
275
|
-
input: { message: "What are your business hours?" },
|
|
276
|
-
output: { response: "Our business hours are 9 AM to 5 PM EST..." },
|
|
277
|
-
status: "COMPLETED",
|
|
278
|
-
totalTokens: 800,
|
|
279
|
-
promptTokens: 500,
|
|
280
|
-
completionTokens: 300,
|
|
281
|
-
totalIterations: 2,
|
|
282
|
-
durationMs: 2100,
|
|
283
|
-
estimatedCostUsd: 0.0012,
|
|
284
|
-
queuedAt: new Date("2024-04-15T09:00:00Z"),
|
|
285
|
-
startedAt: new Date("2024-04-15T09:00:01Z"),
|
|
286
|
-
completedAt: new Date("2024-04-15T09:00:03Z"),
|
|
287
|
-
steps: [],
|
|
288
|
-
logs: []
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
id: "run-4",
|
|
292
|
-
organizationId: "demo-org",
|
|
293
|
-
projectId: "demo-project",
|
|
294
|
-
agentId: "agent-3",
|
|
295
|
-
agentName: "Data Analyst",
|
|
296
|
-
userId: "user-3",
|
|
297
|
-
input: { message: "Generate sales report for Q1" },
|
|
298
|
-
status: "FAILED",
|
|
299
|
-
errorMessage: "Database connection timeout",
|
|
300
|
-
errorCode: "DB_TIMEOUT",
|
|
301
|
-
totalTokens: 2000,
|
|
302
|
-
promptTokens: 1500,
|
|
303
|
-
completionTokens: 500,
|
|
304
|
-
totalIterations: 8,
|
|
305
|
-
durationMs: 45000,
|
|
306
|
-
queuedAt: new Date("2024-04-14T15:00:00Z"),
|
|
307
|
-
startedAt: new Date("2024-04-14T15:00:05Z"),
|
|
308
|
-
completedAt: new Date("2024-04-14T15:00:50Z"),
|
|
309
|
-
steps: [],
|
|
310
|
-
logs: []
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: "run-5",
|
|
314
|
-
organizationId: "demo-org",
|
|
315
|
-
projectId: "demo-project",
|
|
316
|
-
agentId: "agent-2",
|
|
317
|
-
agentName: "Code Review Assistant",
|
|
318
|
-
userId: "user-2",
|
|
319
|
-
input: { message: "Review PR #120" },
|
|
320
|
-
output: { response: "Code review complete. 3 suggestions..." },
|
|
321
|
-
status: "COMPLETED",
|
|
322
|
-
totalTokens: 5200,
|
|
323
|
-
promptTokens: 4000,
|
|
324
|
-
completionTokens: 1200,
|
|
325
|
-
totalIterations: 7,
|
|
326
|
-
durationMs: 15000,
|
|
327
|
-
estimatedCostUsd: 0.0156,
|
|
328
|
-
queuedAt: new Date("2024-04-14T11:00:00Z"),
|
|
329
|
-
startedAt: new Date("2024-04-14T11:00:03Z"),
|
|
330
|
-
completedAt: new Date("2024-04-14T11:00:18Z"),
|
|
331
|
-
steps: [],
|
|
332
|
-
logs: []
|
|
333
|
-
}
|
|
334
|
-
];
|
|
335
|
-
|
|
336
|
-
// src/ui/hooks/useAgentMutations.ts
|
|
337
|
-
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
338
|
-
import { useCallback, useState } from "react";
|
|
339
|
-
|
|
340
|
-
// src/shared/demo-runtime-seed.ts
|
|
341
|
-
var AGENT_CONSOLE_DEMO_ORGANIZATION_ID = "demo-org";
|
|
342
|
-
var AGENT_CONSOLE_DEMO_PROJECT_ID = "agent-console-demo";
|
|
343
|
-
function slugify(name) {
|
|
344
|
-
return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
345
|
-
}
|
|
346
|
-
function cloneAgent(agent) {
|
|
347
|
-
return { ...agent };
|
|
348
|
-
}
|
|
349
|
-
function cloneTool(tool) {
|
|
350
|
-
return { ...tool };
|
|
351
|
-
}
|
|
352
|
-
function cloneRun(run) {
|
|
353
|
-
return { ...run };
|
|
354
|
-
}
|
|
355
|
-
function createDefaultNow() {
|
|
356
|
-
let tick = 0;
|
|
357
|
-
const base = Date.parse("2026-03-20T09:00:00.000Z");
|
|
358
|
-
return () => new Date(base + tick++ * 60000);
|
|
359
|
-
}
|
|
360
|
-
function normalizeProvider(provider) {
|
|
361
|
-
return provider.toLowerCase();
|
|
362
|
-
}
|
|
363
|
-
function normalizeRunStatus(status) {
|
|
364
|
-
return status === "IN_PROGRESS" ? "RUNNING" : status;
|
|
365
|
-
}
|
|
366
|
-
function createSeedState(projectId, organizationId) {
|
|
367
|
-
const agents = MOCK_AGENTS.map((agent) => ({
|
|
368
|
-
id: agent.id,
|
|
369
|
-
projectId,
|
|
370
|
-
organizationId,
|
|
371
|
-
name: agent.name,
|
|
372
|
-
slug: agent.slug,
|
|
373
|
-
description: agent.description,
|
|
374
|
-
modelProvider: normalizeProvider(agent.modelProvider),
|
|
375
|
-
modelName: agent.modelName,
|
|
376
|
-
systemPrompt: agent.systemPrompt,
|
|
377
|
-
temperature: typeof agent.modelConfig?.temperature === "number" ? agent.modelConfig.temperature : 0.4,
|
|
378
|
-
maxTokens: 8192,
|
|
379
|
-
status: agent.status,
|
|
380
|
-
createdAt: agent.createdAt,
|
|
381
|
-
updatedAt: agent.updatedAt
|
|
382
|
-
}));
|
|
383
|
-
const tools = MOCK_TOOLS.map((tool) => ({
|
|
384
|
-
id: tool.id,
|
|
385
|
-
projectId,
|
|
386
|
-
organizationId,
|
|
387
|
-
name: tool.name,
|
|
388
|
-
description: tool.description,
|
|
389
|
-
version: tool.version,
|
|
390
|
-
category: tool.category,
|
|
391
|
-
status: tool.status,
|
|
392
|
-
inputSchema: JSON.stringify(tool.parametersSchema),
|
|
393
|
-
outputSchema: tool.outputSchema ? JSON.stringify(tool.outputSchema) : undefined,
|
|
394
|
-
endpoint: typeof tool.implementationConfig?.url === "string" ? tool.implementationConfig.url : undefined,
|
|
395
|
-
createdAt: tool.createdAt,
|
|
396
|
-
updatedAt: tool.updatedAt
|
|
397
|
-
}));
|
|
398
|
-
const agentNames = new Map(agents.map((agent) => [agent.id, agent.name]));
|
|
399
|
-
const runs = MOCK_RUNS.map((run) => ({
|
|
400
|
-
id: run.id,
|
|
401
|
-
projectId,
|
|
402
|
-
agentId: run.agentId,
|
|
403
|
-
agentName: agentNames.get(run.agentId) ?? run.agentName ?? "Unknown agent",
|
|
404
|
-
status: normalizeRunStatus(run.status),
|
|
405
|
-
input: JSON.stringify(run.input),
|
|
406
|
-
output: run.output ? JSON.stringify(run.output) : undefined,
|
|
407
|
-
totalTokens: run.totalTokens,
|
|
408
|
-
promptTokens: run.promptTokens,
|
|
409
|
-
completionTokens: run.completionTokens,
|
|
410
|
-
estimatedCostUsd: run.estimatedCostUsd ?? 0,
|
|
411
|
-
durationMs: run.durationMs,
|
|
412
|
-
errorMessage: run.errorMessage,
|
|
413
|
-
queuedAt: run.queuedAt,
|
|
414
|
-
startedAt: run.startedAt,
|
|
415
|
-
completedAt: run.completedAt
|
|
416
|
-
}));
|
|
417
|
-
return { agents, tools, runs };
|
|
418
|
-
}
|
|
419
|
-
function summarizeRunMetrics(runs) {
|
|
420
|
-
const totalRuns = runs.length;
|
|
421
|
-
const completedRuns = runs.filter((run) => run.status === "COMPLETED").length;
|
|
422
|
-
const completedDurations = runs.map((run) => run.durationMs).filter((duration) => typeof duration === "number");
|
|
423
|
-
return {
|
|
424
|
-
totalRuns,
|
|
425
|
-
successRate: totalRuns === 0 ? 0 : completedRuns / totalRuns,
|
|
426
|
-
averageDurationMs: completedDurations.length === 0 ? 0 : Math.round(completedDurations.reduce((sum, duration) => sum + duration, 0) / completedDurations.length),
|
|
427
|
-
totalTokens: runs.reduce((sum, run) => sum + run.totalTokens, 0),
|
|
428
|
-
totalCostUsd: runs.reduce((sum, run) => sum + run.estimatedCostUsd, 0)
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// src/ui/hooks/useAgentMutations.ts
|
|
433
|
-
function normalizeMutationError(error, fallbackMessage) {
|
|
434
|
-
return error instanceof Error ? error : new Error(fallbackMessage);
|
|
435
|
-
}
|
|
436
|
-
function useAgentMutations(options = {}) {
|
|
437
|
-
const { handlers, projectId } = useTemplateRuntime();
|
|
438
|
-
const { agent } = handlers;
|
|
439
|
-
const [createState, setCreateState] = useState({
|
|
440
|
-
loading: false,
|
|
441
|
-
error: null,
|
|
442
|
-
data: null
|
|
443
|
-
});
|
|
444
|
-
const [updateState, setUpdateState] = useState({
|
|
445
|
-
loading: false,
|
|
446
|
-
error: null,
|
|
447
|
-
data: null
|
|
448
|
-
});
|
|
449
|
-
const [executeState, setExecuteState] = useState({
|
|
450
|
-
loading: false,
|
|
451
|
-
error: null,
|
|
452
|
-
data: null
|
|
453
|
-
});
|
|
454
|
-
const createAgent = useCallback(async (input) => {
|
|
455
|
-
setCreateState({ loading: true, error: null, data: null });
|
|
456
|
-
try {
|
|
457
|
-
const result = await agent.createAgent(input, {
|
|
458
|
-
projectId,
|
|
459
|
-
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
|
|
460
|
-
});
|
|
461
|
-
setCreateState({ loading: false, error: null, data: result });
|
|
462
|
-
options.onSuccess?.();
|
|
463
|
-
return result;
|
|
464
|
-
} catch (err) {
|
|
465
|
-
const error = normalizeMutationError(err, "Failed to create agent");
|
|
466
|
-
setCreateState({ loading: false, error, data: null });
|
|
467
|
-
options.onError?.(error);
|
|
468
|
-
throw error;
|
|
469
|
-
}
|
|
470
|
-
}, [agent, projectId, options]);
|
|
471
|
-
const updateAgent = useCallback(async (input) => {
|
|
472
|
-
setUpdateState({ loading: true, error: null, data: null });
|
|
473
|
-
try {
|
|
474
|
-
const result = await agent.updateAgent(input);
|
|
475
|
-
setUpdateState({ loading: false, error: null, data: result });
|
|
476
|
-
options.onSuccess?.();
|
|
477
|
-
return result;
|
|
478
|
-
} catch (err) {
|
|
479
|
-
const error = normalizeMutationError(err, "Failed to update agent");
|
|
480
|
-
setUpdateState({ loading: false, error, data: null });
|
|
481
|
-
options.onError?.(error);
|
|
482
|
-
throw error;
|
|
483
|
-
}
|
|
484
|
-
}, [agent, options]);
|
|
485
|
-
const activateAgent = useCallback(async (agentId) => {
|
|
486
|
-
return updateAgent({ id: agentId, status: "ACTIVE" });
|
|
487
|
-
}, [updateAgent]);
|
|
488
|
-
const pauseAgent = useCallback(async (agentId) => {
|
|
489
|
-
return updateAgent({ id: agentId, status: "PAUSED" });
|
|
490
|
-
}, [updateAgent]);
|
|
491
|
-
const archiveAgent = useCallback(async (agentId) => {
|
|
492
|
-
return updateAgent({ id: agentId, status: "ARCHIVED" });
|
|
493
|
-
}, [updateAgent]);
|
|
494
|
-
const executeAgent = useCallback(async (input) => {
|
|
495
|
-
setExecuteState({ loading: true, error: null, data: null });
|
|
496
|
-
try {
|
|
497
|
-
const result = await agent.executeAgent({
|
|
498
|
-
agentId: input.agentId,
|
|
499
|
-
message: input.message,
|
|
500
|
-
context: {
|
|
501
|
-
projectId,
|
|
502
|
-
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
setExecuteState({ loading: false, error: null, data: result });
|
|
506
|
-
options.onSuccess?.();
|
|
507
|
-
return result;
|
|
508
|
-
} catch (err) {
|
|
509
|
-
const error = normalizeMutationError(err, "Failed to execute agent");
|
|
510
|
-
setExecuteState({ loading: false, error, data: null });
|
|
511
|
-
options.onError?.(error);
|
|
512
|
-
throw error;
|
|
513
|
-
}
|
|
514
|
-
}, [agent, projectId, options]);
|
|
515
|
-
return {
|
|
516
|
-
createAgent,
|
|
517
|
-
updateAgent,
|
|
518
|
-
activateAgent,
|
|
519
|
-
pauseAgent,
|
|
520
|
-
archiveAgent,
|
|
521
|
-
executeAgent,
|
|
522
|
-
createState,
|
|
523
|
-
updateState,
|
|
524
|
-
executeState,
|
|
525
|
-
isLoading: createState.loading || updateState.loading || executeState.loading
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
export {
|
|
529
|
-
useAgentMutations
|
|
530
|
-
};
|
|
1
|
+
var h=[{id:"agent-1",organizationId:"demo-org",name:"Customer Support Bot",slug:"customer-support-bot",description:"Handles tier-1 customer inquiries and routes complex issues.",status:"ACTIVE",modelProvider:"OPENAI",modelName:"gpt-4o-mini",modelConfig:{temperature:0.7},systemPrompt:"You are a helpful customer support assistant.",toolChoice:"auto",maxIterations:10,timeoutMs:120000,version:"1.0.0",tags:["support","tier-1"],createdAt:new Date("2024-01-15T10:00:00Z"),updatedAt:new Date("2024-03-20T14:30:00Z")},{id:"agent-2",organizationId:"demo-org",name:"Code Review Assistant",slug:"code-review-assistant",description:"Reviews pull requests and provides actionable feedback.",status:"ACTIVE",modelProvider:"ANTHROPIC",modelName:"claude-sonnet-4-20250514",modelConfig:{temperature:0.3},systemPrompt:"You are a code review expert.",toolChoice:"auto",maxIterations:15,timeoutMs:180000,version:"2.1.0",tags:["code","review","dev"],createdAt:new Date("2024-02-10T09:00:00Z"),updatedAt:new Date("2024-04-05T11:15:00Z")},{id:"agent-3",organizationId:"demo-org",name:"Data Analyst",slug:"data-analyst",description:"Queries databases and generates insights from data.",status:"PAUSED",modelProvider:"OPENAI",modelName:"gpt-4o",modelConfig:{temperature:0.5},systemPrompt:"You are a data analyst expert in SQL and analytics.",toolChoice:"required",maxIterations:20,timeoutMs:300000,version:"1.2.0",tags:["data","analytics","sql"],createdAt:new Date("2024-03-01T08:00:00Z"),updatedAt:new Date("2024-04-10T16:45:00Z")},{id:"agent-4",organizationId:"demo-org",name:"Meeting Scheduler",slug:"meeting-scheduler",description:"Schedules meetings and manages calendar conflicts.",status:"DRAFT",modelProvider:"GOOGLE",modelName:"gemini-2.0-flash",modelConfig:{temperature:0.2},systemPrompt:"You help schedule and organize meetings efficiently.",toolChoice:"auto",maxIterations:5,timeoutMs:60000,version:"0.1.0",tags:["calendar","scheduling"],createdAt:new Date("2024-04-01T12:00:00Z"),updatedAt:new Date("2024-04-01T12:00:00Z")}];var I=[{id:"tool-1",organizationId:"demo-org",name:"Web Search",slug:"web-search",description:"Search the web for real-time information using Brave API.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},numResults:{type:"number",default:10}},required:["query"]},outputSchema:{type:"array",items:{type:"object"}},implementationType:"http",implementationConfig:{url:"https://api.brave.com/search",method:"GET"},maxInvocationsPerMinute:60,timeoutMs:30000,version:"1.0.0",tags:["search","web"],createdAt:new Date("2024-01-01T00:00:00Z"),updatedAt:new Date("2024-02-15T10:00:00Z")},{id:"tool-2",organizationId:"demo-org",name:"SQL Query",slug:"sql-query",description:"Execute read-only SQL queries against the data warehouse.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"SQL query"},maxRows:{type:"number",default:100}},required:["query"]},outputSchema:{type:"object"},implementationType:"function",implementationConfig:{handler:"executeSqlQuery"},maxInvocationsPerMinute:30,timeoutMs:60000,version:"1.1.0",tags:["sql","database"],createdAt:new Date("2024-01-05T00:00:00Z"),updatedAt:new Date("2024-03-10T14:00:00Z")},{id:"tool-3",organizationId:"demo-org",name:"Email Sender",slug:"email-sender",description:"Send emails via SMTP or API.",category:"COMMUNICATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{to:{type:"string"},subject:{type:"string"},body:{type:"string"}},required:["to","subject","body"]},implementationType:"http",implementationConfig:{url:"/api/send-email",method:"POST"},maxInvocationsPerMinute:10,timeoutMs:30000,version:"1.0.0",tags:["email","communication"],createdAt:new Date("2024-02-01T00:00:00Z"),updatedAt:new Date("2024-02-01T00:00:00Z")},{id:"tool-4",organizationId:"demo-org",name:"GitHub Integration",slug:"github-integration",description:"Interact with GitHub repositories, PRs, and issues.",category:"INTEGRATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{action:{type:"string",enum:["list_prs","get_pr","create_comment"]},repo:{type:"string"},params:{type:"object"}},required:["action","repo"]},implementationType:"http",implementationConfig:{url:"https://api.github.com",auth:"token"},maxInvocationsPerMinute:100,timeoutMs:15000,version:"2.0.0",tags:["github","integration","code"],createdAt:new Date("2024-02-20T00:00:00Z"),updatedAt:new Date("2024-04-01T09:00:00Z")},{id:"tool-5",organizationId:"demo-org",name:"Calculator",slug:"calculator",description:"Perform mathematical calculations.",category:"COMPUTATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{expression:{type:"string",description:"Math expression to evaluate"}},required:["expression"]},outputSchema:{type:"object",properties:{result:{type:"number"}}},implementationType:"function",implementationConfig:{handler:"evaluateMath"},timeoutMs:5000,version:"1.0.0",tags:["math","utility"],createdAt:new Date("2024-01-10T00:00:00Z"),updatedAt:new Date("2024-01-10T00:00:00Z")}];var w=[{id:"run-1",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-1",agentName:"Customer Support Bot",userId:"user-1",sessionId:"session-1",input:{message:"How do I reset my password?",context:{}},output:{response:"You can reset your password by clicking..."},status:"COMPLETED",totalTokens:1250,promptTokens:800,completionTokens:450,totalIterations:3,durationMs:4500,estimatedCostUsd:0.0025,queuedAt:new Date("2024-04-15T10:00:00Z"),startedAt:new Date("2024-04-15T10:00:01Z"),completedAt:new Date("2024-04-15T10:00:05Z"),steps:[],logs:[]},{id:"run-2",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-2",agentName:"Code Review Assistant",userId:"user-2",input:{message:"Review PR #123",context:{prNumber:123}},status:"IN_PROGRESS",totalTokens:3500,promptTokens:3000,completionTokens:500,totalIterations:5,queuedAt:new Date("2024-04-15T10:30:00Z"),startedAt:new Date("2024-04-15T10:30:02Z"),steps:[],logs:[]},{id:"run-3",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-1",agentName:"Customer Support Bot",userId:"user-1",input:{message:"What are your business hours?"},output:{response:"Our business hours are 9 AM to 5 PM EST..."},status:"COMPLETED",totalTokens:800,promptTokens:500,completionTokens:300,totalIterations:2,durationMs:2100,estimatedCostUsd:0.0012,queuedAt:new Date("2024-04-15T09:00:00Z"),startedAt:new Date("2024-04-15T09:00:01Z"),completedAt:new Date("2024-04-15T09:00:03Z"),steps:[],logs:[]},{id:"run-4",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-3",agentName:"Data Analyst",userId:"user-3",input:{message:"Generate sales report for Q1"},status:"FAILED",errorMessage:"Database connection timeout",errorCode:"DB_TIMEOUT",totalTokens:2000,promptTokens:1500,completionTokens:500,totalIterations:8,durationMs:45000,queuedAt:new Date("2024-04-14T15:00:00Z"),startedAt:new Date("2024-04-14T15:00:05Z"),completedAt:new Date("2024-04-14T15:00:50Z"),steps:[],logs:[]},{id:"run-5",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-2",agentName:"Code Review Assistant",userId:"user-2",input:{message:"Review PR #120"},output:{response:"Code review complete. 3 suggestions..."},status:"COMPLETED",totalTokens:5200,promptTokens:4000,completionTokens:1200,totalIterations:7,durationMs:15000,estimatedCostUsd:0.0156,queuedAt:new Date("2024-04-14T11:00:00Z"),startedAt:new Date("2024-04-14T11:00:03Z"),completedAt:new Date("2024-04-14T11:00:18Z"),steps:[],logs:[]}];import{useTemplateRuntime as P}from"@contractspec/lib.example-shared-ui";import{useCallback as c,useState as T}from"react";var g="demo-org",q="agent-console-demo";function x(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function z(t){return{...t}}function L(t){return{...t}}function j(t){return{...t}}function _(){let t=0,a=Date.parse("2026-03-20T09:00:00.000Z");return()=>new Date(a+t++*60000)}function b(t){return t.toLowerCase()}function v(t){return t==="IN_PROGRESS"?"RUNNING":t}function U(t,a){let m=h.map((e)=>({id:e.id,projectId:t,organizationId:a,name:e.name,slug:e.slug,description:e.description,modelProvider:b(e.modelProvider),modelName:e.modelName,systemPrompt:e.systemPrompt,temperature:typeof e.modelConfig?.temperature==="number"?e.modelConfig.temperature:0.4,maxTokens:8192,status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt})),n=I.map((e)=>({id:e.id,projectId:t,organizationId:a,name:e.name,description:e.description,version:e.version,category:e.category,status:e.status,inputSchema:JSON.stringify(e.parametersSchema),outputSchema:e.outputSchema?JSON.stringify(e.outputSchema):void 0,endpoint:typeof e.implementationConfig?.url==="string"?e.implementationConfig.url:void 0,createdAt:e.createdAt,updatedAt:e.updatedAt})),o=new Map(m.map((e)=>[e.id,e.name])),i=w.map((e)=>({id:e.id,projectId:t,agentId:e.agentId,agentName:o.get(e.agentId)??e.agentName??"Unknown agent",status:v(e.status),input:JSON.stringify(e.input),output:e.output?JSON.stringify(e.output):void 0,totalTokens:e.totalTokens,promptTokens:e.promptTokens,completionTokens:e.completionTokens,estimatedCostUsd:e.estimatedCostUsd??0,durationMs:e.durationMs,errorMessage:e.errorMessage,queuedAt:e.queuedAt,startedAt:e.startedAt,completedAt:e.completedAt}));return{agents:m,tools:n,runs:i}}function G(t){let a=t.length,m=t.filter((o)=>o.status==="COMPLETED").length,n=t.map((o)=>o.durationMs).filter((o)=>typeof o==="number");return{totalRuns:a,successRate:a===0?0:m/a,averageDurationMs:n.length===0?0:Math.round(n.reduce((o,i)=>o+i,0)/n.length),totalTokens:t.reduce((o,i)=>o+i.totalTokens,0),totalCostUsd:t.reduce((o,i)=>o+i.estimatedCostUsd,0)}}function y(t,a){return t instanceof Error?t:Error(a)}function H(t={}){let{handlers:a,projectId:m}=P(),{agent:n}=a,[o,i]=T({loading:!1,error:null,data:null}),[e,p]=T({loading:!1,error:null,data:null}),[A,l]=T({loading:!1,error:null,data:null}),f=c(async(r)=>{i({loading:!0,error:null,data:null});try{let s=await n.createAgent(r,{projectId:m,organizationId:g});return i({loading:!1,error:null,data:s}),t.onSuccess?.(),s}catch(s){let d=y(s,"Failed to create agent");throw i({loading:!1,error:d,data:null}),t.onError?.(d),d}},[n,m,t]),u=c(async(r)=>{p({loading:!0,error:null,data:null});try{let s=await n.updateAgent(r);return p({loading:!1,error:null,data:s}),t.onSuccess?.(),s}catch(s){let d=y(s,"Failed to update agent");throw p({loading:!1,error:d,data:null}),t.onError?.(d),d}},[n,t]),C=c(async(r)=>{return u({id:r,status:"ACTIVE"})},[u]),D=c(async(r)=>{return u({id:r,status:"PAUSED"})},[u]),M=c(async(r)=>{return u({id:r,status:"ARCHIVED"})},[u]),R=c(async(r)=>{l({loading:!0,error:null,data:null});try{let s=await n.executeAgent({agentId:r.agentId,message:r.message,context:{projectId:m,organizationId:g}});return l({loading:!1,error:null,data:s}),t.onSuccess?.(),s}catch(s){let d=y(s,"Failed to execute agent");throw l({loading:!1,error:d,data:null}),t.onError?.(d),d}},[n,m,t]);return{createAgent:f,updateAgent:u,activateAgent:C,pauseAgent:D,archiveAgent:M,executeAgent:R,createState:o,updateState:e,executeState:A,isLoading:o.loading||e.loading||A.loading}}export{H as useAgentMutations};
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
-
import { useCallback, useEffect, useState } from "react";
|
|
4
|
-
function useRunList(options = {}) {
|
|
5
|
-
const { handlers, projectId } = useTemplateRuntime();
|
|
6
|
-
const { agent } = handlers;
|
|
7
|
-
const [data, setData] = useState(null);
|
|
8
|
-
const [metrics, setMetrics] = useState(null);
|
|
9
|
-
const [loading, setLoading] = useState(true);
|
|
10
|
-
const [error, setError] = useState(null);
|
|
11
|
-
const [internalPageIndex, setInternalPageIndex] = useState(0);
|
|
12
|
-
const pageSize = options.pageSize ?? options.limit ?? 20;
|
|
13
|
-
const pageIndex = options.pageIndex ?? internalPageIndex;
|
|
14
|
-
const [sort] = options.sorting ?? [];
|
|
15
|
-
const fetchData = useCallback(async () => {
|
|
16
|
-
setLoading(true);
|
|
17
|
-
setError(null);
|
|
18
|
-
try {
|
|
19
|
-
const [runsResult, metricsResult] = await Promise.all([
|
|
20
|
-
agent.listRuns({
|
|
21
|
-
projectId,
|
|
22
|
-
agentId: options.agentId,
|
|
23
|
-
status: options.status === "all" ? undefined : options.status,
|
|
24
|
-
sortBy: sort?.id,
|
|
25
|
-
sortDirection: sort ? sort.desc ? "desc" : "asc" : undefined,
|
|
26
|
-
limit: pageSize,
|
|
27
|
-
offset: pageIndex * pageSize
|
|
28
|
-
}),
|
|
29
|
-
agent.getRunMetrics({
|
|
30
|
-
projectId,
|
|
31
|
-
agentId: options.agentId
|
|
32
|
-
})
|
|
33
|
-
]);
|
|
34
|
-
setData(runsResult);
|
|
35
|
-
setMetrics(metricsResult);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
38
|
-
} finally {
|
|
39
|
-
setLoading(false);
|
|
40
|
-
}
|
|
41
|
-
}, [
|
|
42
|
-
agent,
|
|
43
|
-
pageIndex,
|
|
44
|
-
pageSize,
|
|
45
|
-
projectId,
|
|
46
|
-
options.agentId,
|
|
47
|
-
options.status,
|
|
48
|
-
sort?.desc,
|
|
49
|
-
sort?.id
|
|
50
|
-
]);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
fetchData();
|
|
53
|
-
}, [fetchData]);
|
|
54
|
-
const hasControlledPagination = options.pageIndex !== undefined;
|
|
55
|
-
return {
|
|
56
|
-
data,
|
|
57
|
-
metrics,
|
|
58
|
-
loading,
|
|
59
|
-
error,
|
|
60
|
-
page: pageIndex + 1,
|
|
61
|
-
pageIndex,
|
|
62
|
-
pageSize,
|
|
63
|
-
refetch: fetchData,
|
|
64
|
-
nextPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => current + 1),
|
|
65
|
-
prevPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => Math.max(0, current - 1))
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
useRunList
|
|
70
|
-
};
|
|
1
|
+
import{useTemplateRuntime as k}from"@contractspec/lib.example-shared-ui";import{useCallback as M,useEffect as T,useState as y}from"react";function j(q={}){let{handlers:Q,projectId:F}=k(),{agent:G}=Q,[U,V]=y(null),[W,X]=y(null),[Y,J]=y(!0),[Z,K]=y(null),[_,N]=y(0),A=q.pageSize??q.limit??20,B=q.pageIndex??_,[w]=q.sorting??[],H=M(async()=>{J(!0),K(null);try{let[v,$]=await Promise.all([G.listRuns({projectId:F,agentId:q.agentId,status:q.status==="all"?void 0:q.status,sortBy:w?.id,sortDirection:w?w.desc?"desc":"asc":void 0,limit:A,offset:B*A}),G.getRunMetrics({projectId:F,agentId:q.agentId})]);V(v),X($)}catch(v){K(v instanceof Error?v:Error("Unknown error"))}finally{J(!1)}},[G,B,A,F,q.agentId,q.status,w?.desc,w?.id]);T(()=>{H()},[H]);let O=q.pageIndex!==void 0;return{data:U,metrics:W,loading:Y,error:Z,page:B+1,pageIndex:B,pageSize:A,refetch:H,nextPage:O?void 0:()=>N((v)=>v+1),prevPage:O?void 0:()=>N((v)=>Math.max(0,v-1))}}export{j as useRunList};
|