@bloopai/debugger-mcp
Version:
An MCP server that provides interactive debugging capabilities to AI coding agents
109 lines (108 loc) • 3.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WrappedDebugSession = exports.EvaluationError = exports.BreakpointError = exports.InvalidStateError = exports.SessionNotFoundError = exports.DebuggerError = exports.DebuggerErrorCode = exports.SessionState = void 0;
/**
* Represents the state of a debug session
*/
var SessionState;
(function (SessionState) {
SessionState["INITIALIZING"] = "initializing";
SessionState["CONFIGURED"] = "configured";
SessionState["RUNNING"] = "running";
SessionState["STOPPED"] = "stopped";
SessionState["TERMINATED"] = "terminated";
})(SessionState || (exports.SessionState = SessionState = {}));
/**
* Error codes specific to the debugger
*/
var DebuggerErrorCode;
(function (DebuggerErrorCode) {
DebuggerErrorCode["SESSION_NOT_FOUND"] = "SESSION_NOT_FOUND";
DebuggerErrorCode["INVALID_STATE"] = "INVALID_STATE";
DebuggerErrorCode["BREAKPOINT_ERROR"] = "BREAKPOINT_ERROR";
DebuggerErrorCode["EVALUATION_ERROR"] = "EVALUATION_ERROR";
DebuggerErrorCode["ADAPTER_ERROR"] = "ADAPTER_ERROR";
DebuggerErrorCode["TIMEOUT"] = "TIMEOUT";
})(DebuggerErrorCode || (exports.DebuggerErrorCode = DebuggerErrorCode = {}));
/**
* Base class for debugger errors
*/
class DebuggerError extends Error {
code;
constructor(message, code) {
super(message);
this.code = code;
this.name = 'DebuggerError';
}
}
exports.DebuggerError = DebuggerError;
/**
* Error thrown when a session is not found
*/
class SessionNotFoundError extends DebuggerError {
constructor(sessionId) {
super(`Debug session with ID ${sessionId} not found`, DebuggerErrorCode.SESSION_NOT_FOUND);
this.name = 'SessionNotFoundError';
}
}
exports.SessionNotFoundError = SessionNotFoundError;
/**
* Error thrown when a session is in an invalid state for an operation
*/
class InvalidStateError extends DebuggerError {
constructor(sessionId, currentState, expectedStates) {
super(`Session ${sessionId} is in state ${currentState}, expected one of: ${expectedStates.join(', ')}`, DebuggerErrorCode.INVALID_STATE);
this.name = 'InvalidStateError';
}
}
exports.InvalidStateError = InvalidStateError;
/**
* Error thrown when a breakpoint operation fails
*/
class BreakpointError extends DebuggerError {
filePath;
line;
constructor(message, filePath, line) {
super(message, DebuggerErrorCode.BREAKPOINT_ERROR);
this.filePath = filePath;
this.line = line;
this.name = 'BreakpointError';
}
}
exports.BreakpointError = BreakpointError;
/**
* Error thrown when an expression evaluation fails
*/
class EvaluationError extends DebuggerError {
expression;
constructor(message, expression) {
super(message, DebuggerErrorCode.EVALUATION_ERROR);
this.expression = expression;
this.name = 'EvaluationError';
}
}
exports.EvaluationError = EvaluationError;
class WrappedDebugSession {
originalSession;
id;
targetType;
targetPath;
startTime;
logger;
constructor(mcpSessionId, originalSession, targetType, targetPath, startTime, logger) {
this.id = mcpSessionId;
this.originalSession = originalSession;
this.targetType = targetType;
this.targetPath = targetPath;
this.startTime = startTime;
this.logger = logger;
}
get dapSessionHandler() {
return this.originalSession.sessionHandler;
}
get status() {
const handler = this.dapSessionHandler;
return handler ? handler.status : 'terminated';
}
}
exports.WrappedDebugSession = WrappedDebugSession;