@contractspec/example.agent-console 3.8.9 → 3.8.11
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 +30 -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 +26 -10
- package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
- package/src/ui/ExecutionConsoleHost.tsx +14 -0
- package/src/ui/index.ts +1 -1
|
@@ -1,64 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var agentConsoleDemoOverlay = {
|
|
3
|
-
overlayId: "agent-console.demo-user",
|
|
4
|
-
version: "1.0.0",
|
|
5
|
-
description: "Simplifies agent console for demo users",
|
|
6
|
-
appliesTo: {
|
|
7
|
-
feature: "agent-console",
|
|
8
|
-
role: "demo"
|
|
9
|
-
},
|
|
10
|
-
modifications: [
|
|
11
|
-
{
|
|
12
|
-
type: "hideField",
|
|
13
|
-
field: "modelConfig",
|
|
14
|
-
reason: "Advanced config not relevant for demo"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: "hideField",
|
|
18
|
-
field: "webhookConfig",
|
|
19
|
-
reason: "Integration not available in demo"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: "renameLabel",
|
|
23
|
-
field: "systemPrompt",
|
|
24
|
-
newLabel: "Agent Instructions"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: "addBadge",
|
|
28
|
-
position: "header",
|
|
29
|
-
label: "Demo Mode",
|
|
30
|
-
variant: "warning"
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
};
|
|
34
|
-
var agentConsoleReadOnlyOverlay = {
|
|
35
|
-
overlayId: "agent-console.read-only",
|
|
36
|
-
version: "1.0.0",
|
|
37
|
-
description: "Read-only view for non-admin users",
|
|
38
|
-
appliesTo: {
|
|
39
|
-
feature: "agent-console",
|
|
40
|
-
role: "viewer"
|
|
41
|
-
},
|
|
42
|
-
modifications: [
|
|
43
|
-
{
|
|
44
|
-
type: "hideField",
|
|
45
|
-
field: "deleteButton",
|
|
46
|
-
reason: "No delete permission"
|
|
47
|
-
},
|
|
48
|
-
{ type: "hideField", field: "editButton", reason: "No edit permission" },
|
|
49
|
-
{
|
|
50
|
-
type: "hideField",
|
|
51
|
-
field: "createButton",
|
|
52
|
-
reason: "No create permission"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
var agentConsoleOverlays = [
|
|
57
|
-
agentConsoleDemoOverlay,
|
|
58
|
-
agentConsoleReadOnlyOverlay
|
|
59
|
-
];
|
|
60
|
-
export {
|
|
61
|
-
agentConsoleReadOnlyOverlay,
|
|
62
|
-
agentConsoleOverlays,
|
|
63
|
-
agentConsoleDemoOverlay
|
|
64
|
-
};
|
|
1
|
+
var p={overlayId:"agent-console.demo-user",version:"1.0.0",description:"Simplifies agent console for demo users",appliesTo:{feature:"agent-console",role:"demo"},modifications:[{type:"hideField",field:"modelConfig",reason:"Advanced config not relevant for demo"},{type:"hideField",field:"webhookConfig",reason:"Integration not available in demo"},{type:"renameLabel",field:"systemPrompt",newLabel:"Agent Instructions"},{type:"addBadge",position:"header",label:"Demo Mode",variant:"warning"}]},x={overlayId:"agent-console.read-only",version:"1.0.0",description:"Read-only view for non-admin users",appliesTo:{feature:"agent-console",role:"viewer"},modifications:[{type:"hideField",field:"deleteButton",reason:"No delete permission"},{type:"hideField",field:"editButton",reason:"No edit permission"},{type:"hideField",field:"createButton",reason:"No create permission"}]},b=[p,x];export{x as agentConsoleReadOnlyOverlay,b as agentConsoleOverlays,p as agentConsoleDemoOverlay};
|
|
@@ -1,64 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
4
|
-
AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
5
|
-
createAgentConsoleDemoHandlers
|
|
6
|
-
} from "@contractspec/example.agent-console/shared";
|
|
7
|
-
var agentListMarkdownRenderer = {
|
|
8
|
-
target: "markdown",
|
|
9
|
-
render: async (desc, ctx) => {
|
|
10
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
|
|
11
|
-
throw new Error("agentListMarkdownRenderer: not AgentListView");
|
|
12
|
-
}
|
|
13
|
-
const data = Array.isArray(ctx?.data) ? {
|
|
14
|
-
items: ctx.data,
|
|
15
|
-
total: ctx.data.length,
|
|
16
|
-
hasMore: false
|
|
17
|
-
} : await createAgentConsoleDemoHandlers({
|
|
18
|
-
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID
|
|
19
|
-
}).listAgents({
|
|
20
|
-
projectId: AGENT_CONSOLE_DEMO_PROJECT_ID,
|
|
21
|
-
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
22
|
-
limit: 50,
|
|
23
|
-
offset: 0
|
|
24
|
-
});
|
|
25
|
-
const lines = [
|
|
26
|
-
`# ${desc.meta.description ?? "Agent List"}`,
|
|
27
|
-
"",
|
|
28
|
-
`> ${desc.meta.key} v${desc.meta.version}`,
|
|
29
|
-
"",
|
|
30
|
-
`**Total Agents:** ${data.total}`,
|
|
31
|
-
"",
|
|
32
|
-
"## Agents",
|
|
33
|
-
""
|
|
34
|
-
];
|
|
35
|
-
const byStatus = {};
|
|
36
|
-
for (const agent of data.items) {
|
|
37
|
-
const status = agent.status;
|
|
38
|
-
if (byStatus[status]) {
|
|
39
|
-
byStatus[status].push(agent);
|
|
40
|
-
} else {
|
|
41
|
-
byStatus[status] = [agent];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
for (const [status, agents] of Object.entries(byStatus)) {
|
|
45
|
-
lines.push(`### ${status} (${agents.length})`);
|
|
46
|
-
lines.push("");
|
|
47
|
-
for (const agent of agents) {
|
|
48
|
-
lines.push(`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`);
|
|
49
|
-
if (agent.description) {
|
|
50
|
-
lines.push(` > ${agent.description}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
lines.push("");
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
mimeType: "text/markdown",
|
|
57
|
-
body: lines.join(`
|
|
58
|
-
`)
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
agentListMarkdownRenderer
|
|
64
|
-
};
|
|
1
|
+
import{AGENT_CONSOLE_DEMO_ORGANIZATION_ID as v,AGENT_CONSOLE_DEMO_PROJECT_ID as r,createAgentConsoleDemoHandlers as w}from"@contractspec/example.agent-console/shared";var B={target:"markdown",render:async(j,p)=>{if(j.source.type!=="component"||j.source.componentKey!=="AgentListView")throw Error("agentListMarkdownRenderer: not AgentListView");let q=Array.isArray(p?.data)?{items:p.data,total:p.data.length,hasMore:!1}:await w({projectId:r}).listAgents({projectId:r,organizationId:v,limit:50,offset:0}),f=[`# ${j.meta.description??"Agent List"}`,"",`> ${j.meta.key} v${j.meta.version}`,"",`**Total Agents:** ${q.total}`,"","## Agents",""],o={};for(let k of q.items){let h=k.status;if(o[h])o[h].push(k);else o[h]=[k]}for(let[k,h]of Object.entries(o)){f.push(`### ${k} (${h.length})`),f.push("");for(let m of h)if(f.push(`- **${m.name}** (${m.modelProvider}/${m.modelName})`),m.description)f.push(` > ${m.description}`);f.push("")}return{mimeType:"text/markdown",body:f.join(`
|
|
2
|
+
`)}}};export{B as agentListMarkdownRenderer};
|
|
@@ -1,180 +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
|
-
|
|
54
|
-
// src/ui/views/AgentListView.tsx
|
|
55
|
-
import {
|
|
56
|
-
Button,
|
|
57
|
-
EmptyState,
|
|
58
|
-
EntityCard,
|
|
59
|
-
ErrorState,
|
|
60
|
-
LoaderBlock,
|
|
61
|
-
StatCard,
|
|
62
|
-
StatCardGroup,
|
|
63
|
-
StatusChip
|
|
64
|
-
} from "@contractspec/lib.design-system";
|
|
65
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
66
|
-
"use client";
|
|
67
|
-
function getStatusTone(status) {
|
|
68
|
-
switch (status) {
|
|
69
|
-
case "ACTIVE":
|
|
70
|
-
return "success";
|
|
71
|
-
case "PAUSED":
|
|
72
|
-
case "DRAFT":
|
|
73
|
-
return "warning";
|
|
74
|
-
case "ARCHIVED":
|
|
75
|
-
return "neutral";
|
|
76
|
-
default:
|
|
77
|
-
return "neutral";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function AgentListView() {
|
|
81
|
-
const { data, loading, error, stats, refetch } = useAgentList();
|
|
82
|
-
if (loading && !data) {
|
|
83
|
-
return /* @__PURE__ */ jsxDEV(LoaderBlock, {
|
|
84
|
-
label: "Loading agents..."
|
|
85
|
-
}, undefined, false, undefined, this);
|
|
86
|
-
}
|
|
87
|
-
if (error) {
|
|
88
|
-
return /* @__PURE__ */ jsxDEV(ErrorState, {
|
|
89
|
-
title: "Failed to load agents",
|
|
90
|
-
description: error.message,
|
|
91
|
-
onRetry: refetch,
|
|
92
|
-
retryLabel: "Retry"
|
|
93
|
-
}, undefined, false, undefined, this);
|
|
94
|
-
}
|
|
95
|
-
if (!data?.items.length) {
|
|
96
|
-
return /* @__PURE__ */ jsxDEV(EmptyState, {
|
|
97
|
-
title: "No agents yet",
|
|
98
|
-
description: "Create your first AI agent to get started."
|
|
99
|
-
}, undefined, false, undefined, this);
|
|
100
|
-
}
|
|
101
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
102
|
-
className: "space-y-6",
|
|
103
|
-
children: [
|
|
104
|
-
stats && /* @__PURE__ */ jsxDEV(StatCardGroup, {
|
|
105
|
-
children: [
|
|
106
|
-
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
107
|
-
label: "Total Agents",
|
|
108
|
-
value: stats.total
|
|
109
|
-
}, undefined, false, undefined, this),
|
|
110
|
-
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
111
|
-
label: "Active",
|
|
112
|
-
value: stats.active
|
|
113
|
-
}, undefined, false, undefined, this),
|
|
114
|
-
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
115
|
-
label: "Paused",
|
|
116
|
-
value: stats.paused
|
|
117
|
-
}, undefined, false, undefined, this),
|
|
118
|
-
/* @__PURE__ */ jsxDEV(StatCard, {
|
|
119
|
-
label: "Draft",
|
|
120
|
-
value: stats.draft
|
|
121
|
-
}, undefined, false, undefined, this)
|
|
122
|
-
]
|
|
123
|
-
}, undefined, true, undefined, this),
|
|
124
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
125
|
-
className: "flex items-center justify-between",
|
|
126
|
-
children: [
|
|
127
|
-
/* @__PURE__ */ jsxDEV("h3", {
|
|
128
|
-
className: "font-semibold text-lg",
|
|
129
|
-
children: "Agents"
|
|
130
|
-
}, undefined, false, undefined, this),
|
|
131
|
-
/* @__PURE__ */ jsxDEV(Button, {
|
|
132
|
-
onPress: () => alert("Create Agent clicked!"),
|
|
133
|
-
children: "Create Agent"
|
|
134
|
-
}, undefined, false, undefined, this)
|
|
135
|
-
]
|
|
136
|
-
}, undefined, true, undefined, this),
|
|
137
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
138
|
-
className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
139
|
-
children: data.items.map((agent) => /* @__PURE__ */ jsxDEV(EntityCard, {
|
|
140
|
-
cardTitle: agent.name,
|
|
141
|
-
cardSubtitle: agent.modelName,
|
|
142
|
-
meta: /* @__PURE__ */ jsxDEV("p", {
|
|
143
|
-
className: "text-muted-foreground text-sm",
|
|
144
|
-
children: agent.description
|
|
145
|
-
}, undefined, false, undefined, this),
|
|
146
|
-
chips: /* @__PURE__ */ jsxDEV(StatusChip, {
|
|
147
|
-
tone: getStatusTone(agent.status),
|
|
148
|
-
label: agent.status
|
|
149
|
-
}, undefined, false, undefined, this),
|
|
150
|
-
footer: /* @__PURE__ */ jsxDEV("span", {
|
|
151
|
-
className: "text-muted-foreground text-xs",
|
|
152
|
-
children: [
|
|
153
|
-
"Created ",
|
|
154
|
-
agent.createdAt.toLocaleDateString()
|
|
155
|
-
]
|
|
156
|
-
}, undefined, true, undefined, this),
|
|
157
|
-
onClick: () => alert(`View agent: ${agent.name}`)
|
|
158
|
-
}, agent.id, false, undefined, this))
|
|
159
|
-
}, undefined, false, undefined, this)
|
|
160
|
-
]
|
|
161
|
-
}, undefined, true, undefined, this);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/ui/renderers/agent-list.renderer.tsx
|
|
165
|
-
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
166
|
-
var agentListReactRenderer = {
|
|
167
|
-
target: "react",
|
|
168
|
-
render: async (desc) => {
|
|
169
|
-
if (desc.source.type !== "component") {
|
|
170
|
-
throw new Error("AgentListRenderer: expected component source");
|
|
171
|
-
}
|
|
172
|
-
if (desc.source.componentKey !== "AgentListView") {
|
|
173
|
-
throw new Error(`AgentListRenderer: unknown component ${desc.source.componentKey}`);
|
|
174
|
-
}
|
|
175
|
-
return /* @__PURE__ */ jsxDEV2(AgentListView, {}, undefined, false, undefined, this);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
export {
|
|
179
|
-
agentListReactRenderer
|
|
180
|
-
};
|
|
1
|
+
import{useTemplateRuntime as R}from"@contractspec/lib.example-shared-ui";import{useCallback as T,useEffect as k,useMemo as I,useState as Q}from"react";function G(q={}){let{handlers:Y,projectId:N}=R(),{agent:K}=Y,[J,H]=Q(null),[U,_]=Q(!0),[B,$]=Q(null),[O,v]=Q(1),Z=T(async()=>{_(!0),$(null);try{let z=await K.listAgents({projectId:N,search:q.search,status:q.status==="all"?void 0:q.status,limit:q.limit??20,offset:(O-1)*(q.limit??20)});H(z)}catch(z){$(z instanceof Error?z:Error("Unknown error"))}finally{_(!1)}},[K,N,q.search,q.status,q.limit,O]);k(()=>{Z()},[Z]);let P=I(()=>{if(!J)return null;return{total:J.total,active:J.items.filter((z)=>z.status==="ACTIVE").length,paused:J.items.filter((z)=>z.status==="PAUSED").length,draft:J.items.filter((z)=>z.status==="DRAFT").length}},[J]);return{data:J,loading:U,error:B,stats:P,page:O,refetch:Z,nextPage:()=>v((z)=>z+1),prevPage:()=>O>1&&v((z)=>z-1)}}import{Button as V,EmptyState as b,EntityCard as y,ErrorState as D,LoaderBlock as w,StatCard as W,StatCardGroup as E,StatusChip as A}from"@contractspec/lib.design-system";import{jsx as F,jsxs as X}from"react/jsx-runtime";function C(q){switch(q){case"ACTIVE":return"success";case"PAUSED":case"DRAFT":return"warning";case"ARCHIVED":return"neutral";default:return"neutral"}}function M(){let{data:q,loading:Y,error:N,stats:K,refetch:J}=G();if(Y&&!q)return F(w,{label:"Loading agents..."});if(N)return F(D,{title:"Failed to load agents",description:N.message,onRetry:J,retryLabel:"Retry"});if(!q?.items.length)return F(b,{title:"No agents yet",description:"Create your first AI agent to get started."});return X("div",{className:"space-y-6",children:[K&&X(E,{children:[F(W,{label:"Total Agents",value:K.total}),F(W,{label:"Active",value:K.active}),F(W,{label:"Paused",value:K.paused}),F(W,{label:"Draft",value:K.draft})]}),X("div",{className:"flex items-center justify-between",children:[F("h3",{className:"font-semibold text-lg",children:"Agents"}),F(V,{onPress:()=>alert("Create Agent clicked!"),children:"Create Agent"})]}),F("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:q.items.map((H)=>F(y,{cardTitle:H.name,cardSubtitle:H.modelName,meta:F("p",{className:"text-muted-foreground text-sm",children:H.description}),chips:F(A,{tone:C(H.status),label:H.status}),footer:X("span",{className:"text-muted-foreground text-xs",children:["Created ",H.createdAt.toLocaleDateString()]}),onClick:()=>alert(`View agent: ${H.name}`)},H.id))})]})}import{jsx as f}from"react/jsx-runtime";var c={target:"react",render:async(q)=>{if(q.source.type!=="component")throw Error("AgentListRenderer: expected component source");if(q.source.componentKey!=="AgentListView")throw Error(`AgentListRenderer: unknown component ${q.source.componentKey}`);return f(M,{})}};export{c as agentListReactRenderer};
|
|
@@ -1,288 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
defineVisualization,
|
|
4
|
-
VisualizationRegistry
|
|
5
|
-
} from "@contractspec/lib.contracts-spec/visualizations";
|
|
6
|
-
var RUN_LIST_REF = { key: "agent.run.list", version: "1.0.0" };
|
|
7
|
-
var META = {
|
|
8
|
-
version: "1.0.0",
|
|
9
|
-
domain: "ai-ops",
|
|
10
|
-
stability: "experimental",
|
|
11
|
-
owners: ["@example.agent-console"],
|
|
12
|
-
tags: ["agent-console", "visualization", "operations"]
|
|
13
|
-
};
|
|
14
|
-
var AgentRunStatusVisualization = defineVisualization({
|
|
15
|
-
meta: {
|
|
16
|
-
...META,
|
|
17
|
-
key: "agent-console.visualization.run-status",
|
|
18
|
-
title: "Run Status Breakdown",
|
|
19
|
-
description: "Distribution of run outcomes across the current sample.",
|
|
20
|
-
goal: "Make operational success and failure mix visible at a glance.",
|
|
21
|
-
context: "Agent operations overview."
|
|
22
|
-
},
|
|
23
|
-
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
24
|
-
visualization: {
|
|
25
|
-
kind: "pie",
|
|
26
|
-
nameDimension: "status",
|
|
27
|
-
valueMeasure: "runs",
|
|
28
|
-
dimensions: [
|
|
29
|
-
{ key: "status", label: "Status", dataPath: "status", type: "category" }
|
|
30
|
-
],
|
|
31
|
-
measures: [
|
|
32
|
-
{ key: "runs", label: "Runs", dataPath: "runs", format: "number" }
|
|
33
|
-
],
|
|
34
|
-
table: { caption: "Run counts by status." }
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
var AgentRunActivityVisualization = defineVisualization({
|
|
38
|
-
meta: {
|
|
39
|
-
...META,
|
|
40
|
-
key: "agent-console.visualization.run-activity",
|
|
41
|
-
title: "Recent Run Activity",
|
|
42
|
-
description: "Daily run volume across the current sample.",
|
|
43
|
-
goal: "Show whether agent activity is rising or slowing down.",
|
|
44
|
-
context: "Operations trend monitoring."
|
|
45
|
-
},
|
|
46
|
-
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
47
|
-
visualization: {
|
|
48
|
-
kind: "cartesian",
|
|
49
|
-
variant: "line",
|
|
50
|
-
xDimension: "day",
|
|
51
|
-
yMeasures: ["runs"],
|
|
52
|
-
dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
|
|
53
|
-
measures: [
|
|
54
|
-
{
|
|
55
|
-
key: "runs",
|
|
56
|
-
label: "Runs",
|
|
57
|
-
dataPath: "runs",
|
|
58
|
-
format: "number",
|
|
59
|
-
color: "#0f766e"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
table: { caption: "Daily run counts." }
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
var AgentRunEfficiencyVisualization = defineVisualization({
|
|
66
|
-
meta: {
|
|
67
|
-
...META,
|
|
68
|
-
key: "agent-console.visualization.run-efficiency",
|
|
69
|
-
title: "Duration vs Tokens",
|
|
70
|
-
description: "Scatter chart comparing token consumption and runtime.",
|
|
71
|
-
goal: "Reveal outlier runs that are slow relative to their token usage.",
|
|
72
|
-
context: "Operational performance diagnostics."
|
|
73
|
-
},
|
|
74
|
-
source: { primary: RUN_LIST_REF, resultPath: "data" },
|
|
75
|
-
visualization: {
|
|
76
|
-
kind: "cartesian",
|
|
77
|
-
variant: "scatter",
|
|
78
|
-
xDimension: "totalTokens",
|
|
79
|
-
yMeasures: ["durationMs"],
|
|
80
|
-
dimensions: [
|
|
81
|
-
{
|
|
82
|
-
key: "totalTokens",
|
|
83
|
-
label: "Total Tokens",
|
|
84
|
-
dataPath: "totalTokens",
|
|
85
|
-
type: "number"
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
measures: [
|
|
89
|
-
{
|
|
90
|
-
key: "durationMs",
|
|
91
|
-
label: "Duration",
|
|
92
|
-
dataPath: "durationMs",
|
|
93
|
-
format: "duration",
|
|
94
|
-
color: "#7c3aed"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
key: "estimatedCostUsd",
|
|
98
|
-
label: "Cost",
|
|
99
|
-
dataPath: "estimatedCostUsd",
|
|
100
|
-
format: "currency"
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
series: [
|
|
104
|
-
{
|
|
105
|
-
key: "runs",
|
|
106
|
-
label: "Runs",
|
|
107
|
-
measure: "durationMs",
|
|
108
|
-
type: "scatter",
|
|
109
|
-
color: "#7c3aed"
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
table: { caption: "Run duration versus token usage." }
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
var AgentVisualizationSpecs = [
|
|
116
|
-
AgentRunStatusVisualization,
|
|
117
|
-
AgentRunActivityVisualization,
|
|
118
|
-
AgentRunEfficiencyVisualization
|
|
119
|
-
];
|
|
120
|
-
var AgentVisualizationRegistry = new VisualizationRegistry([
|
|
121
|
-
...AgentVisualizationSpecs
|
|
122
|
-
]);
|
|
123
|
-
var AgentVisualizationRefs = AgentVisualizationSpecs.map((spec) => ({
|
|
124
|
-
key: spec.meta.key,
|
|
125
|
-
version: spec.meta.version
|
|
126
|
-
}));
|
|
127
|
-
|
|
128
|
-
// src/visualizations/selectors.ts
|
|
129
|
-
function dayKey(value) {
|
|
130
|
-
if (!value)
|
|
131
|
-
return "unknown";
|
|
132
|
-
return value.toISOString().slice(0, 10);
|
|
133
|
-
}
|
|
134
|
-
function createAgentVisualizationItems(runs) {
|
|
135
|
-
const statusCounts = new Map;
|
|
136
|
-
const activityCounts = new Map;
|
|
137
|
-
for (const run of runs) {
|
|
138
|
-
statusCounts.set(run.status, (statusCounts.get(run.status) ?? 0) + 1);
|
|
139
|
-
activityCounts.set(dayKey(run.startedAt ?? run.queuedAt), (activityCounts.get(dayKey(run.startedAt ?? run.queuedAt)) ?? 0) + 1);
|
|
140
|
-
}
|
|
141
|
-
return [
|
|
142
|
-
{
|
|
143
|
-
key: "run-status",
|
|
144
|
-
spec: AgentRunStatusVisualization,
|
|
145
|
-
data: {
|
|
146
|
-
data: Array.from(statusCounts.entries()).map(([status, count]) => ({
|
|
147
|
-
status,
|
|
148
|
-
runs: count
|
|
149
|
-
}))
|
|
150
|
-
},
|
|
151
|
-
title: "Run Status Breakdown",
|
|
152
|
-
description: "Completed, failed, running, and cancelled runs in the sample.",
|
|
153
|
-
height: 260
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
key: "run-activity",
|
|
157
|
-
spec: AgentRunActivityVisualization,
|
|
158
|
-
data: {
|
|
159
|
-
data: Array.from(activityCounts.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, runs: count }))
|
|
160
|
-
},
|
|
161
|
-
title: "Recent Run Activity",
|
|
162
|
-
description: "Daily run volume derived from run start times."
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
key: "run-efficiency",
|
|
166
|
-
spec: AgentRunEfficiencyVisualization,
|
|
167
|
-
data: {
|
|
168
|
-
data: runs.filter((run) => typeof run.durationMs === "number").map((run) => ({
|
|
169
|
-
totalTokens: run.totalTokens,
|
|
170
|
-
durationMs: run.durationMs ?? 0,
|
|
171
|
-
estimatedCostUsd: run.estimatedCostUsd
|
|
172
|
-
}))
|
|
173
|
-
},
|
|
174
|
-
title: "Duration vs Tokens",
|
|
175
|
-
description: "Operational scatter plot for spotting inefficient runs."
|
|
176
|
-
}
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
// src/ui/renderers/dashboard.markdown.ts
|
|
180
|
-
import {
|
|
181
|
-
getFallbackAgentConsoleDashboardData
|
|
182
|
-
} from "@contractspec/example.agent-console/shared";
|
|
183
|
-
function formatDuration(ms) {
|
|
184
|
-
if (ms < 1000)
|
|
185
|
-
return `${ms}ms`;
|
|
186
|
-
if (ms < 60000)
|
|
187
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
188
|
-
return `${(ms / 60000).toFixed(1)}m`;
|
|
189
|
-
}
|
|
190
|
-
var agentDashboardMarkdownRenderer = {
|
|
191
|
-
target: "markdown",
|
|
192
|
-
render: async (desc, ctx) => {
|
|
193
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
|
|
194
|
-
throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
|
|
195
|
-
}
|
|
196
|
-
const data = ctx?.data ?? await getFallbackAgentConsoleDashboardData();
|
|
197
|
-
const activeAgents = data.agents.filter((a) => a.status === "ACTIVE").length;
|
|
198
|
-
const completedRuns = data.runs.filter((r) => r.status === "COMPLETED").length;
|
|
199
|
-
const failedRuns = data.runs.filter((r) => r.status === "FAILED").length;
|
|
200
|
-
const totalTokens = data.runs.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
|
|
201
|
-
const totalCost = data.runs.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
|
|
202
|
-
const activeTools = data.tools.filter((t) => t.status === "ACTIVE").length;
|
|
203
|
-
const visualizationItems = createAgentVisualizationItems(data.runs);
|
|
204
|
-
const lines = [
|
|
205
|
-
"# Agent Console Dashboard",
|
|
206
|
-
"",
|
|
207
|
-
"> AI agent operations overview",
|
|
208
|
-
"",
|
|
209
|
-
"## Summary",
|
|
210
|
-
"",
|
|
211
|
-
"| Metric | Value |",
|
|
212
|
-
"|--------|-------|",
|
|
213
|
-
`| Total Agents | ${data.summary.totalAgents} |`,
|
|
214
|
-
`| Active Agents | ${activeAgents} |`,
|
|
215
|
-
`| Total Runs | ${data.summary.totalRuns} |`,
|
|
216
|
-
`| Completed Runs | ${completedRuns} |`,
|
|
217
|
-
`| Failed Runs | ${failedRuns} |`,
|
|
218
|
-
`| Total Tokens | ${totalTokens.toLocaleString()} |`,
|
|
219
|
-
`| Total Cost | $${totalCost.toFixed(4)} |`,
|
|
220
|
-
`| Total Tools | ${data.summary.totalTools} |`,
|
|
221
|
-
`| Active Tools | ${activeTools} |`,
|
|
222
|
-
"",
|
|
223
|
-
"## Agents",
|
|
224
|
-
""
|
|
225
|
-
];
|
|
226
|
-
if (data.agents.length === 0) {
|
|
227
|
-
lines.push("_No agents configured._");
|
|
228
|
-
} else {
|
|
229
|
-
lines.push("| Agent | Model | Status | Description |");
|
|
230
|
-
lines.push("|-------|-------|--------|-------------|");
|
|
231
|
-
for (const agent of data.agents.slice(0, 5)) {
|
|
232
|
-
lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
|
|
233
|
-
}
|
|
234
|
-
if (data.agents.length > 5) {
|
|
235
|
-
lines.push(`| ... | ... | ... | _${data.summary.totalAgents - 5} more_ |`);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
lines.push("");
|
|
239
|
-
lines.push("## Recent Runs");
|
|
240
|
-
lines.push("");
|
|
241
|
-
if (data.runs.length === 0) {
|
|
242
|
-
lines.push("_No runs yet._");
|
|
243
|
-
} else {
|
|
244
|
-
lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
|
|
245
|
-
lines.push("|--------|-------|--------|----------|--------|------|");
|
|
246
|
-
for (const run of data.runs.slice(0, 5)) {
|
|
247
|
-
lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
|
|
248
|
-
}
|
|
249
|
-
if (data.runs.length > 5) {
|
|
250
|
-
lines.push(`| ... | ... | ... | ... | ... | _${data.summary.totalRuns - 5} more_ |`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
lines.push("");
|
|
254
|
-
lines.push("## Visualization Overview");
|
|
255
|
-
lines.push("");
|
|
256
|
-
for (const item of visualizationItems) {
|
|
257
|
-
lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
|
|
258
|
-
}
|
|
259
|
-
lines.push("");
|
|
260
|
-
lines.push("## Tools");
|
|
261
|
-
lines.push("");
|
|
262
|
-
const toolsByCategory = {};
|
|
263
|
-
for (const tool of data.tools) {
|
|
264
|
-
const cat = tool.category;
|
|
265
|
-
if (!toolsByCategory[cat])
|
|
266
|
-
toolsByCategory[cat] = [];
|
|
267
|
-
toolsByCategory[cat].push(tool);
|
|
268
|
-
}
|
|
269
|
-
if (Object.keys(toolsByCategory).length === 0) {
|
|
270
|
-
lines.push("_No tools registered._");
|
|
271
|
-
} else {
|
|
272
|
-
lines.push("| Category | Tools | Active |");
|
|
273
|
-
lines.push("|----------|-------|--------|");
|
|
274
|
-
for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
|
|
275
|
-
const active = tools.filter((t) => t.status === "ACTIVE").length;
|
|
276
|
-
lines.push(`| ${category} | ${tools.length} | ${active} |`);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
mimeType: "text/markdown",
|
|
281
|
-
body: lines.join(`
|
|
282
|
-
`)
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
export {
|
|
287
|
-
agentDashboardMarkdownRenderer
|
|
288
|
-
};
|
|
1
|
+
import{defineVisualization as k,VisualizationRegistry as G}from"@contractspec/lib.contracts-spec/visualizations";var w={key:"agent.run.list",version:"1.0.0"},y={version:"1.0.0",domain:"ai-ops",stability:"experimental",owners:["@example.agent-console"],tags:["agent-console","visualization","operations"]},h=k({meta:{...y,key:"agent-console.visualization.run-status",title:"Run Status Breakdown",description:"Distribution of run outcomes across the current sample.",goal:"Make operational success and failure mix visible at a glance.",context:"Agent operations overview."},source:{primary:w,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"runs",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number"}],table:{caption:"Run counts by status."}}}),d=k({meta:{...y,key:"agent-console.visualization.run-activity",title:"Recent Run Activity",description:"Daily run volume across the current sample.",goal:"Show whether agent activity is rising or slowing down.",context:"Operations trend monitoring."},source:{primary:w,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["runs"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number",color:"#0f766e"}],table:{caption:"Daily run counts."}}}),q=k({meta:{...y,key:"agent-console.visualization.run-efficiency",title:"Duration vs Tokens",description:"Scatter chart comparing token consumption and runtime.",goal:"Reveal outlier runs that are slow relative to their token usage.",context:"Operational performance diagnostics."},source:{primary:w,resultPath:"data"},visualization:{kind:"cartesian",variant:"scatter",xDimension:"totalTokens",yMeasures:["durationMs"],dimensions:[{key:"totalTokens",label:"Total Tokens",dataPath:"totalTokens",type:"number"}],measures:[{key:"durationMs",label:"Duration",dataPath:"durationMs",format:"duration",color:"#7c3aed"},{key:"estimatedCostUsd",label:"Cost",dataPath:"estimatedCostUsd",format:"currency"}],series:[{key:"runs",label:"Runs",measure:"durationMs",type:"scatter",color:"#7c3aed"}],table:{caption:"Run duration versus token usage."}}}),M=[h,d,q],Q=new G([...M]),S=M.map((p)=>({key:p.meta.key,version:p.meta.version}));function O(p){if(!p)return"unknown";return p.toISOString().slice(0,10)}function b(p){let m=new Map,u=new Map;for(let f of p)m.set(f.status,(m.get(f.status)??0)+1),u.set(O(f.startedAt??f.queuedAt),(u.get(O(f.startedAt??f.queuedAt))??0)+1);return[{key:"run-status",spec:h,data:{data:Array.from(m.entries()).map(([f,o])=>({status:f,runs:o}))},title:"Run Status Breakdown",description:"Completed, failed, running, and cancelled runs in the sample.",height:260},{key:"run-activity",spec:d,data:{data:Array.from(u.entries()).sort(([f],[o])=>f.localeCompare(o)).map(([f,o])=>({day:f,runs:o}))},title:"Recent Run Activity",description:"Daily run volume derived from run start times."},{key:"run-efficiency",spec:q,data:{data:p.filter((f)=>typeof f.durationMs==="number").map((f)=>({totalTokens:f.totalTokens,durationMs:f.durationMs??0,estimatedCostUsd:f.estimatedCostUsd}))},title:"Duration vs Tokens",description:"Operational scatter plot for spotting inefficient runs."}]}import{getFallbackAgentConsoleDashboardData as H}from"@contractspec/example.agent-console/shared";function J(p){if(p<1000)return`${p}ms`;if(p<60000)return`${(p/1000).toFixed(1)}s`;return`${(p/60000).toFixed(1)}m`}var U={target:"markdown",render:async(p,m)=>{if(p.source.type!=="component"||p.source.componentKey!=="AgentConsoleDashboard")throw Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");let u=m?.data??await H(),f=u.agents.filter((r)=>r.status==="ACTIVE").length,o=u.runs.filter((r)=>r.status==="COMPLETED").length,c=u.runs.filter((r)=>r.status==="FAILED").length,x=u.runs.reduce((r,e)=>r+(e.totalTokens??0),0),K=u.runs.reduce((r,e)=>r+(e.estimatedCostUsd??0),0),j=u.tools.filter((r)=>r.status==="ACTIVE").length,v=b(u.runs),t=["# Agent Console Dashboard","","> AI agent operations overview","","## Summary","","| Metric | Value |","|--------|-------|",`| Total Agents | ${u.summary.totalAgents} |`,`| Active Agents | ${f} |`,`| Total Runs | ${u.summary.totalRuns} |`,`| Completed Runs | ${o} |`,`| Failed Runs | ${c} |`,`| Total Tokens | ${x.toLocaleString()} |`,`| Total Cost | $${K.toFixed(4)} |`,`| Total Tools | ${u.summary.totalTools} |`,`| Active Tools | ${j} |`,"","## Agents",""];if(u.agents.length===0)t.push("_No agents configured._");else{t.push("| Agent | Model | Status | Description |"),t.push("|-------|-------|--------|-------------|");for(let r of u.agents.slice(0,5))t.push(`| ${r.name} | ${r.modelProvider}/${r.modelName} | ${r.status} | ${r.description??"-"} |`);if(u.agents.length>5)t.push(`| ... | ... | ... | _${u.summary.totalAgents-5} more_ |`)}if(t.push(""),t.push("## Recent Runs"),t.push(""),u.runs.length===0)t.push("_No runs yet._");else{t.push("| Run ID | Agent | Status | Duration | Tokens | Cost |"),t.push("|--------|-------|--------|----------|--------|------|");for(let r of u.runs.slice(0,5))t.push(`| ${r.id.slice(-8)} | ${r.agentName} | ${r.status} | ${r.durationMs?J(r.durationMs):"-"} | ${r.totalTokens??0} | $${(r.estimatedCostUsd??0).toFixed(4)} |`);if(u.runs.length>5)t.push(`| ... | ... | ... | ... | ... | _${u.summary.totalRuns-5} more_ |`)}t.push(""),t.push("## Visualization Overview"),t.push("");for(let r of v)t.push(`- **${r.title}** via \`${r.spec.meta.key}\``);t.push(""),t.push("## Tools"),t.push("");let n={};for(let r of u.tools){let e=r.category;if(!n[e])n[e]=[];n[e].push(r)}if(Object.keys(n).length===0)t.push("_No tools registered._");else{t.push("| Category | Tools | Active |"),t.push("|----------|-------|--------|");for(let[r,e]of Object.entries(n).sort()){let A=e.filter((D)=>D.status==="ACTIVE").length;t.push(`| ${r} | ${e.length} | ${A} |`)}}return{mimeType:"text/markdown",body:t.join(`
|
|
2
|
+
`)}}};export{U as agentDashboardMarkdownRenderer};
|