Skip to content

Commit c1510fc

Browse files
authored
Merge pull request #104 from SentriusLLC/vector-ui
Vector UI
2 parents 6ebce08 + 04b627a commit c1510fc

File tree

105 files changed

+8328
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+8328
-404
lines changed

.local.env

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
SENTRIUS_VERSION=1.1.375
1+
SENTRIUS_VERSION=1.1.411
22
SENTRIUS_SSH_VERSION=1.1.41
33
SENTRIUS_KEYCLOAK_VERSION=1.1.53
44
SENTRIUS_AGENT_VERSION=1.1.42
5-
SENTRIUS_AI_AGENT_VERSION=1.1.264
6-
LLMPROXY_VERSION=1.0.78
7-
LAUNCHER_VERSION=1.0.82
5+
SENTRIUS_AI_AGENT_VERSION=1.1.284
6+
LLMPROXY_VERSION=1.0.84
7+
LAUNCHER_VERSION=1.0.88
88
AGENTPROXY_VERSION=1.0.85
9-
SSHPROXY_VERSION=1.0.87
9+
SSHPROXY_VERSION=1.0.88

.local.env.bak

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
SENTRIUS_VERSION=1.1.375
1+
SENTRIUS_VERSION=1.1.411
22
SENTRIUS_SSH_VERSION=1.1.41
33
SENTRIUS_KEYCLOAK_VERSION=1.1.53
44
SENTRIUS_AGENT_VERSION=1.1.42
5-
SENTRIUS_AI_AGENT_VERSION=1.1.264
6-
LLMPROXY_VERSION=1.0.78
7-
LAUNCHER_VERSION=1.0.82
5+
SENTRIUS_AI_AGENT_VERSION=1.1.284
6+
LLMPROXY_VERSION=1.0.84
7+
LAUNCHER_VERSION=1.0.88
88
AGENTPROXY_VERSION=1.0.85
9-
SSHPROXY_VERSION=1.0.87
9+
SSHPROXY_VERSION=1.0.88

agent-launcher/src/main/java/io/sentrius/agent/launcher/service/PodLauncherService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ public V1Pod launchAgentPod(AgentRegistrationDTO agent) throws Exception {
178178
List<String> argList = new ArrayList<>();
179179
argList.add("--spring.config.location=file:/config/agent.properties");
180180
argList.add("--agent.namePrefix=" + agentId);
181+
argList.add("--agent.type=" + agentType);
181182
argList.add("--agent.clientId=" + agent.getClientId());
182183
argList.add("--agent.listen.websocket=true");
183184
argList.add("--agent.callback.url=" + constructedCallbackUrl);
@@ -202,6 +203,7 @@ public V1Pod launchAgentPod(AgentRegistrationDTO agent) throws Exception {
202203
argList.add("--agent.ai.config=/config/" + agentFile);
203204
}
204205

206+
log.info("Agent {} using config file: {}", agentId, argList);
205207

206208
String image = String.format("%ssentrius-launchable-agent:%s", myAgentRegistry, agentVersion);
207209

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package io.sentrius.agent.launcher.service;
2+
3+
import java.io.IOException;
4+
import java.util.ArrayList;
5+
import java.util.List;
6+
import java.util.Map;
7+
import java.util.Optional;
8+
import java.util.regex.Matcher;
9+
import java.util.regex.Pattern;
10+
import io.kubernetes.client.custom.IntOrString;
11+
import io.kubernetes.client.custom.Quantity;
12+
import io.kubernetes.client.openapi.ApiClient;
13+
import io.kubernetes.client.openapi.ApiException;
14+
import io.kubernetes.client.openapi.apis.CoreV1Api;
15+
import io.kubernetes.client.openapi.models.V1ConfigMapVolumeSource;
16+
import io.kubernetes.client.openapi.models.V1Container;
17+
import io.kubernetes.client.openapi.models.V1ObjectMeta;
18+
import io.kubernetes.client.openapi.models.V1Pod;
19+
import io.kubernetes.client.openapi.models.V1PodSpec;
20+
import io.kubernetes.client.openapi.models.V1PodStatus;
21+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
22+
import io.kubernetes.client.openapi.models.V1Service;
23+
import io.kubernetes.client.openapi.models.V1ServicePort;
24+
import io.kubernetes.client.openapi.models.V1ServiceSpec;
25+
import io.kubernetes.client.openapi.models.V1Volume;
26+
import io.kubernetes.client.openapi.models.V1VolumeMount;
27+
import io.kubernetes.client.util.Config;
28+
import io.sentrius.sso.core.dto.AgentRegistrationDTO;
29+
import io.sentrius.sso.core.model.AgentStatus;
30+
import lombok.extern.slf4j.Slf4j;
31+
import org.springframework.beans.factory.annotation.Value;
32+
import org.springframework.scheduling.annotation.Async;
33+
import org.springframework.scheduling.annotation.Scheduled;
34+
import org.springframework.stereotype.Service;
35+
36+
@Slf4j
37+
@Service
38+
public class PodMonitor {
39+
40+
private final CoreV1Api coreV1Api;
41+
42+
@Value("${sentrius.agent.registry}")
43+
private String agentRegistry;
44+
45+
@Value("${sentrius.agent.namespace}")
46+
private String agentNamespace;
47+
48+
public PodMonitor() throws IOException {
49+
ApiClient client = Config.defaultClient(); // in-cluster or kubeconfig
50+
this.coreV1Api = new CoreV1Api(client);
51+
}
52+
53+
@Scheduled(fixedDelay = 60000) // Runs every 60 seconds
54+
@Async
55+
public void removePodsInErrorState() throws ApiException {
56+
57+
log.info("Identifying pods to be removed");
58+
var pods = coreV1Api.listNamespacedPod(
59+
agentNamespace
60+
).execute().getItems();
61+
62+
List<V1Pod> podsToRemove = new ArrayList<>();
63+
for (V1Pod pod : pods) {
64+
65+
var podName = pod.getMetadata().getName();
66+
67+
if (podName == null || !podName.startsWith("sentrius-agent-")) {
68+
log.info("Skipping pod {}", podName);
69+
continue;
70+
}
71+
V1PodStatus status = pod.getStatus();
72+
if (status == null) {
73+
log.warn("Pod {} has no status information", podName);
74+
continue;
75+
}
76+
77+
String phase = status.getPhase(); // e.g., "Running", "Pending", "Failed", "Succeeded"
78+
if ("Error".equalsIgnoreCase(phase) || "Failed".equalsIgnoreCase(phase)) {
79+
log.info("Pod {} is in phase {}, adding to removal list", podName, phase);
80+
podsToRemove.add(pod);
81+
} else {
82+
log.info("Pod {} is in phase {}, skipping", podName, phase);
83+
}
84+
}
85+
86+
for (V1Pod pod : podsToRemove) {
87+
var podName = pod.getMetadata().getName();
88+
try {
89+
assert podName != null;
90+
coreV1Api.deleteNamespacedPod(
91+
podName,
92+
agentNamespace
93+
).execute();
94+
log.info("Deleted pod {}", podName);
95+
} catch (ApiException e) {
96+
log.error("Failed to delete pod {}: {}", podName, e.getResponseBody());
97+
}
98+
}
99+
100+
101+
}
102+
}

agent-launcher/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spring.main.web-application-type=servlet
88
spring.thymeleaf.enabled=true
99
spring.freemarker.enabled=false
1010

11-
sentrius.agent.registry=local
11+
sentrius.agent.registry=local
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.sentrius.agent.analysis.agents.agents;
2+
3+
import java.util.concurrent.TimeUnit;
4+
import com.fasterxml.jackson.databind.node.ArrayNode;
5+
import io.sentrius.agent.analysis.agents.verbs.AgentVerbs;
6+
import io.sentrius.sso.core.dto.agents.AgentExecution;
7+
import io.sentrius.sso.core.dto.agents.AgentExecutionContextDTO;
8+
import io.sentrius.sso.core.dto.ztat.ZtatRequestDTO;
9+
import io.sentrius.sso.core.exceptions.ZtatException;
10+
import io.sentrius.sso.core.services.agents.AgentClientService;
11+
import io.sentrius.sso.core.services.agents.ZeroTrustClientService;
12+
import lombok.RequiredArgsConstructor;
13+
import lombok.extern.slf4j.Slf4j;
14+
import org.springframework.beans.factory.annotation.Autowired;
15+
import org.springframework.boot.context.event.ApplicationReadyEvent;
16+
import org.springframework.context.ApplicationListener;
17+
18+
@Slf4j
19+
public abstract class BaseEnterpriseAgent implements ApplicationListener<ApplicationReadyEvent> {
20+
21+
@Autowired
22+
protected final AgentVerbs agentVerbs;
23+
@Autowired
24+
protected final ZeroTrustClientService zeroTrustClientService;
25+
@Autowired
26+
protected final AgentClientService agentClientService;
27+
@Autowired
28+
protected final VerbRegistry verbRegistry;
29+
30+
protected BaseEnterpriseAgent(
31+
AgentVerbs agentVerbs, ZeroTrustClientService zeroTrustClientService, AgentClientService agentClientService,
32+
VerbRegistry verbRegistry
33+
) {
34+
this.agentVerbs = agentVerbs;
35+
this.zeroTrustClientService = zeroTrustClientService;
36+
this.agentClientService = agentClientService;
37+
this.verbRegistry = verbRegistry;
38+
}
39+
40+
41+
protected ArrayNode promptAgent(AgentExecution execution) throws ZtatException {
42+
return promptAgent(execution);
43+
}
44+
45+
protected ArrayNode promptAgent(AgentExecution execution, AgentExecutionContextDTO contextDTO) throws ZtatException {
46+
while(true){
47+
try {
48+
log.info("Prompting agent...");
49+
return agentVerbs.promptAgent(execution,contextDTO);
50+
} catch (ZtatException e) {
51+
log.info("Mechanisms {}" , e.getMechanisms());
52+
var endpoint = zeroTrustClientService.createEndPointRequest("prompt_agent", e.getEndpoint());
53+
ZtatRequestDTO ztatRequestDTO = ZtatRequestDTO.builder()
54+
.user(execution.getUser())
55+
.command(endpoint.toString())
56+
.justification("Registered Agent requires ability to prompt LLM endpoints to begin operations")
57+
.summary("Registered Agent requires ability to prompt LLM endpoints to begin operations")
58+
.build();
59+
var request = zeroTrustClientService.requestZtatToken(execution, execution.getUser(),ztatRequestDTO);
60+
61+
var token = zeroTrustClientService.awaitZtatToken(execution, execution.getUser(), request, 60,
62+
TimeUnit.MINUTES);
63+
execution.setZtatToken(token);
64+
} catch (Exception e) {
65+
log.error(e.getMessage());
66+
throw new RuntimeException(e);
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)