Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

Merge remote-tracking branch 'origin/dev' into feat/mcp-host-guardrails

Andy Pavia7240e01c76b6
diff --cc control-api/src/routes/admin/resources.ts
index d96901a86,a66269ef3..c8785c1a6
--- a/control-api/src/routes/admin/resources.ts
+++ b/control-api/src/routes/admin/resources.ts
@@@ -5,8 -5,12 +5,13 @@@ import { enforceNamespace } from '../..
import { validateCommunicationChannelSpec } from '../../http/validateCommunicationChannelSpec.js'
import { validateMcpServerSpecPreflight } from '../../http/validateMcpServerSpec.js'
import { K8sGateway } from '../../k8s.js'
+import { stripHookRefFromHosts } from '../../services/hostGuardrailRefs.js'
- import { K8sConflictError } from '../../services/resourceService.js'
+ import {
+ K8sConflictError,
+ K8sNotFoundError,
+ type MutableResourceSnapshot,
+ } from '../../services/resourceService.js'
+ import { secretKeyNames } from '../../services/secretKeyNames.js'
import { ClerumResourceType } from '../../types.js'
import {
registerCommunicationChannelCredentialsRoutes,
diff --cc control-ui/app/hosts/[name]/page.tsx
index 1efc4d042,1237b2550..d93ca9cc8
--- a/control-ui/app/hosts/[name]/page.tsx
+++ b/control-ui/app/hosts/[name]/page.tsx
@@@ -7,11 -7,8 +7,10 @@@ import { DetailPageShell } from '@compo
import { useToast } from '@components/Toast'
import { HOST_DEFAULT_TAB, HOST_TABS } from '@constants/hostDetails'
import { CONTROL_ROUTES } from '@constants/routes'
- import { HostApprovalSection } from '../../../components/HostApprovalSection'
- import { HostEnvTable } from '../../../components/HostEnvTable'
+ import { HostAccessTab } from '../../../components/HostAccessTab'
+ import { HostAdvancedTab } from '../../../components/HostAdvancedTab'
+import { HostGuardrailsSection } from '../../../components/HostGuardrailsSection'
+import type { HostGuardrails } from '../../../components/HostGuardrailsSection/types'
import { HostIdentityTab } from '../../../components/HostIdentityTab'
import { LlmProviderConfig } from '../../../components/LlmProviderConfig'
import { IconRobot } from '../../../components/Sidebar/icons'
@@@ -784,182 -601,6 +608,51 @@@ export default function HostDetailsPage
[routeName]
)
+ // Persist Host.spec.guardrails (hook references + built-ins). Owns only the
+ // guardrails object — every other spec field is preserved via the
+ // `...currentHost.spec` spread (full-replace semantics). Carries the
+ // form-load resourceVersion so a concurrent change 409s instead of being
+ // overwritten (AP-6), surfacing the same reload guidance as the other saves.
+ const persistGuardrails = useCallback(
+ async (next: HostGuardrails) => {
+ setBusy(true)
+ setError('')
+ try {
+ const currentHost = await getHost(routeName)
+ const nextSpec = {
+ ...currentHost.spec,
+ guardrails: next,
+ }
+ const formResourceVersion = formResourceVersionRef.current
+ await apiSend('PUT', `/api/v1/admin/hosts/${encodeURIComponent(routeName)}`, {
+ ...(formResourceVersion ? { metadata: { resourceVersion: formResourceVersion } } : {}),
+ spec: nextSpec,
+ })
+ // Reload guardrails/server state while preserving any drafts left open
+ // in the Overview or Model tabs.
+ await loadData('none')
+ showToast('Guardrails saved.', { tone: 'success' })
+ } catch (e) {
+ const status = (e as { status?: number } | null)?.status
+ const code = (e as { code?: string } | null)?.code
+ if (status === 409 && code === 'conflict') {
+ setError(
+ "This agent changed since you opened the form (another edit, or the agent's own lifecycle state updated). Reload to see the latest, then re-apply your change."
+ )
+ } else {
+ setError(e instanceof Error ? e.message : 'Failed to save guardrails')
+ }
+ // Re-throw so HostGuardrailsSection stays in edit mode and keeps the
+ // operator's draft alongside the error/conflict banner.
+ throw e
+ } finally {
+ setBusy(false)
+ }
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [routeName]
+ )
+
- async function grantUserAccess() {
- if (selectedUserIdsToGrant.length === 0 || hasPendingRename) return
- setBusy(true)
- setError('')
- try {
- await Promise.all(
- selectedUserIdsToGrant.map(async userId => {
- const current = await getAdminUserAgents(userId)
- const next = Array.from(new Set([...(current.agentNames || []), routeName]))
- await updateAdminUserAgents(userId, next, [
- ...(current.agentNames || []),
- ...(current.deletedAgentNames || []),
- ])
- })
- )
- const grantedUserIds = selectedUserIdsToGrant
- const grantedUser = allUsers.find(u => u.id === grantedUserIds[0])
- setSelectedUserIdsToGrant([])
- const refreshed = await getAgentUsers(routeName)
- setUsersWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])
- showToast(
- grantedUserIds.length === 1
- ? `${grantedUser?.displayName || grantedUser?.name || grantedUserIds[0]} can now use this agent.`
- : `${grantedUserIds.length} members can now use this agent.`,
- { tone: 'success' }
- )
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to grant member access')
- } finally {
- setBusy(false)
- }
- }
-
- async function revokeUserAccess(userId: string) {
- if (hasPendingRename) return
- const user = usersWithAccess.find(item => item.id === userId)
- const shouldRevoke = await confirm({
- title: 'Revoke Member Access',
- message: `Revoke ${user?.displayName || user?.name || user?.email || 'this member'}'s access to ${routeName}?`,
- confirmLabel: 'Revoke',
- tone: 'danger',
- })
- if (!shouldRevoke) return
-
- setBusy(true)
- setError('')
- try {
- const current = await getAdminUserAgents(userId)
- const next = (current.agentNames || []).filter(name => name !== routeName)
- await updateAdminUserAgents(userId, next, [
- ...(current.agentNames || []),
- ...(current.deletedAgentNames || []),
- ])
- const removedUser = usersWithAccess.find(u => u.id === userId)
- setUsersWithAccess(prev => prev.filter(u => u.id !== userId))
- showToast(
- `${removedUser?.displayName || removedUser?.name || userId} can no longer use this agent.`,
- { tone: 'success' }
- )
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to revoke member access')
- } finally {
- setBusy(false)
- }
- }
-
- async function grantTeamAccess() {
- if (selectedTeamIdsToGrant.length === 0 || hasPendingRename) return
- setBusy(true)
- setError('')
- try {
- await Promise.all(
- selectedTeamIdsToGrant.map(async teamId => {
- const current = await getAdminTeamAgents(teamId)
- const next = Array.from(new Set([...(current.agentNames || []), routeName]))
- await updateAdminTeamAgents(teamId, next, [
- ...(current.agentNames || []),
- ...(current.deletedAgentNames || []),
- ])
- })
- )
- const grantedTeamIds = selectedTeamIdsToGrant
- const grantedTeam = allTeams.find(t => t.id === grantedTeamIds[0])
- setSelectedTeamIdsToGrant([])
- const refreshed = await getAgentTeams(routeName)
- setTeamsWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])
- showToast(
- grantedTeamIds.length === 1
- ? `${grantedTeam?.name || grantedTeamIds[0]} can now use this agent.`
- : `${grantedTeamIds.length} teams can now use this agent.`,
- { tone: 'success' }
- )
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to grant team access')
- } finally {
- setBusy(false)
- }
- }
-
- async function revokeTeamAccess(teamId: string) {
- if (hasPendingRename) return
- const team = teamsWithAccess.find(item => item.id === teamId)
- const shouldRevoke = await confirm({
- title: 'Revoke Team Access',
- message: `Revoke ${team?.name || 'this team'}'s access to ${routeName}?`,
- confirmLabel: 'Revoke',
- tone: 'danger',
- })
- if (!shouldRevoke) return
-
- setBusy(true)
- setError('')
- try {
- const current = await getAdminTeamAgents(teamId)
- const next = (current.agentNames || []).filter(name => name !== routeName)
- await updateAdminTeamAgents(teamId, next, [
- ...(current.agentNames || []),
- ...(current.deletedAgentNames || []),
- ])
- const removedTeam = teamsWithAccess.find(t => t.id === teamId)
- setTeamsWithAccess(prev => prev.filter(team => team.id !== teamId))
- showToast(`${removedTeam?.name || teamId} can no longer use this agent.`, {
- tone: 'success',
- })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to revoke team access')
- } finally {
- setBusy(false)
- }
- }
-
async function deleteAgentPermanently() {
setDeletingAgent(true)
setDeleteAgentDialogError('')
@@@ -1304,23 -964,14 +1016,26 @@@
</>
)}
- {activeTab === 'approvals' && !initialLoading && (
- <HostApprovalSection
- initialTools={approvalToolsData}
- onSave={persistApprovalTools}
- busy={busy}
- canWrite={true /* TODO: wire to actual host:write check if/when per-field RBAC lands */}
- defaultEditing
- />
- )}
-
- {activeTab === 'guardrails' && !initialLoading && (
- <HostGuardrailsSection
- initialGuardrails={guardrailsData}
- onSave={persistGuardrails}
- busy={busy}
- canWrite={true /* TODO: wire to actual host:write check if/when per-field RBAC lands */}
- />
+ {activeTab === 'advanced' && (
- <HostAdvancedTab
- busy={busy}
- hostName={routeName}
- initialLoading={initialLoading}
- initialTools={approvalToolsData}
- onSaveApprovalTools={persistApprovalTools}
- />
++ <>
++ <HostAdvancedTab
++ busy={busy}
++ hostName={routeName}
++ initialLoading={initialLoading}
++ initialTools={approvalToolsData}
++ onSaveApprovalTools={persistApprovalTools}
++ />
++ {!initialLoading && (
++ <HostGuardrailsSection
++ initialGuardrails={guardrailsData}
++ onSave={persistGuardrails}
++ busy={busy}
++ canWrite={
++ true /* TODO: wire to actual host:write check if/when per-field RBAC lands */
++ }
++ />
++ )}
++ </>
)}
{activeTab === 'contexts' && (
diff --cc control-ui/components/CommunicationChannelsTable.tsx
index 30643a7c4,b596a6d51..76731bc3b
--- a/control-ui/components/CommunicationChannelsTable.tsx
+++ b/control-ui/components/CommunicationChannelsTable.tsx
@@@ -257,9 -256,7 +256,9 @@@ export function CommunicationChannelsTa
<td>
<span className="cu-table__cell-muted">{spec.hostRef || '-'}</span>
</td>
- <td>{telegramCount}</td>
- <td>{slackCount}</td>
- <td>{teamsCount}</td>
- <td>{providerTypes.map(communicationChannelProviderLabel).join(', ') || '-'}</td>
++ <td>
++ {providerTypes.map(communicationChannelProviderLabel).join(', ') || '-'}
++ </td>
<td>
<div className="cu-table-actions">
<CopyChannelMenu
diff --cc control-ui/components/HostAdvancedTab/index.tsx
index 000000000,a70c79b2d..fca1d989d
mode 000000,100644..100644
--- a/control-ui/components/HostAdvancedTab/index.tsx
+++ b/control-ui/components/HostAdvancedTab/index.tsx
@@@ -1,0 -1,79 +1,75 @@@
+ 'use client'
+
+ import React, { useState } from 'react'
+ import { HostApprovalSection } from '@components/HostApprovalSection'
+ import { HostEnvTable } from '@components/HostEnvTable'
+ import { TabBar } from '@components/TabBar'
+ import type { AdvancedSubTab, HostAdvancedTabProps } from './types'
+
+ const ADVANCED_SUB_TABS: { key: AdvancedSubTab; label: string }[] = [
+ { key: 'approvals', label: 'Per-tool approval' },
+ { key: 'env', label: 'Env vars' },
+ ]
+
+ export function HostAdvancedTab({
+ busy,
+ hostName,
+ initialLoading,
+ initialTools,
+ onSaveApprovalTools,
+ }: HostAdvancedTabProps) {
+ const [subTab, setSubTab] = useState<AdvancedSubTab>('approvals')
+
+ return (
+ <section className="cu-advanced-tab" aria-label="Advanced">
+ <TabBar<AdvancedSubTab>
+ activeValue={subTab}
+ ariaLabel="Advanced settings"
+ className="cu-tabs--compact cu-advanced-tabs"
+ onChange={setSubTab}
+ options={ADVANCED_SUB_TABS.map(tab => ({ label: tab.label, value: tab.key }))}
+ />
+
+ <div className="cu-advanced-section">
+ {subTab === 'approvals' ? (
+ initialLoading ? (
- <div
- className="cu-table-wrap"
- role="status"
- aria-label="Loading approval tools"
- >
++ <div className="cu-table-wrap" role="status" aria-label="Loading approval tools">
+ <table className="cu-table cu-table--header-band cu-table--static-rows">
+ <thead>
+ <tr>
+ <th>Tool</th>
+ <th>Default</th>
+ <th className="cu-table__col-actions">Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {[1, 2, 3, 4].map(i => (
+ <tr key={i}>
+ <td>
+ <div className="cu-skeleton cu-skeleton--cell" style={{ width: '8rem' }} />
+ </td>
+ <td>
+ <div className="cu-skeleton cu-skeleton--cell" style={{ width: '6rem' }} />
+ </td>
+ <td />
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ ) : (
+ <HostApprovalSection
+ busy={busy}
+ canWrite
+ defaultEditing
+ initialTools={initialTools}
+ onSave={onSaveApprovalTools}
+ />
+ )
+ ) : (
+ <HostEnvTable hostRef={hostName} />
+ )}
+ </div>
+ </section>
+ )
+ }
diff --cc control-ui/components/LlmProviderConfig/index.tsx
index b3ee8122a,7fe9d8152..0c8f68e12
--- a/control-ui/components/LlmProviderConfig/index.tsx
+++ b/control-ui/components/LlmProviderConfig/index.tsx
@@@ -6,7 -6,8 +6,8 @@@ import { CONTROL_ROUTES } from '@consta
import { LlmPolicyEditor } from '@/components/LlmPolicyEditor'
import { LlmProviderIcon } from '@/components/LlmProviderIcon'
import { SelectionDropdown } from '@/components/SelectionDropdown'
-import { IconChevronRight } from '@/components/icons'
import type { SelectionDropdownOption } from '@/components/SelectionDropdown/types'
++import { IconChevronRight } from '@/components/icons'
import { Button, Field, TextAreaInput, TextInput } from '@/components/ui'
import { cn } from '@/lib/cn'
import {
diff --cc control-ui/next.config.js
index 7b9bee733,6baa3f99a..8be20d4e7
--- a/control-ui/next.config.js
+++ b/control-ui/next.config.js
@@@ -111,6 -111,16 +111,20 @@@ const nextConfig =
{ source: '/publisher/:path*', destination: '/marketplace/org/entries', permanent: true },
{ source: '/cost', destination: '/cost-and-usage/usage', permanent: true },
{ source: '/cost/:path*', destination: '/cost-and-usage/:path*', permanent: true },
+ // Host detail tab consolidation (R1-H1 in feat/agent-ux-polish PR
+ // review): the old top-level tabs are now sub-tabs under the new
+ // `access` and `advanced` parents. Send each old slug to its new
+ // parent so bookmarks, shared links, and the approval-tools E2E
+ // (which navigates to /hosts/<name>/approvals) still reach the
+ // section they used to.
- { source: '/agents/:name/member-access', destination: '/agents/:name/access', permanent: true },
++ {
++ source: '/agents/:name/member-access',
++ destination: '/agents/:name/access',
++ permanent: true,
++ },
+ { source: '/agents/:name/team-access', destination: '/agents/:name/access', permanent: true },
+ { source: '/agents/:name/approvals', destination: '/agents/:name/advanced', permanent: true },
+ { source: '/agents/:name/env-vars', destination: '/agents/:name/advanced', permanent: true },
{ source: '/marketplace', destination: '/marketplace/connectors', permanent: true },
{ source: '/cost-and-usage', destination: '/cost-and-usage/usage', permanent: true },
{
diff --cc host-context-controller/package-lock.json
index 0607476da,e9b28c157..279d4bdfe
--- a/host-context-controller/package-lock.json
+++ b/host-context-controller/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-host-context-controller",
- "version": "0.1.173",
- "version": "0.1.170",
++ "version": "0.1.174",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.173",
- "version": "0.1.170",
++ "version": "0.1.174",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
diff --cc host-context-controller/package.json
index 72a920567,17c98b81a..7854ad18d
--- a/host-context-controller/package.json
+++ b/host-context-controller/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-host-context-controller",
- "version": "0.1.173",
- "version": "0.1.170",
++ "version": "0.1.174",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --cc host-context-controller/src/networkPolicyReconciler.ts
index b1a180b32,8778887cd..bca40c949
--- a/host-context-controller/src/networkPolicyReconciler.ts
+++ b/host-context-controller/src/networkPolicyReconciler.ts
@@@ -108,7 -110,47 +110,47 @@@ export function isAllowedExternalEgress
return !PUBLIC_EGRESS_EXCEPT_CIDRS.some(blocked => cidrOverlaps(cidr, blocked))
}
+ /**
+ * Recursively canonicalize a value: sort every object's keys while preserving
+ * array order. Used to compare policy egress without JSON.stringify key-order
+ * fragility.
+ */
+ function canonicalize(value: unknown): unknown {
+ if (Array.isArray(value)) return value.map(canonicalize)
+ if (value && typeof value === 'object') {
+ const src = value as Record<string, unknown>
+ const out: Record<string, unknown> = {}
+ for (const k of Object.keys(src).sort()) out[k] = canonicalize(src[k])
+ return out
+ }
+ return value
+ }
+
+ /**
+ * A representation-independent signature of a policy's egress: a canonical
+ * (deep key-sorted) JSON of `spec.egress`. Decides whether a write is needed
+ * WITHOUT the key-ordering fragility of a raw JSON.stringify (audit R2-1). Unlike
+ * the earlier tuple-only signature (ipBlock cidr/port), this captures the FULL
+ * rule including selector-based `to` entries (audit H1). It also projects
+ * `podSelector` and `policyTypes` (audit H-C), not just `spec.egress`, so a
+ * policy whose selector or policy types drifted out-of-band (same destination
+ * rules) counts as changed and the reconcile re-owns it instead of leaving
+ * egress applied to the wrong pods. `policyTypes` is order-insensitive (sorted).
+ * HCC external-egress policies are ipBlock-only today, so H1 does not bite here,
+ * but this keeps the gate correct and mirrors WRC's `egressSignature`.
+ */
+ export function egressSignature(policy: k8s.V1NetworkPolicy): string {
+ const spec = policy.spec
+ return JSON.stringify(
+ canonicalize({
+ podSelector: spec?.podSelector ?? {},
+ policyTypes: [...(spec?.policyTypes ?? [])].sort(),
+ egress: spec?.egress ?? [],
+ })
+ )
+ }
+
-function isPublicDnsHostname(host: string): boolean {
+export function isPublicDnsHostname(host: string): boolean {
if (host !== host.trim()) return false
if (host !== host.toLowerCase()) return false
if (host.includes('*') || host.includes('/') || host.includes(':')) return false
diff --cc mcp-host/package-lock.json
index a14759f56,8519e148d..7de42f4ec
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-mcp-host",
- "version": "0.1.262",
- "version": "0.1.239",
++ "version": "0.1.263",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.262",
- "version": "0.1.239",
++ "version": "0.1.263",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --cc mcp-host/package.json
index e997973b4,2dcb39dec..c7b2a90dd
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-mcp-host",
- "version": "0.1.262",
- "version": "0.1.239",
++ "version": "0.1.263",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {