@contractspec/example.agent-console 3.7.7 → 3.8.4
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 +126 -105
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +57 -0
- package/README.md +46 -9
- package/dist/agent/agent.handler.d.ts +3 -0
- package/dist/agent/agent.handler.js +730 -1
- package/dist/agent/index.js +73 -72
- package/dist/agent.feature.js +179 -0
- package/dist/browser/agent/agent.handler.js +730 -1
- package/dist/browser/agent/index.js +73 -72
- package/dist/browser/agent.feature.js +179 -0
- package/dist/browser/docs/agent-console.docblock.js +11 -8
- package/dist/browser/docs/index.js +11 -8
- package/dist/browser/example.js +2 -3
- package/dist/browser/handlers/agent.handlers.js +1883 -2
- package/dist/browser/handlers/index.js +2142 -8
- package/dist/browser/index.js +3347 -2433
- package/dist/browser/presentations/index.js +49 -49
- package/dist/browser/run/index.js +818 -812
- package/dist/browser/run/run.handler.js +666 -1
- package/dist/browser/shared/index.js +293 -1
- package/dist/browser/shared/mock-runs.js +5 -0
- package/dist/browser/tool/index.js +331 -331
- package/dist/browser/tool/tool.handler.js +479 -3
- package/dist/browser/ui/AgentDashboard.js +1204 -319
- package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/browser/ui/AgentRunList.js +359 -127
- package/dist/browser/ui/hooks/index.js +468 -18
- package/dist/browser/ui/hooks/useAgentMutations.js +443 -8
- package/dist/browser/ui/hooks/useRunList.js +25 -10
- package/dist/browser/ui/index.js +1293 -390
- package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/browser/ui/renderers/index.js +245 -49
- package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
- package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/browser/ui/views/RunDataTable.js +326 -0
- package/dist/browser/ui/views/RunListView.js +359 -127
- package/dist/browser/ui/views/index.js +406 -174
- package/dist/browser/ui/views/run-data-table.columns.js +271 -0
- package/dist/browser/ui/views/run-list.shared.js +177 -0
- package/dist/browser/visualizations/catalog.js +134 -0
- package/dist/browser/visualizations/index.js +187 -0
- package/dist/browser/visualizations/selectors.js +181 -0
- package/dist/docs/agent-console.docblock.js +11 -8
- package/dist/docs/index.js +11 -8
- package/dist/example.js +2 -3
- package/dist/example.test.d.ts +1 -0
- package/dist/handlers/agent.handlers.d.ts +2 -0
- package/dist/handlers/agent.handlers.js +1883 -2
- package/dist/handlers/index.d.ts +1 -3
- package/dist/handlers/index.js +2142 -8
- package/dist/handlers/mock-handlers.test.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3347 -2433
- package/dist/node/agent/agent.handler.js +730 -1
- package/dist/node/agent/index.js +73 -72
- package/dist/node/agent.feature.js +179 -0
- package/dist/node/docs/agent-console.docblock.js +11 -8
- package/dist/node/docs/index.js +11 -8
- package/dist/node/example.js +2 -3
- package/dist/node/handlers/agent.handlers.js +1883 -2
- package/dist/node/handlers/index.js +2142 -8
- package/dist/node/index.js +3347 -2433
- package/dist/node/presentations/index.js +49 -49
- package/dist/node/run/index.js +818 -812
- package/dist/node/run/run.handler.js +666 -1
- package/dist/node/shared/index.js +293 -1
- package/dist/node/shared/mock-runs.js +5 -0
- package/dist/node/tool/index.js +331 -331
- package/dist/node/tool/tool.handler.js +479 -3
- package/dist/node/ui/AgentDashboard.js +1204 -319
- package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/node/ui/AgentRunList.js +359 -127
- package/dist/node/ui/hooks/index.js +468 -18
- package/dist/node/ui/hooks/useAgentMutations.js +443 -8
- package/dist/node/ui/hooks/useRunList.js +25 -10
- package/dist/node/ui/index.js +1293 -390
- package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/node/ui/renderers/index.js +245 -49
- package/dist/node/ui/renderers/run-list.markdown.js +9 -4
- package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/node/ui/views/RunDataTable.js +326 -0
- package/dist/node/ui/views/RunListView.js +359 -127
- package/dist/node/ui/views/index.js +406 -174
- package/dist/node/ui/views/run-data-table.columns.js +271 -0
- package/dist/node/ui/views/run-list.shared.js +177 -0
- package/dist/node/visualizations/catalog.js +134 -0
- package/dist/node/visualizations/index.js +187 -0
- package/dist/node/visualizations/selectors.js +181 -0
- package/dist/presentations/index.js +49 -49
- package/dist/proof/index.d.ts +2 -0
- package/dist/proof/meetup-proof.d.ts +10 -0
- package/dist/proof/meetup-proof.runtime.d.ts +22 -0
- package/dist/proof/meetup-proof.scenario.d.ts +2 -0
- package/dist/proof/meetup-proof.suite.d.ts +1 -0
- package/dist/proof/meetup-proof.test.d.ts +1 -0
- package/dist/run/index.js +818 -812
- package/dist/run/run.handler.d.ts +4 -0
- package/dist/run/run.handler.js +666 -1
- package/dist/shared/demo-dashboard-data.d.ts +16 -0
- package/dist/shared/demo-runtime-seed.d.ts +17 -0
- package/dist/shared/demo-runtime.d.ts +8 -0
- package/dist/shared/demo-runtime.test.d.ts +1 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.js +293 -1
- package/dist/shared/mock-runs.d.ts +4 -0
- package/dist/shared/mock-runs.js +5 -0
- package/dist/tool/index.js +331 -331
- package/dist/tool/tool.handler.d.ts +4 -1
- package/dist/tool/tool.handler.js +479 -3
- package/dist/ui/AgentDashboard.js +1204 -319
- package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
- package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
- package/dist/ui/AgentDashboard.visualizations.js +218 -0
- package/dist/ui/AgentRunList.js +359 -127
- package/dist/ui/hooks/index.js +468 -18
- package/dist/ui/hooks/useAgentMutations.js +443 -8
- package/dist/ui/hooks/useRunList.d.ts +8 -2
- package/dist/ui/hooks/useRunList.js +25 -10
- package/dist/ui/index.js +1293 -390
- package/dist/ui/renderers/agent-list.markdown.d.ts +1 -1
- package/dist/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/ui/renderers/agent-list.renderer.d.ts +1 -1
- package/dist/ui/renderers/dashboard.markdown.d.ts +1 -1
- package/dist/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/ui/renderers/index.js +245 -49
- package/dist/ui/renderers/run-list.markdown.d.ts +1 -1
- package/dist/ui/renderers/run-list.markdown.js +9 -4
- package/dist/ui/renderers/tool-registry.markdown.d.ts +2 -2
- package/dist/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/ui/views/RunDataTable.d.ts +18 -0
- package/dist/ui/views/RunDataTable.js +327 -0
- package/dist/ui/views/RunListView.js +359 -127
- package/dist/ui/views/index.js +406 -174
- package/dist/ui/views/run-data-table.columns.d.ts +3 -0
- package/dist/ui/views/run-data-table.columns.js +272 -0
- package/dist/ui/views/run-list.shared.d.ts +14 -0
- package/dist/ui/views/run-list.shared.js +178 -0
- package/dist/visualizations/catalog.d.ts +10 -0
- package/dist/visualizations/catalog.js +135 -0
- package/dist/visualizations/index.d.ts +2 -0
- package/dist/visualizations/index.js +188 -0
- package/dist/visualizations/selectors.d.ts +3 -0
- package/dist/visualizations/selectors.js +182 -0
- package/dist/visualizations/selectors.test.d.ts +1 -0
- package/package.json +114 -11
- package/proofs/agent-console-meetup.replay.json +220 -0
- package/src/agent/agent.handler.ts +18 -1
- package/src/agent.feature.ts +3 -0
- package/src/docs/agent-console.docblock.ts +11 -8
- package/src/example.test.ts +75 -0
- package/src/example.ts +2 -3
- package/src/handlers/agent.handlers.ts +55 -2
- package/src/handlers/index.ts +18 -2
- package/src/handlers/mock-handlers.test.ts +77 -0
- package/src/index.ts +2 -0
- package/src/proof/index.ts +2 -0
- package/src/proof/meetup-proof.runtime.ts +196 -0
- package/src/proof/meetup-proof.scenario.ts +99 -0
- package/src/proof/meetup-proof.suite.ts +29 -0
- package/src/proof/meetup-proof.test.ts +28 -0
- package/src/proof/meetup-proof.ts +130 -0
- package/src/run/run.handler.ts +17 -1
- package/src/shared/demo-dashboard-data.ts +58 -0
- package/src/shared/demo-runtime-seed.ts +139 -0
- package/src/shared/demo-runtime.test.ts +169 -0
- package/src/shared/demo-runtime.ts +260 -0
- package/src/shared/index.ts +11 -0
- package/src/shared/mock-runs.ts +5 -0
- package/src/tool/tool.handler.ts +21 -4
- package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
- package/src/ui/AgentDashboard.tsx +4 -1
- package/src/ui/AgentDashboard.visualizations.tsx +35 -0
- package/src/ui/hooks/useAgentMutations.ts +19 -11
- package/src/ui/hooks/useRunList.ts +41 -9
- package/src/ui/renderers/agent-list.markdown.ts +32 -13
- package/src/ui/renderers/agent-list.renderer.tsx +1 -1
- package/src/ui/renderers/dashboard.markdown.ts +38 -43
- package/src/ui/renderers/run-list.markdown.ts +17 -9
- package/src/ui/renderers/tool-registry.markdown.ts +22 -10
- package/src/ui/views/RunDataTable.tsx +74 -0
- package/src/ui/views/RunListView.tsx +37 -111
- package/src/ui/views/run-data-table.columns.tsx +102 -0
- package/src/ui/views/run-list.shared.tsx +139 -0
- package/src/visualizations/catalog.ts +132 -0
- package/src/visualizations/index.ts +2 -0
- package/src/visualizations/selectors.test.ts +12 -0
- package/src/visualizations/selectors.ts +70 -0
- package/tsdown.config.js +17 -0
package/dist/ui/hooks/index.js
CHANGED
|
@@ -1,4 +1,339 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/shared/mock-agents.ts
|
|
3
|
+
var MOCK_AGENTS = [
|
|
4
|
+
{
|
|
5
|
+
id: "agent-1",
|
|
6
|
+
organizationId: "demo-org",
|
|
7
|
+
name: "Customer Support Bot",
|
|
8
|
+
slug: "customer-support-bot",
|
|
9
|
+
description: "Handles tier-1 customer inquiries and routes complex issues.",
|
|
10
|
+
status: "ACTIVE",
|
|
11
|
+
modelProvider: "OPENAI",
|
|
12
|
+
modelName: "gpt-4o-mini",
|
|
13
|
+
modelConfig: { temperature: 0.7 },
|
|
14
|
+
systemPrompt: "You are a helpful customer support assistant.",
|
|
15
|
+
toolChoice: "auto",
|
|
16
|
+
maxIterations: 10,
|
|
17
|
+
timeoutMs: 120000,
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
tags: ["support", "tier-1"],
|
|
20
|
+
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
21
|
+
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "agent-2",
|
|
25
|
+
organizationId: "demo-org",
|
|
26
|
+
name: "Code Review Assistant",
|
|
27
|
+
slug: "code-review-assistant",
|
|
28
|
+
description: "Reviews pull requests and provides actionable feedback.",
|
|
29
|
+
status: "ACTIVE",
|
|
30
|
+
modelProvider: "ANTHROPIC",
|
|
31
|
+
modelName: "claude-sonnet-4-20250514",
|
|
32
|
+
modelConfig: { temperature: 0.3 },
|
|
33
|
+
systemPrompt: "You are a code review expert.",
|
|
34
|
+
toolChoice: "auto",
|
|
35
|
+
maxIterations: 15,
|
|
36
|
+
timeoutMs: 180000,
|
|
37
|
+
version: "2.1.0",
|
|
38
|
+
tags: ["code", "review", "dev"],
|
|
39
|
+
createdAt: new Date("2024-02-10T09:00:00Z"),
|
|
40
|
+
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "agent-3",
|
|
44
|
+
organizationId: "demo-org",
|
|
45
|
+
name: "Data Analyst",
|
|
46
|
+
slug: "data-analyst",
|
|
47
|
+
description: "Queries databases and generates insights from data.",
|
|
48
|
+
status: "PAUSED",
|
|
49
|
+
modelProvider: "OPENAI",
|
|
50
|
+
modelName: "gpt-4o",
|
|
51
|
+
modelConfig: { temperature: 0.5 },
|
|
52
|
+
systemPrompt: "You are a data analyst expert in SQL and analytics.",
|
|
53
|
+
toolChoice: "required",
|
|
54
|
+
maxIterations: 20,
|
|
55
|
+
timeoutMs: 300000,
|
|
56
|
+
version: "1.2.0",
|
|
57
|
+
tags: ["data", "analytics", "sql"],
|
|
58
|
+
createdAt: new Date("2024-03-01T08:00:00Z"),
|
|
59
|
+
updatedAt: new Date("2024-04-10T16:45:00Z")
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "agent-4",
|
|
63
|
+
organizationId: "demo-org",
|
|
64
|
+
name: "Meeting Scheduler",
|
|
65
|
+
slug: "meeting-scheduler",
|
|
66
|
+
description: "Schedules meetings and manages calendar conflicts.",
|
|
67
|
+
status: "DRAFT",
|
|
68
|
+
modelProvider: "GOOGLE",
|
|
69
|
+
modelName: "gemini-2.0-flash",
|
|
70
|
+
modelConfig: { temperature: 0.2 },
|
|
71
|
+
systemPrompt: "You help schedule and organize meetings efficiently.",
|
|
72
|
+
toolChoice: "auto",
|
|
73
|
+
maxIterations: 5,
|
|
74
|
+
timeoutMs: 60000,
|
|
75
|
+
version: "0.1.0",
|
|
76
|
+
tags: ["calendar", "scheduling"],
|
|
77
|
+
createdAt: new Date("2024-04-01T12:00:00Z"),
|
|
78
|
+
updatedAt: new Date("2024-04-01T12:00:00Z")
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
// src/shared/mock-tools.ts
|
|
83
|
+
var MOCK_TOOLS = [
|
|
84
|
+
{
|
|
85
|
+
id: "tool-1",
|
|
86
|
+
organizationId: "demo-org",
|
|
87
|
+
name: "Web Search",
|
|
88
|
+
slug: "web-search",
|
|
89
|
+
description: "Search the web for real-time information using Brave API.",
|
|
90
|
+
category: "RETRIEVAL",
|
|
91
|
+
status: "ACTIVE",
|
|
92
|
+
parametersSchema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
query: { type: "string", description: "Search query" },
|
|
96
|
+
numResults: { type: "number", default: 10 }
|
|
97
|
+
},
|
|
98
|
+
required: ["query"]
|
|
99
|
+
},
|
|
100
|
+
outputSchema: { type: "array", items: { type: "object" } },
|
|
101
|
+
implementationType: "http",
|
|
102
|
+
implementationConfig: {
|
|
103
|
+
url: "https://api.brave.com/search",
|
|
104
|
+
method: "GET"
|
|
105
|
+
},
|
|
106
|
+
maxInvocationsPerMinute: 60,
|
|
107
|
+
timeoutMs: 30000,
|
|
108
|
+
version: "1.0.0",
|
|
109
|
+
tags: ["search", "web"],
|
|
110
|
+
createdAt: new Date("2024-01-01T00:00:00Z"),
|
|
111
|
+
updatedAt: new Date("2024-02-15T10:00:00Z")
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "tool-2",
|
|
115
|
+
organizationId: "demo-org",
|
|
116
|
+
name: "SQL Query",
|
|
117
|
+
slug: "sql-query",
|
|
118
|
+
description: "Execute read-only SQL queries against the data warehouse.",
|
|
119
|
+
category: "RETRIEVAL",
|
|
120
|
+
status: "ACTIVE",
|
|
121
|
+
parametersSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
query: { type: "string", description: "SQL query" },
|
|
125
|
+
maxRows: { type: "number", default: 100 }
|
|
126
|
+
},
|
|
127
|
+
required: ["query"]
|
|
128
|
+
},
|
|
129
|
+
outputSchema: { type: "object" },
|
|
130
|
+
implementationType: "function",
|
|
131
|
+
implementationConfig: { handler: "executeSqlQuery" },
|
|
132
|
+
maxInvocationsPerMinute: 30,
|
|
133
|
+
timeoutMs: 60000,
|
|
134
|
+
version: "1.1.0",
|
|
135
|
+
tags: ["sql", "database"],
|
|
136
|
+
createdAt: new Date("2024-01-05T00:00:00Z"),
|
|
137
|
+
updatedAt: new Date("2024-03-10T14:00:00Z")
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "tool-3",
|
|
141
|
+
organizationId: "demo-org",
|
|
142
|
+
name: "Email Sender",
|
|
143
|
+
slug: "email-sender",
|
|
144
|
+
description: "Send emails via SMTP or API.",
|
|
145
|
+
category: "COMMUNICATION",
|
|
146
|
+
status: "ACTIVE",
|
|
147
|
+
parametersSchema: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
to: { type: "string" },
|
|
151
|
+
subject: { type: "string" },
|
|
152
|
+
body: { type: "string" }
|
|
153
|
+
},
|
|
154
|
+
required: ["to", "subject", "body"]
|
|
155
|
+
},
|
|
156
|
+
implementationType: "http",
|
|
157
|
+
implementationConfig: { url: "/api/send-email", method: "POST" },
|
|
158
|
+
maxInvocationsPerMinute: 10,
|
|
159
|
+
timeoutMs: 30000,
|
|
160
|
+
version: "1.0.0",
|
|
161
|
+
tags: ["email", "communication"],
|
|
162
|
+
createdAt: new Date("2024-02-01T00:00:00Z"),
|
|
163
|
+
updatedAt: new Date("2024-02-01T00:00:00Z")
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "tool-4",
|
|
167
|
+
organizationId: "demo-org",
|
|
168
|
+
name: "GitHub Integration",
|
|
169
|
+
slug: "github-integration",
|
|
170
|
+
description: "Interact with GitHub repositories, PRs, and issues.",
|
|
171
|
+
category: "INTEGRATION",
|
|
172
|
+
status: "ACTIVE",
|
|
173
|
+
parametersSchema: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
action: {
|
|
177
|
+
type: "string",
|
|
178
|
+
enum: ["list_prs", "get_pr", "create_comment"]
|
|
179
|
+
},
|
|
180
|
+
repo: { type: "string" },
|
|
181
|
+
params: { type: "object" }
|
|
182
|
+
},
|
|
183
|
+
required: ["action", "repo"]
|
|
184
|
+
},
|
|
185
|
+
implementationType: "http",
|
|
186
|
+
implementationConfig: { url: "https://api.github.com", auth: "token" },
|
|
187
|
+
maxInvocationsPerMinute: 100,
|
|
188
|
+
timeoutMs: 15000,
|
|
189
|
+
version: "2.0.0",
|
|
190
|
+
tags: ["github", "integration", "code"],
|
|
191
|
+
createdAt: new Date("2024-02-20T00:00:00Z"),
|
|
192
|
+
updatedAt: new Date("2024-04-01T09:00:00Z")
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: "tool-5",
|
|
196
|
+
organizationId: "demo-org",
|
|
197
|
+
name: "Calculator",
|
|
198
|
+
slug: "calculator",
|
|
199
|
+
description: "Perform mathematical calculations.",
|
|
200
|
+
category: "COMPUTATION",
|
|
201
|
+
status: "ACTIVE",
|
|
202
|
+
parametersSchema: {
|
|
203
|
+
type: "object",
|
|
204
|
+
properties: {
|
|
205
|
+
expression: {
|
|
206
|
+
type: "string",
|
|
207
|
+
description: "Math expression to evaluate"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
required: ["expression"]
|
|
211
|
+
},
|
|
212
|
+
outputSchema: {
|
|
213
|
+
type: "object",
|
|
214
|
+
properties: { result: { type: "number" } }
|
|
215
|
+
},
|
|
216
|
+
implementationType: "function",
|
|
217
|
+
implementationConfig: { handler: "evaluateMath" },
|
|
218
|
+
timeoutMs: 5000,
|
|
219
|
+
version: "1.0.0",
|
|
220
|
+
tags: ["math", "utility"],
|
|
221
|
+
createdAt: new Date("2024-01-10T00:00:00Z"),
|
|
222
|
+
updatedAt: new Date("2024-01-10T00:00:00Z")
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
// src/shared/mock-runs.ts
|
|
227
|
+
var MOCK_RUNS = [
|
|
228
|
+
{
|
|
229
|
+
id: "run-1",
|
|
230
|
+
organizationId: "demo-org",
|
|
231
|
+
projectId: "demo-project",
|
|
232
|
+
agentId: "agent-1",
|
|
233
|
+
agentName: "Customer Support Bot",
|
|
234
|
+
userId: "user-1",
|
|
235
|
+
sessionId: "session-1",
|
|
236
|
+
input: { message: "How do I reset my password?", context: {} },
|
|
237
|
+
output: { response: "You can reset your password by clicking..." },
|
|
238
|
+
status: "COMPLETED",
|
|
239
|
+
totalTokens: 1250,
|
|
240
|
+
promptTokens: 800,
|
|
241
|
+
completionTokens: 450,
|
|
242
|
+
totalIterations: 3,
|
|
243
|
+
durationMs: 4500,
|
|
244
|
+
estimatedCostUsd: 0.0025,
|
|
245
|
+
queuedAt: new Date("2024-04-15T10:00:00Z"),
|
|
246
|
+
startedAt: new Date("2024-04-15T10:00:01Z"),
|
|
247
|
+
completedAt: new Date("2024-04-15T10:00:05Z"),
|
|
248
|
+
steps: [],
|
|
249
|
+
logs: []
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
id: "run-2",
|
|
253
|
+
organizationId: "demo-org",
|
|
254
|
+
projectId: "demo-project",
|
|
255
|
+
agentId: "agent-2",
|
|
256
|
+
agentName: "Code Review Assistant",
|
|
257
|
+
userId: "user-2",
|
|
258
|
+
input: { message: "Review PR #123", context: { prNumber: 123 } },
|
|
259
|
+
status: "IN_PROGRESS",
|
|
260
|
+
totalTokens: 3500,
|
|
261
|
+
promptTokens: 3000,
|
|
262
|
+
completionTokens: 500,
|
|
263
|
+
totalIterations: 5,
|
|
264
|
+
queuedAt: new Date("2024-04-15T10:30:00Z"),
|
|
265
|
+
startedAt: new Date("2024-04-15T10:30:02Z"),
|
|
266
|
+
steps: [],
|
|
267
|
+
logs: []
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: "run-3",
|
|
271
|
+
organizationId: "demo-org",
|
|
272
|
+
projectId: "demo-project",
|
|
273
|
+
agentId: "agent-1",
|
|
274
|
+
agentName: "Customer Support Bot",
|
|
275
|
+
userId: "user-1",
|
|
276
|
+
input: { message: "What are your business hours?" },
|
|
277
|
+
output: { response: "Our business hours are 9 AM to 5 PM EST..." },
|
|
278
|
+
status: "COMPLETED",
|
|
279
|
+
totalTokens: 800,
|
|
280
|
+
promptTokens: 500,
|
|
281
|
+
completionTokens: 300,
|
|
282
|
+
totalIterations: 2,
|
|
283
|
+
durationMs: 2100,
|
|
284
|
+
estimatedCostUsd: 0.0012,
|
|
285
|
+
queuedAt: new Date("2024-04-15T09:00:00Z"),
|
|
286
|
+
startedAt: new Date("2024-04-15T09:00:01Z"),
|
|
287
|
+
completedAt: new Date("2024-04-15T09:00:03Z"),
|
|
288
|
+
steps: [],
|
|
289
|
+
logs: []
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: "run-4",
|
|
293
|
+
organizationId: "demo-org",
|
|
294
|
+
projectId: "demo-project",
|
|
295
|
+
agentId: "agent-3",
|
|
296
|
+
agentName: "Data Analyst",
|
|
297
|
+
userId: "user-3",
|
|
298
|
+
input: { message: "Generate sales report for Q1" },
|
|
299
|
+
status: "FAILED",
|
|
300
|
+
errorMessage: "Database connection timeout",
|
|
301
|
+
errorCode: "DB_TIMEOUT",
|
|
302
|
+
totalTokens: 2000,
|
|
303
|
+
promptTokens: 1500,
|
|
304
|
+
completionTokens: 500,
|
|
305
|
+
totalIterations: 8,
|
|
306
|
+
durationMs: 45000,
|
|
307
|
+
queuedAt: new Date("2024-04-14T15:00:00Z"),
|
|
308
|
+
startedAt: new Date("2024-04-14T15:00:05Z"),
|
|
309
|
+
completedAt: new Date("2024-04-14T15:00:50Z"),
|
|
310
|
+
steps: [],
|
|
311
|
+
logs: []
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
id: "run-5",
|
|
315
|
+
organizationId: "demo-org",
|
|
316
|
+
projectId: "demo-project",
|
|
317
|
+
agentId: "agent-2",
|
|
318
|
+
agentName: "Code Review Assistant",
|
|
319
|
+
userId: "user-2",
|
|
320
|
+
input: { message: "Review PR #120" },
|
|
321
|
+
output: { response: "Code review complete. 3 suggestions..." },
|
|
322
|
+
status: "COMPLETED",
|
|
323
|
+
totalTokens: 5200,
|
|
324
|
+
promptTokens: 4000,
|
|
325
|
+
completionTokens: 1200,
|
|
326
|
+
totalIterations: 7,
|
|
327
|
+
durationMs: 15000,
|
|
328
|
+
estimatedCostUsd: 0.0156,
|
|
329
|
+
queuedAt: new Date("2024-04-14T11:00:00Z"),
|
|
330
|
+
startedAt: new Date("2024-04-14T11:00:03Z"),
|
|
331
|
+
completedAt: new Date("2024-04-14T11:00:18Z"),
|
|
332
|
+
steps: [],
|
|
333
|
+
logs: []
|
|
334
|
+
}
|
|
335
|
+
];
|
|
336
|
+
|
|
2
337
|
// src/ui/hooks/useAgentList.ts
|
|
3
338
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
4
339
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -55,6 +390,103 @@ function useAgentList(options = {}) {
|
|
|
55
390
|
// src/ui/hooks/useAgentMutations.ts
|
|
56
391
|
import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
|
|
57
392
|
import { useCallback as useCallback2, useState as useState2 } from "react";
|
|
393
|
+
|
|
394
|
+
// src/shared/demo-runtime-seed.ts
|
|
395
|
+
var AGENT_CONSOLE_DEMO_ORGANIZATION_ID = "demo-org";
|
|
396
|
+
var AGENT_CONSOLE_DEMO_PROJECT_ID = "agent-console-demo";
|
|
397
|
+
function slugify(name) {
|
|
398
|
+
return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
399
|
+
}
|
|
400
|
+
function cloneAgent(agent) {
|
|
401
|
+
return { ...agent };
|
|
402
|
+
}
|
|
403
|
+
function cloneTool(tool) {
|
|
404
|
+
return { ...tool };
|
|
405
|
+
}
|
|
406
|
+
function cloneRun(run) {
|
|
407
|
+
return { ...run };
|
|
408
|
+
}
|
|
409
|
+
function createDefaultNow() {
|
|
410
|
+
let tick = 0;
|
|
411
|
+
const base = Date.parse("2026-03-20T09:00:00.000Z");
|
|
412
|
+
return () => new Date(base + tick++ * 60000);
|
|
413
|
+
}
|
|
414
|
+
function normalizeProvider(provider) {
|
|
415
|
+
return provider.toLowerCase();
|
|
416
|
+
}
|
|
417
|
+
function normalizeRunStatus(status) {
|
|
418
|
+
return status === "IN_PROGRESS" ? "RUNNING" : status;
|
|
419
|
+
}
|
|
420
|
+
function createSeedState(projectId, organizationId) {
|
|
421
|
+
const agents = MOCK_AGENTS.map((agent) => ({
|
|
422
|
+
id: agent.id,
|
|
423
|
+
projectId,
|
|
424
|
+
organizationId,
|
|
425
|
+
name: agent.name,
|
|
426
|
+
slug: agent.slug,
|
|
427
|
+
description: agent.description,
|
|
428
|
+
modelProvider: normalizeProvider(agent.modelProvider),
|
|
429
|
+
modelName: agent.modelName,
|
|
430
|
+
systemPrompt: agent.systemPrompt,
|
|
431
|
+
temperature: typeof agent.modelConfig?.temperature === "number" ? agent.modelConfig.temperature : 0.4,
|
|
432
|
+
maxTokens: 8192,
|
|
433
|
+
status: agent.status,
|
|
434
|
+
createdAt: agent.createdAt,
|
|
435
|
+
updatedAt: agent.updatedAt
|
|
436
|
+
}));
|
|
437
|
+
const tools = MOCK_TOOLS.map((tool) => ({
|
|
438
|
+
id: tool.id,
|
|
439
|
+
projectId,
|
|
440
|
+
organizationId,
|
|
441
|
+
name: tool.name,
|
|
442
|
+
description: tool.description,
|
|
443
|
+
version: tool.version,
|
|
444
|
+
category: tool.category,
|
|
445
|
+
status: tool.status,
|
|
446
|
+
inputSchema: JSON.stringify(tool.parametersSchema),
|
|
447
|
+
outputSchema: tool.outputSchema ? JSON.stringify(tool.outputSchema) : undefined,
|
|
448
|
+
endpoint: typeof tool.implementationConfig?.url === "string" ? tool.implementationConfig.url : undefined,
|
|
449
|
+
createdAt: tool.createdAt,
|
|
450
|
+
updatedAt: tool.updatedAt
|
|
451
|
+
}));
|
|
452
|
+
const agentNames = new Map(agents.map((agent) => [agent.id, agent.name]));
|
|
453
|
+
const runs = MOCK_RUNS.map((run) => ({
|
|
454
|
+
id: run.id,
|
|
455
|
+
projectId,
|
|
456
|
+
agentId: run.agentId,
|
|
457
|
+
agentName: agentNames.get(run.agentId) ?? run.agentName ?? "Unknown agent",
|
|
458
|
+
status: normalizeRunStatus(run.status),
|
|
459
|
+
input: JSON.stringify(run.input),
|
|
460
|
+
output: run.output ? JSON.stringify(run.output) : undefined,
|
|
461
|
+
totalTokens: run.totalTokens,
|
|
462
|
+
promptTokens: run.promptTokens,
|
|
463
|
+
completionTokens: run.completionTokens,
|
|
464
|
+
estimatedCostUsd: run.estimatedCostUsd ?? 0,
|
|
465
|
+
durationMs: run.durationMs,
|
|
466
|
+
errorMessage: run.errorMessage,
|
|
467
|
+
queuedAt: run.queuedAt,
|
|
468
|
+
startedAt: run.startedAt,
|
|
469
|
+
completedAt: run.completedAt
|
|
470
|
+
}));
|
|
471
|
+
return { agents, tools, runs };
|
|
472
|
+
}
|
|
473
|
+
function summarizeRunMetrics(runs) {
|
|
474
|
+
const totalRuns = runs.length;
|
|
475
|
+
const completedRuns = runs.filter((run) => run.status === "COMPLETED").length;
|
|
476
|
+
const completedDurations = runs.map((run) => run.durationMs).filter((duration) => typeof duration === "number");
|
|
477
|
+
return {
|
|
478
|
+
totalRuns,
|
|
479
|
+
successRate: totalRuns === 0 ? 0 : completedRuns / totalRuns,
|
|
480
|
+
averageDurationMs: completedDurations.length === 0 ? 0 : Math.round(completedDurations.reduce((sum, duration) => sum + duration, 0) / completedDurations.length),
|
|
481
|
+
totalTokens: runs.reduce((sum, run) => sum + run.totalTokens, 0),
|
|
482
|
+
totalCostUsd: runs.reduce((sum, run) => sum + run.estimatedCostUsd, 0)
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/ui/hooks/useAgentMutations.ts
|
|
487
|
+
function normalizeMutationError(error, fallbackMessage) {
|
|
488
|
+
return error instanceof Error ? error : new Error(fallbackMessage);
|
|
489
|
+
}
|
|
58
490
|
function useAgentMutations(options = {}) {
|
|
59
491
|
const { handlers, projectId } = useTemplateRuntime2();
|
|
60
492
|
const { agent } = handlers;
|
|
@@ -78,16 +510,16 @@ function useAgentMutations(options = {}) {
|
|
|
78
510
|
try {
|
|
79
511
|
const result = await agent.createAgent(input, {
|
|
80
512
|
projectId,
|
|
81
|
-
organizationId:
|
|
513
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
|
|
82
514
|
});
|
|
83
515
|
setCreateState({ loading: false, error: null, data: result });
|
|
84
516
|
options.onSuccess?.();
|
|
85
517
|
return result;
|
|
86
518
|
} catch (err) {
|
|
87
|
-
const error = err
|
|
519
|
+
const error = normalizeMutationError(err, "Failed to create agent");
|
|
88
520
|
setCreateState({ loading: false, error, data: null });
|
|
89
521
|
options.onError?.(error);
|
|
90
|
-
|
|
522
|
+
throw error;
|
|
91
523
|
}
|
|
92
524
|
}, [agent, projectId, options]);
|
|
93
525
|
const updateAgent = useCallback2(async (input) => {
|
|
@@ -98,10 +530,10 @@ function useAgentMutations(options = {}) {
|
|
|
98
530
|
options.onSuccess?.();
|
|
99
531
|
return result;
|
|
100
532
|
} catch (err) {
|
|
101
|
-
const error = err
|
|
533
|
+
const error = normalizeMutationError(err, "Failed to update agent");
|
|
102
534
|
setUpdateState({ loading: false, error, data: null });
|
|
103
535
|
options.onError?.(error);
|
|
104
|
-
|
|
536
|
+
throw error;
|
|
105
537
|
}
|
|
106
538
|
}, [agent, options]);
|
|
107
539
|
const activateAgent = useCallback2(async (agentId) => {
|
|
@@ -119,16 +551,19 @@ function useAgentMutations(options = {}) {
|
|
|
119
551
|
const result = await agent.executeAgent({
|
|
120
552
|
agentId: input.agentId,
|
|
121
553
|
message: input.message,
|
|
122
|
-
context: {
|
|
554
|
+
context: {
|
|
555
|
+
projectId,
|
|
556
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
|
|
557
|
+
}
|
|
123
558
|
});
|
|
124
559
|
setExecuteState({ loading: false, error: null, data: result });
|
|
125
560
|
options.onSuccess?.();
|
|
126
561
|
return result;
|
|
127
562
|
} catch (err) {
|
|
128
|
-
const error = err
|
|
563
|
+
const error = normalizeMutationError(err, "Failed to execute agent");
|
|
129
564
|
setExecuteState({ loading: false, error, data: null });
|
|
130
565
|
options.onError?.(error);
|
|
131
|
-
|
|
566
|
+
throw error;
|
|
132
567
|
}
|
|
133
568
|
}, [agent, projectId, options]);
|
|
134
569
|
return {
|
|
@@ -155,7 +590,10 @@ function useRunList(options = {}) {
|
|
|
155
590
|
const [metrics, setMetrics] = useState3(null);
|
|
156
591
|
const [loading, setLoading] = useState3(true);
|
|
157
592
|
const [error, setError] = useState3(null);
|
|
158
|
-
const [
|
|
593
|
+
const [internalPageIndex, setInternalPageIndex] = useState3(0);
|
|
594
|
+
const pageSize = options.pageSize ?? options.limit ?? 20;
|
|
595
|
+
const pageIndex = options.pageIndex ?? internalPageIndex;
|
|
596
|
+
const [sort] = options.sorting ?? [];
|
|
159
597
|
const fetchData = useCallback3(async () => {
|
|
160
598
|
setLoading(true);
|
|
161
599
|
setError(null);
|
|
@@ -165,14 +603,14 @@ function useRunList(options = {}) {
|
|
|
165
603
|
projectId,
|
|
166
604
|
agentId: options.agentId,
|
|
167
605
|
status: options.status === "all" ? undefined : options.status,
|
|
168
|
-
|
|
169
|
-
|
|
606
|
+
sortBy: sort?.id,
|
|
607
|
+
sortDirection: sort ? sort.desc ? "desc" : "asc" : undefined,
|
|
608
|
+
limit: pageSize,
|
|
609
|
+
offset: pageIndex * pageSize
|
|
170
610
|
}),
|
|
171
611
|
agent.getRunMetrics({
|
|
172
612
|
projectId,
|
|
173
|
-
agentId: options.agentId
|
|
174
|
-
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
|
|
175
|
-
endDate: new Date
|
|
613
|
+
agentId: options.agentId
|
|
176
614
|
})
|
|
177
615
|
]);
|
|
178
616
|
setData(runsResult);
|
|
@@ -182,19 +620,31 @@ function useRunList(options = {}) {
|
|
|
182
620
|
} finally {
|
|
183
621
|
setLoading(false);
|
|
184
622
|
}
|
|
185
|
-
}, [
|
|
623
|
+
}, [
|
|
624
|
+
agent,
|
|
625
|
+
pageIndex,
|
|
626
|
+
pageSize,
|
|
627
|
+
projectId,
|
|
628
|
+
options.agentId,
|
|
629
|
+
options.status,
|
|
630
|
+
sort?.desc,
|
|
631
|
+
sort?.id
|
|
632
|
+
]);
|
|
186
633
|
useEffect2(() => {
|
|
187
634
|
fetchData();
|
|
188
635
|
}, [fetchData]);
|
|
636
|
+
const hasControlledPagination = options.pageIndex !== undefined;
|
|
189
637
|
return {
|
|
190
638
|
data,
|
|
191
639
|
metrics,
|
|
192
640
|
loading,
|
|
193
641
|
error,
|
|
194
|
-
page,
|
|
642
|
+
page: pageIndex + 1,
|
|
643
|
+
pageIndex,
|
|
644
|
+
pageSize,
|
|
195
645
|
refetch: fetchData,
|
|
196
|
-
nextPage: () =>
|
|
197
|
-
prevPage:
|
|
646
|
+
nextPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => current + 1),
|
|
647
|
+
prevPage: hasControlledPagination ? undefined : () => setInternalPageIndex((current) => Math.max(0, current - 1))
|
|
198
648
|
};
|
|
199
649
|
}
|
|
200
650
|
|