Class DevModeService
java.lang.Object
ai.nervemind.app.service.DevModeService
- All Implemented Interfaces:
ai.nervemind.common.service.DevModeServiceInterface
@Service
public class DevModeService
extends Object
implements ai.nervemind.common.service.DevModeServiceInterface
Service for Developer Mode features.
Centralizes all developer mode checks and provides utilities for:
- Node execution timing and performance metrics
- Debug bundle export (workflow + execution logs)
- HTTP request verbose logging
- Expression context inspection
Developer mode is controlled by the advanced.devMode setting.
When enabled, additional debugging features become available throughout
the application.
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a log entry in the execution log.static final recordRepresents expression context data for debugging.static final recordRepresents an HTTP request/response log entry.static final recordRepresents timing information for a single node execution.Nested classes/interfaces inherited from interface ai.nervemind.common.service.DevModeServiceInterface
ai.nervemind.common.service.DevModeServiceInterface.StepExecutionListener -
Constructor Summary
ConstructorsConstructorDescriptionDevModeService(ai.nervemind.common.service.SettingsServiceInterface settingsService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates the DevModeService with required dependencies. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStepExecutionListener(ai.nervemind.common.service.DevModeServiceInterface.StepExecutionListener listener) Adds a listener for step execution events.buildExpressionContext(Map<String, Object> variables, Map<String, Object> nodeOutputs, Map<String, Object> workflowData) Build expression context for inspection.voidSignal to cancel step execution.voidClear HTTP request logs.voidClear all timing data (call at execution start).voidSignal to continue to the next step.exportDebugBundle(ai.nervemind.common.dto.WorkflowDTO workflow, Path outputPath, String executionId) Export a debug bundle containing workflow, execution data, and logs.exportNodeAsJson(Object node) Export a node's configuration as JSON string.formatExpressionContext(Object context) Format expression context as readable string.Format HTTP request logs as a readable string.Format a timing summary for console display.Get all node timings for the current execution.Get all execution log entries.Get HTTP request logs.getNodeTiming(String nodeId) Get timing information for a node.Get the node ID that is currently paused (if any).intGet the total number of nodes timed in current execution.longGet the total execution time of all completed nodes.voidExecute an action only if dev mode is enabled.booleanCheck if developer mode is enabled.booleanCheck if step-by-step execution mode is enabled.booleanCheck if verbose HTTP logging is enabled.voidLog an execution event.voidlogHttpRequest(String nodeId, String method, String url, Map<String, String> requestHeaders, String requestBody, int responseStatus, Map<String, String> responseHeaders, String responseBody, long durationMs) Log an HTTP request/response for verbose mode.longrecordNodeEnd(String nodeId, boolean success, String error) Record the end of a node execution.voidrecordNodeStart(String nodeId, String nodeName, String nodeType) Record the start of a node execution.voidremoveStepExecutionListener(ai.nervemind.common.service.DevModeServiceInterface.StepExecutionListener listener) Removes a step execution listener.voidReset step execution state (call at execution start).voidsetStepExecutionEnabled(boolean enabled) Enable or disable step-by-step execution mode.booleanwaitForStepContinue(String nodeId, String nodeName) Wait for step continuation if in step mode.
-
Constructor Details
-
DevModeService
public DevModeService(ai.nervemind.common.service.SettingsServiceInterface settingsService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates the DevModeService with required dependencies.- Parameters:
settingsService- the settings service for reading dev mode stateobjectMapper- the JSON object mapper for serialization
-
-
Method Details
-
isDevModeEnabled
public boolean isDevModeEnabled()Check if developer mode is enabled.- Specified by:
isDevModeEnabledin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- true if developer mode is enabled in settings
-
ifDevMode
Execute an action only if dev mode is enabled.- Specified by:
ifDevModein interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
action- the action to execute
-
recordNodeStart
Record the start of a node execution.- Specified by:
recordNodeStartin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
nodeId- the node IDnodeName- the node display namenodeType- the node type
-
recordNodeEnd
Record the end of a node execution.- Specified by:
recordNodeEndin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
nodeId- the node IDsuccess- whether execution succeedederror- error message if failed- Returns:
- the duration in milliseconds, or -1 if not tracked
-
getNodeTiming
Get timing information for a node.- Parameters:
nodeId- the node ID- Returns:
- timing info, or null if not available
-
getAllNodeTimings
Get all node timings for the current execution.- Returns:
- map of node ID to timing info
-
clearTimings
public void clearTimings()Clear all timing data (call at execution start).- Specified by:
clearTimingsin interfaceai.nervemind.common.service.DevModeServiceInterface
-
formatTimingSummary
Format a timing summary for console display.- Specified by:
formatTimingSummaryin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- formatted timing summary string
-
logExecutionEvent
public void logExecutionEvent(String level, String nodeId, String nodeName, String message, Object data) Log an execution event.- Specified by:
logExecutionEventin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
level- log level (INFO, WARN, ERROR, DEBUG)nodeId- node ID (can be null for workflow-level events)nodeName- node name (can be null)message- log messagedata- optional data object to include
-
getExecutionLog
Get all execution log entries.- Returns:
- list of log entries
-
logHttpRequest
public void logHttpRequest(String nodeId, String method, String url, Map<String, String> requestHeaders, String requestBody, int responseStatus, Map<String, String> responseHeaders, String responseBody, long durationMs) Log an HTTP request/response for verbose mode.- Specified by:
logHttpRequestin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
nodeId- the node ID making the requestmethod- HTTP methodurl- request URLrequestHeaders- request headersrequestBody- request body (truncated for preview)responseStatus- response status coderesponseHeaders- response headersresponseBody- response body (truncated for preview)durationMs- request duration
-
getHttpRequestLogs
Get HTTP request logs.- Specified by:
getHttpRequestLogsin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- list of HTTP request logs
-
formatHttpLogs
Format HTTP request logs as a readable string.- Specified by:
formatHttpLogsin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- formatted HTTP logs string
-
clearHttpRequestLogs
public void clearHttpRequestLogs()Clear HTTP request logs.- Specified by:
clearHttpRequestLogsin interfaceai.nervemind.common.service.DevModeServiceInterface
-
exportDebugBundle
public Path exportDebugBundle(ai.nervemind.common.dto.WorkflowDTO workflow, Path outputPath, String executionId) throws IOException Export a debug bundle containing workflow, execution data, and logs.- Specified by:
exportDebugBundlein interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
workflow- the workflow to includeoutputPath- the output directory pathexecutionId- the execution ID (can be null)- Returns:
- the path to the created bundle file
- Throws:
IOException- if export fails
-
exportNodeAsJson
-
buildExpressionContext
public Object buildExpressionContext(Map<String, Object> variables, Map<String, Object> nodeOutputs, Map<String, Object> workflowData) Build expression context for inspection.- Specified by:
buildExpressionContextin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
variables- current workflow variablesnodeOutputs- outputs from previous nodesworkflowData- workflow-level data- Returns:
- formatted expression context
-
formatExpressionContext
-
isVerboseHttpLoggingEnabled
public boolean isVerboseHttpLoggingEnabled()Check if verbose HTTP logging is enabled. This is a subset of dev mode for HTTP-specific logging.- Specified by:
isVerboseHttpLoggingEnabledin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- true if verbose HTTP logging should be used
-
getTimedNodeCount
public int getTimedNodeCount()Get the total number of nodes timed in current execution.- Specified by:
getTimedNodeCountin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- count of timed nodes
-
getTotalExecutionTime
public long getTotalExecutionTime()Get the total execution time of all completed nodes.- Specified by:
getTotalExecutionTimein interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- total duration in milliseconds
-
isStepExecutionEnabled
public boolean isStepExecutionEnabled()Check if step-by-step execution mode is enabled.- Specified by:
isStepExecutionEnabledin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- true if step mode is active
-
setStepExecutionEnabled
public void setStepExecutionEnabled(boolean enabled) Enable or disable step-by-step execution mode.- Specified by:
setStepExecutionEnabledin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
enabled- true to enable step mode
-
waitForStepContinue
Wait for step continuation if in step mode. Called by execution service after each node.- Specified by:
waitForStepContinuein interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
nodeId- the node that just completednodeName- the node name- Returns:
- true if execution should continue, false if cancelled
- Throws:
InterruptedException- if waiting is interrupted
-
continueStep
public void continueStep()Signal to continue to the next step. Called by UI when user clicks Continue.- Specified by:
continueStepin interfaceai.nervemind.common.service.DevModeServiceInterface
-
cancelStepExecution
public void cancelStepExecution()Signal to cancel step execution. Called by UI when user clicks Cancel/Stop.- Specified by:
cancelStepExecutionin interfaceai.nervemind.common.service.DevModeServiceInterface
-
resetStepExecution
public void resetStepExecution()Reset step execution state (call at execution start).- Specified by:
resetStepExecutionin interfaceai.nervemind.common.service.DevModeServiceInterface
-
getPausedNodeId
Get the node ID that is currently paused (if any).- Specified by:
getPausedNodeIdin interfaceai.nervemind.common.service.DevModeServiceInterface- Returns:
- node ID of paused node, or null if not paused
-
addStepExecutionListener
public void addStepExecutionListener(ai.nervemind.common.service.DevModeServiceInterface.StepExecutionListener listener) Adds a listener for step execution events.- Specified by:
addStepExecutionListenerin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
listener- the listener to add
-
removeStepExecutionListener
public void removeStepExecutionListener(ai.nervemind.common.service.DevModeServiceInterface.StepExecutionListener listener) Removes a step execution listener.- Specified by:
removeStepExecutionListenerin interfaceai.nervemind.common.service.DevModeServiceInterface- Parameters:
listener- the listener to remove
-