Package io.jmix.dynmodelai.impl
Class DynamicModelAgentServiceImpl
java.lang.Object
io.jmix.dynmodelai.impl.DynamicModelAgentServiceImpl
- All Implemented Interfaces:
DynamicModelAgentService
@Component("dmagent_DynamicModelAgentService")
public class DynamicModelAgentServiceImpl
extends Object
implements DynamicModelAgentService
Default implementation of
DynamicModelAgentService.-
Constructor Summary
ConstructorsConstructorDescriptionDynamicModelAgentServiceImpl(AgentRunCoordinator runCoordinator, ConversationSessionWatchdog sessionWatchdog, ModelDraftService draftService, ConversationRepository conversationRepository, CurrentAuthentication currentAuthentication, Messages messages, AgentHistoryService historyService, EditorModelReviewService editorModelReviewService, EditorPublicationService publications) -
Method Summary
Modifier and TypeMethodDescriptionanswerHumanInput(AnswerHumanInputRequest request) Answers a pending question by starting a new Run in the same Conversation.voidapprovePlan(ApprovePlanRequest request) Approves the currently proposed plan.booleancancelRun(CancelRunRequest request) Returnstrueonly when this call cancelled an active Run,falsefor a retained terminal Run.voidcloseConversationSession(UUID conversationId) Ends the temporary work of one open Conversation UI.getConversation(UUID conversationId) Returns information about one Conversation without loading or counting its messages.org.springframework.data.domain.Page<ConversationMessage> getConversationMessages(UUID conversationId, org.springframework.data.domain.Pageable pageable) Returns persisted messages ordered by createdDate ascending, then id ascending, with their total count.org.springframework.data.domain.Page<ConversationSummary> getConversations(org.springframework.data.domain.Pageable pageable) Returns conversations ordered by lastModifiedDate descending, then id descending.getDraftModel(DraftReviewRequest request) Returns the complete candidate of the exact current successful Run, including unrelated settings.org.springframework.data.domain.Page<AgentHistoryRecord> getRunHistory(UUID conversationId, UUID runId, org.springframework.data.domain.Pageable pageable) Returns persisted Run events in sequence order, independently of runtime retention.getRunHistoryLocation(UUID runId, int messagePageSize) Locates a Run without scanning message pages; throws when no saved message exists.org.springframework.data.domain.Page<AgentHistoryRecord> getRunSnapshots(UUID conversationId, UUID runId, org.springframework.data.domain.Pageable pageable) Saved plan and terminal snapshots only, without loading the execution trace or model diagnostics.booleanisRunActive(AgentRun run) Checks whether this exact Run is still active, including waiting for plan approval.recordEditorPublication(UUID conversationId, @Nullable UUID baselineSettingsId, UUID publishedSettingsId) Records an already committed host publication.reviewEditorModel(EditorModelSnapshot snapshot) Validates the complete current editor, including manual changes, without creating a Run or Draft.reactor.core.publisher.Flux<AgentEvent> streamEvents(AgentEventsRequest request) Replays retained events after the requested sequence and then emits live events untilRunCompleted.submitMessage(SubmitMessageRequest request) Starts the asynchronous conversational graph with the request's explicit plan approval mode.voidtouchConversationSession(UUID conversationId) Tells the Engine that a Builder still works with the Conversation.
-
Constructor Details
-
DynamicModelAgentServiceImpl
public DynamicModelAgentServiceImpl(AgentRunCoordinator runCoordinator, ConversationSessionWatchdog sessionWatchdog, ModelDraftService draftService, ConversationRepository conversationRepository, CurrentAuthentication currentAuthentication, Messages messages, AgentHistoryService historyService, EditorModelReviewService editorModelReviewService, EditorPublicationService publications)
-
-
Method Details
-
getConversations
public org.springframework.data.domain.Page<ConversationSummary> getConversations(org.springframework.data.domain.Pageable pageable) Description copied from interface:DynamicModelAgentServiceReturns conversations ordered by lastModifiedDate descending, then id descending. Requires an unsorted, paged request of at most 200 records; otherwise throwsIllegalArgumentException. Pages are not a snapshot of live history.- Specified by:
getConversationsin interfaceDynamicModelAgentService
-
getRunHistoryLocation
public RunHistoryLocation getRunHistoryLocation(UUID runId, int messagePageSize) throws NoSuchElementException Description copied from interface:DynamicModelAgentServiceLocates a Run without scanning message pages; throws when no saved message exists.- Specified by:
getRunHistoryLocationin interfaceDynamicModelAgentService- Throws:
NoSuchElementException
-
getConversation
Description copied from interface:DynamicModelAgentServiceReturns information about one Conversation without loading or counting its messages.- Specified by:
getConversationin interfaceDynamicModelAgentService- Throws:
NoSuchElementException- if the Conversation does not exist
-
getConversationMessages
public org.springframework.data.domain.Page<ConversationMessage> getConversationMessages(UUID conversationId, org.springframework.data.domain.Pageable pageable) throws NoSuchElementException Description copied from interface:DynamicModelAgentServiceReturns persisted messages ordered by createdDate ascending, then id ascending, with their total count. Requires an unsorted, paged request of at most 200 records; otherwise throwsIllegalArgumentException. The Conversation must exist; an existing empty Conversation returns an empty page. The id resolves equal timestamps deterministically, not causally. Pages are not a snapshot of live history.- Specified by:
getConversationMessagesin interfaceDynamicModelAgentService- Throws:
NoSuchElementException- if the Conversation does not exist
-
recordEditorPublication
public ConversationMessage recordEditorPublication(UUID conversationId, @Nullable UUID baselineSettingsId, UUID publishedSettingsId) Description copied from interface:DynamicModelAgentServiceRecords an already committed host publication. Failure here never rolls back that publication.- Specified by:
recordEditorPublicationin interfaceDynamicModelAgentService
-
getRunHistory
public org.springframework.data.domain.Page<AgentHistoryRecord> getRunHistory(UUID conversationId, UUID runId, org.springframework.data.domain.Pageable pageable) Description copied from interface:DynamicModelAgentServiceReturns persisted Run events in sequence order, independently of runtime retention. Requires an unsorted page of at most 200 records. An existing Conversation with no recorded events for this Run returns an empty page, including Runs predating history recording. Reading history neither opens a session nor restores its Run or Draft. Historical sequence includes diagnostics and is independent of the live event cursor.- Specified by:
getRunHistoryin interfaceDynamicModelAgentService
-
getRunSnapshots
public org.springframework.data.domain.Page<AgentHistoryRecord> getRunSnapshots(UUID conversationId, UUID runId, org.springframework.data.domain.Pageable pageable) Description copied from interface:DynamicModelAgentServiceSaved plan and terminal snapshots only, without loading the execution trace or model diagnostics.- Specified by:
getRunSnapshotsin interfaceDynamicModelAgentService
-
submitMessage
Description copied from interface:DynamicModelAgentServiceStarts the asynchronous conversational graph with the request's explicit plan approval mode. Repeating the call creates a new Run. A plan waiting for manual approval is cancelled and supplied as unexecuted context for the new request, which must carry the same editor snapshot. Other active Runs reject the request withRUN_STATE_CONFLICT. An editor snapshot uses fresh complete editor content, without publishing it; without a snapshot the Run starts from the published model. A successful Run replaces the previous Draft.- Specified by:
submitMessagein interfaceDynamicModelAgentService- Throws:
NoSuchElementException- if a supplied Conversation id does not exist
-
streamEvents
Description copied from interface:DynamicModelAgentServiceReplays retained events after the requested sequence and then emits live events untilRunCompleted. A mandatory history write failure terminates this stream with an error and stops the Run. Diagnostics are available throughDynamicModelAgentService.getRunHistory(java.util.UUID, java.util.UUID, org.springframework.data.domain.Pageable), not this live stream. Unknown Runs (RUN_UNAVAILABLE) and gaps in retained history (EVENT_HISTORY_UNAVAILABLE) are rejected when this method is called, before subscription. If requested events are lost before subscription, the stream signalsEVENT_HISTORY_UNAVAILABLEbefore delivering an event after the gap.- Specified by:
streamEventsin interfaceDynamicModelAgentService
-
isRunActive
Description copied from interface:DynamicModelAgentServiceChecks whether this exact Run is still active, including waiting for plan approval. Returns false for terminal, unknown or expired Runs. Reads temporary state only, without opening a session, restoring history or refreshing its idle timeout.- Specified by:
isRunActivein interfaceDynamicModelAgentService
-
approvePlan
Description copied from interface:DynamicModelAgentServiceApproves the currently proposed plan. Execution starts asynchronously; repeated approval fails withRUN_STATE_CONFLICT. Unknown or expired Runs fail withRUN_UNAVAILABLE. Workspace preparation and execution happen in the resumed graph; failures end the Run throughRunCompletedand clean up its workspace.- Specified by:
approvePlanin interfaceDynamicModelAgentService
-
answerHumanInput
Description copied from interface:DynamicModelAgentServiceAnswers a pending question by starting a new Run in the same Conversation. Duplicate, closed or unknown questions fail withHUMAN_INPUT_UNAVAILABLE.- Specified by:
answerHumanInputin interfaceDynamicModelAgentService- Throws:
NoSuchElementException- if the question's Conversation no longer exists
-
cancelRun
Description copied from interface:DynamicModelAgentServiceReturnstrueonly when this call cancelled an active Run,falsefor a retained terminal Run. If Draft completion has already started, waits for its result without undoing it. Unknown or expired Runs fail withRUN_UNAVAILABLE.- Specified by:
cancelRunin interfaceDynamicModelAgentService
-
closeConversationSession
Description copied from interface:DynamicModelAgentServiceEnds the temporary work of one open Conversation UI. Persisted Conversation messages and Dynamic Model settings are not changed. Simple v1 expects one open Builder per Conversation. Waits for this session's registration and Draft cleanup, not for the full language-model call. Reopen the Conversation only after this command completes successfully.- Specified by:
closeConversationSessionin interfaceDynamicModelAgentService
-
touchConversationSession
Description copied from interface:DynamicModelAgentServiceTells the Engine that a Builder still works with the Conversation. Every other call of the Conversation counts as well. Temporary work nobody touched for the configured idle timeout is closed by the Engine as if the Builder had been closed.- Specified by:
touchConversationSessionin interfaceDynamicModelAgentService
-
getDraftModel
Description copied from interface:DynamicModelAgentServiceReturns the complete candidate of the exact current successful Run, including unrelated settings. Intended for atomic transfer to a shared editor afterRunCompleted(DRAFT_READY). Does not publish settings.- Specified by:
getDraftModelin interfaceDynamicModelAgentService
-
reviewEditorModel
Description copied from interface:DynamicModelAgentServiceValidates the complete current editor, including manual changes, without creating a Run or Draft. Returns final configurations of changed entities. A successful review does not reserve the captured revision.- Specified by:
reviewEditorModelin interfaceDynamicModelAgentService
-