@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
|
@@ -1,4 +1,182 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/visualizations/catalog.ts
|
|
3
|
+
import {
|
|
4
|
+
defineVisualization,
|
|
5
|
+
VisualizationRegistry
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/visualizations";
|
|
7
|
+
var RUN_LIST_REF = { key: "agent.run.list", version: "1.0.0" };
|
|
8
|
+
var META = {
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
domain: "ai-ops",
|
|
11
|
+
stability: "experimental",
|
|
12
|
+
owners: ["@example.agent-console"],
|
|
13
|
+
tags: ["agent-console", "visualization", "operations"]
|
|
14
|
+
};
|
|
15
|
+
var AgentRunStatusVisualization = defineVisualization({
|
|
16
|
+
meta: {
|
|
17
|
+
...META,
|
|
18
|
+
key: "agent-console.visualization.run-status",
|
|
19
|
+
title: "Run Status Breakdown",
|
|
20
|
+
description: "Distribution of run outcomes across the current sample.",
|
|
21
|
+
goal: "Make operational success and failure mix visible at a glance.",
|
|
22
|
+
context: "Agent operations overview."
|
|
23
|
+
},
|
|
24
|
+
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
25
|
+
visualization: {
|
|
26
|
+
kind: "pie",
|
|
27
|
+
nameDimension: "status",
|
|
28
|
+
valueMeasure: "runs",
|
|
29
|
+
dimensions: [
|
|
30
|
+
{ key: "status", label: "Status", dataPath: "status", type: "category" }
|
|
31
|
+
],
|
|
32
|
+
measures: [
|
|
33
|
+
{ key: "runs", label: "Runs", dataPath: "runs", format: "number" }
|
|
34
|
+
],
|
|
35
|
+
table: { caption: "Run counts by status." }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var AgentRunActivityVisualization = defineVisualization({
|
|
39
|
+
meta: {
|
|
40
|
+
...META,
|
|
41
|
+
key: "agent-console.visualization.run-activity",
|
|
42
|
+
title: "Recent Run Activity",
|
|
43
|
+
description: "Daily run volume across the current sample.",
|
|
44
|
+
goal: "Show whether agent activity is rising or slowing down.",
|
|
45
|
+
context: "Operations trend monitoring."
|
|
46
|
+
},
|
|
47
|
+
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
48
|
+
visualization: {
|
|
49
|
+
kind: "cartesian",
|
|
50
|
+
variant: "line",
|
|
51
|
+
xDimension: "day",
|
|
52
|
+
yMeasures: ["runs"],
|
|
53
|
+
dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
|
|
54
|
+
measures: [
|
|
55
|
+
{
|
|
56
|
+
key: "runs",
|
|
57
|
+
label: "Runs",
|
|
58
|
+
dataPath: "runs",
|
|
59
|
+
format: "number",
|
|
60
|
+
color: "#0f766e"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
table: { caption: "Daily run counts." }
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var AgentRunEfficiencyVisualization = defineVisualization({
|
|
67
|
+
meta: {
|
|
68
|
+
...META,
|
|
69
|
+
key: "agent-console.visualization.run-efficiency",
|
|
70
|
+
title: "Duration vs Tokens",
|
|
71
|
+
description: "Scatter chart comparing token consumption and runtime.",
|
|
72
|
+
goal: "Reveal outlier runs that are slow relative to their token usage.",
|
|
73
|
+
context: "Operational performance diagnostics."
|
|
74
|
+
},
|
|
75
|
+
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
76
|
+
visualization: {
|
|
77
|
+
kind: "cartesian",
|
|
78
|
+
variant: "scatter",
|
|
79
|
+
xDimension: "totalTokens",
|
|
80
|
+
yMeasures: ["durationMs"],
|
|
81
|
+
dimensions: [
|
|
82
|
+
{
|
|
83
|
+
key: "totalTokens",
|
|
84
|
+
label: "Total Tokens",
|
|
85
|
+
dataPath: "totalTokens",
|
|
86
|
+
type: "number"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
measures: [
|
|
90
|
+
{
|
|
91
|
+
key: "durationMs",
|
|
92
|
+
label: "Duration",
|
|
93
|
+
dataPath: "durationMs",
|
|
94
|
+
format: "duration",
|
|
95
|
+
color: "#7c3aed"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: "estimatedCostUsd",
|
|
99
|
+
label: "Cost",
|
|
100
|
+
dataPath: "estimatedCostUsd",
|
|
101
|
+
format: "currency"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
series: [
|
|
105
|
+
{
|
|
106
|
+
key: "runs",
|
|
107
|
+
label: "Runs",
|
|
108
|
+
measure: "durationMs",
|
|
109
|
+
type: "scatter",
|
|
110
|
+
color: "#7c3aed"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
table: { caption: "Run duration versus token usage." }
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
var AgentVisualizationSpecs = [
|
|
117
|
+
AgentRunStatusVisualization,
|
|
118
|
+
AgentRunActivityVisualization,
|
|
119
|
+
AgentRunEfficiencyVisualization
|
|
120
|
+
];
|
|
121
|
+
var AgentVisualizationRegistry = new VisualizationRegistry([
|
|
122
|
+
...AgentVisualizationSpecs
|
|
123
|
+
]);
|
|
124
|
+
var AgentVisualizationRefs = AgentVisualizationSpecs.map((spec) => ({
|
|
125
|
+
key: spec.meta.key,
|
|
126
|
+
version: spec.meta.version
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
// src/visualizations/selectors.ts
|
|
130
|
+
function dayKey(value) {
|
|
131
|
+
if (!value)
|
|
132
|
+
return "unknown";
|
|
133
|
+
return value.toISOString().slice(0, 10);
|
|
134
|
+
}
|
|
135
|
+
function createAgentVisualizationItems(runs) {
|
|
136
|
+
const statusCounts = new Map;
|
|
137
|
+
const activityCounts = new Map;
|
|
138
|
+
for (const run of runs) {
|
|
139
|
+
statusCounts.set(run.status, (statusCounts.get(run.status) ?? 0) + 1);
|
|
140
|
+
activityCounts.set(dayKey(run.startedAt ?? run.queuedAt), (activityCounts.get(dayKey(run.startedAt ?? run.queuedAt)) ?? 0) + 1);
|
|
141
|
+
}
|
|
142
|
+
return [
|
|
143
|
+
{
|
|
144
|
+
key: "run-status",
|
|
145
|
+
spec: AgentRunStatusVisualization,
|
|
146
|
+
data: {
|
|
147
|
+
data: Array.from(statusCounts.entries()).map(([status, count]) => ({
|
|
148
|
+
status,
|
|
149
|
+
runs: count
|
|
150
|
+
}))
|
|
151
|
+
},
|
|
152
|
+
title: "Run Status Breakdown",
|
|
153
|
+
description: "Completed, failed, running, and cancelled runs in the sample.",
|
|
154
|
+
height: 260
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
key: "run-activity",
|
|
158
|
+
spec: AgentRunActivityVisualization,
|
|
159
|
+
data: {
|
|
160
|
+
data: Array.from(activityCounts.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, runs: count }))
|
|
161
|
+
},
|
|
162
|
+
title: "Recent Run Activity",
|
|
163
|
+
description: "Daily run volume derived from run start times."
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: "run-efficiency",
|
|
167
|
+
spec: AgentRunEfficiencyVisualization,
|
|
168
|
+
data: {
|
|
169
|
+
data: runs.filter((run) => typeof run.durationMs === "number").map((run) => ({
|
|
170
|
+
totalTokens: run.totalTokens,
|
|
171
|
+
durationMs: run.durationMs ?? 0,
|
|
172
|
+
estimatedCostUsd: run.estimatedCostUsd
|
|
173
|
+
}))
|
|
174
|
+
},
|
|
175
|
+
title: "Duration vs Tokens",
|
|
176
|
+
description: "Operational scatter plot for spotting inefficient runs."
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
}
|
|
2
180
|
// src/ui/hooks/useAgentList.ts
|
|
3
181
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
4
182
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -54,16 +232,25 @@ function useAgentList(options = {}) {
|
|
|
54
232
|
|
|
55
233
|
// src/ui/renderers/agent-list.markdown.ts
|
|
56
234
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
235
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
236
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
237
|
+
createAgentConsoleDemoHandlers
|
|
238
|
+
} from "@contractspec/example.agent-console/shared";
|
|
59
239
|
var agentListMarkdownRenderer = {
|
|
60
240
|
target: "markdown",
|
|
61
|
-
render: async (desc) => {
|
|
241
|
+
render: async (desc, ctx) => {
|
|
62
242
|
if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
|
|
63
243
|
throw new Error("agentListMarkdownRenderer: not AgentListView");
|
|
64
244
|
}
|
|
65
|
-
const data =
|
|
66
|
-
|
|
245
|
+
const data = Array.isArray(ctx?.data) ? {
|
|
246
|
+
items: ctx.data,
|
|
247
|
+
total: ctx.data.length,
|
|
248
|
+
hasMore: false
|
|
249
|
+
} : await createAgentConsoleDemoHandlers({
|
|
250
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID
|
|
251
|
+
}).listAgents({
|
|
252
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
253
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
67
254
|
limit: 50,
|
|
68
255
|
offset: 0
|
|
69
256
|
});
|
|
@@ -232,10 +419,8 @@ var agentListReactRenderer = {
|
|
|
232
419
|
|
|
233
420
|
// src/ui/renderers/dashboard.markdown.ts
|
|
234
421
|
import {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
mockListToolsHandler
|
|
238
|
-
} from "@contractspec/example.agent-console/handlers";
|
|
422
|
+
getFallbackAgentConsoleDashboardData
|
|
423
|
+
} from "@contractspec/example.agent-console/shared";
|
|
239
424
|
function formatDuration(ms) {
|
|
240
425
|
if (ms < 1000)
|
|
241
426
|
return `${ms}ms`;
|
|
@@ -245,29 +430,18 @@ function formatDuration(ms) {
|
|
|
245
430
|
}
|
|
246
431
|
var agentDashboardMarkdownRenderer = {
|
|
247
432
|
target: "markdown",
|
|
248
|
-
render: async (desc) => {
|
|
433
|
+
render: async (desc, ctx) => {
|
|
249
434
|
if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
|
|
250
435
|
throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
|
|
251
436
|
}
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
mockListToolsHandler({
|
|
261
|
-
organizationId: "demo-org",
|
|
262
|
-
limit: 100
|
|
263
|
-
})
|
|
264
|
-
]);
|
|
265
|
-
const activeAgents = agentsData.items.filter((a) => a.status === "ACTIVE").length;
|
|
266
|
-
const completedRuns = runsData.items.filter((r) => r.status === "COMPLETED").length;
|
|
267
|
-
const failedRuns = runsData.items.filter((r) => r.status === "FAILED").length;
|
|
268
|
-
const totalTokens = runsData.items.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
|
|
269
|
-
const totalCost = runsData.items.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
|
|
270
|
-
const activeTools = toolsData.items.filter((t) => t.status === "ACTIVE").length;
|
|
437
|
+
const data = ctx?.data ?? await getFallbackAgentConsoleDashboardData();
|
|
438
|
+
const activeAgents = data.agents.filter((a) => a.status === "ACTIVE").length;
|
|
439
|
+
const completedRuns = data.runs.filter((r) => r.status === "COMPLETED").length;
|
|
440
|
+
const failedRuns = data.runs.filter((r) => r.status === "FAILED").length;
|
|
441
|
+
const totalTokens = data.runs.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
|
|
442
|
+
const totalCost = data.runs.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
|
|
443
|
+
const activeTools = data.tools.filter((t) => t.status === "ACTIVE").length;
|
|
444
|
+
const visualizationItems = createAgentVisualizationItems(data.runs);
|
|
271
445
|
const lines = [
|
|
272
446
|
"# Agent Console Dashboard",
|
|
273
447
|
"",
|
|
@@ -277,51 +451,57 @@ var agentDashboardMarkdownRenderer = {
|
|
|
277
451
|
"",
|
|
278
452
|
"| Metric | Value |",
|
|
279
453
|
"|--------|-------|",
|
|
280
|
-
`| Total Agents | ${
|
|
454
|
+
`| Total Agents | ${data.summary.totalAgents} |`,
|
|
281
455
|
`| Active Agents | ${activeAgents} |`,
|
|
282
|
-
`| Total Runs | ${
|
|
456
|
+
`| Total Runs | ${data.summary.totalRuns} |`,
|
|
283
457
|
`| Completed Runs | ${completedRuns} |`,
|
|
284
458
|
`| Failed Runs | ${failedRuns} |`,
|
|
285
459
|
`| Total Tokens | ${totalTokens.toLocaleString()} |`,
|
|
286
460
|
`| Total Cost | $${totalCost.toFixed(4)} |`,
|
|
287
|
-
`| Total Tools | ${
|
|
461
|
+
`| Total Tools | ${data.summary.totalTools} |`,
|
|
288
462
|
`| Active Tools | ${activeTools} |`,
|
|
289
463
|
"",
|
|
290
464
|
"## Agents",
|
|
291
465
|
""
|
|
292
466
|
];
|
|
293
|
-
if (
|
|
467
|
+
if (data.agents.length === 0) {
|
|
294
468
|
lines.push("_No agents configured._");
|
|
295
469
|
} else {
|
|
296
470
|
lines.push("| Agent | Model | Status | Description |");
|
|
297
471
|
lines.push("|-------|-------|--------|-------------|");
|
|
298
|
-
for (const agent of
|
|
472
|
+
for (const agent of data.agents.slice(0, 5)) {
|
|
299
473
|
lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
|
|
300
474
|
}
|
|
301
|
-
if (
|
|
302
|
-
lines.push(`| ... | ... | ... | _${
|
|
475
|
+
if (data.agents.length > 5) {
|
|
476
|
+
lines.push(`| ... | ... | ... | _${data.summary.totalAgents - 5} more_ |`);
|
|
303
477
|
}
|
|
304
478
|
}
|
|
305
479
|
lines.push("");
|
|
306
480
|
lines.push("## Recent Runs");
|
|
307
481
|
lines.push("");
|
|
308
|
-
if (
|
|
482
|
+
if (data.runs.length === 0) {
|
|
309
483
|
lines.push("_No runs yet._");
|
|
310
484
|
} else {
|
|
311
485
|
lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
|
|
312
486
|
lines.push("|--------|-------|--------|----------|--------|------|");
|
|
313
|
-
for (const run of
|
|
487
|
+
for (const run of data.runs.slice(0, 5)) {
|
|
314
488
|
lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
|
|
315
489
|
}
|
|
316
|
-
if (
|
|
317
|
-
lines.push(`| ... | ... | ... | ... | ... | _${
|
|
490
|
+
if (data.runs.length > 5) {
|
|
491
|
+
lines.push(`| ... | ... | ... | ... | ... | _${data.summary.totalRuns - 5} more_ |`);
|
|
318
492
|
}
|
|
319
493
|
}
|
|
320
494
|
lines.push("");
|
|
495
|
+
lines.push("## Visualization Overview");
|
|
496
|
+
lines.push("");
|
|
497
|
+
for (const item of visualizationItems) {
|
|
498
|
+
lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
|
|
499
|
+
}
|
|
500
|
+
lines.push("");
|
|
321
501
|
lines.push("## Tools");
|
|
322
502
|
lines.push("");
|
|
323
503
|
const toolsByCategory = {};
|
|
324
|
-
for (const tool of
|
|
504
|
+
for (const tool of data.tools) {
|
|
325
505
|
const cat = tool.category;
|
|
326
506
|
if (!toolsByCategory[cat])
|
|
327
507
|
toolsByCategory[cat] = [];
|
|
@@ -346,7 +526,10 @@ var agentDashboardMarkdownRenderer = {
|
|
|
346
526
|
};
|
|
347
527
|
|
|
348
528
|
// src/ui/renderers/run-list.markdown.ts
|
|
349
|
-
import {
|
|
529
|
+
import {
|
|
530
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID2,
|
|
531
|
+
createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers2
|
|
532
|
+
} from "@contractspec/example.agent-console/shared";
|
|
350
533
|
function formatDuration2(ms) {
|
|
351
534
|
if (ms < 1000)
|
|
352
535
|
return `${ms}ms`;
|
|
@@ -356,12 +539,14 @@ function formatDuration2(ms) {
|
|
|
356
539
|
}
|
|
357
540
|
var runListMarkdownRenderer = {
|
|
358
541
|
target: "markdown",
|
|
359
|
-
render: async (desc) => {
|
|
542
|
+
render: async (desc, ctx) => {
|
|
360
543
|
if (desc.source.type !== "component" || desc.source.componentKey !== "RunListView") {
|
|
361
544
|
throw new Error("runListMarkdownRenderer: not RunListView");
|
|
362
545
|
}
|
|
363
|
-
const data = await
|
|
364
|
-
|
|
546
|
+
const data = Array.isArray(ctx?.data) ? { items: ctx.data, total: ctx.data.length, hasMore: false } : await createAgentConsoleDemoHandlers2({
|
|
547
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2
|
|
548
|
+
}).listRuns({
|
|
549
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID2,
|
|
365
550
|
limit: 20,
|
|
366
551
|
offset: 0
|
|
367
552
|
});
|
|
@@ -389,15 +574,26 @@ var runListMarkdownRenderer = {
|
|
|
389
574
|
};
|
|
390
575
|
|
|
391
576
|
// src/ui/renderers/tool-registry.markdown.ts
|
|
392
|
-
import {
|
|
577
|
+
import {
|
|
578
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID as AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
|
|
579
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID as AGENT_CONSOLE_DEMO_PROJECT_ID3,
|
|
580
|
+
createAgentConsoleDemoHandlers as createAgentConsoleDemoHandlers3
|
|
581
|
+
} from "@contractspec/example.agent-console/shared";
|
|
393
582
|
var toolRegistryMarkdownRenderer = {
|
|
394
583
|
target: "markdown",
|
|
395
|
-
render: async (desc) => {
|
|
584
|
+
render: async (desc, ctx) => {
|
|
396
585
|
if (desc.source.type !== "component" || desc.source.componentKey !== "ToolRegistryView") {
|
|
397
586
|
throw new Error("toolRegistryMarkdownRenderer: not ToolRegistryView");
|
|
398
587
|
}
|
|
399
|
-
const data =
|
|
400
|
-
|
|
588
|
+
const data = Array.isArray(ctx?.data) ? {
|
|
589
|
+
items: ctx.data,
|
|
590
|
+
total: ctx.data.length,
|
|
591
|
+
hasMore: false
|
|
592
|
+
} : await createAgentConsoleDemoHandlers3({
|
|
593
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3
|
|
594
|
+
}).listTools({
|
|
595
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID3,
|
|
596
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID2,
|
|
401
597
|
limit: 50,
|
|
402
598
|
offset: 0
|
|
403
599
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses dynamic import for handlers to ensure correct build order.
|
|
5
5
|
*/
|
|
6
|
-
import type { PresentationRenderer } from '@contractspec/lib.
|
|
6
|
+
import type { PresentationRenderer } from '@contractspec/lib.presentation-runtime-core/transform-engine';
|
|
7
7
|
/**
|
|
8
8
|
* Markdown renderer for agent-console.run.list presentation
|
|
9
9
|
* Only handles RunListView component
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ui/renderers/run-list.markdown.ts
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
5
|
+
createAgentConsoleDemoHandlers
|
|
6
|
+
} from "@contractspec/example.agent-console/shared";
|
|
4
7
|
function formatDuration(ms) {
|
|
5
8
|
if (ms < 1000)
|
|
6
9
|
return `${ms}ms`;
|
|
@@ -10,12 +13,14 @@ function formatDuration(ms) {
|
|
|
10
13
|
}
|
|
11
14
|
var runListMarkdownRenderer = {
|
|
12
15
|
target: "markdown",
|
|
13
|
-
render: async (desc) => {
|
|
16
|
+
render: async (desc, ctx) => {
|
|
14
17
|
if (desc.source.type !== "component" || desc.source.componentKey !== "RunListView") {
|
|
15
18
|
throw new Error("runListMarkdownRenderer: not RunListView");
|
|
16
19
|
}
|
|
17
|
-
const data = await
|
|
18
|
-
|
|
20
|
+
const data = Array.isArray(ctx?.data) ? { items: ctx.data, total: ctx.data.length, hasMore: false } : await createAgentConsoleDemoHandlers({
|
|
21
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID
|
|
22
|
+
}).listRuns({
|
|
23
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
19
24
|
limit: 20,
|
|
20
25
|
offset: 0
|
|
21
26
|
});
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses dynamic import for handlers to ensure correct build order.
|
|
5
5
|
*/
|
|
6
|
-
import type { PresentationRenderer } from '@contractspec/lib.
|
|
6
|
+
import type { PresentationRenderer } from '@contractspec/lib.presentation-runtime-core/transform-engine';
|
|
7
7
|
/**
|
|
8
|
-
* Markdown renderer for agent-console.tool.
|
|
8
|
+
* Markdown renderer for agent-console.tool.list presentation
|
|
9
9
|
* Only handles ToolRegistryView component
|
|
10
10
|
*/
|
|
11
11
|
export declare const toolRegistryMarkdownRenderer: PresentationRenderer<{
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ui/renderers/tool-registry.markdown.ts
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
5
|
+
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
6
|
+
createAgentConsoleDemoHandlers
|
|
7
|
+
} from "@contractspec/example.agent-console/shared";
|
|
4
8
|
var toolRegistryMarkdownRenderer = {
|
|
5
9
|
target: "markdown",
|
|
6
|
-
render: async (desc) => {
|
|
10
|
+
render: async (desc, ctx) => {
|
|
7
11
|
if (desc.source.type !== "component" || desc.source.componentKey !== "ToolRegistryView") {
|
|
8
12
|
throw new Error("toolRegistryMarkdownRenderer: not ToolRegistryView");
|
|
9
13
|
}
|
|
10
|
-
const data =
|
|
11
|
-
|
|
14
|
+
const data = Array.isArray(ctx?.data) ? {
|
|
15
|
+
items: ctx.data,
|
|
16
|
+
total: ctx.data.length,
|
|
17
|
+
hasMore: false
|
|
18
|
+
} : await createAgentConsoleDemoHandlers({
|
|
19
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID
|
|
20
|
+
}).listTools({
|
|
21
|
+
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
22
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
12
23
|
limit: 50,
|
|
13
24
|
offset: 0
|
|
14
25
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ContractTableSort } from '@contractspec/lib.presentation-runtime-core';
|
|
2
|
+
import type { Run } from '../hooks/useRunList';
|
|
3
|
+
interface RunDataTableProps {
|
|
4
|
+
runs: Run[];
|
|
5
|
+
totalItems: number;
|
|
6
|
+
pageIndex: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
sorting: ContractTableSort[];
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
onSortingChange: (nextSorting: ContractTableSort[]) => void;
|
|
11
|
+
onPaginationChange: (nextPagination: {
|
|
12
|
+
pageIndex: number;
|
|
13
|
+
pageSize: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
onRunClick?: (runId: string) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function RunDataTable({ runs, totalItems, pageIndex, pageSize, sorting, loading, onSortingChange, onPaginationChange, onRunClick, }: RunDataTableProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|