@skyhook-io/radar-app 1.22.1 → 1.23.0
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/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Badge } from '@skyhook-io/k8s-ui'
|
|
2
|
+
import { healthToSeverity } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
3
|
+
import { readKagent } from '@skyhook-io/k8s-ui/components/resources/resource-utils-kagent'
|
|
4
|
+
import type { ResourceHost, KindListProps } from '../../integrations/resourceHost'
|
|
5
|
+
import { refToSelectedResource } from '../../utils/navigation'
|
|
6
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
7
|
+
import { useCapabilities, useRadarFeature } from '../../api/client'
|
|
8
|
+
import { useKagentWorkspace, type KagentRef } from '../../api/kagent'
|
|
9
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
10
|
+
import { DrawerTrailBack } from '../workspace/DrawerTrailBack'
|
|
11
|
+
import { RefreshFailedNotice, ScreenBody } from '../workspace/layout'
|
|
12
|
+
import { KagentAgentRenderer } from './KagentAgentRenderer'
|
|
13
|
+
import { KagentAgentOverview, KagentDependencyOverview } from './KagentPages'
|
|
14
|
+
import { KagentAgentsTable, KagentMCPServers, KagentModels, modelStatus, mcpStatus } from './KagentLists'
|
|
15
|
+
import { CoverageNotice, KagentGate, useKagentRuntime, changeText, revisionText } from './shared'
|
|
16
|
+
import { KAGENT_GROUP, KAGENT_KINDS, kagentPath } from './routes'
|
|
17
|
+
import { veleroKindListMode } from '../velero/routes'
|
|
18
|
+
|
|
19
|
+
function KagentResourceSummary({ resource, onNavigate }: { resource: any; onNavigate?: KindListProps['onInspect'] }) {
|
|
20
|
+
const navigate = useWorkspaceNavigate()
|
|
21
|
+
const { connection } = useConnection()
|
|
22
|
+
const onOpen = (ref: KagentRef) => {
|
|
23
|
+
const path = kagentPath(ref, connection.context)
|
|
24
|
+
if (path) navigate(path)
|
|
25
|
+
else onNavigate?.(refToSelectedResource(ref))
|
|
26
|
+
}
|
|
27
|
+
return (
|
|
28
|
+
<div className="p-5">
|
|
29
|
+
{resource.kind === 'Agent' ? (
|
|
30
|
+
<KagentAgentOverview resource={resource} onOpen={onOpen} />
|
|
31
|
+
) : (
|
|
32
|
+
<KagentDependencyOverview resource={resource} onOpen={onOpen} />
|
|
33
|
+
)}
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
function KagentKindList({ screen, namespaces, onInspect }: KindListProps & { screen: 'agents' | 'mcpservers' | 'models' }) {
|
|
38
|
+
const feature = useRadarFeature('kagentWorkspace')
|
|
39
|
+
const { isPending: checking } = useCapabilities()
|
|
40
|
+
const query = useKagentWorkspace(namespaces)
|
|
41
|
+
const runtime = useKagentRuntime(namespaces, screen === 'agents')
|
|
42
|
+
const navigate = useWorkspaceNavigate()
|
|
43
|
+
const { connection } = useConnection()
|
|
44
|
+
const onOpen = (ref: KagentRef) => {
|
|
45
|
+
const path = kagentPath(ref, connection.context)
|
|
46
|
+
if (path) navigate(path)
|
|
47
|
+
else onInspect(refToSelectedResource(ref))
|
|
48
|
+
}
|
|
49
|
+
return (
|
|
50
|
+
<KagentGate
|
|
51
|
+
support={feature.support}
|
|
52
|
+
checking={checking}
|
|
53
|
+
loading={query.isPending}
|
|
54
|
+
error={query.error && !query.data ? query.error : undefined}
|
|
55
|
+
installed={query.data?.installed}
|
|
56
|
+
>
|
|
57
|
+
{query.data && (
|
|
58
|
+
<ScreenBody>
|
|
59
|
+
<RefreshFailedNotice queries={[query]} />
|
|
60
|
+
<CoverageNotice coverage={query.data.coverage} />
|
|
61
|
+
{screen === 'agents' ? (
|
|
62
|
+
<KagentAgentsTable data={query.data} runtime={runtime} onOpen={onOpen} />
|
|
63
|
+
) : screen === 'mcpservers' ? (
|
|
64
|
+
<KagentMCPServers data={query.data} onOpen={onOpen} />
|
|
65
|
+
) : (
|
|
66
|
+
<KagentModels data={query.data} onOpen={onOpen} />
|
|
67
|
+
)}
|
|
68
|
+
</ScreenBody>
|
|
69
|
+
)}
|
|
70
|
+
</KagentGate>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
export const kagentResourceHost: ResourceHost = {
|
|
74
|
+
id: 'kagent',
|
|
75
|
+
feature: 'kagentWorkspace',
|
|
76
|
+
waitForFeature: true,
|
|
77
|
+
renderers: { KagentAgentRenderer },
|
|
78
|
+
resources: Object.keys(KAGENT_KINDS).map((name) => ({ name, group: KAGENT_GROUP })),
|
|
79
|
+
detailOwnership: ['summary', 'destination'],
|
|
80
|
+
expandedPath: (resource, context, tab) => {
|
|
81
|
+
const plural = Object.keys(KAGENT_KINDS).find(
|
|
82
|
+
(p) => p === resource.kind || KAGENT_KINDS[p as keyof typeof KAGENT_KINDS].kind === resource.kind,
|
|
83
|
+
)
|
|
84
|
+
if (!plural) return null
|
|
85
|
+
const path = kagentPath({ ...resource, kind: KAGENT_KINDS[plural as keyof typeof KAGENT_KINDS].kind, group: KAGENT_GROUP }, context)
|
|
86
|
+
return path && tab ? `${path}${path.includes('?') ? '&' : '?'}tab=${tab}` : path
|
|
87
|
+
},
|
|
88
|
+
detailRedirect: (resource, params) => {
|
|
89
|
+
const plural = Object.keys(KAGENT_KINDS).find(
|
|
90
|
+
(p) => p === resource.kind || KAGENT_KINDS[p as keyof typeof KAGENT_KINDS].kind === resource.kind,
|
|
91
|
+
)
|
|
92
|
+
if (!plural) return null
|
|
93
|
+
const path = kagentPath({ ...resource, kind: KAGENT_KINDS[plural as keyof typeof KAGENT_KINDS].kind, group: KAGENT_GROUP })!
|
|
94
|
+
const search = new URLSearchParams(params)
|
|
95
|
+
search.delete('apiGroup')
|
|
96
|
+
return `${path}${search.size ? `?${search}` : ''}`
|
|
97
|
+
},
|
|
98
|
+
detailSlots: () => ({
|
|
99
|
+
renderStatusBadge: (resource) => {
|
|
100
|
+
const r = readKagent(resource)
|
|
101
|
+
if (!r) return null
|
|
102
|
+
const label =
|
|
103
|
+
resource.kind === 'Agent'
|
|
104
|
+
? `Latest change ${r.state === 'ready' ? 'prepared' : changeText(r.state === 'stale' ? 'notProcessed' : r.state).toLowerCase()}`
|
|
105
|
+
: resource.kind === 'ModelConfig'
|
|
106
|
+
? modelStatus(r)
|
|
107
|
+
: resource.kind === 'RemoteMCPServer'
|
|
108
|
+
? mcpStatus(r)
|
|
109
|
+
: r.text
|
|
110
|
+
return <><Badge severity={healthToSeverity(r.tone)}>{label}</Badge>{resource.kind === 'Agent' && <Badge tone="structural">New sessions {resource.status?.latestSuccessfulRevision ? `revision ${revisionText(resource.status.latestSuccessfulRevision)}` : 'none prepared'}</Badge>}</>
|
|
111
|
+
},
|
|
112
|
+
renderSummary: (props) => <KagentResourceSummary resource={props.resource} onNavigate={props.onNavigate} />,
|
|
113
|
+
}),
|
|
114
|
+
drawerNavigation: {
|
|
115
|
+
ownsPath: (path) => path === '/kagent' || path.startsWith('/kagent/'),
|
|
116
|
+
Component: ({ resource }) => (
|
|
117
|
+
<DrawerTrailBack
|
|
118
|
+
resource={resource}
|
|
119
|
+
pathPrefix="/kagent"
|
|
120
|
+
kindLabel={(plural) => KAGENT_KINDS[plural as keyof typeof KAGENT_KINDS]?.kind}
|
|
121
|
+
/>
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
kindLists: [
|
|
125
|
+
{
|
|
126
|
+
kind: { name: 'agents', kind: 'Agent', group: KAGENT_GROUP },
|
|
127
|
+
title: 'Agents',
|
|
128
|
+
mode: veleroKindListMode,
|
|
129
|
+
Component: (props) => <KagentKindList {...props} screen="agents" />,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
kind: { name: 'remotemcpservers', kind: 'RemoteMCPServer', group: KAGENT_GROUP },
|
|
133
|
+
title: 'MCP servers',
|
|
134
|
+
mode: veleroKindListMode,
|
|
135
|
+
Component: (props) => <KagentKindList {...props} screen="mcpservers" />,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
kind: { name: 'modelconfigs', kind: 'ModelConfig', group: KAGENT_GROUP },
|
|
139
|
+
title: 'Models',
|
|
140
|
+
mode: veleroKindListMode,
|
|
141
|
+
Component: (props) => <KagentKindList {...props} screen="models" />,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { KAGENT_GROUP } from '@skyhook-io/k8s-ui/components/resources/resource-utils-kagent'
|
|
2
|
+
import type { KagentRef } from '../../api/kagent'
|
|
3
|
+
export { KAGENT_GROUP }
|
|
4
|
+
export const KAGENT_AGENT_KIND = { name: 'agents', kind: 'Agent', group: KAGENT_GROUP }
|
|
5
|
+
export const KAGENT_GENERIC_AGENTS_PATH = `/resources/agents?apiGroup=${encodeURIComponent(KAGENT_GROUP)}`
|
|
6
|
+
export const KAGENT_AGENTS_PATH = '/kagent/agents'
|
|
7
|
+
export const KAGENT_KINDS = {
|
|
8
|
+
agents: { kind: 'Agent', label: 'Agents', listPath: KAGENT_AGENTS_PATH },
|
|
9
|
+
remotemcpservers: { kind: 'RemoteMCPServer', label: 'MCP servers', listPath: '/kagent/mcpservers' },
|
|
10
|
+
modelconfigs: { kind: 'ModelConfig', label: 'Models', listPath: '/kagent/models' },
|
|
11
|
+
} as const
|
|
12
|
+
export type KagentPlural = keyof typeof KAGENT_KINDS
|
|
13
|
+
export interface KagentTarget {
|
|
14
|
+
plural: KagentPlural
|
|
15
|
+
namespace: string
|
|
16
|
+
name: string
|
|
17
|
+
}
|
|
18
|
+
export function kagentPath(ref: KagentRef, context?: string): string | null {
|
|
19
|
+
const plural = (Object.keys(KAGENT_KINDS) as KagentPlural[]).find((p) => KAGENT_KINDS[p].kind === ref.kind)
|
|
20
|
+
if (ref.group !== KAGENT_GROUP || !plural) return null
|
|
21
|
+
return `/kagent/${plural}/${encodeURIComponent(ref.namespace)}/${encodeURIComponent(ref.name)}${context ? `?ctx=${encodeURIComponent(context)}` : ''}`
|
|
22
|
+
}
|
|
23
|
+
export function parseKagentRoute(pathname: string): { screen: 'overview' | 'agents' | 'mcpservers' | 'models'; detail?: KagentTarget } {
|
|
24
|
+
const [, , section, ns, name] = pathname.split('/')
|
|
25
|
+
if (Object.hasOwn(KAGENT_KINDS, section) && ns && name)
|
|
26
|
+
return {
|
|
27
|
+
screen: 'overview',
|
|
28
|
+
detail: { plural: section as KagentPlural, namespace: decodeURIComponent(ns), name: decodeURIComponent(name) },
|
|
29
|
+
}
|
|
30
|
+
return { screen: section === 'agents' || section === 'mcpservers' || section === 'models' ? section : 'overview' }
|
|
31
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { shortRevision } from '@skyhook-io/k8s-ui/components/resources/resource-utils-kagent'
|
|
2
|
+
import { useEffect, type ReactNode } from 'react'
|
|
3
|
+
import { Bot } from 'lucide-react'
|
|
4
|
+
import { CertaintyGlyph, FactValue, PaneLoader, StatusDot, TruncatedText, type WorkspaceProblem } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { isStillLoadingError, useRadarFeature } from '../../api/client'
|
|
6
|
+
import {
|
|
7
|
+
useKagentSessionSummary,
|
|
8
|
+
type KagentCount,
|
|
9
|
+
type KagentCredential,
|
|
10
|
+
type KagentFinding,
|
|
11
|
+
type KagentImpact,
|
|
12
|
+
type KagentReading,
|
|
13
|
+
type KagentRef,
|
|
14
|
+
type KagentSessionRow,
|
|
15
|
+
} from '../../api/kagent'
|
|
16
|
+
import { useSubstrateStatus } from '../../api/substrateWorkspace'
|
|
17
|
+
import { issueReasonTitle } from '@skyhook-io/k8s-ui/components/issues'
|
|
18
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
19
|
+
import { coverageLabel, INCOMPLETE_COVERAGE_STATES, type WorkspaceKindCoverage } from '../workspace/coverage'
|
|
20
|
+
import { GrantText, Notice, ScreenEmptyState, Sub } from '../workspace/layout'
|
|
21
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
22
|
+
import { tierReading } from '../substrate/readings'
|
|
23
|
+
import { sessionsFailure } from './KagentAgentSessions'
|
|
24
|
+
import { KAGENT_GENERIC_AGENTS_PATH, kagentPath } from './routes'
|
|
25
|
+
|
|
26
|
+
export const refKey = (ref: KagentRef) => `${ref.kind}/${ref.namespace}/${ref.name}`
|
|
27
|
+
export const refName = (ref: Pick<KagentRef, 'namespace' | 'name'>) => `${ref.namespace}/${ref.name}`
|
|
28
|
+
export const revisionText = (revision: string | undefined) => shortRevision(revision) || 'No revision prepared'
|
|
29
|
+
export const countText = (count: KagentCount) => `${count.lowerBound ? '≥' : ''}${count.n.toLocaleString('en-US')}`
|
|
30
|
+
export const changeText = (state: string) =>
|
|
31
|
+
({
|
|
32
|
+
prepared: 'Prepared',
|
|
33
|
+
preparing: 'Processing',
|
|
34
|
+
blocked: 'Blocked',
|
|
35
|
+
failed: 'Failed',
|
|
36
|
+
notProcessed: 'Not yet processed',
|
|
37
|
+
notReported: 'Not reported',
|
|
38
|
+
notReady: 'Not ready',
|
|
39
|
+
deleting: 'Deleting',
|
|
40
|
+
unknown: 'Unknown',
|
|
41
|
+
})[state] ?? 'Unknown'
|
|
42
|
+
export const roleText = (role: string) =>
|
|
43
|
+
({
|
|
44
|
+
model: 'Agent model',
|
|
45
|
+
subagentModel: 'Subagent model',
|
|
46
|
+
summarizer: 'Summarizer',
|
|
47
|
+
embedding: 'Embedding',
|
|
48
|
+
mcpServer: 'MCP server',
|
|
49
|
+
subagentMcpServer: 'Subagent MCP server',
|
|
50
|
+
template: 'Template',
|
|
51
|
+
subagentTemplate: 'Subagent template',
|
|
52
|
+
harness: 'Harness',
|
|
53
|
+
workerPool: 'Worker pool',
|
|
54
|
+
egressPolicy: 'Egress policy',
|
|
55
|
+
systemPrompt: 'System prompt',
|
|
56
|
+
promptSource: 'Prompt source',
|
|
57
|
+
outputSchema: 'Output schema',
|
|
58
|
+
})[role] ?? role
|
|
59
|
+
export const effectText = (effect: string) =>
|
|
60
|
+
effect === 'blocked' ? 'blocked (first reported cause)' : effect === 'mayRunWithoutTools' ? 'may run without its tools' : 'uses it'
|
|
61
|
+
|
|
62
|
+
export function KagentCountValue({ count }: { count: KagentCount }) {
|
|
63
|
+
return (
|
|
64
|
+
<span className="inline-flex items-center gap-1">
|
|
65
|
+
{count.lowerBound && <CertaintyGlyph certainty="lower_bound" />}
|
|
66
|
+
{count.n.toLocaleString('en-US')}
|
|
67
|
+
</span>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
export function KagentName({ object, onOpen }: { object: KagentRef; onOpen?: (ref: KagentRef) => void }) {
|
|
71
|
+
const navigate = useWorkspaceNavigate()
|
|
72
|
+
const { connection } = useConnection()
|
|
73
|
+
const path = kagentPath(object, connection.context)
|
|
74
|
+
return (
|
|
75
|
+
<TruncatedText text={object.name}>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
onClick={(e) => {
|
|
79
|
+
e.stopPropagation()
|
|
80
|
+
if (onOpen) onOpen(object)
|
|
81
|
+
else if (path) navigate(path)
|
|
82
|
+
}}
|
|
83
|
+
className="text-left font-mono text-xs text-accent-text hover:underline"
|
|
84
|
+
>
|
|
85
|
+
{object.name}
|
|
86
|
+
</button>
|
|
87
|
+
</TruncatedText>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
export function Reading({
|
|
91
|
+
reading,
|
|
92
|
+
text,
|
|
93
|
+
}: {
|
|
94
|
+
reading: Pick<KagentReading, 'state' | 'text' | 'tone' | 'condition' | 'summary'>
|
|
95
|
+
text?: string
|
|
96
|
+
}) {
|
|
97
|
+
const fact = {
|
|
98
|
+
text: text ?? reading.text,
|
|
99
|
+
tone: reading.tone,
|
|
100
|
+
source: `kagent${reading.condition ? ` · ${reading.condition}` : ''}`,
|
|
101
|
+
detail: reading.summary,
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
<div className="inline-flex max-w-full items-baseline gap-1.5">
|
|
105
|
+
<StatusDot tone={reading.tone} />
|
|
106
|
+
<div>
|
|
107
|
+
<FactValue fact={fact} />
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
export function ModelCredentialText({ spec, namespace }: { spec: Record<string, any>; namespace: string }) {
|
|
113
|
+
const credential: KagentCredential = spec.apiKeySecret
|
|
114
|
+
? { mode: 'apiKeySecret', secret: { group: '', kind: 'Secret', namespace, name: spec.apiKeySecret }, key: spec.apiKeySecretKey }
|
|
115
|
+
: { mode: 'actorJwt' in spec ? 'actorJwt' : spec.tokenPassthrough === true ? 'tokenPassthrough' : 'none' }
|
|
116
|
+
return <CredentialText credential={credential} />
|
|
117
|
+
}
|
|
118
|
+
export function CredentialText({ credential, stacked }: { credential: KagentCredential; stacked?: boolean }) {
|
|
119
|
+
if (credential.secret) {
|
|
120
|
+
const secret = refName(credential.secret)
|
|
121
|
+
const key = credential.key ? `key ${credential.key}` : 'key not named'
|
|
122
|
+
return stacked ? (
|
|
123
|
+
<div className="break-words font-mono text-xs">
|
|
124
|
+
{secret}
|
|
125
|
+
<Sub>{key}</Sub>
|
|
126
|
+
</div>
|
|
127
|
+
) : (
|
|
128
|
+
<span className="break-words font-mono text-xs">{secret} · {key}</span>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
return (
|
|
132
|
+
<span>
|
|
133
|
+
{{
|
|
134
|
+
actorJwt: 'Actor identity',
|
|
135
|
+
tokenPassthrough: 'Token passthrough',
|
|
136
|
+
none: 'No credential declared',
|
|
137
|
+
}[credential.mode] ?? credential.mode}
|
|
138
|
+
</span>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
export function consumersText(impact: KagentImpact) {
|
|
142
|
+
if (impact.consumers === 'noneSeen') return 'No Agent consumers seen in what Radar can read'
|
|
143
|
+
if (impact.consumers === 'none') return 'No Agent uses it — may be staged'
|
|
144
|
+
return `${impact.lowerBound ? '≥' : ''}${impact.count} ${impact.count === 1 && !impact.lowerBound ? 'Agent' : 'Agents'}`
|
|
145
|
+
}
|
|
146
|
+
export function CoverageNotice({ coverage }: { coverage: Record<string, WorkspaceKindCoverage> }) {
|
|
147
|
+
const gaps = Object.entries(coverage).filter(([, c]) => INCOMPLETE_COVERAGE_STATES.has(c.state))
|
|
148
|
+
if (!gaps.length) return null
|
|
149
|
+
const resources: Record<string, string> = {
|
|
150
|
+
agents: 'agents',
|
|
151
|
+
agentTemplates: 'agenttemplates',
|
|
152
|
+
harnesses: 'harnesses',
|
|
153
|
+
models: 'modelconfigs',
|
|
154
|
+
mcpServers: 'remotemcpservers',
|
|
155
|
+
egressPolicies: 'egresspolicies',
|
|
156
|
+
modelProviders: 'modelproviderconfigs',
|
|
157
|
+
sandboxTemplates: 'sandboxtemplates',
|
|
158
|
+
}
|
|
159
|
+
return (
|
|
160
|
+
<Notice>
|
|
161
|
+
<p>Radar could not read every kagent object. Counts are lower bounds in what Radar can read.</p>
|
|
162
|
+
<ul className="mt-1 space-y-1">
|
|
163
|
+
{gaps.map(([key, c]) => (
|
|
164
|
+
<li key={key}>
|
|
165
|
+
{resources[key]}: {coverageLabel(c)}
|
|
166
|
+
{c.state === 'denied' && (
|
|
167
|
+
<>
|
|
168
|
+
. Needs{' '}
|
|
169
|
+
<GrantText
|
|
170
|
+
grant={{
|
|
171
|
+
verb: 'list',
|
|
172
|
+
resource: resources[key],
|
|
173
|
+
group: 'api.kagent.dev',
|
|
174
|
+
...(c.deniedNamespaces?.length === 1 ? { namespace: c.deniedNamespaces[0] } : {}),
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
</>
|
|
178
|
+
)}
|
|
179
|
+
</li>
|
|
180
|
+
))}
|
|
181
|
+
</ul>
|
|
182
|
+
</Notice>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
export function findingProblem(finding: KagentFinding, readingsByRef?: ReadonlyMap<string, KagentReading>): WorkspaceProblem {
|
|
186
|
+
const reading = readingsByRef?.get(refKey(finding.subject))
|
|
187
|
+
const affected = finding.affects
|
|
188
|
+
const impact = affected?.count === 0 ? ` ${consumersText(affected)}.` : ''
|
|
189
|
+
const readings: Record<string, string> = {
|
|
190
|
+
KagentToolDiscoveryFailed: "kagent's controller can't discover this server's tools; sessions may run without them.",
|
|
191
|
+
KagentAPIKeySecretMissing: 'kagent cannot resolve the API key Secret or key this model names.',
|
|
192
|
+
KagentModelConfigRejected: "kagent did not accept this model's configuration.",
|
|
193
|
+
KagentModelConfigReferenceMissing: 'kagent could not resolve a Secret or ConfigMap this model names.',
|
|
194
|
+
KagentNoPreparedRevision: 'No revision has been prepared, so no session can start.',
|
|
195
|
+
KagentChangeBlocked: 'kagent could not prepare the latest change. New sessions still use the last prepared revision.',
|
|
196
|
+
KagentChangeFailed: 'kagent failed to prepare the latest change. New sessions still use the last prepared revision.',
|
|
197
|
+
KagentEgressNotApplied: 'The declared egress grants were not applied. Sessions may run without them.',
|
|
198
|
+
}
|
|
199
|
+
const detail =
|
|
200
|
+
readings[finding.reason] ??
|
|
201
|
+
(finding.reason.startsWith('KagentDependency') ? finding.message : 'kagent reported a problem with this configuration.')
|
|
202
|
+
return {
|
|
203
|
+
id: finding.id,
|
|
204
|
+
category: finding.reason,
|
|
205
|
+
source: 'reading',
|
|
206
|
+
tone: finding.severity === 'critical' ? 'unhealthy' : 'alert',
|
|
207
|
+
subject: finding.subject,
|
|
208
|
+
title:
|
|
209
|
+
finding.reason === 'KagentDependencyMissing'
|
|
210
|
+
? 'Declared dependency missing'
|
|
211
|
+
: finding.reason === 'KagentDependencyNotPermitted'
|
|
212
|
+
? 'Reference not permitted'
|
|
213
|
+
: (issueReasonTitle(finding.reason) ?? finding.subject.kind + ' needs attention'),
|
|
214
|
+
detail: detail + impact,
|
|
215
|
+
nextStep: finding.action,
|
|
216
|
+
rawDetail: finding.reason.startsWith('KagentDependency') ? undefined : (reading?.message ?? finding.message),
|
|
217
|
+
rawDetailLabel: "kagent's message",
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export function KagentGate({
|
|
221
|
+
support,
|
|
222
|
+
checking = true,
|
|
223
|
+
loading,
|
|
224
|
+
error,
|
|
225
|
+
installed,
|
|
226
|
+
children,
|
|
227
|
+
}: {
|
|
228
|
+
support: string
|
|
229
|
+
checking?: boolean
|
|
230
|
+
loading: boolean
|
|
231
|
+
error?: unknown
|
|
232
|
+
installed?: boolean
|
|
233
|
+
children: ReactNode
|
|
234
|
+
}) {
|
|
235
|
+
const navigate = useWorkspaceNavigate()
|
|
236
|
+
if ((support === 'unknown' && checking) || (support === 'supported' && (loading || isStillLoadingError(error))))
|
|
237
|
+
return <PaneLoader label="Reading kagent configuration…" className="flex-1" />
|
|
238
|
+
if (support !== 'supported')
|
|
239
|
+
return (
|
|
240
|
+
<ScreenEmptyState
|
|
241
|
+
icon={Bot}
|
|
242
|
+
title={support === 'unknown' ? 'Could not check kagent workspace support' : 'kagent workspace needs a newer Radar'}
|
|
243
|
+
detail="This Radar keeps the existing Agents list and drawer."
|
|
244
|
+
action={
|
|
245
|
+
<button type="button" onClick={() => navigate(KAGENT_GENERIC_AGENTS_PATH)} className="btn-secondary mt-3 px-3 py-1.5 text-sm">
|
|
246
|
+
Open Agents
|
|
247
|
+
</button>
|
|
248
|
+
}
|
|
249
|
+
/>
|
|
250
|
+
)
|
|
251
|
+
if (error)
|
|
252
|
+
return <ScreenEmptyState icon={Bot} title="Could not read kagent" detail={error instanceof Error ? error.message : 'Try refreshing.'} />
|
|
253
|
+
if (installed === false)
|
|
254
|
+
return <ScreenEmptyState icon={Bot} title="kagent is not installed" detail="This cluster serves no api.kagent.dev resources." />
|
|
255
|
+
return <>{children}</>
|
|
256
|
+
}
|
|
257
|
+
export function useKagentRuntime(namespaces: string[], enabled = true) {
|
|
258
|
+
const feature = useRadarFeature('kagentWorkspace')
|
|
259
|
+
const status = useSubstrateStatus(enabled && feature.support === 'supported')
|
|
260
|
+
const summary = useKagentSessionSummary(namespaces, enabled && status.data?.apiTier.state === 'connected')
|
|
261
|
+
const { hasNextPage, isFetchingNextPage, isFetchNextPageError, fetchNextPage } = summary
|
|
262
|
+
const pageCount = summary.data?.pages.length
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (enabled && status.data?.apiTier.state === 'connected' && hasNextPage && !isFetchingNextPage && !isFetchNextPageError)
|
|
265
|
+
void fetchNextPage()
|
|
266
|
+
}, [enabled, status.data?.apiTier.state, hasNextPage, isFetchingNextPage, isFetchNextPageError, pageCount, fetchNextPage])
|
|
267
|
+
const currentTier = status.data?.apiTier
|
|
268
|
+
const pages = currentTier && currentTier.state !== 'connected' ? undefined : summary.data?.pages
|
|
269
|
+
const rows = [...new Map((pages?.flatMap((p) => p.rows) ?? []).map((row) => [`${row.agent.namespace}/${row.agent.name}`, row])).values()]
|
|
270
|
+
const tier = currentTier && currentTier.state !== 'connected' ? currentTier : (pages?.[0].apiTier ?? currentTier)
|
|
271
|
+
const unavailable =
|
|
272
|
+
feature.support === 'unsupported'
|
|
273
|
+
? 'Sessions need a newer Radar in this cluster.'
|
|
274
|
+
: feature.support === 'unknown'
|
|
275
|
+
? feature.upgrade
|
|
276
|
+
? 'Session support could not be checked.'
|
|
277
|
+
: 'Checking session support…'
|
|
278
|
+
: tier && tier.state !== 'connected'
|
|
279
|
+
? (() => {
|
|
280
|
+
const r = tierReading(tier)
|
|
281
|
+
return `${r.title}${r.detail ? `: ${r.detail}` : ''}`
|
|
282
|
+
})()
|
|
283
|
+
: summary.error || status.error
|
|
284
|
+
? sessionsFailure(summary.error ?? status.error, {
|
|
285
|
+
namespace: namespaces.join(', ') || 'this scope',
|
|
286
|
+
name: '',
|
|
287
|
+
})
|
|
288
|
+
: 'Reading sessions from Substrate…'
|
|
289
|
+
const completePage = !!pages && !summary.hasNextPage && !summary.isFetchNextPageError
|
|
290
|
+
return {
|
|
291
|
+
query: summary,
|
|
292
|
+
rows,
|
|
293
|
+
tier,
|
|
294
|
+
unavailable,
|
|
295
|
+
completePage,
|
|
296
|
+
lowerBound: !completePage || !!pages?.some((p) => p.lowerBound),
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
export type KagentRuntime = ReturnType<typeof useKagentRuntime>
|
|
300
|
+
export function SessionValue({ row, runtime }: { row?: KagentSessionRow; runtime: KagentRuntime }) {
|
|
301
|
+
if (!row)
|
|
302
|
+
return (
|
|
303
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
304
|
+
{runtime.completePage ? 'No summary for this Agent in what Radar could read.' : runtime.unavailable}
|
|
305
|
+
</span>
|
|
306
|
+
)
|
|
307
|
+
return (
|
|
308
|
+
<>
|
|
309
|
+
<KagentCountValue count={{ n: row.sessions.total, lowerBound: !row.complete }} />{' '}
|
|
310
|
+
{row.sessions.total === 1 && row.complete ? 'session' : 'sessions'}
|
|
311
|
+
<Sub>
|
|
312
|
+
<KagentCountValue count={{ n: row.crashed, lowerBound: !row.complete }} /> crashed
|
|
313
|
+
</Sub>
|
|
314
|
+
</>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function KagentRuntimeRead({ runtime }: { runtime: KagentRuntime }) {
|
|
319
|
+
const tier = runtime.tier
|
|
320
|
+
if (!tier?.readAt) return null
|
|
321
|
+
return (
|
|
322
|
+
<div className="space-y-1 text-xs text-theme-text-tertiary">
|
|
323
|
+
<FactValue
|
|
324
|
+
fact={{
|
|
325
|
+
text: 'Substrate snapshot',
|
|
326
|
+
tone: tier.lastError ? 'degraded' : 'neutral',
|
|
327
|
+
source: 'Substrate API',
|
|
328
|
+
at: tier.readAt,
|
|
329
|
+
detail: tier.readStartedAt ? `Read from ${tier.readStartedAt} to ${tier.readAt}` : undefined,
|
|
330
|
+
}}
|
|
331
|
+
/>
|
|
332
|
+
{tier.refreshing && !tier.lastError && <span> · refreshing…</span>}
|
|
333
|
+
{tier.lastError && <p>Last Substrate read failed: {tier.lastError.message}. Showing the previous snapshot.</p>}
|
|
334
|
+
</div>
|
|
335
|
+
)
|
|
336
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { beforeEach, expect, it, vi } from 'vitest'
|
|
3
|
+
import type { KagentSessionSummary } from '../../api/kagent'
|
|
4
|
+
import { connectedTier, counts } from '../substrate/substrate.fixtures'
|
|
5
|
+
import { useKagentRuntime, type KagentRuntime } from './shared'
|
|
6
|
+
|
|
7
|
+
const state = vi.hoisted(() => ({
|
|
8
|
+
pages: undefined as KagentSessionSummary[] | undefined,
|
|
9
|
+
hasNextPage: false,
|
|
10
|
+
isFetchNextPageError: false,
|
|
11
|
+
}))
|
|
12
|
+
vi.mock('../../api/client', async (original) => ({
|
|
13
|
+
...(await original<typeof import('../../api/client')>()),
|
|
14
|
+
useRadarFeature: () => ({ support: 'supported' }),
|
|
15
|
+
}))
|
|
16
|
+
vi.mock('../../api/substrateWorkspace', async (original) => ({
|
|
17
|
+
...(await original<typeof import('../../api/substrateWorkspace')>()),
|
|
18
|
+
useSubstrateStatus: () => ({ data: { apiTier: connectedTier } }),
|
|
19
|
+
}))
|
|
20
|
+
vi.mock('../../api/kagent', async (original) => ({
|
|
21
|
+
...(await original<typeof import('../../api/kagent')>()),
|
|
22
|
+
useKagentSessionSummary: () => ({
|
|
23
|
+
data: state.pages ? { pages: state.pages } : undefined,
|
|
24
|
+
hasNextPage: state.hasNextPage,
|
|
25
|
+
isFetchNextPageError: state.isFetchNextPageError,
|
|
26
|
+
}),
|
|
27
|
+
}))
|
|
28
|
+
|
|
29
|
+
function readRuntime() {
|
|
30
|
+
let result: KagentRuntime | undefined
|
|
31
|
+
function Probe() {
|
|
32
|
+
result = useKagentRuntime([])
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
renderToStaticMarkup(<Probe />)
|
|
36
|
+
return result!
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
state.hasNextPage = false
|
|
41
|
+
state.isFetchNextPageError = false
|
|
42
|
+
const rows: KagentSessionSummary['rows'] = Array.from({ length: 1001 }, (_, i) => ({
|
|
43
|
+
agent: { namespace: 'agents', name: `agent-${i}` },
|
|
44
|
+
revisions: [], sessions: counts({ suspended: 1 }), complete: true,
|
|
45
|
+
onEarlierRevisions: 0, needAttention: 0, attention: [], hintedEarlierRevisions: 0,
|
|
46
|
+
crashed: 0, onNewSessionsRevision: 1, onOtherRevisions: 0,
|
|
47
|
+
placement: { state: 'unknown', reading: 'Not read', pools: [], complete: false },
|
|
48
|
+
}))
|
|
49
|
+
const page: KagentSessionSummary = {
|
|
50
|
+
apiTier: connectedTier,
|
|
51
|
+
coverage: { actors: { state: 'full' }, templates: { state: 'full' }, workers: { state: 'full' }, atespaces: { state: 'full' } },
|
|
52
|
+
rows: rows.slice(0, 1000), total: 1001, limit: 1000, offset: 0, lowerBound: false,
|
|
53
|
+
}
|
|
54
|
+
state.pages = [page, { ...page, rows: rows.slice(1000), offset: 1000 }]
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('counts a completely read fleet across multiple pages without a lower-bound marker', () => {
|
|
58
|
+
const runtime = readRuntime()
|
|
59
|
+
expect(runtime.rows).toHaveLength(1001)
|
|
60
|
+
expect(runtime.rows.reduce((n, row) => n + row.sessions.total, 0)).toBe(1001)
|
|
61
|
+
expect(runtime.completePage).toBe(true)
|
|
62
|
+
expect(runtime.lowerBound).toBe(false)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('keeps server-reported partial coverage after every page loads', () => {
|
|
66
|
+
state.pages![1].lowerBound = true
|
|
67
|
+
expect(readRuntime().lowerBound).toBe(true)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it.each(['loading', 'failed', 'missing'])('keeps incomplete pagination a lower bound (%s)', (kind) => {
|
|
71
|
+
state.pages = kind === 'missing' ? undefined : state.pages!.slice(0, 1)
|
|
72
|
+
state.hasNextPage = kind === 'loading'
|
|
73
|
+
state.isFetchNextPageError = kind === 'failed'
|
|
74
|
+
const runtime = readRuntime()
|
|
75
|
+
expect(runtime.completePage).toBe(false)
|
|
76
|
+
expect(runtime.lowerBound).toBe(true)
|
|
77
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useLocation } from 'react-router-dom'
|
|
3
|
+
import { Bot } from 'lucide-react'
|
|
4
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import type { APIResource } from '../../types'
|
|
6
|
+
import { useCapabilities, useRadarFeature } from '../../api/client'
|
|
7
|
+
import { useKagentWorkspace } from '../../api/kagent'
|
|
8
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
9
|
+
import { AGENTS_SIDEBAR_CATEGORY } from '../workspace/sidebar'
|
|
10
|
+
import { KAGENT_AGENTS_PATH, KAGENT_AGENT_KIND, KAGENT_GENERIC_AGENTS_PATH, KAGENT_KINDS } from './routes'
|
|
11
|
+
|
|
12
|
+
export const KAGENT_SIDEBAR_SECTION = 'kagent'
|
|
13
|
+
export function kagentAgentsServed(apiResources: APIResource[] | undefined): boolean {
|
|
14
|
+
return !!apiResources?.some((r) => r.group === KAGENT_AGENT_KIND.group && r.name === KAGENT_AGENT_KIND.name)
|
|
15
|
+
}
|
|
16
|
+
export function useKagentSidebarWorkspace({
|
|
17
|
+
apiResources,
|
|
18
|
+
namespaces = [],
|
|
19
|
+
}: {
|
|
20
|
+
apiResources: APIResource[] | undefined
|
|
21
|
+
namespaces?: string[]
|
|
22
|
+
}): Record<string, SidebarCategoryWorkspace> | undefined {
|
|
23
|
+
const navigate = useWorkspaceNavigate()
|
|
24
|
+
const location = useLocation()
|
|
25
|
+
const served = kagentAgentsServed(apiResources)
|
|
26
|
+
const feature = useRadarFeature('kagentWorkspace')
|
|
27
|
+
const { isPending: checking } = useCapabilities()
|
|
28
|
+
const workspace = useKagentWorkspace(namespaces, served)
|
|
29
|
+
const ready = feature.support === 'supported'
|
|
30
|
+
return useMemo(() => {
|
|
31
|
+
if (!served || checking && feature.support === 'unknown') return undefined
|
|
32
|
+
const count = workspace.data?.counts.findings
|
|
33
|
+
const destination = (id: string, label: string, path: string, kind?: typeof KAGENT_AGENT_KIND) => ({
|
|
34
|
+
id: `kagent-${id}`,
|
|
35
|
+
label,
|
|
36
|
+
section: KAGENT_SIDEBAR_SECTION,
|
|
37
|
+
active: location.pathname === path,
|
|
38
|
+
kind,
|
|
39
|
+
onSelect: () => navigate(path),
|
|
40
|
+
})
|
|
41
|
+
return {
|
|
42
|
+
[AGENTS_SIDEBAR_CATEGORY]: {
|
|
43
|
+
tools: 'kagent',
|
|
44
|
+
icon: Bot,
|
|
45
|
+
count: ready ? (count ? (count.n === 0 && count.lowerBound ? null : count.n) : null) : undefined,
|
|
46
|
+
countLowerBound: ready ? (count?.lowerBound ?? true) : undefined,
|
|
47
|
+
countTitle: ready ? 'Configuration findings; runtime crashes and pool capacity are counted by Agent Substrate.' : undefined,
|
|
48
|
+
destinations: ready
|
|
49
|
+
? [
|
|
50
|
+
destination('overview', 'Overview', '/kagent'),
|
|
51
|
+
destination('agents', 'Agents', KAGENT_AGENTS_PATH, KAGENT_AGENT_KIND),
|
|
52
|
+
destination('mcpservers', 'MCP servers', '/kagent/mcpservers', {
|
|
53
|
+
name: 'remotemcpservers',
|
|
54
|
+
kind: KAGENT_KINDS.remotemcpservers.kind,
|
|
55
|
+
group: KAGENT_AGENT_KIND.group,
|
|
56
|
+
}),
|
|
57
|
+
destination('models', 'Models', '/kagent/models', {
|
|
58
|
+
name: 'modelconfigs',
|
|
59
|
+
kind: KAGENT_KINDS.modelconfigs.kind,
|
|
60
|
+
group: KAGENT_AGENT_KIND.group,
|
|
61
|
+
}),
|
|
62
|
+
]
|
|
63
|
+
: [destination('agents', 'Agents', KAGENT_GENERIC_AGENTS_PATH, KAGENT_AGENT_KIND)],
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
}, [served, ready, feature.support, checking, workspace.data, location.pathname, navigate])
|
|
67
|
+
}
|