@skyhook-io/radar-app 1.22.2 → 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.
Files changed (196) hide show
  1. package/package.json +8 -8
  2. package/src/App.tsx +35 -10
  3. package/src/RadarApp.basename.test.tsx +177 -0
  4. package/src/RadarApp.settings.test.tsx +33 -0
  5. package/src/api/agentSandbox.ts +259 -0
  6. package/src/api/client.autoPromConnect.test.tsx +43 -0
  7. package/src/api/client.metricsRelayCheck.test.tsx +134 -0
  8. package/src/api/client.ts +122 -24
  9. package/src/api/cloudInstallDiscover.test.tsx +76 -0
  10. package/src/api/diagnose.ts +4 -0
  11. package/src/api/kagent.test.ts +82 -0
  12. package/src/api/kagent.ts +230 -0
  13. package/src/api/prometheusCharts.ts +5 -0
  14. package/src/api/radarFeatures.test.ts +9 -0
  15. package/src/api/radarFeatures.ts +13 -0
  16. package/src/api/substrateWorkspace.test.ts +72 -0
  17. package/src/api/substrateWorkspace.ts +1394 -0
  18. package/src/api/vulnerabilities.ts +207 -9
  19. package/src/api/workloadSource.test.tsx +315 -0
  20. package/src/api/workloadSource.ts +128 -12
  21. package/src/components/CloudConnectFlow.tsx +46 -7
  22. package/src/components/CloudFunnelButton.test.tsx +193 -7
  23. package/src/components/CloudFunnelButton.tsx +127 -32
  24. package/src/components/SelfManagedStart.tsx +12 -2
  25. package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
  26. package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
  27. package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
  28. package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
  29. package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
  30. package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
  31. package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
  32. package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
  33. package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
  34. package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
  35. package/src/components/agentsandbox/data.ts +135 -0
  36. package/src/components/agentsandbox/host.test.ts +27 -0
  37. package/src/components/agentsandbox/host.tsx +85 -0
  38. package/src/components/agentsandbox/labels.test.ts +42 -0
  39. package/src/components/agentsandbox/labels.ts +146 -0
  40. package/src/components/agentsandbox/listFilters.ts +85 -0
  41. package/src/components/agentsandbox/lists.ts +52 -0
  42. package/src/components/agentsandbox/routes.ts +23 -0
  43. package/src/components/agentsandbox/shared.tsx +321 -0
  44. package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
  45. package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
  46. package/src/components/agentsandbox/workspace.tsx +258 -0
  47. package/src/components/agentsandbox/workspaceRoute.ts +18 -0
  48. package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
  49. package/src/components/applications/ApplicationsView.tsx +156 -3
  50. package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
  51. package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
  52. package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
  53. package/src/components/audit/VulnerabilitiesView.tsx +639 -199
  54. package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
  55. package/src/components/cloudHints/CloudHintLink.tsx +29 -0
  56. package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
  57. package/src/components/cloudHints/cloudHints.test.ts +126 -0
  58. package/src/components/cloudHints/cloudHints.ts +131 -0
  59. package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
  60. package/src/components/cloudHints/cloudLinks.test.ts +52 -0
  61. package/src/components/cloudHints/cloudLinks.ts +31 -0
  62. package/src/components/cloudHints/hintStorage.ts +28 -0
  63. package/src/components/cnpg/CNPGView.tsx +4 -7
  64. package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
  65. package/src/components/diagnose/DiagnoseContext.tsx +7 -0
  66. package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
  67. package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
  68. package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
  69. package/src/components/home/HomeAgentBlock.tsx +2 -0
  70. package/src/components/home/HomeView.tsx +3 -3
  71. package/src/components/home/MCPSetupDialog.test.tsx +9 -0
  72. package/src/components/home/MCPSetupDialog.tsx +6 -2
  73. package/src/components/home/McpCloudLine.test.tsx +162 -0
  74. package/src/components/home/McpCloudLine.tsx +95 -0
  75. package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
  76. package/src/components/home/mcpToolCatalog.test.ts +10 -0
  77. package/src/components/home/mcpToolCatalog.ts +4 -4
  78. package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
  79. package/src/components/issues/IssuesPane.render.test.tsx +36 -1
  80. package/src/components/issues/IssuesPane.tsx +181 -23
  81. package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
  82. package/src/components/issues/SinceLastVisitRow.tsx +71 -0
  83. package/src/components/issues/sinceLastVisit.test.ts +266 -0
  84. package/src/components/issues/sinceLastVisit.ts +439 -0
  85. package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
  86. package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
  87. package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
  88. package/src/components/kagent/KagentAgentSessions.tsx +124 -0
  89. package/src/components/kagent/KagentDetailPage.tsx +106 -0
  90. package/src/components/kagent/KagentLists.tsx +412 -0
  91. package/src/components/kagent/KagentOverview.tsx +234 -0
  92. package/src/components/kagent/KagentPages.tsx +690 -0
  93. package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
  94. package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
  95. package/src/components/kagent/KagentSidebar.test.tsx +112 -0
  96. package/src/components/kagent/KagentView.tsx +109 -0
  97. package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
  98. package/src/components/kagent/host.tsx +144 -0
  99. package/src/components/kagent/routes.ts +31 -0
  100. package/src/components/kagent/shared.tsx +336 -0
  101. package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
  102. package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
  103. package/src/components/kagent/workspace.fixtures.ts +108 -0
  104. package/src/components/kagent/workspaceRoute.ts +18 -0
  105. package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
  106. package/src/components/resource/MetricsNotConnected.tsx +10 -7
  107. package/src/components/resource/PrometheusCharts.tsx +10 -1
  108. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
  109. package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
  110. package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
  111. package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
  112. package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
  113. package/src/components/resources/ResourcesView.tsx +2 -6
  114. package/src/components/resources/renderers/PodRenderer.tsx +8 -2
  115. package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
  116. package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
  117. package/src/components/settings/SettingsDialog.tsx +84 -16
  118. package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
  119. package/src/components/settings/SubstrateSettings.test.tsx +131 -0
  120. package/src/components/settings/SubstrateSettings.tsx +544 -0
  121. package/src/components/settings/settings-state.test.ts +21 -3
  122. package/src/components/settings/settings-state.ts +13 -3
  123. package/src/components/share/ShareLinkButton.test.tsx +360 -0
  124. package/src/components/share/ShareLinkButton.tsx +391 -0
  125. package/src/components/share/openShareInCloud.test.ts +29 -0
  126. package/src/components/share/openShareInCloud.ts +10 -0
  127. package/src/components/share/shareLink.test.ts +129 -0
  128. package/src/components/share/shareLink.ts +175 -0
  129. package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
  130. package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
  131. package/src/components/substrate/SubstrateActorPage.tsx +384 -0
  132. package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
  133. package/src/components/substrate/SubstrateActors.tsx +612 -0
  134. package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
  135. package/src/components/substrate/SubstrateConnect.tsx +88 -0
  136. package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
  137. package/src/components/substrate/SubstrateOverview.tsx +575 -0
  138. package/src/components/substrate/SubstratePages.test.tsx +478 -0
  139. package/src/components/substrate/SubstratePool.test.tsx +462 -0
  140. package/src/components/substrate/SubstratePoolPage.tsx +95 -0
  141. package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
  142. package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
  143. package/src/components/substrate/SubstrateStateBar.tsx +63 -0
  144. package/src/components/substrate/SubstrateTemplates.tsx +376 -0
  145. package/src/components/substrate/SubstrateView.tsx +173 -0
  146. package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
  147. package/src/components/substrate/SubstrateWorkers.tsx +389 -0
  148. package/src/components/substrate/attention.ts +81 -0
  149. package/src/components/substrate/contextPin.tsx +69 -0
  150. package/src/components/substrate/host.tsx +83 -0
  151. package/src/components/substrate/kubectlTarget.test.tsx +77 -0
  152. package/src/components/substrate/readings.test.ts +484 -0
  153. package/src/components/substrate/readings.ts +997 -0
  154. package/src/components/substrate/routes.ts +103 -0
  155. package/src/components/substrate/shared.tsx +426 -0
  156. package/src/components/substrate/substrate.fixtures.ts +325 -0
  157. package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
  158. package/src/components/substrate/workspaceRoute.ts +23 -0
  159. package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
  160. package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
  161. package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
  162. package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
  163. package/src/components/traffic/TrafficFlowList.tsx +9 -5
  164. package/src/components/traffic/TrafficGraph.test.tsx +26 -0
  165. package/src/components/traffic/TrafficGraph.tsx +17 -14
  166. package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
  167. package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
  168. package/src/components/traffic/TrafficView.tsx +26 -56
  169. package/src/components/traffic/trafficFilters.test.ts +61 -1
  170. package/src/components/traffic/trafficFilters.ts +68 -8
  171. package/src/components/velero/VeleroOverview.tsx +2 -2
  172. package/src/components/velero/VeleroView.tsx +3 -6
  173. package/src/components/vulnerabilities/columns.tsx +132 -0
  174. package/src/components/vulnerabilities/filters.tsx +317 -0
  175. package/src/components/vulnerabilities/owner.test.ts +54 -0
  176. package/src/components/vulnerabilities/owner.tsx +163 -0
  177. package/src/components/vulnerabilities/parts.test.ts +126 -12
  178. package/src/components/vulnerabilities/parts.tsx +612 -52
  179. package/src/components/vulnerabilities/traffic.test.tsx +65 -0
  180. package/src/components/vulnerabilities/traffic.tsx +40 -0
  181. package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
  182. package/src/components/workload/WorkloadView.tsx +52 -13
  183. package/src/components/workspace/layout.tsx +13 -7
  184. package/src/components/workspace/sidebar.test.ts +48 -0
  185. package/src/components/workspace/sidebar.ts +73 -3
  186. package/src/components/workspace/table.ts +2 -1
  187. package/src/contexts/RegistryAccessMode.test.tsx +51 -0
  188. package/src/contexts/RegistryAccessMode.tsx +25 -0
  189. package/src/integrations/resourceHost.ts +12 -6
  190. package/src/integrations/resourceHosts.test.tsx +27 -1
  191. package/src/integrations/resourceHosts.tsx +15 -7
  192. package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
  193. package/src/integrations/sidebarWorkspaces.ts +41 -0
  194. package/src/integrations/workspaceRoute.ts +1 -1
  195. package/src/integrations/workspaceRoutes.ts +7 -1
  196. package/src/integrations/workspaceScreens.tsx +6 -0
@@ -0,0 +1,412 @@
1
+ import { useState } from 'react'
2
+ import { Input, Tooltip } from '@skyhook-io/k8s-ui'
3
+ import { useSearchParams } from 'react-router-dom'
4
+ import { GrantText, Segments, SectionTable, Sub, type TableColumn } from '../workspace/layout'
5
+ import { coverageEmpty, type WorkspaceKindCoverage } from '../workspace/coverage'
6
+ import { useMediaQuery } from '../../hooks/useMediaQuery'
7
+ import type { KagentAgent, KagentMCPServer, KagentModel, KagentReading, KagentRef, KagentWorkspace } from '../../api/kagent'
8
+ import {
9
+ changeText,
10
+ consumersText,
11
+ countText,
12
+ CredentialText,
13
+ KagentName,
14
+ Reading,
15
+ refKey,
16
+ revisionText,
17
+ roleText,
18
+ SessionValue,
19
+ type KagentRuntime,
20
+ } from './shared'
21
+
22
+ export function KagentAgentsTable({
23
+ data,
24
+ runtime,
25
+ onOpen,
26
+ overview = false,
27
+ }: {
28
+ overview?: boolean
29
+ data: KagentWorkspace
30
+ runtime: KagentRuntime
31
+ onOpen: (ref: KagentRef) => void
32
+ }) {
33
+ const [params] = useSearchParams()
34
+ const [search, setSearch] = useState('')
35
+ const problemAgents = new Set(data.findings.flatMap((f) => [refKey(f.subject), ...(f.affects?.agents.map((a) => refKey(a.agent)) ?? [])]))
36
+ const subjects = new Set(data.findings.map(f => refKey(f.subject)))
37
+ for (const agent of data.agents) {
38
+ if (agent.references.some(r => subjects.has(refKey(r.target)))) problemAgents.add(refKey(agent.ref))
39
+ }
40
+ const isProblem = (a: KagentAgent) => problemAgents.has(refKey(a.ref))
41
+ const scoped = data.agents.filter((a) => overview || matchesSearch(search, a.ref.name, a.ref.namespace, a.model?.ref.name))
42
+ const problemRows = scoped.filter(isProblem)
43
+ const rows = overview || params.get('status') !== 'problems' ? scoped : problemRows
44
+ const wide = useMediaQuery('(min-width: 1280px)')
45
+ const sessionByAgent = new Map(runtime.rows.map((row) => [`${row.agent.namespace}/${row.agent.name}`, row]))
46
+ const session = (a: KagentAgent) => <SessionValue row={sessionByAgent.get(`${a.ref.namespace}/${a.ref.name}`)} runtime={runtime} />
47
+ const change = (a: KagentAgent) => <Reading reading={a.reading} text={changeText(a.latestChange.state)} />
48
+ const revision = (a: KagentAgent) => (
49
+ <span className={a.newSessionsRevision ? 'font-mono text-xs' : 'text-xs'}>{revisionText(a.newSessionsRevision)}</span>
50
+ )
51
+ const model = (a: KagentAgent) =>
52
+ a.model ? (
53
+ <>
54
+ <KagentName object={a.model.ref} onOpen={onOpen} />
55
+ <Sub>
56
+ {a.model.state === 'notPermitted' ? (
57
+ 'Not permitted by allowedNamespaces'
58
+ ) : a.model.state === 'unread' ? (
59
+ a.model.unread === 'denied' ? (
60
+ <>
61
+ Unread · needs{' '}
62
+ <GrantText grant={{ verb: 'list', resource: 'modelconfigs', group: a.model.ref.group, namespace: a.model.ref.namespace }} />
63
+ </>
64
+ ) : (
65
+ `Unread · ${a.model.unread}`
66
+ )
67
+ ) : a.model.reading ? (
68
+ modelStatus(a.model.reading)
69
+ ) : a.model.state === 'absent' ? (
70
+ 'Absent'
71
+ ) : (
72
+ 'Present'
73
+ )}
74
+ </Sub>
75
+ </>
76
+ ) : (
77
+ <span className="text-theme-text-tertiary">{a.incomplete ? 'Not fully read' : 'No model declared'}</span>
78
+ )
79
+ const servers = (a: KagentAgent) => (
80
+ <>
81
+ <span>
82
+ {a.incomplete ? '≥' : ''}
83
+ {a.mcpServers.declared} declared
84
+ {a.mcpServers.failing > 0 ? ` · ${a.mcpServers.failing} failing` : ''}
85
+ </span>
86
+ {a.mcpServers.unread > 0 && <Sub>{a.mcpServers.unread} unread</Sub>}
87
+ {a.mcpServers.absent > 0 && <Sub>{a.mcpServers.absent} absent</Sub>}
88
+ {a.mcpServers.notPermitted > 0 && <Sub>{a.mcpServers.notPermitted} not permitted</Sub>}
89
+ </>
90
+ )
91
+ const columns: TableColumn<KagentAgent>[] = [
92
+ {
93
+ header: 'Agent',
94
+ width: wide ? '20%' : '38%',
95
+ cell: (a) => (
96
+ <>
97
+ <KagentName object={a.ref} onOpen={onOpen} />
98
+ {a.description && <Sub>{a.description}</Sub>}
99
+ {!wide && (
100
+ <>
101
+ <Sub>{a.ref.namespace}</Sub>
102
+ <div className="mt-2">{change(a)}</div>
103
+ <Sub>New sessions: {revision(a)}</Sub>
104
+ <Sub>{session(a)}</Sub>
105
+ </>
106
+ )}
107
+ </>
108
+ ),
109
+ },
110
+ ...(wide
111
+ ? [
112
+ { header: 'Latest change', width: '14%', cell: change },
113
+ { header: 'New sessions run', width: '14%', cell: revision },
114
+ ]
115
+ : []),
116
+ { header: 'Model', width: wide ? '17%' : '34%', cell: model },
117
+ { header: 'MCP servers', width: wide ? '12%' : '28%', cell: servers },
118
+ ...(wide
119
+ ? [
120
+ { header: 'Sessions', width: '13%', cell: session },
121
+ {
122
+ header: 'Namespace',
123
+ width: '10%',
124
+ cell: (a: KagentAgent) => <span className="break-words text-xs">{a.ref.namespace}</span>,
125
+ },
126
+ ]
127
+ : []),
128
+ ]
129
+ return (
130
+ <div className="space-y-3">
131
+ {!overview && <ListToolbar noun="Agents" search={search} setSearch={setSearch} total={scoped.length} problems={problemRows.length} partial={data.counts.agents.lowerBound} />}
132
+ <SectionTable
133
+ title={overview ? 'Agents' : undefined}
134
+ subtitle="The latest change and the revision new sessions run are separate facts."
135
+ columns={columns}
136
+ rows={rows.sort((a, b) => Number(isProblem(b)) - Number(isProblem(a)))}
137
+ rowKey={(a) => refKey(a.ref)}
138
+ minWidth={0}
139
+ rowResource={(a) => a.ref}
140
+ onInspect={(r) => onOpen({ ...r, group: 'api.kagent.dev' })}
141
+ empty={searchEmpty(search, data.coverage.agents, 'Agents')}
142
+ />
143
+ </div>
144
+ )
145
+ }
146
+ export function mcpStatus(reading: Pick<KagentReading, 'state' | 'text'> & { previous?: { state: string } }, failing?: boolean) {
147
+ const lastState = (reading.previous ?? reading).state
148
+ const failed = failing ?? (lastState === 'failed' || lastState === 'notReady')
149
+ if (reading.state === 'stale') return failed ? 'Not processed · last discovery failed' : 'Latest change not processed'
150
+ if (reading.state === 'notReady') return 'Not accepted'
151
+ if (failed) return 'Discovery failed'
152
+ if (reading.state === 'ready') return 'Discovery OK'
153
+ if (reading.state === 'discoveryOff') return 'Discovery disabled'
154
+ return reading.state === 'notReported' ? 'Discovery not reported' : reading.text
155
+ }
156
+ export function modelStatus(reading: Pick<KagentModel['reading'], 'state' | 'reason' | 'condition' | 'text'>) {
157
+ if (reading.state === 'stale') return 'Latest change not processed'
158
+ if (reading.state === 'ready') return 'References resolved'
159
+ if (reading.reason === 'APIKeySecretNotFound') return 'API key Secret missing'
160
+ if (reading.reason === 'APIKeySecretKeyNotFound') return 'API key Secret key missing'
161
+ if (reading.condition === 'Accepted' && reading.state === 'failed') return 'Not accepted'
162
+ return reading.state === 'notReported' ? 'Not reported' : reading.text
163
+ }
164
+ export function KagentMCPServers({ data, onOpen }: { data: KagentWorkspace; onOpen: (ref: KagentRef) => void }) {
165
+ const [params] = useSearchParams()
166
+ const [search, setSearch] = useState('')
167
+ const problems = params.get('status') === 'problems'
168
+ const wide = useMediaQuery('(min-width: 1280px)')
169
+ const isProblem = (s: KagentMCPServer) => s.failing || !!s.askedNotOffered?.length
170
+ const scoped = data.mcpServers.filter((s) =>
171
+ matchesSearch(search, s.ref.name, s.ref.namespace, ...s.toolsOffered, ...(s.askedNotOffered ?? []).map((t) => t.tool)),
172
+ )
173
+ const problemRows = scoped.filter(isProblem)
174
+ return (
175
+ <div className="space-y-3">
176
+ <ListToolbar noun="MCP servers" search={search} setSearch={setSearch} total={scoped.length} problems={problemRows.length} partial={data.counts.mcpServers.lowerBound} />
177
+ <SectionTable
178
+ subtitle={
179
+ problems ? 'Showing servers with discovery problems.' : 'Controller discovery is separate from what a running session can reach.'
180
+ }
181
+ rows={(problems ? problemRows : scoped).sort((a, b) => Number(isProblem(b)) - Number(isProblem(a)))}
182
+ rowKey={(s) => refKey(s.ref)}
183
+ rowResource={(s) => s.ref}
184
+ onInspect={(r) => onOpen({ ...r, group: 'api.kagent.dev' })}
185
+ minWidth={0}
186
+ empty={searchEmpty(search, data.coverage.mcpServers, 'MCP servers')}
187
+ columns={[
188
+ {
189
+ header: 'MCP server',
190
+ width: wide ? '20%' : '27%',
191
+ cell: (s) => (
192
+ <>
193
+ <KagentName object={s.ref} onOpen={onOpen} />
194
+ {!wide && <Sub>{s.ref.namespace}</Sub>}
195
+ </>
196
+ ),
197
+ },
198
+ {
199
+ header: 'Status',
200
+ width: wide ? '22%' : '27%',
201
+ cell: (s) => (
202
+ <>
203
+ <Reading reading={s.reading} text={mcpStatus(s.reading, s.failing)} />
204
+ {!wide && <Sub>Used by: {<UsedByValue impact={s.usedBy} />}</Sub>}
205
+ </>
206
+ ),
207
+ },
208
+ {
209
+ header: 'Tools offered',
210
+ width: wide ? '10%' : '23%',
211
+ cell: (s) => (s.toolsOfferedKnown ? s.toolsOffered.length : <span className="text-theme-text-tertiary">Unknown</span>),
212
+ },
213
+ ...(wide
214
+ ? [
215
+ {
216
+ header: 'Used by',
217
+ width: '15%',
218
+ cell: (s: KagentMCPServer) => <UsedByValue impact={s.usedBy} />,
219
+ },
220
+ ]
221
+ : []),
222
+ {
223
+ header: 'Missing tools',
224
+ width: wide ? '21%' : '23%',
225
+ cell: (s) => {
226
+ if (!s.toolsOfferedKnown) return 'Unknown'
227
+ return s.askedNotOffered?.map((t) => t.tool).join(', ') || <Tooltip content="No requested tools were found missing"><span>—</span></Tooltip>
228
+ },
229
+ },
230
+ ...(wide
231
+ ? [
232
+ {
233
+ header: 'Namespace',
234
+ width: '12%',
235
+ cell: (s: KagentMCPServer) => <span className="break-words">{s.ref.namespace}</span>,
236
+ },
237
+ ]
238
+ : []),
239
+ ]}
240
+ />
241
+ </div>
242
+ )
243
+ }
244
+ export function KagentModels({ data, onOpen }: { data: KagentWorkspace; onOpen: (ref: KagentRef) => void }) {
245
+ const [params] = useSearchParams()
246
+ const [search, setSearch] = useState('')
247
+ const problems = params.get('status') === 'problems'
248
+ const credentialProblems = new Set(data.findings.map((f) => refKey(f.subject)))
249
+ const wide = useMediaQuery('(min-width: 1280px)')
250
+ const isProblem = (m: KagentModel) => credentialProblems.has(refKey(m.ref))
251
+ const scoped = data.models.filter((m) => matchesSearch(search, m.ref.name, m.ref.namespace, m.model, m.provider, m.credential.secret?.name))
252
+ const problemRows = scoped.filter(isProblem)
253
+ return (
254
+ <div className="space-y-3">
255
+ <ListToolbar noun="models" search={search} setSearch={setSearch} total={scoped.length} problems={problemRows.length} partial={data.counts.models.lowerBound} />
256
+ <SectionTable
257
+ subtitle={
258
+ problems
259
+ ? 'Showing models with credential problems.'
260
+ : 'Credential references name Secrets and keys; Radar never reads their values.'
261
+ }
262
+ rows={(problems ? problemRows : scoped).sort((a, b) => Number(isProblem(b)) - Number(isProblem(a)))}
263
+ rowKey={(m) => refKey(m.ref)}
264
+ rowResource={(m) => m.ref}
265
+ onInspect={(r) => onOpen({ ...r, group: 'api.kagent.dev' })}
266
+ minWidth={0}
267
+ empty={searchEmpty(search, data.coverage.models, 'models')}
268
+ columns={[
269
+ {
270
+ header: 'ModelConfig',
271
+ width: wide ? '20%' : '38%',
272
+ cell: (m) => (
273
+ <>
274
+ <KagentName object={m.ref} onOpen={onOpen} />
275
+ {!wide && (
276
+ <>
277
+ <Sub>{m.ref.namespace}</Sub>
278
+ <Sub>
279
+ {m.provider || 'Provider not reported'} · {m.model || 'Model not reported'}
280
+ </Sub>
281
+ <Sub>Used by: {<UsedByValue impact={m.usedBy} />}</Sub>
282
+ </>
283
+ )}
284
+ </>
285
+ ),
286
+ },
287
+ {
288
+ header: 'Status',
289
+ width: wide ? '18%' : '27%',
290
+ cell: (m) => <Reading reading={m.reading} text={modelStatus(m.reading)} />,
291
+ },
292
+ ...(wide
293
+ ? [
294
+ {
295
+ header: 'Provider / Model',
296
+ width: '17%',
297
+ cell: (m: KagentModel) => (
298
+ <>
299
+ {m.provider || 'Not reported'}
300
+ <Sub>{m.model || 'Not reported'}</Sub>
301
+ </>
302
+ ),
303
+ },
304
+ ]
305
+ : []),
306
+ {
307
+ header: 'Credential reference',
308
+ width: wide ? '20%' : '35%',
309
+ cell: (m) => <CredentialText credential={m.credential} stacked />,
310
+ },
311
+ ...(wide
312
+ ? [
313
+ {
314
+ header: 'Used by',
315
+ width: '15%',
316
+ cell: (m: KagentModel) => {
317
+ const roles = Object.entries(m.usedBy.byRole ?? {})
318
+ const redundant = roles.length === 1 && roles[0][0] === 'model' && roles[0][1] === m.usedBy.count
319
+ return (
320
+ <>
321
+ <UsedByValue impact={m.usedBy} />
322
+ {roles.length > 0 && !redundant && <Sub>
323
+ {roles.map(([r, n]) => `${roleText(r)}: ${m.usedBy.lowerBound ? '≥' : ''}${n}`).join(' · ')}
324
+ </Sub>}
325
+ </>
326
+ )
327
+ },
328
+ },
329
+ {
330
+ header: 'Namespace',
331
+ width: '10%',
332
+ cell: (m: KagentModel) => <span className="break-words">{m.ref.namespace}</span>,
333
+ },
334
+ ]
335
+ : []),
336
+ ]}
337
+ />
338
+ <SectionTable
339
+ title="Model providers"
340
+ subtitle="kagent 1.0.1 does not report ModelProviderConfig status."
341
+ rows={data.modelProviders}
342
+ rowKey={(p) => refKey(p.ref)}
343
+ rowResource={(p) => p.ref}
344
+ onInspect={(r) => onOpen({ ...r, group: 'api.kagent.dev' })}
345
+ minWidth={0}
346
+ empty={coverageEmpty(data.coverage.modelProviders, 'ModelProviderConfigs')}
347
+ columns={[
348
+ { header: 'ModelProviderConfig', cell: (p) => p.ref.name },
349
+ { header: 'Provider', cell: (p) => p.provider || 'Not reported' },
350
+ {
351
+ header: 'Status',
352
+ cell: (p) => (p.reading.state === 'notReported' ? 'Not reported' : p.reading.text),
353
+ },
354
+ { header: 'Namespace', cell: (p) => p.ref.namespace },
355
+ ]}
356
+ />
357
+ </div>
358
+ )
359
+ }
360
+
361
+ function matchesSearch(search: string, ...fields: (string | undefined)[]) {
362
+ const query = search.trim().toLowerCase()
363
+ return !query || fields.some((field) => field?.toLowerCase().includes(query))
364
+ }
365
+
366
+ function searchEmpty(search: string, coverage: WorkspaceKindCoverage, noun: string) {
367
+ if (!search.trim()) return coverageEmpty(coverage, noun)
368
+ if (coverage.state === 'full') return `No ${noun} match your search.`
369
+ if (coverage.state === 'partial') return `No ${noun} match in what Radar could read.`
370
+ return coverageEmpty(coverage, noun)
371
+ }
372
+
373
+ function ListToolbar({ noun, search, setSearch, total, problems, partial }: {
374
+ noun: string
375
+ search: string
376
+ setSearch: (search: string) => void
377
+ total: number
378
+ problems: number
379
+ partial: boolean
380
+ }) {
381
+ const [params, setParams] = useSearchParams()
382
+ const label = `Search ${noun}`
383
+ const count = (n: number) => partial && n === 0 ? undefined : countText({ n, lowerBound: partial })
384
+ return (
385
+ <div className="flex flex-wrap items-center gap-2">
386
+ <Segments
387
+ label="Show kagent resources"
388
+ value={params.get('status') === 'problems' ? 'problems' : 'all'}
389
+ options={[
390
+ { id: 'all', label: 'All', count: count(total) },
391
+ { id: 'problems', label: 'Problems', count: count(problems) },
392
+ ]}
393
+ onChange={(value) => {
394
+ const next = new URLSearchParams(params)
395
+ if (value === 'all') next.delete('status')
396
+ else next.set('status', value)
397
+ setParams(next, { replace: true })
398
+ }}
399
+ />
400
+ <Input aria-label={label} placeholder={`${label}…`} value={search} onChange={(e) => setSearch(e.target.value)} className="h-8 max-w-52 rounded-md border border-theme-border bg-theme-elevated px-3" />
401
+ </div>
402
+ )
403
+ }
404
+ function UsedByValue({ impact }: { impact: import('../../api/kagent').KagentImpact }) {
405
+ return impact.consumers === 'none' ? (
406
+ <Tooltip content="No Agent uses it">
407
+ <span className="text-theme-text-tertiary">—</span>
408
+ </Tooltip>
409
+ ) : (
410
+ <>{consumersText(impact)}</>
411
+ )
412
+ }
@@ -0,0 +1,234 @@
1
+ import { Link, useLocation } from 'react-router-dom'
2
+ import { FoldSection, WorkspaceProblemCallout, toneTextClass } from '@skyhook-io/k8s-ui'
3
+ import type { KagentRef, KagentWorkspace } from '../../api/kagent'
4
+ import { useRadarFeature } from '../../api/client'
5
+ import { withCrossViewParams } from '../../utils/navigation'
6
+ import { substrateActorsPath } from '../substrate/routes'
7
+ import { KagentAgentsTable } from './KagentLists'
8
+ import {
9
+ countText,
10
+ changeText,
11
+ findingProblem,
12
+ KagentCountValue,
13
+ KagentName,
14
+ consumersText,
15
+ effectText,
16
+ refKey,
17
+ refName,
18
+ KagentRuntimeRead,
19
+ type KagentRuntime,
20
+ } from './shared'
21
+
22
+ function messagePreview(line: string) {
23
+ const limit = 160
24
+ if (line.length <= limit) return line
25
+
26
+ const headLimit = 64
27
+ const separator = ' … '
28
+ const head = line.slice(0, headLimit)
29
+ const tail = line.slice(-(limit - headLimit - separator.length))
30
+ const headBoundary = head.lastIndexOf(': ')
31
+ const tailBoundary = tail.indexOf(': ')
32
+ const start = headBoundary >= 24 ? head.slice(0, headBoundary) : head
33
+ const end = tailBoundary >= 0 && tailBoundary < 20 ? tail.slice(tailBoundary + 2) : tail
34
+ return `${start.trimEnd()}${separator}${end.trimStart()}`
35
+ }
36
+
37
+ export function KagentAttention({ data, onOpen, agent }: { data: KagentWorkspace; onOpen: (ref: KagentRef) => void; agent?: KagentRef }) {
38
+ const byId = new Map(data.findings.map((f) => [f.id, f]))
39
+ const readings = new Map([...data.agents, ...data.models, ...data.mcpServers].map((o) => [refKey(o.ref), o.reading]))
40
+ const foldedByLead = new Map<string, typeof data.findings>()
41
+ for (const group of data.groups)
42
+ for (const folded of group.folded ?? []) {
43
+ const finding = byId.get(folded.finding)
44
+ if (!finding) continue
45
+ const rows = foldedByLead.get(folded.under) ?? []
46
+ rows.push(finding)
47
+ foldedByLead.set(folded.under, rows)
48
+ }
49
+ const references = data.agents.find((a) => agent && refKey(a.ref) === refKey(agent))?.references
50
+ const groups = data.groups.filter(
51
+ (g) =>
52
+ !agent ||
53
+ [...g.findings, ...(g.folded?.map((f) => f.finding) ?? [])].some((id) => {
54
+ const f = byId.get(id)
55
+ return (
56
+ f &&
57
+ (refKey(f.subject) === refKey(agent) ||
58
+ references?.some((r) => refKey(r.target) === refKey(f.subject) && (f.reason !== 'KagentDependencyNotPermitted' || r.state === 'notPermitted')) ||
59
+ f.affects?.agents.some((a) => refKey(a.agent) === refKey(agent)))
60
+ )
61
+ }),
62
+ )
63
+ const ordered = [...groups].sort((a, b) => {
64
+ const priority = (g: typeof a) => (g.severity === 'critical' ? 0 : g.findings.some((id) => byId.get(id)?.affects?.count) ? 1 : 2)
65
+ return priority(a) - priority(b)
66
+ })
67
+ if (!ordered.length) return agent ? null : <p className="text-sm text-theme-text-secondary">{data.counts.findings.lowerBound ? 'Nothing in what Radar can read needs attention.' : 'Nothing needs attention.'}</p>
68
+ const renderGroup = (g: (typeof ordered)[number]) => (
69
+ <div key={g.id} className="space-y-2">
70
+ {g.secret && (agent?.kind !== 'ModelConfig' || g.findings.length > 1) && (
71
+ <p className="mb-2 text-sm font-medium text-theme-text-primary">
72
+ {g.findings.length > 1 ? 'Shared API key Secret' : 'API key Secret'}:{' '}
73
+ <span className="font-mono text-xs">{refName(g.secret)}</span>
74
+ </p>
75
+ )}
76
+ {g.findings.map((id) => {
77
+ const finding = byId.get(id)
78
+ if (!finding) return null
79
+ const problem = {
80
+ ...findingProblem(finding, readings),
81
+ ...(g.severity === 'critical' ? { tone: 'unhealthy' as const } : {}),
82
+ }
83
+ const folded = foldedByLead.get(id) ?? []
84
+ const messages = [...new Set([problem.rawDetail, ...folded.map((f) => readings.get(refKey(f.subject))?.message)].map((message) => message?.trim()).filter(Boolean))]
85
+ const message = messages.join('\n')
86
+ const [firstLine, ...remainingLines] = message.split(/\r?\n/)
87
+ const preview = messagePreview(firstLine)
88
+ const rawDetail = preview !== firstLine || remainingLines.some((line) => line.trim()) ? message : undefined
89
+ const impact = finding.affects
90
+ return <WorkspaceProblemCallout
91
+ key={id}
92
+ rootKind="kagent"
93
+ subjectFirst
94
+ preserveRawDetailLineBreaks
95
+ hideOrigin
96
+ subjectIsSelf={!!agent && refKey(agent) === refKey(finding.subject)}
97
+ onNavigate={r => onOpen({ ...r, group: r.group ?? '' })}
98
+ problem={{ ...problem, rawDetail }}
99
+ action={<>
100
+ {preview && <p className="mt-1 break-words text-xs text-theme-text-secondary">{preview}</p>}
101
+ {impact && impact.count > 0 && (
102
+ <div className="w-full text-xs text-theme-text-secondary">
103
+ <p>Affects {consumersText(impact)}:</p>
104
+ <ul className="mt-1 flex flex-wrap gap-x-4 gap-y-1">{impact.agents.slice(0, 8).map(a => <li key={refKey(a.agent)} className="flex flex-wrap items-baseline gap-x-2"><KagentName object={a.agent} onOpen={onOpen} /><span>{a.agent.namespace} · {effectText(a.effect)}{folded.some(f => refKey(f.subject) === refKey(a.agent) && f.reason === 'KagentNoPreparedRevision') ? ' · no session can start' : ''}</span></li>)}</ul>
105
+ {impact.count > 8 && <p>and {impact.count - 8} more Agents.</p>}
106
+ </div>
107
+ )}
108
+ </>}
109
+ />
110
+ })}
111
+ </div>
112
+ )
113
+ const unused = ordered.filter((g) => !agent && g.severity !== 'critical' && g.findings.every((id) => byId.get(id)?.affects?.count === 0))
114
+ const unusedIds = new Set(unused.map((g) => g.id))
115
+ const active = ordered.filter((g) => !unusedIds.has(g.id))
116
+ const incomplete = unused.some((g) => g.findings.some((id) => byId.get(id)?.affects?.lowerBound))
117
+ const unusedSubjects = new Map(
118
+ unused
119
+ .flatMap((g) => g.findings)
120
+ .flatMap((id) => {
121
+ const f = byId.get(id)
122
+ return f ? [[refKey(f.subject), f.subject] as const] : []
123
+ }),
124
+ )
125
+ const unusedKinds = [...unusedSubjects.values()]
126
+ const unusedCounts = [
127
+ ['RemoteMCPServer', 'MCP server'],
128
+ ['ModelConfig', 'model'],
129
+ ['Agent', 'Agent'],
130
+ ]
131
+ .flatMap(([kind, label]) => {
132
+ const n = unusedKinds.filter((ref) => ref.kind === kind).length
133
+ return n ? [`${n} ${label}${n === 1 ? '' : 's'}`] : []
134
+ })
135
+ .join(', ')
136
+ return (
137
+ <div className="space-y-3">
138
+ {active.map(renderGroup)}
139
+ {unused.length > 0 && (
140
+ <FoldSection
141
+ title={unusedCounts}
142
+ summary={incomplete ? 'no Agent consumers seen — may be staged' : 'no Agent uses — may be staged'}
143
+ attention={false}
144
+ >
145
+ <div className="space-y-3">{unused.map(renderGroup)}</div>
146
+ </FoldSection>
147
+ )}
148
+ </div>
149
+ )
150
+ }
151
+ export function KagentOverview({
152
+ data,
153
+ runtime,
154
+ onOpen,
155
+ namespaces = [],
156
+ }: {
157
+ namespaces?: string[]
158
+ data: KagentWorkspace
159
+ runtime: KagentRuntime
160
+ onOpen: (ref: KagentRef) => void
161
+ }) {
162
+ const { search } = useLocation()
163
+ const sessionFeature = useRadarFeature('kagentWorkspace')
164
+ const states = data.counts.agentsByLatestChange
165
+ const bound = data.counts.agents.lowerBound
166
+ const unread = (key: 'agents' | 'models' | 'mcpServers') => ['denied', 'uncached', 'syncing', 'error'].includes(data.coverage[key].state)
167
+ const credentialProblems = {
168
+ n: new Set(data.findings.filter((f) => f.reason === 'KagentAPIKeySecretMissing').map((f) => refKey(f.subject))).size,
169
+ lowerBound: data.counts.models.lowerBound,
170
+ }
171
+ const rows = runtime.rows
172
+ const runtimePartial = runtime.lowerBound || !runtime.completePage || rows.some((r) => !r.complete)
173
+ const totalSessions = rows.reduce((n, r) => n + r.sessions.total, 0)
174
+ const scope = namespaces.join(',')
175
+ const actorsPath = (kagent: 'agentSession' | 'sessions', state?: 'crashed') =>
176
+ withCrossViewParams(substrateActorsPath({ kagent, atespaces: scope, state, namespaces: scope }), search)
177
+ const cardClass = 'block rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm hover:bg-theme-hover'
178
+ const numberClass = 'block text-2xl font-semibold tabular-nums'
179
+ const sessionCount = <>
180
+ <span className={numberClass}>{rows.length || runtime.completePage ? `${runtimePartial ? '≥' : ''}${totalSessions}` : 'Unknown'}</span>
181
+ <span className="text-theme-text-secondary">Attributed sessions{sessionFeature.support === 'supported' ? ' →' : ''}</span>
182
+ </>
183
+ return (
184
+ <>
185
+ <div className="grid grid-cols-2 gap-3 text-sm text-theme-text-primary lg:grid-cols-4" aria-label="kagent status">
186
+ <Link to={withCrossViewParams('/kagent/agents', search)} className={cardClass}>
187
+ <span className={numberClass}>{unread('agents') ? 'Unknown' : countText(data.counts.agents)}</span>
188
+ <span className="text-theme-text-secondary">Agents</span>
189
+ {!unread('agents') && <span className="mt-1 block text-xs text-theme-text-secondary">{bound ? '≥' : ''}{states.prepared ?? 0} prepared</span>}
190
+ {!unread('agents') && <span className={`mt-1 block text-xs ${toneTextClass(states.blocked || states.failed ? 'unhealthy' : 'neutral')}`}>{bound ? '≥' : ''}{states.blocked ?? 0} blocked{states.failed ? ` · ${bound ? '≥' : ''}${states.failed} failed` : ''}</span>}
191
+ {!!states.preparing && <span className="block text-xs text-theme-text-tertiary">{bound ? '≥' : ''}{states.preparing} processing</span>}
192
+ {Object.entries(states).filter(([state, count]) => !['prepared', 'blocked', 'failed', 'preparing'].includes(state) && count > 0).map(([state, count]) => <span key={state} className="block text-xs text-theme-text-tertiary">{bound ? '≥' : ''}{count} {changeText(state).toLowerCase()}</span>)}
193
+ </Link>
194
+ <Link to={withCrossViewParams('/kagent/mcpservers?status=problems', search)} className={cardClass}>
195
+ <span className={`${numberClass} ${data.counts.mcpServersFailing.n ? toneTextClass('alert') : ''}`}>
196
+ {unread('mcpServers') ? 'Unknown' : <>
197
+ <KagentCountValue count={data.counts.mcpServersFailing} />
198
+ {!data.counts.mcpServers.lowerBound && <> of {countText(data.counts.mcpServers)}</>}
199
+ </>}
200
+ </span>
201
+ <span className="text-theme-text-secondary">Failing MCP servers</span>
202
+ </Link>
203
+ <Link to={withCrossViewParams('/kagent/models?status=problems', search)} className={cardClass}>
204
+ <span className={`${numberClass} ${credentialProblems.n ? toneTextClass('alert') : ''}`}>
205
+ {unread('models') ? 'Unknown' : <>
206
+ <KagentCountValue count={credentialProblems} />
207
+ {!data.counts.models.lowerBound && <> of {countText(data.counts.models)}</>}
208
+ </>}
209
+ </span>
210
+ <span className="text-theme-text-secondary">Models with credential problems</span>
211
+ </Link>
212
+ <div className={cardClass}>
213
+ {sessionFeature.support === 'supported' ? <Link to={actorsPath('agentSession')} className="block hover:underline" aria-label="Attributed sessions in Agent Substrate">{sessionCount}</Link> : <div>{sessionCount}</div>}
214
+ {sessionFeature.support === 'supported' && (rows.length || runtime.completePage) ? <Link to={actorsPath('agentSession', 'crashed')} className={`mt-1 block text-xs hover:underline ${rows.some(r => r.crashed) ? toneTextClass('unhealthy') : 'text-theme-text-secondary'}`} aria-label="Crashed attributed sessions in Agent Substrate">{runtimePartial ? '≥' : ''}{rows.reduce((n, r) => n + r.crashed, 0)} crashed →</Link> : <span className="text-xs text-theme-text-tertiary">{runtime.unavailable}</span>}
215
+ {sessionFeature.support === 'supported' && <Link to={actorsPath('sessions')} className="mt-1 block text-xs text-accent-text hover:underline">All kagent sessions →</Link>}
216
+ <KagentRuntimeRead runtime={runtime} />
217
+ </div>
218
+ </div>
219
+ <section className="space-y-2">
220
+ <h2 className="text-sm font-semibold text-theme-text-primary">
221
+ Needs attention{' '}
222
+ <span className="font-normal text-theme-text-tertiary">
223
+ · {countText(data.counts.findings)} configuration{' '}
224
+ {data.counts.findings.n === 1 && !data.counts.findings.lowerBound ? 'finding' : 'findings'} in {data.counts.groups.n}{' '}
225
+ {data.counts.groups.n === 1 ? 'group' : 'groups'}
226
+ {data.counts.groups.incomplete ? ' (grouping incomplete)' : ''}
227
+ </span>
228
+ </h2>
229
+ <KagentAttention data={data} onOpen={onOpen} />
230
+ </section>
231
+ <KagentAgentsTable overview data={data} runtime={runtime} onOpen={onOpen} />
232
+ </>
233
+ )
234
+ }