Skip to content

Commit 7938213

Browse files
committed
Final update
1 parent e4b1ec7 commit 7938213

24 files changed

Lines changed: 382 additions & 244 deletions

File tree

.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.158
2-
SENTRIUS_SSH_VERSION=1.1.32
3-
SENTRIUS_KEYCLOAK_VERSION=1.1.44
4-
SENTRIUS_AGENT_VERSION=1.1.31
5-
SENTRIUS_AI_AGENT_VERSION=1.1.50
6-
LLMPROXY_VERSION=1.0.40
7-
LAUNCHER_VERSION=1.0.47
8-
AGENTPROXY_VERSION=1.0.58
1+
SENTRIUS_VERSION=1.1.170
2+
SENTRIUS_SSH_VERSION=1.1.33
3+
SENTRIUS_KEYCLOAK_VERSION=1.1.46
4+
SENTRIUS_AGENT_VERSION=1.1.33
5+
SENTRIUS_AI_AGENT_VERSION=1.1.60
6+
LLMPROXY_VERSION=1.0.43
7+
LAUNCHER_VERSION=1.0.49
8+
AGENTPROXY_VERSION=1.0.60

.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.158
2-
SENTRIUS_SSH_VERSION=1.1.32
3-
SENTRIUS_KEYCLOAK_VERSION=1.1.44
4-
SENTRIUS_AGENT_VERSION=1.1.31
5-
SENTRIUS_AI_AGENT_VERSION=1.1.50
6-
LLMPROXY_VERSION=1.0.40
7-
LAUNCHER_VERSION=1.0.47
8-
AGENTPROXY_VERSION=1.0.58
1+
SENTRIUS_VERSION=1.1.170
2+
SENTRIUS_SSH_VERSION=1.1.33
3+
SENTRIUS_KEYCLOAK_VERSION=1.1.46
4+
SENTRIUS_AGENT_VERSION=1.1.33
5+
SENTRIUS_AI_AGENT_VERSION=1.1.60
6+
LLMPROXY_VERSION=1.0.43
7+
LAUNCHER_VERSION=1.0.49
8+
AGENTPROXY_VERSION=1.0.60

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public void scanClasspath() {
7777
}
7878
}
7979

80+
public boolean isVerbRegistered(String verb) {
81+
synchronized (this) {
82+
return verbs.containsKey(verb);
83+
}
84+
}
85+
8086
public VerbResponse execute(AgentExecution agentExecution, VerbResponse priorResponse, String verb,
8187
Map<String, Object> args)
8288
throws Exception {

ai-agent/src/main/java/io/sentrius/agent/analysis/api/websocket/ChatWSHandler.java

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ChatWSHandler extends TextWebSocketHandler {
4747
// Store active sessions, using session ID or a custom identifier
4848

4949

50-
private final ChatAgent chatAgent;
50+
private final ChatAgent chatAgent;
5151
private final AgentClientService agentClientService;
5252
private final VerbRegistry verbRegistry;
5353

@@ -199,36 +199,49 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
199199

200200
websocky.get().getMessages().add(response);
201201

202-
if (response.getNextOperation() != null )
202+
if (response.getNextOperation() != null && !response.getNextOperation().isEmpty() &&
203+
verbRegistry.isVerbRegistered(response.getNextOperation()))
203204
{
204-
var lastVerbResponse =
205-
websocketCommunication.getVerbResponses().stream().reduce((prev, next) -> next).orElse(null);
206-
var executionResponse = verbRegistry.execute(chatAgent.getAgentExecution(),
207-
lastVerbResponse,
208-
response.getNextOperation(), Maps.newHashMap());
209-
210-
var nextResponse = chatVerbs.interpret_plan_response(
211-
chatAgent.getAgentExecution(), websocketCommunication,
212-
verbRegistry.getVerbs().get(response.getNextOperation()),
213-
executionResponse.getResponse().toString());
214-
215-
websocky.get().getMessages().add(nextResponse);
216-
217-
websocketCommunication.getVerbResponses().add(executionResponse);
218-
219-
var newNextMessage = Session.ChatMessage.newBuilder()
220-
.setMessage(String.format("{\"type\":\"user-message\",\"message\":\"%s\"}",
221-
nextResponse.getResponseForUser()))
222-
.setSender("agent")
223-
.setChatGroupId("")
224-
.setSessionId(Long.parseLong(websocketCommunication.getSessionId()))
225-
.setTimestamp(System.currentTimeMillis())
226-
.build();
227-
messageBytes = newNextMessage.toByteArray();
228-
base64Message = Base64.getEncoder().encodeToString(messageBytes);
229-
session.sendMessage(new TextMessage(
230-
base64Message
231-
));
205+
try {
206+
var lastVerbResponse =
207+
websocketCommunication.getVerbResponses().stream().reduce((prev, next) -> next)
208+
.orElse(null);
209+
var executionResponse = verbRegistry.execute(
210+
chatAgent.getAgentExecution(),
211+
lastVerbResponse,
212+
response.getNextOperation(), Maps.newHashMap()
213+
);
214+
215+
var nextResponse = chatVerbs.interpret_plan_response(
216+
chatAgent.getAgentExecution(), websocketCommunication,
217+
verbRegistry.getVerbs().get(response.getNextOperation()),
218+
executionResponse.getResponse().toString()
219+
);
220+
221+
websocky.get().getMessages().add(nextResponse);
222+
223+
websocketCommunication.getVerbResponses().add(executionResponse);
224+
225+
var newNextMessage = Session.ChatMessage.newBuilder()
226+
.setMessage(String.format(
227+
"{\"type\":\"user-message\",\"message\":\"%s\"}",
228+
nextResponse.getResponseForUser()
229+
))
230+
.setSender("agent")
231+
.setChatGroupId("")
232+
.setSessionId(Long.parseLong(websocketCommunication.getSessionId()))
233+
.setTimestamp(System.currentTimeMillis())
234+
.build();
235+
messageBytes = newNextMessage.toByteArray();
236+
base64Message = Base64.getEncoder().encodeToString(messageBytes);
237+
session.sendMessage(new TextMessage(
238+
base64Message
239+
));
240+
}catch (Exception e){
241+
e.printStackTrace();
242+
log.error("Error executing next operation: {}", e.getMessage());
243+
244+
}
232245

233246

234247
}

api/src/main/java/io/sentrius/sso/ApiApplication.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212
@EntityScan(basePackages = "io.sentrius.sso.core.model") // Replace with your actual entity package
1313
public class ApiApplication {
1414
public static void main(String[] args) {
15-
16-
String user = System.getenv("SPRING_DATASOURCE_USERNAME");
17-
String pass = System.getenv("SPRING_DATASOURCE_PASSWORD");
18-
19-
System.out.println("🔐 SPRING_DATASOURCE_USERNAME = " + user);
20-
System.out.println("🔐 SPRING_DATASOURCE_PASSWORD2 = " + pass);
21-
2215
SpringApplication.run(ApiApplication.class, args);
2316
}
2417
}

api/src/main/java/io/sentrius/sso/controllers/api/AgentApiController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public ResponseEntity<?> listAgents(HttpServletRequest request, HttpServletRespo
296296
@LimitAccess(applicationAccess = {ApplicationAccessEnum.CAN_LOG_IN}, allowedIdentityTypes = {IdentityType.NON_PERSON_ENTITY})
297297
public ResponseEntity<?> justifyOperations(
298298
@RequestHeader("Authorization") String token,
299-
@RequestHeader("communication_id") String communicationId,
299+
@RequestHeader("X-Communication-Id") String communicationId,
300300
@RequestParam("requestId") String requestId,
301301
HttpServletRequest request, HttpServletResponse response) throws SQLException, GeneralSecurityException {
302302

@@ -342,7 +342,7 @@ public ResponseEntity<?> justifyOperations(
342342
@LimitAccess(applicationAccess = {ApplicationAccessEnum.CAN_LOG_IN}, allowedIdentityTypes = {IdentityType.NON_PERSON_ENTITY})
343343
public ResponseEntity<?> justifyAccess(
344344
@RequestHeader("Authorization") String token,
345-
@RequestHeader("communication_id") String communicationId,
345+
@RequestHeader("X-Communication-Id") String communicationId,
346346
@RequestParam("requestId") String requestId,
347347
HttpServletRequest request, HttpServletResponse response) throws SQLException, GeneralSecurityException {
348348

@@ -509,7 +509,7 @@ public ResponseEntity<?> sendMessage(
509509
HttpServletRequest request,
510510
HttpServletResponse response,
511511
@RequestHeader("Authorization") String token,
512-
@RequestHeader("communication_id") String communicationId,
512+
@RequestHeader("X-Communication-Id") String communicationId,
513513
@RequestParam("requestId") String requestId,
514514
@RequestBody AgentCommunicationDTO comm)
515515
throws GeneralSecurityException, ExecutionException, InterruptedException {
@@ -578,7 +578,7 @@ public ResponseEntity<?> getNextMessage(
578578
HttpServletRequest request,
579579
HttpServletResponse response,
580580
@RequestHeader("Authorization") String token,
581-
@RequestHeader("communication_id") String communicationId,
581+
@RequestHeader("X-Communication-Id") String communicationId,
582582
@RequestParam("id") Long previousId)
583583
throws GeneralSecurityException, ExecutionException, InterruptedException {
584584

@@ -650,7 +650,7 @@ public ResponseEntity<?> getNextMessage(
650650
HttpServletRequest request,
651651
HttpServletResponse response,
652652
@RequestHeader("Authorization") String token,
653-
@RequestHeader("communication_id") String communicationId)
653+
@RequestHeader("X-Communication-Id") String communicationId)
654654
throws GeneralSecurityException, ExecutionException, InterruptedException {
655655

656656
String compactJwt = token.startsWith("Bearer ") ? token.substring(7) : token;

api/src/main/resources/templates/sso/atpl/configure.html

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,12 @@ <h6>Primitive Capability ${primitiveCounter + 1}</h6>
734734
<label>Description</label>
735735
<input type="text" class="form-control" name="capabilities.primitives[${primitiveCounter}].description">
736736
</div>
737+
<div class="form-group">
738+
<label>Endpoints</label>
739+
<div class="dynamic-list" id="primitive-endpoints-${primitiveCounter}">
740+
</div>
741+
<button type="button" class="btn-add" onclick="addListItem('primitive-endpoints-${primitiveCounter}', 'capabilities.primitives[${primitiveCounter}].endpoints')">Add Endpoint</button>
742+
</div>
737743
<div class="form-group">
738744
<label>Tags</label>
739745
<div class="dynamic-list" id="primitive-tags-${primitiveCounter}">
@@ -947,90 +953,62 @@ <h6>Endpoint Rule ${endpointCounter + 1}</h6>
947953
}
948954
}
949955

950-
// Convert FormData to proper policy object
951956
function formDataToPolicyObject() {
952957
const form = document.getElementById('atpl-form');
953958
const formData = new FormData(form);
954959
const policy = {};
955960

956-
// Helper function to set nested object properties
957-
function setNestedProperty(obj, path, value) {
958-
const keys = path.split('.');
959-
let current = obj;
960-
961-
for (let i = 0; i < keys.length - 1; i++) {
962-
const key = keys[i];
963-
if (!current[key]) current[key] = {};
964-
current = current[key];
965-
}
966-
967-
const lastKey = keys[keys.length - 1];
968-
969-
// Handle array notation [index]
970-
if (lastKey.includes('[') && lastKey.includes(']')) {
971-
const match = lastKey.match(/(\w+)\[(\d+)\]/);
961+
for (let [key, value] of formData.entries()) {
962+
if (value.trim() === '') continue;
963+
964+
// Fix: Properly merge primitives and their tags into the same object
965+
if (key.includes('[') && key.includes(']')) {
966+
const match = key.match(/([^.]+)\[(\d+)\]\.(.+)/);
972967
if (match) {
973-
const arrayKey = match[1];
968+
const arrayKey = match[1]; // e.g., 'primitives'
974969
const index = parseInt(match[2]);
975-
976-
if (!current[arrayKey]) current[arrayKey] = [];
977-
if (!current[arrayKey][index]) current[arrayKey][index] = {};
978-
979-
return current[arrayKey][index];
970+
const propertyPath = match[3]; // e.g., 'tags' or 'description'
971+
972+
if (!policy.capabilities) policy.capabilities = {};
973+
if (!policy.capabilities[arrayKey]) policy.capabilities[arrayKey] = [];
974+
if (!policy.capabilities[arrayKey][index]) policy.capabilities[arrayKey][index] = {};
975+
976+
// Support array properties (e.g., tags[])
977+
if (propertyPath.endsWith('[]')) {
978+
const prop = propertyPath.replace('[]', '');
979+
if (!policy.capabilities[arrayKey][index][prop]) policy.capabilities[arrayKey][index][prop] = [];
980+
policy.capabilities[arrayKey][index][prop].push(value);
981+
} else {
982+
policy.capabilities[arrayKey][index][propertyPath] = value;
983+
}
984+
continue;
980985
}
981986
}
982-
983-
return current;
984-
}
985987

986-
// Process form data
987-
for (let [key, value] of formData.entries()) {
988-
if (value.trim() === '') continue;
989-
988+
// Handle arrays for other fields
990989
if (key.includes('[]')) {
991-
// Handle arrays
992990
const arrayKey = key.replace('[]', '');
993991
const keys = arrayKey.split('.');
994992
let current = policy;
995-
993+
996994
for (let i = 0; i < keys.length - 1; i++) {
997995
if (!current[keys[i]]) current[keys[i]] = {};
998996
current = current[keys[i]];
999997
}
1000-
998+
1001999
const lastKey = keys[keys.length - 1];
10021000
if (!current[lastKey]) current[lastKey] = [];
10031001
current[lastKey].push(value);
1004-
} else if (key.includes('[') && key.includes(']')) {
1005-
// Handle indexed arrays for capabilities
1006-
const baseKey = key.substring(0, key.indexOf('['));
1007-
const match = key.match(/\[(\d+)\]\.(\w+)/);
1008-
1009-
if (match) {
1010-
const index = parseInt(match[1]);
1011-
const property = match[2];
1012-
1013-
const keys = baseKey.split('.');
1014-
let current = policy;
1015-
1016-
for (let i = 0; i < keys.length; i++) {
1017-
if (!current[keys[i]]) current[keys[i]] = {};
1018-
current = current[keys[i]];
1019-
}
1020-
1021-
if (!current[index]) current[index] = {};
1022-
current[index][property] = value;
1023-
}
10241002
} else {
10251003
// Handle regular nested properties
10261004
const keys = key.split('.');
10271005
let current = policy;
1028-
1006+
10291007
for (let i = 0; i < keys.length - 1; i++) {
10301008
if (!current[keys[i]]) current[keys[i]] = {};
10311009
current = current[keys[i]];
10321010
}
1033-
1011+
10341012
current[keys[keys.length - 1]] = value;
10351013
}
10361014
}
@@ -1040,12 +1018,12 @@ <h6>Endpoint Rule ${endpointCounter + 1}</h6>
10401018
checkboxes.forEach(checkbox => {
10411019
const keys = checkbox.name.split('.');
10421020
let current = policy;
1043-
1021+
10441022
for (let i = 0; i < keys.length - 1; i++) {
10451023
if (!current[keys[i]]) current[keys[i]] = {};
10461024
current = current[keys[i]];
10471025
}
1048-
1026+
10491027
current[keys[keys.length - 1]] = checkbox.checked;
10501028
});
10511029

@@ -1184,7 +1162,7 @@ <h6>Endpoint Rule ${endpointCounter + 1}</h6>
11841162
// Populate match criteria
11851163
if (policy.match && policy.match.agent_tags) {
11861164
policy.match.agent_tags.forEach(tag => {
1187-
addListItem('agent-tags-list', 'agent_tags');
1165+
addListItem('agent-tags-list', 'match.agent_tags');
11881166
const inputs = document.querySelectorAll('#agent-tags-list input');
11891167
inputs[inputs.length - 1].value = tag;
11901168
});
@@ -1241,7 +1219,20 @@ <h6>Endpoint Rule ${endpointCounter + 1}</h6>
12411219

12421220
if (primitive.id) container.querySelector('input[name*=".id"]').value = primitive.id;
12431221
if (primitive.description) container.querySelector('input[name*=".description"]').value = primitive.description;
1244-
1222+
1223+
if (primitive.endpoints) {
1224+
const tagsList = container.querySelector('.dynamic-list');
1225+
primitive.endpoints.forEach(endpoint => {
1226+
addListItem(
1227+
tagsList.id,
1228+
'capabilities.primitives[' + (primitiveCounter - 1) + '].endpoint'
1229+
);
1230+
const inputs = tagsList.querySelectorAll('input');
1231+
inputs[inputs.length - 1].value = endpoint;
1232+
});
1233+
}
1234+
1235+
12451236
if (primitive.tags) {
12461237
const tagsList = container.querySelector('.dynamic-list');
12471238
primitive.tags.forEach(tag => {

0 commit comments

Comments
 (0)