Function bodies 269 total
getSearchTargets method · java · L153-L156 (4 LOC)src/main/java/com/matoe/controller/AdminController.java
public ResponseEntity<List<SearchTargetEntity>> getSearchTargets(@PathVariable String agentName) {
return ResponseEntity.ok(
searchTargetRepo.findByAgentNameAndEnabledTrueOrderByPriorityAsc(agentName));
}getSystemStatus method · java · L187-L194 (8 LOC)src/main/java/com/matoe/controller/AdminController.java
public ResponseEntity<Map<String, Object>> getSystemStatus() {
return ResponseEntity.ok(Map.of(
"status", "running",
"agents", promptService.getAgentNames(),
"searchTargets", searchTargetRepo.count(),
"version", "0.1.0"
));
}TravelController class · java · L24-L86 (63 LOC)src/main/java/com/matoe/controller/TravelController.java
public class TravelController {
private final TravelService travelService;
private final AgentProgressService progressService;
private final PdfExportService pdfExportService;
public TravelController(TravelService travelService,
AgentProgressService progressService,
PdfExportService pdfExportService) {
this.travelService = travelService;
this.progressService = progressService;
this.pdfExportService = pdfExportService;
}
/** Open this EventSource BEFORE calling POST /plan with the same sessionId. */
@GetMapping(value = "/progress/{sessionId}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter subscribeToProgress(@PathVariable String sessionId) {
return progressService.subscribe(sessionId);
}
/** POST /api/travel/plan?sessionId=xyz (sessionId optional) */
@PostMapping("/plan")
public ResponseEntity<UnforgettableItinerary> planTrip(
TravelController method · java · L30-L36 (7 LOC)src/main/java/com/matoe/controller/TravelController.java
public TravelController(TravelService travelService,
AgentProgressService progressService,
PdfExportService pdfExportService) {
this.travelService = travelService;
this.progressService = progressService;
this.pdfExportService = pdfExportService;
}subscribeToProgress method · java · L40-L42 (3 LOC)src/main/java/com/matoe/controller/TravelController.java
public SseEmitter subscribeToProgress(@PathVariable String sessionId) {
return progressService.subscribe(sessionId);
}getAllItineraries method · java · L53-L55 (3 LOC)src/main/java/com/matoe/controller/TravelController.java
public ResponseEntity<List<UnforgettableItinerary>> getAllItineraries() {
return ResponseEntity.ok(travelService.getAllItineraries());
}searchItineraries method · java · L58-L61 (4 LOC)src/main/java/com/matoe/controller/TravelController.java
public ResponseEntity<List<UnforgettableItinerary>> searchItineraries(
@RequestParam String destination) {
return ResponseEntity.ok(travelService.searchItineraries(destination));
}Open data scored by Repobility · https://repobility.com
downloadPdf method · java · L65-L76 (12 LOC)src/main/java/com/matoe/controller/TravelController.java
public ResponseEntity<byte[]> downloadPdf(@PathVariable String id) {
UnforgettableItinerary it = travelService.getItinerary(id);
if (it == null) return ResponseEntity.notFound().build();
byte[] pdf = pdfExportService.render(it);
String safeDest = it.destination() == null ? "itinerary"
: it.destination().replaceAll("[^A-Za-z0-9_.-]", "_");
String filename = "matoe-" + safeDest + "-" + id + ".pdf";
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
.contentType(MediaType.APPLICATION_PDF)
.body(pdf);
}health method · java · L79-L85 (7 LOC)src/main/java/com/matoe/controller/TravelController.java
public ResponseEntity<Map<String, Object>> health() {
return ResponseEntity.ok(Map.of(
"status", "ok",
"service", "M.A.T.O.E",
"version", "0.1.0"
));
}AccommodationOption class · java · L6-L27 (22 LOC)src/main/java/com/matoe/domain/AccommodationOption.java
public record AccommodationOption(
@JsonProperty("id") String id,
@JsonProperty("type") String type, // "hotel", "bb", "apartment", "hostel"
@JsonProperty("name") String name,
@JsonProperty("pricePerNight") double pricePerNight,
@JsonProperty("totalPrice") double totalPrice,
@JsonProperty("rating") double rating,
@JsonProperty("location") String location,
@JsonProperty("amenities") List<String> amenities,
@JsonProperty("bookingUrl") String bookingUrl,
@JsonProperty("tier") String tier, // "budget", "standard", "luxury"
@JsonProperty("source") String source, // "browser", "llm", "api" — provenance tracking
@JsonProperty("imageUrl") String imageUrl
) {
/** Backwards-compatible constructor. */
public AccommodationOption(String id, String type, String name, double pricePerNight,
double totalPrice, double rating, String location,
List<SAccommodationOption method · java · L21-L26 (6 LOC)src/main/java/com/matoe/domain/AccommodationOption.java
public AccommodationOption(String id, String type, String name, double pricePerNight,
double totalPrice, double rating, String location,
List<String> amenities, String bookingUrl, String tier) {
this(id, type, name, pricePerNight, totalPrice, rating, location,
amenities, bookingUrl, tier, "llm", "");
}AttractionOption class · java · L6-L19 (14 LOC)src/main/java/com/matoe/domain/AttractionOption.java
public record AttractionOption(
@JsonProperty("id") String id,
@JsonProperty("name") String name,
@JsonProperty("description") String description,
@JsonProperty("category") String category, // "museum", "tour", "food", "nature", "nightlife", etc.
@JsonProperty("price") double price,
@JsonProperty("duration") String duration, // e.g. "2h", "half-day"
@JsonProperty("rating") double rating,
@JsonProperty("location") String location,
@JsonProperty("bookingUrl") String bookingUrl,
@JsonProperty("tier") String tier,
@JsonProperty("source") String source,
@JsonProperty("tags") List<String> tags
) {}ItineraryDay class · java · L9-L20 (12 LOC)src/main/java/com/matoe/domain/ItineraryDay.java
public record ItineraryDay(
@JsonProperty("dayNumber") int dayNumber,
@JsonProperty("date") String date,
@JsonProperty("title") String title, // e.g. "Arrival & Montmartre Exploration"
@JsonProperty("summary") String summary,
@JsonProperty("morningActivities") List<String> morningActivities,
@JsonProperty("afternoonActivities") List<String> afternoonActivities,
@JsonProperty("eveningActivities") List<String> eveningActivities,
@JsonProperty("meals") List<String> meals, // restaurant/food suggestions
@JsonProperty("transportNotes") String transportNotes,
@JsonProperty("estimatedDayCost") double estimatedDayCost
) {}ItineraryVariant class · java · L9-L18 (10 LOC)src/main/java/com/matoe/domain/ItineraryVariant.java
public record ItineraryVariant(
@JsonProperty("tier") String tier, // "budget", "standard", "luxury"
@JsonProperty("totalEstimatedCost") double totalEstimatedCost,
@JsonProperty("accommodations") List<AccommodationOption> accommodations,
@JsonProperty("transport") List<TransportOption> transport,
@JsonProperty("attractions") List<AttractionOption> attractions,
@JsonProperty("dayByDay") List<ItineraryDay> dayByDay,
@JsonProperty("highlights") List<String> highlights, // e.g. "Best value for couples"
@JsonProperty("tradeoffs") String tradeoffs // e.g. "Fewer amenities, longer transit"
) {}TransportOption class · java · L5-L27 (23 LOC)src/main/java/com/matoe/domain/TransportOption.java
public record TransportOption(
@JsonProperty("id") String id,
@JsonProperty("type") String type, // "flight", "car", "bus", "train", "ferry"
@JsonProperty("provider") String provider,
@JsonProperty("departureTime") String departureTime,
@JsonProperty("arrivalTime") String arrivalTime,
@JsonProperty("duration") String duration,
@JsonProperty("price") double price,
@JsonProperty("stops") int stops,
@JsonProperty("bookingUrl") String bookingUrl,
@JsonProperty("tier") String tier, // "budget", "standard", "luxury"
@JsonProperty("source") String source, // "browser", "llm", "api"
@JsonProperty("origin") String origin,
@JsonProperty("destination") String destination
) {
/** Backwards-compatible constructor. */
public TransportOption(String id, String type, String provider, String departureTime,
String arrivalTime, String duration, double price, int stops,
Want this analysis on your repo? https://repobility.com/scan/
TransportOption method · java · L21-L26 (6 LOC)src/main/java/com/matoe/domain/TransportOption.java
public TransportOption(String id, String type, String provider, String departureTime,
String arrivalTime, String duration, double price, int stops,
String bookingUrl, String tier) {
this(id, type, provider, departureTime, arrivalTime, duration, price, stops,
bookingUrl, tier, "llm", "", "");
}TravelRequest class · java · L11-L44 (34 LOC)src/main/java/com/matoe/domain/TravelRequest.java
public record TravelRequest(
@JsonProperty("destination") String destination,
@JsonProperty("destinations") List<String> destinations, // multi-destination support
@JsonProperty("startDate") LocalDate startDate,
@JsonProperty("endDate") LocalDate endDate,
@JsonProperty("guestCount") int guestCount,
@JsonProperty("budgetMin") double budgetMin,
@JsonProperty("budgetMax") double budgetMax,
@JsonProperty("travelStyle") String travelStyle, // "budget", "standard", "luxury"
@JsonProperty("accommodationTypes") List<String> accommodationTypes, // "hotel", "bb", "apartment", "hostel"
@JsonProperty("transportTypes") List<String> transportTypes, // "flight", "car", "bus", "train", "ferry"
@JsonProperty("interestTags") List<String> interestTags, // "food", "history", "nature", "nightlife", etc.
@JsonProperty("orchestratorModel") String orchestratorModel,
@JsonProperty("extractorModel") String extractorModel,
@JsonPnights method · java · L40-L43 (4 LOC)src/main/java/com/matoe/domain/TravelRequest.java
public long nights() {
long n = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate);
return n > 0 ? n : 1;
}UnforgettableItinerary class · java · L12-L37 (26 LOC)src/main/java/com/matoe/domain/UnforgettableItinerary.java
public record UnforgettableItinerary(
@JsonProperty("id") String id,
@JsonProperty("destination") String destination,
@JsonProperty("startDate") String startDate,
@JsonProperty("endDate") String endDate,
@JsonProperty("guestCount") int guestCount,
@JsonProperty("regionInsights") Map<String, Object> regionInsights,
@JsonProperty("accommodations") List<AccommodationOption> accommodations,
@JsonProperty("transport") List<TransportOption> transport,
@JsonProperty("attractions") List<AttractionOption> attractions,
@JsonProperty("variants") List<ItineraryVariant> variants,
@JsonProperty("totalEstimatedCost") double totalEstimatedCost,
@JsonProperty("weatherForecast") Map<String, Object> weatherForecast,
@JsonProperty("currencyInfo") Map<String, Object> currencyInfo,
@JsonProperty("createdAt") LocalDateTime createdAt
) {
/** Backwards-compatible constructor (no variants, attractions, weather, currency). */
public UnforgettableItiUnforgettableItinerary method · java · L29-L36 (8 LOC)src/main/java/com/matoe/domain/UnforgettableItinerary.java
public UnforgettableItinerary(String id, String destination, String startDate, String endDate,
int guestCount, Map<String, Object> regionInsights,
List<AccommodationOption> accommodations, List<TransportOption> transport,
double totalEstimatedCost, LocalDateTime createdAt) {
this(id, destination, startDate, endDate, guestCount, regionInsights,
accommodations, transport, List.of(), List.of(),
totalEstimatedCost, Map.of(), Map.of(), createdAt);
}ItineraryEntity class · java · L11-L107 (97 LOC)src/main/java/com/matoe/entity/ItineraryEntity.java
public class ItineraryEntity {
@Id
@Column(length = 36)
private String id;
@Column(nullable = false, length = 255)
private String destination;
@Column(name = "start_date", nullable = false, length = 20)
private String startDate;
@Column(name = "end_date", nullable = false, length = 20)
private String endDate;
@Column(name = "guest_count", nullable = false)
private int guestCount;
@Column(name = "total_estimated_cost", nullable = false)
private double totalEstimatedCost;
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
@Column(name = "region_insights_json", columnDefinition = "TEXT")
private String regionInsightsJson;
@Column(name = "accommodations_json", columnDefinition = "TEXT")
private String accommodationsJson;
@Column(name = "transport_json", columnDefinition = "TEXT")
private String transportJson;
@Column(name = "attractions_json", columnDefinition = "ItineraryEntity method · java · L61-L74 (14 LOC)src/main/java/com/matoe/entity/ItineraryEntity.java
public ItineraryEntity(String id, String destination, String startDate, String endDate,
int guestCount, double totalEstimatedCost, LocalDateTime createdAt,
String regionInsightsJson, String accommodationsJson, String transportJson) {
this.id = id;
this.destination = destination;
this.startDate = startDate;
this.endDate = endDate;
this.guestCount = guestCount;
this.totalEstimatedCost = totalEstimatedCost;
this.createdAt = createdAt;
this.regionInsightsJson = regionInsightsJson;
this.accommodationsJson = accommodationsJson;
this.transportJson = transportJson;
}LlmCostLogEntity class · java · L12-L77 (66 LOC)src/main/java/com/matoe/entity/LlmCostLogEntity.java
public class LlmCostLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "session_id", length = 100)
private String sessionId;
@Column(name = "agent_name", nullable = false, length = 100)
private String agentName;
@Column(nullable = false, length = 200)
private String model;
@Column(nullable = false, length = 50)
private String provider;
@Column(name = "input_tokens")
private int inputTokens;
@Column(name = "output_tokens")
private int outputTokens;
@Column(name = "estimated_cost")
private double estimatedCost;
@Column(name = "duration_ms")
private long durationMs;
@Column(nullable = false)
private boolean success = true;
@Column(name = "error_message", columnDefinition = "TEXT")
private String errorMessage;
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt = LocalDateTime.now();
public LlmCostLoRepobility — same analyzer, your code, free for public repos · /scan/
PromptVersionEntity class · java · L10-L56 (47 LOC)src/main/java/com/matoe/entity/PromptVersionEntity.java
public class PromptVersionEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "agent_name", nullable = false, length = 100)
private String agentName;
@Column(name = "prompt_text", nullable = false, columnDefinition = "TEXT")
private String promptText;
@Column(nullable = false)
private int version = 1;
@Column(name = "is_active", nullable = false)
private boolean active = true;
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt = LocalDateTime.now();
@Column(name = "created_by", length = 100)
private String createdBy = "system";
public PromptVersionEntity() {}
public PromptVersionEntity(String agentName, String promptText, int version) {
this.agentName = agentName;
this.promptText = promptText;
this.version = version;
}
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
PromptVersionEntity method · java · L36-L40 (5 LOC)src/main/java/com/matoe/entity/PromptVersionEntity.java
public PromptVersionEntity(String agentName, String promptText, int version) {
this.agentName = agentName;
this.promptText = promptText;
this.version = version;
}SearchTargetEntity class · java · L9-L49 (41 LOC)src/main/java/com/matoe/entity/SearchTargetEntity.java
public class SearchTargetEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "agent_name", nullable = false, length = 100)
private String agentName;
@Column(name = "site_url", nullable = false, length = 500)
private String siteUrl;
@Column(nullable = false)
private boolean enabled = true;
@Column(nullable = false)
private int priority;
@Column(name = "rate_limit_rpm")
private int rateLimitRpm = 10;
@Column(length = 500)
private String notes;
public SearchTargetEntity() {}
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getAgentName() { return agentName; }
public void setAgentName(String v) { this.agentName = v; }
public String getSiteUrl() { return siteUrl; }
public void setSiteUrl(String v) { this.siteUrl = v; }
public boolean isEnabled() { return enabled; }
public void setEnabled(boolean v) MATOEApplication class · java · L9-L13 (5 LOC)src/main/java/com/matoe/MATOEApplication.java
public class MATOEApplication {
public static void main(String[] args) {
SpringApplication.run(MATOEApplication.class, args);
}
}main method · java · L10-L12 (3 LOC)src/main/java/com/matoe/MATOEApplication.java
public static void main(String[] args) {
SpringApplication.run(MATOEApplication.class, args);
}AgentProgressEvent class · java · L6-L11 (6 LOC)src/main/java/com/matoe/service/AgentProgressEvent.java
public record AgentProgressEvent(
String agentName,
String status, // "idle" | "searching" | "analyzing" | "completed" | "error"
int progress, // 0–100
String message // human-readable detail
) {}AgentProgressEvent function · java · L6-L11 (6 LOC)src/main/java/com/matoe/service/AgentProgressEvent.java
public record AgentProgressEvent(
String agentName,
String status, // "idle" | "searching" | "analyzing" | "completed" | "error"
int progress, // 0–100
String message // human-readable detail
) {}AgentProgressService class · java · L18-L98 (81 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public class AgentProgressService {
private static final Logger log = LoggerFactory.getLogger(AgentProgressService.class);
private final ConcurrentHashMap<String, SseEmitter> emitters = new ConcurrentHashMap<>();
private final ObjectMapper objectMapper;
public AgentProgressService(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
/**
* Register a new SSE emitter for a session. The frontend calls this endpoint
* before dispatching the POST /plan request.
*/
public SseEmitter subscribe(String sessionId) {
SseEmitter emitter = new SseEmitter(300_000L); // 5-minute timeout
emitters.put(sessionId, emitter);
emitter.onCompletion(() -> {
emitters.remove(sessionId);
log.debug("SSE completed for session {}", sessionId);
});
emitter.onTimeout(() -> {
emitters.remove(sessionId);
log.debug("SSE timed out for session {}", sessionId);
Repobility · MCP-ready · https://repobility.com
AgentProgressService method · java · L25-L27 (3 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public AgentProgressService(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}subscribe method · java · L33-L52 (20 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public SseEmitter subscribe(String sessionId) {
SseEmitter emitter = new SseEmitter(300_000L); // 5-minute timeout
emitters.put(sessionId, emitter);
emitter.onCompletion(() -> {
emitters.remove(sessionId);
log.debug("SSE completed for session {}", sessionId);
});
emitter.onTimeout(() -> {
emitters.remove(sessionId);
log.debug("SSE timed out for session {}", sessionId);
});
emitter.onError(e -> {
emitters.remove(sessionId);
log.debug("SSE error for session {}: {}", sessionId, e.getMessage());
});
log.info("SSE subscriber registered: {}", sessionId);
return emitter;
}broadcast method · java · L57-L73 (17 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public void broadcast(String sessionId, AgentProgressEvent event) {
if (sessionId == null || sessionId.isBlank()) return;
SseEmitter emitter = emitters.get(sessionId);
if (emitter == null) return;
try {
String json = objectMapper.writeValueAsString(event);
emitter.send(SseEmitter.event()
.name("agent-progress")
.data(json)
.id(String.valueOf(System.currentTimeMillis())));
} catch (IOException e) {
log.debug("SSE send failed for session {}, removing emitter", sessionId);
emitters.remove(sessionId);
}
}complete method · java · L78-L90 (13 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public void complete(String sessionId) {
if (sessionId == null || sessionId.isBlank()) return;
SseEmitter emitter = emitters.remove(sessionId);
if (emitter == null) return;
try {
emitter.send(SseEmitter.event().name("complete").data("{\"status\":\"done\"}"));
emitter.complete();
} catch (IOException ignored) {
// emitter may already be closed
}
}update method · java · L95-L97 (3 LOC)src/main/java/com/matoe/service/AgentProgressService.java
public void update(String sessionId, String agentName, String status, int progress, String message) {
broadcast(sessionId, new AgentProgressEvent(agentName, status, progress, message));
}BrowserAgentService function · java · L40-L43 (4 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
public BrowserAgentService(WebClient.Builder webClientBuilder, ObjectMapper objectMapper) {
this.webClient = webClientBuilder.build();
this.objectMapper = objectMapper;
}isAvailable function · java · L48-L61 (14 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
public boolean isAvailable() {
if (!enabled) return false;
try {
Map<?, ?> health = webClient.get()
.uri(browserServiceUrl + "/health")
.retrieve()
.bodyToMono(Map.class)
.block(Duration.ofSeconds(5));
return health != null && "ok".equals(health.get("status"));
} catch (Exception e) {
log.debug("Browser service unavailable: {}", e.getMessage());
return false;
}
}browseForList function · java · L72-L96 (25 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
public List<Map<String, Object>> browseForList(
String task, List<String> sites, String extractionHint, String model) {
try {
Map<String, Object> result = browse(task, sites, extractionHint, model);
if (result == null || !(Boolean) result.get("success")) {
log.warn("Browser task failed: {}", result != null ? result.get("error") : "null response");
return null;
}
Object data = result.get("result");
if (data instanceof List) {
//noinspection unchecked
return (List<Map<String, Object>>) data;
}
if (data instanceof String) {
// Try to parse raw string as JSON array
String raw = (String) data;
return objectMapper.readValue(raw, new TypeReference<List<Map<String, Object>>>() {});
}
return null;
} catch (Exception e) {
log.warn("broOpen data scored by Repobility · https://repobility.com
browseForMap function · java · L101-L122 (22 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
public Map<String, Object> browseForMap(
String task, List<String> sites, String extractionHint, String model) {
try {
Map<String, Object> result = browse(task, sites, extractionHint, model);
if (result == null || !(Boolean) result.get("success")) {
return null;
}
Object data = result.get("result");
if (data instanceof Map) {
//noinspection unchecked
return (Map<String, Object>) data;
}
if (data instanceof String) {
return objectMapper.readValue((String) data, new TypeReference<Map<String, Object>>() {});
}
return null;
} catch (Exception e) {
log.warn("browseForMap failed: {}", e.getMessage());
return null;
}
}browseBatch function · java · L128-L142 (15 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
public List<Map<String, Object>> browseBatch(List<Map<String, Object>> requests) {
try {
//noinspection unchecked
return webClient.post()
.uri(browserServiceUrl + "/browse/batch")
.header("Content-Type", "application/json")
.bodyValue(requests)
.retrieve()
.bodyToMono(List.class)
.block(Duration.ofSeconds((long) timeoutSeconds * requests.size()));
} catch (Exception e) {
log.warn("browseBatch failed: {}", e.getMessage());
return List.of();
}
}browse function · java · L146-L168 (23 LOC)src/main/java/com/matoe/service/BrowserAgentService.java
private Map<String, Object> browse(
String task, List<String> sites, String extractionHint, String model) {
Map<String, Object> body = Map.of(
"task", task,
"sites", sites != null ? sites : List.of(),
"extraction_schema", extractionHint != null ? extractionHint : "",
"model", model != null ? model : "",
"max_steps", maxSteps,
"timeout_seconds", timeoutSeconds
);
log.info("Dispatching browser task to {}: {}", browserServiceUrl, task.substring(0, Math.min(80, task.length())));
//noinspection unchecked
return webClient.post()
.uri(browserServiceUrl + "/browse")
.header("Content-Type", "application/json")
.bodyValue(body)
.retrieve()
.bodyToMono(Map.class)
.block(Duration.ofSeconds(timeoutSeconds + 30));
}DynamicPromptService class · java · L19-L87 (69 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public class DynamicPromptService {
private static final Logger log = LoggerFactory.getLogger(DynamicPromptService.class);
private final PromptVersionRepository promptRepo;
private final ConcurrentHashMap<String, String> yamlDefaults = new ConcurrentHashMap<>();
public DynamicPromptService(PromptVersionRepository promptRepo) {
this.promptRepo = promptRepo;
}
/** Register the YAML default for an agent (called at startup). */
public void registerDefault(String agentName, String yamlPrompt) {
yamlDefaults.put(agentName, yamlPrompt);
}
/** Get the active prompt for an agent. DB version wins over YAML. */
public String getPrompt(String agentName) {
return promptRepo.findByAgentNameAndActiveTrue(agentName)
.map(PromptVersionEntity::getPromptText)
.orElseGet(() -> yamlDefaults.getOrDefault(agentName, ""));
}
/** Save a new prompt version (admin action). Deactivates the previous active versionDynamicPromptService method · java · L26-L28 (3 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public DynamicPromptService(PromptVersionRepository promptRepo) {
this.promptRepo = promptRepo;
}registerDefault method · java · L31-L33 (3 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public void registerDefault(String agentName, String yamlPrompt) {
yamlDefaults.put(agentName, yamlPrompt);
}getPrompt method · java · L36-L40 (5 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public String getPrompt(String agentName) {
return promptRepo.findByAgentNameAndActiveTrue(agentName)
.map(PromptVersionEntity::getPromptText)
.orElseGet(() -> yamlDefaults.getOrDefault(agentName, ""));
}savePrompt method · java · L43-L56 (14 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public PromptVersionEntity savePrompt(String agentName, String promptText, String author) {
// Deactivate current active
promptRepo.findByAgentNameAndActiveTrue(agentName)
.ifPresent(prev -> { prev.setActive(false); promptRepo.save(prev); });
// Determine next version number
List<PromptVersionEntity> history = promptRepo.findByAgentNameOrderByVersionDesc(agentName);
int nextVersion = history.isEmpty() ? 1 : history.get(0).getVersion() + 1;
PromptVersionEntity entity = new PromptVersionEntity(agentName, promptText, nextVersion);
entity.setCreatedBy(author != null ? author : "admin");
entity.setCreatedAt(LocalDateTime.now());
return promptRepo.save(entity);
}Want this analysis on your repo? https://repobility.com/scan/
rollback method · java · L59-L69 (11 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public PromptVersionEntity rollback(String agentName, int version) {
List<PromptVersionEntity> history = promptRepo.findByAgentNameOrderByVersionDesc(agentName);
// Deactivate all
history.forEach(e -> { e.setActive(false); promptRepo.save(e); });
// Activate the target version
return history.stream()
.filter(e -> e.getVersion() == version)
.findFirst()
.map(e -> { e.setActive(true); return promptRepo.save(e); })
.orElseThrow(() -> new IllegalArgumentException("Version " + version + " not found for " + agentName));
}getHistory method · java · L72-L74 (3 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public List<PromptVersionEntity> getHistory(String agentName) {
return promptRepo.findByAgentNameOrderByVersionDesc(agentName);
}getAllActive method · java · L77-L79 (3 LOC)src/main/java/com/matoe/service/DynamicPromptService.java
public List<PromptVersionEntity> getAllActive() {
return promptRepo.findByActiveTrueOrderByAgentName();
}