Skip to content

Commit 2ff4645

Browse files
committed
update
1 parent 8448952 commit 2ff4645

File tree

30 files changed

+317
-206
lines changed

30 files changed

+317
-206
lines changed

.local.env

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SENTRIUS_VERSION=1.1.246
2-
SENTRIUS_SSH_VERSION=1.1.36
3-
SENTRIUS_KEYCLOAK_VERSION=1.1.48
4-
SENTRIUS_AGENT_VERSION=1.1.35
5-
SENTRIUS_AI_AGENT_VERSION=1.1.124
6-
LLMPROXY_VERSION=1.0.49
7-
LAUNCHER_VERSION=1.0.62
8-
AGENTPROXY_VERSION=1.0.69
1+
SENTRIUS_VERSION=1.1.261
2+
SENTRIUS_SSH_VERSION=1.1.40
3+
SENTRIUS_KEYCLOAK_VERSION=1.1.52
4+
SENTRIUS_AGENT_VERSION=1.1.39
5+
SENTRIUS_AI_AGENT_VERSION=1.1.148
6+
LLMPROXY_VERSION=1.0.53
7+
LAUNCHER_VERSION=1.0.73
8+
AGENTPROXY_VERSION=1.0.74

.local.env.bak

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SENTRIUS_VERSION=1.1.246
2-
SENTRIUS_SSH_VERSION=1.1.36
3-
SENTRIUS_KEYCLOAK_VERSION=1.1.48
4-
SENTRIUS_AGENT_VERSION=1.1.35
5-
SENTRIUS_AI_AGENT_VERSION=1.1.124
6-
LLMPROXY_VERSION=1.0.49
7-
LAUNCHER_VERSION=1.0.62
8-
AGENTPROXY_VERSION=1.0.69
1+
SENTRIUS_VERSION=1.1.261
2+
SENTRIUS_SSH_VERSION=1.1.40
3+
SENTRIUS_KEYCLOAK_VERSION=1.1.52
4+
SENTRIUS_AGENT_VERSION=1.1.39
5+
SENTRIUS_AI_AGENT_VERSION=1.1.148
6+
LLMPROXY_VERSION=1.0.53
7+
LAUNCHER_VERSION=1.0.73
8+
AGENTPROXY_VERSION=1.0.74

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

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.springframework.stereotype.Service;
1414

1515
import java.io.IOException;
16+
import java.util.ArrayList;
1617
import java.util.List;
1718
import java.util.Map;
1819
import java.util.regex.Matcher;
@@ -167,25 +168,37 @@ public V1Pod launchAgentPod(AgentRegistrationDTO agent) throws Exception {
167168
myAgentRegistry += "/";
168169
}
169170
}
170-
String agentId = agent.getAgentName();
171+
String agentId = agent.getAgentName().toLowerCase();
171172
String callbackUrl = agent.getAgentCallbackUrl();
172173
String agentType = agent.getAgentType();
173-
String agentFile= "chat-helper.yaml";
174-
// TODO This should be pluggable
175-
switch(agentType){
176-
case "chat":
177-
agentFile = "chat-helper.yaml";
178-
break;
179-
case "atpl-helper":
180-
agentFile = "chat-atpl-helper.yaml";
181-
break;
182-
case "default":
183-
default:
184-
agentFile = "chat-helper.yaml";
185-
}
186174

187175
var constructedCallbackUrl = buildAgentCallbackUrl(agentId);
188176

177+
178+
List<String> argList = new ArrayList<>();
179+
argList.add("--spring.config.location=file:/config/agent.properties");
180+
argList.add("--agent.namePrefix=" + agentId);
181+
argList.add("--agent.listen.websocket=true");
182+
argList.add("--agent.callback.url=" + constructedCallbackUrl);
183+
if (agent.getAgentContextId() != null && !agent.getAgentContextId().isEmpty()) {
184+
argList.add("--agent.ai.context.db.id=" + agent.getAgentContextId());
185+
}else {
186+
String agentFile= "chat-helper.yaml";
187+
switch(agentType){
188+
case "chat":
189+
agentFile = "chat-helper.yaml";
190+
break;
191+
case "atpl-helper":
192+
agentFile = "chat-atpl-helper.yaml";
193+
break;
194+
case "default":
195+
default:
196+
agentFile = "chat-helper.yaml";
197+
}
198+
argList.add("--agent.ai.config=/config/" + agentFile);
199+
}
200+
201+
189202
String image = String.format("%ssentrius-launchable-agent:%s", myAgentRegistry, agentVersion);
190203

191204
log.info("Launching agent pod with ID: {}, Image: {}, Callback URL: {}", agentId, image, callbackUrl);
@@ -199,11 +212,7 @@ public V1Pod launchAgentPod(AgentRegistrationDTO agent) throws Exception {
199212
.image(image)
200213
.imagePullPolicy("IfNotPresent")
201214

202-
.args(List.of("--spring.config.location=file:/config/agent.properties",
203-
"--agent.namePrefix=" + agentId, "--agent.ai.config=/config/" + agentFile, "--agent.listen" +
204-
".websocket=true",
205-
"--agent.callback.url=" + constructedCallbackUrl
206-
))
215+
.args(argList)
207216
.resources(new V1ResourceRequirements()
208217
.limits(Map.of(
209218
"cpu", Quantity.fromString("1000m"),

agent-proxy/src/main/java/io/sentrius/sso/config/AgentWebSocketProxyHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Mono<Void> handle(WebSocketSession clientSession) {
6565
log.info("Handling WebSocket connection for host: {}, sessionId: {}, chatGroupId: {}, ztat: {}",
6666
agentHost, sessionId, chatGroupId, ztat);
6767

68-
URI agentUri = agentLocator.resolveWebSocketUri(agentHost, sessionId, chatGroupId, ztat);
68+
URI agentUri = agentLocator.resolveWebSocketUri(agentHost.toLowerCase(), sessionId, chatGroupId, ztat);
6969

7070
log.info("Resolved agent URI: {}", agentUri);
7171

ai-agent/src/main/java/io/sentrius/agent/analysis/agents/interpreters/ObjectNodeInterpreter.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.HashMap;
44
import java.util.Map;
5+
import com.fasterxml.jackson.databind.JsonNode;
56
import com.fasterxml.jackson.databind.node.ObjectNode;
67
import io.sentrius.sso.core.model.verbs.InputInterpreterIfc;
78
import io.sentrius.sso.core.model.verbs.OutputInterpreterIfc;
@@ -13,14 +14,20 @@
1314
public class ObjectNodeInterpreter implements InputInterpreterIfc<ObjectNode>, OutputInterpreterIfc {
1415
@Override
1516
public ObjectNode interpret(Map<String, Object> input) throws Exception {
17+
Object raw = input.containsKey("arg1") ? input.get("arg1") : input;
1618

17-
Object arg1Value = input.get("arg1");
18-
if (arg1Value == null) {
19-
throw new IllegalArgumentException("Missing 'arg1' field in arguments map.");
19+
JsonNode node = JsonUtil.MAPPER.valueToTree(raw);
20+
21+
if (node == null || node.isNull()) {
22+
throw new IllegalArgumentException("Input is null or could not be converted to ObjectNode");
23+
}
24+
25+
if (!node.isObject()) {
26+
throw new IllegalArgumentException("Expected ObjectNode, got: " + node.getNodeType());
2027
}
2128

22-
// Convert the value under "arg1" to an ObjectNode
23-
return JsonUtil.MAPPER.valueToTree(arg1Value);
29+
return (ObjectNode) node;
30+
2431
}
2532

2633
@Override

ai-agent/src/main/java/io/sentrius/agent/analysis/agents/verbs/AgentVerbs.java

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@
2424
import io.sentrius.agent.analysis.agents.agents.AgentConfig;
2525
import io.sentrius.agent.analysis.agents.agents.PromptBuilder;
2626
import io.sentrius.agent.analysis.agents.agents.VerbRegistry;
27-
import io.sentrius.agent.analysis.agents.interpreters.AgentContextInterpreter;
2827
import io.sentrius.agent.analysis.agents.interpreters.AsessmentListInterpreter;
2928
import io.sentrius.agent.analysis.agents.interpreters.ObjectListInterpreter;
3029
import io.sentrius.agent.analysis.agents.interpreters.ObjectNodeInterpreter;
31-
import io.sentrius.agent.analysis.agents.interpreters.StringInterpreter;
3230
import io.sentrius.agent.analysis.agents.interpreters.ZtatOutputInterpreter;
3331
import io.sentrius.agent.analysis.model.AssessedTerminal;
3432
import io.sentrius.agent.analysis.model.Assessment;
35-
import io.sentrius.agent.analysis.model.TerminalResponse;
36-
import io.sentrius.agent.analysis.model.WebSocky;
3733
import io.sentrius.agent.analysis.model.ZtatAsessment;
3834
import io.sentrius.agent.analysis.model.ZtatResponse;
3935
import io.sentrius.sso.core.dto.AgentCommunicationDTO;
@@ -45,7 +41,6 @@
4541
import io.sentrius.sso.core.dto.ztat.AtatRequest;
4642
import io.sentrius.sso.core.dto.ztat.ZtatRequestDTO;
4743
import io.sentrius.sso.core.exceptions.ZtatException;
48-
import io.sentrius.sso.core.model.verbs.DefaultInterpreter;
4944
import io.sentrius.sso.core.model.verbs.Verb;
5045
import io.sentrius.sso.core.services.agents.AgentClientService;
5146
import io.sentrius.sso.core.services.agents.LLMService;
@@ -54,7 +49,6 @@
5449
import io.sentrius.sso.genai.Message;
5550
import io.sentrius.sso.genai.Response;
5651
import io.sentrius.sso.genai.model.LLMRequest;
57-
import lombok.NonNull;
5852
import lombok.extern.slf4j.Slf4j;
5953
import org.springframework.beans.factory.annotation.Value;
6054
import org.springframework.stereotype.Service;
@@ -66,16 +60,14 @@
6660
*/
6761
@Service
6862
@Slf4j
69-
public class AgentVerbs {
63+
public class AgentVerbs extends VerbBase {
7064

7165
final ZeroTrustClientService zeroTrustClientService;
7266
final LLMService llmService;
7367
final VerbRegistry verbRegistry;
74-
final AgentClientService agentClientService;
7568

7669

77-
@Value("${agent.ai.config}")
78-
private String agentConfigFile;
70+
7971

8072
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // Jackson ObjectMapper for YAML parsing
8173

@@ -88,14 +80,14 @@ public class AgentVerbs {
8880
* @throws JsonProcessingException If there is an error processing JSON during initialization.
8981
*/
9082
public AgentVerbs( @Value("${agent.ai.config}") String agentConfigFile,
83+
@Value("${agent.ai.context.db.id:none}") String agentDatabaseContext,
9184
ZeroTrustClientService zeroTrustClientService, LLMService llmService, VerbRegistry verbRegistry,
9285
AgentClientService agentService
9386
) throws JsonProcessingException {
87+
super(agentConfigFile, agentDatabaseContext, agentService);
9488
this.zeroTrustClientService = zeroTrustClientService;
9589
this.llmService = llmService;
9690
this.verbRegistry = verbRegistry;
97-
this.agentClientService = agentService;
98-
this.agentConfigFile = agentConfigFile;
9991

10092
log.info("Loading agent config from {}", agentConfigFile);
10193
}
@@ -112,11 +104,8 @@ public AgentVerbs( @Value("${agent.ai.config}") String agentConfigFile,
112104
isAiCallable = false, requiresTokenManagement = true)
113105
public ArrayNode promptAgent(AgentExecution execution, Map<String, Object> args) throws ZtatException,
114106
IOException {
115-
InputStream is = getClass().getClassLoader().getResourceAsStream(agentConfigFile);
116-
if (is == null) {
117-
throw new RuntimeException(agentConfigFile + " not found on classpath");
118-
}
119-
AgentConfig config = new ObjectMapper(new YAMLFactory()).readValue(is, AgentConfig.class);
107+
108+
AgentConfig config = getAgentConfig(execution);
120109

121110
log.info("Agent config loaded: {}", config);
122111
PromptBuilder promptBuilder = new PromptBuilder(verbRegistry, config);
@@ -125,7 +114,7 @@ public ArrayNode promptAgent(AgentExecution execution, Map<String, Object> args)
125114

126115
messages.add(Message.builder().role("system").content(prompt).build());
127116

128-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o").messages(messages).build();
117+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
129118
var resp = llmService.askQuestion(execution, chatRequest);
130119
execution.addMessages( messages );
131120
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);
@@ -232,7 +221,7 @@ public String justifyAgent(AgentExecution execution, ZtatRequestDTO ztatRequest,
232221
messages.add(Message.builder().role("system").content("please respond in the following json " +
233222
"format: " + respondZtat).build());
234223

235-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o").messages(messages).build();
224+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
236225
execution.addMessages( messages );
237226
var resp = llmService.askQuestion(execution, chatRequest);
238227
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);
@@ -290,11 +279,7 @@ public String justifyAgent(AgentExecution execution, ZtatRequestDTO ztatRequest,
290279
inputInterpreter =
291280
ObjectListInterpreter.class, requiresTokenManagement = true)
292281
public List<AssessedTerminal> assessData(AgentExecution execution, List<?> objectList) throws ZtatException, IOException {
293-
InputStream is = getClass().getClassLoader().getResourceAsStream(agentConfigFile);
294-
if (is == null) {
295-
throw new RuntimeException(agentConfigFile + " not found on classpath");
296-
}
297-
AgentConfig config = new ObjectMapper(new YAMLFactory()).readValue(is, AgentConfig.class);
282+
AgentConfig config = getAgentConfig(execution);
298283

299284
log.info("Agent config loaded: {}", config);
300285

@@ -311,7 +296,7 @@ public List<AssessedTerminal> assessData(AgentExecution execution, List<?> objec
311296

312297

313298

314-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o").messages(messages).build();
299+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
315300

316301
var resp = llmService.askQuestion(execution, chatRequest);
317302
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);
@@ -346,7 +331,7 @@ public List<AssessedTerminal> assessData(AgentExecution execution, List<?> objec
346331
execution.addMessages(assistantMessage);
347332

348333

349-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o").messages(messages).build();
334+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
350335
execution.addMessages(messages);
351336
var resp = llmService.askQuestion(execution, chatRequest);
352337
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);
@@ -431,11 +416,6 @@ public List<ZtatAsessment> analyzeAtatRequests(AgentExecution execution, List<At
431416
throws ZtatException,
432417
IOException, TimeoutException {
433418
// set up context
434-
InputStream is = getClass().getClassLoader().getResourceAsStream(agentConfigFile);
435-
if (is == null) {
436-
throw new RuntimeException("assessor-config.yaml not found on classpath");
437-
438-
}
439419

440420
InputStream assessZtatStream = getClass().getClassLoader().getResourceAsStream("assess-ztat.json");
441421
if (assessZtatStream == null) {
@@ -444,7 +424,7 @@ public List<ZtatAsessment> analyzeAtatRequests(AgentExecution execution, List<At
444424
}
445425
String assessZtat = new String(assessZtatStream.readAllBytes());
446426

447-
AgentConfig config = new ObjectMapper(new YAMLFactory()).readValue(is, AgentConfig.class);
427+
AgentConfig config = getAgentConfig(execution);
448428
log.info("Agent config loaded: {}", config);
449429
List<ZtatAsessment> responses = new ArrayList<>();
450430
log.info("Size of requests {}", requests.size());
@@ -466,7 +446,7 @@ public List<ZtatAsessment> analyzeAtatRequests(AgentExecution execution, List<At
466446

467447
log.info("Messages is {}", messages);
468448

469-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
449+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini-mini").messages(messages).build();
470450
var resp = llmService.askQuestion(execution, chatRequest);
471451
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);
472452
log.info("Assess Response is {}", resp);
@@ -530,7 +510,7 @@ public List<ZtatAsessment> analyzeAtatRequests(AgentExecution execution, List<At
530510

531511
log.info("Messages is {}", messages);
532512

533-
chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
513+
chatRequest = LLMRequest.builder().model("gpt-4o-mini-mini").messages(messages).build();
534514
resp = llmService.askQuestion(execution, chatRequest);
535515
response = JsonUtil.MAPPER.readValue(resp, Response.class);
536516
if (response.getChoices().isEmpty()) {
@@ -644,7 +624,7 @@ public ObjectNode getEndpointsLike(AgentExecution execution, ObjectNode queryInp
644624
List<Message> messages = new ArrayList<>();
645625
messages.add( listedEndpoints);
646626
execution.addMessages(Message.builder().role("user").content(queryInput.toString()).build());
647-
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o").messages(messages).build();
627+
LLMRequest chatRequest = LLMRequest.builder().model("gpt-4o-mini").messages(messages).build();
648628
var resp = llmService.askQuestion(execution, chatRequest);
649629

650630
Response response = JsonUtil.MAPPER.readValue(resp, Response.class);

ai-agent/src/main/java/io/sentrius/agent/analysis/agents/verbs/AtplVerbs.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
import io.sentrius.sso.core.exceptions.ZtatException;
1111
import io.sentrius.sso.core.model.verbs.DefaultInterpreter;
1212
import io.sentrius.sso.core.model.verbs.Verb;
13+
import io.sentrius.sso.core.services.agents.AgentClientService;
1314
import io.sentrius.sso.core.services.agents.LLMService;
1415
import io.sentrius.sso.core.services.agents.ZeroTrustClientService;
1516
import io.sentrius.sso.core.trust.ATPLPolicy;
1617
import io.sentrius.sso.core.utils.JsonUtil;
1718
import lombok.extern.slf4j.Slf4j;
19+
import org.springframework.beans.factory.annotation.Value;
1820
import org.springframework.stereotype.Service;
1921

2022
/**
@@ -23,7 +25,7 @@
2325
*/
2426
@Slf4j
2527
@Service
26-
public class AtplVerbs {
28+
public class AtplVerbs extends VerbBase {
2729

2830
final ZeroTrustClientService zeroTrustClientService;
2931
final LLMService llmService;
@@ -35,7 +37,11 @@ public class AtplVerbs {
3537
* @param zeroTrustClientService The service for interacting with Zero Trust APIs.
3638
* @param llmService The service for interacting with the LLM (Large Language Model).
3739
*/
38-
public AtplVerbs(ZeroTrustClientService zeroTrustClientService, LLMService llmService, AgentVerbs agentVerbs) {
40+
public AtplVerbs(@Value("${agent.ai.config}") String agentConfigFile,
41+
@Value("${agent.ai.context.db.id:none}") String agentDatabaseContext,
42+
ZeroTrustClientService zeroTrustClientService, LLMService llmService, AgentVerbs agentVerbs,
43+
AgentClientService agentClientService) {
44+
super(agentConfigFile, agentDatabaseContext, agentClientService);
3945
this.zeroTrustClientService = zeroTrustClientService;
4046
this.llmService = llmService;
4147
this.agentVerbs = agentVerbs;

0 commit comments

Comments
 (0)