/**
 * JSON-RPC Protocol for code-buddy External Integration
 *
 * This protocol is designed for loose coupling - any client can use it.
 * No dependencies on FileCommander or any specific application.
 *
 * Transport: stdin/stdout (line-delimited JSON)
 * Protocol: JSON-RPC 2.0
 */
// ============================================
// Error Codes (JSON-RPC 2.0 + Custom)
// ============================================
export const ErrorCodes = {
    // JSON-RPC 2.0 standard errors
    PARSE_ERROR: -32700,
    INVALID_REQUEST: -32600,
    METHOD_NOT_FOUND: -32601,
    INVALID_PARAMS: -32602,
    INTERNAL_ERROR: -32603,
    // Custom errors (application-specific: -32000 to -32099)
    NOT_INITIALIZED: -32001,
    OPERATION_CANCELLED: -32002,
    TIMEOUT: -32003,
    FILE_NOT_FOUND: -32004,
    PERMISSION_DENIED: -32005,
    AI_ERROR: -32006,
    TOOL_ERROR: -32007,
};
// ============================================
// Helper Functions
// ============================================
export function createRequest(id, method, params) {
    return {
        jsonrpc: '2.0',
        id,
        method,
        params: params,
    };
}
export function createResponse(id, result) {
    return {
        jsonrpc: '2.0',
        id,
        result,
    };
}
export function createErrorResponse(id, code, message, data) {
    return {
        jsonrpc: '2.0',
        id,
        error: { code, message, data },
    };
}
export function createNotification(method, params) {
    return {
        jsonrpc: '2.0',
        method,
        params,
    };
}
export function isRequest(msg) {
    return (typeof msg === 'object' &&
        msg !== null &&
        'jsonrpc' in msg &&
        msg.jsonrpc === '2.0' &&
        'method' in msg &&
        'id' in msg);
}
export function isNotification(msg) {
    return (typeof msg === 'object' &&
        msg !== null &&
        'jsonrpc' in msg &&
        msg.jsonrpc === '2.0' &&
        'method' in msg &&
        !('id' in msg));
}
//# sourceMappingURL=protocol.js.map